├── .project
├── .settings
├── org.eclipse.core.resources.prefs
├── org.eclipse.m2e.core.prefs
└── org.eclipse.wst.common.project.facet.core.xml
├── LICENSE
├── README.md
├── reqifcompiler
├── .classpath
├── .gitignore
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ ├── org.eclipse.jdt.ui.prefs
│ └── org.eclipse.m2e.core.prefs
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── de
│ │ └── kay_muench
│ │ └── reqif10
│ │ └── reqifcompiler
│ │ ├── DateManager.java
│ │ ├── DateValue.java
│ │ ├── DescriptionValue.java
│ │ ├── Headline.java
│ │ ├── IDValue.java
│ │ ├── IdentifierManager.java
│ │ ├── Relation.java
│ │ ├── ReqIF10Compiler.java
│ │ ├── RequirementRankingValue.java
│ │ ├── RequirementStatusValue.java
│ │ ├── SpecObjectFactory.java
│ │ ├── SpecificationOutline.java
│ │ ├── dto
│ │ ├── EnumeratorDTO.java
│ │ ├── ImageRefDTO.java
│ │ ├── RankingDTO.java
│ │ ├── RelationTypeDTO.java
│ │ ├── RequirementDTO.java
│ │ ├── StatusDTO.java
│ │ ├── TextDTO.java
│ │ └── XhtmlUlDTO.java
│ │ ├── types
│ │ ├── complex
│ │ │ ├── AttributesRegistry.java
│ │ │ ├── BaselineSpecObjectType.java
│ │ │ ├── CommonSpecObjectTypeDefinitions.java
│ │ │ ├── ConfigurationSpecObjectType.java
│ │ │ ├── DescriptionAttribute.java
│ │ │ ├── EnumeratedAttributeValue.java
│ │ │ ├── HeadlineType.java
│ │ │ ├── IdentifierAttribute.java
│ │ │ ├── RequirementRankingAttribute.java
│ │ │ ├── RequirementStatusAttribute.java
│ │ │ ├── ScheduledByAttribute.java
│ │ │ ├── SpecRelationTypeWithRelationKind.java
│ │ │ └── SpecTypesRegistry.java
│ │ └── simple
│ │ │ ├── DateType.java
│ │ │ ├── Headline.java
│ │ │ ├── RequirementRanking.java
│ │ │ ├── RequirementStatus.java
│ │ │ ├── SimpleTypesRegistry.java
│ │ │ ├── String32k.java
│ │ │ └── XhtmlType.java
│ │ └── xhtml
│ │ └── XhtmlBuilder.java
│ └── test
│ ├── java
│ └── de
│ │ └── kay_muench
│ │ └── reqif10
│ │ └── reqifcompiler
│ │ ├── LoggingAspect.aj
│ │ └── ReqIF10CompilerTest.java
│ └── resources
│ ├── UT_1000.reqif
│ ├── UT_1001.reqif
│ └── flowers.jpg
├── reqifiterator
├── .classpath
├── .gitignore
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.m2e.core.prefs
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── de
│ │ └── kay_muench
│ │ └── reqif10
│ │ └── reqifiterator
│ │ ├── AttributeHolder.java
│ │ ├── AttributeListener.java
│ │ ├── AttributeValueConverter.java
│ │ ├── DefaultAttributeHolder.java
│ │ ├── DefaultRegistrableListener.java
│ │ ├── I18nableListener.java
│ │ ├── RegistrableListener.java
│ │ ├── ReqIF10Finder.java
│ │ ├── ReqIF10Iterator.java
│ │ ├── ReqIF10ListenerIterator.java
│ │ ├── SpecObjectCallback.java
│ │ ├── SpecObjectDTO.java
│ │ ├── SpecObjectListener.java
│ │ ├── SpecObjectListenerRegistry.java
│ │ ├── SpecRelationCallback.java
│ │ ├── SpecRelationDTO.java
│ │ ├── SpecRelationListener.java
│ │ ├── SpecRelationListenerRegistry.java
│ │ ├── SpecificationCallback.java
│ │ ├── SpecificationDTO.java
│ │ ├── SpecificationListener.java
│ │ ├── SpecificationListenerRegistry.java
│ │ └── XhtmlContentProcessor.java
│ └── test
│ ├── java
│ └── de
│ │ └── kay_muench
│ │ └── reqif10
│ │ └── reqifiterator
│ │ ├── LoggingAspect.aj
│ │ ├── ReqIF10IteratorTest.java
│ │ └── ReqIF10ListenerIteratorTest.java
│ └── resources
│ └── UT_1000.reqif
├── reqifparser
├── .classpath
├── .gitignore
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.m2e.core.prefs
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── de
│ │ └── kay_muench
│ │ └── reqif10
│ │ └── reqifparser
│ │ ├── ReqIF10Parser.java
│ │ └── ToolExRemover.java
│ └── test
│ ├── java
│ └── de
│ │ └── kay_muench
│ │ └── reqif10
│ │ └── reqifparser
│ │ └── ReqIF10ParserTest.java
│ └── resources
│ └── UT_1000.reqif
└── reqiftools-parent
├── .project
├── .settings
└── org.eclipse.m2e.core.prefs
├── LICENSE
└── pom.xml
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | reqiftools
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.wst.common.project.facet.core.nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 1.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6 |
7 | 1. DEFINITIONS
8 |
9 | "Contribution" means:
10 |
11 | a) in the case of the initial Contributor, the initial code and documentation
12 | distributed under this Agreement, and
13 | b) in the case of each subsequent Contributor:
14 | i) changes to the Program, and
15 | ii) additions to the Program;
16 |
17 | where such changes and/or additions to the Program originate from and are
18 | distributed by that particular Contributor. A Contribution 'originates'
19 | from a Contributor if it was added to the Program by such Contributor
20 | itself or anyone acting on such Contributor's behalf. Contributions do not
21 | include additions to the Program which: (i) are separate modules of
22 | software distributed in conjunction with the Program under their own
23 | license agreement, and (ii) are not derivative works of the Program.
24 |
25 | "Contributor" means any person or entity that distributes the Program.
26 |
27 | "Licensed Patents" mean patent claims licensable by a Contributor which are
28 | necessarily infringed by the use or sale of its Contribution alone or when
29 | combined with the Program.
30 |
31 | "Program" means the Contributions distributed in accordance with this
32 | Agreement.
33 |
34 | "Recipient" means anyone who receives the Program under this Agreement,
35 | including all Contributors.
36 |
37 | 2. GRANT OF RIGHTS
38 | a) Subject to the terms of this Agreement, each Contributor hereby grants
39 | Recipient a non-exclusive, worldwide, royalty-free copyright license to
40 | reproduce, prepare derivative works of, publicly display, publicly
41 | perform, distribute and sublicense the Contribution of such Contributor,
42 | if any, and such derivative works, in source code and object code form.
43 | b) Subject to the terms of this Agreement, each Contributor hereby grants
44 | Recipient a non-exclusive, worldwide, royalty-free patent license under
45 | Licensed Patents to make, use, sell, offer to sell, import and otherwise
46 | transfer the Contribution of such Contributor, if any, in source code and
47 | object code form. This patent license shall apply to the combination of
48 | the Contribution and the Program if, at the time the Contribution is
49 | added by the Contributor, such addition of the Contribution causes such
50 | combination to be covered by the Licensed Patents. The patent license
51 | shall not apply to any other combinations which include the Contribution.
52 | No hardware per se is licensed hereunder.
53 | c) Recipient understands that although each Contributor grants the licenses
54 | to its Contributions set forth herein, no assurances are provided by any
55 | Contributor that the Program does not infringe the patent or other
56 | intellectual property rights of any other entity. Each Contributor
57 | disclaims any liability to Recipient for claims brought by any other
58 | entity based on infringement of intellectual property rights or
59 | otherwise. As a condition to exercising the rights and licenses granted
60 | hereunder, each Recipient hereby assumes sole responsibility to secure
61 | any other intellectual property rights needed, if any. For example, if a
62 | third party patent license is required to allow Recipient to distribute
63 | the Program, it is Recipient's responsibility to acquire that license
64 | before distributing the Program.
65 | d) Each Contributor represents that to its knowledge it has sufficient
66 | copyright rights in its Contribution, if any, to grant the copyright
67 | license set forth in this Agreement.
68 |
69 | 3. REQUIREMENTS
70 |
71 | A Contributor may choose to distribute the Program in object code form under
72 | its own license agreement, provided that:
73 |
74 | a) it complies with the terms and conditions of this Agreement; and
75 | b) its license agreement:
76 | i) effectively disclaims on behalf of all Contributors all warranties
77 | and conditions, express and implied, including warranties or
78 | conditions of title and non-infringement, and implied warranties or
79 | conditions of merchantability and fitness for a particular purpose;
80 | ii) effectively excludes on behalf of all Contributors all liability for
81 | damages, including direct, indirect, special, incidental and
82 | consequential damages, such as lost profits;
83 | iii) states that any provisions which differ from this Agreement are
84 | offered by that Contributor alone and not by any other party; and
85 | iv) states that source code for the Program is available from such
86 | Contributor, and informs licensees how to obtain it in a reasonable
87 | manner on or through a medium customarily used for software exchange.
88 |
89 | When the Program is made available in source code form:
90 |
91 | a) it must be made available under this Agreement; and
92 | b) a copy of this Agreement must be included with each copy of the Program.
93 | Contributors may not remove or alter any copyright notices contained
94 | within the Program.
95 |
96 | Each Contributor must identify itself as the originator of its Contribution,
97 | if
98 | any, in a manner that reasonably allows subsequent Recipients to identify the
99 | originator of the Contribution.
100 |
101 | 4. COMMERCIAL DISTRIBUTION
102 |
103 | Commercial distributors of software may accept certain responsibilities with
104 | respect to end users, business partners and the like. While this license is
105 | intended to facilitate the commercial use of the Program, the Contributor who
106 | includes the Program in a commercial product offering should do so in a manner
107 | which does not create potential liability for other Contributors. Therefore,
108 | if a Contributor includes the Program in a commercial product offering, such
109 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
110 | every other Contributor ("Indemnified Contributor") against any losses,
111 | damages and costs (collectively "Losses") arising from claims, lawsuits and
112 | other legal actions brought by a third party against the Indemnified
113 | Contributor to the extent caused by the acts or omissions of such Commercial
114 | Contributor in connection with its distribution of the Program in a commercial
115 | product offering. The obligations in this section do not apply to any claims
116 | or Losses relating to any actual or alleged intellectual property
117 | infringement. In order to qualify, an Indemnified Contributor must:
118 | a) promptly notify the Commercial Contributor in writing of such claim, and
119 | b) allow the Commercial Contributor to control, and cooperate with the
120 | Commercial Contributor in, the defense and any related settlement
121 | negotiations. The Indemnified Contributor may participate in any such claim at
122 | its own expense.
123 |
124 | For example, a Contributor might include the Program in a commercial product
125 | offering, Product X. That Contributor is then a Commercial Contributor. If
126 | that Commercial Contributor then makes performance claims, or offers
127 | warranties related to Product X, those performance claims and warranties are
128 | such Commercial Contributor's responsibility alone. Under this section, the
129 | Commercial Contributor would have to defend claims against the other
130 | Contributors related to those performance claims and warranties, and if a
131 | court requires any other Contributor to pay any damages as a result, the
132 | Commercial Contributor must pay those damages.
133 |
134 | 5. NO WARRANTY
135 |
136 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
137 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
138 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
139 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
140 | Recipient is solely responsible for determining the appropriateness of using
141 | and distributing the Program and assumes all risks associated with its
142 | exercise of rights under this Agreement , including but not limited to the
143 | risks and costs of program errors, compliance with applicable laws, damage to
144 | or loss of data, programs or equipment, and unavailability or interruption of
145 | operations.
146 |
147 | 6. DISCLAIMER OF LIABILITY
148 |
149 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
150 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
151 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
152 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
153 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
154 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
155 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
156 | OF SUCH DAMAGES.
157 |
158 | 7. GENERAL
159 |
160 | If any provision of this Agreement is invalid or unenforceable under
161 | applicable law, it shall not affect the validity or enforceability of the
162 | remainder of the terms of this Agreement, and without further action by the
163 | parties hereto, such provision shall be reformed to the minimum extent
164 | necessary to make such provision valid and enforceable.
165 |
166 | If Recipient institutes patent litigation against any entity (including a
167 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself
168 | (excluding combinations of the Program with other software or hardware)
169 | infringes such Recipient's patent(s), then such Recipient's rights granted
170 | under Section 2(b) shall terminate as of the date such litigation is filed.
171 |
172 | All Recipient's rights under this Agreement shall terminate if it fails to
173 | comply with any of the material terms or conditions of this Agreement and does
174 | not cure such failure in a reasonable period of time after becoming aware of
175 | such noncompliance. If all Recipient's rights under this Agreement terminate,
176 | Recipient agrees to cease use and distribution of the Program as soon as
177 | reasonably practicable. However, Recipient's obligations under this Agreement
178 | and any licenses granted by Recipient relating to the Program shall continue
179 | and survive.
180 |
181 | Everyone is permitted to copy and distribute copies of this Agreement, but in
182 | order to avoid inconsistency the Agreement is copyrighted and may only be
183 | modified in the following manner. The Agreement Steward reserves the right to
184 | publish new versions (including revisions) of this Agreement from time to
185 | time. No one other than the Agreement Steward has the right to modify this
186 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The
187 | Eclipse Foundation may assign the responsibility to serve as the Agreement
188 | Steward to a suitable separate entity. Each new version of the Agreement will
189 | be given a distinguishing version number. The Program (including
190 | Contributions) may always be distributed subject to the version of the
191 | Agreement under which it was received. In addition, after a new version of the
192 | Agreement is published, Contributor may elect to distribute the Program
193 | (including its Contributions) under the new version. Except as expressly
194 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
195 | licenses to the intellectual property of any Contributor under this Agreement,
196 | whether expressly, by implication, estoppel or otherwise. All rights in the
197 | Program not expressly granted under this Agreement are reserved.
198 |
199 | This Agreement is governed by the laws of the State of New York and the
200 | intellectual property laws of the United States of America. No party to this
201 | Agreement will bring a legal action under this Agreement more than one year
202 | after the cause of action arose. Each party waives its rights to a jury trial in
203 | any resulting litigation.
204 |
205 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | reqiftools
2 | ==========
3 |
4 | A tool collection for handling the Requirements Interchange Format
5 |
6 | Motivation or "why these tools?"
7 | --------------------------------
8 |
9 | Working in the requirements business isn't that easy.
10 | Not only the engineering part but also the management calls for a
11 | lot of tasks to do and to think about.
12 |
13 | I don't know the origin of this advice, but for me it has always
14 | been a leading light at the horizon:
15 |
16 | If you can, automate!
17 |
18 | Fortunately for managing requirements there is a standard
19 | for exchanging them, developed under the Object Management Group,
20 | the [Requirements Interchange Format](http://www.omg.org/spec/ReqIF/) ReqIF.
21 |
22 | A good article (http://re-magazine.ireb.org/issues/2014-3-gaining-height/open-up/)
23 | about the history and current state, written by Michael Jastram, can be found in the
24 | [Requirements Engineering Magazine](http://re-magazine.ireb.org/).
25 |
26 | Not only there is a standard, there are some tools too.
27 | One I would recommend is the [Eclipse Requirements Modeling Framework](https://www.eclipse.org/rmf/) RMF.
28 |
29 | Due to its Eclipse-nature the main focus, I think, lies in building Eclipse based
30 | tools, which is a well-founded goal, but not enough automation for me.
31 | Fortunately again, the RMF not only includes an IDE for working with
32 | ReqIF formatted files, called ProR, but also a number of plugins usable as
33 | packages outside of Eclipse. They build the basis of this work.
34 |
35 | The reqiftools shall wrap up the RMF packages to simplify creating and
36 | parsing ReqIF formatted files, used by perhaps a maven based toolchain
37 | or by yet another requirements tool.
38 |
39 |
40 | ReqIF-Compiler
41 | --------------
42 |
43 | The ReqIF-Compiler simplifies the creation of a specification by shifting
44 | levels up and down in a hierarchy, marked up with headlines, and supplying requirements
45 | by adding specification objects at the current level.
46 |
47 | Requirements have only a few attributes:
48 | * an ID,
49 | * an XHTML-based description,
50 | * an optional date,
51 | * a status marker
52 | * a priority marker and
53 | * a risk marker.
54 |
55 |
56 | ReqIF-Parser
57 | ------------
58 |
59 | The ReqIF-Parser reads files in ReqIF-format and returns an RMF ReqIF object.
60 |
61 |
62 | ReqIF-Iterator
63 | --------------
64 |
65 | Simple recursive callback-based iterator through specifications.
66 |
--------------------------------------------------------------------------------
/reqifcompiler/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/reqifcompiler/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/reqifcompiler/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | reqifcompiler
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.ajdt.core.ajbuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.ajdt.ui.ajnature
21 | org.eclipse.jdt.core.javanature
22 | org.eclipse.m2e.core.maven2Nature
23 |
24 |
25 |
--------------------------------------------------------------------------------
/reqifcompiler/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/test/java=UTF-8
4 | encoding//src/test/resources=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/reqifcompiler/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4 | org.eclipse.jdt.core.compiler.compliance=1.7
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8 | org.eclipse.jdt.core.compiler.source=1.7
9 |
--------------------------------------------------------------------------------
/reqifcompiler/.settings/org.eclipse.jdt.ui.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.ui.javadoc=false
3 | org.eclipse.jdt.ui.text.custom_code_templates=/**\n * @return the ${bare_field_name}\n *//**\n * @param ${param} the ${bare_field_name} to set\n *//**\n * ${tags}\n *//**\n * Copyright (c) 2014 Kay Erik M\u00FCnch.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.spdx.org/licenses/EPL-1.0\n * \n * Contributors\:\n * Kay Erik M\u00FCnch - initial API and implementation\n * \n *//**\n * @author ${user}\n *\n * ${tags}\n *//**\n * \n *//**\n * ${tags}\n *//* (non-Javadoc)\n * ${see_to_overridden}\n *//**\n * ${tags}\n * ${see_to_target}\n */${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}\n\n\n\n// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();// ${todo} Auto-generated method stub\n${body_statement}${body_statement}\n// ${todo} Auto-generated constructor stubreturn ${field};${field} \= ${param};
4 |
--------------------------------------------------------------------------------
/reqifcompiler/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/reqifcompiler/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | reqifcompiler
6 | jar
7 |
8 | reqifcompiler
9 |
10 |
11 | Eclipse Public License 1.0
12 | http://www.spdx.org/licenses/EPL-1.0
13 | Copyright (c) 2014 Kay Erik Münch. All rights reserved.
14 | This program and the accompanying materials are made available under the
15 | terms of the Eclipse Public License v1.0 which accompanies this distribution,
16 | and is available at http://www.spdx.org/licenses/EPL-1.0
17 |
18 |
19 |
20 |
21 | UTF-8
22 |
23 |
24 |
25 |
26 | org.eclipse.emf
27 | org.eclipse.emf.ecore.xmi
28 |
29 |
30 | org.eclipse.emf
31 | org.eclipse.emf.ecore
32 |
33 |
34 | org.eclipse.emf
35 | org.eclipse.emf.common
36 |
37 |
38 | org.eclipse.rmf
39 | org.eclipse.rmf.reqif10
40 |
41 |
42 | org.eclipse.rmf
43 | org.eclipse.rmf.reqif10.common
44 |
45 |
46 | org.eclipse.rmf
47 | org.eclipse.rmf.reqif10.xhtml
48 |
49 |
50 | org.eclipse.rmf
51 | org.eclipse.rmf.serialization
52 |
53 |
54 | de.kay-muench
55 | imageinformationprovider
56 |
57 |
58 | junit
59 | junit
60 | test
61 |
62 |
63 | org.aspectj
64 | aspectjrt
65 | test
66 |
67 |
68 |
69 | de.kay-muench.reqif10
70 | reqif-parent
71 | 0.0.1-SNAPSHOT
72 | ../reqiftools-parent
73 |
74 |
75 |
76 |
77 | org.apache.maven.plugins
78 | maven-compiler-plugin
79 | 3.1
80 |
81 | 1.7
82 | 1.7
83 |
84 |
85 |
86 |
87 |
88 | scm:git:https://github.com/KayErikMuench/reqiftools.git
89 | scm:git:https://github.com/KayErikMuench/reqiftools.git
90 | https://github.com/KayErikMuench/reqiftools
91 |
92 |
93 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/DateManager.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import java.util.Date;
15 | import java.util.GregorianCalendar;
16 | import java.util.TimeZone;
17 |
18 | import javax.xml.datatype.DatatypeConfigurationException;
19 | import javax.xml.datatype.XMLGregorianCalendar;
20 |
21 | import org.eclipse.emf.ecore.util.EcoreUtil;
22 | import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
23 |
24 | public class DateManager {
25 | private static boolean predictabilityEnabled = false;
26 |
27 | public static void enablePredictableId() {
28 | predictabilityEnabled = true;
29 | }
30 |
31 | public static GregorianCalendar getCurrentDate()
32 | throws DatatypeConfigurationException {
33 | GregorianCalendar calendar = new GregorianCalendar();
34 | if (predictabilityEnabled) {
35 | calendar.setTimeInMillis(0);
36 | calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
37 | } else {
38 | calendar.setTime(new Date());
39 | }
40 | return calendar;
41 | }
42 |
43 | public static GregorianCalendar toDate(String date)
44 | throws DatatypeConfigurationException {
45 | XMLGregorianCalendar xmlGregoriaCalendar = (XMLGregorianCalendar) EcoreUtil
46 | .createFromString(XMLTypePackage.eINSTANCE.getDateTime(), date);
47 | return xmlGregoriaCalendar.toGregorianCalendar();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/DateValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.AttributeValueDate;
17 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
18 | import org.eclipse.rmf.reqif10.SpecObject;
19 |
20 | import de.kay_muench.reqif10.reqifcompiler.types.complex.ScheduledByAttribute;
21 |
22 | class DateValue {
23 | private AttributeValueDate value;
24 |
25 | DateValue(final ScheduledByAttribute type,
26 | final SpecObject specObject) {
27 | value = ReqIF10Factory.eINSTANCE.createAttributeValueDate();
28 | value.setDefinition(type.getDef());
29 | specObject.getValues().add(value);
30 | }
31 |
32 | void setDate(final String date) throws DatatypeConfigurationException {
33 | value.setTheValue(DateManager.toDate(date));
34 | }
35 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/DescriptionValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import org.eclipse.rmf.reqif10.AttributeValueXHTML;
15 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
16 | import org.eclipse.rmf.reqif10.SpecObject;
17 | import org.eclipse.rmf.reqif10.XhtmlContent;
18 | import org.eclipse.rmf.reqif10.xhtml.XhtmlDivType;
19 | import org.eclipse.rmf.reqif10.xhtml.XhtmlFactory;
20 |
21 | import de.kay_muench.reqif10.reqifcompiler.types.complex.DescriptionAttribute;
22 | import de.kay_muench.reqif10.reqifcompiler.xhtml.XhtmlBuilder;
23 |
24 | class DescriptionValue {
25 | private AttributeValueXHTML value;
26 |
27 | DescriptionValue(final DescriptionAttribute type,
28 | final SpecObject specObject) {
29 | value = ReqIF10Factory.eINSTANCE.createAttributeValueXHTML();
30 | value.setDefinition(type.getDef());
31 | specObject.getValues().add(value);
32 | }
33 |
34 | void setDescription(final XhtmlBuilder builder) {
35 | XhtmlContent content = ReqIF10Factory.eINSTANCE.createXhtmlContent();
36 |
37 | XhtmlDivType type = XhtmlFactory.eINSTANCE.createXhtmlDivType();
38 | type.setClass("requirement");
39 | type.getDiv().addAll(builder.build());
40 | content.setXhtml(type);
41 |
42 | value.setTheValue(content);
43 | }
44 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/Headline.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
15 | import org.eclipse.rmf.reqif10.SpecObject;
16 |
17 | import de.kay_muench.reqif10.reqifcompiler.types.complex.HeadlineType;
18 |
19 | class Headline {
20 | private IDValue attributeValueID;
21 | private SpecObject specObject;
22 |
23 | Headline(final HeadlineType type, final String id) {
24 | specObject = ReqIF10Factory.eINSTANCE.createSpecObject();
25 | specObject.setIdentifier(IdentifierManager.generateIdentifier());
26 | specObject.setType(type.getDef());
27 |
28 | attributeValueID = new IDValue(type.getId(), specObject);
29 |
30 | this.setId(id);
31 | }
32 |
33 | void setId(String id) {
34 | attributeValueID.setId(id);
35 | }
36 |
37 | SpecObject getObj() {
38 | return specObject;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/IDValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import org.eclipse.rmf.reqif10.AttributeValueString;
15 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
16 | import org.eclipse.rmf.reqif10.SpecElementWithAttributes;
17 |
18 | import de.kay_muench.reqif10.reqifcompiler.types.complex.IdentifierAttribute;
19 |
20 | class IDValue {
21 | private AttributeValueString value;
22 |
23 | IDValue(final IdentifierAttribute type,
24 | final SpecElementWithAttributes elementWithAttributes) {
25 | value = ReqIF10Factory.eINSTANCE.createAttributeValueString();
26 | value.setDefinition(type.getDef());
27 | elementWithAttributes.getValues().add(value);
28 | }
29 |
30 | void setId(final String id) {
31 | value.setTheValue(id);
32 | }
33 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/IdentifierManager.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import java.util.UUID;
15 |
16 | public final class IdentifierManager {
17 | private static boolean predictabilityEnabled = false;
18 | private static long predictableId = 1L;
19 |
20 | public static void enablePredictableId() {
21 | predictabilityEnabled = true;
22 | }
23 |
24 | public static String generateIdentifier() {
25 | if (predictabilityEnabled) {
26 | predictableId += 1L;
27 | return "" + predictableId;
28 | }
29 | return "requie-tool-" + UUID.randomUUID().toString();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/Relation.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import de.kay_muench.reqif10.reqifcompiler.dto.RelationTypeDTO;
15 | import de.kay_muench.reqif10.reqifcompiler.dto.RequirementDTO;
16 |
17 |
18 | public class Relation {
19 | private final RelationTypeDTO relationKind;
20 | private final RequirementDTO src;
21 | private final RequirementDTO dest;
22 |
23 | public Relation(RelationTypeDTO relationType, RequirementDTO src, RequirementDTO dest) {
24 | this.relationKind = relationType;
25 | this.src = src;
26 | this.dest = dest;
27 | }
28 |
29 | public RelationTypeDTO getRelationKind() {
30 | return relationKind;
31 | }
32 |
33 | public RequirementDTO getSrc() {
34 | return src;
35 | }
36 |
37 | public RequirementDTO getDest() {
38 | return dest;
39 | }
40 |
41 | public String getName() {
42 | return this.src.getName() + " -> " + this.dest.getName();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/ReqIF10Compiler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import java.io.ByteArrayOutputStream;
15 | import java.io.OutputStream;
16 | import java.util.HashMap;
17 | import java.util.LinkedList;
18 | import java.util.List;
19 | import java.util.Locale;
20 | import java.util.Map;
21 |
22 | import org.eclipse.emf.common.util.URI;
23 | import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
24 | import org.eclipse.emf.ecore.xmi.XMLResource;
25 | import org.eclipse.rmf.reqif10.AttributeValueString;
26 | import org.eclipse.rmf.reqif10.DatatypeDefinition;
27 | import org.eclipse.rmf.reqif10.ReqIF;
28 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
29 | import org.eclipse.rmf.reqif10.ReqIFContent;
30 | import org.eclipse.rmf.reqif10.ReqIFHeader;
31 | import org.eclipse.rmf.reqif10.SpecHierarchy;
32 | import org.eclipse.rmf.reqif10.SpecObject;
33 | import org.eclipse.rmf.reqif10.SpecRelation;
34 | import org.eclipse.rmf.reqif10.SpecType;
35 | import org.eclipse.rmf.reqif10.Specification;
36 | import org.eclipse.rmf.serialization.XMLPersistenceMappingResourceFactoryImpl;
37 |
38 | import de.kay_muench.reqif10.reqifcompiler.dto.RankingDTO;
39 | import de.kay_muench.reqif10.reqifcompiler.dto.RelationTypeDTO;
40 | import de.kay_muench.reqif10.reqifcompiler.dto.RequirementDTO;
41 | import de.kay_muench.reqif10.reqifcompiler.dto.StatusDTO;
42 | import de.kay_muench.reqif10.reqifcompiler.types.complex.SpecTypesRegistry;
43 | import de.kay_muench.reqif10.reqifcompiler.types.simple.SimpleTypesRegistry;
44 | import de.kay_muench.reqif10.reqifcompiler.xhtml.XhtmlBuilder;
45 |
46 | public final class ReqIF10Compiler {
47 |
48 | private class TypeRegistry {
49 |
50 | private SimpleTypesRegistry simpleTypesRegistry = new SimpleTypesRegistry();
51 | private SpecTypesRegistry specTypesRegistry = new SpecTypesRegistry(
52 | simpleTypesRegistry);
53 |
54 | public TypeRegistry() throws Exception {
55 | }
56 |
57 | public List getDatatypes() {
58 | List definitions = new LinkedList();
59 | definitions.addAll(simpleTypesRegistry.getDatatypes());
60 | return definitions;
61 | }
62 |
63 | public List getSpectypes() {
64 | List types = new LinkedList();
65 | types.addAll(specTypesRegistry.getSpectypes());
66 | return types;
67 | }
68 |
69 | }
70 |
71 | private TypeRegistry typeRegistry;
72 | private ReqIF reqIF;
73 | private SpecObjectFactory specObjectFactory;
74 | private SpecificationOutline outline = SpecificationOutline.newInstance();
75 | private List relations;
76 | private Map idSpecobjectMap;
77 |
78 | public void initialize() throws Exception {
79 | typeRegistry = new TypeRegistry();
80 | reqIF = ReqIF10Factory.eINSTANCE.createReqIF();
81 | specObjectFactory = new SpecObjectFactory(
82 | typeRegistry.specTypesRegistry.getSpecObjectTypeWithDate(),
83 | typeRegistry.specTypesRegistry.getSpecObjectTypeWithoutDate());
84 | outline.setReqIF(getReqIF());
85 | relations = new LinkedList();
86 | idSpecobjectMap = new HashMap();
87 |
88 | ReqIFContent reqIFContent = ReqIF10Factory.eINSTANCE
89 | .createReqIFContent();
90 | getReqIF().setCoreContent(reqIFContent);
91 |
92 | this.createDatatypes();
93 | this.createSpecTypes();
94 | }
95 |
96 | public String export(String id) throws Exception {
97 | this.createHeader(id);
98 |
99 | ResourceFactoryImpl resourceFactory = new XMLPersistenceMappingResourceFactoryImpl();
100 | URI emfURI = URI.createURI("http://kay-muench.de", true);
101 | XMLResource resource = (XMLResource) resourceFactory
102 | .createResource(emfURI);
103 |
104 | resource.setEncoding("UTF-8");
105 | resource.getContents().add(getReqIF());
106 |
107 | OutputStream os = new ByteArrayOutputStream();
108 | resource.save(os, null);
109 | return os.toString();
110 | }
111 |
112 | private void createHeader(String id) throws Exception {
113 | ReqIFHeader reqIfHeader = ReqIF10Factory.eINSTANCE.createReqIFHeader();
114 | reqIfHeader.setComment("RequieTool export");
115 | reqIfHeader.setIdentifier(IdentifierManager.generateIdentifier());
116 | reqIfHeader.setReqIFToolId("RequieTool (c) Kay Münch");
117 | reqIfHeader.setSourceToolId("RequieTool (c) Kay Münch");
118 | reqIfHeader.setReqIFVersion("1.0");
119 | reqIfHeader.setTitle(id);
120 | reqIfHeader.setCreationTime(DateManager.getCurrentDate());
121 | getReqIF().setTheHeader(reqIfHeader);
122 | }
123 |
124 | private void createDatatypes() throws Exception {
125 | // datatypeDefinitionBoolean =
126 | // ReqIF10Factory.eINSTANCE.createDatatypeDefinitionBoolean();
127 | // datatypeDefinitionBoolean.setIdentifier("ID_TC1000_DatatypeDefinitionBoolean");
128 | // datatypeDefinitionBoolean.setLongName("TC1000 DatatypeDefinitionBoolean");
129 | // datatypeDefinitionBoolean.setLastChange(toDate(LAST_CHANGE_STRING));
130 | //
131 | // datatypeDefinitionInteger =
132 | // ReqIF10Factory.eINSTANCE.createDatatypeDefinitionInteger();
133 | // datatypeDefinitionInteger.setIdentifier("ID_TC1000_DatatypeDefinitionInteger");
134 | // datatypeDefinitionInteger.setLongName("TC1000 DatatypeDefinitionInteger");
135 | // datatypeDefinitionInteger.setLastChange(toDate(LAST_CHANGE_STRING));
136 | // datatypeDefinitionInteger.setMin(new BigInteger("-17496"));
137 | // datatypeDefinitionInteger.setMax(new BigInteger("5000"));
138 | //
139 |
140 | getReqIF().getCoreContent().getDatatypes()
141 | .addAll(this.typeRegistry.getDatatypes());
142 | }
143 |
144 | private void createSpecTypes() throws Exception {
145 | getReqIF().getCoreContent().getSpecTypes()
146 | .addAll(this.typeRegistry.getSpectypes());
147 | }
148 |
149 | public void addSpecObject(String id, XhtmlBuilder builder, String date,
150 | StatusDTO status, RankingDTO importance, RankingDTO risk)
151 | throws Exception {
152 | SpecObject specObject = this.specObjectFactory.newSpecObject(id,
153 | builder, date, status, importance, risk);
154 | idSpecobjectMap.put(id, specObject);
155 | getReqIF().getCoreContent().getSpecObjects().add(specObject);
156 | SpecHierarchy specHierarchy = ReqIF10Factory.eINSTANCE
157 | .createSpecHierarchy();
158 | specHierarchy.setIdentifier(IdentifierManager.generateIdentifier());
159 | specHierarchy.setLongName("SpecHierarchy");
160 | specHierarchy.setObject(specObject);
161 |
162 | this.outline.add(specHierarchy);
163 | }
164 |
165 | public void addSpecification(String idSpec) throws Exception {
166 |
167 | Specification specification = ReqIF10Factory.eINSTANCE
168 | .createSpecification();
169 | specification.setIdentifier(IdentifierManager.generateIdentifier());
170 | specification.setLongName("Spec");
171 | specification.setType(this.typeRegistry.specTypesRegistry
172 | .getSpecificationType());
173 |
174 | IDValue attributeValueID = new IDValue(
175 | this.typeRegistry.specTypesRegistry.getAttributesRegistry()
176 | .getReqIFIDAttrib(), specification);
177 | attributeValueID.setId(idSpec);
178 |
179 | getReqIF().getCoreContent().getSpecifications().add(specification);
180 | this.outline.push(specification);
181 | }
182 |
183 | public void addRelation(RelationTypeDTO type, RequirementDTO src,
184 | RequirementDTO dest) {
185 | relations.add(new Relation(type, src, dest));
186 | }
187 |
188 | public void addSpecRelations() throws Exception {
189 | for (Relation link : this.relations) {
190 | if (idSpecobjectMap.containsKey(link.getSrc().getName())
191 | && idSpecobjectMap.containsKey(link.getDest().getName())) {
192 | SpecObject srcObject = idSpecobjectMap.get(link.getSrc()
193 | .getName());
194 | SpecObject destObject = idSpecobjectMap.get(link.getDest()
195 | .getName());
196 | this.addSpecRelation(link, srcObject, destObject);
197 | }
198 | }
199 | }
200 |
201 | private void addSpecRelation(Relation link, SpecObject source,
202 | SpecObject target) throws Exception {
203 | SpecRelation specRelation = ReqIF10Factory.eINSTANCE
204 | .createSpecRelation();
205 | specRelation.setIdentifier(IdentifierManager.generateIdentifier());
206 | specRelation.setLongName("SpecRelation");
207 | specRelation.setLastChange(DateManager.getCurrentDate());
208 |
209 | specRelation.setSource(source);
210 | specRelation.setTarget(target);
211 | specRelation.setType(this.typeRegistry.specTypesRegistry
212 | .getSpecRelationType().getDef());
213 |
214 | IDValue attributeValueId = new IDValue(
215 | this.typeRegistry.specTypesRegistry.getSpecRelationType()
216 | .getId(), specRelation);
217 | attributeValueId.setId(link.getName());
218 |
219 | AttributeValueString attributeValueString = ReqIF10Factory.eINSTANCE
220 | .createAttributeValueString();
221 | attributeValueString.setDefinition(this.typeRegistry.specTypesRegistry
222 | .getSpecRelationType()
223 | .getSpecRelationTypeAttributeDefinitionString());
224 | attributeValueString.setTheValue(link.getRelationKind().toString()
225 | .toLowerCase(Locale.ENGLISH));
226 | specRelation.getValues().add(attributeValueString);
227 |
228 | getReqIF().getCoreContent().getSpecRelations().add(specRelation);
229 | }
230 |
231 | public void shiftLevelDown(final String title) {
232 | Headline headline = new Headline(
233 | this.typeRegistry.specTypesRegistry.getHeadlineType(), title);
234 | this.outline.shiftLevelDown(headline);
235 | }
236 |
237 | public void shiftLevelUp() {
238 | this.outline.shiftLevelUp();
239 | }
240 |
241 | private ReqIF getReqIF() {
242 | return this.reqIF;
243 | }
244 |
245 | public static ReqIF10Compiler newInstance() {
246 | return new ReqIF10Compiler();
247 | }
248 | }
249 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/RequirementRankingValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import org.eclipse.rmf.reqif10.AttributeValueEnumeration;
15 | import org.eclipse.rmf.reqif10.SpecObject;
16 |
17 | import de.kay_muench.reqif10.reqifcompiler.dto.RankingDTO;
18 | import de.kay_muench.reqif10.reqifcompiler.types.complex.EnumeratedAttributeValue;
19 | import de.kay_muench.reqif10.reqifcompiler.types.complex.RequirementRankingAttribute;
20 |
21 | public class RequirementRankingValue {
22 | private EnumeratedAttributeValue value;
23 |
24 | public RequirementRankingValue(
25 | final RequirementRankingAttribute type,
26 | final SpecObject specObject) {
27 | this(type);
28 | specObject.getValues().add(value.getValue());
29 | }
30 |
31 | public RequirementRankingValue(
32 | final RequirementRankingAttribute type) {
33 | value = new EnumeratedAttributeValue(type.getDef());
34 | }
35 |
36 | void setRanking(RankingDTO ranking) {
37 | value.setValue(ranking.getValue());
38 | }
39 |
40 | public AttributeValueEnumeration getValue() {
41 | return value.getValue();
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/RequirementStatusValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import org.eclipse.rmf.reqif10.AttributeValueEnumeration;
15 | import org.eclipse.rmf.reqif10.SpecObject;
16 |
17 | import de.kay_muench.reqif10.reqifcompiler.dto.StatusDTO;
18 | import de.kay_muench.reqif10.reqifcompiler.types.complex.EnumeratedAttributeValue;
19 | import de.kay_muench.reqif10.reqifcompiler.types.complex.RequirementStatusAttribute;
20 |
21 | public class RequirementStatusValue {
22 | private EnumeratedAttributeValue value;
23 |
24 | public RequirementStatusValue(
25 | final RequirementStatusAttribute type,
26 | final SpecObject specObject) {
27 | this(type);
28 | specObject.getValues().add(value.getValue());
29 | }
30 |
31 | public RequirementStatusValue(
32 | final RequirementStatusAttribute type) {
33 | value = new EnumeratedAttributeValue(type.getDef());
34 | }
35 |
36 | void setStatus(StatusDTO status) {
37 | value.setValue(status.getValue());
38 | }
39 |
40 | public AttributeValueEnumeration getValue() {
41 | return value.getValue();
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/SpecObjectFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
17 | import org.eclipse.rmf.reqif10.SpecObject;
18 |
19 | import de.kay_muench.reqif10.reqifcompiler.dto.RankingDTO;
20 | import de.kay_muench.reqif10.reqifcompiler.dto.StatusDTO;
21 | import de.kay_muench.reqif10.reqifcompiler.types.complex.BaselineSpecObjectType;
22 | import de.kay_muench.reqif10.reqifcompiler.types.complex.ConfigurationSpecObjectType;
23 | import de.kay_muench.reqif10.reqifcompiler.xhtml.XhtmlBuilder;
24 |
25 | class SpecObjectFactory {
26 | private class BaselineSpecObject {
27 | private IDValue attributeValueID;
28 | private DescriptionValue attributeValueDescription;
29 | private DateValue attributeValueDate;
30 | private RequirementStatusValue attributeValueStatus;
31 | private RequirementRankingValue attributeValueImportance;
32 | private RequirementRankingValue attributeValueRisk;
33 | private SpecObject specObject;
34 |
35 | BaselineSpecObject(final BaselineSpecObjectType type, final String id,
36 | final XhtmlBuilder builder, final String date,
37 | final StatusDTO status, RankingDTO importance, RankingDTO risk)
38 | throws DatatypeConfigurationException {
39 | specObject = ReqIF10Factory.eINSTANCE.createSpecObject();
40 | specObject.setIdentifier(IdentifierManager.generateIdentifier());
41 | specObject.setType(type.getDef());
42 |
43 | attributeValueID = new IDValue(type.getId(), specObject);
44 | attributeValueDescription = new DescriptionValue(
45 | type.getDesc(), specObject);
46 | attributeValueDate = new DateValue(type.getScheduledBy(),
47 | specObject);
48 | attributeValueStatus = new RequirementStatusValue(
49 | type.getStatus(), specObject);
50 | attributeValueImportance = new RequirementRankingValue(
51 | type.getPriority(), specObject);
52 | attributeValueRisk = new RequirementRankingValue(
53 | type.getRisk(), specObject);
54 |
55 | this.setId(id);
56 | this.setDescription(builder);
57 | this.setDate(date);
58 | this.setStatus(status);
59 | this.setImportance(importance);
60 | this.setRisk(risk);
61 | }
62 |
63 | void setId(final String id) {
64 | attributeValueID.setId(id);
65 | }
66 |
67 | void setDescription(final XhtmlBuilder builder) {
68 | attributeValueDescription.setDescription(builder);
69 | }
70 |
71 | void setDate(final String date) throws DatatypeConfigurationException {
72 | attributeValueDate.setDate(date);
73 | }
74 |
75 | void setStatus(final StatusDTO status) {
76 | attributeValueStatus.setStatus(status);
77 | }
78 |
79 | void setImportance(final RankingDTO importance) {
80 | attributeValueImportance.setRanking(importance);
81 | }
82 |
83 | void setRisk(final RankingDTO risk) {
84 | attributeValueRisk.setRanking(risk);
85 | }
86 |
87 | SpecObject getObj() {
88 | return specObject;
89 | }
90 | }
91 |
92 | private class ConfigurationSpecObject {
93 | private IDValue attributeValueID;
94 | private DescriptionValue attributeValueDescription;
95 | private RequirementStatusValue attributeValueStatus;
96 | private RequirementRankingValue attributeValueImportance;
97 | private RequirementRankingValue attributeValueRisk;
98 | private SpecObject specObject;
99 |
100 | ConfigurationSpecObject(final ConfigurationSpecObjectType type,
101 | final String id, final XhtmlBuilder builder, StatusDTO status,
102 | RankingDTO importance, RankingDTO risk)
103 | throws DatatypeConfigurationException {
104 | specObject = ReqIF10Factory.eINSTANCE.createSpecObject();
105 | specObject.setIdentifier(IdentifierManager.generateIdentifier());
106 | specObject.setType(type.getDef());
107 |
108 | attributeValueID = new IDValue(type.getId(), specObject);
109 | attributeValueDescription = new DescriptionValue(
110 | type.getDesc(), specObject);
111 | attributeValueStatus = new RequirementStatusValue(
112 | type.getStatus(), specObject);
113 | attributeValueImportance = new RequirementRankingValue(
114 | type.getImportance(), specObject);
115 | attributeValueRisk = new RequirementRankingValue(
116 | type.getRisk(), specObject);
117 |
118 | this.setId(id);
119 | this.setDescription(builder);
120 | this.setStatus(status);
121 | this.setImportance(importance);
122 | this.setRisk(risk);
123 | }
124 |
125 | void setId(final String id) {
126 | attributeValueID.setId(id);
127 | }
128 |
129 | void setDescription(final XhtmlBuilder builder) {
130 | attributeValueDescription.setDescription(builder);
131 | }
132 |
133 | void setStatus(final StatusDTO status) {
134 | attributeValueStatus.setStatus(status);
135 | }
136 |
137 | void setImportance(final RankingDTO importance) {
138 | attributeValueImportance.setRanking(importance);
139 | }
140 |
141 | void setRisk(final RankingDTO risk) {
142 | attributeValueRisk.setRanking(risk);
143 | }
144 |
145 | SpecObject getObj() {
146 | return specObject;
147 | }
148 | }
149 |
150 | private BaselineSpecObjectType typeWD;
151 | private ConfigurationSpecObjectType typeWoD;
152 |
153 | SpecObjectFactory(final BaselineSpecObjectType typeWD,
154 | final ConfigurationSpecObjectType typeWoD) {
155 | this.typeWD = typeWD;
156 | this.typeWoD = typeWoD;
157 | }
158 |
159 | SpecObject newSpecObject(final String id, final XhtmlBuilder builder,
160 | final String date, final StatusDTO status, RankingDTO importance,
161 | RankingDTO risk) throws DatatypeConfigurationException {
162 | SpecObject specObject;
163 | if (date != null) {
164 | specObject = new BaselineSpecObject(this.typeWD, id, builder, date,
165 | status, importance, risk).getObj();
166 | } else {
167 | specObject = new ConfigurationSpecObject(this.typeWoD, id, builder,
168 | status, importance, risk).getObj();
169 | }
170 | return specObject;
171 | }
172 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/SpecificationOutline.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import java.util.Stack;
15 |
16 | import org.eclipse.emf.common.util.EList;
17 | import org.eclipse.rmf.reqif10.ReqIF;
18 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
19 | import org.eclipse.rmf.reqif10.SpecHierarchy;
20 | import org.eclipse.rmf.reqif10.Specification;
21 |
22 | public final class SpecificationOutline {
23 | private Stack> stack = new Stack>();
24 | private ReqIF reqIF;
25 |
26 | public void shiftLevelDown(final Headline headline) {
27 | getReqIF().getCoreContent().getSpecObjects().add(headline.getObj());
28 | SpecHierarchy specHierarchy = ReqIF10Factory.eINSTANCE
29 | .createSpecHierarchy();
30 | specHierarchy.setIdentifier(IdentifierManager.generateIdentifier());
31 | specHierarchy.setLongName("SpecHierarchy");
32 | specHierarchy.setObject(headline.getObj());
33 |
34 | this.stack.peek().add(specHierarchy);
35 | this.stack.push(specHierarchy.getChildren());
36 | }
37 |
38 | public void shiftLevelUp() {
39 | this.stack.pop();
40 | }
41 |
42 | public ReqIF getReqIF() {
43 | return reqIF;
44 | }
45 |
46 | public void setReqIF(ReqIF reqIF) {
47 | this.reqIF = reqIF;
48 | }
49 |
50 | public static SpecificationOutline newInstance() {
51 | return new SpecificationOutline();
52 | }
53 |
54 | private void push(EList children) {
55 | this.stack.push(children);
56 | }
57 |
58 | public void push(Specification specification) {
59 | this.push(specification.getChildren());
60 | }
61 |
62 | public void add(SpecHierarchy specHierarchy) {
63 | this.stack.peek().add(specHierarchy);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/dto/EnumeratorDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.dto;
13 |
14 | import org.eclipse.emf.common.util.Enumerator;
15 |
16 | class EnumeratorDTO {
17 |
18 | private Enumerator enumerator;
19 |
20 | public void fromEnumerator(final Enumerator enumerator) {
21 | this.enumerator = enumerator;
22 | }
23 |
24 | public int getValue() {
25 | return enumerator.getValue();
26 | }
27 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/dto/ImageRefDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.dto;
13 |
14 | public final class ImageRefDTO {
15 |
16 | private String uri;
17 |
18 | public void setUri(String uri) {
19 | this.uri = uri;
20 | }
21 |
22 | public String getUri() {
23 | return this.uri;
24 | }
25 |
26 | public static ImageRefDTO newInstance() {
27 | return new ImageRefDTO();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/dto/RankingDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.dto;
13 |
14 | import java.util.List;
15 |
16 | import org.eclipse.emf.common.util.Enumerator;
17 |
18 | public final class RankingDTO extends EnumeratorDTO {
19 |
20 | public static Integer DEFAULT = 0;
21 | public static List extends Enumerator> VALUES;
22 |
23 | public static RankingDTO newInstance() {
24 | return new RankingDTO();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/dto/RelationTypeDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.dto;
13 |
14 | import org.eclipse.emf.common.util.Enumerator;
15 |
16 | public final class RelationTypeDTO {
17 | public static Enumerator DEFAULT;
18 |
19 | private Enumerator enumerator;
20 |
21 | public void fromEnumerator(Enumerator enumerator) {
22 | this.enumerator = enumerator;
23 | }
24 | @Override
25 | public String toString() {
26 | return enumerator.toString();
27 | }
28 |
29 | public String name() {
30 | return enumerator.getName();
31 | }
32 |
33 | public static RelationTypeDTO newInstance() {
34 | return new RelationTypeDTO();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/dto/RequirementDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.dto;
13 |
14 | public final class RequirementDTO {
15 |
16 | private String name;
17 |
18 | public String getName() {
19 | return this.name;
20 | }
21 |
22 | public void setName(String name) {
23 | this.name = name;
24 | }
25 |
26 | public static RequirementDTO newInstance() {
27 | return new RequirementDTO();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/dto/StatusDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.dto;
13 |
14 | import java.util.List;
15 |
16 | import org.eclipse.emf.common.util.Enumerator;
17 |
18 | public final class StatusDTO extends EnumeratorDTO {
19 |
20 | public static Integer DEFAULT = 0;
21 | public static List extends Enumerator> VALUES;
22 |
23 | public static StatusDTO newInstance() {
24 | return new StatusDTO();
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/dto/TextDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.dto;
13 |
14 | public final class TextDTO {
15 |
16 | private String value;
17 |
18 | public void setValue(final String value) {
19 | this.value = value;
20 | }
21 |
22 | public String getText() {
23 | return value;
24 | }
25 |
26 | public static TextDTO newInstance() {
27 | return new TextDTO();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/dto/XhtmlUlDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.dto;
13 |
14 | import org.eclipse.emf.ecore.util.FeatureMapUtil;
15 | import org.eclipse.rmf.reqif10.xhtml.XhtmlFactory;
16 | import org.eclipse.rmf.reqif10.xhtml.XhtmlLiType;
17 | import org.eclipse.rmf.reqif10.xhtml.XhtmlUlType;
18 |
19 | public final class XhtmlUlDTO {
20 | private final XhtmlUlType ul = XhtmlFactory.eINSTANCE.createXhtmlUlType();
21 | private String title;
22 |
23 | public void addEntry(final String entry) {
24 | XhtmlLiType li = XhtmlFactory.eINSTANCE.createXhtmlLiType();
25 | li.getXhtmlFlowMix().add(FeatureMapUtil.createTextEntry(entry));
26 | getUl().getLi().add(li);
27 | }
28 |
29 | public void add(XhtmlUlDTO dto) {
30 | if (dto.getTitle() != null) {
31 | XhtmlLiType li = XhtmlFactory.eINSTANCE.createXhtmlLiType();
32 | li.getXhtmlFlowMix().add(
33 | FeatureMapUtil.createTextEntry(dto.getTitle()));
34 | li.getUl().add(dto.getUl());
35 | getUl().getLi().add(li);
36 | }
37 | }
38 |
39 | private String getTitle() {
40 | return title;
41 | }
42 |
43 | public void setTitle(String title) {
44 | this.title = title;
45 | }
46 |
47 | public XhtmlUlType getUl() {
48 | return ul;
49 | }
50 |
51 | public static XhtmlUlDTO newInstance() {
52 | return new XhtmlUlDTO();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/AttributesRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import de.kay_muench.reqif10.reqifcompiler.types.simple.SimpleTypesRegistry;
15 |
16 | public class AttributesRegistry {
17 | private IdentifierAttribute idAttribute;
18 |
19 | public AttributesRegistry(SimpleTypesRegistry registry) throws Exception {
20 | idAttribute = new IdentifierAttribute(registry.getReqIFString32kType());
21 | }
22 |
23 | public IdentifierAttribute getReqIFIDAttrib() {
24 | return this.idAttribute;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/BaselineSpecObjectType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.SpecObjectType;
17 |
18 | import de.kay_muench.reqif10.reqifcompiler.types.simple.DateType;
19 | import de.kay_muench.reqif10.reqifcompiler.types.simple.RequirementRanking;
20 | import de.kay_muench.reqif10.reqifcompiler.types.simple.RequirementStatus;
21 | import de.kay_muench.reqif10.reqifcompiler.types.simple.String32k;
22 | import de.kay_muench.reqif10.reqifcompiler.types.simple.XhtmlType;
23 |
24 | public class BaselineSpecObjectType {
25 | private CommonSpecObjectTypeDefinitions commondefs;
26 |
27 | BaselineSpecObjectType(String32k typeId, XhtmlType reqifXhtml,
28 | DateType typeDate, RequirementStatus typeStatus,
29 | RequirementRanking typeRanking)
30 | throws DatatypeConfigurationException {
31 | this.commondefs = new CommonSpecObjectTypeDefinitions(typeId, reqifXhtml, typeDate,
32 | typeStatus, typeRanking);
33 | this.commondefs.setName(this.getClass().getSimpleName());
34 | }
35 |
36 | public IdentifierAttribute getId() {
37 | return this.commondefs.getIdAttribute();
38 | }
39 |
40 | public DescriptionAttribute getDesc() {
41 | return this.commondefs.getDescAttribute();
42 | }
43 |
44 | public ScheduledByAttribute getScheduledBy() {
45 | return this.commondefs.getScheduledByAttribute();
46 | }
47 |
48 | public RequirementStatusAttribute getStatus() {
49 | return this.commondefs.getStatusAttribute();
50 | }
51 |
52 | public RequirementRankingAttribute getPriority() {
53 | return this.commondefs.getPriorityAttribute();
54 | }
55 |
56 | public RequirementRankingAttribute getRisk() {
57 | return this.commondefs.getRiskAttribute();
58 | }
59 |
60 | public SpecObjectType getDef() {
61 | return this.commondefs.getObjectType();
62 | }
63 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/CommonSpecObjectTypeDefinitions.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
17 | import org.eclipse.rmf.reqif10.SpecObjectType;
18 |
19 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
20 | import de.kay_muench.reqif10.reqifcompiler.types.simple.DateType;
21 | import de.kay_muench.reqif10.reqifcompiler.types.simple.RequirementRanking;
22 | import de.kay_muench.reqif10.reqifcompiler.types.simple.RequirementStatus;
23 | import de.kay_muench.reqif10.reqifcompiler.types.simple.String32k;
24 | import de.kay_muench.reqif10.reqifcompiler.types.simple.XhtmlType;
25 |
26 | final class CommonSpecObjectTypeDefinitions {
27 | final static String PRIORITY = "Priority";
28 | final static String RISK = "Risk";
29 |
30 | private SpecObjectType objectType;
31 | private IdentifierAttribute idAttribute;
32 | private DescriptionAttribute descAttribute;
33 | private ScheduledByAttribute scheduledByAttribute;
34 | private RequirementStatusAttribute statusAttribute;
35 | private RequirementRankingAttribute priorityAttribute;
36 | private RequirementRankingAttribute riskAttribute;
37 |
38 | public CommonSpecObjectTypeDefinitions(String32k typeId,
39 | XhtmlType reqifXhtml, DateType typeDate,
40 | RequirementStatus typeStatus,
41 | RequirementRanking typeRanking)
42 | throws DatatypeConfigurationException {
43 | idAttribute = new IdentifierAttribute(typeId);
44 | descAttribute = new DescriptionAttribute(reqifXhtml);
45 | statusAttribute = new RequirementStatusAttribute(typeStatus);
46 | priorityAttribute = new RequirementRankingAttribute(PRIORITY,
47 | typeRanking);
48 | riskAttribute = new RequirementRankingAttribute(RISK, typeRanking);
49 |
50 | objectType = ReqIF10Factory.eINSTANCE.createSpecObjectType();
51 | objectType.setIdentifier(IdentifierManager.generateIdentifier());
52 | objectType.getSpecAttributes().add(idAttribute.getDef());
53 | objectType.getSpecAttributes().add(descAttribute.getDef());
54 | objectType.getSpecAttributes().add(statusAttribute.getDef());
55 | objectType.getSpecAttributes().add(priorityAttribute.getDef());
56 | objectType.getSpecAttributes().add(riskAttribute.getDef());
57 | this.setScheduledByAttribute(typeDate);
58 | this.setName("T_SpecObject");
59 | }
60 |
61 | public void setName(final String name) {
62 | objectType.setLongName(name);
63 | }
64 |
65 | public SpecObjectType getObjectType() {
66 | return objectType;
67 | }
68 |
69 | public IdentifierAttribute getIdAttribute() {
70 | return idAttribute;
71 | }
72 |
73 | public DescriptionAttribute getDescAttribute() {
74 | return descAttribute;
75 | }
76 |
77 | public ScheduledByAttribute getScheduledByAttribute() {
78 | return scheduledByAttribute;
79 | }
80 |
81 | private void setScheduledByAttribute(DateType typeDate)
82 | throws DatatypeConfigurationException {
83 | if (typeDate != null) {
84 | scheduledByAttribute = new ScheduledByAttribute(typeDate);
85 | objectType.getSpecAttributes().add(scheduledByAttribute.getDef());
86 | }
87 | }
88 |
89 | public RequirementStatusAttribute getStatusAttribute() {
90 | return statusAttribute;
91 | }
92 |
93 | public RequirementRankingAttribute getPriorityAttribute() {
94 | return priorityAttribute;
95 | }
96 |
97 | public RequirementRankingAttribute getRiskAttribute() {
98 | return riskAttribute;
99 | }
100 |
101 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/ConfigurationSpecObjectType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.SpecObjectType;
17 |
18 | import de.kay_muench.reqif10.reqifcompiler.types.simple.RequirementRanking;
19 | import de.kay_muench.reqif10.reqifcompiler.types.simple.RequirementStatus;
20 | import de.kay_muench.reqif10.reqifcompiler.types.simple.String32k;
21 | import de.kay_muench.reqif10.reqifcompiler.types.simple.XhtmlType;
22 |
23 | public class ConfigurationSpecObjectType {
24 | private CommonSpecObjectTypeDefinitions commondefs;
25 |
26 | ConfigurationSpecObjectType(String32k typeIdDesc, XhtmlType reqifXhtml,
27 | RequirementStatus typeStatus,
28 | RequirementRanking typeRanking)
29 | throws DatatypeConfigurationException {
30 | this.commondefs = new CommonSpecObjectTypeDefinitions(typeIdDesc, reqifXhtml, null,
31 | typeStatus, typeRanking);
32 | this.commondefs.setName(this.getClass().getSimpleName());
33 | }
34 |
35 | public IdentifierAttribute getId() {
36 | return this.commondefs.getIdAttribute();
37 | }
38 |
39 | public DescriptionAttribute getDesc() {
40 | return this.commondefs.getDescAttribute();
41 | }
42 |
43 | public RequirementStatusAttribute getStatus() {
44 | return this.commondefs.getStatusAttribute();
45 | }
46 |
47 | public RequirementRankingAttribute getImportance() {
48 | return this.commondefs.getPriorityAttribute();
49 | }
50 |
51 | public RequirementRankingAttribute getRisk() {
52 | return this.commondefs.getRiskAttribute();
53 | }
54 |
55 | public SpecObjectType getDef() {
56 | return this.commondefs.getObjectType();
57 | }
58 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/DescriptionAttribute.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.AttributeDefinitionXHTML;
17 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
18 |
19 | import de.kay_muench.reqif10.reqifcompiler.DateManager;
20 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
21 | import de.kay_muench.reqif10.reqifcompiler.types.simple.XhtmlType;
22 |
23 | public final class DescriptionAttribute {
24 | private static final String DESCRIPTION = "Description";
25 | private AttributeDefinitionXHTML def;
26 |
27 | DescriptionAttribute(XhtmlType type) throws DatatypeConfigurationException {
28 | def = ReqIF10Factory.eINSTANCE.createAttributeDefinitionXHTML();
29 | def.setIdentifier(IdentifierManager.generateIdentifier());
30 | def.setLongName(DESCRIPTION);
31 | def.setType(type.getDef());
32 | def.setLastChange(DateManager.getCurrentDate());
33 | }
34 |
35 | public AttributeDefinitionXHTML getDef() {
36 | return this.def;
37 | }
38 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/EnumeratedAttributeValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import java.math.BigInteger;
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | import org.eclipse.emf.common.util.EList;
19 | import org.eclipse.rmf.reqif10.AttributeDefinitionEnumeration;
20 | import org.eclipse.rmf.reqif10.AttributeValueEnumeration;
21 | import org.eclipse.rmf.reqif10.EnumValue;
22 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
23 |
24 | public class EnumeratedAttributeValue {
25 | private AttributeValueEnumeration value;
26 |
27 | public EnumeratedAttributeValue(AttributeDefinitionEnumeration def) {
28 | value = ReqIF10Factory.eINSTANCE.createAttributeValueEnumeration();
29 | value.setDefinition(def);
30 | }
31 |
32 | public AttributeValueEnumeration getValue() {
33 | return value;
34 | }
35 |
36 | public void setValue(int v) {
37 | List newValues = new ArrayList();
38 | final EList enumValues = value.getDefinition().getType()
39 | .getSpecifiedValues();
40 | for (EnumValue enumValue : enumValues) {
41 | if (enumValue.getProperties().getKey()
42 | .equals(BigInteger.valueOf(v))) {
43 | newValues.add(enumValue);
44 | break;
45 | }
46 | }
47 |
48 | value.getValues().clear();
49 | value.getValues().addAll(newValues);
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/HeadlineType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
17 | import org.eclipse.rmf.reqif10.SpecObjectType;
18 |
19 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
20 | import de.kay_muench.reqif10.reqifcompiler.types.simple.Headline;
21 |
22 | public class HeadlineType {
23 | private SpecObjectType def;
24 | private IdentifierAttribute id;
25 |
26 | HeadlineType(Headline typeIdDesc)
27 | throws DatatypeConfigurationException {
28 | id = new IdentifierAttribute(typeIdDesc);
29 |
30 | def = ReqIF10Factory.eINSTANCE.createSpecObjectType();
31 | def.setIdentifier(IdentifierManager.generateIdentifier());
32 | def.setLongName("HeadlineType");
33 | def.getSpecAttributes().add(id.getDef());
34 | }
35 |
36 | public IdentifierAttribute getId() {
37 | return id;
38 | }
39 |
40 | public SpecObjectType getDef() {
41 | return def;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/IdentifierAttribute.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.AttributeDefinitionString;
17 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
18 |
19 | import de.kay_muench.reqif10.reqifcompiler.DateManager;
20 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
21 | import de.kay_muench.reqif10.reqifcompiler.types.simple.Headline;
22 | import de.kay_muench.reqif10.reqifcompiler.types.simple.String32k;
23 |
24 | public class IdentifierAttribute {
25 | public static String NAME = "ID";
26 | private AttributeDefinitionString def;
27 |
28 | IdentifierAttribute(String32k type) throws DatatypeConfigurationException {
29 | def = ReqIF10Factory.eINSTANCE.createAttributeDefinitionString();
30 | def.setIdentifier(IdentifierManager.generateIdentifier());
31 | def.setLongName(IdentifierAttribute.NAME);
32 | def.setType(type.getDef());
33 | def.setLastChange(DateManager.getCurrentDate());
34 | }
35 |
36 | IdentifierAttribute(Headline type) throws DatatypeConfigurationException {
37 | def = ReqIF10Factory.eINSTANCE.createAttributeDefinitionString();
38 | def.setIdentifier(IdentifierManager.generateIdentifier());
39 | def.setLongName(IdentifierAttribute.NAME);
40 | def.setType(type.getDef());
41 | def.setLastChange(DateManager.getCurrentDate());
42 | }
43 |
44 | public AttributeDefinitionString getDef() {
45 | return this.def;
46 | }
47 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/RequirementRankingAttribute.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import org.eclipse.rmf.reqif10.AttributeDefinitionEnumeration;
15 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
16 |
17 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
18 | import de.kay_muench.reqif10.reqifcompiler.dto.RankingDTO;
19 | import de.kay_muench.reqif10.reqifcompiler.types.simple.RequirementRanking;
20 |
21 | public class RequirementRankingAttribute {
22 | private AttributeDefinitionEnumeration def;
23 |
24 | public RequirementRankingAttribute(final String name, final RequirementRanking type) {
25 | def = ReqIF10Factory.eINSTANCE.createAttributeDefinitionEnumeration();
26 | def.setIdentifier(IdentifierManager.generateIdentifier());
27 | def.setLongName(name);
28 | def.setType(type.getDef());
29 | def.setMultiValued(false);
30 |
31 | EnumeratedAttributeValue rankingValue = new EnumeratedAttributeValue(def);
32 | rankingValue.setValue(RankingDTO.DEFAULT);
33 | def.setDefaultValue(rankingValue.getValue());
34 | }
35 |
36 | public AttributeDefinitionEnumeration getDef() {
37 | return def;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/RequirementStatusAttribute.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import org.eclipse.rmf.reqif10.AttributeDefinitionEnumeration;
15 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
16 |
17 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
18 | import de.kay_muench.reqif10.reqifcompiler.dto.StatusDTO;
19 | import de.kay_muench.reqif10.reqifcompiler.types.simple.RequirementStatus;
20 |
21 | public final class RequirementStatusAttribute {
22 | private static final String STATUS = "Status";
23 | private AttributeDefinitionEnumeration def;
24 |
25 | public RequirementStatusAttribute(RequirementStatus type) {
26 |
27 | def = ReqIF10Factory.eINSTANCE.createAttributeDefinitionEnumeration();
28 | def.setIdentifier(IdentifierManager.generateIdentifier());
29 | def.setLongName(STATUS);
30 | def.setType(type.getDef());
31 | def.setMultiValued(false);
32 |
33 | EnumeratedAttributeValue statusValue = new EnumeratedAttributeValue(def);
34 | statusValue.setValue(StatusDTO.DEFAULT);
35 | def.setDefaultValue(statusValue.getValue());
36 | }
37 |
38 | public AttributeDefinitionEnumeration getDef() {
39 | return def;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/ScheduledByAttribute.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.AttributeDefinitionDate;
17 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
18 |
19 | import de.kay_muench.reqif10.reqifcompiler.DateManager;
20 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
21 | import de.kay_muench.reqif10.reqifcompiler.types.simple.DateType;
22 |
23 | public class ScheduledByAttribute {
24 | private static final String SCHEDULEDBY = "Scheduled by";
25 | private AttributeDefinitionDate def;
26 |
27 | ScheduledByAttribute(DateType type)
28 | throws DatatypeConfigurationException {
29 | def = ReqIF10Factory.eINSTANCE.createAttributeDefinitionDate();
30 | def.setIdentifier(IdentifierManager.generateIdentifier());
31 | def.setLongName(SCHEDULEDBY);
32 | def.setType(type.getDef());
33 | def.setLastChange(DateManager.getCurrentDate());
34 | }
35 |
36 | public AttributeDefinitionDate getDef() {
37 | return def;
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/SpecRelationTypeWithRelationKind.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.AttributeDefinitionString;
17 | import org.eclipse.rmf.reqif10.AttributeValueString;
18 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
19 | import org.eclipse.rmf.reqif10.SpecRelationType;
20 |
21 | import de.kay_muench.reqif10.reqifcompiler.DateManager;
22 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
23 | import de.kay_muench.reqif10.reqifcompiler.dto.RelationTypeDTO;
24 | import de.kay_muench.reqif10.reqifcompiler.types.simple.String32k;
25 |
26 | public class SpecRelationTypeWithRelationKind {
27 | private SpecRelationType def;
28 | private IdentifierAttribute id;
29 | private AttributeDefinitionString specRelationTypeAttributeDefinitionString;
30 |
31 | public SpecRelationTypeWithRelationKind(String32k typeId)
32 | throws DatatypeConfigurationException {
33 | id = new IdentifierAttribute(typeId);
34 | specRelationTypeAttributeDefinitionString = ReqIF10Factory.eINSTANCE
35 | .createAttributeDefinitionString();
36 | specRelationTypeAttributeDefinitionString
37 | .setIdentifier(IdentifierManager.generateIdentifier());
38 | specRelationTypeAttributeDefinitionString.setLongName("Relation");
39 | specRelationTypeAttributeDefinitionString.setLastChange(DateManager
40 | .getCurrentDate());
41 | specRelationTypeAttributeDefinitionString.setType(typeId.getDef());
42 |
43 | AttributeValueString attributeValueString = ReqIF10Factory.eINSTANCE
44 | .createAttributeValueString();
45 | attributeValueString.setTheValue(RelationTypeDTO.DEFAULT.toString()
46 | .toLowerCase());
47 | specRelationTypeAttributeDefinitionString
48 | .setDefaultValue(attributeValueString);
49 |
50 | def = ReqIF10Factory.eINSTANCE.createSpecRelationType();
51 |
52 | def.setIdentifier(IdentifierManager.generateIdentifier());
53 | def.setLongName("SpecRelationType");
54 | def.setLastChange(DateManager.getCurrentDate());
55 | def.getSpecAttributes().add(id.getDef());
56 | def.getSpecAttributes().add(specRelationTypeAttributeDefinitionString);
57 | }
58 |
59 | public IdentifierAttribute getId() {
60 | return id;
61 | }
62 |
63 | public AttributeDefinitionString getSpecRelationTypeAttributeDefinitionString() {
64 | return specRelationTypeAttributeDefinitionString;
65 | }
66 |
67 | public SpecRelationType getDef() {
68 | return def;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/complex/SpecTypesRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.complex;
13 |
14 | import java.util.LinkedList;
15 | import java.util.List;
16 |
17 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
18 | import org.eclipse.rmf.reqif10.SpecType;
19 | import org.eclipse.rmf.reqif10.SpecificationType;
20 |
21 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
22 | import de.kay_muench.reqif10.reqifcompiler.types.simple.SimpleTypesRegistry;
23 |
24 | public class SpecTypesRegistry {
25 |
26 | private HeadlineType headlineType;
27 | private SpecificationType specificationType;
28 | private AttributesRegistry attributesRegistry;
29 | private BaselineSpecObjectType specObjectTypeWithDate;
30 | private ConfigurationSpecObjectType specObjectTypeWithoutDate;
31 | private SpecRelationTypeWithRelationKind specRelationType;
32 |
33 | public AttributesRegistry getAttributesRegistry() {
34 | return attributesRegistry;
35 | }
36 |
37 | public SpecTypesRegistry(SimpleTypesRegistry registry) throws Exception {
38 | attributesRegistry = new AttributesRegistry(registry);
39 | headlineType = new HeadlineType(registry.getReqIFHeadlineType());
40 | specificationType = ReqIF10Factory.eINSTANCE.createSpecificationType();
41 | specificationType.setIdentifier(IdentifierManager.generateIdentifier());
42 | specificationType.setLongName("SpecificationType");
43 | specificationType.getSpecAttributes().add(
44 | attributesRegistry.getReqIFIDAttrib().getDef());
45 | specObjectTypeWithDate = new BaselineSpecObjectType(
46 | registry.getReqIFString32kType(), registry.getReqIFXhtmlType(),
47 | registry.getReqIFDateType(),
48 | registry.getReqIFRequirementStatusType(),
49 | registry.getReqIFRequirementRankingType());
50 | specObjectTypeWithoutDate = new ConfigurationSpecObjectType(
51 | registry.getReqIFString32kType(), registry.getReqIFXhtmlType(),
52 | registry.getReqIFRequirementStatusType(),
53 | registry.getReqIFRequirementRankingType());
54 | specRelationType = new SpecRelationTypeWithRelationKind(
55 | registry.getReqIFString32kType());
56 | }
57 |
58 | public HeadlineType getHeadlineType() {
59 | return this.headlineType;
60 | }
61 |
62 | public SpecificationType getSpecificationType() {
63 | return this.specificationType;
64 | }
65 |
66 | public BaselineSpecObjectType getSpecObjectTypeWithDate() {
67 | return this.specObjectTypeWithDate;
68 | }
69 |
70 | public ConfigurationSpecObjectType getSpecObjectTypeWithoutDate() {
71 | return this.specObjectTypeWithoutDate;
72 | }
73 |
74 | public SpecRelationTypeWithRelationKind getSpecRelationType() {
75 | return this.specRelationType;
76 | }
77 |
78 | public List getSpectypes() {
79 | List types = new LinkedList();
80 | types.add(this.specObjectTypeWithoutDate.getDef());
81 | types.add(this.specObjectTypeWithDate.getDef());
82 | types.add(this.specRelationType.getDef());
83 | types.add(this.specificationType);
84 | types.add(this.headlineType.getDef());
85 | return types;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/simple/DateType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.simple;
13 |
14 | import javax.xml.datatype.DatatypeConfigurationException;
15 |
16 | import org.eclipse.rmf.reqif10.DatatypeDefinitionDate;
17 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
18 |
19 | import de.kay_muench.reqif10.reqifcompiler.DateManager;
20 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
21 |
22 | public class DateType {
23 | private DatatypeDefinitionDate def;
24 |
25 | DateType() throws DatatypeConfigurationException {
26 | def = ReqIF10Factory.eINSTANCE.createDatatypeDefinitionDate();
27 | def.setIdentifier(IdentifierManager.generateIdentifier());
28 | def.setLongName("T_Date");
29 | def.setLastChange(DateManager.getCurrentDate());
30 | }
31 |
32 | public DatatypeDefinitionDate getDef() {
33 | return this.def;
34 | }
35 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/simple/Headline.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.simple;
13 |
14 | import org.eclipse.rmf.reqif10.DatatypeDefinitionString;
15 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
16 |
17 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
18 |
19 | public class Headline {
20 | private DatatypeDefinitionString def;
21 |
22 | Headline() {
23 | def = ReqIF10Factory.eINSTANCE.createDatatypeDefinitionString();
24 | def.setIdentifier(IdentifierManager.generateIdentifier());
25 | def.setLongName("T_Headline");
26 | }
27 |
28 | public DatatypeDefinitionString getDef() {
29 | return this.def;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/simple/RequirementRanking.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.simple;
13 |
14 | import java.math.BigInteger;
15 |
16 | import org.eclipse.emf.common.util.Enumerator;
17 | import org.eclipse.rmf.reqif10.DatatypeDefinitionEnumeration;
18 | import org.eclipse.rmf.reqif10.EmbeddedValue;
19 | import org.eclipse.rmf.reqif10.EnumValue;
20 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
21 |
22 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
23 | import de.kay_muench.reqif10.reqifcompiler.dto.RankingDTO;
24 |
25 | final class ReqIFEnumerationDatatype {
26 | private DatatypeDefinitionEnumeration def;
27 |
28 | public ReqIFEnumerationDatatype() {
29 | def = ReqIF10Factory.eINSTANCE.createDatatypeDefinitionEnumeration();
30 | def.setIdentifier(IdentifierManager.generateIdentifier());
31 | this.setName("T_Enum_" + def.getIdentifier());
32 | }
33 |
34 | void setName(final String name) {
35 | def.setLongName(name);
36 | }
37 |
38 | public void addEnumValue(Enumerator enumerator) {
39 | EnumValue enumValue = ReqIF10Factory.eINSTANCE.createEnumValue();
40 | enumValue.setIdentifier(IdentifierManager.generateIdentifier());
41 | enumValue.setLongName(enumerator.getLiteral());
42 |
43 | EmbeddedValue embeddedValue = ReqIF10Factory.eINSTANCE
44 | .createEmbeddedValue();
45 | embeddedValue.setKey(BigInteger.valueOf(enumerator.getValue()));
46 | embeddedValue.setOtherContent("");
47 |
48 | enumValue.setProperties(embeddedValue);
49 |
50 | def.getSpecifiedValues().add(enumValue);
51 | }
52 |
53 | public DatatypeDefinitionEnumeration getDef() {
54 | return def;
55 | }
56 |
57 | }
58 |
59 | public final class RequirementRanking {
60 | private ReqIFEnumerationDatatype def;
61 |
62 | public RequirementRanking() {
63 | def = new ReqIFEnumerationDatatype();
64 | def.setName("T_ReqRanking");
65 |
66 | for (Enumerator ranking : RankingDTO.VALUES) {
67 | def.addEnumValue(ranking);
68 | }
69 | }
70 |
71 | public DatatypeDefinitionEnumeration getDef() {
72 | return def.getDef();
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/simple/RequirementStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.simple;
13 |
14 | import java.math.BigInteger;
15 |
16 | import org.eclipse.emf.common.util.Enumerator;
17 | import org.eclipse.rmf.reqif10.DatatypeDefinitionEnumeration;
18 | import org.eclipse.rmf.reqif10.EmbeddedValue;
19 | import org.eclipse.rmf.reqif10.EnumValue;
20 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
21 |
22 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
23 | import de.kay_muench.reqif10.reqifcompiler.dto.StatusDTO;
24 |
25 | public class RequirementStatus {
26 | private DatatypeDefinitionEnumeration def;
27 |
28 | public RequirementStatus() {
29 | def = ReqIF10Factory.eINSTANCE.createDatatypeDefinitionEnumeration();
30 | def.setIdentifier(IdentifierManager.generateIdentifier());
31 | def.setLongName("T_ReqStatus");
32 |
33 | for (Enumerator status : StatusDTO.VALUES) {
34 | EnumValue enumValue = ReqIF10Factory.eINSTANCE.createEnumValue();
35 | enumValue.setIdentifier(IdentifierManager.generateIdentifier());
36 | enumValue.setLongName(status.getLiteral());
37 |
38 | EmbeddedValue embeddedValue = ReqIF10Factory.eINSTANCE
39 | .createEmbeddedValue();
40 | embeddedValue.setKey(BigInteger.valueOf(status.getValue()));
41 | embeddedValue.setOtherContent("");
42 |
43 | enumValue.setProperties(embeddedValue);
44 |
45 | def.getSpecifiedValues().add(enumValue);
46 | }
47 | }
48 |
49 | public DatatypeDefinitionEnumeration getDef() {
50 | return def;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/simple/SimpleTypesRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.simple;
13 |
14 | import java.util.LinkedList;
15 | import java.util.List;
16 |
17 | import org.eclipse.rmf.reqif10.DatatypeDefinition;
18 |
19 | public class SimpleTypesRegistry {
20 | public SimpleTypesRegistry() throws Exception {
21 | }
22 |
23 | private String32k reqifString = new String32k();
24 | private DateType reqifDate = new DateType();
25 | private XhtmlType reqifXhtml = new XhtmlType();
26 | private Headline reqifHeadline = new Headline();
27 | private RequirementStatus reqifRequirementStatus = new RequirementStatus();
28 | private RequirementRanking reqifRequirementRanking = new RequirementRanking();
29 |
30 | public String32k getReqIFString32kType() {
31 | return this.reqifString;
32 | }
33 |
34 | public DateType getReqIFDateType() {
35 | return this.reqifDate;
36 | }
37 |
38 | public XhtmlType getReqIFXhtmlType() {
39 | return this.reqifXhtml;
40 | }
41 |
42 | public Headline getReqIFHeadlineType() {
43 | return this.reqifHeadline;
44 | }
45 |
46 | public RequirementStatus getReqIFRequirementStatusType() {
47 | return reqifRequirementStatus;
48 | }
49 |
50 | public RequirementRanking getReqIFRequirementRankingType() {
51 | return this.reqifRequirementRanking;
52 | }
53 |
54 | public List getDatatypes() {
55 | List definitions = new LinkedList();
56 | definitions.add(this.reqifString.getDef());
57 | definitions.add(this.reqifDate.getDef());
58 | definitions.add(this.reqifXhtml.getDef());
59 | definitions.add(this.reqifHeadline.getDef());
60 | definitions.add(this.reqifRequirementStatus.getDef());
61 | definitions.add(this.reqifRequirementRanking.getDef());
62 | return definitions;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/simple/String32k.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.simple;
13 |
14 | import java.math.BigInteger;
15 |
16 | import org.eclipse.rmf.reqif10.DatatypeDefinitionString;
17 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
18 |
19 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
20 |
21 | public class String32k {
22 | private DatatypeDefinitionString def;
23 |
24 | String32k() {
25 | def = ReqIF10Factory.eINSTANCE.createDatatypeDefinitionString();
26 | def.setIdentifier(IdentifierManager.generateIdentifier());
27 | def.setLongName("T_String");
28 | def.setMaxLength(new BigInteger("32000"));
29 | }
30 |
31 | public DatatypeDefinitionString getDef() {
32 | return this.def;
33 | }
34 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/types/simple/XhtmlType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.types.simple;
13 |
14 | import org.eclipse.rmf.reqif10.DatatypeDefinitionXHTML;
15 | import org.eclipse.rmf.reqif10.ReqIF10Factory;
16 |
17 | import de.kay_muench.reqif10.reqifcompiler.IdentifierManager;
18 |
19 | public class XhtmlType {
20 | private DatatypeDefinitionXHTML def;
21 |
22 | public XhtmlType() {
23 | this.def = ReqIF10Factory.eINSTANCE.createDatatypeDefinitionXHTML();
24 | this.def.setIdentifier(IdentifierManager.generateIdentifier());
25 | this.def.setLongName("T_Xhtml");
26 | }
27 |
28 | public DatatypeDefinitionXHTML getDef() {
29 | return def;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/reqifcompiler/src/main/java/de/kay_muench/reqif10/reqifcompiler/xhtml/XhtmlBuilder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler.xhtml;
13 |
14 | import java.io.IOException;
15 | import java.util.ArrayList;
16 | import java.util.Collection;
17 |
18 | import org.eclipse.emf.ecore.util.FeatureMapUtil;
19 | import org.eclipse.rmf.reqif10.xhtml.XhtmlDivType;
20 | import org.eclipse.rmf.reqif10.xhtml.XhtmlFactory;
21 | import org.eclipse.rmf.reqif10.xhtml.XhtmlObjectType;
22 | import org.eclipse.rmf.reqif10.xhtml.XhtmlPType;
23 |
24 | import de.kay_muench.imageinformationprovider.ImageDataUriProvider;
25 | import de.kay_muench.imageinformationprovider.ImageInformation;
26 | import de.kay_muench.imageinformationprovider.ImageInformationProvider;
27 | import de.kay_muench.reqif10.reqifcompiler.dto.ImageRefDTO;
28 | import de.kay_muench.reqif10.reqifcompiler.dto.TextDTO;
29 | import de.kay_muench.reqif10.reqifcompiler.dto.XhtmlUlDTO;
30 |
31 | public class XhtmlBuilder {
32 | private Collection collection = new ArrayList();
33 |
34 | public XhtmlBuilder append(ImageRefDTO ref) {
35 | XhtmlDivType d = XhtmlFactory.eINSTANCE.createXhtmlDivType();
36 |
37 | ImageInformationProvider provider = new ImageInformationProvider();
38 |
39 | try {
40 | ImageInformation info = provider.provideFor(ref.getUri());
41 | ImageDataUriProvider dataUriProvider = new ImageDataUriProvider();
42 |
43 | XhtmlObjectType o = XhtmlFactory.eINSTANCE.createXhtmlObjectType();
44 | o.setClass("figure");
45 | o.setData(dataUriProvider.provideFor(info));
46 | o.setType(info.getMimeType());
47 | o.setWidth(Integer.valueOf(info.getWidth()).toString());
48 | o.setHeight(Integer.valueOf(info.getHeight()).toString());
49 | o.getBr().add(XhtmlFactory.eINSTANCE.createXhtmlBrType());
50 |
51 | d.getObject().add(o);
52 | } catch (RuntimeException e) {
53 | XhtmlPType p = XhtmlFactory.eINSTANCE.createXhtmlPType();
54 | p.getXhtmlInlineMix().add(
55 | FeatureMapUtil.createTextEntry(e.getMessage()));
56 | d.getP().add(p);
57 | } catch (IOException e) {
58 | XhtmlPType p = XhtmlFactory.eINSTANCE.createXhtmlPType();
59 | p.getXhtmlInlineMix().add(
60 | FeatureMapUtil.createTextEntry(e.getMessage()));
61 | d.getP().add(p);
62 | }
63 |
64 | this.collection.add(d);
65 | return this;
66 | }
67 |
68 | public XhtmlBuilder append(final TextDTO txt) {
69 | XhtmlDivType d = XhtmlFactory.eINSTANCE.createXhtmlDivType();
70 | XhtmlPType p = XhtmlFactory.eINSTANCE.createXhtmlPType();
71 | final String[] lines = txt.getText().split("\n");
72 | for (int i = 0; i < lines.length; i++) {
73 | p.getXhtmlInlineMix().add(FeatureMapUtil.createTextEntry(lines[i]));
74 | if (i < lines.length - 1)
75 | p.getBr().add(XhtmlFactory.eINSTANCE.createXhtmlBrType());
76 | }
77 | d.getP().add(p);
78 | this.collection.add(d);
79 | return this;
80 | }
81 |
82 | public XhtmlBuilder append(final XhtmlUlDTO dto) {
83 | XhtmlDivType d = XhtmlFactory.eINSTANCE.createXhtmlDivType();
84 | d.getUl().add(dto.getUl());
85 | this.collection.add(d);
86 | return this;
87 | }
88 |
89 | public Collection extends XhtmlDivType> build() {
90 | return this.collection;
91 | }
92 |
93 | public static XhtmlBuilder newInstance() {
94 | return new XhtmlBuilder();
95 | }
96 |
97 | }
--------------------------------------------------------------------------------
/reqifcompiler/src/test/java/de/kay_muench/reqif10/reqifcompiler/LoggingAspect.aj:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 |
15 | import org.apache.log4j.Logger;
16 |
17 | import de.kay_muench.reqif10.reqifcompiler.dto.RelationTypeDTO;
18 | import de.kay_muench.reqif10.reqifcompiler.dto.RequirementDTO;
19 |
20 | /**
21 | * @author Kay Erik Münch
22 | *
23 | */
24 | public aspect LoggingAspect {
25 | private Logger logger = Logger.getLogger("testlogger");
26 |
27 | pointcut addrelation(RelationTypeDTO type, RequirementDTO src,
28 | RequirementDTO dest) : execution(* ReqIF10Compiler.addRelation(..)) && args(type, src, dest);
29 |
30 | before(RelationTypeDTO type, RequirementDTO src, RequirementDTO dest) : addrelation(type, src, dest) {
31 | logger.info(type.name() + " " + src.getName() + " "
32 | + dest.getName());
33 | }
34 |
35 | pointcut export(String id) : execution(* ReqIF10Compiler.export(..)) && args(id);
36 |
37 | before(String id) : export(id) {
38 | logger.info("creating export for " + id);
39 | }
40 |
41 | pointcut initialize() : execution(* ReqIF10Compiler.initialize(..));
42 |
43 | before() : initialize() {
44 | logger.info("initializing compiler");
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/reqifcompiler/src/test/java/de/kay_muench/reqif10/reqifcompiler/ReqIF10CompilerTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifcompiler;
13 |
14 | import static org.junit.Assert.assertEquals;
15 |
16 | import java.io.File;
17 | import java.util.Arrays;
18 | import java.util.Collections;
19 | import java.util.List;
20 |
21 | import org.apache.commons.io.FileUtils;
22 | import org.apache.log4j.ConsoleAppender;
23 | import org.apache.log4j.Level;
24 | import org.apache.log4j.Logger;
25 | import org.apache.log4j.PatternLayout;
26 | import org.eclipse.emf.common.util.Enumerator;
27 | import org.junit.Before;
28 | import org.junit.BeforeClass;
29 | import org.junit.Test;
30 |
31 | import de.kay_muench.reqif10.reqifcompiler.dto.ImageRefDTO;
32 | import de.kay_muench.reqif10.reqifcompiler.dto.RankingDTO;
33 | import de.kay_muench.reqif10.reqifcompiler.dto.RelationTypeDTO;
34 | import de.kay_muench.reqif10.reqifcompiler.dto.RequirementDTO;
35 | import de.kay_muench.reqif10.reqifcompiler.dto.StatusDTO;
36 | import de.kay_muench.reqif10.reqifcompiler.dto.TextDTO;
37 | import de.kay_muench.reqif10.reqifcompiler.xhtml.XhtmlBuilder;
38 |
39 | public class ReqIF10CompilerTest {
40 |
41 | private ReqIF10Compiler compiler;
42 |
43 | private enum StatusTestEnumerator implements Enumerator {
44 | TEST(0, "StatusTest", "StatusTest");
45 | private final int value;
46 | private final String name;
47 | private final String literal;
48 |
49 | public static final List VALUES = Collections
50 | .unmodifiableList(Arrays.asList(TEST));
51 |
52 | private StatusTestEnumerator(int value, String name, String literal) {
53 | this.value = value;
54 | this.name = name;
55 | this.literal = literal;
56 | }
57 |
58 | public String getLiteral() {
59 | return this.literal;
60 | }
61 |
62 | public String getName() {
63 | return this.name;
64 | }
65 |
66 | public int getValue() {
67 | return this.value;
68 | }
69 |
70 | }
71 |
72 | private enum RankingTestEnumerator implements Enumerator {
73 | RTEST(0, "RankingTest", "RankingTest");
74 | private final int value;
75 | private final String name;
76 | private final String literal;
77 |
78 | public static final List VALUES = Collections
79 | .unmodifiableList(Arrays.asList(RTEST));
80 |
81 | private RankingTestEnumerator(int value, String name, String literal) {
82 | this.value = value;
83 | this.name = name;
84 | this.literal = literal;
85 | }
86 |
87 | public String getLiteral() {
88 | return this.literal;
89 | }
90 |
91 | public String getName() {
92 | return this.name;
93 | }
94 |
95 | public int getValue() {
96 | return this.value;
97 | }
98 | }
99 |
100 | private enum RelationTestEnumerator implements Enumerator {
101 | RELATESTO(2, "relatesto", "relatesto");
102 | private final int value;
103 | private final String name;
104 | private final String literal;
105 |
106 | private RelationTestEnumerator(int value, String name, String literal) {
107 | this.value = value;
108 | this.name = name;
109 | this.literal = literal;
110 | }
111 |
112 | public String getLiteral() {
113 | return this.literal;
114 | }
115 |
116 | public String getName() {
117 | return this.name;
118 | }
119 |
120 | public int getValue() {
121 | return this.value;
122 | }
123 |
124 | }
125 |
126 | @BeforeClass
127 | public static void setUpBeforeClass() {
128 | ConsoleAppender appender = new ConsoleAppender();
129 | appender.setName("testappender");
130 | appender.setLayout(new PatternLayout("%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}]: %m%n"));
131 | appender.setTarget(ConsoleAppender.SYSTEM_OUT);
132 | appender.activateOptions();
133 |
134 | Logger.getLogger("org.apache.xmlgraphics").addAppender(appender);
135 | Logger.getLogger("org.apache.xmlgraphics").setLevel(Level.INFO);
136 |
137 | Logger.getLogger("testlogger").addAppender(appender);
138 |
139 | RelationTypeDTO.DEFAULT = RelationTestEnumerator.RELATESTO;
140 | RankingDTO.DEFAULT = RankingTestEnumerator.RTEST.getValue();
141 | RankingDTO.VALUES = RankingTestEnumerator.VALUES;
142 | StatusDTO.DEFAULT = StatusTestEnumerator.TEST.getValue();
143 | StatusDTO.VALUES = StatusTestEnumerator.VALUES;
144 | IdentifierManager.enablePredictableId();
145 | DateManager.enablePredictableId();
146 | }
147 |
148 | @Before
149 | public void setUp() throws Exception {
150 | compiler = ReqIF10Compiler.newInstance();
151 | compiler.initialize();
152 | }
153 |
154 | @Test
155 | public void testUT_1000() throws Exception {
156 |
157 | compiler.addSpecification("Test-Specification");
158 | compiler.shiftLevelDown("Chapter 1");
159 |
160 | TextDTO textDTO = TextDTO.newInstance();
161 | textDTO.setValue("Hello");
162 | XhtmlBuilder builder = XhtmlBuilder.newInstance();
163 | builder.append(textDTO);
164 |
165 | StatusDTO status = StatusDTO.newInstance();
166 | status.fromEnumerator(StatusTestEnumerator.TEST);
167 | RankingDTO priority = RankingDTO.newInstance();
168 | priority.fromEnumerator(RankingTestEnumerator.RTEST);
169 | RankingDTO risk = RankingDTO.newInstance();
170 | risk.fromEnumerator(RankingTestEnumerator.RTEST);
171 |
172 | compiler.addSpecObject("REQ_1", builder, null, status, priority, risk);
173 |
174 | compiler.shiftLevelUp();
175 |
176 | compiler.shiftLevelDown("Chapter 2");
177 | compiler.shiftLevelDown("Section 2.2");
178 |
179 | XhtmlBuilder builder2 = XhtmlBuilder.newInstance();
180 | builder2.append(textDTO);
181 | compiler.addSpecObject("REQ_2", builder2, null, status, priority,
182 | risk);
183 | RelationTypeDTO type = RelationTypeDTO.newInstance();
184 | type.fromEnumerator(RelationTestEnumerator.RELATESTO);
185 | RequirementDTO src = RequirementDTO.newInstance();
186 | src.setName("REQ_1");
187 | RequirementDTO dest = RequirementDTO.newInstance();
188 | dest.setName("REQ_2");
189 | compiler.addRelation(type, src, dest);
190 |
191 | compiler.shiftLevelUp();
192 | compiler.shiftLevelUp();
193 |
194 | compiler.addSpecRelations();
195 |
196 | final String expected = FileUtils.readFileToString(new File(
197 | "src/test/resources/UT_1000.reqif"), "UTF-8");
198 | final String actual = compiler.export("test");
199 | //System.out.println(actual);
200 | assertEquals(expected, actual);
201 | }
202 |
203 | @Test
204 | public void testUT_1001() throws Exception {
205 |
206 | compiler.addSpecification("Test-Specification");
207 | compiler.shiftLevelDown("Chapter 1");
208 |
209 | TextDTO textDTO = TextDTO.newInstance();
210 | textDTO.setValue("Hello");
211 |
212 | ImageRefDTO imageRefDTO = ImageRefDTO.newInstance();
213 | imageRefDTO.setUri("src/test/resources/flowers.jpg");
214 |
215 | XhtmlBuilder builder = XhtmlBuilder.newInstance();
216 | builder.append(textDTO);
217 | builder.append(imageRefDTO);
218 |
219 | StatusDTO status = StatusDTO.newInstance();
220 | status.fromEnumerator(StatusTestEnumerator.TEST);
221 | RankingDTO importance = RankingDTO.newInstance();
222 | importance.fromEnumerator(RankingTestEnumerator.RTEST);
223 | RankingDTO risk = RankingDTO.newInstance();
224 | risk.fromEnumerator(RankingTestEnumerator.RTEST);
225 |
226 | compiler.addSpecObject("REQ_1", builder, null, status, importance, risk);
227 |
228 | compiler.shiftLevelUp();
229 |
230 | final String expected = FileUtils.readFileToString(new File(
231 | "src/test/resources/UT_1001.reqif"), "UTF-8");
232 | final String actual = compiler.export("test").replaceAll("
", "")
233 | .replaceAll("
", "");
234 | // System.out.println(actual);
235 | assertEquals(expected, actual);
236 | }
237 | }
238 |
--------------------------------------------------------------------------------
/reqifcompiler/src/test/resources/flowers.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KayErikMuench/reqiftools/2810307ae9ceda75dc9285d043468615a7ad98cf/reqifcompiler/src/test/resources/flowers.jpg
--------------------------------------------------------------------------------
/reqifiterator/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/reqifiterator/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /bin
3 |
--------------------------------------------------------------------------------
/reqifiterator/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | reqifiterator
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.ajdt.core.ajbuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.ajdt.ui.ajnature
21 | org.eclipse.jdt.core.javanature
22 | org.eclipse.m2e.core.maven2Nature
23 |
24 |
25 |
--------------------------------------------------------------------------------
/reqifiterator/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 | encoding//src/test/java=UTF-8
4 | encoding//src/test/resources=UTF-8
5 | encoding/=UTF-8
6 |
--------------------------------------------------------------------------------
/reqifiterator/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
3 | org.eclipse.jdt.core.compiler.compliance=1.7
4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 | org.eclipse.jdt.core.compiler.source=1.7
6 |
--------------------------------------------------------------------------------
/reqifiterator/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/reqifiterator/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | reqifiterator
6 | jar
7 |
8 | reqifiterator
9 |
10 |
11 | Eclipse Public License 1.0
12 | http://www.spdx.org/licenses/EPL-1.0
13 | Copyright (c) 2014 Kay Erik Münch. All rights reserved.
14 | This program and the accompanying materials are made available under the
15 | terms of the Eclipse Public License v1.0 which accompanies this distribution,
16 | and is available at http://www.spdx.org/licenses/EPL-1.0
17 |
18 |
19 |
20 |
21 | UTF-8
22 |
23 |
24 |
25 |
26 | org.eclipse.emf
27 | org.eclipse.emf.ecore.xmi
28 |
29 |
30 | org.eclipse.emf
31 | org.eclipse.emf.ecore
32 |
33 |
34 | org.eclipse.emf
35 | org.eclipse.emf.common
36 |
37 |
38 | org.eclipse.rmf
39 | org.eclipse.rmf.reqif10
40 |
41 |
42 | org.eclipse.rmf
43 | org.eclipse.rmf.reqif10.common
44 |
45 |
46 | org.eclipse.rmf
47 | org.eclipse.rmf.reqif10.xhtml
48 |
49 |
50 | org.eclipse.rmf
51 | org.eclipse.rmf.serialization
52 |
53 |
54 | junit
55 | junit
56 | test
57 |
58 |
59 | de.kay-muench.reqif10
60 | reqifparser
61 | 0.0.1-SNAPSHOT
62 | test
63 |
64 |
65 | org.aspectj
66 | aspectjrt
67 | test
68 |
69 |
70 | log4j
71 | log4j
72 |
73 |
74 |
75 | de.kay-muench.reqif10
76 | reqif-parent
77 | 0.0.1-SNAPSHOT
78 | ../reqiftools-parent
79 |
80 |
81 |
82 |
83 | org.apache.maven.plugins
84 | maven-compiler-plugin
85 | 3.1
86 |
87 | 1.7
88 | 1.7
89 |
90 |
91 |
92 |
93 |
94 | scm:git:https://github.com/KayErikMuench/reqiftools.git
95 | scm:git:https://github.com/KayErikMuench/reqiftools.git
96 | https://github.com/KayErikMuench/reqiftools
97 |
98 |
99 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/AttributeHolder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.List;
15 |
16 | interface AttributeHolder extends AttributeListener {
17 | public List getAttributes();
18 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/AttributeListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.List;
15 |
16 | public interface AttributeListener {
17 | public void setRelevantAttributes(final List attributes);
18 |
19 | public void addRelevantAttributes(final List attributes);
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/AttributeValueConverter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.Iterator;
15 | import java.util.List;
16 |
17 | import org.eclipse.rmf.reqif10.AttributeValue;
18 | import org.eclipse.rmf.reqif10.EnumValue;
19 | import org.eclipse.rmf.reqif10.XhtmlContent;
20 | import org.eclipse.rmf.reqif10.common.util.ReqIF10Util;
21 |
22 | interface AttributeEnumValueConverter {
23 | String convert(final String orig);
24 | }
25 |
26 | final class AttributeValueConverter {
27 | private class DefaultEnumValueConverter implements AttributeEnumValueConverter {
28 |
29 | public String convert(String orig) {
30 | return orig;
31 | }
32 |
33 | }
34 |
35 | public static String getDefaultValue(final AttributeValue av) {
36 | AttributeValueConverter converter = new AttributeValueConverter();
37 | return getDefaultValue(av, converter.new DefaultEnumValueConverter());
38 | }
39 |
40 | public static String getDefaultValue(final AttributeValue av,
41 | AttributeEnumValueConverter converter) {
42 | final Object value = getTheValue(av);
43 | String textValue;
44 | if (value == null) {
45 | textValue = "";
46 | } else if (value instanceof List>) {
47 | textValue = "";
48 | for (Iterator> i = ((List>) value).iterator(); i.hasNext();) {
49 | EnumValue enumValue = (EnumValue) i.next();
50 | textValue += converter.convert(enumValue.getLongName());
51 | if (i.hasNext()) {
52 | textValue += ", ";
53 | }
54 | }
55 | } else if (value instanceof XhtmlContent) {
56 | textValue = XhtmlContentProcessor
57 | .generateXMLString((XhtmlContent) value);
58 | } else {
59 | textValue = value.toString();
60 | }
61 | return textValue;
62 | }
63 |
64 | public static boolean hasXhtmlContent(final AttributeValue av) {
65 | final Object value = getTheValue(av);
66 | return value != null && value instanceof XhtmlContent;
67 | }
68 |
69 | private static Object getTheValue(final AttributeValue av) {
70 | final Object value = av == null ? null : ReqIF10Util.getTheValue(av);
71 | return value;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/DefaultAttributeHolder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | class DefaultAttributeHolder implements AttributeHolder {
18 | private List attributes = new ArrayList();
19 |
20 | @Override
21 | public void setRelevantAttributes(final List attributes) {
22 | this.attributes = attributes;
23 | }
24 |
25 | @Override
26 | public void addRelevantAttributes(final List attributes) {
27 | List addAttributes = new ArrayList(attributes);
28 | addAttributes.removeAll(this.attributes);
29 | this.attributes.addAll(addAttributes);
30 |
31 | }
32 |
33 | @Override
34 | public List getAttributes() {
35 | return this.attributes;
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/DefaultRegistrableListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | class DefaultRegistrableListener implements RegistrableListener {
18 | private final List register = new ArrayList();
19 |
20 | @Override
21 | public List registeredFor() {
22 | return this.register;
23 | }
24 |
25 | @Override
26 | public void registerFor(String... strings) {
27 | for (String s : strings) {
28 | this.register.add(s);
29 | }
30 | }
31 |
32 | @Override
33 | public void registerFor(List strings) {
34 | for (String s : strings) {
35 | this.register.add(s);
36 | }
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/I18nableListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.ResourceBundle;
15 |
16 | public interface I18nableListener {
17 | public void setMessageBundle(ResourceBundle messages);
18 | }
19 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/RegistrableListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.List;
15 |
16 | public interface RegistrableListener {
17 | public List registeredFor();
18 |
19 | public void registerFor(String... strings);
20 |
21 | public void registerFor(List strings);
22 | }
23 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/ReqIF10Finder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.ArrayList;
15 | import java.util.Collections;
16 | import java.util.List;
17 |
18 | import org.eclipse.emf.common.util.EList;
19 | import org.eclipse.rmf.reqif10.ReqIF;
20 | import org.eclipse.rmf.reqif10.ReqIFContent;
21 | import org.eclipse.rmf.reqif10.SpecHierarchy;
22 | import org.eclipse.rmf.reqif10.SpecObject;
23 | import org.eclipse.rmf.reqif10.SpecRelation;
24 | import org.eclipse.rmf.reqif10.Specification;
25 | import org.eclipse.rmf.reqif10.common.util.ReqIF10Util;
26 |
27 | public class ReqIF10Finder {
28 | /**
29 | *
30 | * @param object
31 | * @return Find the specification where the ${object} is contained
32 | */
33 | static public Specification findSpecFor(SpecObject object) {
34 | ReqIFContent ric = (ReqIFContent) object.eContainer();
35 | for (Specification spec : ric.getSpecifications()) {
36 | if (has(spec, object))
37 | return spec;
38 | }
39 | return null;
40 | }
41 |
42 | /**
43 | *
44 | * @param spec
45 | * @param object
46 | * @return Lookup the ${spec} if the ${object} is contained
47 | */
48 | static private boolean has(Specification spec, SpecObject object) {
49 | return has(spec.getChildren(), object);
50 | }
51 |
52 | /**
53 | *
54 | * @param children
55 | * @param object
56 | * @return Lookup the ${children} recursively if the ${object} is contained
57 | */
58 | static private boolean has(final EList children,
59 | final SpecObject object) {
60 | for (SpecHierarchy child : children) {
61 | if (child.getObject() != null) {
62 | SpecObject specObject = child.getObject();
63 | if (specObject.getIdentifier().equals(object.getIdentifier()))
64 | return true;
65 | }
66 | if (has(child.getChildren(), object))
67 | return true;
68 | }
69 | return false;
70 | }
71 | /**
72 | * Returns the SpecRelations that use the given SpecObject (via the
73 | * given SpecHierarchy) as a source. Shameless copied from
74 | * ProrAgileGridContentProvider
75 | * @param source
76 | */
77 | static public List getOutgoingSpecRelationsFor(SpecObject source) {
78 | if (source == null) {
79 | return Collections.emptyList();
80 | }
81 | ReqIF reqIF = ReqIF10Util.getReqIF(source);
82 | List list = new ArrayList();
83 | for (SpecRelation relation : reqIF.getCoreContent()
84 | .getSpecRelations()) {
85 | if (source.equals(relation.getSource())) {
86 | list.add(relation);
87 | }
88 | }
89 | return list;
90 | }
91 |
92 | /**
93 | * Returns the SpecRelations that use the given SpecObject (via the
94 | * given SpecHierarchy) as a source. Shameless copied from
95 | * ProrAgileGridContentProvider
96 | * @param target
97 | */
98 | static public List getIncomingSpecRelationsFor(
99 | SpecObject target) {
100 | if (target == null) {
101 | return Collections.emptyList();
102 | }
103 | ReqIF reqIF = ReqIF10Util.getReqIF(target);
104 | List list = new ArrayList();
105 | for (SpecRelation relation : reqIF.getCoreContent()
106 | .getSpecRelations()) {
107 | if (target.equals(relation.getTarget())) {
108 | list.add(relation);
109 | }
110 | }
111 | return list;
112 | }
113 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/ReqIF10Iterator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import org.eclipse.emf.common.util.EList;
15 | import org.eclipse.rmf.reqif10.SpecHierarchy;
16 | import org.eclipse.rmf.reqif10.SpecRelation;
17 | import org.eclipse.rmf.reqif10.Specification;
18 |
19 | public final class ReqIF10Iterator {
20 | public void iterateRecursivelyThrough(
21 | final EList specifications,
22 | final SpecificationCallback specificationCallback,
23 | final SpecObjectCallback specObjectCallback) {
24 | for (Specification specification : specifications) {
25 | this.iterateRecursivelyThrough(specification,
26 | specificationCallback, specObjectCallback);
27 | }
28 | }
29 |
30 | public void iterateRecursivelyThrough(final Specification specification,
31 | final SpecificationCallback specificationCallback,
32 | final SpecObjectCallback specObjectCallback) {
33 | specificationCallback.call(SpecificationDTO.Builder.newBuilder(specification).build());
34 | this.iterateRecursivelyThrough(specification.getChildren(), 0,
35 | specObjectCallback);
36 | }
37 |
38 | private void iterateRecursivelyThrough(
39 | final EList specHierarchies, final int depth,
40 | final SpecObjectCallback specObjectCallback) {
41 | for (SpecHierarchy hierarchy : specHierarchies) {
42 | if (hierarchy.getObject() != null) {
43 | SpecObjectDTO.Builder builder = SpecObjectDTO.Builder
44 | .newBuilder(hierarchy.getObject())
45 | .setOutgoingRelations(
46 | ReqIF10Finder
47 | .getOutgoingSpecRelationsFor(hierarchy
48 | .getObject()))
49 | .setIncomingRelations(
50 | ReqIF10Finder
51 | .getIncomingSpecRelationsFor(hierarchy
52 | .getObject()));
53 | specObjectCallback.call(builder.build(), depth);
54 | }
55 |
56 | this.iterateRecursivelyThrough(hierarchy.getChildren(), depth + 1,
57 | specObjectCallback);
58 | }
59 |
60 | }
61 |
62 | public void iterateThrough(EList relations,
63 | SpecRelationCallback specRelationCallback) {
64 | for (SpecRelation relation : relations) {
65 | SpecRelationDTO dto = SpecRelationDTO.Builder.newBuilder()
66 | .fromRelation(relation).build();
67 | specRelationCallback.call(dto);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/ReqIF10ListenerIterator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.Set;
15 |
16 | import org.eclipse.emf.common.util.EList;
17 | import org.eclipse.rmf.reqif10.SpecRelation;
18 | import org.eclipse.rmf.reqif10.Specification;
19 |
20 | class ReqIF10ListenerIterator {
21 | private final ReqIF10Iterator iterator = new ReqIF10Iterator();
22 | private final SpecObjectListenerRegistry specObjectListenerRegistry = new SpecObjectListenerRegistry();
23 | private final SpecificationListenerRegistry specificationRegistry = new SpecificationListenerRegistry();
24 | private final SpecRelationListenerRegistry specRelationRegistry = new SpecRelationListenerRegistry();
25 |
26 | public void iterateRecursivelyThrough(EList specs) {
27 | this.iterator.iterateRecursivelyThrough(specs,
28 | new SpecificationCallback() {
29 |
30 | @Override
31 | public void call(SpecificationDTO specificationDto) {
32 | for (SpecificationListener listener : specificationRegistry
33 | .getListener(specificationDto.getTypeName())) {
34 | listener.listenOn(specificationDto);
35 | }
36 |
37 | }
38 | }, new SpecObjectCallback() {
39 |
40 | @Override
41 | public void call(SpecObjectDTO specObject, int depth) {
42 | specObjectListenerRegistry
43 | .getListener(specObject.getTypeName())
44 | .setDepth(depth).listenOn(specObject);
45 | }
46 | });
47 |
48 | }
49 |
50 | public void registerSpecObjectListeners(Set listeners) {
51 | this.specObjectListenerRegistry.registerListener(listeners);
52 | }
53 |
54 | public void registerSpecificationListeners(
55 | Set listeners) {
56 | this.specificationRegistry.registerListener(listeners);
57 | }
58 |
59 | public void iterateThrough(EList relations) {
60 | this.iterator.iterateThrough(relations, new SpecRelationCallback() {
61 |
62 | @Override
63 | public void call(SpecRelationDTO relationDTO) {
64 | specRelationRegistry.getListener(relationDTO.getTypeName())
65 | .listenOn(relationDTO);
66 | }
67 | });
68 |
69 | }
70 |
71 | public void registerSpecRelationListeners(
72 | Set listeners) {
73 | this.specRelationRegistry.registerListener(listeners);
74 | }
75 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecObjectCallback.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | interface SpecObjectCallback {
15 | public void call(final SpecObjectDTO specObject, final int depth);
16 |
17 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecObjectDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | import org.eclipse.rmf.reqif10.SpecObject;
18 | import org.eclipse.rmf.reqif10.SpecRelation;
19 |
20 | public final class SpecObjectDTO {
21 | private final SpecObject specObject;
22 | private final List outgoingRelations = new ArrayList();
23 | private final List incomingRelations = new ArrayList();
24 |
25 | private SpecObjectDTO(SpecObject specObject, List outgoing,
26 | List incoming) {
27 | this.specObject = specObject;
28 |
29 | SpecRelationDTO.Builder builder = SpecRelationDTO.Builder.newBuilder();
30 | for (SpecRelation relation : outgoing) {
31 | this.outgoingRelations.add(builder.fromRelation(relation).build());
32 | }
33 | for (SpecRelation relation : incoming) {
34 | this.incomingRelations.add(builder.fromRelation(relation).build());
35 | }
36 | }
37 |
38 | public SpecObject getSpecObject() {
39 | return specObject;
40 | }
41 |
42 | public List getOutgoingRelations() {
43 | return outgoingRelations;
44 | }
45 |
46 | public List getIncomingRelations() {
47 | return incomingRelations;
48 | }
49 |
50 | public String getTypeName() {
51 | return this.getSpecObject().getType().getLongName();
52 | }
53 |
54 | public static final class Builder {
55 | private final SpecObject specObject;
56 | private List outgoingRelations = new ArrayList();
57 | private List incomingRelations = new ArrayList();
58 |
59 | public static Builder newBuilder(final SpecObject specObject) {
60 | return new Builder(specObject);
61 | }
62 |
63 | private Builder(final SpecObject specObject) {
64 | this.specObject = specObject;
65 | }
66 |
67 | public Builder setOutgoingRelations(List outgoingRelations) {
68 | this.outgoingRelations = outgoingRelations;
69 | return this;
70 | }
71 |
72 | public Builder setIncomingRelations(List incomingRelations) {
73 | this.incomingRelations = incomingRelations;
74 | return this;
75 | }
76 |
77 | public SpecObjectDTO build() {
78 | return new SpecObjectDTO(specObject, outgoingRelations,
79 | incomingRelations);
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecObjectListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | public interface SpecObjectListener extends RegistrableListener,
15 | I18nableListener, AttributeListener {
16 | public SpecObjectListener setDepth(final int depth);
17 |
18 | public void listenOn(final SpecObjectDTO object);
19 | }
20 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecObjectListenerRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.Collections;
15 | import java.util.HashMap;
16 | import java.util.List;
17 | import java.util.Map;
18 | import java.util.ResourceBundle;
19 | import java.util.Set;
20 |
21 | class SpecObjectListenerRegistry {
22 | /**
23 | * Null Object
24 | */
25 | private class NullSpecObjectListener implements SpecObjectListener {
26 |
27 | @Override
28 | public void listenOn(SpecObjectDTO object) {
29 | }
30 |
31 | @Override
32 | public SpecObjectListener setDepth(int depth) {
33 | return this;
34 | }
35 |
36 | @Override
37 | public List registeredFor() {
38 | return Collections.emptyList();
39 | }
40 |
41 | @Override
42 | public void registerFor(String... strings) {
43 | }
44 |
45 | @Override
46 | public void registerFor(List strings) {
47 | }
48 |
49 | @Override
50 | public void setRelevantAttributes(List columns) {
51 | }
52 |
53 | @Override
54 | public void addRelevantAttributes(List columns) {
55 |
56 | }
57 |
58 | @Override
59 | public void setMessageBundle(ResourceBundle messages) {
60 | }
61 | }
62 |
63 | private Map listeners = new HashMap();
64 |
65 | /**
66 | *
67 | * @param type
68 | * @param listener
69 | * Register a listener for a type
70 | */
71 | public void registerListener(final SpecObjectListener listener) {
72 | if (listener == null)
73 | return;
74 | for (String type : listener.registeredFor()) {
75 | if (type != null && !type.isEmpty())
76 | this.listeners.put(type, listener);
77 | }
78 | }
79 |
80 | /**
81 | *
82 | * @param types
83 | * @param listener
84 | * Register listener for types
85 | */
86 | public void registerListener(final Set listeners) {
87 | if (listeners == null)
88 | return;
89 | for (SpecObjectListener listener : listeners)
90 | this.registerListener(listener);
91 | }
92 |
93 | /**
94 | *
95 | * @param type
96 | * @return Always a valid listener is returned
97 | */
98 | public SpecObjectListener getListener(final String type) {
99 | SpecObjectListener listener = this.listeners.get(type);
100 | if (listener == null)
101 | return new NullSpecObjectListener();
102 | return listener;
103 | }
104 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecRelationCallback.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | public interface SpecRelationCallback {
15 | public void call(final SpecRelationDTO relationDTO);
16 | }
17 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecRelationDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import org.eclipse.rmf.reqif10.AttributeValue;
15 | import org.eclipse.rmf.reqif10.AttributeValueString;
16 | import org.eclipse.rmf.reqif10.SpecRelation;
17 | import org.eclipse.rmf.reqif10.common.util.ReqIF10Util;
18 |
19 | public final class SpecRelationDTO {
20 | private final SpecRelation relation;
21 |
22 | private SpecRelationDTO(final SpecRelation relation) {
23 | this.relation = relation;
24 | }
25 |
26 | public SpecRelation getRelation() {
27 | return relation;
28 | }
29 |
30 | public String getValueFor(final String label) {
31 | String value = "";
32 | AttributeValue avRel = ReqIF10Util.getAttributeValueForLabel(
33 | this.getRelation(), label);
34 | if (avRel != null && avRel instanceof AttributeValueString) {
35 | value = ((AttributeValueString) avRel).getTheValue();
36 | }
37 | return value;
38 | }
39 |
40 | public String getTypeName() {
41 | return this.relation.getLongName();
42 | }
43 |
44 | public static final class Builder {
45 | private SpecRelation relation;
46 |
47 | private Builder() {
48 | }
49 |
50 | public static Builder newBuilder() {
51 | return new Builder();
52 | }
53 |
54 | public Builder fromRelation(final SpecRelation relation) {
55 | this.relation = relation;
56 | return this;
57 | }
58 |
59 | public SpecRelationDTO build() {
60 | return new SpecRelationDTO(this.relation);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecRelationListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | public interface SpecRelationListener extends RegistrableListener,
15 | I18nableListener, AttributeListener {
16 |
17 | void listenOn(final SpecRelationDTO specRelationDTO);
18 | }
19 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecRelationListenerRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.Collections;
15 | import java.util.HashMap;
16 | import java.util.List;
17 | import java.util.Map;
18 | import java.util.ResourceBundle;
19 | import java.util.Set;
20 |
21 | class SpecRelationListenerRegistry {
22 | private class NullSpecRelationListener implements SpecRelationListener {
23 |
24 | @Override
25 | public void listenOn(SpecRelationDTO specRelationDTO) {
26 | }
27 |
28 | @Override
29 | public List registeredFor() {
30 | return Collections.emptyList();
31 | }
32 |
33 | @Override
34 | public void registerFor(String... strings) {
35 | }
36 |
37 | @Override
38 | public void registerFor(List strings) {
39 | }
40 |
41 | @Override
42 | public void setMessageBundle(ResourceBundle messages) {
43 | }
44 |
45 | @Override
46 | public void setRelevantAttributes(List attributes) {
47 | }
48 |
49 | @Override
50 | public void addRelevantAttributes(List attributes) {
51 | }
52 | }
53 |
54 | private Map listeners = new HashMap<>();
55 |
56 | public void registerListener(final SpecRelationListener listener) {
57 | if (listener == null)
58 | return;
59 | for (String type : listener.registeredFor()) {
60 | this.listeners.put(type, listener);
61 | }
62 | }
63 |
64 | public void registerListener(final Set listeners) {
65 | if (listeners == null)
66 | return;
67 | for (SpecRelationListener listener : listeners)
68 | this.registerListener(listener);
69 | }
70 |
71 | public SpecRelationListener getListener(final String type) {
72 | SpecRelationListener listener = this.listeners.get(type);
73 | if (listener == null)
74 | return new NullSpecRelationListener();
75 | return listener;
76 |
77 | }
78 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecificationCallback.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 |
15 | public interface SpecificationCallback {
16 | public void call(final SpecificationDTO specificationDto);
17 | }
18 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecificationDTO.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import org.eclipse.rmf.reqif10.AttributeDefinition;
15 | import org.eclipse.rmf.reqif10.AttributeValue;
16 | import org.eclipse.rmf.reqif10.Specification;
17 | import org.eclipse.rmf.reqif10.common.util.ReqIF10Util;
18 |
19 | public class SpecificationDTO {
20 | private final Specification specification;
21 |
22 | private SpecificationDTO(final Specification specification) {
23 | this.specification = specification;
24 | }
25 |
26 | public String getTypeName() {
27 | return specification.getLongName();
28 | }
29 |
30 | public String getAttributeValue(int index) {
31 | if (specification.getValues().size() > index) {
32 | AttributeValue av = specification.getValues().get(index);
33 | AttributeDefinition ad = ReqIF10Util.getAttributeDefinition(av);
34 | if (ad != null) {
35 | return ReqIF10Util.getTheValue(av).toString();
36 | }
37 | }
38 | return null;
39 | }
40 |
41 | public static final class Builder {
42 | private final Specification specification;
43 |
44 | public static Builder newBuilder(final Specification specification) {
45 | return new Builder(specification);
46 | }
47 |
48 | private Builder(final Specification specification) {
49 | this.specification = specification;
50 | }
51 |
52 | public SpecificationDTO build() {
53 | return new SpecificationDTO(specification);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecificationListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 |
15 | public interface SpecificationListener extends RegistrableListener, AttributeListener {
16 |
17 | public void listenOn(final SpecificationDTO specification);
18 | }
19 |
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/SpecificationListenerRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.util.ArrayList;
15 | import java.util.HashMap;
16 | import java.util.HashSet;
17 | import java.util.List;
18 | import java.util.Map;
19 | import java.util.Set;
20 |
21 | class SpecificationListenerRegistry {
22 | private class NullSpecificationListener implements SpecificationListener {
23 |
24 | @Override
25 | public void listenOn(SpecificationDTO spec) {
26 | }
27 |
28 | @Override
29 | public List registeredFor() {
30 | return new ArrayList();
31 | }
32 |
33 | @Override
34 | public void registerFor(String... strings) {
35 | }
36 |
37 | @Override
38 | public void registerFor(List strings) {
39 | }
40 |
41 | @Override
42 | public void setRelevantAttributes(List attributes) {
43 | }
44 |
45 | @Override
46 | public void addRelevantAttributes(List attributes) {
47 | }
48 | }
49 |
50 | private Map> listeners = new HashMap<>();
51 |
52 | /**
53 | *
54 | * @param type
55 | * @return a listener. Always a valid listener is returned.
56 | */
57 | public Set getListener(final String type) {
58 | Set listeners = this.listeners.get(type);
59 | if (listeners == null) {
60 | listeners = new HashSet<>();
61 | listeners.add(new NullSpecificationListener());
62 | }
63 | return listeners;
64 | }
65 |
66 | /**
67 | * Register a listener
68 | *
69 | * @param listener
70 | */
71 | public void registerListener(final SpecificationListener listener) {
72 | if (listener == null)
73 | return;
74 | for (String type : listener.registeredFor()) {
75 | if (!this.listeners.containsKey(type)) {
76 | this.listeners.put(type, new HashSet());
77 | }
78 | this.listeners.get(type).add(listener);
79 | }
80 |
81 | }
82 |
83 | /**
84 | * Register a listener
85 | *
86 | * @param type
87 | * @param listener
88 | */
89 | public void registerListener(final Set listeners) {
90 | if (listeners == null)
91 | return;
92 | for (SpecificationListener listener : listeners)
93 | this.registerListener(listener);
94 | }
95 | }
--------------------------------------------------------------------------------
/reqifiterator/src/main/java/de/kay_muench/reqif10/reqifiterator/XhtmlContentProcessor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 Kay Erik Münch.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.spdx.org/licenses/EPL-1.0
7 | *
8 | * Contributors:
9 | * Kay Erik Münch - initial API and implementation
10 | *
11 | */
12 | package de.kay_muench.reqif10.reqifiterator;
13 |
14 | import java.io.IOException;
15 | import java.io.StringWriter;
16 | import java.util.Collections;
17 | import java.util.HashMap;
18 | import java.util.Map;
19 |
20 | import org.eclipse.emf.ecore.EObject;
21 | import org.eclipse.emf.ecore.xmi.XMLResource;
22 | import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
23 | import org.eclipse.rmf.reqif10.XhtmlContent;
24 |
25 | final class XhtmlContentProcessor {
26 |
27 | public static String generateXMLString(XhtmlContent content) {
28 | String xmlContent = "";
29 | try {
30 | xmlContent = generateXMLString((EObject) content.getXhtml());
31 | xmlContent = xmlContent.replaceAll("<.?reqif.*>", "");
32 | xmlContent = xmlContent.replaceAll("xhtml:", "");
33 | xmlContent = xmlContent.replaceAll("[\\n\\r]", "");
34 | xmlContent = xmlContent
35 | .replaceAll("", "$1");
36 | } catch (IOException e) {
37 | xmlContent = "" + e.getMessage() + "
";
38 | }
39 |
40 | return xmlContent.trim();
41 | }
42 |
43 | // Shameless copied from ProrXhtmlSimplifiedHelper
44 | private static String generateXMLString(EObject eobject) throws IOException {
45 | StringWriter sw = new StringWriter();
46 | Map