├── LICENSE
├── README.md
├── VERSION.md
├── features
└── edu.uoc.som.jsonschematouml.feature
│ ├── .project
│ ├── build.properties
│ └── feature.xml
└── plugins
├── edu.uoc.som.jsonschematouml.test
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── META-INF
│ └── MANIFEST.MF
├── build.properties
├── inputs
│ ├── testAny.json
│ ├── testArray.json
│ ├── testInvalid.json
│ ├── testNumericInstance.json
│ ├── testObject.json
│ ├── testSet
│ │ ├── set1.json
│ │ └── set2.json
│ ├── testString.json
│ ├── testTitleDescription.json
│ ├── testValid.json
│ └── testWrong.json
├── lib
│ ├── json-schema-validator-2.2.6-lib.jar
│ └── json-schema-validator-2.2.6.jar
└── src
│ └── edu
│ └── uoc
│ └── som
│ └── jsonschematouml
│ ├── generators
│ └── test
│ │ ├── JSONSchemaToUMLTest.java
│ │ └── JSONSchemaURITest.java
│ └── validator
│ └── test
│ └── JSONSchemaValidatorTest.java
├── edu.uoc.som.jsonschematouml.ui
├── .classpath
├── .gitignore
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── META-INF
│ └── MANIFEST.MF
├── build.properties
├── images
│ ├── logo-512.png
│ ├── logo.png
│ └── logo.svg
├── plugin.xml
└── src
│ └── edu
│ └── uoc
│ └── som
│ └── jsonschematouml
│ └── ui
│ ├── JSONSchemaToUMLUIPlugin.java
│ └── handlers
│ └── ConvertToClassDiagram.java
└── edu.uoc.som.jsonschematouml
├── .classpath
├── .gitignore
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── META-INF
└── MANIFEST.MF
├── build.properties
├── lib
├── json-schema-validator-2.2.6-lib.jar
└── json-schema-validator-2.2.6.jar
└── src
└── edu
└── uoc
└── som
└── jsonschematouml
├── generators
├── JSONSchemaToUML.java
├── JSONSchemaToUMLException.java
└── JSONSchemaURI.java
└── validator
└── JSONSchemaValidator.java
/LICENSE:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 2.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
4 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
5 | OF THE PROGRAM 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 content
12 | Distributed under this Agreement, and
13 |
14 | b) in the case of each subsequent Contributor:
15 | i) changes to the Program, and
16 | ii) additions to the Program;
17 | where such changes and/or additions to the Program originate from
18 | and are Distributed by that particular Contributor. A Contribution
19 | "originates" from a Contributor if it was added to the Program by
20 | such Contributor itself or anyone acting on such Contributor's behalf.
21 | Contributions do not include changes or additions to the Program that
22 | are not Modified Works.
23 |
24 | "Contributor" means any person or entity that Distributes the Program.
25 |
26 | "Licensed Patents" mean patent claims licensable by a Contributor which
27 | are necessarily infringed by the use or sale of its Contribution alone
28 | or when combined with the Program.
29 |
30 | "Program" means the Contributions Distributed in accordance with this
31 | Agreement.
32 |
33 | "Recipient" means anyone who receives the Program under this Agreement
34 | or any Secondary License (as applicable), including Contributors.
35 |
36 | "Derivative Works" shall mean any work, whether in Source Code or other
37 | form, that is based on (or derived from) the Program and for which the
38 | editorial revisions, annotations, elaborations, or other modifications
39 | represent, as a whole, an original work of authorship.
40 |
41 | "Modified Works" shall mean any work in Source Code or other form that
42 | results from an addition to, deletion from, or modification of the
43 | contents of the Program, including, for purposes of clarity any new file
44 | in Source Code form that contains any contents of the Program. Modified
45 | Works shall not include works that contain only declarations,
46 | interfaces, types, classes, structures, or files of the Program solely
47 | in each case in order to link to, bind by name, or subclass the Program
48 | or Modified Works thereof.
49 |
50 | "Distribute" means the acts of a) distributing or b) making available
51 | in any manner that enables the transfer of a copy.
52 |
53 | "Source Code" means the form of a Program preferred for making
54 | modifications, including but not limited to software source code,
55 | documentation source, and configuration files.
56 |
57 | "Secondary License" means either the GNU General Public License,
58 | Version 2.0, or any later versions of that license, including any
59 | exceptions or additional permissions as identified by the initial
60 | Contributor.
61 |
62 | 2. GRANT OF RIGHTS
63 |
64 | a) Subject to the terms of this Agreement, each Contributor hereby
65 | grants Recipient a non-exclusive, worldwide, royalty-free copyright
66 | license to reproduce, prepare Derivative Works of, publicly display,
67 | publicly perform, Distribute and sublicense the Contribution of such
68 | Contributor, if any, and such Derivative Works.
69 |
70 | b) Subject to the terms of this Agreement, each Contributor hereby
71 | grants Recipient a non-exclusive, worldwide, royalty-free patent
72 | license under Licensed Patents to make, use, sell, offer to sell,
73 | import and otherwise transfer the Contribution of such Contributor,
74 | if any, in Source Code or other form. This patent license shall
75 | apply to the combination of the Contribution and the Program if, at
76 | the time the Contribution is added by the Contributor, such addition
77 | of the Contribution causes such combination to be covered by the
78 | Licensed Patents. The patent license shall not apply to any other
79 | combinations which include the Contribution. No hardware per se is
80 | licensed hereunder.
81 |
82 | c) Recipient understands that although each Contributor grants the
83 | licenses to its Contributions set forth herein, no assurances are
84 | provided by any Contributor that the Program does not infringe the
85 | patent or other intellectual property rights of any other entity.
86 | Each Contributor disclaims any liability to Recipient for claims
87 | brought by any other entity based on infringement of intellectual
88 | property rights or otherwise. As a condition to exercising the
89 | rights and licenses granted hereunder, each Recipient hereby
90 | assumes sole responsibility to secure any other intellectual
91 | property rights needed, if any. For example, if a third party
92 | patent license is required to allow Recipient to Distribute the
93 | Program, it is Recipient's responsibility to acquire that license
94 | before distributing the Program.
95 |
96 | d) Each Contributor represents that to its knowledge it has
97 | sufficient copyright rights in its Contribution, if any, to grant
98 | the copyright license set forth in this Agreement.
99 |
100 | e) Notwithstanding the terms of any Secondary License, no
101 | Contributor makes additional grants to any Recipient (other than
102 | those set forth in this Agreement) as a result of such Recipient's
103 | receipt of the Program under the terms of a Secondary License
104 | (if permitted under the terms of Section 3).
105 |
106 | 3. REQUIREMENTS
107 |
108 | 3.1 If a Contributor Distributes the Program in any form, then:
109 |
110 | a) the Program must also be made available as Source Code, in
111 | accordance with section 3.2, and the Contributor must accompany
112 | the Program with a statement that the Source Code for the Program
113 | is available under this Agreement, and informs Recipients how to
114 | obtain it in a reasonable manner on or through a medium customarily
115 | used for software exchange; and
116 |
117 | b) the Contributor may Distribute the Program under a license
118 | different than this Agreement, provided that such license:
119 | i) effectively disclaims on behalf of all other Contributors all
120 | warranties and conditions, express and implied, including
121 | warranties or conditions of title and non-infringement, and
122 | implied warranties or conditions of merchantability and fitness
123 | for a particular purpose;
124 |
125 | ii) effectively excludes on behalf of all other Contributors all
126 | liability for damages, including direct, indirect, special,
127 | incidental and consequential damages, such as lost profits;
128 |
129 | iii) does not attempt to limit or alter the recipients' rights
130 | in the Source Code under section 3.2; and
131 |
132 | iv) requires any subsequent distribution of the Program by any
133 | party to be under a license that satisfies the requirements
134 | of this section 3.
135 |
136 | 3.2 When the Program is Distributed as Source Code:
137 |
138 | a) it must be made available under this Agreement, or if the
139 | Program (i) is combined with other material in a separate file or
140 | files made available under a Secondary License, and (ii) the initial
141 | Contributor attached to the Source Code the notice described in
142 | Exhibit A of this Agreement, then the Program may be made available
143 | under the terms of such Secondary Licenses, and
144 |
145 | b) a copy of this Agreement must be included with each copy of
146 | the Program.
147 |
148 | 3.3 Contributors may not remove or alter any copyright, patent,
149 | trademark, attribution notices, disclaimers of warranty, or limitations
150 | of liability ("notices") contained within the Program from any copy of
151 | the Program which they Distribute, provided that Contributors may add
152 | their own appropriate notices.
153 |
154 | 4. COMMERCIAL DISTRIBUTION
155 |
156 | Commercial distributors of software may accept certain responsibilities
157 | with respect to end users, business partners and the like. While this
158 | license is intended to facilitate the commercial use of the Program,
159 | the Contributor who includes the Program in a commercial product
160 | offering should do so in a manner which does not create potential
161 | liability for other Contributors. Therefore, if a Contributor includes
162 | the Program in a commercial product offering, such Contributor
163 | ("Commercial Contributor") hereby agrees to defend and indemnify every
164 | other Contributor ("Indemnified Contributor") against any losses,
165 | damages and costs (collectively "Losses") arising from claims, lawsuits
166 | and other legal actions brought by a third party against the Indemnified
167 | Contributor to the extent caused by the acts or omissions of such
168 | Commercial Contributor in connection with its distribution of the Program
169 | in a commercial product offering. The obligations in this section do not
170 | apply to any claims or Losses relating to any actual or alleged
171 | intellectual property infringement. In order to qualify, an Indemnified
172 | Contributor must: a) promptly notify the Commercial Contributor in
173 | writing of such claim, and b) allow the Commercial Contributor to control,
174 | and cooperate with the Commercial Contributor in, the defense and any
175 | related settlement negotiations. The Indemnified Contributor may
176 | participate in any such claim at its own expense.
177 |
178 | For example, a Contributor might include the Program in a commercial
179 | product offering, Product X. That Contributor is then a Commercial
180 | Contributor. If that Commercial Contributor then makes performance
181 | claims, or offers warranties related to Product X, those performance
182 | claims and warranties are such Commercial Contributor's responsibility
183 | alone. Under this section, the Commercial Contributor would have to
184 | defend claims against the other Contributors related to those performance
185 | claims and warranties, and if a court requires any other Contributor to
186 | pay any damages as a result, the Commercial Contributor must pay
187 | those damages.
188 |
189 | 5. NO WARRANTY
190 |
191 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
192 | PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
193 | BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
194 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
195 | TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
196 | PURPOSE. Each Recipient is solely responsible for determining the
197 | appropriateness of using and distributing the Program and assumes all
198 | risks associated with its exercise of rights under this Agreement,
199 | including but not limited to the risks and costs of program errors,
200 | compliance with applicable laws, damage to or loss of data, programs
201 | or equipment, and unavailability or interruption of operations.
202 |
203 | 6. DISCLAIMER OF LIABILITY
204 |
205 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
206 | PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
207 | SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
208 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
209 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
210 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
211 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
212 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
213 | POSSIBILITY OF SUCH DAMAGES.
214 |
215 | 7. GENERAL
216 |
217 | If any provision of this Agreement is invalid or unenforceable under
218 | applicable law, it shall not affect the validity or enforceability of
219 | the remainder of the terms of this Agreement, and without further
220 | action by the parties hereto, such provision shall be reformed to the
221 | minimum extent necessary to make such provision valid and enforceable.
222 |
223 | If Recipient institutes patent litigation against any entity
224 | (including a cross-claim or counterclaim in a lawsuit) alleging that the
225 | Program itself (excluding combinations of the Program with other software
226 | or hardware) infringes such Recipient's patent(s), then such Recipient's
227 | rights granted under Section 2(b) shall terminate as of the date such
228 | litigation is filed.
229 |
230 | All Recipient's rights under this Agreement shall terminate if it
231 | fails to comply with any of the material terms or conditions of this
232 | Agreement and does not cure such failure in a reasonable period of
233 | time after becoming aware of such noncompliance. If all Recipient's
234 | rights under this Agreement terminate, Recipient agrees to cease use
235 | and distribution of the Program as soon as reasonably practicable.
236 | However, Recipient's obligations under this Agreement and any licenses
237 | granted by Recipient relating to the Program shall continue and survive.
238 |
239 | Everyone is permitted to copy and distribute copies of this Agreement,
240 | but in order to avoid inconsistency the Agreement is copyrighted and
241 | may only be modified in the following manner. The Agreement Steward
242 | reserves the right to publish new versions (including revisions) of
243 | this Agreement from time to time. No one other than the Agreement
244 | Steward has the right to modify this Agreement. The Eclipse Foundation
245 | is the initial Agreement Steward. The Eclipse Foundation may assign the
246 | responsibility to serve as the Agreement Steward to a suitable separate
247 | entity. Each new version of the Agreement will be given a distinguishing
248 | version number. The Program (including Contributions) may always be
249 | Distributed subject to the version of the Agreement under which it was
250 | received. In addition, after a new version of the Agreement is published,
251 | Contributor may elect to Distribute the Program (including its
252 | Contributions) under the new version.
253 |
254 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
255 | receives no rights or licenses to the intellectual property of any
256 | Contributor under this Agreement, whether expressly, by implication,
257 | estoppel or otherwise. All rights in the Program not expressly granted
258 | under this Agreement are reserved. Nothing in this Agreement is intended
259 | to be enforceable by any entity that is not a Contributor or Recipient.
260 | No third-party beneficiary rights are created under this Agreement.
261 |
262 | Exhibit A - Form of Secondary Licenses Notice
263 |
264 | "This Source Code may also be made available under the following
265 | Secondary Licenses when the conditions for such availability set forth
266 | in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
267 | version(s), and exceptions or additional permissions here}."
268 |
269 | Simply including a copy of this Agreement, including this Exhibit A
270 | is not sufficient to license the Source Code under Secondary Licenses.
271 |
272 | If it is not possible or desirable to put the notice in a particular
273 | file, then You may include the notice in a location (such as a LICENSE
274 | file in a relevant directory) where a recipient would be likely to
275 | look for such a notice.
276 |
277 | You may add additional accurate notices of copyright ownership.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # jsonSchema-to-uml
4 |
5 | A tool to generate UML models from JSON schema documents.
6 |
7 | ## Requirements
8 |
9 | To generate UML models:
10 |
11 | - Eclipse Modeling tools (it can be found [here](http://www.eclipse.org/downloads/packages/eclipse-modeling-tools/oxygen2)).
12 |
13 | To visualize the generated UML models:
14 |
15 | - A UML 2.5 modeling environment in Eclipse such as [Papyrus](https://www.eclipse.org/papyrus/) or [UMLDesigner](https://marketplace.eclipse.org/content/uml-designer) (we tested the tool with Papyrus).
16 |
17 | ## Installation
18 |
19 | 1. Open Eclipse IDE
20 | 2. Click on *Help / Install New Software...*
21 | 3. Click on *Add...* and fill in the form as indicated. The update site is
22 | ```
23 | https://som-research.github.io/jsonSchema-to-uml/update/
24 | ```
25 | 4. Select *JSONSchema to UML* then click on *Next*.
26 | 5. Follow the the rest of the steps (license, etc...) and reboot Eclipse.
27 |
28 | ## Using the plugin
29 |
30 | 1. Create a Project or use an existing project in your workspace.
31 | 2. [Import](https://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2FgettingStarted%2Fqs-31a.htm) the JSON Schema documents in your Eclipse project.
32 | 3. To generate a UML model from your documents you can right-click on a JSON file of your project or a folder containing your documents, and select the *JSONSchema to UML/Generate Class diagram* option.
33 | 4. A UML model corresponding to the input definition will be generated in the folder *src-gen* of your project.
34 |
35 | ## Visualizing the Class diagram using Papyrus
36 |
37 | 1. Install Papyrus if you didn't do it yet (You can find the instructions [here](https://www.eclipse.org/papyrus/download.html)).
38 | 2. Open the perspective *Papyrus*.
39 | 3. Right-click on the generated UML model and select *New -> Papyrus Model*.
40 | 4. Follow the steps in the wizard to initialize a Class diagram (keep everything as predefined except in the *Initialization information* step where you should check *Class Diagram* as the Representation kind).
41 | 5. Drag-and-drop the UML elements from the *Model Explrer* into the editor.
42 | 6. Align and arrange the layout as you prefer.
43 | 7. Save.
44 |
45 | ## The mapping in a nutshell
46 | The generation process apply this (non exhaustive) list of mappings:
47 | * Each JSON Schema element is represented by a UML Class
48 | * Properties in JSON Schema elements represent the properties of a UML Class.
49 | * If the property is of primitive type it will become an attribute in the UML Class
50 | * If the property is of type enum, an Enumeration will be created and an attribute in the UML Class will be added
51 | * If the property is of type object or refers to other element (using $ref), an association is created in the UML Class. The type of the association corresponds to the UML Class element created from the object (or the referred object)
52 | * Hierarchies are created from ``allOf``, ``oneOf``, ``anyOf``
53 | * The elements defined in ``definitions`` are considered as a library of JSON Schema elements and therefore they generate new UML Classes
54 | * The folder structure is used to created UML Packages containing the UML Classes coming from the JSON Schema files.
--------------------------------------------------------------------------------
/VERSION.md:
--------------------------------------------------------------------------------
1 | 0.0.6
--------------------------------------------------------------------------------
/features/edu.uoc.som.jsonschematouml.feature/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | edu.uoc.som.jsonschematouml.feature
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.pde.FeatureBuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.pde.FeatureNature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/features/edu.uoc.som.jsonschematouml.feature/build.properties:
--------------------------------------------------------------------------------
1 | bin.includes = feature.xml
2 |
--------------------------------------------------------------------------------
/features/edu.uoc.som.jsonschematouml.feature/feature.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 | Generate UML models from JSON Schema documents
10 |
11 |
12 |
13 | SOM Resesearch Lab (c) 2018.
14 |
15 |
16 |
17 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
18 |
19 | 1. DEFINITIONS
20 | “Contribution” means:
21 |
22 | a) in the case of the initial Contributor, the initial content Distributed under this Agreement, and
23 | b) in the case of each subsequent Contributor:
24 | i) changes to the Program, and
25 | ii) additions to the Program;
26 | where such changes and/or additions to the Program originate from and are Distributed by that particular Contributor. A Contribution “originates” from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include changes or additions to the Program that are not Modified Works.
27 | “Contributor” means any person or entity that Distributes the Program.
28 |
29 | “Licensed Patents” mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
30 |
31 | “Program” means the Contributions Distributed in accordance with this Agreement.
32 |
33 | “Recipient” means anyone who receives the Program under this Agreement or any Secondary License (as applicable), including Contributors.
34 |
35 | “Derivative Works” shall mean any work, whether in Source Code or other form, that is based on (or derived from) the Program and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship.
36 |
37 | “Modified Works” shall mean any work in Source Code or other form that results from an addition to, deletion from, or modification of the contents of the Program, including, for purposes of clarity any new file in Source Code form that contains any contents of the Program. Modified Works shall not include works that contain only declarations, interfaces, types, classes, structures, or files of the Program solely in each case in order to link to, bind by name, or subclass the Program or Modified Works thereof.
38 |
39 | “Distribute” means the acts of a) distributing or b) making available in any manner that enables the transfer of a copy.
40 |
41 | “Source Code” means the form of a Program preferred for making modifications, including but not limited to software source code, documentation source, and configuration files.
42 |
43 | “Secondary License” means either the GNU General Public License, Version 2.0, or any later versions of that license, including any exceptions or additional permissions as identified by the initial Contributor.
44 |
45 | 2. GRANT OF RIGHTS
46 | a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, Distribute and sublicense the Contribution of such Contributor, if any, and such Derivative Works.
47 | b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in Source Code or other form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
48 | c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to Distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
49 | d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
50 | e) Notwithstanding the terms of any Secondary License, no Contributor makes additional grants to any Recipient (other than those set forth in this Agreement) as a result of such Recipient's receipt of the Program under the terms of a Secondary License (if permitted under the terms of Section 3).
51 | 3. REQUIREMENTS
52 | 3.1 If a Contributor Distributes the Program in any form, then:
53 |
54 | a) the Program must also be made available as Source Code, in accordance with section 3.2, and the Contributor must accompany the Program with a statement that the Source Code for the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and
55 | b) the Contributor may Distribute the Program under a license different than this Agreement, provided that such license:
56 | i) effectively disclaims on behalf of all other Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
57 | ii) effectively excludes on behalf of all other Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
58 | iii) does not attempt to limit or alter the recipients' rights in the Source Code under section 3.2; and
59 | iv) requires any subsequent distribution of the Program by any party to be under a license that satisfies the requirements of this section 3.
60 | 3.2 When the Program is Distributed as Source Code:
61 |
62 | a) it must be made available under this Agreement, or if the Program (i) is combined with other material in a separate file or files made available under a Secondary License, and (ii) the initial Contributor attached to the Source Code the notice described in Exhibit A of this Agreement, then the Program may be made available under the terms of such Secondary Licenses, and
63 | b) a copy of this Agreement must be included with each copy of the Program.
64 | 3.3 Contributors may not remove or alter any copyright, patent, trademark, attribution notices, disclaimers of warranty, or limitations of liability (‘notices’) contained within the Program from any copy of the Program which they Distribute, provided that Contributors may add their own appropriate notices.
65 |
66 | 4. COMMERCIAL DISTRIBUTION
67 | Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify every other Contributor (“Indemnified Contributor”) against any losses, damages and costs (collectively “Losses”) arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
68 |
69 | For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
70 |
71 | 5. NO WARRANTY
72 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
73 |
74 | 6. DISCLAIMER OF LIABILITY
75 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
76 |
77 | 7. GENERAL
78 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
79 |
80 | If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
81 |
82 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
83 |
84 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be Distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to Distribute the Program (including its Contributions) under the new version.
85 |
86 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. Nothing in this Agreement is intended to be enforceable by any entity that is not a Contributor or Recipient. No third-party beneficiary rights are created under this Agreement.
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
111 |
112 |
118 |
119 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 | /inputs
3 | !/inputs/testSet
4 | !/inputs/*.json
5 | /outputs
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | edu.uoc.som.jsonschematouml.test
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.pde.PluginNature
26 | org.eclipse.jdt.core.javanature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/.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.8
4 | org.eclipse.jdt.core.compiler.compliance=1.8
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=1.8
8 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: JSON Schema to UML test cases
4 | Bundle-SymbolicName: edu.uoc.som.jsonschematouml.test
5 | Bundle-Version: 0.0.6.qualifier
6 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8
7 | Bundle-Vendor: SOM Research Lab
8 | Require-Bundle: com.google.gson;bundle-version="2.7.0",
9 | org.eclipse.emf.ecore;bundle-version="2.15.0",
10 | org.eclipse.emf.ecore.xmi;bundle-version="2.15.0",
11 | org.eclipse.uml2.uml;bundle-version="5.3.0",
12 | org.eclipse.uml2.uml.resources;bundle-version="5.3.0",
13 | edu.uoc.som.jsonschematouml,
14 | org.junit
15 | Bundle-ClassPath: lib/json-schema-validator-2.2.6-lib.jar,
16 | lib/json-schema-validator-2.2.6.jar,
17 | .
18 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/build.properties:
--------------------------------------------------------------------------------
1 | source.. = src/
2 | output.. = bin/
3 | bin.includes = META-INF/,\
4 | .,\
5 | inputs/,\
6 | lib/,\
7 | lib/json-schema-validator-2.2.6-lib.jar,\
8 | lib/json-schema-validator-2.2.6.jar
9 | src.includes = inputs/
10 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testAny.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/anyInstance/schema.json",
4 | "title": "Test data for any instance",
5 | "description": "This schema contains data to test any instances (6.1 in validation JSON specificacion)",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "att1": {
11 | "type": "boolean"
12 | },
13 | "att2": {
14 | "type": "object"
15 | },
16 | "att3": {
17 | "type": "array"
18 | },
19 | "att4": {
20 | "type": "number"
21 | },
22 | "att5": {
23 | "type": "integer"
24 | },
25 | "att6": {
26 | "type": "string",
27 | "enum": [
28 | "val1",
29 | "val2",
30 | "val3"
31 | ]
32 | },
33 | "att7": {
34 | "type": "string",
35 | "const" : "CONSTANT"
36 | }
37 | }
38 | }
39 | ],
40 | "required": [
41 | "att1"
42 | ]
43 | }
44 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testArray.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/arrayInstance/schema.json",
4 | "title": "Test data for array instance",
5 | "description": "This schema contains data to test array instances (6.4 in validation JSON specificacion)",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "att1": {
11 | "type": "array",
12 | "items" : {
13 | "type" : "string"
14 | }
15 | },
16 | "att2": {
17 | "type": "array",
18 | "items" : {
19 | "type" : "string",
20 | "enum" : [
21 | "val1",
22 | "val2"
23 | ]
24 | }
25 | },
26 | "att2": {
27 | "type": "array",
28 | "items" : {
29 | "type" : "integer"
30 | }
31 | }
32 | }
33 | }
34 | ],
35 | "required": [
36 | "att1"
37 | ]
38 | }
39 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testInvalid.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/anyInstance/schema.json",
4 | "title": "Test data for any instance",
5 | "description": "This schema contains data to test any instances (6.1 in validation JSON specificacion)",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "att1": {
11 | "type": {
12 | "type" : "string"
13 | }
14 | },
15 | "att2": {
16 | "type": "object"
17 | },
18 | "att3": {
19 | "type": "array"
20 | },
21 | "att4": {
22 | "type": "number"
23 | },
24 | "att5": {
25 | "type": "integer"
26 | },
27 | "att6": {
28 | "type": "string",
29 | "enum": [
30 | "val1",
31 | "val2",
32 | "val3"
33 | ]
34 | },
35 | "att7": {
36 | "type": "string",
37 | "const" : "CONSTANT"
38 | }
39 | }
40 | }
41 | ],
42 | "required": [
43 | "att1"
44 | ]
45 | }
46 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testNumericInstance.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/numericInstance/schema.json",
4 | "title": "Test data for numeric instance",
5 | "description": "This schema contains data to test numeric instances (6.2 in validation JSON specificacion)",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "att1": {
11 | "type": "number",
12 | "multipleOf" : 2,
13 | "minimum" : 0,
14 | "maximum" : 10
15 |
16 | },
17 | "att2": {
18 | "type": "integer",
19 | "exclusiveMaximum" : 10,
20 | "exclusiveMinimum" : 0
21 | }
22 | }
23 | }
24 | ],
25 | "required": [
26 | "att1",
27 | "att2"
28 | ]
29 | }
30 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/objectInstance/schema.json",
4 | "title": "Test data for object instance",
5 | "description": "This schema contains data to test object instances (6.5 in validation JSON specificacion)",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "att1": {
11 | "type": "string"
12 | }
13 | }
14 | }
15 | ],
16 | "required": [
17 | "att1"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testSet/set1.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschemadiscoverer/test/setInstance1/schema.json",
4 | "title": "Test data for any instance",
5 | "description": "This schema checks the use of several files",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "set1Att": {
11 | "type": "boolean"
12 | }
13 | }
14 | }
15 | ],
16 | "required": [
17 | "set1Att"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testSet/set2.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschemadiscoverer/test/setInstance2/schema.json",
4 | "title": "Test data for any instance",
5 | "description": "This schema checks the use of several files",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "set2Att": {
11 | "type": "boolean"
12 | }
13 | }
14 | }
15 | ],
16 | "required": [
17 | "set2Att"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testString.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/stringInstance/schema.json",
4 | "title": "Test data for string instance",
5 | "description": "This schema contains data to test string instances (6.3 in validation JSON specificacion)",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "att1": {
11 | "type": "string",
12 | "maxLength" : 0,
13 | "minLength" : 2,
14 | "pattern" : "^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!,:\\\\]+$"
15 | }
16 | }
17 | }
18 | ],
19 | "required": [
20 | "att1"
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testTitleDescription.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/titleDescription/schema.json",
4 | "title": "titleTest",
5 | "description": "descriptionTest",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "att1": {
11 | "type": "string"
12 | }
13 | }
14 | }
15 | ],
16 | "required": [
17 | "att1"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testValid.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/anyInstance/schema.json",
4 | "title": "Test data for any instance",
5 | "description": "This schema contains data to test any instances (6.1 in validation JSON specificacion)",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "properties": {
10 | "att1": {
11 | "type": "boolean"
12 | },
13 | "att2": {
14 | "type": "object"
15 | },
16 | "att3": {
17 | "type": "array"
18 | },
19 | "att4": {
20 | "type": "number"
21 | },
22 | "att5": {
23 | "type": "integer"
24 | },
25 | "att6": {
26 | "type": "string",
27 | "enum": [
28 | "val1",
29 | "val2",
30 | "val3"
31 | ]
32 | },
33 | "att7": {
34 | "type": "string",
35 | "const" : "CONSTANT"
36 | }
37 | }
38 | }
39 | ],
40 | "required": [
41 | "att1"
42 | ]
43 | }
44 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/inputs/testWrong.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schema#",
3 | "id": "https://edu.uoc.som-research/jsonschematouml/test/anyInstance/schema.json",
4 | "title": "Test data for any instance",
5 | "description": "This schema contains data to test any instances (6.1 in validation JSON specificacion)",
6 | "type": "object",
7 | "allOf": [
8 | "properties": {
9 | "att1": {
10 | "type": "boolean"
11 | },
12 | "att2": {
13 | "type": "object"
14 | },
15 | "att3": {
16 | "type": "array"
17 | },
18 | "att4": {
19 | "type": "number"
20 | },
21 | "att5": {
22 | "type": "integer"
23 | },
24 | "att6": {
25 | "type": "string",
26 | "enum": [
27 | "val1",
28 | "val2",
29 | "val3"
30 | ]
31 | },
32 | "att7": {
33 | "type": "string",
34 | "const" : "CONSTANT"
35 | }
36 | }
37 | }
38 | ],
39 | "required": [
40 | "att1"
41 | ]
42 | }
43 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/lib/json-schema-validator-2.2.6-lib.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SOM-Research/jsonSchema-to-uml/162072bb4d9382c76b19107f57d7828c187d74c1/plugins/edu.uoc.som.jsonschematouml.test/lib/json-schema-validator-2.2.6-lib.jar
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/lib/json-schema-validator-2.2.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SOM-Research/jsonSchema-to-uml/162072bb4d9382c76b19107f57d7828c187d74c1/plugins/edu.uoc.som.jsonschematouml.test/lib/json-schema-validator-2.2.6.jar
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/src/edu/uoc/som/jsonschematouml/generators/test/JSONSchemaToUMLTest.java:
--------------------------------------------------------------------------------
1 | package edu.uoc.som.jsonschematouml.generators.test;
2 |
3 | import junit.framework.TestCase;
4 | import org.eclipse.uml2.uml.*;
5 | import org.eclipse.uml2.uml.Class;
6 | import org.junit.Test;
7 |
8 | import edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML;
9 |
10 | import java.io.File;
11 |
12 | public class JSONSchemaToUMLTest extends TestCase {
13 |
14 | @Test
15 | public void testLaunchAndSave() {
16 | JSONSchemaToUML io = new JSONSchemaToUML("test");
17 | File input = new File("inputs/fiware");
18 | io.launch(input);
19 | io.saveModel(new File("outputs/model.uml"));
20 | }
21 |
22 | @Test
23 | public void testNumericInstance() {
24 | JSONSchemaToUML io = new JSONSchemaToUML("test");
25 | File input = new File("inputs/testNumericInstance.json");
26 | io.launch(input);
27 | Model model = io.getModel();
28 |
29 | Class c = (Class) model.getPackagedElement("numericInstance");
30 | assertNotNull(c);
31 | assertTrue(c.getOwnedRules().size() > 0);
32 | for(Constraint constraint : c.getOwnedRules()) {
33 | assertNotNull(constraint.getSpecification());
34 | OpaqueExpression spec = (OpaqueExpression) constraint.getSpecification();
35 | assertEquals("OCL", spec.getLanguages().get(0));
36 | if(constraint.getName().equals("numericInstance-att1-multipleOfConstraint"))
37 | assertEquals("self.att1.div(2) = 0", spec.getBodies().get(0));
38 | if(constraint.getName().equals("numericInstance-att1-maximumConstraint"))
39 | assertEquals("self.att1 <= 10", spec.getBodies().get(0));
40 | if(constraint.getName().equals("numericInstance-att1-minimumConstraint"))
41 | assertEquals("self.att1 >= 0", spec.getBodies().get(0));
42 | if(constraint.getName().equals("numericInstance-att2-exclusiveMaximumConstraint"))
43 | assertEquals("self.att2 < 10", spec.getBodies().get(0));
44 | if(constraint.getName().equals("numericInstance-att2-exclusiveMinimumConstraint"))
45 | assertEquals("self.att2 > 0", spec.getBodies().get(0));
46 | }
47 | }
48 |
49 | @Test
50 | public void testString() {
51 | JSONSchemaToUML io = new JSONSchemaToUML("test");
52 | File input = new File("inputs/testString.json");
53 | io.launch(input);
54 | Model model = io.getModel();
55 |
56 | Class c = (Class) model.getPackagedElement("stringInstance");
57 | assertNotNull(c);
58 | assertTrue(c.getOwnedRules().size() > 0);
59 | for(Constraint constraint : c.getOwnedRules()) {
60 | assertNotNull(constraint.getSpecification());
61 | OpaqueExpression spec = (OpaqueExpression) constraint.getSpecification();
62 | assertEquals("OCL", spec.getLanguages().get(0));
63 | if(constraint.getName().equals("stringInstance-att1-maxLengthConstraint"))
64 | assertEquals("self.att1.size() <= 0", spec.getBodies().get(0));
65 | if(constraint.getName().equals("stringInstance-att1-minLengthConstraint"))
66 | assertEquals("self.att1.size() >= 2", spec.getBodies().get(0));
67 | }
68 | }
69 | @Test
70 | public void testAny() {
71 | JSONSchemaToUML io = new JSONSchemaToUML("test");
72 | File input = new File("inputs/testAny.json");
73 | io.launch(input);
74 | Model model = io.getModel();
75 |
76 | Class c = (Class) model.getPackagedElement("anyInstance");
77 | assertNotNull(c);
78 | assertTrue(c.getOwnedAttributes().size() > 0);
79 | for(Property property : c.getOwnedAttributes()) {
80 | if(property.getName().equals("att1")) {
81 | assertEquals("Boolean", property.getType().getName());
82 | } else if(property.getName().equals("att2")) {
83 | assertEquals("Att2", property.getType().getName());
84 | } else if(property.getName().equals("att3")) {
85 | // TODO
86 | } else if(property.getName().equals("att4")) {
87 | assertEquals("Integer", property.getType().getName());
88 | } else if(property.getName().equals("att5")) {
89 | assertEquals("Integer", property.getType().getName());
90 | } else if(property.getName().equals("att6")) {
91 | assertEquals("att6Enum", property.getType().getName());
92 | } else if(property.getName().equals("att7")) {
93 | assertEquals("String", property.getType().getName());
94 | }
95 | }
96 |
97 | Enumeration e = (Enumeration) model.getPackagedElement("att6Enum");
98 | assertNotNull(e);
99 | assertNotNull(e.getOwnedLiteral("val1"));
100 | assertNotNull(e.getOwnedLiteral("val2"));
101 | assertNotNull(e.getOwnedLiteral("val3"));
102 | }
103 |
104 | @Test
105 | public void testObject() {
106 | JSONSchemaToUML io = new JSONSchemaToUML("test");
107 | File input = new File("inputs/testObject.json");
108 | io.launch(input);
109 | Model model = io.getModel();
110 |
111 | Class c = (Class) model.getPackagedElement("objectInstance");
112 | assertNotNull(c);
113 | assertTrue(c.getOwnedAttributes().size() > 0);
114 | for(Property property : c.getOwnedAttributes()) {
115 | if(property.getName().equals("att1")) {
116 | assertEquals("String", property.getType().getName());
117 | assertEquals(1, property.getLower());
118 | }
119 | }
120 | }
121 |
122 | @Test
123 | public void testTitleDescription() {
124 | JSONSchemaToUML io = new JSONSchemaToUML("test");
125 | File input = new File("inputs/testTitleDescription.json");
126 | io.launch(input);
127 | Model model = io.getModel();
128 | io.saveModel(new File("outputs/model.uml"));
129 |
130 | Class c = (Class) model.getPackagedElement("titleDescription");
131 | assertNotNull(c);
132 | assertTrue(c.getOwnedComments().size() > 0);
133 | for(Comment comment : c.getOwnedComments()) {
134 | if(comment.getBody().startsWith("Title:")) {
135 | assertEquals("Title: titleTest", comment.getBody());
136 | }
137 | if(comment.getBody().startsWith("Description:")) {
138 | assertEquals("Description: descriptionTest", comment.getBody());
139 | }
140 | }
141 | }
142 |
143 | @Test
144 | public void testSet() {
145 | JSONSchemaToUML io = new JSONSchemaToUML("test");
146 | File input = new File("inputs/testSet");
147 | io.launch(input);
148 | io.saveModel(new File("outputs/model.uml"));
149 | }
150 |
151 | @Test
152 | public void testWrong() {
153 | JSONSchemaToUML io = new JSONSchemaToUML("test");
154 | File input = new File("inputs/testWrong.json");
155 | io.launch(input);
156 | io.saveModel(new File("outputs/model.uml"));
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/src/edu/uoc/som/jsonschematouml/generators/test/JSONSchemaURITest.java:
--------------------------------------------------------------------------------
1 | package edu.uoc.som.jsonschematouml.generators.test;
2 |
3 | import org.junit.Test;
4 |
5 | import edu.uoc.som.jsonschematouml.generators.JSONSchemaURI;
6 | import junit.framework.TestCase;
7 |
8 | public class JSONSchemaURITest extends TestCase {
9 |
10 | @Test
11 | public void testA() {
12 | String URI = "foo://example.com:8042/over/there?name=ferret#nose";
13 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
14 | assertEquals("foo", jsu.getScheme());
15 | assertEquals("example.com:8042", jsu.getAuthority());
16 | assertEquals("/over/there", jsu.getPath());
17 | assertEquals("name=ferret", jsu.getQuery());
18 | assertEquals("nose", jsu.getFragment());
19 | }
20 |
21 | @Test
22 | public void testB() {
23 | String URI = "foo://example.com:8042/over/there?name=ferret";
24 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
25 | assertEquals("foo", jsu.getScheme());
26 | assertEquals("example.com:8042", jsu.getAuthority());
27 | assertEquals("/over/there", jsu.getPath());
28 | assertEquals("name=ferret", jsu.getQuery());
29 | assertNull(jsu.getFragment());
30 | }
31 |
32 | @Test
33 | public void testC() {
34 | String URI = "foo://example.com:8042/over/there#nose";
35 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
36 | assertEquals("foo", jsu.getScheme());
37 | assertEquals("example.com:8042", jsu.getAuthority());
38 | assertEquals("/over/there", jsu.getPath());
39 | assertNull(jsu.getQuery());
40 | assertEquals("nose", jsu.getFragment());
41 | }
42 |
43 | @Test
44 | public void testD() {
45 | String URI = "foo://example.com:8042/over";
46 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
47 | assertEquals("foo", jsu.getScheme());
48 | assertEquals("example.com:8042", jsu.getAuthority());
49 | assertEquals("/over", jsu.getPath());
50 | assertNull(jsu.getQuery());
51 | assertNull(jsu.getFragment());
52 | }
53 |
54 | @Test
55 | public void testE() {
56 | String URI = "foo://example.com:8042/over/there";
57 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
58 | assertEquals("foo", jsu.getScheme());
59 | assertEquals("example.com:8042", jsu.getAuthority());
60 | assertEquals("/over/there", jsu.getPath());
61 | assertNull(jsu.getQuery());
62 | assertNull(jsu.getFragment());
63 | }
64 |
65 | @Test
66 | public void testDigestName() {
67 | String URI = "foo://example.com:8042/over/there.json";
68 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
69 | assertEquals("there", jsu.digestName());
70 |
71 | URI = "foo://example.com:8042/there.json";
72 | jsu = new JSONSchemaURI(URI);
73 | assertEquals("there", jsu.digestName());
74 | }
75 |
76 | @Test
77 | public void testDigestIdNameA() {
78 | String URI = "foo://example.com:8042/over/there.json";
79 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
80 | assertEquals("over", jsu.digestIdName());
81 | }
82 |
83 | @Test
84 | public void testDigestIdNameB() {
85 | String URI = "foo://example.com:8042/over";
86 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
87 | assertEquals("over", jsu.digestIdName());
88 | }
89 |
90 | @Test
91 | public void testDigestFragment() {
92 | String URI = "foo://example.com:8042/over/there.json#/fragment/name";
93 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
94 | assertEquals("name", jsu.digestFragmentName());
95 |
96 | URI = "foo://example.com:8042/over/there.json#/fragment";
97 | jsu = new JSONSchemaURI(URI);
98 | assertEquals("fragment", jsu.digestFragmentName());
99 | }
100 |
101 | @Test
102 | public void testDigestOnlyFragment() {
103 | String URI = "#/fragment/name";
104 | JSONSchemaURI jsu = new JSONSchemaURI(URI);
105 | assertEquals("name", jsu.digestFragmentName());
106 |
107 | URI = "#/fragment";
108 | jsu = new JSONSchemaURI(URI);
109 | assertEquals("fragment", jsu.digestFragmentName());
110 | }
111 |
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.test/src/edu/uoc/som/jsonschematouml/validator/test/JSONSchemaValidatorTest.java:
--------------------------------------------------------------------------------
1 | package edu.uoc.som.jsonschematouml.validator.test;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 |
6 | import org.junit.Test;
7 |
8 | import com.github.fge.jsonschema.core.exceptions.ProcessingException;
9 | import com.github.fge.jsonschema.core.report.ProcessingReport;
10 |
11 | import edu.uoc.som.jsonschematouml.validator.JSONSchemaValidator;
12 | import junit.framework.TestCase;
13 |
14 | public class JSONSchemaValidatorTest extends TestCase {
15 |
16 | @Test
17 | public void testValidateValid() {
18 | File input = new File("inputs/testValid.json");
19 | try {
20 | ProcessingReport report = JSONSchemaValidator.validate(input);
21 | assertTrue(report.isSuccess());
22 | } catch (IOException | ProcessingException e) {
23 | fail(e.getLocalizedMessage());
24 | }
25 | }
26 |
27 | public void testValidateInvalid() {
28 | File input = new File("inputs/testInvalid.json");
29 | try {
30 | ProcessingReport report = JSONSchemaValidator.validate(input);
31 | assertFalse(report.isSuccess());
32 | } catch (IOException | ProcessingException e) {
33 | fail(e.getLocalizedMessage());
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | edu.uoc.som.jsonschematouml.ui
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.pde.PluginNature
26 | org.eclipse.jdt.core.javanature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/.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.8
4 | org.eclipse.jdt.core.compiler.compliance=1.8
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=1.8
8 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: JSONSchematoUML
4 | Bundle-SymbolicName: edu.uoc.som.jsonschematouml.ui;singleton:=true
5 | Bundle-Version: 0.0.6.qualifier
6 | Bundle-Activator: edu.uoc.som.jsonschematouml.ui.JSONSchemaToUMLUIPlugin
7 | Bundle-Vendor: SOM Research Lab
8 | Require-Bundle: org.eclipse.ui,
9 | org.eclipse.core.runtime,
10 | org.eclipse.core.resources,
11 | org.eclipse.emf.ecore;bundle-version="2.15.0",
12 | org.eclipse.emf.ecore.xmi;bundle-version="2.15.0",
13 | org.eclipse.uml2.uml;bundle-version="5.3.0",
14 | org.eclipse.uml2.uml.resources;bundle-version="5.3.0",
15 | edu.uoc.som.jsonschematouml
16 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8
17 | Bundle-ActivationPolicy: lazy
18 | Bundle-ClassPath: .
19 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/build.properties:
--------------------------------------------------------------------------------
1 | source.. = src/
2 | output.. = bin/
3 | bin.includes = META-INF/,\
4 | .,\
5 | plugin.xml,\
6 | images/,\
7 | bin/
8 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/images/logo-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SOM-Research/jsonSchema-to-uml/162072bb4d9382c76b19107f57d7828c187d74c1/plugins/edu.uoc.som.jsonschematouml.ui/images/logo-512.png
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SOM-Research/jsonSchema-to-uml/162072bb4d9382c76b19107f57d7828c187d74c1/plugins/edu.uoc.som.jsonschematouml.ui/images/logo.png
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/images/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
1426 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
9 |
43 |
44 |
45 |
47 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/src/edu/uoc/som/jsonschematouml/ui/JSONSchemaToUMLUIPlugin.java:
--------------------------------------------------------------------------------
1 | package edu.uoc.som.jsonschematouml.ui;
2 |
3 | import org.eclipse.ui.plugin.AbstractUIPlugin;
4 | import org.osgi.framework.BundleContext;
5 |
6 | public class JSONSchemaToUMLUIPlugin extends AbstractUIPlugin {
7 |
8 | // The plug-in ID
9 | public static final String PLUGIN_ID = "edu.uoc.som.jsonschematouml.ui"; //$NON-NLS-1$
10 |
11 | // The shared instance
12 | private static JSONSchemaToUMLUIPlugin plugin;
13 |
14 | /**
15 | * The constructor
16 | */
17 | public JSONSchemaToUMLUIPlugin() {
18 | }
19 |
20 | /*
21 | * (non-Javadoc)
22 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
23 | */
24 | public void start(BundleContext context) throws Exception {
25 | super.start(context);
26 | plugin = this;
27 | }
28 |
29 | /*
30 | * (non-Javadoc)
31 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
32 | */
33 | public void stop(BundleContext context) throws Exception {
34 | plugin = null;
35 | super.stop(context);
36 | }
37 |
38 | /**
39 | * Returns the shared instance
40 | *
41 | * @return the shared instance
42 | */
43 | public static JSONSchemaToUMLUIPlugin getDefault() {
44 | return plugin;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml.ui/src/edu/uoc/som/jsonschematouml/ui/handlers/ConvertToClassDiagram.java:
--------------------------------------------------------------------------------
1 | package edu.uoc.som.jsonschematouml.ui.handlers;
2 |
3 | import java.io.File;
4 | import java.util.Iterator;
5 |
6 | import org.eclipse.core.commands.AbstractHandler;
7 | import org.eclipse.core.commands.ExecutionEvent;
8 | import org.eclipse.core.commands.ExecutionException;
9 | import org.eclipse.core.resources.IContainer;
10 | import org.eclipse.core.resources.IFile;
11 | import org.eclipse.core.resources.IFolder;
12 | import org.eclipse.core.resources.IResource;
13 | import org.eclipse.core.runtime.CoreException;
14 | import org.eclipse.core.runtime.IProgressMonitor;
15 | import org.eclipse.core.runtime.IStatus;
16 | import org.eclipse.core.runtime.NullProgressMonitor;
17 | import org.eclipse.core.runtime.Status;
18 | import org.eclipse.core.runtime.jobs.Job;
19 | import org.eclipse.emf.common.util.URI;
20 | import org.eclipse.jface.viewers.ISelection;
21 | import org.eclipse.jface.viewers.IStructuredSelection;
22 | import org.eclipse.ui.handlers.HandlerUtil;
23 |
24 | import edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML;
25 | import edu.uoc.som.jsonschematouml.generators.JSONSchemaToUMLException;
26 | import edu.uoc.som.jsonschematouml.ui.JSONSchemaToUMLUIPlugin;
27 |
28 | /**
29 | * Main handler class to respond to the main contribution to Eclipse UI. This handler
30 | * executes the JSON Schema to UML tool for the set of files selected by the user
31 | *
32 | */
33 | public class ConvertToClassDiagram extends AbstractHandler {
34 |
35 | /**
36 | * ID for this plugin
37 | */
38 | public static final String ID = "edu.uoc.som.jsonschematouml.ui.popup.handlers.ConvertToClassDiagram";
39 |
40 | @Override
41 | public Object execute(ExecutionEvent event) throws ExecutionException {
42 | ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
43 | if (selection != null & selection instanceof IStructuredSelection) {
44 | final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
45 | Job job = new Job(ID) {
46 | @Override
47 | protected IStatus run(IProgressMonitor monitor) {
48 | if (monitor == null) monitor = new NullProgressMonitor();
49 | try {
50 | monitor.beginTask("Generating the Class diagram", IProgressMonitor.UNKNOWN);
51 | for (Iterator> iterator = structuredSelection.iterator(); iterator.hasNext();) {
52 | Object obj = iterator.next();
53 | if (obj instanceof IFile || obj instanceof IFolder) {
54 | IResource iResource = (IResource) obj;
55 | JSONSchemaToUML generator = new JSONSchemaToUML(iResource.getProject().getName());
56 | generator.launch(new File(iResource.getLocation().toString()));
57 | URI finalLocation = buildFinalLocation(iResource, monitor);
58 | generator.saveModel(finalLocation);
59 | }
60 | }
61 | } catch (CoreException e) {
62 | return new Status(IStatus.ERROR, JSONSchemaToUMLUIPlugin.PLUGIN_ID, e.getLocalizedMessage(), e);
63 | } catch(JSONSchemaToUMLException je) {
64 | return new Status(IStatus.ERROR, JSONSchemaToUMLUIPlugin.PLUGIN_ID, je.getMessage(), je);
65 | } finally {
66 | monitor.done();
67 | }
68 | return Status.OK_STATUS;
69 | }
70 | };
71 | job.schedule();
72 | }
73 | return null;
74 | }
75 |
76 | /**
77 | * Builds and URI for the final destination of the generated Class Diagram
78 | *
79 | * @param iResource The resource to use as input for the generator
80 | * @param monitor The Monitor of the process
81 | * @return The URI for the target Class Diagram
82 | * @throws CoreException
83 | */
84 | private URI buildFinalLocation(IResource iResource, IProgressMonitor monitor) throws CoreException {
85 | IContainer target = iResource.getProject().getFolder("src-gen");
86 | if (!target.getLocation().toFile().exists()) {
87 | target.getLocation().toFile().mkdirs();
88 | iResource.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
89 | }
90 | String location = target.getFullPath().toString();
91 | String fileName = iResource.getName();
92 | if(iResource.getName().lastIndexOf(".") > 0)
93 | fileName = iResource.getName().substring(0, iResource.getName().lastIndexOf('.'));
94 | URI finalLocation = URI.createPlatformResourceURI(location, true).appendSegment(fileName).appendFileExtension("uml");
95 | return finalLocation;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | edu.uoc.som.jsonschematouml
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.pde.PluginNature
26 | org.eclipse.jdt.core.javanature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/.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.8
4 | org.eclipse.jdt.core.compiler.compliance=1.8
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=1.8
8 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: JSON Schema to UML
4 | Bundle-SymbolicName: edu.uoc.som.jsonschematouml
5 | Require-Bundle: com.google.gson;bundle-version="2.7.0",
6 | org.eclipse.emf.ecore;bundle-version="2.15.0",
7 | org.eclipse.emf.ecore.xmi;bundle-version="2.15.0",
8 | org.eclipse.uml2.uml;bundle-version="5.3.0",
9 | org.eclipse.uml2.uml.resources;bundle-version="5.3.0"
10 | Bundle-Version: 0.0.6.qualifier
11 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8
12 | Bundle-ClassPath: .,
13 | lib/json-schema-validator-2.2.6-lib.jar,
14 | lib/json-schema-validator-2.2.6.jar
15 | Export-Package: edu.uoc.som.jsonschematouml.generators,
16 | edu.uoc.som.jsonschematouml.validator
17 | Bundle-Vendor: SOM Research Lab
18 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/build.properties:
--------------------------------------------------------------------------------
1 | source.. = src/
2 | output.. = bin/
3 | bin.includes = META-INF/,\
4 | .,\
5 | lib/,\
6 | lib/json-schema-validator-2.2.6-lib.jar,\
7 | lib/json-schema-validator-2.2.6.jar
8 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/lib/json-schema-validator-2.2.6-lib.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SOM-Research/jsonSchema-to-uml/162072bb4d9382c76b19107f57d7828c187d74c1/plugins/edu.uoc.som.jsonschematouml/lib/json-schema-validator-2.2.6-lib.jar
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/lib/json-schema-validator-2.2.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SOM-Research/jsonSchema-to-uml/162072bb4d9382c76b19107f57d7828c187d74c1/plugins/edu.uoc.som.jsonschematouml/lib/json-schema-validator-2.2.6.jar
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/src/edu/uoc/som/jsonschematouml/generators/JSONSchemaToUML.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SOM-Research/jsonSchema-to-uml/162072bb4d9382c76b19107f57d7828c187d74c1/plugins/edu.uoc.som.jsonschematouml/src/edu/uoc/som/jsonschematouml/generators/JSONSchemaToUML.java
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/src/edu/uoc/som/jsonschematouml/generators/JSONSchemaToUMLException.java:
--------------------------------------------------------------------------------
1 | package edu.uoc.som.jsonschematouml.generators;
2 |
3 | /**
4 | * Generic Runtime Exception for JSONSchema to UML tool
5 | *
6 | */
7 | public class JSONSchemaToUMLException extends RuntimeException {
8 | private static final long serialVersionUID = 1L;
9 |
10 | public JSONSchemaToUMLException(String msg) {
11 | super(msg);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/src/edu/uoc/som/jsonschematouml/generators/JSONSchemaURI.java:
--------------------------------------------------------------------------------
1 | package edu.uoc.som.jsonschematouml.generators;
2 |
3 | /**
4 | * Utility class to deal with URIs in JSON Schemas. The class includes some helper
5 | * methods to ease the resolution and comparison of URIs.
6 | *
7 | * The behavior of the helpers methods of this class follows the indications described in
8 | * RFC 3986 ("Uniform Resource Identitier (URI): Generic Syntax")
9 | *
10 | */
11 | public class JSONSchemaURI {
12 | /**
13 | * Holds the full URI string
14 | */
15 | private String URIString;
16 | /**
17 | * The scheme of the URI (cf. Section 3.1 - RFC 3986)
18 | */
19 | private String scheme;
20 | /**
21 | * The authority of the URI (cf. Section 3.2 - RFC 3986)
22 | */
23 | private String authority;
24 | /**
25 | * The path of the URI (cf. Section 3.3 - RFC 3986)
26 | */
27 | private String path;
28 | /**
29 | * The query of the URI (cf. Section 3.4 - RFC 3986)
30 | */
31 | private String query;
32 | /**
33 | * The fragment of the URI (cf. Section 3.5 - RFC 3986)
34 | */
35 | private String fragment;
36 |
37 |
38 | public JSONSchemaURI(String URIString) {
39 | this.URIString = URIString;
40 | parseURIString();
41 | }
42 |
43 | /**
44 | * Parses the URIString to obtain the main element of the URI
45 | */
46 | private void parseURIString() {
47 | /* Extracting the scheme */
48 | int index = this.URIString.indexOf(":");
49 | int startIndex = 0;
50 | int endIndex = 0;
51 | if(index >= 0) {
52 | // The URI contains a scheme and therefore an authority
53 | this.scheme = this.URIString.substring(0, index);
54 |
55 | /* Extracting the authority */
56 | startIndex = this.URIString.indexOf("//");
57 | endIndex = 0;
58 | if(startIndex >= 0) {
59 | endIndex = this.URIString.substring(startIndex+2).indexOf("/");
60 | this.authority = this.URIString.substring(startIndex+2, startIndex+2+endIndex);
61 | }
62 |
63 | /* Extracting the path */
64 | startIndex = startIndex+2+endIndex;
65 | endIndex = this.URIString.lastIndexOf("/");
66 | endIndex = this.URIString.indexOf("?");
67 | if(endIndex < 0 && this.URIString.indexOf("#") < 0) {
68 | /* No query or fragment part */
69 | this.path = this.URIString.substring(startIndex, this.URIString.length());
70 | return;
71 | } else if(endIndex < 0 && this.URIString.indexOf("#") > 0) {
72 | /* No query part but fragment included */
73 | endIndex = this.URIString.indexOf("#");
74 | }
75 | this.path = this.URIString.substring(startIndex, endIndex);
76 | }
77 |
78 | /* Extracting the query and fragment (if any) */
79 | startIndex = endIndex;
80 | endIndex = this.URIString.indexOf("#");
81 | if(endIndex < 0) {
82 | /* Only query part */
83 | this.query = this.URIString.substring(startIndex+1, this.URIString.length());
84 | return;
85 | } else if (this.URIString.indexOf("?") < 0) {
86 | /* Only fragment part */
87 | this.fragment = this.URIString.substring(endIndex+1, this.URIString.length());
88 | } else {
89 | /* Both query and fragment */
90 | this.query = this.URIString.substring(startIndex+1, endIndex);
91 | this.fragment = this.URIString.substring(endIndex+1, this.URIString.length());
92 | }
93 | }
94 |
95 | public String toString() {
96 | StringBuilder sb = new StringBuilder();
97 | sb.append("Scheme : " + this.scheme + "\n");
98 | sb.append("Authority : " + this.authority + "\n");
99 | sb.append("Path : " + this.path + "\n");
100 | sb.append("Query : " + this.query + "\n");
101 | sb.append("Fragment : " + this.fragment + "\n");
102 | return sb.toString();
103 | }
104 |
105 | /**
106 | * Digest the name of an object given an URI. It uses the last element of the path
107 | * of the URI (and removes the extension, if any).
108 | *
109 | * For instance:
110 | * foo://example.com:8042/over/there.json
111 | *
112 | * returns:
113 | * there
114 | *
115 | * @return String with the name digested
116 | */
117 | public String digestName() {
118 | String[] splitPath = this.path.split("/");
119 | String lastPathElement = splitPath[splitPath.length-1];
120 | int index = lastPathElement.lastIndexOf(".");
121 | if(index > 0) {
122 | return lastPathElement.substring(0, index);
123 | }
124 | return lastPathElement;
125 | }
126 |
127 | /**
128 | * Digest the name of an schema in an URI. It uses the previous to last
129 | * element of the path of the URI.
130 | *
131 | * For instance:
132 | * foo://example.com:8042/over/there.json
133 | *
134 | * returns:
135 | * over
136 | *
137 | * @return String with the name digested
138 | */
139 | public String digestIdName() {
140 | String[] splitPath = this.path.split("/");
141 | if(splitPath.length > 2) {
142 | return splitPath[splitPath.length-2];
143 | } else {
144 | return splitPath[splitPath.length-1];
145 | }
146 | }
147 |
148 | /**
149 | * Digest the name of a fragment. It iuses the last element of the
150 | * fragment
151 | *
152 | * For instance:
153 | *
154 | * 1. foo://example.com:8042/over/there.json#/fragment/name
155 | *
156 | * 2. foo://example.com:8042/over/there.json#/fragment
157 | *
158 | * returns:
159 | *
160 | * 1. name
161 | *
162 | * 2. fragment
163 | *
164 | * @return
165 | */
166 | public String digestFragmentName() {
167 | if(this.fragment == null) {
168 | return this.digestIdName();
169 | } else {
170 | String[] splitFragment = this.fragment.split("/");
171 | return splitFragment[splitFragment.length-1];
172 | }
173 | }
174 |
175 | /* Generated */
176 | public String getURIString() {
177 | return URIString;
178 | }
179 |
180 | public String getScheme() {
181 | return scheme;
182 | }
183 |
184 | public String getAuthority() {
185 | return authority;
186 | }
187 |
188 | public String getPath() {
189 | return path;
190 | }
191 |
192 | public String getQuery() {
193 | return query;
194 | }
195 |
196 | public String getFragment() {
197 | return fragment;
198 | }
199 |
200 |
201 |
202 |
203 | }
204 |
--------------------------------------------------------------------------------
/plugins/edu.uoc.som.jsonschematouml/src/edu/uoc/som/jsonschematouml/validator/JSONSchemaValidator.java:
--------------------------------------------------------------------------------
1 | package edu.uoc.som.jsonschematouml.validator;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 |
6 | import com.fasterxml.jackson.databind.JsonNode;
7 | import com.github.fge.jackson.JsonLoader;
8 | import com.github.fge.jsonschema.cfg.ValidationConfiguration;
9 | import com.github.fge.jsonschema.core.exceptions.ProcessingException;
10 | import com.github.fge.jsonschema.core.report.ProcessingReport;
11 | import com.github.fge.jsonschema.processors.syntax.SyntaxValidator;
12 |
13 |
14 | /**
15 | * This class validates that a JSON file conforms to the standard JSON Schema specification.
16 | *
17 | * The implementation of this class is inspired by edu.uoc.som.openapitouml.validator.OpenAPIValidator
18 | * (https://github.com/SOM-Research/openapi-to-uml)
19 | *
20 | */
21 | public class JSONSchemaValidator {
22 | /**
23 | * The Validator used to check that a JSON Schema is valid
24 | */
25 | private static final SyntaxValidator VALIDATOR = new SyntaxValidator(ValidationConfiguration.byDefault());
26 |
27 | /**
28 | * Validates that a jsonFile conforms to the JSON Schema specification
29 | *
30 | * @param jsonFile The file to validate
31 | * @return The report of the validation
32 | * @throws ProcessingException
33 | * @throws IOException
34 | */
35 | public static ProcessingReport validate(File jsonFile) throws ProcessingException, IOException {
36 | JsonNode jsonNode = JsonLoader.fromFile(jsonFile);
37 | return VALIDATOR.validateSchema(jsonNode);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------