- If you did not receive this Content directly from the Eclipse Foundation, the Content is
- being redistributed by another party (“Redistributor”) and different terms and conditions may
- apply to your use of any object code in the Content. Check the Redistributor’s license that was
- provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
- indicated below, the terms and conditions of the EPL and Apache License 2.0 still apply to any source code
- in the Content and such source code may be obtained at http://www.eclipse.org.
-
CDDL and GPL with classpath exception (https://jersey.java.net/license.html).
- The Eclipse Foundation elects to include this software in this distribution under the CDDL license.
- A copy of the license is available at CDDL-v1.1.txt.
-
-
-
-
diff --git a/org.eclipse.winery.common/about_files/Apache-LICENSE-2.0.txt b/org.eclipse.winery.common/about_files/Apache-LICENSE-2.0.txt
deleted file mode 100644
index d645695673..0000000000
--- a/org.eclipse.winery.common/about_files/Apache-LICENSE-2.0.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) 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. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/org.eclipse.winery.common/about_files/CDDL-v1.1.txt b/org.eclipse.winery.common/about_files/CDDL-v1.1.txt
deleted file mode 100644
index 7cc8719b3b..0000000000
--- a/org.eclipse.winery.common/about_files/CDDL-v1.1.txt
+++ /dev/null
@@ -1,129 +0,0 @@
-COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL - Version 1.1)
-1. Definitions.
-
- 1.1. “Contributor” means each individual or entity that creates or contributes to the creation of Modifications.
-
- 1.2. “Contributor Version” means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
-
- 1.3. “Covered Software” means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
-
- 1.4. “Executable” means the Covered Software in any form other than Source Code.
-
- 1.5. “Initial Developer” means the individual or entity that first makes Original Software available under this License.
-
- 1.6. “Larger Work” means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
-
- 1.7. “License” means this document.
-
- 1.8. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
-
- 1.9. “Modifications” means the Source Code and Executable form of any of the following:
-
- A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications;
-
- B. Any new file that contains any part of the Original Software or previous Modification; or
-
- C. Any new file that is contributed or otherwise made available under the terms of this License.
-
- 1.10. “Original Software” means the Source Code and Executable form of computer software code that is originally released under this License.
-
- 1.11. “Patent Claims” means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
-
- 1.12. “Source Code” means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
-
- 1.13. “You” (or “Your”) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, “You” includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
-
-2. License Grants.
-
- 2.1. The Initial Developer Grant.
-
- Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
-
- (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
-
- (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).
-
- (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License.
-
- (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
-
- 2.2. Contributor Grant.
-
- Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
-
- (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
-
- (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
-
- (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
-
- (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
-
-3. Distribution Obligations.
-
- 3.1. Availability of Source Code.
-
- Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
-
- 3.2. Modifications.
-
- The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
-
- 3.3. Required Notices.
-
- You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
-
- 3.4. Application of Additional Terms.
-
- You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients’ rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
-
- 3.5. Distribution of Executable Versions.
-
- You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient’s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
-
- 3.6. Larger Works.
-
- You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
-
-4. Versions of the License.
-
- 4.1. New Versions.
-
- Oracle is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
-
- 4.2. Effect of New Versions.
-
- You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
-
- 4.3. Modified Versions.
-
- When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
-
-5. DISCLAIMER OF WARRANTY.
-
-COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
-6. TERMINATION.
-
- 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
-
- 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as “Participant”) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
-
- 6.3. If You assert a patent infringement claim against Participant alleging that the Participant Software directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
-
- 6.4. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
-
-7. LIMITATION OF LIABILITY.
-
-UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
-8. U.S. GOVERNMENT END USERS.
-
-The Covered Software is a “commercial item,” as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” (as that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and “commercial computer software documentation” as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
-9. MISCELLANEOUS.
-
-This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction’s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys’ fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
-10. RESPONSIBILITY FOR CLAIMS.
-
-As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
-NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
-
-The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California.
\ No newline at end of file
diff --git a/org.eclipse.winery.common/about_files/LICENSE-logback.txt b/org.eclipse.winery.common/about_files/LICENSE-logback.txt
deleted file mode 100644
index b4fe24e02a..0000000000
--- a/org.eclipse.winery.common/about_files/LICENSE-logback.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-Logback LICENSE
----------------
-
-Logback: the reliable, generic, fast and flexible logging framework.
-Copyright (C) 1999-2012, QOS.ch. All rights reserved.
-
-This program and the accompanying materials are dual-licensed under
-either the terms of the Eclipse Public License v1.0 as published by
-the Eclipse Foundation
-
- or (per the licensee's choosing)
-
-under the terms of the GNU Lesser General Public License version 2.1
-as published by the Free Software Foundation.
-
diff --git a/org.eclipse.winery.common/about_files/LICENSE-slf4j-api.txt b/org.eclipse.winery.common/about_files/LICENSE-slf4j-api.txt
deleted file mode 100644
index 37050c9568..0000000000
--- a/org.eclipse.winery.common/about_files/LICENSE-slf4j-api.txt
+++ /dev/null
@@ -1,21 +0,0 @@
- Copyright (c) 2004-2013 QOS.ch
- All rights reserved.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/org.eclipse.winery.common/pom.xml b/org.eclipse.winery.common/pom.xml
index 9758a43e41..2dae3fc98b 100644
--- a/org.eclipse.winery.common/pom.xml
+++ b/org.eclipse.winery.common/pom.xml
@@ -18,7 +18,7 @@
org.eclipse.winerywinery
- 2.0.0-SNAPSHOT
+ 3.0.0-SNAPSHOTorg.eclipse.winery.common
@@ -32,21 +32,15 @@
jitpack.io
- https://jitpack.io
+ https://www.jitpack.io
-
- com.github.ust-edmm.edmm
- edmm-core
- v1.0.6
- org.slf4jslf4j-api${org.slf4j}
- compileorg.yaml
@@ -54,28 +48,35 @@
1.17
- org.eclipse.winery
- org.eclipse.winery.model.tosca
- 2.0.0-SNAPSHOT
- compile
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.10.1
+
+
+ org.glassfish.jaxb
+ jaxb-runtime
+ ${org.glassfish.jxb}
+ runtime
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-jackson
+ ${jersey.version}org.slf4jjcl-over-slf4j${org.slf4j}
- compilejstljstl1.2
- compilecommons-iocommons-io2.4
- compilecommons-logging
@@ -87,7 +88,6 @@
org.apache.commonscommons-lang3${org.apache.commons-lang3.version}
- compileorg.apache.commons
@@ -111,6 +111,16 @@
${junit.jupiter.version}test
+
+ io.github.adr
+ e-adr
+ ${io.github.adr.e-adr.version}
+
+
+ org.eclipse.jdt
+ org.eclipse.jdt.annotation
+ ${org.eclipse.jdt.annotation}
+
diff --git a/org.eclipse.winery.common/sonar-project.properties b/org.eclipse.winery.common/sonar-project.properties
deleted file mode 100644
index 34b855df56..0000000000
--- a/org.eclipse.winery.common/sonar-project.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-################################################################################
-# Copyright (c) 2014 Contributors to the Eclipse Foundation
-#
-# See the NOTICE file(s) distributed with this work for additional
-# information regarding copyright ownership.
-#
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
-# which is available at https://www.apache.org/licenses/LICENSE-2.0.
-#
-# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
-#################################################################################
-# required metadata
-sonar.projectKey=org.eclipse.winery.common
-sonar.projectName=org.eclipse.winery.common
-sonar.projectVersion=0.1.2
-# path to source directories (required)
-sonar.sources=src/main/java
-# path to test source directories (optional)
-#sonar.tests=
-# path to project binaries (optional), for example directory of Java bytecode
-#sonar.binaries=binDir
-# optional comma-separated list of paths to libraries. Only path to JAR file and path to directory of classes are supported.
-#sonar.libraries=org.eclipse.jgit-2.1.0.201209190230-r.jar
-# The value of the property must be the key of the language.
-sonar.language=java
-# enforce Java 1.7 to enable analysis of diamond operator by PMD
-# Winery uses 1.8
-sonar.java.source=1.8
-sonar.sourceEncoding=UTF-8
diff --git a/org.eclipse.winery.common/src/main/java/META-INF/MANIFEST.MF b/org.eclipse.winery.common/src/main/java/META-INF/MANIFEST.MF
deleted file mode 100644
index 254272e1c0..0000000000
--- a/org.eclipse.winery.common/src/main/java/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/ConfigurationTestUtils.java b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/ConfigurationTestUtils.java
index 93b6580766..8767d0b6a5 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/ConfigurationTestUtils.java
+++ b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/ConfigurationTestUtils.java
@@ -55,7 +55,7 @@ public static void saveCurrentConfiguration() {
*/
public static void replaceFileWithTestFile() throws IOException {
Environment.getInstance().setConfiguration(null);
- InputStream testConfigInputStream = ConfigurationTestUtils.class.getClassLoader().getResourceAsStream("wineryTest.yml");
+ InputStream testConfigInputStream = ConfigurationTestUtils.class.getClassLoader().getResourceAsStream(Environment.TEST_CONFIG_NAME);
if (testConfigInputStream == null) {
throw new NullPointerException();
}
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/Environment.java b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/Environment.java
index b23f32fd3a..a74311c210 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/Environment.java
+++ b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/Environment.java
@@ -37,10 +37,11 @@
*/
final class Environment {
+ static final String TEST_CONFIG_NAME = "wineryTest.yml";
private static final Logger LOGGER = LoggerFactory.getLogger(Environment.class);
private static final String DEFAULT_CONFIG_NAME = "winery.yml";
- private static final String TEST_CONFIG_NAME = "wineryTest.yml";
+ // Visible for test classes
private static final File DEFAULT_CONFIG_DIRECTORY = new File(System.getProperty("user.home"), ".winery");
private static final File DEFAULT_CONFIG_FILE = new File(DEFAULT_CONFIG_DIRECTORY, DEFAULT_CONFIG_NAME);
private static final File LINUX_CONFIG_FILE = new File("/opt/winery/.winery", DEFAULT_CONFIG_NAME);
@@ -164,6 +165,7 @@ private void copyDefaultConfigFile() {
if (defaultConfigInputStream == null) {
throw new NullPointerException();
}
+ LOGGER.info("Copying default configuration to user home");
FileUtils.copyInputStreamToFile(defaultConfigInputStream, Environment.DEFAULT_CONFIG_FILE);
} catch (IOException | NullPointerException e) {
LOGGER.debug("Error while copying the default config file into the winery directory", e);
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/Environments.java b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/Environments.java
index ce2b274166..1ea854db7a 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/Environments.java
+++ b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/Environments.java
@@ -20,7 +20,6 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Objects;
-import java.util.Optional;
import java.util.Properties;
import org.apache.commons.configuration2.YAMLConfiguration;
@@ -182,9 +181,9 @@ public FileBasedRepositoryConfiguration getFilebasedRepositoryConfiguration() {
*
* @return an instance of GitBasedRepositoryConfiguration
*/
- public Optional getGitBasedRepositoryConfiguration() {
+ public GitBasedRepositoryConfiguration getGitBasedRepositoryConfiguration() {
final FileBasedRepositoryConfiguration filebasedRepositoryConfiguration = getFilebasedRepositoryConfiguration();
- return Optional.of(new GitBasedRepositoryConfiguration(this.getGitConfig().isAutocommit(), filebasedRepositoryConfiguration));
+ return new GitBasedRepositoryConfiguration(this.getGitConfig().isAutocommit(), filebasedRepositoryConfiguration);
}
/**
@@ -210,5 +209,12 @@ public static void resetAccountabilityConfiguration() throws IOException {
Environment.getInstance().reloadAccountabilityConfiguration(inputStream);
}
}
+
+ public static boolean isFeatureEnabled(String name) {
+ Boolean value = getInstance().getUiConfig().getFeatures().get(name);
+ if (value == null) {
+ return false;
+ }
+ return value;
+ }
}
-
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/FileBasedRepositoryConfiguration.java b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/FileBasedRepositoryConfiguration.java
index 567b6470c6..49550b1390 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/FileBasedRepositoryConfiguration.java
+++ b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/FileBasedRepositoryConfiguration.java
@@ -35,7 +35,8 @@ public FileBasedRepositoryConfiguration(@NonNull Path repositoryPath) {
this(repositoryPath, Environments.getInstance().getRepositoryConfig().getProvider());
}
- private FileBasedRepositoryConfiguration(@NonNull Path repositoryPath, RepositoryConfigurationObject.RepositoryProvider repositoryProvider) {
+ // We are making the access public here to enable proper testing.
+ public FileBasedRepositoryConfiguration(@NonNull Path repositoryPath, RepositoryConfigurationObject.RepositoryProvider repositoryProvider) {
this.repositoryPath = Objects.requireNonNull(repositoryPath);
this.repositoryProvider = Objects.requireNonNull(repositoryProvider);
}
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/RepositoryConfigurationObject.java b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/RepositoryConfigurationObject.java
index 25e46636cd..6796534553 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/RepositoryConfigurationObject.java
+++ b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/configuration/RepositoryConfigurationObject.java
@@ -15,13 +15,23 @@
package org.eclipse.winery.common.configuration;
import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
-import org.eclipse.winery.common.Util;
+import org.eclipse.winery.common.Constants;
import org.apache.commons.configuration2.YAMLConfiguration;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RepositoryConfigurationObject extends AbstractConfigurationObject {
-
+ // this class shares the responsibility of the Environment class in abstracting
+ // over interactions with the configuration file. Loggers are therefore shared.
+ private static final Logger LOGGER = LoggerFactory.getLogger(Environment.class);
+
private static final String key = "repository.";
private GitConfigurationObject gitConfiguration;
@@ -99,7 +109,7 @@ public void setProvider(RepositoryProvider provider) {
public String getRepositoryRoot() {
String repositoryRoot = this.repositoryRoot;
if (repositoryRoot == null || repositoryRoot.isEmpty()) {
- repositoryRoot = Util.determineAndCreateRepositoryPath().toString();
+ repositoryRoot = determineAndCreateRepositoryPath().toString();
}
setRepositoryRoot(repositoryRoot);
return repositoryRoot;
@@ -116,7 +126,7 @@ public String getCsarOutputPath() {
csarOutputPath = getRepositoryRoot() + File.separator + "csars";
}
setCsarOutputPath(csarOutputPath);
- Util.createCsarOutputPath(csarOutputPath);
+ createCsarOutputPath(csarOutputPath);
return csarOutputPath;
}
@@ -132,4 +142,61 @@ public GitConfigurationObject getGitConfiguration() {
public void setGitConfiguration(GitConfigurationObject gitConfiguration) {
this.gitConfiguration = gitConfiguration;
}
+
+ private static Path determineAndCreateRepositoryPath() {
+ Path repositoryPath;
+ if (SystemUtils.IS_OS_WINDOWS) {
+ if (Files.exists(Constants.GLOBAL_REPO_PATH_WINDOWS)) {
+ repositoryPath = Constants.GLOBAL_REPO_PATH_WINDOWS;
+ } else {
+ repositoryPath = createDefaultRepositoryPath();
+ }
+ } else {
+ repositoryPath = createDefaultRepositoryPath();
+ }
+ return repositoryPath;
+ }
+
+ private static Path createDefaultRepositoryPath() {
+ File repo = null;
+ boolean operationalFileSystemAccess;
+ try {
+ repo = new File(FileUtils.getUserDirectory(), Constants.DEFAULT_REPO_NAME);
+ operationalFileSystemAccess = true;
+ } catch (NullPointerException e) {
+ // it seems, we run at a system, where we do not have any filesystem
+ // access
+ operationalFileSystemAccess = false;
+ }
+
+ // operationalFileSystemAccess = false;
+
+ Path repositoryPath;
+ if (operationalFileSystemAccess) {
+ try {
+ FileUtils.forceMkdir(repo);
+ } catch (IOException e) {
+ LOGGER.debug("Error while creating directory.", e);
+ }
+ repositoryPath = repo.toPath();
+ } else {
+ // we do not have access to the file system
+ throw new IllegalStateException("No write access to file system");
+ }
+
+ return repositoryPath;
+ }
+
+ private static void createCsarOutputPath(String csarOutputPath) {
+ File outputPath = new File(csarOutputPath);
+ if (outputPath.exists() && outputPath.isDirectory()) {
+ return;
+ }
+ try {
+ org.apache.commons.io.FileUtils.forceMkdir(outputPath);
+ } catch (IOException e) {
+ LOGGER.error("Error while creating directory: {}", e.getMessage(), e);
+ throw new IllegalStateException(e);
+ }
+ }
}
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/version/VersionUtils.java b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/version/VersionUtils.java
index 0d15c5f76d..002fcdee1a 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/version/VersionUtils.java
+++ b/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/version/VersionUtils.java
@@ -18,58 +18,17 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.xml.namespace.QName;
-
-import org.eclipse.winery.common.ids.definitions.ArtifactTemplateId;
-import org.eclipse.winery.common.ids.definitions.ArtifactTypeId;
-import org.eclipse.winery.common.ids.definitions.CapabilityTypeId;
-import org.eclipse.winery.common.ids.definitions.DefinitionsChildId;
-import org.eclipse.winery.common.ids.definitions.NodeTypeId;
-import org.eclipse.winery.common.ids.definitions.NodeTypeImplementationId;
-import org.eclipse.winery.common.ids.definitions.PolicyTemplateId;
-import org.eclipse.winery.common.ids.definitions.PolicyTypeId;
-import org.eclipse.winery.common.ids.definitions.RelationshipTypeId;
-import org.eclipse.winery.common.ids.definitions.RelationshipTypeImplementationId;
-import org.eclipse.winery.common.ids.definitions.RequirementTypeId;
-import org.eclipse.winery.common.ids.definitions.ServiceTemplateId;
-import org.eclipse.winery.model.tosca.HasIdInIdOrNameField;
-import org.eclipse.winery.model.tosca.TExtensibleElements;
-import org.eclipse.winery.model.tosca.TRelationshipTemplate;
-
-import de.danielbechler.diff.ObjectDifferBuilder;
-import de.danielbechler.diff.identity.IdentityStrategy;
-import de.danielbechler.diff.node.DiffNode;
import io.github.adr.embedded.ADR;
/**
* Utility class for working with versions.
- *
- * TODO: DefinitionsChildId specific parts should go into into the DefinitionsChildId to have a true object-oriented
- * thinking
*/
public class VersionUtils {
- private static final Pattern VERSION_PATTERN = Pattern.compile("_(([^_]*)-)?w([0-9]+)(-wip([0-9]+))?$");
- private static final int COMPONENT_VERSION_GROUP = 2;
- private static final int WINERY_VERSION_GROUP = 3;
- private static final int WIP_VERSION_GROUP_EXISTS = 4;
- private static final int WIP_VERSION_GROUP = 5;
-
- private static String REFERENCING_OBJECT = "referencingObject";
-
- public static WineryVersion getVersion(DefinitionsChildId id) {
- return getVersion(id.getXmlId().getDecoded());
- }
-
- public static WineryVersion getVersionWithCurrentFlag(DefinitionsChildId id, DefinitionsChildId requestingElementInSet) {
- Objects.requireNonNull(id);
- Objects.requireNonNull(requestingElementInSet);
- return getVersionWithCurrentFlag(id.getXmlId().getDecoded(), requestingElementInSet.getXmlId().getDecoded());
- }
-
- public static String getNameWithoutVersion(DefinitionsChildId id) {
- return getNameWithoutVersion(id.getXmlId().getDecoded());
- }
+ public static final Pattern VERSION_PATTERN = Pattern.compile("_((?[^_]*)-)?w(?\\d+)(-wip(?\\d+))?$");
+ public static final String COMPONENT_VERSION_GROUP = "component";
+ public static final String WINERY_VERSION_GROUP = "winery";
+ public static final String WIP_VERSION_GROUP = "wip";
public static String getNameWithoutVersion(String id) {
Matcher m = VERSION_PATTERN.matcher(id);
@@ -88,8 +47,9 @@ public static WineryVersion getVersion(String id) {
if (m.find()) {
String componentVersion = Objects.nonNull(m.group(COMPONENT_VERSION_GROUP)) ? m.group(COMPONENT_VERSION_GROUP) : "";
- int wineryVersion = Objects.nonNull(m.group(WINERY_VERSION_GROUP)) ? Integer.parseInt(m.group(WINERY_VERSION_GROUP)) : 0;
- int workInProgressVersion = Objects.nonNull(m.group(WIP_VERSION_GROUP_EXISTS)) ? Integer.parseInt(m.group(WIP_VERSION_GROUP)) : 0;
+ // winery group is not optional
+ int wineryVersion = Integer.parseInt(m.group(WINERY_VERSION_GROUP));
+ int workInProgressVersion = Objects.nonNull(m.group(WIP_VERSION_GROUP)) ? Integer.parseInt(m.group(WIP_VERSION_GROUP)) : 0;
return new WineryVersion(componentVersion, wineryVersion, workInProgressVersion);
}
@@ -97,122 +57,12 @@ public static WineryVersion getVersion(String id) {
return new WineryVersion();
}
- public static String getQNameWithComponentVersionOnly(DefinitionsChildId id) {
- Matcher m = VERSION_PATTERN.matcher(id.getXmlId().getDecoded());
- String componentVersion = "";
-
- if (m.find()) {
- componentVersion = Objects.nonNull(m.group(COMPONENT_VERSION_GROUP)) ? m.group(COMPONENT_VERSION_GROUP) : "";
- }
-
- String nameWithoutVersion = getNameWithoutVersion(id.getQName().toString());
- if (componentVersion.length() > 0) {
- nameWithoutVersion += WineryVersion.WINERY_VERSION_SEPARATOR + componentVersion;
- }
-
- return nameWithoutVersion;
- }
-
- public static DefinitionsChildId getDefinitionInTheGivenVersion(DefinitionsChildId childId, WineryVersion otherVersion) {
- if (getVersion(childId).compareTo(otherVersion) == 0) {
- return childId;
- }
-
- String localPart = getNameWithoutVersion(childId) +
- (otherVersion.toString().length() > 0 ? WineryVersion.WINERY_NAME_FROM_VERSION_SEPARATOR + otherVersion.toString() : "");
-
- QName qName = new QName(childId.getNamespace().getDecoded(), localPart);
- if (childId instanceof RelationshipTypeImplementationId) {
- return new RelationshipTypeImplementationId(qName);
- } else if (childId instanceof NodeTypeImplementationId) {
- return new NodeTypeImplementationId(qName);
- } else if (childId instanceof RequirementTypeId) {
- return new RequirementTypeId(qName);
- } else if (childId instanceof NodeTypeId) {
- return new NodeTypeId(qName);
- } else if (childId instanceof RelationshipTypeId) {
- return new RelationshipTypeId(qName);
- } else if (childId instanceof CapabilityTypeId) {
- return new CapabilityTypeId(qName);
- } else if (childId instanceof ArtifactTypeId) {
- return new ArtifactTypeId(qName);
- } else if (childId instanceof PolicyTypeId) {
- return new PolicyTypeId(qName);
- } else if (childId instanceof PolicyTemplateId) {
- return new PolicyTemplateId(qName);
- } else if (childId instanceof ServiceTemplateId) {
- return new ServiceTemplateId(qName);
- } else if (childId instanceof ArtifactTemplateId) {
- return new ArtifactTemplateId(qName);
- } else {
- throw new IllegalStateException("Unhandled id branch. Could happen for XSDImportId");
- }
- }
-
public static WineryVersion getVersionWithCurrentFlag(String id, String requestingElementInSet) {
WineryVersion version = getVersion(id);
version.setCurrentVersion(id.equals(requestingElementInSet));
return version;
}
- public static ToscaDiff calculateDifferences(T oldVersion, T newVersion) {
- IdentityStrategy identityStrategy = (o, o1) -> {
- if (o instanceof HasIdInIdOrNameField && o1 instanceof HasIdInIdOrNameField) {
- return Objects.equals(
- ((HasIdInIdOrNameField) o).getIdFromIdOrNameField(),
- ((HasIdInIdOrNameField) o1).getIdFromIdOrNameField());
- } else {
- return Objects.equals(o, o1);
- }
- };
-
- DiffNode diffNode = ObjectDifferBuilder
- .startBuilding()
- .categories()
- // In the scope of winery, a source or target element will not be changed, because relationship templates will be removed if
- // either one of the source or target element is removed. Therefore, to avoid changed relationships, if one of the source or
- // target element was changed, we ignore referencing elements.
- .ofType(TRelationshipTemplate.SourceOrTargetElement.class)
- .toBe(REFERENCING_OBJECT)
- .and()
- .inclusion()
- .exclude()
- .propertyName("nodeTemplateOrRelationshipTemplate")
- .propertyName("fakeJacksonType")
- // Ignore 'any', otherwise, it crashes if a policy with a XML content is contained somehow: java.util.Collections$EmptyEnumeration
- // at nodeTemplate/policies/policy/any/[content]/parentNode/identifiers
- .propertyName("any")
- .propertyName("internalAny")
- // ignore changes of the namespace prefix
- .propertyName("prefix")
- .category(REFERENCING_OBJECT)
- .and()
- .identity()
- // to provide a proper identification of elements in lists, use the custom identity strategy
- .setDefaultCollectionItemIdentityStrategy(identityStrategy)
- .and()
- .build()
- .compare(newVersion, oldVersion);
-
- return ToscaDiff.convertDiffToToscaDiff(diffNode, oldVersion, newVersion);
- }
-
- public static String getNewComponentVersionId(DefinitionsChildId oldId, String appendixName) {
- WineryVersion version = VersionUtils.getVersion(oldId);
- String oldVersion = version.toString();
-
- if (Objects.nonNull(oldVersion) && !oldVersion.isEmpty()) {
- version.setComponentVersion(oldVersion + "-" + appendixName);
- } else {
- version.setComponentVersion(appendixName);
- }
-
- version.setWineryVersion(1);
- version.setWorkInProgressVersion(1);
-
- return VersionUtils.getNameWithoutVersion(oldId) + WineryVersion.WINERY_NAME_FROM_VERSION_SEPARATOR + version.toString();
- }
-
public static WineryVersion getNewWineryVersion(List versions) {
WineryVersion[] version = new WineryVersion[1];
version[0] = versions.stream().filter(WineryVersion::isCurrentVersion)
diff --git a/org.eclipse.winery.common/src/main/resources/winery.yml b/org.eclipse.winery.common/src/main/resources/winery.yml
index 396e610f64..80729166d9 100644
--- a/org.eclipse.winery.common/src/main/resources/winery.yml
+++ b/org.eclipse.winery.common/src/main/resources/winery.yml
@@ -1,18 +1,19 @@
ui:
features:
- accountability: true
- completion: true
- compliance: true
- freezeAndDefrost: true
- managementFeatureEnrichment: true
- nfv: true
- patternRefinement: true
- problemDetection: true
- radon: false
- splitting: true
- testRefinement: true
- placement: true
+ updateTemplates: true
+ splitting: false
edmmModeling: false
+ freezeAndDefrost: false
+ managementFeatureEnrichment: false
+ problemDetection: false
+ patternRefinement: false
+ topologyFragmentRefinementModel: false
+ testRefinement: false
+ completion: false
+ accountability: false
+ compliance: false
+ placement: false
+ radon: false
endpoints:
container: http://localhost:1337
workflowmodeler: http://localhost:9527
diff --git a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/HashingUtilTests.java b/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/HashingUtilTests.java
new file mode 100644
index 0000000000..55014e27be
--- /dev/null
+++ b/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/HashingUtilTests.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
+ * which is available at https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
+ *******************************************************************************/
+
+package org.eclipse.winery.common;
+
+import java.io.File;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class HashingUtilTests {
+
+ @Test
+ public void testGetChecksum() throws Exception {
+ String text = "my super content of any file which will be hashed using a SHA-256 hash.";
+ assertEquals("c0af55785d21197a9fe4c5e9435fa77bb763f386810909e97f646eba7c827df7",
+ HashingUtil.getChecksum(IOUtils.toInputStream(text), "SHA-256"));
+ }
+
+ @Test
+ public void testGetChecksumOfFile() throws Exception {
+ File file = new File(ClassLoader.getSystemClassLoader().getResource("org/eclipse/winery/common/invalid.xml").getFile());
+ assertEquals("4406bff97249955ef46ea3ae590f9813fd44dcd769b8204cbb702ee6767173b0",
+ HashingUtil.getChecksum(file, "SHA-256"));
+ }
+}
diff --git a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/VersionUtilsTest.java b/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/VersionUtilsTest.java
index d73f0937d2..0eee6ee128 100644
--- a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/VersionUtilsTest.java
+++ b/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/VersionUtilsTest.java
@@ -14,9 +14,6 @@
package org.eclipse.winery.common;
-import org.eclipse.winery.common.ids.definitions.ArtifactTypeId;
-import org.eclipse.winery.common.ids.definitions.DefinitionsChildId;
-import org.eclipse.winery.common.ids.definitions.ServiceTemplateId;
import org.eclipse.winery.common.version.VersionUtils;
import org.eclipse.winery.common.version.WineryVersion;
@@ -58,16 +55,6 @@ public void getVersionWithNoVersionInTheName() {
assertEquals("", version.toString());
}
- @Test
- public void getVersionWithLeadingDashButNoComponentVersion() {
- DefinitionsChildId id = new ServiceTemplateId("http://example.org/tosca/versioning", "myServiceTemplate_-w1-wip5", false);
- WineryVersion version = VersionUtils.getVersion(id);
-
- assertEquals("", version.getComponentVersion());
- assertEquals(1, version.getWineryVersion());
- assertEquals(5, version.getWorkInProgressVersion());
- }
-
@Test
public void getVersionFromNameWithMultipleUnderscores() {
WineryVersion version = VersionUtils.getVersion("myExample_Component_v1.3.0-w1");
@@ -112,66 +99,5 @@ public void getVersionWithCurrentFlag() {
assertTrue(VersionUtils.getVersionWithCurrentFlag(name, name).isCurrentVersion());
}
- @Test
- public void getVersion() {
- String componentVersion = "1.0.0";
- int wineryVersion = 6;
- int wipVersion = 3;
-
- DefinitionsChildId id = getDefinitionChildId("http://example.org/tosca/versions", "myElement", componentVersion, wineryVersion, wipVersion);
- WineryVersion version = VersionUtils.getVersion(id);
-
- assertEquals(componentVersion, version.getComponentVersion());
- assertEquals(wineryVersion, version.getWineryVersion());
- assertEquals(wipVersion, version.getWorkInProgressVersion());
- }
-
- @Test
- public void getNameWithoutVersionFromDefinitionsChildId() {
- String name = "myElementTest";
- DefinitionsChildId id = getDefinitionChildId("http://example.org/tosca/versions", name, "1.2.3", 1, 1);
-
- assertEquals(name, VersionUtils.getNameWithoutVersion(id));
- }
-
- @Test
- public void getQNameWithComponentVersionOnly() {
- String name = "myElementTest";
- String namespace = "http://example.org/tosca/versions";
- String componentVersion = "1.2.3";
-
- DefinitionsChildId id = getDefinitionChildId(namespace, name, componentVersion, 1, 1);
-
- assertEquals("{" + namespace + "}" + name + WineryVersion.WINERY_VERSION_SEPARATOR + componentVersion,
- VersionUtils.getQNameWithComponentVersionOnly(id));
- }
-
- @Test
- public void getNewIdName() {
- String id = "myId_w1-wip56";
- String appendix = "test";
- String expectedId = "myId_w1-wip56-" + appendix + "-w1-wip1";
- ServiceTemplateId serviceTemplateId = new ServiceTemplateId("https://ex.org/tosca/sts", id, false);
-
- assertEquals(expectedId, VersionUtils.getNewComponentVersionId(serviceTemplateId, appendix));
- }
- @Test
- public void getNewIdIfComponentVersionIsAvailable() {
- String id = "myId_component-version-w1";
- String appendix = "test";
- String expectedId = "myId_component-version-w1-" + appendix + "-w1-wip1";
- ArtifactTypeId serviceTemplateId = new ArtifactTypeId("https://ex.org/tosca/sts", id, false);
-
- assertEquals(expectedId, VersionUtils.getNewComponentVersionId(serviceTemplateId, appendix));
- }
-
- private DefinitionsChildId getDefinitionChildId(String namespace, String name, String componentVersion, int wineryVersion, int wipVersion) {
- String elementName = name
- + WineryVersion.WINERY_NAME_FROM_VERSION_SEPARATOR + componentVersion
- + WineryVersion.WINERY_VERSION_SEPARATOR + WineryVersion.WINERY_VERSION_PREFIX + wineryVersion
- + WineryVersion.WINERY_VERSION_SEPARATOR + WineryVersion.WINERY_WIP_VERSION_PREFIX + wipVersion;
-
- return new ServiceTemplateId(namespace, elementName, false);
- }
}
diff --git a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/configuration/EnvironmentsTest.java b/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/configuration/EnvironmentsTest.java
index 269321c288..d181d46778 100644
--- a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/configuration/EnvironmentsTest.java
+++ b/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/configuration/EnvironmentsTest.java
@@ -25,6 +25,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Disabled("This test seems to fail transiently on test infrastructure")
@@ -148,4 +149,16 @@ public void testSaveEndpoints() {
UiConfigurationObject result = Environments.getInstance().getUiConfig();
assertEquals("", result.getEndpoints().get("quaz"));
}
+
+ @Test
+ public void testIsFeatureEnabled() {
+ UiConfigurationObject object = Environments.getInstance().getUiConfig();
+ object.getFeatures().put("test1", true);
+ object.getFeatures().put("test2", false);
+ object.save();
+ UiConfigurationObject result = Environments.getInstance().getUiConfig();
+ assertTrue(result.getFeatures().get("test1"));
+ assertFalse(result.getFeatures().get("test2"));
+ assertNull(result.getFeatures().get("test3"));
+ }
}
diff --git a/org.eclipse.winery.compliance/pom.xml b/org.eclipse.winery.compliance/pom.xml
index 1d7eb6dc86..41b91ba8ab 100644
--- a/org.eclipse.winery.compliance/pom.xml
+++ b/org.eclipse.winery.compliance/pom.xml
@@ -19,7 +19,7 @@
org.eclipse.winerywinery
- 2.0.0-SNAPSHOT
+ 3.0.0-SNAPSHOTorg.eclipse.winery.compliance
@@ -31,9 +31,8 @@
org.eclipse.winery
- org.eclipse.winery.model.tosca
- 2.0.0-SNAPSHOT
- compile
+ org.eclipse.winery.model.tosca.canonical
+ ${project.version}org.jgrapht
@@ -43,7 +42,7 @@
org.eclipse.wineryorg.eclipse.winery.topologygraph
- 2.0.0-SNAPSHOT
+ ${project.version}org.junit.jupiter
diff --git a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ComplianceRuleChecker.java b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ComplianceRuleChecker.java
index 66f2b18ef4..2c718dfbaf 100644
--- a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ComplianceRuleChecker.java
+++ b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ComplianceRuleChecker.java
@@ -20,7 +20,7 @@
import java.util.Map;
import java.util.Optional;
-import org.eclipse.winery.model.tosca.OTComplianceRule;
+import org.eclipse.winery.model.tosca.extensions.OTComplianceRule;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
import org.eclipse.winery.topologygraph.matching.ToscaIsomorphismMatcher;
import org.eclipse.winery.topologygraph.model.ToscaEdge;
diff --git a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ServiceTemplateComplianceRuleRuleChecker.java b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ServiceTemplateComplianceRuleRuleChecker.java
index ea660c88b5..b6e3b23496 100644
--- a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ServiceTemplateComplianceRuleRuleChecker.java
+++ b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ServiceTemplateComplianceRuleRuleChecker.java
@@ -19,9 +19,9 @@
import java.util.Map;
import java.util.stream.Collectors;
-import org.eclipse.winery.common.ids.Namespace;
-import org.eclipse.winery.common.ids.definitions.ComplianceRuleId;
-import org.eclipse.winery.model.tosca.OTComplianceRule;
+import org.eclipse.winery.model.ids.Namespace;
+import org.eclipse.winery.model.ids.extensions.ComplianceRuleId;
+import org.eclipse.winery.model.tosca.extensions.OTComplianceRule;
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.repository.backend.IRepository;
import org.eclipse.winery.repository.backend.RepositoryFactory;
diff --git a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ToscaComplianceRuleMatcher.java b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ToscaComplianceRuleMatcher.java
index 364bb8c24b..916cd5a41a 100644
--- a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ToscaComplianceRuleMatcher.java
+++ b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ToscaComplianceRuleMatcher.java
@@ -13,11 +13,12 @@
*******************************************************************************/
package org.eclipse.winery.compliance.checking;
-import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
+import org.eclipse.winery.model.tosca.TEntityTemplate;
import org.eclipse.winery.topologygraph.matching.IToscaMatcher;
import org.eclipse.winery.topologygraph.model.ToscaEdge;
import org.eclipse.winery.topologygraph.model.ToscaEntity;
@@ -61,21 +62,43 @@ private List mapToStringList(@NonNull List policy) {
}
public boolean isPropertiesCompatible(ToscaNode left, ToscaNode right) {
- if (left.getTemplate().getProperties() != null) {
- if (right.getTemplate().getProperties() != null) {
- for (Entry leftEntry : left.getTemplate().getProperties().getKVProperties().entrySet()) {
- if (!isPropertyCompatible(leftEntry, right.getTemplate().getProperties().getKVProperties())) {
- return false;
- }
+ TEntityTemplate.Properties leftProps = left.getTemplate().getProperties();
+ TEntityTemplate.Properties rightProps = right.getTemplate().getProperties();
+ if (leftProps == null) {
+ // no constraints on the properties, so all rightProps are valid
+ return true;
+ }
+ if (rightProps == null) {
+ // there are property requirements, so right must have a value
+ return false;
+ }
+ // property types are different
+ if (leftProps.getClass() != rightProps.getClass()) {
+ return false;
+ }
+ if (leftProps instanceof TEntityTemplate.WineryKVProperties) {
+ assert (rightProps instanceof TEntityTemplate.WineryKVProperties);
+
+ Map leftMap = ((TEntityTemplate.WineryKVProperties) leftProps).getKVProperties();
+ Map rightMap = ((TEntityTemplate.WineryKVProperties) rightProps).getKVProperties();
+
+ for (Entry leftEntry : leftMap.entrySet()) {
+ if (!isPropertyCompatible(leftEntry, rightMap)) {
+ return false;
}
- } else {
- return false;
}
+ return true;
+ } else if (leftProps instanceof TEntityTemplate.XmlProperties) {
+ assert (rightProps instanceof TEntityTemplate.XmlProperties);
+
+ return ((TEntityTemplate.XmlProperties) leftProps).getAny().equals(((TEntityTemplate.XmlProperties) rightProps).getAny());
+ } else {
+ // There's no ComplianceRules in YAML mode
+ return false;
}
- return true;
}
- public boolean isPropertyCompatible(Entry leftEntry, @ADR(12) LinkedHashMap rightProperties) {
+ public boolean isPropertyCompatible(Entry leftEntry, @ADR(12) Map rightProperties) {
return rightProperties.containsKey(leftEntry.getKey()) &&
rightProperties.get(leftEntry.getKey()) != null &&
isPropertyValueCompatible(leftEntry.getValue(), rightProperties.get(leftEntry.getKey()));
@@ -102,7 +125,8 @@ public boolean isTEntityTypesCompatible(ToscaEntity left, ToscaEntity right) {
}
public boolean equals(TEntityType lType, TEntityType rType) {
- return StringUtils.equals(lType.getIdFromIdOrNameField(), rType.getIdFromIdOrNameField()) && StringUtils.equals(lType.getTargetNamespace(), rType.getTargetNamespace());
+ return StringUtils.equals(lType.getIdFromIdOrNameField(), rType.getIdFromIdOrNameField())
+ && StringUtils.equals(lType.getTargetNamespace(), rType.getTargetNamespace());
}
@Override
diff --git a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ComplianceRuleCheckerTests.java b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ComplianceRuleCheckerTests.java
new file mode 100644
index 0000000000..3df18b6b64
--- /dev/null
+++ b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ComplianceRuleCheckerTests.java
@@ -0,0 +1,322 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
+ * which is available at https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
+ *******************************************************************************/
+
+package org.eclipse.winery.compliance;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.compliance.checking.ComplianceCheckingException;
+import org.eclipse.winery.compliance.checking.ComplianceRuleChecker;
+import org.eclipse.winery.model.ids.definitions.DefinitionsChildId;
+import org.eclipse.winery.model.ids.definitions.NodeTypeId;
+import org.eclipse.winery.model.ids.definitions.RelationshipTypeId;
+import org.eclipse.winery.model.tosca.TExtensibleElements;
+import org.eclipse.winery.model.tosca.TNodeTemplate;
+import org.eclipse.winery.model.tosca.TNodeType;
+import org.eclipse.winery.model.tosca.TRelationshipTemplate;
+import org.eclipse.winery.model.tosca.TRelationshipType;
+import org.eclipse.winery.model.tosca.TTopologyTemplate;
+import org.eclipse.winery.repository.TestWithGitBackedRepository;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
+
+import org.apache.commons.lang3.StringUtils;
+import org.jgrapht.GraphMapping;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.eclipse.winery.compliance.ToscaModelHelper.TEST_TARGET_NAMESPACE;
+import static org.eclipse.winery.compliance.ToscaModelHelper.createNodeTypeId;
+import static org.eclipse.winery.compliance.ToscaModelHelper.createTNodeTemplate;
+import static org.eclipse.winery.compliance.ToscaModelHelper.createTNodeType;
+import static org.eclipse.winery.compliance.ToscaModelHelper.createTRelationshipTemplate;
+import static org.eclipse.winery.compliance.ToscaModelHelper.createTRelationshipType;
+import static org.eclipse.winery.compliance.ToscaModelHelper.createTTopologyTemplate;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ComplianceRuleCheckerTests extends TestWithGitBackedRepository {
+
+ private TTopologyTemplate topologyTemplateToSearchIn;
+ private TTopologyTemplate requiredStructure;
+ private TTopologyTemplate identifier;
+ private TTopologyTemplate unrelatedTopology;
+
+ private void persist(HashMap allEntities) throws IOException {
+ for (Map.Entry entry : allEntities.entrySet()) {
+ repository.setElement(entry.getKey(), entry.getValue());
+ }
+ }
+
+ @BeforeEach
+ public void setup() throws IOException {
+ HashMap allEntities = new HashMap<>();
+
+ ToscaModelPropertiesBuilder bldr = new ToscaModelPropertiesBuilder(TEST_TARGET_NAMESPACE, "MyProperties");
+ bldr.addProperty("key1", "value1");
+ bldr.addProperty("key2", "value2");
+
+ //create NodeTypes A B
+ String idNodeTypeA = "idA";
+ TNodeType nodeTypeA = createTNodeType(idNodeTypeA, TEST_TARGET_NAMESPACE);
+ String idNodeTypeB = "idB";
+ TNodeType nodeTypeB = createTNodeType(idNodeTypeB, TEST_TARGET_NAMESPACE);
+ String idNodeTypeC = "idC";
+ TNodeType nodeTypeC = createTNodeType(idNodeTypeC, TEST_TARGET_NAMESPACE);
+
+ NodeTypeId idA = createNodeTypeId(idNodeTypeA);
+ NodeTypeId idB = createNodeTypeId(idNodeTypeB);
+ NodeTypeId idC = createNodeTypeId(idNodeTypeC);
+
+ allEntities.put(idA, nodeTypeA);
+ allEntities.put(idB, nodeTypeB);
+ allEntities.put(idC, nodeTypeC);
+
+ //createRelationshipTypes
+ String relTypeIdAString = "adRelA";
+ RelationshipTypeId relTypeIdA = new RelationshipTypeId(new QName(TEST_TARGET_NAMESPACE, relTypeIdAString));
+ TRelationshipType relTypeA = createTRelationshipType(relTypeIdAString, TEST_TARGET_NAMESPACE);
+
+ allEntities.put(relTypeIdA, relTypeA);
+
+ //createNodeTemplates
+ TNodeTemplate nodeTemplate1 = createTNodeTemplate("01");
+ nodeTemplate1.setType(idA.getQName());
+
+ TNodeTemplate nodeTemplate2 = createTNodeTemplate("02");
+ nodeTemplate2.setType(idB.getQName());
+
+ TNodeTemplate nodeTemplate3 = createTNodeTemplate("03");
+ nodeTemplate3.setType(idA.getQName());
+ nodeTemplate3.setProperties(bldr.build());
+
+ TNodeTemplate nodeTemplate4 = createTNodeTemplate("04");
+ nodeTemplate4.setType(idB.getQName());
+
+ TNodeTemplate nodeTemplate5 = createTNodeTemplate("05");
+ nodeTemplate5.setType(idA.getQName());
+
+ TNodeTemplate nodeTemplate6 = createTNodeTemplate("06");
+ nodeTemplate6.setType(idB.getQName());
+
+ TNodeTemplate nodeTemplate7 = createTNodeTemplate("07");
+ nodeTemplate7.setType(idA.getQName());
+ nodeTemplate7.setProperties(bldr.build());
+
+ TNodeTemplate nodeTemplate8 = createTNodeTemplate("08");
+ nodeTemplate8.setType(idB.getQName());
+
+ TNodeTemplate nodeTemplate9 = createTNodeTemplate("CompletelyUnrelated");
+ nodeTemplate9.setType(idC.getQName());
+
+ //create RelationshipTemplates
+ TRelationshipTemplate relTemplate1 = createTRelationshipTemplate("1");
+ relTemplate1.setSourceNodeTemplate(nodeTemplate1);
+ relTemplate1.setTargetNodeTemplate(nodeTemplate2);
+ relTemplate1.setType(relTypeIdA.getQName());
+
+ TRelationshipTemplate relTemplate2 = createTRelationshipTemplate("2");
+ relTemplate2.setSourceNodeTemplate(nodeTemplate3);
+ relTemplate2.setTargetNodeTemplate(nodeTemplate4);
+ relTemplate2.setType(relTypeIdA.getQName());
+
+ TRelationshipTemplate relTemplate3 = createTRelationshipTemplate("3");
+ relTemplate3.setSourceNodeTemplate(nodeTemplate5);
+ relTemplate3.setTargetNodeTemplate(nodeTemplate6);
+ relTemplate3.setType(relTypeIdA.getQName());
+
+ TRelationshipTemplate relTemplate4 = createTRelationshipTemplate("4");
+ relTemplate4.setSourceNodeTemplate(nodeTemplate7);
+ relTemplate4.setTargetNodeTemplate(nodeTemplate8);
+ relTemplate4.setType(relTypeIdA.getQName());
+
+ //create TopologyTemplates
+ List nodeTemplates = new ArrayList<>();
+ List relationshipTemplates = new ArrayList<>();
+
+ // create identifier
+ nodeTemplates.add(nodeTemplate1);
+ nodeTemplates.add(nodeTemplate2);
+ relationshipTemplates.add(relTemplate1);
+ identifier = createTTopologyTemplate(nodeTemplates, relationshipTemplates);
+ identifier.setNodeTemplates(nodeTemplates);
+ identifier.setRelationshipTemplates(relationshipTemplates);
+ nodeTemplates.clear();
+ relationshipTemplates.clear();
+
+ //create required structure
+ nodeTemplates.add(nodeTemplate3);
+ nodeTemplates.add(nodeTemplate4);
+ relationshipTemplates.add(relTemplate2);
+ requiredStructure = createTTopologyTemplate(nodeTemplates, relationshipTemplates);
+ requiredStructure.setNodeTemplates(nodeTemplates);
+ requiredStructure.setRelationshipTemplates(relationshipTemplates);
+ nodeTemplates.clear();
+ relationshipTemplates.clear();
+
+ //create topologyToSearchIn
+ nodeTemplates.add(nodeTemplate5);
+ nodeTemplates.add(nodeTemplate6);
+ nodeTemplates.add(nodeTemplate7);
+ nodeTemplates.add(nodeTemplate8);
+ relationshipTemplates.add(relTemplate3);
+ relationshipTemplates.add(relTemplate4);
+ topologyTemplateToSearchIn = createTTopologyTemplate(nodeTemplates, relationshipTemplates);
+ topologyTemplateToSearchIn.setNodeTemplates(nodeTemplates);
+ topologyTemplateToSearchIn.setRelationshipTemplates(relationshipTemplates);
+ nodeTemplates.clear();
+ relationshipTemplates.clear();
+
+ //create unrelated topology
+ nodeTemplates.add(nodeTemplate9);
+ unrelatedTopology = createTTopologyTemplate(nodeTemplates, relationshipTemplates);
+ unrelatedTopology.setNodeTemplates(nodeTemplates);
+ unrelatedTopology.setRelationshipTemplates(relationshipTemplates);
+ nodeTemplates.clear();
+ relationshipTemplates.clear();
+
+ persist(allEntities);
+ }
+
+ @Test
+ public void nullTemplateToCheck() {
+ ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
+ ComplianceCheckingException expected = null;
+ try {
+ checker.checkComplianceRule();
+ } catch (ComplianceCheckingException e) {
+ expected = e;
+ }
+ assertNotNull(expected);
+ assertTrue(StringUtils.equals(ComplianceCheckingException.NO_TEMPLATE_TO_CHECK, expected.getMessage()));
+ }
+
+ @Test
+ public void emptyRule() {
+ ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
+ checker.setToCheckTemplate(topologyTemplateToSearchIn);
+
+ ComplianceCheckingException expected = null;
+ try {
+ checker.checkComplianceRule();
+ } catch (ComplianceCheckingException e) {
+ expected = e;
+ }
+ assertNotNull(expected);
+ assertTrue(StringUtils.equals(ComplianceCheckingException.EMPTY_COMPLIANCE_RULE, expected.getMessage()));
+ }
+
+ @Test
+ public void whitelist() {
+ ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
+ checker.setToCheckTemplate(topologyTemplateToSearchIn);
+
+ checker.setRequiredStructureTemplate(requiredStructure);
+ ComplianceCheckingException expected = null;
+ try {
+ checker.checkComplianceRule();
+ } catch (ComplianceCheckingException e) {
+ expected = e;
+ }
+ assertNotNull(expected);
+ assertTrue(StringUtils.equals(ComplianceCheckingException.WHITELISTING_NOT_YET_IMPLEMENTED, expected.getMessage()));
+ }
+
+ @Test
+ public void blacklist() throws Exception {
+ ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
+ checker.setToCheckTemplate(topologyTemplateToSearchIn);
+ checker.setRequiredStructureTemplate(null);
+ checker.setIdentifierTemplate(identifier);
+ List blacklistResult = checker.checkComplianceRule();
+ assertEquals(2, blacklistResult.size());
+ }
+
+ @Test
+ public void completeRule() {
+ ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
+ checker.setToCheckTemplate(topologyTemplateToSearchIn);
+
+ checker.setIdentifierTemplate(unrelatedTopology);
+ checker.setRequiredStructureTemplate(requiredStructure);
+ ComplianceCheckingException expected = null;
+ try {
+ checker.checkComplianceRule();
+ } catch (ComplianceCheckingException e) {
+ expected = e;
+ }
+ assertNotNull(expected);
+ assertTrue(StringUtils.equals(ComplianceCheckingException.IDENTIFIER_NOT_IN_REQUIREDSTRUCTURE, expected.getMessage()));
+ }
+
+ @Test
+ public void completeRule_noMapping() {
+ ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
+ checker.setToCheckTemplate(topologyTemplateToSearchIn);
+
+ // test completeRule
+ // invalid Rule: identifier and required structure have no mapping
+ checker.setIdentifierTemplate(unrelatedTopology);
+ checker.setRequiredStructureTemplate(requiredStructure);
+ ComplianceCheckingException expected = null;
+ try {
+ checker.checkComplianceRule();
+ } catch (ComplianceCheckingException e) {
+ expected = e;
+ }
+ assertNotNull(expected);
+ assertTrue(StringUtils.equals(ComplianceCheckingException.IDENTIFIER_NOT_IN_REQUIREDSTRUCTURE, expected.getMessage()));
+ }
+
+ @Test
+ public void validRule_identifierInRequired_findsOne() throws Exception {
+ ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
+ checker.setToCheckTemplate(topologyTemplateToSearchIn);
+
+ checker.setIdentifierTemplate(identifier);
+ checker.setRequiredStructureTemplate(requiredStructure);
+ List violatingMappings = checker.checkComplianceRule();
+ assertEquals(1, violatingMappings.size());
+
+ ToscaNode identifierNode1 = checker.getIdentifierGraph().getNode("01");
+ ToscaNode identifierNode2 = checker.getIdentifierGraph().getNode("02");
+ ToscaEdge identifierEdge = checker.getIdentifierGraph().getEdge(identifierNode1, identifierNode2);
+
+ GraphMapping violatingMapping = violatingMappings.stream().findFirst().get();
+
+ assertNotNull(violatingMapping);
+ Map resultMap = checker.getSubGraphMappingAsMap(violatingMapping, checker.getIdentifierGraph());
+
+ assertTrue(resultMap.get(identifierNode1).getId().matches("05"));
+ assertTrue(resultMap.get(identifierNode2).getId().matches("06"));
+ assertTrue(((ToscaEdge) violatingMapping.getEdgeCorrespondence(identifierEdge, false)).getId().matches("3"));
+ }
+
+ @Test
+ public void findsNoViolation() throws Exception {
+ ComplianceRuleChecker checker = new ComplianceRuleChecker(null, null, null);
+ checker.setToCheckTemplate(topologyTemplateToSearchIn);
+
+ checker.setIdentifierTemplate(identifier);
+ checker.setRequiredStructureTemplate(identifier);
+ assertEquals(0, checker.checkComplianceRule().size());
+ }
+}
diff --git a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaGraphIsomorphismTest.java b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaGraphIsomorphismTest.java
index 7131de1fd6..b496e2ad38 100644
--- a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaGraphIsomorphismTest.java
+++ b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaGraphIsomorphismTest.java
@@ -15,7 +15,6 @@
import java.io.IOException;
import java.io.StringWriter;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@@ -27,24 +26,18 @@
import javax.xml.bind.Marshaller;
import javax.xml.namespace.QName;
-import org.eclipse.winery.common.ids.definitions.ComplianceRuleId;
-import org.eclipse.winery.common.ids.definitions.DefinitionsChildId;
-import org.eclipse.winery.common.ids.definitions.NodeTypeId;
-import org.eclipse.winery.common.ids.definitions.RelationshipTypeId;
-import org.eclipse.winery.common.ids.definitions.ServiceTemplateId;
-import org.eclipse.winery.compliance.checking.ComplianceCheckingException;
-import org.eclipse.winery.compliance.checking.ComplianceRuleChecker;
import org.eclipse.winery.compliance.checking.ServiceTemplateCheckingResult;
import org.eclipse.winery.compliance.checking.ServiceTemplateComplianceRuleRuleChecker;
import org.eclipse.winery.compliance.checking.ToscaComplianceRuleMatcher;
-import org.eclipse.winery.model.tosca.OTComplianceRule;
+import org.eclipse.winery.model.ids.extensions.ComplianceRuleId;
+import org.eclipse.winery.model.ids.definitions.DefinitionsChildId;
+import org.eclipse.winery.model.ids.definitions.NodeTypeId;
+import org.eclipse.winery.model.ids.definitions.ServiceTemplateId;
import org.eclipse.winery.model.tosca.TExtensibleElements;
import org.eclipse.winery.model.tosca.TNodeTemplate;
import org.eclipse.winery.model.tosca.TNodeType;
-import org.eclipse.winery.model.tosca.TRelationshipTemplate;
-import org.eclipse.winery.model.tosca.TRelationshipType;
import org.eclipse.winery.model.tosca.TServiceTemplate;
-import org.eclipse.winery.model.tosca.TTopologyTemplate;
+import org.eclipse.winery.model.tosca.extensions.OTComplianceRule;
import org.eclipse.winery.repository.TestWithGitBackedRepository;
import org.eclipse.winery.repository.backend.BackendUtils;
import org.eclipse.winery.topologygraph.matching.ToscaIsomorphismMatcher;
@@ -52,9 +45,7 @@
import org.eclipse.winery.topologygraph.model.ToscaGraph;
import org.eclipse.winery.topologygraph.model.ToscaNode;
-import org.apache.commons.lang3.StringUtils;
import org.jgrapht.GraphMapping;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static com.google.common.collect.Lists.newArrayList;
@@ -67,41 +58,24 @@
import static org.eclipse.winery.compliance.ToscaModelHelper.createTOSCANode;
import static org.eclipse.winery.compliance.ToscaModelHelper.createTOSCANodeOnlyProperties;
import static org.eclipse.winery.compliance.ToscaModelHelper.createTOSCANodeOnlyTypes;
-import static org.eclipse.winery.compliance.ToscaModelHelper.createTRelationshipTemplate;
-import static org.eclipse.winery.compliance.ToscaModelHelper.createTRelationshipType;
import static org.eclipse.winery.compliance.ToscaModelHelper.createTServiceTemplate;
import static org.eclipse.winery.compliance.ToscaModelHelper.createTTopologyTemplate;
import static org.eclipse.winery.compliance.ToscaModelHelper.setDerivedFrom;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ToscaGraphIsomorphismTest extends TestWithGitBackedRepository {
- // TODO revise
-// private final IRepository repository = initializeRepository();
-//
-// private IRepository initializeRepository() {
-// Path path = Paths.get(System.getProperty("java.io.tmpdir")).resolve("test-repository");
-// return RepositoryFactory.getRepository(new FileBasedRepositoryConfiguration(path));
-// }
-
private void persist(HashMap allEntities) throws IOException {
for (Map.Entry entry : allEntities.entrySet()) {
repository.setElement(entry.getKey(), entry.getValue());
}
}
- // TODO revise
-// @BeforeEach
-// public void cleanUp() {
-// repository.doClear();
-// }
-
@Test
public void testTComplianceRulePersistence() throws Exception {
- OTComplianceRule rule = new OTComplianceRule();
+ OTComplianceRule rule = new OTComplianceRule(new OTComplianceRule.Builder());
rule.setName("test");
rule.setTargetNamespace(TEST_TARGET_NAMESPACE);
@@ -196,25 +170,12 @@ public void testTOSCAComplianceRuleMatcher() throws IOException {
// other way round
assertFalse(matcher.isPropertiesCompatible(createTOSCANodeOnlyProperties(bldrRight), createTOSCANodeOnlyProperties(bldrLeft)));
-
-// String repositoryURI = "http://localhost:8080/winery";
-//
-// boolean USE_PROXY = false;
-//
-// IWineryRepositoryClient client = new WineryRepositoryClient(USE_PROXY);
-//
-// client.addRepository(repositoryURI);
-//
-// TTopologyTemplate testTemplate = client.getTopologyTemplate(new QName( "http://opentosca.org/compliancerules","TestTemplate"));
-//
-// TNodeTemplate.Policies leftPolicies;
-// TPolicy policy;
-
}
@Test
- @Disabled // TODO Fix this test using the repo test superclass
- public void testServiceTemplateComplianceRuleChecker() throws IOException {
+ public void testServiceTemplateComplianceRuleChecker() throws Exception {
+ this.setRevisionTo("origin/plain");
+
HashMap allEntities = new HashMap<>();
TServiceTemplate tServiceTemplate = createTServiceTemplate("ServiceTemplateTestId", TEST_TARGET_NAMESPACE);
@@ -297,229 +258,6 @@ public void testServiceTemplateComplianceRuleChecker() throws IOException {
}
}
- @Test
- public void testTOSCAComplianceRuleChecker() throws IOException, ComplianceCheckingException {
-
- HashMap allEntities = new HashMap<>();
-
- ToscaModelPropertiesBuilder bldr = new ToscaModelPropertiesBuilder(TEST_TARGET_NAMESPACE, "MyProperties");
- bldr.addProperty("key1", "value1");
- bldr.addProperty("key2", "value2");
-
- //create NodeTypes A B
- String idNodeTypeA = "idA";
- TNodeType nodeTypeA = createTNodeType(idNodeTypeA, TEST_TARGET_NAMESPACE);
- String idNodeTypeB = "idB";
- TNodeType nodeTypeB = createTNodeType(idNodeTypeB, TEST_TARGET_NAMESPACE);
- String idNodeTypeC = "idC";
- TNodeType nodeTypeC = createTNodeType(idNodeTypeC, TEST_TARGET_NAMESPACE);
-
- NodeTypeId idA = createNodeTypeId(idNodeTypeA);
- NodeTypeId idB = createNodeTypeId(idNodeTypeB);
- NodeTypeId idC = createNodeTypeId(idNodeTypeC);
-
- allEntities.put(idA, nodeTypeA);
- allEntities.put(idB, nodeTypeB);
- allEntities.put(idC, nodeTypeC);
-
- //createRelationshipTypes
- String relTypeIdAString = "adRelA";
- RelationshipTypeId relTypeIdA = new RelationshipTypeId(new QName(TEST_TARGET_NAMESPACE, relTypeIdAString));
- TRelationshipType relTypeA = createTRelationshipType(relTypeIdAString, TEST_TARGET_NAMESPACE);
-
- allEntities.put(relTypeIdA, relTypeA);
-
- //createNodeTemplates
- TNodeTemplate nodeTemplate1 = createTNodeTemplate("01");
- nodeTemplate1.setType(idA.getQName());
-
- TNodeTemplate nodeTemplate2 = createTNodeTemplate("02");
- nodeTemplate2.setType(idB.getQName());
-
- TNodeTemplate nodeTemplate3 = createTNodeTemplate("03");
- nodeTemplate3.setType(idA.getQName());
- nodeTemplate3.setProperties(bldr.build());
-
- TNodeTemplate nodeTemplate4 = createTNodeTemplate("04");
- nodeTemplate4.setType(idB.getQName());
-
- TNodeTemplate nodeTemplate5 = createTNodeTemplate("05");
- nodeTemplate5.setType(idA.getQName());
-
- TNodeTemplate nodeTemplate6 = createTNodeTemplate("06");
- nodeTemplate6.setType(idB.getQName());
-
- TNodeTemplate nodeTemplate7 = createTNodeTemplate("07");
- nodeTemplate7.setType(idA.getQName());
- nodeTemplate7.setProperties(bldr.build());
-
- TNodeTemplate nodeTemplate8 = createTNodeTemplate("08");
- nodeTemplate8.setType(idB.getQName());
-
- TNodeTemplate nodeTemplate9 = createTNodeTemplate("CompletelyUnrelated");
- nodeTemplate9.setType(idC.getQName());
-
- //create RelationshipTemplates
- TRelationshipTemplate relTemplate1 = createTRelationshipTemplate("1");
- relTemplate1.setSourceNodeTemplate(nodeTemplate1);
- relTemplate1.setTargetNodeTemplate(nodeTemplate2);
- relTemplate1.setType(relTypeIdA.getQName());
-
- TRelationshipTemplate relTemplate2 = createTRelationshipTemplate("2");
- relTemplate2.setSourceNodeTemplate(nodeTemplate3);
- relTemplate2.setTargetNodeTemplate(nodeTemplate4);
- relTemplate2.setType(relTypeIdA.getQName());
-
- TRelationshipTemplate relTemplate3 = createTRelationshipTemplate("3");
- relTemplate3.setSourceNodeTemplate(nodeTemplate5);
- relTemplate3.setTargetNodeTemplate(nodeTemplate6);
- relTemplate3.setType(relTypeIdA.getQName());
-
- TRelationshipTemplate relTemplate4 = createTRelationshipTemplate("4");
- relTemplate4.setSourceNodeTemplate(nodeTemplate7);
- relTemplate4.setTargetNodeTemplate(nodeTemplate8);
- relTemplate4.setType(relTypeIdA.getQName());
-
- //create TopologyTemplates
- List nodeTemplates = new ArrayList<>();
- List relationshipTemplates = new ArrayList<>();
-
- // create identifier
- nodeTemplates.add(nodeTemplate1);
- nodeTemplates.add(nodeTemplate2);
- relationshipTemplates.add(relTemplate1);
- TTopologyTemplate identifier = createTTopologyTemplate(nodeTemplates, relationshipTemplates);
- identifier.setNodeTemplates(nodeTemplates);
- identifier.setRelationshipTemplates(relationshipTemplates);
- nodeTemplates.clear();
- relationshipTemplates.clear();
-
- //create required structure
- nodeTemplates.add(nodeTemplate3);
- nodeTemplates.add(nodeTemplate4);
- relationshipTemplates.add(relTemplate2);
- TTopologyTemplate requiredStructure = createTTopologyTemplate(nodeTemplates, relationshipTemplates);
- requiredStructure.setNodeTemplates(nodeTemplates);
- requiredStructure.setRelationshipTemplates(relationshipTemplates);
- nodeTemplates.clear();
- relationshipTemplates.clear();
-
- //create topologyToSearchIn
- nodeTemplates.add(nodeTemplate5);
- nodeTemplates.add(nodeTemplate6);
- nodeTemplates.add(nodeTemplate7);
- nodeTemplates.add(nodeTemplate8);
- relationshipTemplates.add(relTemplate3);
- relationshipTemplates.add(relTemplate4);
- TTopologyTemplate topologyTemplateToSearchIn = createTTopologyTemplate(nodeTemplates, relationshipTemplates);
- topologyTemplateToSearchIn.setNodeTemplates(nodeTemplates);
- topologyTemplateToSearchIn.setRelationshipTemplates(relationshipTemplates);
- nodeTemplates.clear();
- relationshipTemplates.clear();
-
- //create unrelated topology
- nodeTemplates.add(nodeTemplate9);
- TTopologyTemplate unrelatedTopology = createTTopologyTemplate(nodeTemplates, relationshipTemplates);
- unrelatedTopology.setNodeTemplates(nodeTemplates);
- unrelatedTopology.setRelationshipTemplates(relationshipTemplates);
- nodeTemplates.clear();
- relationshipTemplates.clear();
-
- persist(allEntities);
-
- // **************** //
- // Test starts here //
- // **************** //
-
- ComplianceRuleChecker checker;
-
- // test null topologyTemplateToCheck
- checker = new ComplianceRuleChecker(null, null, null);
- ComplianceCheckingException expected = null;
- try {
- checker.checkComplianceRule();
- } catch (ComplianceCheckingException e) {
- expected = e;
- }
- assertNotNull(expected);
- assertTrue(StringUtils.equals(ComplianceCheckingException.NO_TEMPLATE_TO_CHECK, expected.getMessage()));
-
- checker.setToCheckTemplate(topologyTemplateToSearchIn);
-
- // test empty rule
- expected = null;
- try {
- checker.checkComplianceRule();
- } catch (ComplianceCheckingException e) {
- expected = e;
- }
- assertNotNull(expected);
- assertTrue(StringUtils.equals(ComplianceCheckingException.EMPTY_COMPLIANCE_RULE, expected.getMessage()));
-
- // test Whitelist
- checker.setRequiredStructureTemplate(requiredStructure);
- expected = null;
- try {
- checker.checkComplianceRule();
- } catch (ComplianceCheckingException e) {
- expected = e;
- }
- assertNotNull(expected);
- assertTrue(StringUtils.equals(ComplianceCheckingException.WHITELISTING_NOT_YET_IMPLEMENTED, expected.getMessage()));
-
- // test blacklist
- checker.setRequiredStructureTemplate(null);
- checker.setIdentifierTemplate(identifier);
- List blacklistResult = checker.checkComplianceRule();
- assertEquals(2, blacklistResult.size());
-
- // test completeRule
- // invalid Rule: identifier and required structure have no mapping
- checker.setIdentifierTemplate(unrelatedTopology);
- checker.setRequiredStructureTemplate(requiredStructure);
- expected = null;
- try {
- checker.checkComplianceRule();
- } catch (ComplianceCheckingException e) {
- expected = e;
- }
- assertNotNull(expected);
- assertTrue(StringUtils.equals(ComplianceCheckingException.IDENTIFIER_NOT_IN_REQUIREDSTRUCTURE, expected.getMessage()));
-
- // valid Rule: identifier in required structure
- // finds one violation
- checker.setIdentifierTemplate(identifier);
- checker.setRequiredStructureTemplate(requiredStructure);
- List violatingMappings = checker.checkComplianceRule();
- assertEquals(1, violatingMappings.size());
-
- // check the mapping.
- // must contain nodesTemplates 5 & 6 and relTemplate3
-
- ToscaNode identifierNode1 = checker.getIdentifierGraph().getNode("01");
- ToscaNode identifierNode2 = checker.getIdentifierGraph().getNode("02");
- ToscaEdge identifierEdge = checker.getIdentifierGraph().getEdge(identifierNode1, identifierNode2);
-
- GraphMapping violatingMapping = violatingMappings.stream().findFirst().get();
-
- assertNotNull(violatingMapping);
- Map resultMap = checker.getSubGraphMappingAsMap(violatingMapping, checker.getIdentifierGraph());
-
- assertTrue(resultMap.get(identifierNode1).getId().matches("05"));
- assertTrue(resultMap.get(identifierNode2).getId().matches("06"));
- assertTrue(((ToscaEdge) violatingMapping.getEdgeCorrespondence(identifierEdge, false)).getId().matches("3"));
-
- //finds no violation
- checker.setRequiredStructureTemplate(identifier);
- assertEquals(0, checker.checkComplianceRule().size());
-
- OTComplianceRule rule = new OTComplianceRule();
- rule.setName("test");
- rule.setTargetNamespace(TEST_TARGET_NAMESPACE);
- rule.setIdentifier(identifier);
- rule.setRequiredStructure(requiredStructure);
- }
-
@Test
public void testTOSCADefaultMatcher() {
ToscaGraph queryGraph = new ToscaGraph();
diff --git a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelHelper.java b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelHelper.java
index 276349700c..acf42ad99c 100644
--- a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelHelper.java
+++ b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelHelper.java
@@ -17,13 +17,8 @@
import javax.xml.namespace.QName;
-import org.eclipse.winery.common.ids.definitions.ComplianceRuleId;
-import org.eclipse.winery.common.ids.definitions.NodeTypeId;
-import org.eclipse.winery.topologygraph.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.model.ToscaGraph;
-import org.eclipse.winery.topologygraph.model.ToscaNode;
-import org.eclipse.winery.topologygraph.transformation.ToscaTransformer;
-import org.eclipse.winery.model.tosca.OTComplianceRule;
+import org.eclipse.winery.model.ids.extensions.ComplianceRuleId;
+import org.eclipse.winery.model.ids.definitions.NodeTypeId;
import org.eclipse.winery.model.tosca.TEntityType;
import org.eclipse.winery.model.tosca.TNodeTemplate;
import org.eclipse.winery.model.tosca.TNodeType;
@@ -31,6 +26,11 @@
import org.eclipse.winery.model.tosca.TRelationshipType;
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
+import org.eclipse.winery.model.tosca.extensions.OTComplianceRule;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaGraph;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
+import org.eclipse.winery.topologygraph.transformation.ToscaTransformer;
public class ToscaModelHelper {
@@ -44,10 +44,10 @@ public static TNodeTemplate createTNodeTemplate(String id) {
}
public static TTopologyTemplate createTTopologyTemplate(List nodeTemplates, List relationshipTemplates) {
- TTopologyTemplate template = new TTopologyTemplate();
- template.setNodeTemplates(nodeTemplates);
- template.setRelationshipTemplates(relationshipTemplates);
- return template;
+ return new TTopologyTemplate.Builder()
+ .addNodeTemplates(nodeTemplates)
+ .addRelationshipTemplates(relationshipTemplates)
+ .build();
}
public static TNodeType createTNodeType(NodeTypeId nodeTypeIdAbstractA) {
@@ -85,13 +85,14 @@ public static ToscaNode createTOSCANode(String id, String name) {
template.setName(name);
ToscaNode node = new ToscaNode();
node.setNodeTemplate(template);
+ node.setId(id);
return node;
}
- public static ToscaNode createTOSCANodeOnlyProperties(ToscaModelPropertiesBuilder bldr) {
+ public static ToscaNode createTOSCANodeOnlyProperties(ToscaModelPropertiesBuilder propertiesBuilder) {
ToscaNode node = new ToscaNode();
node.setNodeTemplate(new TNodeTemplate());
- node.getTemplate().setProperties(bldr.build());
+ node.getTemplate().setProperties(propertiesBuilder.build());
return node;
}
@@ -147,9 +148,7 @@ public static OTComplianceRule createTComplianceRule(ComplianceRuleId id) {
}
public static OTComplianceRule createTComplianceRule(String id, String ns) {
- OTComplianceRule rule = new OTComplianceRule();
- rule.setId(id);
- rule.setTargetNamespace(ns);
- return rule;
+ return new OTComplianceRule(new OTComplianceRule.Builder(id)
+ .setTargetNamespace(ns));
}
}
diff --git a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelPropertiesBuilder.java b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelPropertiesBuilder.java
index 69904f2e28..8b6c9aeac7 100644
--- a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelPropertiesBuilder.java
+++ b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelPropertiesBuilder.java
@@ -13,84 +13,61 @@
********************************************************************************/
package org.eclipse.winery.compliance;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
+import java.util.LinkedHashMap;
import org.eclipse.winery.model.tosca.TEntityTemplate;
import org.eclipse.jdt.annotation.NonNull;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
public class ToscaModelPropertiesBuilder {
- java.util.Properties properties = new Properties();
- @NonNull
- public static String namespaceURI;
- @NonNull
- public static String prefix = "rnd";
- @NonNull
- public static String localName;
-
- public ToscaModelPropertiesBuilder(@NonNull String namespaceURI, @NonNull String localName) {
- this.namespaceURI = namespaceURI;
- this.localName = localName;
- }
-
- public ToscaModelPropertiesBuilder addProperty(@NonNull String key, @NonNull String value) {
- properties.put(key, value);
- return this;
- }
-
- public TEntityTemplate.Properties build() {
- Document doc = null;
- TEntityTemplate.Properties result = new TEntityTemplate.Properties();
-
- if (properties.isEmpty()) {
- return result;
- }
- try {
- doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- Element propertiesElement = doc.createElementNS(namespaceURI, prefix + ":" + localName);
- for (Map.Entry
-
+
org.apache.httpcomponents
@@ -65,13 +65,11 @@
commons-iocommons-io2.6
- compileorg.apache.commonscommons-compress${org.apache.commons.compress.version}
- compileorg.tukaani
@@ -88,13 +86,11 @@
org.eclipse.wineryorg.eclipse.winery.model.tosca.yaml${project.version}
- compileorg.eclipse.winery
- org.eclipse.winery.model.tosca
+ org.eclipse.winery.model.tosca.canonical${project.version}
- compile
@@ -106,9 +102,7 @@
org.eclipse.wineryorg.eclipse.winery.repository${project.version}
- compile
-
diff --git a/org.eclipse.winery.crawler/src/main/java/org/eclipse/winery/crawler/chefcookbooks/chefcookbook/CookbookConfigurationToscaConverter.java b/org.eclipse.winery.crawler/src/main/java/org/eclipse/winery/crawler/chefcookbooks/chefcookbook/CookbookConfigurationToscaConverter.java
index 2dd1fbe7af..452724f27e 100644
--- a/org.eclipse.winery.crawler/src/main/java/org/eclipse/winery/crawler/chefcookbooks/chefcookbook/CookbookConfigurationToscaConverter.java
+++ b/org.eclipse.winery.crawler/src/main/java/org/eclipse/winery/crawler/chefcookbooks/chefcookbook/CookbookConfigurationToscaConverter.java
@@ -21,7 +21,7 @@
import javax.xml.namespace.QName;
-import org.eclipse.winery.common.ids.definitions.NodeTypeId;
+import org.eclipse.winery.model.ids.definitions.NodeTypeId;
import org.eclipse.winery.common.version.WineryVersion;
import org.eclipse.winery.model.tosca.*;
import org.eclipse.winery.repository.backend.RepositoryFactory;
diff --git a/org.eclipse.winery.edmm/pom.xml b/org.eclipse.winery.edmm/pom.xml
new file mode 100644
index 0000000000..eec37e38a7
--- /dev/null
+++ b/org.eclipse.winery.edmm/pom.xml
@@ -0,0 +1,74 @@
+
+
+
+
+ 4.0.0
+
+ winery
+ org.eclipse.winery
+ 3.0.0-SNAPSHOT
+
+ org.eclipse.winery.edmm
+
+
+
+ jitpack.io
+ https://www.jitpack.io
+
+
+
+
+
+ com.github.UST-EDMM.edmm
+ edmm-core
+ v1.0.8
+
+
+ org.eclipse.winery
+ org.eclipse.winery.common
+ ${project.version}
+
+
+ org.eclipse.winery
+ org.eclipse.winery.model.tosca.canonical
+ ${project.version}
+
+
+ org.eclipse.winery
+ org.eclipse.winery.repository
+ ${project.version}
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.jupiter.version}
+ test
+
+
+ io.github.adr
+ e-adr
+ ${io.github.adr.e-adr.version}
+
+
+ org.eclipse.jdt
+ org.eclipse.jdt.annotation
+ ${org.eclipse.jdt.annotation}
+
+
+
+
+
diff --git a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/EdmmManager.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/EdmmManager.java
similarity index 67%
rename from org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/EdmmManager.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/EdmmManager.java
index d986011f17..3a8b929ad1 100644
--- a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/EdmmManager.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/EdmmManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ * Copyright (c) 2019-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.repository.backend;
+package org.eclipse.winery.edmm;
import java.util.HashMap;
import java.util.List;
@@ -20,11 +20,20 @@
import javax.xml.namespace.QName;
-import org.eclipse.winery.common.edmm.EdmmMappingItem;
-import org.eclipse.winery.common.edmm.EdmmType;
+import org.eclipse.winery.edmm.model.EdmmMappingItem;
+import org.eclipse.winery.edmm.model.EdmmType;
+import org.eclipse.winery.model.ids.admin.EdmmMappingsId;
+import org.eclipse.winery.repository.backend.BackendUtils;
+import org.eclipse.winery.repository.backend.IRepository;
+import org.eclipse.winery.repository.common.RepositoryFileReference;
public interface EdmmManager {
+ static EdmmManager forRepository(IRepository repo) {
+ RepositoryFileReference ref = BackendUtils.getRefOfJsonConfiguration(new EdmmMappingsId());
+ return new JsonBasedEdmmManager(repo.ref2AbsolutePath(ref).toFile());
+ }
+
List getOneToOneMappings();
void setOneToOneMappings(List list);
diff --git a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/export/EdmmUtils.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/EdmmUtils.java
similarity index 84%
rename from org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/export/EdmmUtils.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/EdmmUtils.java
index c215314bb8..0c51cea9eb 100644
--- a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/export/EdmmUtils.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/EdmmUtils.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.repository.export;
+package org.eclipse.winery.edmm;
import java.util.HashMap;
import java.util.List;
@@ -21,11 +21,11 @@
import javax.xml.namespace.QName;
-import org.eclipse.winery.common.edmm.EdmmType;
-import org.eclipse.winery.common.ids.definitions.NodeTypeId;
-import org.eclipse.winery.common.ids.definitions.RelationshipTypeId;
-import org.eclipse.winery.common.ids.definitions.ServiceTemplateId;
-import org.eclipse.winery.common.toscalight.ToscaLightChecker;
+import org.eclipse.winery.edmm.model.EdmmType;
+import org.eclipse.winery.edmm.toscalight.ToscaLightChecker;
+import org.eclipse.winery.model.ids.definitions.NodeTypeId;
+import org.eclipse.winery.model.ids.definitions.RelationshipTypeId;
+import org.eclipse.winery.model.ids.definitions.ServiceTemplateId;
import org.eclipse.winery.model.tosca.TNodeType;
import org.eclipse.winery.model.tosca.TRelationshipType;
import org.eclipse.winery.model.tosca.TServiceTemplate;
@@ -53,8 +53,8 @@ public static ToscaLightChecker getToscaLightChecker() {
Map relationshipTypes = repository.getQNameToElementMapping(RelationshipTypeId.class);
Map nodeTypes = repository.getQNameToElementMapping(NodeTypeId.class);
- Map typeMap = repository.getEdmmManager().getTypeMap();
- Map oneToOneMap = repository.getEdmmManager().getOneToOneMap();
+ Map typeMap = EdmmManager.forRepository(repository).getTypeMap();
+ Map oneToOneMap = EdmmManager.forRepository(repository).getOneToOneMap();
return new ToscaLightChecker(nodeTypes, relationshipTypes, typeMap, oneToOneMap);
}
diff --git a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/filebased/JsonBasedEdmmManager.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/JsonBasedEdmmManager.java
similarity index 93%
rename from org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/filebased/JsonBasedEdmmManager.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/JsonBasedEdmmManager.java
index fed2022575..6e99f91361 100644
--- a/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/backend/filebased/JsonBasedEdmmManager.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/JsonBasedEdmmManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ * Copyright (c) 2019-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.repository.backend.filebased;
+package org.eclipse.winery.edmm;
import java.io.File;
import java.io.IOException;
@@ -20,9 +20,8 @@
import java.util.List;
import java.util.Objects;
-import org.eclipse.winery.common.edmm.EdmmMappingItem;
import org.eclipse.winery.common.json.JacksonProvider;
-import org.eclipse.winery.repository.backend.EdmmManager;
+import org.eclipse.winery.edmm.model.EdmmMappingItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmConverter.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmConverter.java
similarity index 98%
rename from org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmConverter.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmConverter.java
index 72c766b013..30baa4289c 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmConverter.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmConverter.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.edmm;
+package org.eclipse.winery.edmm.model;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@@ -39,6 +39,7 @@
import org.eclipse.winery.model.tosca.TRelationshipType;
import org.eclipse.winery.model.tosca.TRelationshipTypeImplementation;
import org.eclipse.winery.model.tosca.TServiceTemplate;
+import org.eclipse.winery.model.tosca.utils.ModelUtilities;
import io.github.edmm.core.parser.Entity;
import io.github.edmm.core.parser.EntityGraph;
@@ -115,7 +116,7 @@ private void createRelation(TRelationshipTemplate relationship, EntityGraph enti
EntityId relationEntityId = relationsCollectionEntityId.extend(relationTypeEntityId.getName());
- if (Objects.nonNull(relationship.getProperties()) && Objects.nonNull(relationship.getProperties().getKVProperties())) {
+ if (Objects.nonNull(relationship.getProperties()) && Objects.nonNull(ModelUtilities.getPropertiesKV(relationship))) {
entityGraph.addEntity(new MappingEntity(relationEntityId, entityGraph));
createProperties(relationship, relationEntityId, entityGraph);
} else {
@@ -191,11 +192,11 @@ private void createPathReferenceEntity(EntityGraph entityGraph, String givenPath
}
private void createProperties(TEntityTemplate toscaTemplate, EntityId componentNodeId, EntityGraph entityGraph) {
- if (Objects.nonNull(toscaTemplate.getProperties()) && Objects.nonNull(toscaTemplate.getProperties().getKVProperties())) {
+ if (Objects.nonNull(toscaTemplate.getProperties()) && Objects.nonNull(ModelUtilities.getPropertiesKV(toscaTemplate))) {
EntityId propertiesEntityId = componentNodeId.extend(DefaultKeys.PROPERTIES);
entityGraph.addEntity(new MappingEntity(propertiesEntityId, entityGraph));
- toscaTemplate.getProperties().getKVProperties()
+ ModelUtilities.getPropertiesKV(toscaTemplate)
.forEach((key, value) -> {
EntityId propertyEntityId = propertiesEntityId.extend(key);
entityGraph.addEntity(new ScalarEntity(value, propertyEntityId, entityGraph));
@@ -269,7 +270,7 @@ private void createPropertiesDefinition(TEntityType toscaType, EntityId typeEnti
EntityId propertiesEntityId = typeEntityId.extend(DefaultKeys.PROPERTIES);
entityGraph.addEntity(new MappingEntity(propertiesEntityId, entityGraph));
- toscaType.getWinerysPropertiesDefinition().getPropertyDefinitionKVList().getPropertyDefinitionKVs()
+ toscaType.getWinerysPropertiesDefinition().getPropertyDefinitions()
.forEach(propertyDef -> {
EntityId propertyEntityId = propertiesEntityId.extend(propertyDef.getKey());
entityGraph.addEntity(new MappingEntity(propertyEntityId, entityGraph));
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmMappingItem.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmMappingItem.java
similarity index 96%
rename from org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmMappingItem.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmMappingItem.java
index 317d1b9465..55ac1c8992 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmMappingItem.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmMappingItem.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.edmm;
+package org.eclipse.winery.edmm.model;
import javax.xml.namespace.QName;
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmType.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmType.java
similarity index 97%
rename from org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmType.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmType.java
index 16fdd4f561..4ae2da5360 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmType.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmType.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.edmm;
+package org.eclipse.winery.edmm.model;
import java.io.Serializable;
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmTypeProperties.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmTypeProperties.java
similarity index 99%
rename from org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmTypeProperties.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmTypeProperties.java
index 769092165c..7ad9023243 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/edmm/EdmmTypeProperties.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/model/EdmmTypeProperties.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.edmm;
+package org.eclipse.winery.edmm.model;
import io.github.edmm.core.parser.EntityGraph;
import io.github.edmm.core.parser.EntityId;
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/toscalight/ToscaLightChecker.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/toscalight/ToscaLightChecker.java
similarity index 93%
rename from org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/toscalight/ToscaLightChecker.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/toscalight/ToscaLightChecker.java
index cae11c0538..a16d8f8571 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/toscalight/ToscaLightChecker.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/toscalight/ToscaLightChecker.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.toscalight;
+package org.eclipse.winery.edmm.toscalight;
import java.util.ArrayList;
import java.util.HashMap;
@@ -21,7 +21,7 @@
import javax.xml.namespace.QName;
-import org.eclipse.winery.common.edmm.EdmmType;
+import org.eclipse.winery.edmm.model.EdmmType;
import org.eclipse.winery.model.tosca.HasPolicies;
import org.eclipse.winery.model.tosca.TEntityTemplate;
import org.eclipse.winery.model.tosca.TInterface;
@@ -32,6 +32,8 @@
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
import org.eclipse.winery.model.tosca.utils.ModelUtilities;
+import org.eclipse.winery.repository.backend.RepositoryFactory;
+import org.eclipse.winery.repository.filebased.RepositoryUtils;
public class ToscaLightChecker {
@@ -42,7 +44,7 @@ public class ToscaLightChecker {
private QName hostedOn;
private QName connectsTo;
private QName dependsOn;
- private Map> errorList;
+ private Map> errorList = new HashMap<>();
private boolean foundError;
public ToscaLightChecker(Map nodeTypes,
@@ -73,8 +75,12 @@ public Map> getErrorList() {
}
public boolean isToscaLightCompliant(TServiceTemplate serviceTemplate) {
- this.checkToscaLightCompatibility(serviceTemplate);
- return !this.foundError;
+ // Only in non-YAML mode for now
+ if (!RepositoryUtils.isYamlRepository(RepositoryFactory.getRepository())) {
+ this.checkToscaLightCompatibility(serviceTemplate);
+ return !this.foundError;
+ }
+ return false;
}
public Map> checkToscaLightCompatibility(TServiceTemplate serviceTemplate) {
diff --git a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/toscalight/ToscaLightUtils.java b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/toscalight/ToscaLightUtils.java
similarity index 96%
rename from org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/toscalight/ToscaLightUtils.java
rename to org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/toscalight/ToscaLightUtils.java
index 3c16180eb7..543612a7d8 100644
--- a/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/toscalight/ToscaLightUtils.java
+++ b/org.eclipse.winery.edmm/src/main/java/org/eclipse/winery/edmm/toscalight/ToscaLightUtils.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.toscalight;
+package org.eclipse.winery.edmm.toscalight;
import org.eclipse.winery.model.tosca.TInterface;
diff --git a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/edmm/EdmmDependantTest.java b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/EdmmDependantTest.java
similarity index 93%
rename from org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/edmm/EdmmDependantTest.java
rename to org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/EdmmDependantTest.java
index 5332e63d9e..aa40f06545 100644
--- a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/edmm/EdmmDependantTest.java
+++ b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/EdmmDependantTest.java
@@ -12,14 +12,19 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.edmm;
+package org.eclipse.winery.edmm;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
import javax.xml.namespace.QName;
+import org.eclipse.winery.edmm.model.EdmmType;
import org.eclipse.winery.model.tosca.TArtifactReference;
import org.eclipse.winery.model.tosca.TArtifactTemplate;
import org.eclipse.winery.model.tosca.TDeploymentArtifact;
@@ -36,9 +41,8 @@
import org.eclipse.winery.model.tosca.TRelationshipTemplate;
import org.eclipse.winery.model.tosca.TRelationshipType;
import org.eclipse.winery.model.tosca.TRelationshipTypeImplementation;
-import org.eclipse.winery.model.tosca.kvproperties.PropertyDefinitionKV;
-import org.eclipse.winery.model.tosca.kvproperties.PropertyDefinitionKVList;
-import org.eclipse.winery.model.tosca.kvproperties.WinerysPropertiesDefinition;
+import org.eclipse.winery.model.tosca.extensions.kvproperties.PropertyDefinitionKV;
+import org.eclipse.winery.model.tosca.extensions.kvproperties.WinerysPropertiesDefinition;
import org.eclipse.winery.model.tosca.utils.ModelUtilities;
import org.junit.jupiter.api.BeforeEach;
@@ -82,12 +86,14 @@ void setup() {
TNodeType nodeType3 = new TNodeType();
nodeType3.setName(nodeType3QName.getLocalPart());
nodeType3.setTargetNamespace(nodeType3QName.getNamespaceURI());
- PropertyDefinitionKVList kvList = new PropertyDefinitionKVList();
- kvList.add(new PropertyDefinitionKV("os_family", "xsd:string"));
- kvList.add(new PropertyDefinitionKV("public_key", "xsd:string"));
- kvList.add(new PropertyDefinitionKV("ssh_port", "number"));
+ List kvList = new ArrayList<>();
+ kvList.addAll(Arrays.asList(
+ new PropertyDefinitionKV("os_family", "xsd:string"),
+ new PropertyDefinitionKV("public_key", "xsd:string"),
+ new PropertyDefinitionKV("ssh_port", "number")
+ ));
WinerysPropertiesDefinition wpd = new WinerysPropertiesDefinition();
- wpd.setPropertyDefinitionKVList(kvList);
+ wpd.setPropertyDefinitions(kvList);
ModelUtilities.replaceWinerysPropertiesDefinition(nodeType3, wpd);
nodeTypes.put(nodeType3QName, nodeType3);
@@ -200,8 +206,8 @@ void setup() {
nt3.setType(nodeType3QName);
nt3.setId("test_node_3");
nt3.setName("test_node_3");
- TEntityTemplate.Properties properties = new TEntityTemplate.Properties();
- HashMap nt3Properties = new HashMap<>();
+ TEntityTemplate.WineryKVProperties properties = new TEntityTemplate.WineryKVProperties();
+ LinkedHashMap nt3Properties = new LinkedHashMap<>();
nt3Properties.put("os_family", "ubuntu");
nt3Properties.put("public_key", "-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----");
nt3Properties.put("ssh_port", "22");
diff --git a/org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/export/EdmmUtilsTest.java b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/EdmmUtilsTest.java
similarity index 96%
rename from org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/export/EdmmUtilsTest.java
rename to org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/EdmmUtilsTest.java
index 041511c183..63e0bda7de 100644
--- a/org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/export/EdmmUtilsTest.java
+++ b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/EdmmUtilsTest.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.repository.export;
+package org.eclipse.winery.edmm;
import java.util.Map;
diff --git a/org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/backend/filebased/JsonBasedEdmmManagerTest.java b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/JsonBasedEdmmManagerTest.java
similarity index 87%
rename from org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/backend/filebased/JsonBasedEdmmManagerTest.java
rename to org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/JsonBasedEdmmManagerTest.java
index b6951bd953..271aca8b1c 100644
--- a/org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/backend/filebased/JsonBasedEdmmManagerTest.java
+++ b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/JsonBasedEdmmManagerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ * Copyright (c) 2019-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
@@ -12,14 +12,14 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.repository.backend.filebased;
+package org.eclipse.winery.edmm;
import java.io.File;
import javax.xml.namespace.QName;
-import org.eclipse.winery.common.edmm.EdmmMappingItem;
-import org.eclipse.winery.common.edmm.EdmmType;
+import org.eclipse.winery.edmm.model.EdmmMappingItem;
+import org.eclipse.winery.edmm.model.EdmmType;
import org.junit.jupiter.api.Test;
diff --git a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/edmm/EdmmConverterTest.java b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/model/EdmmConverterTest.java
similarity index 86%
rename from org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/edmm/EdmmConverterTest.java
rename to org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/model/EdmmConverterTest.java
index dff8fc5095..01003e8d24 100644
--- a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/edmm/EdmmConverterTest.java
+++ b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/model/EdmmConverterTest.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.edmm;
+package org.eclipse.winery.edmm.model;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
@@ -20,6 +20,7 @@
import java.util.Optional;
import java.util.stream.Stream;
+import org.eclipse.winery.edmm.EdmmDependantTest;
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
@@ -41,12 +42,12 @@ protected EdmmConverterTest() throws UnsupportedEncodingException {
@Test
void transformOneNodeTemplate() {
// region *** build the TopologyTemplate ***
- TTopologyTemplate topology = new TTopologyTemplate();
- topology.addNodeTemplate(nodeTemplates.get("test_node_1"));
+ TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
+ topology.addNodeTemplates(nodeTemplates.get("test_node_1"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate();
- serviceTemplate.setTopologyTemplate(topology);
+ serviceTemplate.setTopologyTemplate(topology.build());
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations,
relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
@@ -59,12 +60,12 @@ void transformOneNodeTemplate() {
@Test
void transformDerivedFrom() {
// region *** build the TopologyTemplate ***
- TTopologyTemplate topology = new TTopologyTemplate();
- topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
+ TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
+ topology.addNodeTemplates(nodeTemplates.get("test_node_2"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate();
- serviceTemplate.setTopologyTemplate(topology);
+ serviceTemplate.setTopologyTemplate(topology.build());
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations,
relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
@@ -81,12 +82,12 @@ void transformDerivedFrom() {
@Test
void transformProperties() {
// region *** build the TopologyTemplate ***
- TTopologyTemplate topology = new TTopologyTemplate();
- topology.addNodeTemplate(nodeTemplates.get("test_node_3"));
+ TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
+ topology.addNodeTemplates(nodeTemplates.get("test_node_3"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate();
- serviceTemplate.setTopologyTemplate(topology);
+ serviceTemplate.setTopologyTemplate(topology.build());
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations,
relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
@@ -121,17 +122,17 @@ void transformProperties() {
@Test
void transformTopologyWithRelationsAndRelationTypes() {
// region *** build the TopologyTemplate ***
- TTopologyTemplate topology = new TTopologyTemplate();
- topology.addNodeTemplate(nodeTemplates.get("test_node_1"));
- topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
- topology.addNodeTemplate(nodeTemplates.get("test_node_3"));
+ TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
+ topology.addNodeTemplates(nodeTemplates.get("test_node_1"));
+ topology.addNodeTemplates(nodeTemplates.get("test_node_2"));
+ topology.addNodeTemplates(nodeTemplates.get("test_node_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("2_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_connects_to_2"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate();
- serviceTemplate.setTopologyTemplate(topology);
+ serviceTemplate.setTopologyTemplate(topology.build());
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations,
relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
@@ -158,12 +159,12 @@ void transformTopologyWithRelationsAndRelationTypes() {
@Test
void transformTopologyWithOperations() {
// region *** build the TopologyTemplate ***
- TTopologyTemplate topology = new TTopologyTemplate();
- topology.addNodeTemplate(nodeTemplates.get("test_node_4"));
+ TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
+ topology.addNodeTemplates(nodeTemplates.get("test_node_4"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate();
- serviceTemplate.setTopologyTemplate(topology);
+ serviceTemplate.setTopologyTemplate(topology.build());
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations,
relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping, false);
@@ -187,17 +188,17 @@ void transformTopologyWithOperations() {
@Test
void transformTopology() {
// region *** build the TopologyTemplate ***
- TTopologyTemplate topology = new TTopologyTemplate();
- topology.addNodeTemplate(nodeTemplates.get("test_node_1"));
- topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
- topology.addNodeTemplate(nodeTemplates.get("test_node_3"));
- topology.addNodeTemplate(nodeTemplates.get("test_node_4"));
+ TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
+ topology.addNodeTemplates(nodeTemplates.get("test_node_1"));
+ topology.addNodeTemplates(nodeTemplates.get("test_node_2"));
+ topology.addNodeTemplates(nodeTemplates.get("test_node_3"));
+ topology.addNodeTemplates(nodeTemplates.get("test_node_4"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("2_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("4_hosted_on_1"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_connects_to_2"));
TServiceTemplate serviceTemplate = new TServiceTemplate();
- serviceTemplate.setTopologyTemplate(topology);
+ serviceTemplate.setTopologyTemplate(topology.build());
// endregion
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations,
diff --git a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/toscalight/ToscaLightCheckerTest.java b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/toscalight/ToscaLightCheckerTest.java
similarity index 83%
rename from org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/toscalight/ToscaLightCheckerTest.java
rename to org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/toscalight/ToscaLightCheckerTest.java
index 9896ddd705..c53063e75b 100644
--- a/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/toscalight/ToscaLightCheckerTest.java
+++ b/org.eclipse.winery.edmm/src/test/java/org/eclipse/winery/edmm/toscalight/ToscaLightCheckerTest.java
@@ -12,7 +12,7 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
-package org.eclipse.winery.common.toscalight;
+package org.eclipse.winery.edmm.toscalight;
import java.io.UnsupportedEncodingException;
import java.util.List;
@@ -20,7 +20,7 @@
import javax.xml.namespace.QName;
-import org.eclipse.winery.common.edmm.EdmmDependantTest;
+import org.eclipse.winery.edmm.EdmmDependantTest;
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
@@ -37,17 +37,17 @@ protected ToscaLightCheckerTest() throws UnsupportedEncodingException {
@Test
void checkValidServiceTemplate() throws Exception {
// region *** build the TopologyTemplate ***
- TTopologyTemplate topology = new TTopologyTemplate();
- topology.addNodeTemplate(nodeTemplates.get("test_node_1"));
- topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
- topology.addNodeTemplate(nodeTemplates.get("test_node_3"));
- topology.addNodeTemplate(nodeTemplates.get("test_node_4"));
+ TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
+ topology.addNodeTemplates(nodeTemplates.get("test_node_1"));
+ topology.addNodeTemplates(nodeTemplates.get("test_node_2"));
+ topology.addNodeTemplates(nodeTemplates.get("test_node_3"));
+ topology.addNodeTemplates(nodeTemplates.get("test_node_4"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("2_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("4_hosted_on_1"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_connects_to_2"));
TServiceTemplate serviceTemplate = new TServiceTemplate();
- serviceTemplate.setTopologyTemplate(topology);
+ serviceTemplate.setTopologyTemplate(topology.build());
serviceTemplate.setName("MyTestServiceTemplate");
serviceTemplate.setId(serviceTemplate.getName());
serviceTemplate.setTargetNamespace(this.NAMESPACE);
diff --git a/org.eclipse.winery.frontends/app/topologymodeler/src/app/models/qname.ts b/org.eclipse.winery.frontends/app/shared/src/app/model/qName.ts
similarity index 70%
rename from org.eclipse.winery.frontends/app/topologymodeler/src/app/models/qname.ts
rename to org.eclipse.winery.frontends/app/shared/src/app/model/qName.ts
index fc8e00a732..24a5ca4fc7 100644
--- a/org.eclipse.winery.frontends/app/topologymodeler/src/app/models/qname.ts
+++ b/org.eclipse.winery.frontends/app/shared/src/app/model/qName.ts
@@ -1,5 +1,5 @@
-/********************************************************************************
- * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation
+/*******************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
@@ -10,16 +10,34 @@
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
- ********************************************************************************/
+ *******************************************************************************/
-/**
- * Retrieves the local name and the namespace from the qname
- */
export class QName {
+
+ public static stringToQName(name: string): QName {
+ return new QName(name);
+ }
+
+ public static create(nameSpace: string, localName: string): QName {
+ return new QName(`{${nameSpace}}${localName}`);
+ }
+
private _localName: string;
private _nameSpace: string;
constructor(private _qName?: string) {
+ this.parseQName();
+ }
+
+ private parseQName() {
+ const regex = /\{(.*?)\}(.*)/g;
+ const res = regex.exec(this._qName);
+
+ if (!res || res.length !== 3) {
+ throw new Error();
+ }
+ this._nameSpace = res[1];
+ this._localName = res[2];
}
/**
@@ -35,6 +53,7 @@ export class QName {
*/
set localName(value: string) {
this._localName = value;
+ this._qName = `{${this._nameSpace}}${this._localName}`;
}
/**
@@ -51,6 +70,7 @@ export class QName {
*/
set nameSpace(value: string) {
this._nameSpace = value;
+ this._qName = `{${this._nameSpace}}${this._localName}`;
}
/**
@@ -68,6 +88,7 @@ export class QName {
*/
set qName(value: string) {
this._qName = value;
+ this.parseQName();
}
/**
@@ -77,5 +98,6 @@ export class QName {
*/
setQNameWithLocalNameAndNamespace(localname: string, namespace: string) {
this._qName = '{' + namespace + '}' + localname;
+ this.parseQName();
}
}
diff --git a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.css b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.css
index 3cf86f01e9..cb465f1f09 100644
--- a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.css
+++ b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.css
@@ -49,7 +49,6 @@
#grid {
position: absolute;
- z-index: 4;
}
.labelStyle path {
diff --git a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.html b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.html
index ac1ae99d88..0290289085 100644
--- a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.html
+++ b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.html
@@ -386,16 +386,15 @@
Existing Policies:
Properties of {{selectedYamlPolicy.name}}:
diff --git a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.ts b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.ts
index 86896c5370..05844b0f6e 100644
--- a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.ts
+++ b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/canvas.component.ts
@@ -34,13 +34,11 @@ import { ToggleModalDataModel } from '../models/toggleModalDataModel';
import { ToastrService } from 'ngx-toastr';
import { BackendService } from '../services/backend.service';
import { CapabilityModel } from '../models/capabilityModel';
-import { isNullOrUndefined } from 'util';
import { RequirementModel } from '../models/requirementModel';
import { EntityTypesModel } from '../models/entityTypesModel';
import { ExistsService } from '../services/exists.service';
import { ModalVariant, ModalVariantAndState } from './entities-modal/modal-model';
import { align, toggleModalType } from '../models/enums';
-import { QName } from '../models/qname';
import { ImportTopologyModalData } from '../models/importTopologyModalData';
import { ImportTopologyService } from '../services/import-topology.service';
import { SplitMatchTopologyService } from '../services/split-match-topology.service';
@@ -60,6 +58,7 @@ import { CapabilityDefinitionModel } from '../models/capabilityDefinitionModel';
import { WineryRowData } from '../../../../tosca-management/src/app/wineryTableModule/wineryTable.component';
import { InheritanceUtils } from '../models/InheritanceUtils';
import { PolicyService } from '../services/policy.service';
+import { QName } from '../../../../shared/src/app/model/qName';
@Component({
selector: 'winery-canvas',
@@ -99,8 +98,6 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
dragSourceActive = false;
event: any;
selectedRelationshipType: EntityType;
- nodeChildrenIdArray: Array;
- nodeChildrenArray: Array;
jsPlumbBindConnection = false;
newNode: TNodeTemplate;
paletteOpened: boolean;
@@ -197,16 +194,13 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
this.subscriptions.push(this.ngRedux.select(state => state.wineryState.currentJsonTopology.policies)
.subscribe(policies => this.handleUpdatedYamlPolicies(policies)));
this.subscriptions.push(this.ngRedux.select(state => state.wineryState.currentJsonTopology.nodeTemplates)
- .subscribe(currentNodes => this.updateNodes(currentNodes)));
+ .subscribe(storeNodes => this.updateNodes(storeNodes)));
this.subscriptions.push(this.ngRedux.select(state => state.wineryState.currentJsonTopology.relationshipTemplates)
.subscribe(currentRelationships => this.updateRelationships(currentRelationships)));
this.subscriptions.push(this.ngRedux.select(state => state.topologyRendererState)
.subscribe(currentButtonsState => this.setRendererState(currentButtonsState)));
- this.subscriptions.push(this.ngRedux.select(state => state.wineryState.currentNodeData)
- .subscribe(currentNodeData => this.toggleMarkNode(currentNodeData)));
+
this.gridTemplate = new GridTemplate(100, false, false, 30);
- this.subscriptions.push(this.ngRedux.select(state => state.wineryState.currentPaletteOpenedState)
- .subscribe(currentPaletteOpened => this.setPaletteState(currentPaletteOpened)));
this.hotkeysService.add(new Hotkey('mod+a', (event: KeyboardEvent): boolean => {
event.stopPropagation();
this.allNodeTemplates.forEach(node => this.enhanceDragSelection(node.id));
@@ -256,25 +250,25 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
/**
* Gets called if nodes get deleted, created, or node attributes are updated and calls the
* correct handler.
- * @param currentNodes List of all displayed nodes.
+ * @param storeNodes List of all displayed nodes.
*/
- updateNodes(currentNodes: Array): void {
- const storeNodesLength = currentNodes.length;
+ updateNodes(storeNodes: Array): void {
+ const storeNodesLength = storeNodes.length;
const localCopyNodesLength = this.allNodeTemplates.length;
if (storeNodesLength !== localCopyNodesLength) {
- const difference = currentNodes.length - this.allNodeTemplates.length;
+ const difference = storeNodes.length - this.allNodeTemplates.length;
if (difference === 1 && this.paletteOpened) {
- this.handleNewNode(currentNodes);
+ this.handleNewNode(storeNodes);
} else if (difference < 0) {
- this.handleDeletedNodes(currentNodes);
+ this.handleDeletedNodes(storeNodes);
} else if (difference === 1 && !this.paletteOpened) {
- this.allNodeTemplates.push(currentNodes[currentNodes.length - 1]);
+ this.allNodeTemplates.push(storeNodes[storeNodes.length - 1]);
this.revalidateContainer();
} else {
- this.allNodeTemplates = currentNodes;
+ this.allNodeTemplates = storeNodes;
}
} else if (storeNodesLength !== 0 && localCopyNodesLength !== 0) {
- this.updateNodeAttributes(currentNodes);
+ this.updateNodeAttributes(storeNodes);
}
this.allNodesIds = this.allNodeTemplates.map(node => node.id);
}
@@ -286,17 +280,11 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* of the node
*/
toggleMarkNode(currentNodeData: NodeIdAndFocusModel) {
- if (this.nodeChildrenArray) {
- this.nodeChildrenArray.forEach(node => {
- if (node.nodeTemplate.id === currentNodeData.id) {
- if (currentNodeData.focus === true) {
- node.makeSelectionVisible = true;
- } else {
- node.makeSelectionVisible = false;
- }
- }
- });
- }
+ this.nodeComponentChildren.forEach(component => {
+ if (component.nodeTemplate.id === currentNodeData.id) {
+ component.makeSelectionVisible = currentNodeData.focus;
+ }
+ });
}
/**
@@ -342,7 +330,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
this.requirements.requirements = currentNodeData.requirements;
this.requirements.nodeId = currentNodeData.id;
// if a requirement in the table is clicked show the data in the modal
- if (!isNullOrUndefined(currentNodeData.currentRequirement)) {
+ if (currentNodeData.currentRequirement) {
this.showCurrentRequirement = true;
this.requirements.reqId = currentNodeData.currentRequirement.id;
this.requirements.oldReqId = currentNodeData.currentRequirement.id;
@@ -424,7 +412,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
this.capabilities.capabilities = currentNodeData.capabilities;
this.capabilities.nodeId = currentNodeData.id;
// if a capability in the table is clicked show the data in the modal
- if (!isNullOrUndefined(currentNodeData.currentCapability)) {
+ if (currentNodeData.currentCapability) {
this.showCurrentCapability = true;
this.capabilities.capId = currentNodeData.currentCapability.id;
this.capabilities.oldCapId = currentNodeData.currentCapability.id;
@@ -506,11 +494,10 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* This function sets the capability default KV properties
*/
setDefaultCapKVProperties(): void {
- this.capabilities.capabilities.capability.some(cap => {
+ this.capabilities.capabilities.capability.forEach(cap => {
if (cap.id === this.currentModalData.currentCapability.id) {
cap.properties = {
- kvproperties:
- this.capabilities.properties
+ kvproperties: this.capabilities.properties
};
}
});
@@ -520,11 +507,10 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* This function sets the requirement default KV properties
*/
setDefaultReqKVProperties(): void {
- this.requirements.requirements.requirement.some(req => {
+ this.requirements.requirements.requirement.forEach(req => {
if (req.id === this.currentModalData.currentRequirement.id) {
req.properties = {
- kvproperties:
- this.requirements.properties
+ kvproperties: this.requirements.properties
};
}
});
@@ -534,7 +520,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* This function sets the capability default XML properties
*/
setDefaultCapXMLProperties(): void {
- this.capabilities.capabilities.capability.some(cap => {
+ this.capabilities.capabilities.capability.forEach(cap => {
if (cap.id === this.currentModalData.currentCapability.id) {
cap.properties = {
any: this.capabilities.properties
@@ -547,7 +533,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* This function sets the requirement default XML properties
*/
setDefaultReqXMLProperties(): void {
- this.requirements.requirements.requirement.some(req => {
+ this.requirements.requirements.requirement.forEach(req => {
if (req.id === this.currentModalData.currentCapability.id) {
req.properties = {
any: this.requirements.properties
@@ -922,7 +908,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
if (difference === 1) {
this.handleNewRelationship(currentRelationships);
} else if (difference > 0 || difference < 0) {
- if (this.configuration.isYaml() && difference < 0) {
+ if (this.configuration.isYaml() && difference < 0 && this.allNodeTemplates.length > 0) {
// a relationship is deleted. reset the associated source requirement
const deletedRels = this.allRelationshipTemplates.filter(rel => currentRelationships.every(curRel => curRel.id !== rel.id));
deletedRels.forEach(deletedRel => {
@@ -1006,7 +992,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
let leaveNodesAsSelectedAfterLayouting;
if (this.topologyRendererState.buttonsState.layoutButton) {
- this.layoutDirective.layoutNodes(this.nodeChildrenArray, this.allRelationshipTemplates)
+ this.layoutDirective.layoutNodes(this.nodeComponentChildren.toArray(), this.allRelationshipTemplates)
.then(done => {
leaveNodesAsSelectedAfterLayouting = false;
// This call might seem confusing as we are calling it again right after executing,
@@ -1020,7 +1006,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
const nodesToBeAligned = selectionActive ? this.selectedNodes : this.allNodeTemplates;
leaveNodesAsSelectedAfterLayouting = selectionActive;
const alignmentMode = this.topologyRendererState.buttonsState.alignHButton ? align.Horizontal : align.Vertical;
- this.layoutDirective.align(this.nodeChildrenArray, nodesToBeAligned, alignmentMode)
+ this.layoutDirective.align(this.nodeComponentChildren.toArray(), nodesToBeAligned, alignmentMode)
.then(() => {
leaveNodesAsSelectedAfterLayouting = false;
// This call might seem confusing as we are calling it again right after executing,
@@ -1194,13 +1180,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* @param nodeTemplate Node Element (DOM).
*/
setNewCoordinates(nodeTemplate: any): void {
- let nodeIndex;
- this.allNodeTemplates.some((node, index) => {
- if (node.id === nodeTemplate.firstChild.id) {
- nodeIndex = index;
- return true;
- }
- });
+ const nodeIndex = this.allNodeTemplates.findIndex(node => node.id === nodeTemplate.firstChild.id);
const nodeCoordinates = {
id: nodeTemplate.firstChild.id,
x: nodeTemplate.firstChild.offsetLeft,
@@ -1231,7 +1211,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
paintRelationship(newRelationship: TRelationshipTemplate) {
const allJsPlumbRelationships = this.newJsPlumbInstance.getAllConnections();
if (!allJsPlumbRelationships.some(rel => rel.id === newRelationship.id)) {
- let labelString = (isNullOrUndefined(newRelationship.state) ? '' : newRelationship.state + ' ')
+ let labelString = (!newRelationship.state ? '' : newRelationship.state + ' ')
// why not use name -> save the type's id into the name (without management version)
+ newRelationship.name;
@@ -1282,7 +1262,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
}
}
- const border = isNullOrUndefined(newRelationship.state)
+ const border = !newRelationship.state
? '#fafafa' : VersionUtils.getElementColorByDiffState(newRelationship.state);
const me = this;
const conn = this.newJsPlumbInstance.connect({
@@ -1349,9 +1329,9 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
this.newJsPlumbInstance.unmakeSource(this.dragSourceInfos.nodeId);
}
}
- const indexOfNode = this.nodeChildrenIdArray.indexOf(this.dragSourceInfos.nodeId);
- if (this.nodeChildrenArray[indexOfNode]) {
- this.nodeChildrenArray[indexOfNode].connectorEndpointVisible = false;
+ const nodeComponent = this.nodeComponentChildren.find(c => c.nodeTemplate.id === this.dragSourceInfos.nodeId);
+ if (nodeComponent) {
+ nodeComponent.connectorEndpointVisible = false;
this.revalidateContainer();
}
this.dragSourceActive = false;
@@ -1367,19 +1347,13 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* @param nodeId
*/
toggleClosedEndpoint(nodeId: string): void {
- const node = this.nodeChildrenArray.find((nodeTemplate => nodeTemplate.nodeTemplate.id === nodeId));
+ const node = this.nodeComponentChildren.find((c => c.nodeTemplate.id === nodeId));
node.connectorEndpointVisible = !node.connectorEndpointVisible;
- if (node.connectorEndpointVisible === true) {
+ if (node.connectorEndpointVisible) {
this.dragSourceActive = false;
this.resetDragSource(nodeId);
- this.nodeChildrenArray.some(currentNode => {
- if (currentNode.nodeTemplate.id !== nodeId) {
- if (currentNode.connectorEndpointVisible === true) {
- currentNode.connectorEndpointVisible = false;
- return true;
- }
- }
- });
+ this.nodeComponentChildren.filter(c => c.nodeTemplate.id !== nodeId)
+ .forEach(c => c.connectorEndpointVisible = false);
}
}
@@ -1416,7 +1390,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
// if name, min or max instances has changed, do not delete the node.
if (this.selectedNodes.length > 0) {
let selectedNodeSideBarVisible = false;
- this.nodeChildrenArray.forEach(node => {
+ this.nodeComponentChildren.forEach(node => {
if (node.makeSelectionVisible === true) {
if (!selectedNodeSideBarVisible) {
this.hideSidebar();
@@ -1458,7 +1432,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
*/
clearSelectedNodes(): void {
if (this.selectedNodes.length > 0) {
- this.nodeChildrenArray.forEach(node => {
+ this.nodeComponentChildren.forEach(node => {
if (this.selectedNodes.find(selectedNode => selectedNode && selectedNode.id === node.nodeTemplate.id)) {
node.makeSelectionVisible = false;
}
@@ -1477,7 +1451,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
this.ngRedux.dispatch(this.actions.sendPaletteOpened(false));
this.hideSidebar();
this.clearSelectedNodes();
- this.nodeChildrenArray.forEach(node => node.makeSelectionVisible = false);
+ this.nodeComponentChildren.forEach(node => node.makeSelectionVisible = false);
this.gridTemplate.pageX = $event.pageX;
this.gridTemplate.pageY = $event.pageY;
this.gridTemplate.initialW = $event.pageX;
@@ -1565,14 +1539,17 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
hideSidebar() {
this.ngRedux.dispatch(this.actions.openSidebar({
sidebarContents: {
- sidebarVisible: false,
+ visible: false,
nodeClicked: false,
- id: '',
- nameTextFieldValue: '',
- type: '',
- properties: '',
+ template: {
+ id: '',
+ name: '',
+ type: '',
+ properties: '',
+ },
+ relationshipTemplate: undefined,
source: '',
- target: ''
+ target: '',
}
}));
}
@@ -1758,7 +1735,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* Removes the dragSource of a node which marks the area where a connection can be dragged from
*/
removeDragSource(): void {
- this.nodeChildrenArray.some(node => {
+ this.nodeComponentChildren.some(node => {
if (node.dragSource) {
if (this.newJsPlumbInstance.isSource(node.dragSource)) {
this.newJsPlumbInstance.unmakeSource(node.dragSource);
@@ -1801,13 +1778,12 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* Lifecycle event
*/
ngAfterViewInit() {
- this.nodeChildrenArray = this.nodeComponentChildren.toArray();
- this.nodeChildrenIdArray = this.nodeChildrenArray.map(node => node.nodeTemplate.id);
- this.nodeComponentChildren.changes.subscribe(children => {
- this.nodeChildrenArray = children.toArray();
- this.nodeChildrenIdArray = this.nodeChildrenArray.map(node => node.nodeTemplate.id);
- });
- if (this.allRelationshipTemplates.length > 0 && this.nodeChildrenArray.length > 1) {
+ this.subscriptions.push(this.ngRedux.select(state => state.wineryState.currentNodeData)
+ .subscribe(currentNodeData => this.toggleMarkNode(currentNodeData)));
+ this.subscriptions.push(this.ngRedux.select(state => state.wineryState.currentPaletteOpenedState)
+ .subscribe(currentPaletteOpened => this.setPaletteState(currentPaletteOpened)));
+
+ if (this.allRelationshipTemplates.length > 0 && this.nodeComponentChildren.length > 1) {
this.allRelationshipTemplates.forEach(rel => {
setTimeout(() => this.manageRelationships(rel), 1);
});
@@ -1890,6 +1866,9 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
}
});
+ // define default properties of the node based on the type of the node
+ this.newNode.properties = InheritanceUtils.getDefaultPropertiesFromEntityTypes(this.newNode.type, this.entityTypes.unGroupedNodeTypes);
+
// if in YAML mode, automatically add all requirement and capability definitions to the node template!
if (this.configuration.isYaml()) {
this.newNode.requirements = { requirement: [] };
@@ -1935,49 +1914,29 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
}
/**
- * Gets called if node is updated, implements some checks.
- * @param currentNodes List of all displayed nodes.
+ * Gets called if node is updated
+ * @param storeNodes List of all displayed nodes.
*/
- private updateNodeAttributes(currentNodes: Array): void {
- this.allNodeTemplates.some(nodeTemplate => {
- const node = currentNodes.find(el => el.id === nodeTemplate.id);
- if (node) {
- if (nodeTemplate.name !== node.name) {
- const nodeId = this.nodeChildrenIdArray.indexOf(nodeTemplate.id);
- this.nodeChildrenArray[nodeId].nodeTemplate.name = node.name;
- this.nodeChildrenArray[nodeId].flash('name');
- nodeTemplate.name = node.name;
- return true;
- } else if (nodeTemplate.minInstances !== node.minInstances) {
- const nodeId = this.nodeChildrenIdArray.indexOf(nodeTemplate.id);
- nodeTemplate.minInstances = node.minInstances;
- this.nodeChildrenArray[nodeId].flash('min');
- return true;
- } else if (nodeTemplate.maxInstances !== node.maxInstances) {
- const nodeId = this.nodeChildrenIdArray.indexOf(nodeTemplate.id);
- nodeTemplate.maxInstances = node.maxInstances;
- this.nodeChildrenArray[nodeId].flash('max');
- return true;
- } else if (nodeTemplate.properties !== node.properties) {
- nodeTemplate.properties = node.properties;
- return true;
- } else if (nodeTemplate.capabilities !== node.capabilities) {
- nodeTemplate.capabilities = node.capabilities;
- return true;
- } else if (nodeTemplate.requirements !== node.requirements) {
- nodeTemplate.requirements = node.requirements;
- return true;
- } else if (nodeTemplate.deploymentArtifacts !== node.deploymentArtifacts) {
- nodeTemplate.deploymentArtifacts = node.deploymentArtifacts;
- return true;
- } else if (nodeTemplate.policies !== node.policies) {
- nodeTemplate.policies = node.policies;
- return true;
- } else if (nodeTemplate.otherAttributes !== node.otherAttributes) {
- nodeTemplate.otherAttributes = node.otherAttributes;
- return true;
+ private updateNodeAttributes(storeNodes: Array): void {
+ this.allNodeTemplates = this.allNodeTemplates.map(nodeTemplate => {
+ const storeData = storeNodes.find(el => el.id === nodeTemplate.id);
+ if (storeData) {
+ // update exposed keys
+ for (const key of ['name', 'minInstances', 'maxInstances', 'properties',
+ 'capabilities', 'requirements', 'deploymentArtifacts',
+ 'policies', 'otherAttributes']) {
+ nodeTemplate[key] = storeData[key];
+ }
+ const nodeComponent = this.nodeComponentChildren.find(c => c.nodeTemplate.id === nodeTemplate.id);
+ if (nodeTemplate.name !== storeData.name) {
+ nodeComponent.flash('name');
+ } else if (nodeTemplate.minInstances !== storeData.minInstances) {
+ nodeComponent.flash('min');
+ } else if (nodeTemplate.maxInstances !== storeData.maxInstances) {
+ nodeComponent.flash('max');
}
}
+ return nodeTemplate;
});
}
@@ -2011,20 +1970,22 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
this.clearSelectedNodes();
this.newJsPlumbInstance.select().removeType('marked');
const currentRel = this.allRelationshipTemplates.find(con => con.id === conn.id);
- let name = currentRel.name;
- if (currentRel.name.startsWith(this.backendService.configuration.relationshipPrefix)) {
- // Workaround to support old topology templates with the real name
- name = currentRel.type.substring(currentRel.type.indexOf('}') + 1);
- }
if (currentRel) {
+ let name = currentRel.name;
+ if (currentRel.name.startsWith(this.backendService.configuration.relationshipPrefix)) {
+ // Workaround to support old topology templates with the real name
+ name = currentRel.type.substring(currentRel.type.indexOf('}') + 1);
+ }
this.ngRedux.dispatch(this.actions.openSidebar({
sidebarContents: {
- sidebarVisible: true,
+ visible: true,
nodeClicked: false,
- id: currentRel.id,
- nameTextFieldValue: name,
- type: currentRel.type,
- properties: currentRel.properties,
+ template: {
+ id: currentRel.id,
+ name: name,
+ type: currentRel.type,
+ properties: currentRel.properties,
+ },
relationshipTemplate: currentRel,
source: currentRel.sourceElement.ref,
target: currentRel.targetElement.ref
@@ -2069,7 +2030,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
}
if (!this.arrayContainsNode(this.selectedNodes, nodeId)) {
this.enhanceDragSelection(nodeId);
- this.nodeChildrenArray.forEach(node => {
+ this.nodeComponentChildren.forEach(node => {
let nodeIndex;
this.selectedNodes.some((selectedNode, index) => {
if (selectedNode.id === node.nodeTemplate.id) {
@@ -2088,14 +2049,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
});
} else {
this.newJsPlumbInstance.removeFromAllPosses(nodeId);
- let nodeIndex;
- this.nodeChildrenArray.some((node, index) => {
- if (node.nodeTemplate.id === nodeId) {
- nodeIndex = index;
- return true;
- }
- });
- this.nodeChildrenArray[nodeIndex].makeSelectionVisible = false;
+ this.nodeComponentChildren.find(c => c.nodeTemplate.id === nodeId).makeSelectionVisible = false;
let selectedNodeIndex;
this.selectedNodes.some((node, index) => {
if (node.id === nodeId) {
@@ -2112,7 +2066,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
* @param nodeId
*/
private handleNodePressActions(nodeId: string): void {
- this.nodeChildrenArray.forEach(node => {
+ this.nodeComponentChildren.forEach(node => {
if (node.nodeTemplate.id === nodeId) {
node.makeSelectionVisible = true;
} else if (!this.arrayContainsNode(this.selectedNodes, node.nodeTemplate.id)) {
@@ -2140,7 +2094,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
if (!this.arrayContainsNode(this.selectedNodes, nodeId)) {
this.selectedNodes.push(this.getNodeByID(this.allNodeTemplates, nodeId));
this.newJsPlumbInstance.addToPosse(nodeId, 'dragSelection');
- this.nodeChildrenArray.forEach(node => {
+ this.nodeComponentChildren.forEach(node => {
if (this.selectedNodes.find(selectedNode => selectedNode && selectedNode.id === node.nodeTemplate.id)) {
if (node.makeSelectionVisible === false) {
node.makeSelectionVisible = true;
@@ -2308,7 +2262,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
if (this.matchType(reqDefinition.node, targetNodeType.qName, this.entityTypes.unGroupedNodeTypes) &&
this.matchType(reqDefinition.capability, capDefinition.capabilityType, this.entityTypes.capabilityTypes)) {
const validSourceTypes: string[] = InheritanceUtils.getValidSourceTypes(capDefinition, this.entityTypes.capabilityTypes);
- if (validSourceTypes) {
+ if (validSourceTypes && validSourceTypes.length) {
if (validSourceTypes.some(e => this.matchType(e, sourceNodeType.qName, this.entityTypes.unGroupedNodeTypes))) {
return true;
} else {
@@ -2386,7 +2340,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
}
private layoutTopology() {
- this.layoutDirective.layoutNodes(this.nodeChildrenArray, this.allRelationshipTemplates);
+ this.layoutDirective.layoutNodes(this.nodeComponentChildren.toArray(), this.allRelationshipTemplates);
this.ngRedux.dispatch(this.topologyRendererActions.executeLayout());
}
@@ -2401,7 +2355,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
if (rel.policies !== relationshipTemplate.policies) {
const oldCon = this.newJsPlumbInstance.getAllConnections().find(jSPlumbConnection => jSPlumbConnection.id === relationshipTemplate.id);
if (relationshipTemplate.policies && relationshipTemplate.policies.policy) {
- let labelString = (isNullOrUndefined(relationshipTemplate.state) ? '' : relationshipTemplate.state + ' ')
+ let labelString = (!relationshipTemplate.state ? '' : relationshipTemplate.state + ' ')
+ relationshipTemplate.name;
if (labelString.startsWith(this.backendService.configuration.relationshipPrefix)) {
// Workaround to support old topology templates with the real name
@@ -2421,7 +2375,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
const relationshipType = this.entityTypes.relationshipTypes.filter(rT => rT.qName === relationshipTemplate.type)[0];
if (oldCon) {
- const border = isNullOrUndefined(relationshipTemplate.state)
+ const border = !relationshipTemplate.state
? '#fafafa' : VersionUtils.getElementColorByDiffState(relationshipTemplate.state);
const me = this;
// create new JsPlumb instance with updated attributes
@@ -2473,7 +2427,7 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
this.notify.warning('Duplicate policy name!', 'Policy not Added!');
} else {
const newPolicy = new TPolicy(policyName, undefined, this.selectedNewPolicyType, [],
- [], {}, { kvproperties: {} }, []);
+ [], {}, { properties: {} }, []);
const newPolicies = [...this.entityTypes.yamlPolicies, newPolicy];
this.ngRedux.dispatch(this.actions.changeYamlPolicies(newPolicies));
this.addYamlPolicyModal.hide();
@@ -2501,25 +2455,28 @@ export class CanvasComponent implements OnInit, OnDestroy, OnChanges, AfterViewI
handleYamlPolicySelected($event: WineryRowData) {
this.selectedYamlPolicy = this.entityTypes.yamlPolicies.find(policy => policy.name === ($event.row).name);
- this.selectedYamlPolicy.properties = InheritanceUtils.getEffectiveKVPropertiesOfTemplateElement(this.selectedYamlPolicy.properties,
+ this.selectedYamlPolicy.properties = InheritanceUtils.getEffectivePropertiesOfTemplateElement(this.selectedYamlPolicy.properties,
this.selectedYamlPolicy.policyType, this.entityTypes.policyTypes);
}
savePolicyProperties(): void {
this.yamlPolicyProperties.forEach(txtArea => {
const keyOfChangedTextArea = txtArea.nativeElement.parentElement.innerText.replace(/\s/g, '');
- this.selectedYamlPolicy.properties.kvproperties[keyOfChangedTextArea] = txtArea.nativeElement.value;
+ this.selectedYamlPolicy.properties.properties[keyOfChangedTextArea] = txtArea.nativeElement.value;
});
}
showPropertiesOfSelectedYamlPolicy(): boolean {
- if (this.selectedYamlPolicy && this.selectedYamlPolicy.properties && this.selectedYamlPolicy.properties.kvproperties) {
- return Object.keys(this.selectedYamlPolicy.properties.kvproperties).length > 0;
+ if (this.selectedYamlPolicy && this.selectedYamlPolicy.properties && this.selectedYamlPolicy.properties.properties) {
+ return Object.keys(this.selectedYamlPolicy.properties.properties).length > 0;
}
return false;
}
getYamlPoliciesTableData() {
+ if (!this.entityTypes.yamlPolicies) {
+ return [];
+ }
return this.entityTypes.yamlPolicies.map(policy => {
const result:
{
diff --git a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/entities-modal/entities-modal.component.css b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/entities-modal/entities-modal.component.css
index c634a64c24..24b06e5cde 100644
--- a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/entities-modal/entities-modal.component.css
+++ b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/entities-modal/entities-modal.component.css
@@ -26,4 +26,8 @@
padding: 0;
border: 0;
vertical-align: baseline;
+ width: 100%;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
}
diff --git a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/entities-modal/entities-modal.component.html b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/entities-modal/entities-modal.component.html
index 416567eb21..7c7eefefda 100644
--- a/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/entities-modal/entities-modal.component.html
+++ b/org.eclipse.winery.frontends/app/topologymodeler/src/app/canvas/entities-modal/entities-modal.component.html
@@ -263,12 +263,12 @@
-