diff --git a/ARCHITECT/AppManager/.gitignore b/ARCHITECT/AppManager/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..79ccbc52e30d3bdf247ce1b2f05f25d1cf44d15b --- /dev/null +++ b/ARCHITECT/AppManager/.gitignore @@ -0,0 +1,4 @@ +.settings/ +/classes/ +/target/ +.classpath \ No newline at end of file diff --git a/ARCHITECT/AppManager/.project b/ARCHITECT/AppManager/.project new file mode 100644 index 0000000000000000000000000000000000000000..20f42f7033bac807a42b213faa885e15b46d69f4 --- /dev/null +++ b/ARCHITECT/AppManager/.project @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>eu.DECIDEh2020.architect.appManager</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/ARCHITECT/AppManager/LICENSE.txt b/ARCHITECT/AppManager/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..3276fe0690e8305937007c7653ffaf71fb65cf7f --- /dev/null +++ b/ARCHITECT/AppManager/LICENSE.txt @@ -0,0 +1,281 @@ +Copyright (C) 2017 Fraunhofer FOKUS. + +This program is free software: you can redistribute it and/or modify +it under the terms of the Eclipse Public License version 2.0. + +Eclipse Public License - v 2.0 +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION +OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial content +Distributed under this Agreement, and + +b) in the case of each subsequent Contributor: +i) changes to the Program, and +ii) additions to the Program; +where such changes and/or additions to the Program originate from +and are Distributed by that particular Contributor. A Contribution +"originates" from a Contributor if it was added to the Program by +such Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include changes or additions to the Program that +are not Modified Works. + +"Contributor" means any person or entity that Distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone +or when combined with the Program. + +"Program" means the Contributions Distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement +or any Secondary License (as applicable), including Contributors. + +"Derivative Works" shall mean any work, whether in Source Code or other +form, that is based on (or derived from) the Program and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. + +"Modified Works" shall mean any work in Source Code or other form that +results from an addition to, deletion from, or modification of the +contents of the Program, including, for purposes of clarity any new file +in Source Code form that contains any contents of the Program. Modified +Works shall not include works that contain only declarations, +interfaces, types, classes, structures, or files of the Program solely +in each case in order to link to, bind by name, or subclass the Program +or Modified Works thereof. + +"Distribute" means the acts of a) distributing or b) making available +in any manner that enables the transfer of a copy. + +"Source Code" means the form of a Program preferred for making +modifications, including but not limited to software source code, +documentation source, and configuration files. + +"Secondary License" means either the GNU General Public License, +Version 2.0, or any later versions of that license, including any +exceptions or additional permissions as identified by the initial +Contributor. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare Derivative Works of, publicly display, +publicly perform, Distribute and sublicense the Contribution of such +Contributor, if any, and such Derivative Works. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, +if any, in Source Code or other form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. +Each Contributor disclaims any liability to Recipient for claims +brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby +assumes sole responsibility to secure any other intellectual +property rights needed, if any. For example, if a third party +patent license is required to allow Recipient to Distribute the +Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has +sufficient copyright rights in its Contribution, if any, to grant +the copyright license set forth in this Agreement. + +e) Notwithstanding the terms of any Secondary License, no +Contributor makes additional grants to any Recipient (other than +those set forth in this Agreement) as a result of such Recipient's +receipt of the Program under the terms of a Secondary License +(if permitted under the terms of Section 3). + +3. REQUIREMENTS + +3.1 If a Contributor Distributes the Program in any form, then: + +a) the Program must also be made available as Source Code, in +accordance with section 3.2, and the Contributor must accompany +the Program with a statement that the Source Code for the Program +is available under this Agreement, and informs Recipients how to +obtain it in a reasonable manner on or through a medium customarily +used for software exchange; and + +b) the Contributor may Distribute the Program under a license +different than this Agreement, provided that such license: +i) effectively disclaims on behalf of all other Contributors all +warranties and conditions, express and implied, including +warranties or conditions of title and non-infringement, and +implied warranties or conditions of merchantability and fitness +for a particular purpose; + +ii) effectively excludes on behalf of all other Contributors all +liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits; + +iii) does not attempt to limit or alter the recipients' rights +in the Source Code under section 3.2; and + +iv) requires any subsequent distribution of the Program by any +party to be under a license that satisfies the requirements +of this section 3. + +3.2 When the Program is Distributed as Source Code: + +a) it must be made available under this Agreement, or if the +Program (i) is combined with other material in a separate file or +files made available under a Secondary License, and (ii) the initial +Contributor attached to the Source Code the notice described in +Exhibit A of this Agreement, then the Program may be made available +under the terms of such Secondary Licenses, and + +b) a copy of this Agreement must be included with each copy of +the Program. + +3.3 Contributors may not remove or alter any copyright, patent, +trademark, attribution notices, disclaimers of warranty, or limitations +of liability ("notices") contained within the Program from any copy of +the Program which they Distribute, provided that Contributors may add +their own appropriate notices. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, +the Contributor who includes the Program in a commercial product +offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes +the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every +other Contributor ("Indemnified Contributor") against any losses, +damages and costs (collectively "Losses") arising from claims, lawsuits +and other legal actions brought by a third party against the Indemnified +Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program +in a commercial product offering. The obligations in this section do not +apply to any claims or Losses relating to any actual or alleged +intellectual property infringement. In order to qualify, an Indemnified +Contributor must: a) promptly notify the Commercial Contributor in +writing of such claim, and b) allow the Commercial Contributor to control, +and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those performance +claims and warranties, and if a court requires any other Contributor to +pay any damages as a result, the Commercial Contributor must pay +those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF +TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE. Each Recipient is solely responsible for determining the +appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs +or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS +SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software +or hardware) infringes such Recipient's patent(s), then such Recipient's +rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign the +responsibility to serve as the Agreement Steward to a suitable separate +entity. Each new version of the Agreement will be given a distinguishing +version number. The Program (including Contributions) may always be +Distributed subject to the version of the Agreement under which it was +received. In addition, after a new version of the Agreement is published, +Contributor may elect to Distribute the Program (including its +Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient +receives no rights or licenses to the intellectual property of any +Contributor under this Agreement, whether expressly, by implication, +estoppel or otherwise. All rights in the Program not expressly granted +under this Agreement are reserved. Nothing in this Agreement is intended +to be enforceable by any entity that is not a Contributor or Recipient. +No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice + +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth +in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), +version(s), and exceptions or additional permissions here}." + +Simply including a copy of this Agreement, including this Exhibit A +is not sufficient to license the Source Code under Secondary Licenses. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to +look for such a notice. + +You may add additional accurate notices of copyright ownership. \ No newline at end of file diff --git a/ARCHITECT/AppManager/pom.xml b/ARCHITECT/AppManager/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..48ee9ed424276f687c1b23ccbe9ea3f8df6c9427 --- /dev/null +++ b/ARCHITECT/AppManager/pom.xml @@ -0,0 +1,54 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>de.decideh2020</groupId> + <artifactId>appManager</artifactId> + <version>0.0.1-SNAPSHOT</version> + <repositories> + <repository> + <id>jgit-repository</id> + <url>https://repo.eclipse.org/content/groups/releases/</url> + </repository> + </repositories> + <build> + <sourceDirectory>src</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.7.0</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <!-- Cloudpatterns dependency --> + <dependency> + <groupId>de.decideh2020</groupId> + <artifactId>cloudpatterns</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jgit</groupId> + <artifactId>org.eclipse.jgit</artifactId> + <version>4.9.0.201710071750-r</version> + </dependency> + <!-- Gson: Java to Json conversion --> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.8.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>apache-jena-libs</artifactId> + <type>pom</type> + <version>3.4.0</version> + </dependency> + + + </dependencies> +</project> \ No newline at end of file diff --git a/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/models/AppDescriptor.java b/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/models/AppDescriptor.java new file mode 100644 index 0000000000000000000000000000000000000000..0f43e0ff7ac7fd5206178582abe7694ee4705214 --- /dev/null +++ b/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/models/AppDescriptor.java @@ -0,0 +1,263 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.appManager.models; + + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.UUID; + +import org.apache.jena.rdf.model.Resource; + +public class AppDescriptor { + private UUID id; + private String name, description, version; + private Boolean highTechnologicalRisk; + + private LinkedList<Microservice> microservices; + private HashSet<Resource> projectNfrs; + private Object app_mcsla,containers[], virtual_machines[]; + final public static String plugin_version ="0.2.2-alpha"; + + public AppDescriptor() { + id = UUID.randomUUID(); + microservices = new LinkedList<Microservice>(); + setDeploymentOrder(); + this.projectNfrs = new HashSet<Resource>(); + this.version = plugin_version; + } + + + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + + + /** + * @return the version + */ + public String getVersion() { + return version; + } + + + + /** + * @param version the version to set + */ + public void setVersion(String version) { + this.version = version; + } + + + + /** + * @return the highTechnologicalRisk + */ + public Boolean getHighTechnologicalRisk() { + return highTechnologicalRisk; + } + + + + /** + * @param highTechnologicalRisk the highTechnologicalRisk to set + */ + public void setHighTechnologicalRisk(Boolean highTechnologicalRisk) { + this.highTechnologicalRisk = highTechnologicalRisk; + } + + + + /** + * @return the app_mcsla + */ + public Object getApp_mcsla() { + return app_mcsla; + } + + + + /** + * @param app_mcsla the app_mcsla to set + */ + public void setApp_mcsla(Object app_mcsla) { + this.app_mcsla = app_mcsla; + } + + + + + + + + /** + * @return the containers + */ + public Object[] getContainers() { + return containers; + } + + + + /** + * @param containers the containers to set + */ + public void setContainers(Object[] containers) { + this.containers = containers; + } + + + + /** + * @return the virtual_machines + */ + public Object[] getVirtual_machines() { + return virtual_machines; + } + + + + /** + * @param virtual_machines the virtual_machines to set + */ + public void setVirtual_machines(Object[] virtual_machines) { + this.virtual_machines = virtual_machines; + } + + + + /** + * @param id the id to set + */ + public void setId(UUID id) { + this.id = id; + } + + + + public LinkedList<Microservice> changeIndex(int index, int plus) { + + int size = microservices.size(); + if (index+plus>=0&& index+plus<size) { + Microservice mscv = microservices.get(index); + microservices.remove(index); + microservices.add(index+plus, mscv); + } + setDeploymentOrder(); + return microservices; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + + + + public void setDeploymentOrder(){ + + for (Microservice m: microservices) { + m.setDeployment_order(microservices.indexOf(m)); + + } + } + + + public LinkedList<Microservice> getMicroservices() { + return microservices; + } + + public void setMicroservices(LinkedList<Microservice> microservices) { + this.microservices = microservices; + setDeploymentOrder(); + } + + public LinkedList<Microservice> addMicroservice(Microservice microservice) { + this.microservices.add(microservice); + setDeploymentOrder(); + return this.microservices; + } + + public LinkedList<Microservice> addMicroservices(int number){ + for (int j = 0; j < number; j++) { + this.microservices.add(new Microservice()); + } + setDeploymentOrder(); + return this.microservices; + } + + public LinkedList<Microservice> removeMicroservice(int index) { + this.microservices.remove(index); + setDeploymentOrder(); + return this.microservices; + } + + + public LinkedList<Microservice> removeMicroservice(Microservice microservice) { + this.microservices.remove(microservice); + setDeploymentOrder(); + return this.microservices; + } + + public String getIDString() { + return id.toString(); + } + + /** + * @return the id + */ + public UUID getUID() { + return id; + } + + + public HashSet<Resource> getProjectNfrs() { + return projectNfrs; + } + + + + public void setProjectNfrs(HashSet<Resource> projectNfrs) { + this.projectNfrs = projectNfrs; + + } + public void addProjectNfr(Resource nfr) { + projectNfrs.add(nfr); + + } + public void removeProjectNfr(Resource nfr) { + projectNfrs.remove(nfr); + + } +} diff --git a/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/models/Microservice.java b/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/models/Microservice.java new file mode 100644 index 0000000000000000000000000000000000000000..be48c5b32f890ddc8480a1466dc90a204714c2f4 --- /dev/null +++ b/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/models/Microservice.java @@ -0,0 +1,315 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.appManager.models; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.UUID; + +import org.apache.jena.rdf.model.Resource; + +public class Microservice { + + private class InfrastructureRequirements{ + private String disk_min, disk_max, ram; + + /** + * @return the disk_min + */ + public String getDisk_min() { + return disk_min; + } + + /** + * @param disk_min the disk_min to set + */ + public void setDisk_min(String disk_min) { + this.disk_min = disk_min; + } + + /** + * @return the disk_max + */ + public String getDisk_max() { + return disk_max; + } + + /** + * @param disk_max the disk_max to set + */ + public void setDisk_max(String disk_max) { + this.disk_max = disk_max; + } + + /** + * @return the ram + */ + public String getRam() { + return ram; + } + + /** + * @param ram the ram to set + */ + public void setRam(String ram) { + this.ram = ram; + } + } + private String ms_name, patterns[], programming_language ="", type, category, ms_repo ; + private HashSet<Resource> nfrs; + private UUID ms_uid; + private boolean stateless = false, publicIP =false; + private URI endpoint[], container_ref; + private int deployment_order; + private ArrayList<String> dependencies = new ArrayList<String>(); + private InfrastructureRequirements infrastructure_requirements; + + /** + * @return the programmingLanguage + */ + public String getProgrammingLanguage() { + return programming_language; + } + + + /** + * @param programmingLanguage the programmingLanguage to set + */ + public void setProgrammingLanguage(String programmingLanguage) { + this.programming_language = programmingLanguage; + } + + + /** + * @return the category + */ + public String getCategory() { + return category; + } + + + /** + * @param category the category to set + */ + public void setCategory(String category) { + this.category = category; + } + + + /** + * @return the endpoint + */ + public URI[] getEndpoint() { + return endpoint; + } + + + /** + * @param endpoint the endpoint to set + */ + public void setEndpoint(URI[] endpoint) { + this.endpoint = endpoint; + } + + + /** + * @return the container_ref + */ + public URI getContainer_ref() { + return container_ref; + } + + + /** + * @param container_ref the container_ref to set + */ + public void setContainer_ref(URI container_ref) { + this.container_ref = container_ref; + } + + + /** + * @return the deployment_order + */ + public int getDeployment_order() { + return deployment_order; + } + + + /** + * @param deployment_order the deployment_order to set + */ + public void setDeployment_order(int deployment_order) { + this.deployment_order = deployment_order; + } + + + /** + * @return the infrastructure_requirements + */ + public InfrastructureRequirements getInfrastructure_requirements() { + return infrastructure_requirements; + } + + + /** + * @param infrastructure_requirements the infrastructure_requirements to set + */ + public void setInfrastructure_requirements(InfrastructureRequirements infrastructure_requirements) { + this.infrastructure_requirements = infrastructure_requirements; + } + + + /** + * @return the repo + */ + public String getRepo() { + return ms_repo; + } + + + /** + * @param repo the repo to set + */ + public void setRepo(String repo) { + this.ms_repo = repo; + } + + + /** + * @return the id + */ + public UUID getUID() { + return ms_uid; + } + + + /** + * @param dependencies the dependencies to set + */ + public void setDependencies(ArrayList<String> dependencies) { + this.dependencies = dependencies; + } + + public void addDependency(String dependency) { + this.dependencies.add(dependency); + } + + + + + public Microservice() { + + this("Microservice ", UUID.randomUUID()); + String uuid = this.getUIDstring().substring(0, 8); + this.setName("Microservice " + uuid); + } + + + public Microservice(String name) { + this(name, UUID.randomUUID()); + } + + public Microservice(UUID id) { + this("Microservice", id); + } + + public Microservice(HashSet<Resource> nfrs) { + this("Microservice", nfrs); + } + + public Microservice(String name, HashSet<Resource> nfrs) { + this(name, UUID.randomUUID(),nfrs ); + } + + public Microservice(String name, UUID id) { + this(name, id, new HashSet<Resource>() ); + } + public Microservice(UUID id, HashSet<Resource> nfrs) { + this("Microservice", id,nfrs ); + } + + + public Microservice(String name, UUID id, HashSet<Resource> nfrs) { + super(); + this.ms_name = name; + this.ms_uid = id; + this.stateless=true; + this.nfrs = nfrs; + } + + public String getUIDstring(){ + return ms_uid.toString(); + } + + public String getName(){ + return ms_name; + } + + public void setName(String name) { + this.ms_name = name; + } + + public HashSet<Resource> getNfrs() { + return nfrs; + } + + public void setNfrs(HashSet<Resource> nfrs) { + this.nfrs = nfrs; + } + + public String[] getPatterns() { + return patterns; + } + + public void setPatterns(String[] patterns) { + this.patterns = patterns; + } + + public String getLanguage() { + return programming_language; + } + + public void setLanguage(String language) { + this.programming_language = language; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isStateless() { + return stateless; + } + + public void setStateless(boolean stateless) { + this.stateless = stateless; + } + + + /** + * @return the dependencies + */ + public ArrayList<String> getDependencies() { + return dependencies; + } + + + + +} diff --git a/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/persistence/GitHandler.java b/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/persistence/GitHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..ae94aeed3ab16008baa1ef90f9ec55bd001d696a --- /dev/null +++ b/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/persistence/GitHandler.java @@ -0,0 +1,336 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.appManager.persistence; + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; + +import org.eclipse.jgit.api.AddCommand; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.PushCommand; +import org.eclipse.jgit.api.errors.CanceledException; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.DetachedHeadException; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidConfigurationException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.NoFilepatternException; +import org.eclipse.jgit.api.errors.NoHeadException; +import org.eclipse.jgit.api.errors.NoMessageException; +import org.eclipse.jgit.api.errors.RefNotFoundException; +import org.eclipse.jgit.api.errors.TransportException; +import org.eclipse.jgit.api.errors.WrongRepositoryStateException; +import org.eclipse.jgit.transport.CredentialsProvider; +import org.eclipse.jgit.transport.PushResult; +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; + + + +public class GitHandler { + public static class Repository { + private String uri, path, host, user, password, name, port, protocol; + private boolean secureStorage = true, newRepo = true, localRepo=true; + + public Repository(String uri, String path, String host, String user, String password, String port, String name, String protocol, boolean secureStorage) { + this.uri = uri; + this.path = path; + this.host = host; + this.user = user; + this.name = name; + this.port = port; + this.protocol = protocol; + this.password = password; + this.setSecureStorage(secureStorage); + } + + public Repository() { + this.setSecureStorage(false); + } + + /** + * @return the URI + */ + public String getURI() { + return uri; + } + + /** + * @param URI + * the URI to set + */ + public void setURI(String uri) { + this.uri = uri; + } + + /** + * @return the path + */ + public String getPath() { + return path; + } + + /** + * @param path + * the path to set + */ + public void setPath(String path) { + this.path = path; + } + + /** + * @return the host + */ + public String getHost() { + return host; + } + + /** + * @param host + * the host to set + */ + public void setHost(String host) { + this.host = host; + } + + /** + * @return the user + */ + public String getUser() { + return user; + } + + /** + * @param user + * the user to set + */ + public void setUser(String user) { + this.user = user; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @param password + * the password to set + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * @return the secureStorage + */ + public boolean isSecureStorage() { + return secureStorage; + } + + /** + * @param secureStorage + * the secureStorage to set + */ + public void setSecureStorage(boolean secureStorage) { + this.secureStorage = secureStorage; + } + + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the port + */ + public String getPort() { + return port; + } + + /** + * @param port the port to set + */ + public void setPort(String port) { + this.port = port; + } + + /** + * @return the protocol + */ + public String getProtocol() { + return protocol; + } + + /** + * @param protocol the protocol to set + */ + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + /** + * @return the newRepo + */ + public boolean isNewRepo() { + return newRepo; + } + + /** + * @param newRepo the newRepo to set + */ + public void setNewRepo(boolean newRepo) { + this.newRepo = newRepo; + } + + /** + * @return the localRepo + */ + public boolean isLocalRepo() { + return localRepo; + } + + /** + * @param localRepo the localRepo to set + */ + public void setLocalRepo(boolean localRepo) { + this.localRepo = localRepo; + } + + } + + private Repository repository; + private Git git; + private File directory; + private CredentialsProvider cp; + + public GitHandler(Repository repository) { + this.repository=repository; + if(repository.getName()!=null && !repository.getName().isEmpty() + && repository.getPassword()!=null && !repository.getPassword().isEmpty()) { + cp=new UsernamePasswordCredentialsProvider(repository.getName(), repository.getPassword()); + } + + } + + + public void cloneRepositoryTo(File dir) throws InvalidRemoteException, TransportException, GitAPIException { + + + Git git = Git.cloneRepository() + .setURI(repository.getURI()) + .setCredentialsProvider(cp) + .setDirectory(dir) + .call(); + + setDirectory(git.getRepository().getDirectory()); + git.close(); + + } + + public void createRepositoryIn(File dir) throws IllegalStateException, GitAPIException { + git = Git.init().setDirectory(dir).call(); + directory= git.getRepository().getDirectory(); + + } + + public void cloneRepo() throws IOException, NoFilepatternException, GitAPIException { + Git.cloneRepository() + .setURI(repository.getURI()) + .setDirectory(directory) + .call(); + } + + public void addToRepo() throws IOException, NoFilepatternException, GitAPIException { + AddCommand add = git.add(); + add.addFilepattern(".").call(); + } + + public void commitToRepo(String message) throws IOException, NoHeadException, + NoMessageException, ConcurrentRefUpdateException, + JGitInternalException, WrongRepositoryStateException, GitAPIException { + git.commit().setMessage(message).call(); + } + + public void pushToRepo() throws IOException, JGitInternalException, + InvalidRemoteException, GitAPIException { + PushCommand pc = git.push(); + pc.setCredentialsProvider(cp) + .setForce(true) + .setPushAll(); + try { + Iterator<PushResult> it = pc.call().iterator(); + if (it.hasNext()) { + System.out.println(it.next().toString()); + } + } catch (InvalidRemoteException e) { + e.printStackTrace(); + } + } + + public void pullFromRepo() throws IOException, WrongRepositoryStateException, + InvalidConfigurationException, DetachedHeadException, + InvalidRemoteException, CanceledException, RefNotFoundException, + NoHeadException, GitAPIException { + git.pull().call(); + } + + public void setCredentials(String name,String password) { + cp=new UsernamePasswordCredentialsProvider(repository.getName(), repository.getPassword()); + } + + + /** + * @return the repository + */ + public Repository getRepository() { + return repository; + } + + /** + * @param repository the repository to set + */ + public void setRepository(Repository repository) { + this.repository = repository; + } + + + /** + * @return the directory + */ + public File getDirectory() { + return directory; + } + + + /** + * @param directory the directory to set + */ + public void setDirectory(File directory) { + this.directory = directory; + } +} diff --git a/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/persistence/JsonHandler.java b/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/persistence/JsonHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..8f85fe15f333239e042a259c158f2fadfb8092de --- /dev/null +++ b/ARCHITECT/AppManager/src/eu/DECIDEh2020/architect/appManager/persistence/JsonHandler.java @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ + +/** + * + */ +package eu.DECIDEh2020.architect.appManager.persistence; + +import java.lang.reflect.Type; + +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.ResourceFactory; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.InstanceCreator; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonSyntaxException; + +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; +/** + * @author tja + * + */ +public class JsonHandler { + + public static class AppDescriptorWrapper { + // Old version means an older version than the one this class currently uses + private boolean oldVersion = false; + private String fileVersion = ""; + private AppDescriptor appDescriptor = null; + + public AppDescriptor getAppDescriptor() { + return appDescriptor; + } + + public void setAppDescriptor(AppDescriptor appDescriptor) { + this.appDescriptor = appDescriptor; + } + + public boolean isOldVersion() { + return oldVersion; + } + + public void setOldVersion(boolean oldVersion) { + this.oldVersion = oldVersion; + } + + public String getFileVersion() { + return fileVersion; + } + + public void setFileVersion(String fileVersion) { + this.fileVersion = fileVersion; + } + } + + private static class ResourceSerializer implements JsonSerializer<Resource> { + public JsonElement serialize(Resource src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src.toString()); + } + } + + private static class ResourceDeserializer implements JsonDeserializer<Resource> { + public Resource deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + + return Patterns.createDefaultPatterns().getModel().createResource(json.getAsJsonPrimitive().getAsString()); + } + } + + private static class ResourceInstanceCreator implements InstanceCreator<Resource> { + public Resource createInstance(Type type) { + + return ResourceFactory.createResource(); + } + } + + /** + * @param jsonString the String in JSON format to convert into an AppDescriptor Object + * @return AppDescriptorWrapper a wrapper Object containing the AppDescriptor and a Boolean value which might provide the reason for possible conversion errors by indicating the version of the AppDescriptor file. + * @throws JsonSyntaxException TODO + */ + public static AppDescriptorWrapper toAppDescriptor(String jsonString) throws JsonSyntaxException { + AppDescriptorWrapper app = new AppDescriptorWrapper(); + + Gson gson = new GsonBuilder().registerTypeAdapter(Resource.class, new ResourceInstanceCreator()) + .registerTypeAdapter(Resource.class, new ResourceDeserializer()).create(); + + app.appDescriptor = gson.fromJson(jsonString, AppDescriptor.class); + + JsonParser parser = new JsonParser(); + JsonObject jsonObject = parser.parse(jsonString).getAsJsonObject(); + + if (jsonObject.has("version")) { + String version = parser.parse(jsonString).getAsJsonObject().get("version").getAsString(); + + if (!version.equals(AppDescriptor.plugin_version)) { + app.setOldVersion(true); + app.setFileVersion(version); + } + + } + return app; + + } + + public static String fromAppDescriptor(AppDescriptor app) { + //create new gson with pretty printing activated and Serializer & deserializer for Resource Type + Gson gson = new GsonBuilder() + .setPrettyPrinting() + .registerTypeAdapter(Resource.class, new ResourceSerializer()) + .registerTypeAdapter(Resource.class, new ResourceDeserializer()) + .create(); + + + + //convert app descriptor object to json string + return gson.toJson(app); + + } + + +} diff --git a/ARCHITECT/CloudPatterns/pom.xml b/ARCHITECT/CloudPatterns/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..68eab2cc67264daf48fbe889e6e0c2a2789d5f8b --- /dev/null +++ b/ARCHITECT/CloudPatterns/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>eu.DECIDEh2020</groupId> + <artifactId>cloudpatterns</artifactId> + <version>1.0-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.2.3</version> + </dependency> + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>apache-jena-libs</artifactId> + <type>pom</type> + <version>3.4.0</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.11</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.6.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>${project.build.sourceEncoding}</encoding> + </configuration> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file diff --git a/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/DECIDEPatterns.java b/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/DECIDEPatterns.java new file mode 100644 index 0000000000000000000000000000000000000000..fd049d2fa08d093bdb702541ee09f6d1c653ae45 --- /dev/null +++ b/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/DECIDEPatterns.java @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.rdf.model.Resource; + +public class DECIDEPatterns { + + public static final String BASE = "http://decideh2020.eu/resources/"; + + public static final Resource patternCategories; + + public static final Resource fundamentalCategory; + public static final Resource developmentCategory; + public static final Resource optimizationCategory; + public static final Resource deploymentCategory; + + public static final Resource availability; + public static final Resource scalability; + public static final Resource performance; + public static final Resource cost; + public static final Resource location; + + static { + Model m = ModelFactory.createDefaultModel(); + + patternCategories = m.createResource(BASE + "patterncategories"); + + fundamentalCategory = m.createResource(BASE + "patterncategories/fundamental"); + developmentCategory = m.createResource(BASE + "patterncategories/development"); + optimizationCategory = m.createResource(BASE + "patterncategories/optimization"); + deploymentCategory = m.createResource(BASE + "patterncategories/deployment"); + + availability = m.createResource(BASE + "patterns/availability"); + scalability = m.createResource(BASE + "patterns/scalability"); + performance = m.createResource(BASE + "patterns/performance"); + cost = m.createResource(BASE + "patterns/cost"); + location = m.createResource(BASE + "patterns/location"); + + } + +} diff --git a/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/DP.java b/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/DP.java new file mode 100644 index 0000000000000000000000000000000000000000..9e1633652f102119b3b43341810178f8800d6064 --- /dev/null +++ b/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/DP.java @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.rdf.model.Property; +import org.apache.jena.rdf.model.Resource; + +public class DP { + + public static final String DP_NS = "http://decideh2020.eu/ns/patterns/"; + + public static final Property icon; + public static final Property solution; + public static final Property context; + public static final Property hasImpactOn; + public static final Property hasPositiveImpactOn; + public static final Property hasNegativeImpactOn; + + public static final Resource Pattern; + public static final Resource NFR; + + static { + Model m = ModelFactory.createDefaultModel(); + Pattern = m.createResource(DP_NS + "Pattern"); + NFR = m.createResource(DP_NS + "NFR"); + + icon = m.createProperty(DP_NS, "icon"); + solution = m.createProperty(DP_NS, "solution"); + context = m.createProperty(DP_NS, "context"); + hasImpactOn = m.createProperty(DP_NS, "hasImpactOn"); + hasPositiveImpactOn = m.createProperty(DP_NS, "hasPositiveImpactOn"); + hasNegativeImpactOn = m.createProperty(DP_NS, "hasNegativeImpactOn"); + } + +} diff --git a/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/Patterns.java b/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/Patterns.java new file mode 100644 index 0000000000000000000000000000000000000000..da263c9e86e0856398eecc801d1fd33198f53323 --- /dev/null +++ b/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/Patterns.java @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Resource; + +import java.io.InputStream; +import java.util.List; + +public interface Patterns { + + Model getModel(); + + List<Resource> query(String queryString); + + List<Resource> listPatterns(); + + List<Resource> getPatternsByCategory(Resource type); + + Resource getPattern(String uri); + + InputStream getIcon(Resource icon); + + List<Resource> listNFRs(); + + List<Resource> inferPatterns(List<Resource> nfrs); + + List<Resource> inferBadPatterns(List<Resource> nfrs); + + static Patterns createDefaultPatterns() { + return new PatternsImpl(); + } + +} diff --git a/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/PatternsImpl.java b/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/PatternsImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..4910cf55dbd3bc3a0a45c686ac5176564acb3146 --- /dev/null +++ b/ARCHITECT/CloudPatterns/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/PatternsImpl.java @@ -0,0 +1,122 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns; + +import org.apache.jena.query.*; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFDataMgr; +import org.apache.jena.vocabulary.*; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +class PatternsImpl implements Patterns { + + private static Model patternsModel; + + PatternsImpl() { + if (patternsModel == null) { + patternsModel = ModelFactory.createDefaultModel(); + RDFDataMgr.read(patternsModel, PatternsImpl.class.getClassLoader().getResourceAsStream("patterns/decide-patterns.ttl"), Lang.TURTLE); + } + } + + @Override + public Model getModel() { + return patternsModel; + } + + @Override + public List<Resource> query(String queryString) { + Query query = QueryFactory.create(queryString); + return execute(query); + } + + @Override + public List<Resource> listPatterns() { + return patternsModel.listResourcesWithProperty(RDF.type, DP.Pattern).toList(); + } + + @Override + public List<Resource> getPatternsByCategory(Resource type) { + Resource res = patternsModel.getResource(type.getURI()); + if (res != null && res.hasProperty(SKOS.inScheme, DECIDEPatterns.patternCategories)) { + return patternsModel.listResourcesWithProperty(DCTerms.type, res).toList(); + } else { + return null; + } + } + + @Override + public Resource getPattern(String uri) { + return patternsModel.getResource(uri); + } + + @Override + public InputStream getIcon(Resource icon) { + String fileName = icon.getLocalName(); + return PatternsImpl.class.getClassLoader().getResourceAsStream("patterns/icons/" + fileName); + } + + @Override + public List<Resource> listNFRs() { + return patternsModel.listResourcesWithProperty(RDF.type, DP.NFR).toList(); + } + + @Override + public List<Resource> inferPatterns(List<Resource> nfrs) { + // list all patterns that have an positive impact on these nfrs. + // we should leave out fundamentals! + StringBuffer buffer = new StringBuffer("select ?pattern where { ?pattern <http://decideh2020.eu/ns/patterns/hasPositiveImpactOn> ?nfr . filter ( ?nfr in ("); + nfrs.forEach(nfr -> { + buffer.append("<"); + buffer.append(nfr.getURI()); + buffer.append(">, "); + }); + buffer.setLength(buffer.length() - 2); + buffer.append(") && not exists { ?pattern <http://purl.org/dc/terms/type> <http://decideh2020.eu/resources/patterncategories/fundamental> } ) }"); + Query query = QueryFactory.create(buffer.toString()); + return execute(query); + } + + public List<Resource> inferBadPatterns(List<Resource> nfrs) { + // list all patterns that have a negative impact on these nfrs. + // we should probably NOT leave out fundamentals! + StringBuffer buffer = new StringBuffer("select ?pattern where { ?pattern <http://decideh2020.eu/ns/patterns/hasNegativeImpactOn> ?nfr . filter ( ?nfr in ("); + nfrs.forEach(nfr -> { + buffer.append("<"); + buffer.append(nfr.getURI()); + buffer.append(">, "); + }); + buffer.setLength(buffer.length() - 2); + buffer.append(") ) }"); + Query query = QueryFactory.create(buffer.toString()); + return execute(query); + } + + private List<Resource> execute(Query query) { + QueryExecution exec = QueryExecutionFactory.create(query, patternsModel); + ResultSet result = exec.execSelect(); + List<Resource> patterns = new ArrayList<>(); + result.forEachRemaining(r -> patterns.add(r.getResource("pattern"))); + return patterns; + } + +} diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/decide-patterns.ttl b/ARCHITECT/CloudPatterns/src/main/resources/patterns/decide-patterns.ttl new file mode 100644 index 0000000000000000000000000000000000000000..0f3b295d5320f9e727c6faf935f292b4984af905 --- /dev/null +++ b/ARCHITECT/CloudPatterns/src/main/resources/patterns/decide-patterns.ttl @@ -0,0 +1,231 @@ +# +# Copyright (c) 2017 Fraunhofer FOKUS. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the +# GNU AGPL v3 which accompanies +# this distribution, and is available at +# http://www.gnu.org/licenses/agpl.txt +# +# Contributors: +# +# Simon Dutkowski Fraunhofer FOKUS +# +# Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +# + +@base <http://decideh2020.eu/resources/patterns/> . + +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix dct: <http://purl.org/dc/terms/> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix dp: <http://decideh2020.eu/ns/patterns/> . + +@prefix skos: <http://www.w3.org/2004/02/skos/core#> . + +<http://decideh2020.eu/resources/patterncategories> + a skos:ConceptScheme ; + rdfs:label "Cloud Pattern Categories"@en . + +<http://decideh2020.eu/resources/patterncategories/fundamental> + a skos:Concept ; + skos:inScheme <http://decideh2020.eu/resources/patterncategories> ; + skos:prefLabel "Fundamental Pattern"@en . + +<http://decideh2020.eu/resources/patterncategories/development> + a skos:Concept ; + skos:inScheme <http://decideh2020.eu/resources/patterncategories> ; + skos:prefLabel "Development Pattern"@en . + +<http://decideh2020.eu/resources/patterncategories/optimization> + a skos:Concept ; + skos:inScheme <http://decideh2020.eu/resources/patterncategories> ; + skos:prefLabel "Optimization Pattern"@en . + +<http://decideh2020.eu/resources/patterncategories/deployment> + a skos:Concept ; + skos:inScheme <http://decideh2020.eu/resources/patterncategories> ; + skos:prefLabel "Deployment Pattern"@en . + +<availability> + a dp:NFR ; + dct:title "Availability"@en ; + dct:description ""@en . + +<cost> + a dp:NFR ; + dct:title "Cost"@en ; + dct:description ""@en . + +<scalability> + a dp:NFR ; + dct:title "Scalability"@en ; + dct:description ""@en . + +<performance> + a dp:NFR ; + dct:title "Performance"@en ; + dct:description ""@en . + +<location> + a dp:NFR ; + dct:title "Location"@en ; + dct:description ""@en . + +<distributed-application> + a dp:Pattern ; + dct:title "Distributed Application"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/fundamental> ; + dp:icon <urn:distributed_application.png> ; + dct:subject "How can application functionality be decomposed to be handled by separate application components?"@en ; + dct:description "A cloud application divides provided functionality among multiple application components that can be scaled out independently."@en ; + dp:context "Applications have to respect the distribution and the scaling-out support of cloud environments in their architecture to efficiently benefit from it. Cloud applications, therefore, should to rely on multiple, possibly redundant IT resources. This can especially be the case if the cloud provider assures Environment-based Availability – the availability of the complete environment and not of single IT resources hosted in it."@en ; + dp:solution "The functionality of the application is divided into multiple independent components that provide a certain function. This componentization of application functionality introduces a logical decomposition of the application. These logical components are subsumed to multiple tiers to denote that they shall be deployed together physically, i.e., on one server (cluster)."@en ; + dct:license <https://creativecommons.org/licenses/by/4.0/> ; + foaf:page [ + a foaf:Document ; + foaf:topic "Distributed Application Pattern" ; + foaf:primaryTopic <http://www.cloudcomputingpatterns.org/distributed_application/> ; + ] ; + dct:relation <elastic-infrastructure> ; + dct:relation <watchdog> . + +<two-tier-cloud-application> + a dp:Pattern ; + dct:title "Two-Tier Cloud Application"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/fundamental> ; + dp:icon <urn:two_tier_cloud_application.png> ; + dct:subject "How can application functionality be separated from data handling to scale them independently?"@en ; + dct:description "Presentation and business logic is bundled to one stateless tier that is easy to scale. This tier is separated from the data tier that is harder to scale and often handled by a provider-supplied storage offering."@en ; + dp:context "A Distributed Application is decomposed into application components to scale individual application functions independently. In this scope, data handling functionality is significantly harder to scale than Stateless Components, because Stateful Components have to coordinate state information between instances. Therefore, the application shall be decomposed in a fashion that separates the easy-to-scale functionality from the hard-to-scale functionality."@en ; + dp:solution "Application functionality is decomposed into data handling functionality, provided by one or several Storage Offerings, and application components handling presentation and business logic. This separation enables the two tiers to elastically scale independently with their workloads."@en ; + dct:license <https://creativecommons.org/licenses/by/4.0/> ; + foaf:page [ + a foaf:Document ; + foaf:topic "Two-Tier Cloud Application" ; + foaf:primaryTopic <http://www.cloudcomputingpatterns.org/two_tier_cloud_application/> ; + ] ; + dct:relation <three-tier-cloud-application> ; + dct:relation <content-distribution-network> ; + dct:relation <hybrid-data> ; + dct:relation <hybrid-backup> ; + dct:relation <hybrid-application-functions> ; + dct:relation <hybrid-development-environment> . + +<three-tier-cloud-application> + a dp:Pattern ; + dct:title "Three-Tier Cloud Application"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/fundamental> ; + dp:icon <urn:three_tier_cloud_application.png> ; + dct:subject "How can presentation logic, business logic, and data handling be decomposed into separate tiers that are scaled independently?"@en ; + dct:description "The presentation, business logic, and data handling is realized as separate tiers to scale stateless presentation and compute-intensive processing independently of the data tier, which is harder to scale and often handled by the cloud provider."@en ; + dp:context "A Distributed Application is decomposed into application components to scale individual application functions independently. There can be many differentiating factors of application tiers. For example, if Processing Components are more computation intensive or are used less frequently than User Interface Components, aligning the elastic scaling of these two components by summarizing their implementation in one tier can be inefficient. This issue arises every time components experiences different Application Workloads. The number of provisioned component instances cannot be aligned well to the different workloads if they are summarized to coarse grained tiers."@en ; + dp:solution "The application is decomposed into three tiers, where each tier is elastically scaled independently. The presentation tier is comprised of a load balancer and an application component that implements the Stateless Component pattern and User Interface Component pattern. The business logic tier is comprised of an application component implementing the Stateless Component pattern in addition to the Processing Component pattern."@en ; + dct:license <https://creativecommons.org/licenses/by/4.0/> ; + foaf:page [ + a foaf:Document ; + foaf:topic "Three-Tier Cloud Application" ; + foaf:primaryTopic <http://www.cloudcomputingpatterns.org/three_tier_cloud_application/> ; + ] ; + dct:relation <two-tier-cloud-application> ; + dct:relation <content-distribution-network> ; + dct:relation <hybrid-cloud-applications> . + +<loose-coupling> + a dp:Pattern ; + dct:title "Loose Coupling"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/fundamental> ; + dct:type <http://decideh2020.eu/resources/patterncategories/development> ; + dp:icon <urn:loose_coupling.png> ; + dct:subject "How can dependencies between Distributed Applications and between individual components of these applications be reduced?"@en ; + dct:description "Information exchange between applications and their individual components as well as associated management tasks, such as scaling, failure handling, or update management can be simplified significantly if application components can be treated individually and the dependencies among them are kept to a minimum."@en ; + dp:context "Information exchange between applications and their individual components as well as associated management tasks, such as scaling, failure handling, or update management can be simplified significantly if application components can be treated individually and the dependencies among them are kept to a minimum."@en ; + dp:solution "Communicating components and multiple integrated applications are decoupled from each other by interacting through a broker. This broker encapsulates the assumptions that communication partners would otherwise have to make about one other and, thus, ensures separation of concerns."@en ; + dct:license <https://creativecommons.org/licenses/by/4.0/> ; + foaf:page [ + a foaf:Document ; + foaf:topic "Loose Coupling Pattern" ; + foaf:primaryTopic <http://www.cloudcomputingpatterns.org/loose_coupling/> ; + ] ; + dct:relation <distributed-application> ; + dct:relation <two-tier-cloud-application> ; + dct:relation <hypervisor> ; + dct:relation <eventual-consistency> ; + dct:relation <message-oriented-middleware> ; + dct:relation <watchdog> ; + dp:hasPositiveImpactOn <scalability> . + +<managed-configuration> + a dp:Pattern ; + dct:title "Managed Configuration"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/fundamental> ; + dp:icon <urn:managed_configuration.png> ; + dct:subject ""@en ; + dct:description ""@en ; + dp:context ""@en ; + dp:solution ""@en . + +<containerization> + a dp:Pattern ; + dct:title "Containerization"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/fundamental> ; + dct:subject ""@en ; + dct:description ""@en ; + dp:context ""@en ; + dp:solution ""@en . + +<service-registry> + a dp:Pattern ; + dct:title "Service Registry"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/fundamental> . + +<provider-adapter> + a dp:Pattern ; + dct:title "Provider Adapter"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/optimization> . + +<elasticity-manager> + a dp:Pattern ; + dct:title "Elasticity Manager"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/optimization> ; + dp:hasPositiveImpactOn <scalability> . + +<resiliency-management-process> + a dp:Pattern ; + dct:title "Resiliency Management Process"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/optimization> ; + dp:hasPositiveImpactOn <availability> . + +<elastic-load-balancer> + a dp:Pattern ; + dct:title "Elastic Load Balancer"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/optimization> ; + dp:hasPositiveImpactOn <availability> . + +<elastic-queue> + a dp:Pattern ; + dct:title "Elastic Queue"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/optimization> ; + dp:hasPositiveImpactOn <scalability> . + +<stateless-component> + a dp:Pattern ; + dct:title "Stateless Component"@en ; + dct:type <http://decideh2020.eu/resources/patterncategories/development> ; + dp:icon <urn:stateless_component.png> ; + dct:subject "How can elasticity and robustness of an application component be increased?"@en ; + dct:description "State is handled external of application components to ease their scaling-out and to make the application more tolerant to component failures."@en ; + dp:context "The components of a Distributed Application are deployed among multiple cloud resources to benefit from this distributed runtime environment through scaling out.The most significant factor complicating addition and removal of component instances in this scope is the internal state maintained by them. In case of failure, this information may even be lost."@en ; + dp:solution "Application components are implemented in a fashion that they do not have an internal state. Instead, their state and configuration is stored externally in Storage Offerings or provided to the component with each request."@en ; + dct:license <https://creativecommons.org/licenses/by/4.0/> ; + foaf:page [ + a foaf:Document ; + foaf:topic "Stateless Component Pattern" ; + foaf:primaryTopic <http://www.cloudcomputingpatterns.org/stateless_component/> ; + ] ; + dct:relation <relational-database> ; + dct:relation <key-value-storage> ; + dct:relation <blob-storage> ; + dct:relation <message-oriented-middleware> ; + dp:hasPositiveImpactOn <scalability> . diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/CC-BY.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/CC-BY.png new file mode 100644 index 0000000000000000000000000000000000000000..cc9cae16c81ccf55653272e934b6cfe9256df8a8 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/CC-BY.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/_License.txt b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/_License.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a188fdb56daba3ad64ce153311cb5dd4200e9eb --- /dev/null +++ b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/_License.txt @@ -0,0 +1,6 @@ +These icons are released unter the Creative Commons Attribution 4.0 International License. +Please include the following in your PNG file and text to give appropriate credit: + +CC-BY.png http://www.cloudcomputingpatterns.org + +License: http://creativecommons.org/licenses/by/4.0/ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/application_component_proxy.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/application_component_proxy.png new file mode 100644 index 0000000000000000000000000000000000000000..b68db9bb08269ef83a2a97a589233c873ddf7ef0 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/application_component_proxy.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/at-least-once_delivery.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/at-least-once_delivery.png new file mode 100644 index 0000000000000000000000000000000000000000..6a99e2a8fce2931ec46517184314ebf644f3ef05 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/at-least-once_delivery.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/batch_processing_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/batch_processing_component.png new file mode 100644 index 0000000000000000000000000000000000000000..4324bb7d3447b4224937465af24f3c9a0fa8e407 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/batch_processing_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/blob_storage.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/blob_storage.png new file mode 100644 index 0000000000000000000000000000000000000000..7976638777a85dd1913a3eba93f613d4d534183b Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/blob_storage.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/block_storage.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/block_storage.png new file mode 100644 index 0000000000000000000000000000000000000000..345494c341ee5aa5244a0ca7440f634664dcebbf Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/block_storage.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/community_cloud.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/community_cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..a3e660c162cd0122410ca480cde71e67ba653798 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/community_cloud.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/compliant_data_replication.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/compliant_data_replication.png new file mode 100644 index 0000000000000000000000000000000000000000..f8bb7ff5df3f4fa26a404b4a8315b85dc507283e Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/compliant_data_replication.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/content_distribution_network.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/content_distribution_network.png new file mode 100644 index 0000000000000000000000000000000000000000..2b997e4ae8d453b57cb0bd3e6bcb072496223f04 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/content_distribution_network.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/continuously_changing_workload.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/continuously_changing_workload.png new file mode 100644 index 0000000000000000000000000000000000000000..9b2f3ee1b3cac405e6769d4257f8fc0f2ae01845 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/continuously_changing_workload.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/data_abstractor.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/data_abstractor.png new file mode 100644 index 0000000000000000000000000000000000000000..ba9fb63d77748cdf7510545cd4e77e0a033972a2 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/data_abstractor.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/data_access_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/data_access_component.png new file mode 100644 index 0000000000000000000000000000000000000000..5e2a2597859c6faae53da4738d60951a8f146f11 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/data_access_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/dedicated_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/dedicated_component.png new file mode 100644 index 0000000000000000000000000000000000000000..6b97a60b54b27ed238b4666e1ed2dcdfa6aca33e Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/dedicated_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/distributed_application.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/distributed_application.png new file mode 100644 index 0000000000000000000000000000000000000000..6af1a6ae6e1027448388e7ed7af8220740de4852 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/distributed_application.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_infrastructure.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_infrastructure.png new file mode 100644 index 0000000000000000000000000000000000000000..33fbff45b9ae9e3b49e2b18b3ad0c65907d33bb5 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_infrastructure.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_load_balancer.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_load_balancer.png new file mode 100644 index 0000000000000000000000000000000000000000..320a8399f8e2d186e5afc217822fb89c7d2bb82f Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_load_balancer.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_platform.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_platform.png new file mode 100644 index 0000000000000000000000000000000000000000..6ff2250a39f0581a31d2bfbc1e4ff94922efc53a Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_platform.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_queue.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_queue.png new file mode 100644 index 0000000000000000000000000000000000000000..fe2c637466ebab27a5a26ec69a886af1d540df87 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elastic_queue.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elasticity_management_process.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elasticity_management_process.png new file mode 100644 index 0000000000000000000000000000000000000000..06d4646a03033d13ae40ff8f9476c396a1791fe2 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elasticity_management_process.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elasticity_manager.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elasticity_manager.png new file mode 100644 index 0000000000000000000000000000000000000000..526446b5109169fe7ac3f462f935f75cab7ddf14 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/elasticity_manager.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/environment-based_availability.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/environment-based_availability.png new file mode 100644 index 0000000000000000000000000000000000000000..a1507c1c98ef45a3e89849356774158f98b957e9 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/environment-based_availability.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/eventual_consistency.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/eventual_consistency.png new file mode 100644 index 0000000000000000000000000000000000000000..df03617a01d196ea72f7e2db8df7b5e3e6297679 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/eventual_consistency.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/exactly-once_delivery.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/exactly-once_delivery.png new file mode 100644 index 0000000000000000000000000000000000000000..3981ec40d3d2ccde374c0aed69511aa1da820ee6 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/exactly-once_delivery.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/execution_environment.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/execution_environment.png new file mode 100644 index 0000000000000000000000000000000000000000..73eafde95a5967b46302545ef462115bc96a2ef1 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/execution_environment.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/feature_flag_management_process.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/feature_flag_management_process.png new file mode 100644 index 0000000000000000000000000000000000000000..9bdb037560e3b80982808e1a98f71910b13c8c68 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/feature_flag_management_process.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_application_functions.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_application_functions.png new file mode 100644 index 0000000000000000000000000000000000000000..2983da7c2941cbbecc8ca1cecf710b9363e66902 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_application_functions.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_backend.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_backend.png new file mode 100644 index 0000000000000000000000000000000000000000..42d1c75e4d0e64b083f5a42733080e5bdcfee2cc Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_backend.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_backup.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_backup.png new file mode 100644 index 0000000000000000000000000000000000000000..b68da377fa8148c23579574146558d9e8a2cfa9f Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_backup.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_cloud.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..6ee4dfe07e04cf5bf69178bc55ca7b91b8f85395 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_cloud.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_data.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_data.png new file mode 100644 index 0000000000000000000000000000000000000000..0cf5ac6dcd522ed0d81d5d928ec41bd9fb02c601 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_data.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_development_environment.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_development_environment.png new file mode 100644 index 0000000000000000000000000000000000000000..121ccc738935ff3476485560bdc9234436da249f Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_development_environment.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_multimedia_web_application.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_multimedia_web_application.png new file mode 100644 index 0000000000000000000000000000000000000000..ebe96ac920ca3adfaa006f06aa372c00f4d57ac9 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_multimedia_web_application.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_processing.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_processing.png new file mode 100644 index 0000000000000000000000000000000000000000..0de93a9222c52f55360992454469421f0730e467 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_processing.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_user_interface.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_user_interface.png new file mode 100644 index 0000000000000000000000000000000000000000..65f16e7c9f6c465b186c1a2c231268e444ceb3f9 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hybrid_user_interface.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hypervisor.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hypervisor.png new file mode 100644 index 0000000000000000000000000000000000000000..b319ecb7656b1ed8a9080181fbbf9811e6abd09c Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/hypervisor.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/idempotent_processor.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/idempotent_processor.png new file mode 100644 index 0000000000000000000000000000000000000000..466295ae47a8e9cdd099f63c802e1fd3c153272c Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/idempotent_processor.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/infrastructure_as_a_service.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/infrastructure_as_a_service.png new file mode 100644 index 0000000000000000000000000000000000000000..1c7df6625d49fc7fef79dfb7e52e9a80284240c0 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/infrastructure_as_a_service.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/integration_provider.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/integration_provider.png new file mode 100644 index 0000000000000000000000000000000000000000..26f333375d24a4d554e31a3c8ef3366f6c2250d2 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/integration_provider.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/key-value_storage.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/key-value_storage.png new file mode 100644 index 0000000000000000000000000000000000000000..61c34f2a7809ecada825b51b8cde58ead7a5890e Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/key-value_storage.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/loose_coupling.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/loose_coupling.png new file mode 100644 index 0000000000000000000000000000000000000000..d2380bb39d781b60c0e5cbbd8ec66a02863a8726 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/loose_coupling.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/managed_configuration.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/managed_configuration.png new file mode 100644 index 0000000000000000000000000000000000000000..dffc3c0e66bf1e17d01dd351827d8e88adb16021 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/managed_configuration.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/map_reduce.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/map_reduce.png new file mode 100644 index 0000000000000000000000000000000000000000..f23168faf54b3a3be822b4fa3c203fb7c32f6673 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/map_reduce.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/message-oriented_middleware.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/message-oriented_middleware.png new file mode 100644 index 0000000000000000000000000000000000000000..25a3b80cbe94770d1a6886abb8bab80ba5d2d4e5 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/message-oriented_middleware.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/message_mover.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/message_mover.png new file mode 100644 index 0000000000000000000000000000000000000000..f621eb86001377f6a7463ca6da5e1c2dd21623ce Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/message_mover.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/multi-component_image.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/multi-component_image.png new file mode 100644 index 0000000000000000000000000000000000000000..3dbdefc38e356c22dffe12c9e64f057e827bcbc0 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/multi-component_image.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/node-based_availability.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/node-based_availability.png new file mode 100644 index 0000000000000000000000000000000000000000..cd34f54751f43607ee345cf061c692bba1fd7a34 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/node-based_availability.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/once-in-a-lifetime_workload.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/once-in-a-lifetime_workload.png new file mode 100644 index 0000000000000000000000000000000000000000..e0b3b915bfe9d836495bf79b339ce0b2fb8f5eff Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/once-in-a-lifetime_workload.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/periodic_workload.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/periodic_workload.png new file mode 100644 index 0000000000000000000000000000000000000000..e8bb402a3da275e2c6634498096290c72c2e8b55 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/periodic_workload.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/platform_as_a_service.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/platform_as_a_service.png new file mode 100644 index 0000000000000000000000000000000000000000..02887b2139543f16028772b21ccf3718da2dda4c Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/platform_as_a_service.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/private_cloud.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/private_cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..88caa83db7ff60aa04dfe21e550cdc95d9e2552c Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/private_cloud.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/processing_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/processing_component.png new file mode 100644 index 0000000000000000000000000000000000000000..e2b6eae8b6f9a5b9bb337a46bed95ae6b0860719 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/processing_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/provider_adapter.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/provider_adapter.png new file mode 100644 index 0000000000000000000000000000000000000000..b546d8098a96f709c1c713c3431d0e35a49b01fb Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/provider_adapter.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/public_cloud.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/public_cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..dc2b22f8b7822d574a4ca33c8d9be677b1337333 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/public_cloud.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/relational_database.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/relational_database.png new file mode 100644 index 0000000000000000000000000000000000000000..90b86e681d4a0b228102c23e25720c40824a689c Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/relational_database.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/resiliency_management_process.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/resiliency_management_process.png new file mode 100644 index 0000000000000000000000000000000000000000..9b5afb5405ff9e6780926a81b37057561d862310 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/resiliency_management_process.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/restricted_data_access_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/restricted_data_access_component.png new file mode 100644 index 0000000000000000000000000000000000000000..aaf70f1e9ec23138292319a70685f4528f2de34d Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/restricted_data_access_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/shared_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/shared_component.png new file mode 100644 index 0000000000000000000000000000000000000000..e9fffa3c6fbf4856fb2a681f7e1c531aba91ba57 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/shared_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/software_as_a_service.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/software_as_a_service.png new file mode 100644 index 0000000000000000000000000000000000000000..6a728a625f9235882e77a397b75cb0069d03165b Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/software_as_a_service.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/standby_pooling_process.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/standby_pooling_process.png new file mode 100644 index 0000000000000000000000000000000000000000..2da15a5a29e616536abacdc63a754ba1e0e6138a Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/standby_pooling_process.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/stateful_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/stateful_component.png new file mode 100644 index 0000000000000000000000000000000000000000..fe8661c887908c660e35cf800016909c999edbbd Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/stateful_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/stateless_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/stateless_component.png new file mode 100644 index 0000000000000000000000000000000000000000..b3fcb134626b144aa6034a436f1789c2c875dca7 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/stateless_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/static_workload.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/static_workload.png new file mode 100644 index 0000000000000000000000000000000000000000..27b33846a36e396a748293c3a62a892a6a5153b4 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/static_workload.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/strict_consistency.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/strict_consistency.png new file mode 100644 index 0000000000000000000000000000000000000000..f066ca63fd94cdd885b365a603fdd0cf5c2a42d4 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/strict_consistency.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/tenant-isolated_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/tenant-isolated_component.png new file mode 100644 index 0000000000000000000000000000000000000000..a76a8706af8b4689aaef20cd4ebf0b3adbedf084 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/tenant-isolated_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/three-tier_cloud_application.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/three-tier_cloud_application.png new file mode 100644 index 0000000000000000000000000000000000000000..9f5f3b9aad379daf46db8c544a500a194cb8c482 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/three-tier_cloud_application.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/timeout-based_delivery.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/timeout-based_delivery.png new file mode 100644 index 0000000000000000000000000000000000000000..952053c0c51d8be343cf6773e7eef4b404763124 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/timeout-based_delivery.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/timeout-based_message_processor.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/timeout-based_message_processor.png new file mode 100644 index 0000000000000000000000000000000000000000..e3d43c422d26ec97ba0973a6f019755a4615354d Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/timeout-based_message_processor.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/transaction-based_delivery.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/transaction-based_delivery.png new file mode 100644 index 0000000000000000000000000000000000000000..8bb87d6ed157e8a9b4ea18e12834a2d846079f7f Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/transaction-based_delivery.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/transaction-based_processor.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/transaction-based_processor.png new file mode 100644 index 0000000000000000000000000000000000000000..6b62c302dc1c45fa6be6d70411ec8f23e9060927 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/transaction-based_processor.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/two-tier_cloud_application.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/two-tier_cloud_application.png new file mode 100644 index 0000000000000000000000000000000000000000..16ad175e56644c6ec63d3fd3315b8d44a4206e92 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/two-tier_cloud_application.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/unpredictable_workload.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/unpredictable_workload.png new file mode 100644 index 0000000000000000000000000000000000000000..b0115568960ceba04fea8361f90f96b3795588dd Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/unpredictable_workload.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/update_transition_process.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/update_transition_process.png new file mode 100644 index 0000000000000000000000000000000000000000..04bc947e45822075c87e701cee0e994a1726196c Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/update_transition_process.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/user_interface_component.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/user_interface_component.png new file mode 100644 index 0000000000000000000000000000000000000000..6218bb4b0441a1ba13a82475a72ac711be083234 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/user_interface_component.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/virtual_networking.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/virtual_networking.png new file mode 100644 index 0000000000000000000000000000000000000000..9bc8a06029ae7bf56c361f8095ff1a43b7582366 Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/virtual_networking.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/watchdog.png b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/watchdog.png new file mode 100644 index 0000000000000000000000000000000000000000..f636c6836e4acd2cf827f45b6db77b2e2a88746a Binary files /dev/null and b/ARCHITECT/CloudPatterns/src/main/resources/patterns/icons/watchdog.png differ diff --git a/ARCHITECT/CloudPatterns/src/main/resources/patterns/patterns-owl.ttl b/ARCHITECT/CloudPatterns/src/main/resources/patterns/patterns-owl.ttl new file mode 100644 index 0000000000000000000000000000000000000000..198c3e180d17fb56d384282621314e2d1f2c9e31 --- /dev/null +++ b/ARCHITECT/CloudPatterns/src/main/resources/patterns/patterns-owl.ttl @@ -0,0 +1,88 @@ +# +# Copyright (c) 2017 Fraunhofer FOKUS. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the +# GNU AGPL v3 which accompanies +# this distribution, and is available at +# http://www.gnu.org/licenses/agpl.txt +# +# Contributors: +# +# Simon Dutkowski Fraunhofer FOKUS +# +# Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +# + +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +@prefix dp: <http://decideh2020.eu/ns/patterns/> . + +dp: + a owl:Ontology ; + rdfs:label "DECIDE Patterns Vocabulary"@en ; + rdfs:comment "This vocabulary defines terms for patterns used in DECIDE."@en ; + dp:declare [ + dp:prefix "dp" ; + dp:namespace "http://decideh2020.eu/ns/patterns/" ; + ] . + +# DECIDE patterns vocabulary ----------------------------------------------------------- + +dp:NFR + a rdfs:Class ; + rdfs:label "Non Functional Requirement"@en ; + rdfs:comment "A non functional requirement."@en ; + rdfs:subClassOf rdfs:Resource ; + rdfs:isDefinedBy dp: . + +dp:Pattern + a rdfs:Class ; + rdfs:label "Pattern"@en ; + rdfs:comment "A pattern is a reusable solution for a common problem."@en ; + rdfs:subClassOf rdfs:Resource ; + rdfs:isDefinedBy dp: . + +dp:context + a rdf:Property ; + rdfs:label "context"@en ; + rdfs:comment "Describes the context of the pattern's problem."@en ; + rdfs:domain dp:Pattern ; + rdfs:range rdf:langString ; + rdfs:isDefinedBy dp: . + +dp:solution + a rdf:Property ; + rdfs:label "solution"@en ; + rdfs:comment "Describes the solution of the pattern's problem."@en ; + rdfs:domain dp:Pattern ; + rdfs:range rdf:langString ; + rdfs:isDefinedBy dp: . + +dp:hasImpactOn + a rdf:Property ; + rdfs:label "positive impact"@en ; + rdfs:comment "The subject has a general impact on the object."@en ; + rdfs:domain rdfs:Class ; + rdfs:range rdfs:Resource ; + rdfs:isDefinedBy dp: . + +dp:hasPositiveImpactOn + a rdf:Property ; + rdfs:subPropertyOf dp:hasImpactOn ; + rdfs:label "positive impact"@en ; + rdfs:comment "The subject has a positive impact on the object."@en ; + rdfs:domain rdfs:Class ; + rdfs:range rdfs:Resource ; + rdfs:isDefinedBy dp: . + +dp:hasNegativeImpactOn + a rdf:Property ; + rdfs:subPropertyOf dp:hasImpactOn ; + rdfs:label "negative impact"@en ; + rdfs:comment "The subject has a negative impact on the object."@en ; + rdfs:domain rdfs:Class ; + rdfs:range rdfs:Resource ; + rdfs:isDefinedBy dp: . diff --git a/ARCHITECT/CloudPatterns/src/test/java/eu/DECIDEh2020/architect/patterns/PatternsTest.java b/ARCHITECT/CloudPatterns/src/test/java/eu/DECIDEh2020/architect/patterns/PatternsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..81b4da02d61920b7132809c9e519b890e5a537d5 --- /dev/null +++ b/ARCHITECT/CloudPatterns/src/test/java/eu/DECIDEh2020/architect/patterns/PatternsTest.java @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.patterns; + +import eu.DECIDEh2020.architect.cloudpatterns.DECIDEPatterns; +import eu.DECIDEh2020.architect.cloudpatterns.DP; +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.vocabulary.DCTerms; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import java.io.InputStream; +import java.util.Collections; +import java.util.List; + +public class PatternsTest { + + private Patterns patterns; + + @BeforeTest + void initPatterns() { + patterns = Patterns.createDefaultPatterns(); + assert patterns.getModel() != null : "Expected initial patterns model."; + } + + @Test + void listPatterns() { + List<Resource> patternList = patterns.listPatterns(); + assert patternList.size() == 13 : "Expected to get a list with 13 elements."; + } + + @Test + void getPattern() { + Resource pattern = patterns.getPattern(DECIDEPatterns.BASE + "patterns/loose-coupling"); + assert pattern != null : "Expected to get loose coupling pattern."; + assert pattern.getProperty(DCTerms.title).getString().equals("Loose Coupling") : "Expected 'Loose Coupling' in title"; + } + + @Test + void getIcon() { + Resource pattern = patterns.getPattern(DECIDEPatterns.BASE + "patterns/stateless-component"); + assert pattern != null : "Expected stateless component pattern."; + Resource icon = pattern.getProperty(DP.icon).getResource(); + assert icon != null : "Expected icon property"; + InputStream stream = patterns.getIcon(icon); + assert stream != null : "Expected icon as input stream."; + } + + @Test + void getSolution() { + Resource pattern = patterns.getPattern(DECIDEPatterns.BASE + "patterns/stateless-component"); + assert pattern != null : "Expected stateless component pattern."; + assert !pattern.getProperty(DP.solution).getString().isEmpty(): "Expected non empty string."; + } + + @Test + void testCategories() { + List<Resource> patternList = patterns.getPatternsByCategory(patterns.getModel().createResource(":dummy")); + assert patternList == null : "Expected null list"; + patternList = patterns.getPatternsByCategory(DECIDEPatterns.fundamentalCategory); + assert patternList.size() == 7 : "Expected list of patterns with 7 elements."; + patternList = patterns.getPatternsByCategory(DECIDEPatterns.optimizationCategory); + assert patternList.size() == 5 : "Expected empty list of 5 patterns."; + patternList = patterns.getPatternsByCategory(DECIDEPatterns.developmentCategory); + assert patternList.size() == 2 : "Expected list of patterns with two elements."; + } + + @Test + void listNFRs() { + List<Resource> patternList = patterns.listNFRs(); + assert patternList.size() == 5 : "Expected to get a list with 5 elements."; + } + + @Test + void testInference() { + List<Resource> patternList = patterns.inferPatterns(Collections.singletonList(DECIDEPatterns.scalability)); + assert patternList.size() == 3 : "Expected to get a list with 3 elements."; + } + + @Test + void testBadInference() { + List<Resource> patternList = patterns.inferBadPatterns(Collections.singletonList(DECIDEPatterns.scalability)); + assert patternList.size() == 0 : "Expected to get a list with 0 elements."; + } +} diff --git a/ARCHITECT/CloudPatternsMicroservice/.gitlab-ci.yml b/ARCHITECT/CloudPatternsMicroservice/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..ae4e0fb1abe02921b2d89ce4e9ef8434518a2804 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/.gitlab-ci.yml @@ -0,0 +1,37 @@ +stages: + - build + - deploy + +cache: + paths: + - .m2/repository + +build: + stage: build + tags: + - docker + image: maven:3.3.9-jdk-8 + script: + - "mvn install:install-file -Dfile=3rdpartylibs/cloudpatterns-1.0-SNAPSHOT.jar -DpomFile=3rdpartylibs/pom.xml" + - "mvn clean package -B" + only: + - master + artifacts: + paths: + - target + +register: + stage: deploy + tags: + - docker + image: docker:latest + variables: + DOCKER_DRIVER: overlay2 + services: + - docker:dind + only: + - master + script: + - docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY + - docker build --pull -t "$CI_REGISTRY_IMAGE" . + - docker push "$CI_REGISTRY_IMAGE" diff --git a/ARCHITECT/CloudPatternsMicroservice/3rdpartylibs/cloudpatterns-1.0-SNAPSHOT.jar b/ARCHITECT/CloudPatternsMicroservice/3rdpartylibs/cloudpatterns-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..5e3aebd310045237383724384b5075b2d3bf4421 Binary files /dev/null and b/ARCHITECT/CloudPatternsMicroservice/3rdpartylibs/cloudpatterns-1.0-SNAPSHOT.jar differ diff --git a/ARCHITECT/CloudPatternsMicroservice/3rdpartylibs/pom.xml b/ARCHITECT/CloudPatternsMicroservice/3rdpartylibs/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..68eab2cc67264daf48fbe889e6e0c2a2789d5f8b --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/3rdpartylibs/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>eu.DECIDEh2020</groupId> + <artifactId>cloudpatterns</artifactId> + <version>1.0-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.2.3</version> + </dependency> + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>apache-jena-libs</artifactId> + <type>pom</type> + <version>3.4.0</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.11</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.6.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>${project.build.sourceEncoding}</encoding> + </configuration> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file diff --git a/ARCHITECT/CloudPatternsMicroservice/Dockerfile b/ARCHITECT/CloudPatternsMicroservice/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2dca7a426a87fff216c6f23b5e4b92d1b8548e72 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/Dockerfile @@ -0,0 +1,31 @@ +### +# vert.x docker example using a Java verticle packaged as a fatjar +# To build: +# docker build -t sample/vertx-java-fat . +# To run: +# docker run -t -i -p 8080:8080 sample/vertx-java-fat +### + +FROM openjdk:8u131-jre-alpine + +ENV VERTICLE_FILE cloudpatternscompendium-1.0-SNAPSHOT-fat.jar + +# Set the location of the verticles +ENV VERTICLE_HOME /usr/verticles + +EXPOSE 8080 + +RUN addgroup -S vertx && adduser -S -g vertx vertx + +# Copy your fat jar to the container +COPY target/$VERTICLE_FILE $VERTICLE_HOME/ + +RUN chown -R vertx $VERTICLE_HOME +RUN chmod -R g+w $VERTICLE_HOME + +USER vertx + +# Launch the verticle +WORKDIR $VERTICLE_HOME +ENTRYPOINT ["sh", "-c"] +CMD ["exec java -Xmx2048m -jar $VERTICLE_FILE -Dvertx.metrics.options.enabled=true"] diff --git a/ARCHITECT/CloudPatternsMicroservice/README.md b/ARCHITECT/CloudPatternsMicroservice/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3c24f9d09b428264a856059e2a81adbe0c1d1569 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/README.md @@ -0,0 +1,37 @@ +# DECIDE Cloud Patterns Compendium +A microservice to infer patterns from non-functional requirements in the context of DECIDE. + +## Install and run the microservice +``` +$ git clone git@gitlab.fokus.fraunhofer.de:DECIDE/CloudPatternsCompendium.git +$ cd CloudPatternsCompendium +$ mvn package +$ java -jar target/cloudpatternscompendium-<version>-fat.jar +``` + +The service is running on port `8080`. + +## API Documentation +The root context contains a convenient documentation of the REST API of this microservice. From there, you can also download a OpenAPI 3.0 specification of this interface. + +## Additional Info +### `/health` +Returns the health status of the microservice. +### `/metrics` +This requires to start the microservice with ```-Dvertx.metrics.options.enabled=true```. + +Returns some metrics of the microservice. + +## Docker +You can also build a docker image and run it in a docker container: +``` +$ docker build -t decide/cloudpatternscompendium . +$ docker run -t -i -p 8080:8080 decide/cloudpatternscompendium +``` + +## Docker hub +The latest image is also available on the FOKUS docker hub: +``` +$ docker run -t -i -p 8080:8080 dockerhub.fokus.fraunhofer.de:5000/decide/cloudpatternscompendium +``` +But you need to login first. \ No newline at end of file diff --git a/ARCHITECT/CloudPatternsMicroservice/pom.xml b/ARCHITECT/CloudPatternsMicroservice/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..16fbc4d3103119a70349ba6921e2541cccfe39ef --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/pom.xml @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>eu.DECIDEh2020</groupId> + <artifactId>cloudpatternscompendium</artifactId> + <version>1.0-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <verticle.name>eu.DECIDEh2020.architect.cloudpatterns.compendium.Server</verticle.name> + </properties> + + <dependencies> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.11</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.2.3</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-web</artifactId> + <version>3.4.2</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-web-templ-thymeleaf</artifactId> + <version>3.4.2</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-health-check</artifactId> + <version>3.4.2</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-dropwizard-metrics</artifactId> + <version>3.4.2</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-service-proxy</artifactId> + <version>3.4.2</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-codegen</artifactId> + <version>3.4.2</version> + </dependency> + <dependency> + <groupId>eu.DECIDEh2020</groupId> + <artifactId>cloudpatterns</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.6.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>${project.build.sourceEncoding}</encoding> + <useIncrementalCompilation>false</useIncrementalCompilation> + <annotationProcessors> + <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor> + </annotationProcessors> + <generatedSourcesDirectory>${project.basedir}/src/main/generated</generatedSourcesDirectory> + <compilerArgs> + <arg>-Acodegen.output=${project.basedir}/src/main</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>3.0.0</version> + <configuration> + <filesets> + <fileset> + <directory>${project.basedir}/src/main/generated</directory> + </fileset> + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <manifestEntries> + <Main-Class>io.vertx.core.Launcher</Main-Class> + <Main-Verticle>${verticle.name}</Main-Verticle> + </manifestEntries> + </transformer> + <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> + <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> + <resource>META-INF/services/io.vertx.core.spi.VerticleFactory</resource> + </transformer> + </transformers> + <artifactSet> + </artifactSet> + <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/generated/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceVertxEBProxy.java b/ARCHITECT/CloudPatternsMicroservice/src/main/generated/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceVertxEBProxy.java new file mode 100644 index 0000000000000000000000000000000000000000..d48394b8b5da79bc7bf1bc7eeb0ab3ef7ed56717 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/generated/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceVertxEBProxy.java @@ -0,0 +1,203 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you 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. +*/ + +package eu.DECIDEh2020.architect.cloudpatterns.compendium.service; + +import eu.DECIDEh2020.architect.cloudpatterns.compendium.service.CloudPatternsService; +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.Vertx; +import io.vertx.core.Future; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.function.Function; +import io.vertx.serviceproxy.ProxyHelper; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.core.json.JsonArray; +import eu.DECIDEh2020.architect.cloudpatterns.compendium.service.CloudPatternsService; +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; + +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ +@SuppressWarnings({"unchecked", "rawtypes"}) +public class CloudPatternsServiceVertxEBProxy implements CloudPatternsService { + + private Vertx _vertx; + private String _address; + private DeliveryOptions _options; + private boolean closed; + + public CloudPatternsServiceVertxEBProxy(Vertx vertx, String address) { + this(vertx, address, null); + } + + public CloudPatternsServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { + this._vertx = vertx; + this._address = address; + this._options = options; + try { + this._vertx.eventBus().registerDefaultCodec(ServiceException.class, + new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) {} + } + + public CloudPatternsService listPatterns(Handler<AsyncResult<JsonArray>> handler) { + if (closed) { + handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); + return this; + } + JsonObject _json = new JsonObject(); + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "listPatterns"); + _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { + if (res.failed()) { + handler.handle(Future.failedFuture(res.cause())); + } else { + handler.handle(Future.succeededFuture(res.result().body())); + } + }); + return this; + } + + public CloudPatternsService listNFRs(Handler<AsyncResult<JsonArray>> handler) { + if (closed) { + handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); + return this; + } + JsonObject _json = new JsonObject(); + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "listNFRs"); + _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { + if (res.failed()) { + handler.handle(Future.failedFuture(res.cause())); + } else { + handler.handle(Future.succeededFuture(res.result().body())); + } + }); + return this; + } + + public CloudPatternsService inferPatterns(JsonArray nfrs, Handler<AsyncResult<JsonArray>> handler) { + if (closed) { + handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); + return this; + } + JsonObject _json = new JsonObject(); + _json.put("nfrs", nfrs); + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "inferPatterns"); + _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { + if (res.failed()) { + handler.handle(Future.failedFuture(res.cause())); + } else { + handler.handle(Future.succeededFuture(res.result().body())); + } + }); + return this; + } + + public CloudPatternsService getPattern(String name, Handler<AsyncResult<JsonObject>> handler) { + if (closed) { + handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); + return this; + } + JsonObject _json = new JsonObject(); + _json.put("name", name); + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "getPattern"); + _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { + if (res.failed()) { + handler.handle(Future.failedFuture(res.cause())); + } else { + handler.handle(Future.succeededFuture(res.result().body())); + } + }); + return this; + } + + + private List<Character> convertToListChar(JsonArray arr) { + List<Character> list = new ArrayList<>(); + for (Object obj: arr) { + Integer jobj = (Integer)obj; + list.add((char)(int)jobj); + } + return list; + } + + private Set<Character> convertToSetChar(JsonArray arr) { + Set<Character> set = new HashSet<>(); + for (Object obj: arr) { + Integer jobj = (Integer)obj; + set.add((char)(int)jobj); + } + return set; + } + + private <T> Map<String, T> convertMap(Map map) { + if (map.isEmpty()) { + return (Map<String, T>) map; + } + + Object elem = map.values().stream().findFirst().get(); + if (!(elem instanceof Map) && !(elem instanceof List)) { + return (Map<String, T>) map; + } else { + Function<Object, T> converter; + if (elem instanceof List) { + converter = object -> (T) new JsonArray((List) object); + } else { + converter = object -> (T) new JsonObject((Map) object); + } + return ((Map<String, T>) map).entrySet() + .stream() + .collect(Collectors.toMap(Map.Entry::getKey, converter::apply)); + } + } + private <T> List<T> convertList(List list) { + if (list.isEmpty()) { + return (List<T>) list; + } + + Object elem = list.get(0); + if (!(elem instanceof Map) && !(elem instanceof List)) { + return (List<T>) list; + } else { + Function<Object, T> converter; + if (elem instanceof List) { + converter = object -> (T) new JsonArray((List) object); + } else { + converter = object -> (T) new JsonObject((Map) object); + } + return (List<T>) list.stream().map(converter).collect(Collectors.toList()); + } + } + private <T> Set<T> convertSet(List list) { + return new HashSet<T>(convertList(list)); + } +} \ No newline at end of file diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/generated/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceVertxProxyHandler.java b/ARCHITECT/CloudPatternsMicroservice/src/main/generated/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceVertxProxyHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..9efc986ba094eeb4ffe661c8d2fe2e46412c105c --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/generated/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceVertxProxyHandler.java @@ -0,0 +1,248 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you 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. +*/ + +package eu.DECIDEh2020.architect.cloudpatterns.compendium.service; + +import eu.DECIDEh2020.architect.cloudpatterns.compendium.service.CloudPatternsService; +import io.vertx.core.Vertx; +import io.vertx.core.Handler; +import io.vertx.core.AsyncResult; +import io.vertx.core.eventbus.EventBus; +import io.vertx.core.eventbus.Message; +import io.vertx.core.eventbus.MessageConsumer; +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.eventbus.ReplyException; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.Collection; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import io.vertx.serviceproxy.ProxyHelper; +import io.vertx.serviceproxy.ProxyHandler; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.core.json.JsonArray; +import eu.DECIDEh2020.architect.cloudpatterns.compendium.service.CloudPatternsService; +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; + +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ +@SuppressWarnings({"unchecked", "rawtypes"}) +public class CloudPatternsServiceVertxProxyHandler extends ProxyHandler { + + public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes + + private final Vertx vertx; + private final CloudPatternsService service; + private final long timerID; + private long lastAccessed; + private final long timeoutSeconds; + + public CloudPatternsServiceVertxProxyHandler(Vertx vertx, CloudPatternsService service) { + this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); + } + + public CloudPatternsServiceVertxProxyHandler(Vertx vertx, CloudPatternsService service, long timeoutInSecond) { + this(vertx, service, true, timeoutInSecond); + } + + public CloudPatternsServiceVertxProxyHandler(Vertx vertx, CloudPatternsService service, boolean topLevel, long timeoutSeconds) { + this.vertx = vertx; + this.service = service; + this.timeoutSeconds = timeoutSeconds; + try { + this.vertx.eventBus().registerDefaultCodec(ServiceException.class, + new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) {} + if (timeoutSeconds != -1 && !topLevel) { + long period = timeoutSeconds * 1000 / 2; + if (period > 10000) { + period = 10000; + } + this.timerID = vertx.setPeriodic(period, this::checkTimedOut); + } else { + this.timerID = -1; + } + accessed(); + } + + public MessageConsumer<JsonObject> registerHandler(String address) { + MessageConsumer<JsonObject> consumer = vertx.eventBus().<JsonObject>consumer(address).handler(this); + this.setConsumer(consumer); + return consumer; + } + + private void checkTimedOut(long id) { + long now = System.nanoTime(); + if (now - lastAccessed > timeoutSeconds * 1000000000) { + close(); + } + } + + @Override + public void close() { + if (timerID != -1) { + vertx.cancelTimer(timerID); + } + super.close(); + } + + private void accessed() { + this.lastAccessed = System.nanoTime(); + } + + public void handle(Message<JsonObject> msg) { + try { + JsonObject json = msg.body(); + String action = msg.headers().get("action"); + if (action == null) { + throw new IllegalStateException("action not specified"); + } + accessed(); + switch (action) { + + + case "listPatterns": { + service.listPatterns(createHandler(msg)); + break; + } + case "listNFRs": { + service.listNFRs(createHandler(msg)); + break; + } + case "inferPatterns": { + service.inferPatterns((io.vertx.core.json.JsonArray)json.getValue("nfrs"), createHandler(msg)); + break; + } + case "getPattern": { + service.getPattern((java.lang.String)json.getValue("name"), createHandler(msg)); + break; + } + default: { + throw new IllegalStateException("Invalid action: " + action); + } + } + } catch (Throwable t) { + msg.reply(new ServiceException(500, t.getMessage())); + throw t; + } + } + + private <T> Handler<AsyncResult<T>> createHandler(Message msg) { + return res -> { + if (res.failed()) { + if (res.cause() instanceof ServiceException) { + msg.reply(res.cause()); + } else { + msg.reply(new ServiceException(-1, res.cause().getMessage())); + } + } else { + if (res.result() != null && res.result().getClass().isEnum()) { + msg.reply(((Enum) res.result()).name()); + } else { + msg.reply(res.result()); + } + } + }; + } + + private <T> Handler<AsyncResult<List<T>>> createListHandler(Message msg) { + return res -> { + if (res.failed()) { + if (res.cause() instanceof ServiceException) { + msg.reply(res.cause()); + } else { + msg.reply(new ServiceException(-1, res.cause().getMessage())); + } + } else { + msg.reply(new JsonArray(res.result())); + } + }; + } + + private <T> Handler<AsyncResult<Set<T>>> createSetHandler(Message msg) { + return res -> { + if (res.failed()) { + if (res.cause() instanceof ServiceException) { + msg.reply(res.cause()); + } else { + msg.reply(new ServiceException(-1, res.cause().getMessage())); + } + } else { + msg.reply(new JsonArray(new ArrayList<>(res.result()))); + } + }; + } + + private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) { + return res -> { + if (res.failed()) { + if (res.cause() instanceof ServiceException) { + msg.reply(res.cause()); + } else { + msg.reply(new ServiceException(-1, res.cause().getMessage())); + } + } else { + JsonArray arr = new JsonArray(); + for (Character chr: res.result()) { + arr.add((int) chr); + } + msg.reply(arr); + } + }; + } + + private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) { + return res -> { + if (res.failed()) { + if (res.cause() instanceof ServiceException) { + msg.reply(res.cause()); + } else { + msg.reply(new ServiceException(-1, res.cause().getMessage())); + } + } else { + JsonArray arr = new JsonArray(); + for (Character chr: res.result()) { + arr.add((int) chr); + } + msg.reply(arr); + } + }; + } + + private <T> Map<String, T> convertMap(Map map) { + return (Map<String, T>)map; + } + + private <T> List<T> convertList(List list) { + return (List<T>)list; + } + + private <T> Set<T> convertSet(List list) { + return new HashSet<T>((List<T>)list); + } +} \ No newline at end of file diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/CloudPatternsCompendiumVerticle.java b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/CloudPatternsCompendiumVerticle.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8f236c615de0b7f8574ff0a0cdccf9a388e7c3 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/CloudPatternsCompendiumVerticle.java @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns.compendium; + +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; +import eu.DECIDEh2020.architect.cloudpatterns.compendium.service.CloudPatternsService; +import io.vertx.core.AbstractVerticle; +import io.vertx.core.Future; +import io.vertx.serviceproxy.ProxyHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CloudPatternsCompendiumVerticle extends AbstractVerticle { + private Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public void start(Future<Void> startFuture) throws Exception { + try { + Patterns patterns = Patterns.createDefaultPatterns(); + CloudPatternsService patternsService = CloudPatternsService.create(patterns, ready -> { + if (ready.succeeded()) { + ProxyHelper.registerService(CloudPatternsService.class, vertx, ready.result(), "cloudpatterns"); + startFuture.complete(); + } else { + startFuture.fail(ready.cause()); + } + }); + } catch (Exception e) { + log.error("creating default patterns", e); + startFuture.fail(e); + } + } + +} diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/Server.java b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/Server.java new file mode 100644 index 0000000000000000000000000000000000000000..d00dac1b034c807fb5b54be4ab45674bf120d4b0 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/Server.java @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns.compendium; + +import eu.DECIDEh2020.architect.cloudpatterns.compendium.service.CloudPatternsService; +import io.vertx.core.*; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.dropwizard.MetricsService; +import io.vertx.ext.healthchecks.HealthCheckHandler; +import io.vertx.ext.healthchecks.Status; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.handler.BodyHandler; +import io.vertx.ext.web.handler.StaticHandler; +import io.vertx.ext.web.handler.TemplateHandler; +import io.vertx.ext.web.templ.TemplateEngine; +import io.vertx.ext.web.templ.ThymeleafTemplateEngine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; + +public class Server extends AbstractVerticle { + private Logger log = LoggerFactory.getLogger(getClass()); + + public static void main(String[] args) { + Launcher.executeCommand("run", Server.class.getName()); + } + + private CloudPatternsService patternsService; + + @Override + public void start(Future<Void> startFuture) throws Exception { + MetricsService metrics = MetricsService.create(vertx); + + vertx.deployVerticle(CloudPatternsCompendiumVerticle.class.getName(), new DeploymentOptions().setWorker(true), res -> { + if (res.succeeded()) { + patternsService = CloudPatternsService.createProxy(vertx, "cloudpatterns"); + + Router router = Router.router(vertx); + router.route().handler(BodyHandler.create()); + + router.route("/").handler(StaticHandler.create()); + router.route("/openapi/*").handler(StaticHandler.create("openapi")); + router.route("/resources/*").handler(StaticHandler.create("patterns")); + + HealthCheckHandler hch = HealthCheckHandler.create(vertx); + hch.register("simple-ok", future -> future.complete(Status.OK())); + hch.register("status", future -> future.complete(Status.OK(new JsonObject().put("build", 1)))); + router.get("/health*").handler(hch); + + router.get("/metrics").produces("application/json").handler(routingContext -> { + JsonObject m = metrics.getMetricsSnapshot(vertx); + if (m != null) { + routingContext.response().setStatusCode(200).end(m.encodePrettily()); + } else { + routingContext.response().setStatusCode(503).end(); + } + }); + + TemplateEngine engine = ThymeleafTemplateEngine.create(); + router.get("/templates/*").handler(TemplateHandler.create(engine)); + + router.get("/nfrs").produces("application/json").handler(routingContext -> { + patternsService.listNFRs(reply -> { + if (reply.succeeded()) { + routingContext.response().setStatusCode(200); + routingContext.response().end(reply.result().encodePrettily()); + } else { + routingContext.fail(500); + } + }); + }); + + router.get("/patterns").produces("application/json").handler(routingContext -> { + patternsService.listPatterns(reply -> { + if (reply.succeeded()) { + routingContext.response().setStatusCode(200); + routingContext.response().end(reply.result().encodePrettily()); + } else { + routingContext.fail(500); + } + }); + }); + + router.get("/patterns/:pattern").produces("text/html").handler(routingContext -> { + String patternName = routingContext.request().getParam("pattern"); + patternsService.getPattern(patternName, reply -> { + if (reply.succeeded()) { + routingContext.put("pattern", reply.result()); + routingContext.reroute("/templates/pattern.html"); + } else { + routingContext.response().setStatusCode(404); + routingContext.response().end("Pattern not found."); + } + }); + }); + + router.get("/patterns/:pattern").produces("application/json").handler(routingContext -> { + String patternName = routingContext.request().getParam("pattern"); + patternsService.getPattern(patternName, reply -> { + if (reply.succeeded()) { + routingContext.response().setStatusCode(200); + routingContext.response().end(reply.result().encodePrettily()); + } else { + routingContext.response().setStatusCode(404); + routingContext.response().end("Pattern not found."); + } + }); + }); + + router.get("/inferred/patterns").produces("application/json").handler(routingContext -> { + String param = routingContext.request().getParam("nfr"); + if (param != null) { + String[] nfrs = param.split(","); + patternsService.inferPatterns(new JsonArray(Arrays.asList(nfrs)),reply -> { + if (reply.succeeded()) { + routingContext.response().setStatusCode(200); + routingContext.response().end(reply.result().encodePrettily()); + } else { + routingContext.fail(500); + } + }); + } else { + routingContext.fail(500); + } + }); + + vertx.createHttpServer().requestHandler(router::accept).listen(8080); + + startFuture.complete(); + } else { + startFuture.fail(res.result()); + } + }); + } + +} diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/converters/NFRConverter.java b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/converters/NFRConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..cfd913c3c3dc4c844c14237f45e3d0c8be727ded --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/converters/NFRConverter.java @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns.compendium.converters; + +import io.vertx.core.json.JsonObject; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.vocabulary.DCTerms; + +public class NFRConverter { + + public static Resource toResource(JsonObject nfr) { + return null; + } + + public static JsonObject toJson(Resource nfr) { + JsonObject obj = new JsonObject(); + obj.put("uriref", nfr.getURI()); + obj.put("title", nfr.getProperty(DCTerms.title).getString()); + obj.put("description", nfr.getProperty(DCTerms.description).getString()); + return obj; + } + +} diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/converters/PatternConverter.java b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/converters/PatternConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..64141e7f7c3fa4f36f8ff94cd7cc894528b99ea4 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/converters/PatternConverter.java @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns.compendium.converters; + +import eu.DECIDEh2020.architect.cloudpatterns.DP; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.sparql.vocabulary.FOAF; +import org.apache.jena.vocabulary.DCTerms; + +public class PatternConverter { + + public static Resource toResource(JsonObject nfr) { + return null; + } + + public static JsonObject toJson(Resource pattern) { + JsonObject obj = new JsonObject(); + obj.put("uriref", pattern.getURI()); + obj.put("title", pattern.getRequiredProperty(DCTerms.title).getString()); + if (pattern.hasProperty(DCTerms.type)) { + JsonArray array = new JsonArray(); + pattern.listProperties(DCTerms.type).forEachRemaining(stmt -> array.add(stmt.getResource().getURI())); + obj.put("categories", array); + } + if (pattern.hasProperty(DP.icon)) { + obj.put("icon", pattern.getPropertyResourceValue(DP.icon).getLocalName()); + } + if (pattern.hasProperty(DCTerms.subject)) { + obj.put("subject", pattern.getProperty(DCTerms.subject).getString()); + } + if (pattern.hasProperty(DCTerms.description)) { + obj.put("description", pattern.getProperty(DCTerms.description).getString()); + } + if (pattern.hasProperty(DP.context)) { + obj.put("context", pattern.getProperty(DP.context).getString()); + } + if (pattern.hasProperty(DP.solution)) { + obj.put("solution", pattern.getProperty(DP.solution).getString()); + } + if (pattern.hasProperty(DCTerms.license)) { + obj.put("license", pattern.getPropertyResourceValue(DCTerms.license).getLocalName()); + } + if (pattern.hasProperty(FOAF.page)) { + JsonObject page = new JsonObject(); + Resource p = pattern.getPropertyResourceValue(FOAF.page); + page.put("topic", p.getProperty(FOAF.topic).getString()); + page.put("primaryTopic", p.getPropertyResourceValue(FOAF.primaryTopic).getURI()); + obj.put("page", page); + } + if (pattern.hasProperty(DCTerms.relation)) { + JsonArray array = new JsonArray(); + pattern.listProperties(DCTerms.relation).forEachRemaining(stmt -> array.add(stmt.getResource().getURI())); + obj.put("relations", array); + } + if (pattern.hasProperty(DP.hasImpactOn)) { + JsonArray array = new JsonArray(); + pattern.listProperties(DP.hasImpactOn).forEachRemaining(stmt -> array.add(stmt.getResource().getURI())); + obj.put("impacts", array); + } + if (pattern.hasProperty(DP.hasPositiveImpactOn)) { + JsonArray array = new JsonArray(); + pattern.listProperties(DP.hasPositiveImpactOn).forEachRemaining(stmt -> array.add(stmt.getResource().getURI())); + obj.put("positive-impacts", array); + } + if (pattern.hasProperty(DP.hasNegativeImpactOn)) { + JsonArray array = new JsonArray(); + pattern.listProperties(DP.hasNegativeImpactOn).forEachRemaining(stmt -> array.add(stmt.getResource().getURI())); + obj.put("negative-impacts", array); + } + return obj; + } + +} diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsService.java b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsService.java new file mode 100644 index 0000000000000000000000000000000000000000..98409d67acd23d2b1902d0059e85536897af538a --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsService.java @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns.compendium.service; + +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; +import io.vertx.codegen.annotations.Fluent; +import io.vertx.codegen.annotations.ProxyGen; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; + +@ProxyGen +public interface CloudPatternsService { + + static CloudPatternsService create(Patterns patterns, Handler<AsyncResult<CloudPatternsService>> readyHandler) { + return new CloudPatternsServiceImpl(patterns, readyHandler); + } + + static CloudPatternsService createProxy(Vertx vertx, String address) { + return new CloudPatternsServiceVertxEBProxy(vertx, address); + } + + @Fluent + CloudPatternsService listPatterns(Handler<AsyncResult<JsonArray>> handler); + + @Fluent + CloudPatternsService listNFRs(Handler<AsyncResult<JsonArray>> handler); + + @Fluent + CloudPatternsService inferPatterns(JsonArray nfrs, Handler<AsyncResult<JsonArray>> handler); + + @Fluent + CloudPatternsService getPattern(String name, Handler<AsyncResult<JsonObject>> handler); + +} diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceImpl.java b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..33c9111043963b6b666eedfc12666676856f8cb4 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/CloudPatternsServiceImpl.java @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* GNU AGPL v3 which accompanies +* this distribution, and is available at +* http://www.gnu.org/licenses/agpl.txt +* +* Contributors: +* +* Simon Dutkowski Fraunhofer FOKUS +* +* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +package eu.DECIDEh2020.architect.cloudpatterns.compendium.service; + +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; +import eu.DECIDEh2020.architect.cloudpatterns.compendium.converters.NFRConverter; +import eu.DECIDEh2020.architect.cloudpatterns.compendium.converters.PatternConverter; +import io.vertx.core.AsyncResult; +import io.vertx.core.Future; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import org.apache.jena.rdf.model.Resource; + +import java.util.List; +import java.util.stream.Collectors; + +class CloudPatternsServiceImpl implements CloudPatternsService { + + Patterns patterns; + + CloudPatternsServiceImpl(Patterns patterns, Handler<AsyncResult<CloudPatternsService>> readyHandler) { + this.patterns = patterns; + readyHandler.handle(Future.succeededFuture(this)); + } + + @Override + public CloudPatternsService listPatterns(Handler<AsyncResult<JsonArray>> handler) { + List<Resource> result = patterns.listPatterns(); + handler.handle(Future.succeededFuture(new JsonArray(result.stream().map(PatternConverter::toJson).collect(Collectors.toList())))); + return this; + } + + @Override + public CloudPatternsService listNFRs(Handler<AsyncResult<JsonArray>> handler) { + List<Resource> result = patterns.listNFRs(); + handler.handle(Future.succeededFuture(new JsonArray(result.stream().map(NFRConverter::toJson).collect(Collectors.toList())))); + return this; + } + + @Override + public CloudPatternsService inferPatterns(JsonArray nfrs, Handler<AsyncResult<JsonArray>> handler) { + List<Resource> result = patterns.inferPatterns(nfrs.stream().map(nfr -> { + String uriref = nfr.toString(); + if (!uriref.startsWith("http://decideh2020.eu/resources/patterns/")) { + uriref = "http://decideh2020.eu/resources/patterns/" + uriref.toLowerCase(); + } + return patterns.getModel().createResource(uriref); + }).collect(Collectors.toList())); + handler.handle(Future.succeededFuture(new JsonArray(result.stream().map(PatternConverter::toJson).collect(Collectors.toList())))); + return this; + } + + @Override + public CloudPatternsService getPattern(String name, Handler<AsyncResult<JsonObject>> handler) { + Resource pattern = patterns.getModel().getResource("http://decideh2020.eu/resources/patterns/" + name); + if (pattern != null) { + handler.handle(Future.succeededFuture(PatternConverter.toJson(pattern))); + } else { + handler.handle(Future.failedFuture("Pattern not found.")); + } + return this; + } + +} diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/package-info.java b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..43f47cf898709b3e3ba5e73a6028ebeca7157ecf --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/java/eu/DECIDEh2020/architect/cloudpatterns/compendium/service/package-info.java @@ -0,0 +1,4 @@ +@ModuleGen(groupPackage = "eu.DECIDEh2020.architect.cloudpatterns", name = "cloudpatternscompendium") +package eu.DECIDEh2020.architect.cloudpatterns.compendium.service; + +import io.vertx.codegen.annotations.ModuleGen; \ No newline at end of file diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/resources/logback.xml b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..ae277159e62f49cf9493b128ea8549ad4fd18866 --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/logback.xml @@ -0,0 +1,15 @@ +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> + </encoder> + </appender> + + <logger name="eu.DECIDEh2020" level="TRACE" /> + + <root level="INFO"> + <appender-ref ref="STDOUT"/> + </root> +</configuration> diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/resources/openapi/images/logoDecide_300ppp.jpg b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/openapi/images/logoDecide_300ppp.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9b4c3f9bdc961c0c3f2f0032856e7a241c06d442 Binary files /dev/null and b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/openapi/images/logoDecide_300ppp.jpg differ diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/resources/openapi/openapi.json b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/openapi/openapi.json new file mode 100644 index 0000000000000000000000000000000000000000..4d5bfed8544501854b52ce0138906094610ad61a --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/openapi/openapi.json @@ -0,0 +1,204 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0", + "title": "Cloud Patterns Compendium Microservice", + "x-logo": { + "url": "openapi/images/logoDecide_300ppp.jpg" + } + }, + "servers": [ + { + "url": "/", + "description": "The API context" + } + ], + "paths": { + "/nfrs": { + "get": { + "description": "Returns the list of all NFRs.", + "summary": "List all NFRs", + "operationId": "listNFRs", + "responses": { + "200": { + "description": "List of NFRs.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/NFR" + } + } + } + } + } + } + } + }, + "/patterns": { + "get": { + "description": "Returns the list of all patterns.", + "summary": "List all Patterns", + "operationId": "listPatterns", + "responses": { + "200": { + "description": "List of all patterns.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pattern" + } + } + } + } + } + } + } + }, + "/inferred/patterns": { + "get": { + "description": "Returns a list patterns inferred from NFRs.", + "summary": "Infer Patterns from NFRs", + "operationId": "inferPatterns", + "parameters": [ + { + "name": "nfr", + "in": "query", + "description": "A list of case insensitive non functional requirements.", + "required": true, + "type": "array", + "example": "nfr=scalability,availability,performance" + } + ], + "responses": { + "200": { + "description": "List of inferred patterns.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pattern" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Pattern": { + "description": "A representation of a pattern.", + "type": "object", + "required": [ + "name", + "title", + "uriref" + ], + "properties": { + "uriref": { + "type": "string", + "format": "uri" + }, + "title": { + "type": "string" + }, + "categories": { + "type": "array", + "items": { + "type": "string", + "format": "uri" + } + }, + "icon": { + "type": "string", + "format": "uri" + }, + "subject": { + "type": "string" + }, + "description": { + "type": "string" + }, + "context": { + "type": "string" + }, + "solution": { + "type": "string" + }, + "license": { + "type": "string" + }, + "page": { + "$ref": "#/components/schemas/Page" + }, + "relation": { + "type": "string" + }, + "impacts": { + "type": "array", + "items": { + "type": "string", + "format": "uri" + } + }, + "positive-impacts": { + "type": "array", + "items": { + "type": "string", + "format": "uri" + } + }, + "negative-impacts": { + "type": "array", + "items": { + "type": "string", + "format": "uri" + } + } + } + }, + "NFR": { + "description": "A representation of a non functional requirement.", + "type": "object", + "required": [ + "uriref", + "title" + ], + "properties": { + "uriref": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + } + } + }, + "Page": { + "description": "A description of a page reference.", + "type": "object", + "required": [ + "primaryTopic" + ], + "properties": { + "topic": { + "type": "string" + }, + "primaryTopic": { + "type": "string", + "format": "uri" + } + } + } + } + } +} diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/resources/templates/pattern.html b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/templates/pattern.html new file mode 100644 index 0000000000000000000000000000000000000000..32dc35d9005a6befe3d583807d24d7fb8f1d479a --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/templates/pattern.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8" /> + <title>DECIDE Cloud Pattern</title> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"> + + <style> + .footer { + position: absolute; + bottom: 0; + width: 100%; + /* Set the fixed height of the footer here */ + height: 40px; + font-size: 80%; + border-color: transparent + } + </style> +</head> +<body> + <div class="container" data-th-object="${context.get('pattern')}"> + <p/> + <div class="media"> + <img class="d-flex align-self-end mr-3" height="100" data-th-src="@{'~/resources/icons/' + *{getString('icon')}}" /> + <div class="media-body"> + <h1 class="mt-0" data-th-text="*{getString('title')}">Pattern Title</h1> + <p data-th-text="*{getString('description')}">Description</p> + </div> + </div> + <hr/> + <h3>Problem</h3> + <div class="jumbotron"> + <p class="lead" data-th-text="*{getString('subject')}">Subject</p> + </div> + <h2>Context</h2> + <p data-th-text="*{getString('context')}">Context</p> + <h3>Solution</h3> + <p data-th-text="*{getString('solution')}">Solution</p> + <p>From: <a data-th-href="*{getJsonObject('page').getString('primaryTopic')}" ><span data-th-text="*{getJsonObject('page').getString('topic')}">Topic</span></a></p> + </div> + + <footer class="footer"> + <div class="container text-center"> + <p class="text-muted"> + © Fraunhofer FOKUS 2016 + </p> + </div> + </footer> + + <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script> + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script> +</body> +</html> \ No newline at end of file diff --git a/ARCHITECT/CloudPatternsMicroservice/src/main/resources/webroot/index.html b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/webroot/index.html new file mode 100644 index 0000000000000000000000000000000000000000..59f0195c0594b0e11baf07f2f9d39d2d57abdd1e --- /dev/null +++ b/ARCHITECT/CloudPatternsMicroservice/src/main/resources/webroot/index.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> +<head> + <title>Cloud Patterns Compendium</title> + <!-- needed for adaptive design --> + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + + <!-- + ReDoc doesn't change outer page styles + --> + <style> + body { + margin: 0; + padding: 0; + } + </style> +</head> +<body> +<redoc spec-url='openapi/openapi.json'></redoc> +<script src="https://unpkg.com/redoc/bundles/redoc.standalone.js"></script> +</body> +</html> diff --git a/ARCHITECT/EclipsePlugin/.gitignore b/ARCHITECT/EclipsePlugin/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a29c26e7379f3550175b524822ea334b1bc0232b --- /dev/null +++ b/ARCHITECT/EclipsePlugin/.gitignore @@ -0,0 +1,3 @@ +*.class +/target/ +*/bin/ \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/LICENSE.txt b/ARCHITECT/EclipsePlugin/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..3276fe0690e8305937007c7653ffaf71fb65cf7f --- /dev/null +++ b/ARCHITECT/EclipsePlugin/LICENSE.txt @@ -0,0 +1,281 @@ +Copyright (C) 2017 Fraunhofer FOKUS. + +This program is free software: you can redistribute it and/or modify +it under the terms of the Eclipse Public License version 2.0. + +Eclipse Public License - v 2.0 +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION +OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial content +Distributed under this Agreement, and + +b) in the case of each subsequent Contributor: +i) changes to the Program, and +ii) additions to the Program; +where such changes and/or additions to the Program originate from +and are Distributed by that particular Contributor. A Contribution +"originates" from a Contributor if it was added to the Program by +such Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include changes or additions to the Program that +are not Modified Works. + +"Contributor" means any person or entity that Distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone +or when combined with the Program. + +"Program" means the Contributions Distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement +or any Secondary License (as applicable), including Contributors. + +"Derivative Works" shall mean any work, whether in Source Code or other +form, that is based on (or derived from) the Program and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. + +"Modified Works" shall mean any work in Source Code or other form that +results from an addition to, deletion from, or modification of the +contents of the Program, including, for purposes of clarity any new file +in Source Code form that contains any contents of the Program. Modified +Works shall not include works that contain only declarations, +interfaces, types, classes, structures, or files of the Program solely +in each case in order to link to, bind by name, or subclass the Program +or Modified Works thereof. + +"Distribute" means the acts of a) distributing or b) making available +in any manner that enables the transfer of a copy. + +"Source Code" means the form of a Program preferred for making +modifications, including but not limited to software source code, +documentation source, and configuration files. + +"Secondary License" means either the GNU General Public License, +Version 2.0, or any later versions of that license, including any +exceptions or additional permissions as identified by the initial +Contributor. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare Derivative Works of, publicly display, +publicly perform, Distribute and sublicense the Contribution of such +Contributor, if any, and such Derivative Works. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, +if any, in Source Code or other form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. +Each Contributor disclaims any liability to Recipient for claims +brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby +assumes sole responsibility to secure any other intellectual +property rights needed, if any. For example, if a third party +patent license is required to allow Recipient to Distribute the +Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has +sufficient copyright rights in its Contribution, if any, to grant +the copyright license set forth in this Agreement. + +e) Notwithstanding the terms of any Secondary License, no +Contributor makes additional grants to any Recipient (other than +those set forth in this Agreement) as a result of such Recipient's +receipt of the Program under the terms of a Secondary License +(if permitted under the terms of Section 3). + +3. REQUIREMENTS + +3.1 If a Contributor Distributes the Program in any form, then: + +a) the Program must also be made available as Source Code, in +accordance with section 3.2, and the Contributor must accompany +the Program with a statement that the Source Code for the Program +is available under this Agreement, and informs Recipients how to +obtain it in a reasonable manner on or through a medium customarily +used for software exchange; and + +b) the Contributor may Distribute the Program under a license +different than this Agreement, provided that such license: +i) effectively disclaims on behalf of all other Contributors all +warranties and conditions, express and implied, including +warranties or conditions of title and non-infringement, and +implied warranties or conditions of merchantability and fitness +for a particular purpose; + +ii) effectively excludes on behalf of all other Contributors all +liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits; + +iii) does not attempt to limit or alter the recipients' rights +in the Source Code under section 3.2; and + +iv) requires any subsequent distribution of the Program by any +party to be under a license that satisfies the requirements +of this section 3. + +3.2 When the Program is Distributed as Source Code: + +a) it must be made available under this Agreement, or if the +Program (i) is combined with other material in a separate file or +files made available under a Secondary License, and (ii) the initial +Contributor attached to the Source Code the notice described in +Exhibit A of this Agreement, then the Program may be made available +under the terms of such Secondary Licenses, and + +b) a copy of this Agreement must be included with each copy of +the Program. + +3.3 Contributors may not remove or alter any copyright, patent, +trademark, attribution notices, disclaimers of warranty, or limitations +of liability ("notices") contained within the Program from any copy of +the Program which they Distribute, provided that Contributors may add +their own appropriate notices. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, +the Contributor who includes the Program in a commercial product +offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes +the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every +other Contributor ("Indemnified Contributor") against any losses, +damages and costs (collectively "Losses") arising from claims, lawsuits +and other legal actions brought by a third party against the Indemnified +Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program +in a commercial product offering. The obligations in this section do not +apply to any claims or Losses relating to any actual or alleged +intellectual property infringement. In order to qualify, an Indemnified +Contributor must: a) promptly notify the Commercial Contributor in +writing of such claim, and b) allow the Commercial Contributor to control, +and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those performance +claims and warranties, and if a court requires any other Contributor to +pay any damages as a result, the Commercial Contributor must pay +those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF +TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE. Each Recipient is solely responsible for determining the +appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs +or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS +SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software +or hardware) infringes such Recipient's patent(s), then such Recipient's +rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign the +responsibility to serve as the Agreement Steward to a suitable separate +entity. Each new version of the Agreement will be given a distinguishing +version number. The Program (including Contributions) may always be +Distributed subject to the version of the Agreement under which it was +received. In addition, after a new version of the Agreement is published, +Contributor may elect to Distribute the Program (including its +Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient +receives no rights or licenses to the intellectual property of any +Contributor under this Agreement, whether expressly, by implication, +estoppel or otherwise. All rights in the Program not expressly granted +under this Agreement are reserved. Nothing in this Agreement is intended +to be enforceable by any entity that is not a Contributor or Recipient. +No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice + +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth +in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), +version(s), and exceptions or additional permissions here}." + +Simply including a copy of this Agreement, including this Exhibit A +is not sufficient to license the Source Code under Secondary Licenses. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to +look for such a notice. + +You may add additional accurate notices of copyright ownership. \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/feature/.gitignore b/ARCHITECT/EclipsePlugin/feature/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b83d22266ac8aa2f8df2edef68082c789727841d --- /dev/null +++ b/ARCHITECT/EclipsePlugin/feature/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/ARCHITECT/EclipsePlugin/feature/.project b/ARCHITECT/EclipsePlugin/feature/.project new file mode 100644 index 0000000000000000000000000000000000000000..d82803dc16954b4b7f7ef8d7aa3c6dbbf176c736 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/feature/.project @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>feature</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.pde.FeatureBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.pde.FeatureNature</nature> + </natures> +</projectDescription> diff --git a/ARCHITECT/EclipsePlugin/feature/.settings/org.eclipse.core.resources.prefs b/ARCHITECT/EclipsePlugin/feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000000000000000000000000000000000..99f26c0203a7844de00dbfc56e6a35d8ed3c022c --- /dev/null +++ b/ARCHITECT/EclipsePlugin/feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/ARCHITECT/EclipsePlugin/feature/.settings/org.eclipse.m2e.core.prefs b/ARCHITECT/EclipsePlugin/feature/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..f897a7f1cb2389f85fe6381425d29f0a9866fb65 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/feature/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ARCHITECT/EclipsePlugin/feature/build.properties b/ARCHITECT/EclipsePlugin/feature/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..64f93a9f0b7328eb563aa5ad6cec7f828020e124 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/ARCHITECT/EclipsePlugin/feature/feature.xml b/ARCHITECT/EclipsePlugin/feature/feature.xml new file mode 100644 index 0000000000000000000000000000000000000000..a6a9b00a8765caa0dbc74c362d4562d888f4bffb --- /dev/null +++ b/ARCHITECT/EclipsePlugin/feature/feature.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feature + id="eu.DECIDEh2020.architect.feature" + label="Architect" + version="1.0.0.qualifier"> + + <description url="http://decide-h2020.eu/"> + ARCHITECT description + </description> + + <copyright url="http://www.example.com/copyright"> + (C) 2017 + </copyright> + + <license url="http://www.example.com/license"> + ARCHITECT license agreement + </license> + + <plugin + id="eu.DECIDEh2020.architect.plugin" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + +</feature> diff --git a/ARCHITECT/EclipsePlugin/feature/pom.xml b/ARCHITECT/EclipsePlugin/feature/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..f87c13d44fe5dae3fcb3d8c87ab446e2630662b7 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/feature/pom.xml @@ -0,0 +1,11 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <artifactId>eu.DECIDEh2020.architect.feature</artifactId> + <packaging>eclipse-feature</packaging> + <parent> + <groupId>de.decideh2020</groupId> + <artifactId>eu.DECIDEh2020.architect.releng</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../releng</relativePath> + </parent> +</project> \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/plugin/.classpath b/ARCHITECT/EclipsePlugin/plugin/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..6096f799a34b4b7518a0caaaadce43849424883e --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/.classpath @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="libs"/> + <classpathentry kind="lib" path="libs/AppManager.jar"/> + <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="lib" path="libs/jena/lib/collection-0.7.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/commons-cli-1.4.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/commons-codec-1.10.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/commons-csv-1.4.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/commons-io-2.5.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/commons-lang3-3.4.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/httpclient-4.5.3.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/httpclient-cache-4.5.3.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/httpcore-4.4.6.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jackson-annotations-2.8.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jackson-core-2.8.6.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jackson-databind-2.8.6.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jcl-over-slf4j-1.7.25.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jena-arq-3.4.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jena-base-3.4.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jena-cmds-3.4.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jena-core-3.4.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jena-iri-3.4.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jena-rdfconnection-3.4.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jena-shaded-guava-3.4.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jena-tdb-3.4.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/jsonld-java-0.10.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/libthrift-0.9.3.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/log4j-1.2.17.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/slf4j-api-1.7.25.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/slf4j-log4j12-1.7.25.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/xercesImpl-2.11.0.jar"/> + <classpathentry kind="lib" path="libs/jena/lib/xml-apis-1.4.01.jar"/> + <classpathentry kind="lib" path="libs/cloudpatterns-1.0-SNAPSHOT.jar"/> + <classpathentry kind="lib" path="libs/gson-2.8.2.jar"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> diff --git a/ARCHITECT/EclipsePlugin/plugin/.gitignore b/ARCHITECT/EclipsePlugin/plugin/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b83d22266ac8aa2f8df2edef68082c789727841d --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/ARCHITECT/EclipsePlugin/plugin/.project b/ARCHITECT/EclipsePlugin/plugin/.project new file mode 100644 index 0000000000000000000000000000000000000000..8b0bb0596c62758cf8cc68e1f277632bc117e99a --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>plugin</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/ARCHITECT/EclipsePlugin/plugin/.settings/org.eclipse.jdt.core.prefs b/ARCHITECT/EclipsePlugin/plugin/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..0c68a61dca867ceb49e79d2402935261ec3e3809 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/ARCHITECT/EclipsePlugin/plugin/.settings/org.eclipse.m2e.core.prefs b/ARCHITECT/EclipsePlugin/plugin/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..f897a7f1cb2389f85fe6381425d29f0a9866fb65 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ARCHITECT/EclipsePlugin/plugin/LICENSES b/ARCHITECT/EclipsePlugin/plugin/LICENSES new file mode 100644 index 0000000000000000000000000000000000000000..96139f460c1804ee3839ba1d640c5d4d2ee8f5a9 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/LICENSES @@ -0,0 +1,4 @@ +Eclipse: Eclipse Public License - v 2.0 http://www.eclipse.org/org/documents/epl-2.0/ +gson: Apache 2.0 license http://www.apache.org/licenses/LICENSE-2.0 +Apache Jena: Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 +JGit: Eclipse Distribution License - v 1.0 http://www.eclipse.org/org/documents/edl-v10.php \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/plugin/META-INF/MANIFEST.MF b/ARCHITECT/EclipsePlugin/plugin/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..91ea2ff2adb64267281387f5ee16be03517f7f95 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/META-INF/MANIFEST.MF @@ -0,0 +1,53 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Architect Plugin +Bundle-SymbolicName: eu.DECIDEh2020.architect.plugin;singleton:=true +Bundle-Version: 1.0.0.qualifier +Require-Bundle: org.eclipse.jface.text, + org.eclipse.core.resources, + org.eclipse.ui, + org.eclipse.ui.ide, + org.eclipse.core.runtime, + org.eclipse.wst.json.core;bundle-version="1.0.100", + org.eclipse.wst.sse.ui;bundle-version="1.3.600", + org.eclipse.core.databinding.observable, + org.eclipse.core.databinding.property, + org.eclipse.jgit;bundle-version="4.8.0", + org.eclipse.core.databinding.beans, + org.eclipse.core.databinding, + org.eclipse.jface.databinding +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ClassPath: ., + libs/cloudpatterns-1.0-SNAPSHOT.jar, + libs/jena/lib/jena-core-3.4.0.jar, + libs/jena/lib/slf4j-log4j12-1.7.25.jar, + libs/jena/lib/slf4j-api-1.7.25.jar, + libs/jena/lib/log4j-1.2.17.jar, + libs/jena/lib/xml-apis-1.4.01.jar, + libs/jena/lib/xercesImpl-2.11.0.jar, + libs/jena/lib/collection-0.7.jar, + libs/jena/lib/commons-cli-1.4.jar, + libs/jena/lib/commons-codec-1.10.jar, + libs/jena/lib/commons-csv-1.4.jar, + libs/jena/lib/commons-io-2.5.jar, + libs/jena/lib/commons-lang3-3.4.jar, + libs/jena/lib/httpclient-4.5.3.jar, + libs/jena/lib/httpclient-cache-4.5.3.jar, + libs/jena/lib/httpcore-4.4.6.jar, + libs/jena/lib/jackson-annotations-2.8.0.jar, + libs/jena/lib/jackson-core-2.8.6.jar, + libs/jena/lib/jackson-databind-2.8.6.jar, + libs/jena/lib/jcl-over-slf4j-1.7.25.jar, + libs/jena/lib/jena-arq-3.4.0.jar, + libs/jena/lib/jena-base-3.4.0.jar, + libs/jena/lib/jena-cmds-3.4.0.jar, + libs/jena/lib/jena-iri-3.4.0.jar, + libs/jena/lib/jena-rdfconnection-3.4.0.jar, + libs/jena/lib/jena-shaded-guava-3.4.0.jar, + libs/jena/lib/jena-tdb-3.4.0.jar, + libs/jena/lib/jsonld-java-0.10.0.jar, + libs/jena/lib/libthrift-0.9.3.jar, + libs/AppManager.jar, + libs/gson-2.8.2.jar, + libs/ +Import-Package: org.eclipse.ui.views.contentoutline diff --git a/ARCHITECT/EclipsePlugin/plugin/README.md b/ARCHITECT/EclipsePlugin/plugin/README.md new file mode 100644 index 0000000000000000000000000000000000000000..570b11f8a82ff1a3b33c6e8f1ab0c9202880331b --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/README.md @@ -0,0 +1 @@ +# ARCHITECT \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/plugin/build.properties b/ARCHITECT/EclipsePlugin/plugin/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..6e5f863c1023ab4014bc0a83fb537d53951c0afa --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/build.properties @@ -0,0 +1,10 @@ +source.. = src/,\ + libs/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + libs/,\ + libs/AppManager.jar +jars.compile.order = . diff --git a/ARCHITECT/EclipsePlugin/plugin/icons/icon_000.jpg b/ARCHITECT/EclipsePlugin/plugin/icons/icon_000.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a79369ecc404f8dd3410e895f42cb0dcd2426b94 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/icons/icon_000.jpg differ diff --git a/ARCHITECT/EclipsePlugin/plugin/icons/sample.gif b/ARCHITECT/EclipsePlugin/plugin/icons/sample.gif new file mode 100644 index 0000000000000000000000000000000000000000..34fb3c9d8cb7d489681b7f7aee4bdcd7eaf53610 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/icons/sample.gif differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/AppManager.jar b/ARCHITECT/EclipsePlugin/plugin/libs/AppManager.jar new file mode 100644 index 0000000000000000000000000000000000000000..802925b899deb575dbef13d9d35d2af06f9d263f Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/AppManager.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/cloudpatterns-1.0-SNAPSHOT.jar b/ARCHITECT/EclipsePlugin/plugin/libs/cloudpatterns-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..307a1429af607987c169334e5c15e29a7ef3c3b7 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/cloudpatterns-1.0-SNAPSHOT.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/gson-2.8.2.jar b/ARCHITECT/EclipsePlugin/plugin/libs/gson-2.8.2.jar new file mode 100644 index 0000000000000000000000000000000000000000..d0d030c6371cb44e7caee238f7bf148c7732ce28 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/gson-2.8.2.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/collection-0.7.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/collection-0.7.jar new file mode 100644 index 0000000000000000000000000000000000000000..aa5de6b95fa45dd3ca55b4e9441db7f79ce7e8ab Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/collection-0.7.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-cli-1.4.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-cli-1.4.jar new file mode 100644 index 0000000000000000000000000000000000000000..22deb3089e2f79a983406bd13a75a3e6238afdcf Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-cli-1.4.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-codec-1.10.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-codec-1.10.jar new file mode 100644 index 0000000000000000000000000000000000000000..1d7417c4031324cc6577a306cde57ae220f55523 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-codec-1.10.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-csv-1.4.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-csv-1.4.jar new file mode 100644 index 0000000000000000000000000000000000000000..e9eb0bd35ccf5876b3d2f1fce3afecdfc3cd12b7 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-csv-1.4.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-io-2.5.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-io-2.5.jar new file mode 100644 index 0000000000000000000000000000000000000000..107b061f5fa84cecca645eae9bdefc98e084ce03 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-io-2.5.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-lang3-3.4.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-lang3-3.4.jar new file mode 100644 index 0000000000000000000000000000000000000000..8ec91d454c31f73638de2994711a8487822247c1 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/commons-lang3-3.4.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpclient-4.5.3.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpclient-4.5.3.jar new file mode 100644 index 0000000000000000000000000000000000000000..8af45610819f7afb6c72f37ca3cc20c029b84810 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpclient-4.5.3.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpclient-cache-4.5.3.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpclient-cache-4.5.3.jar new file mode 100644 index 0000000000000000000000000000000000000000..3f609f5dcf5a5d84c5b885722fabb42ed0df0b08 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpclient-cache-4.5.3.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpcore-4.4.6.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpcore-4.4.6.jar new file mode 100644 index 0000000000000000000000000000000000000000..16ed0d160d7deed898d2f65f7c970bc2ccf6d97f Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/httpcore-4.4.6.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-annotations-2.8.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-annotations-2.8.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..d19b67b0f11086544c2dc2ab36a6b09abc9962a0 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-annotations-2.8.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-core-2.8.6.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-core-2.8.6.jar new file mode 100644 index 0000000000000000000000000000000000000000..2b10bf3030f994b6cf9717b510243ffa6250a585 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-core-2.8.6.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-databind-2.8.6.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-databind-2.8.6.jar new file mode 100644 index 0000000000000000000000000000000000000000..2784d1f82760589dcec0f64e87b122e0dc8105ac Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jackson-databind-2.8.6.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jcl-over-slf4j-1.7.25.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jcl-over-slf4j-1.7.25.jar new file mode 100644 index 0000000000000000000000000000000000000000..8e7fec880f401e6e8f2a979192c1870448ff1ad0 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jcl-over-slf4j-1.7.25.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-arq-3.4.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-arq-3.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..c8ed9bcceae730ce1202ed3d6f41a25e6d1fe5cd Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-arq-3.4.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-base-3.4.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-base-3.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..3043f31786f8be37e5cb526c52f96109e926bc45 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-base-3.4.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-cmds-3.4.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-cmds-3.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..98b54ddede9223d7ebb6ba4ad79be7b615096f6e Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-cmds-3.4.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-core-3.4.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-core-3.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..525a1e2cc9a047f621de8f7e539cfec087953ca1 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-core-3.4.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-iri-3.4.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-iri-3.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..f6804576f2c1eabd22c38b967ca5768f7e2b3442 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-iri-3.4.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-rdfconnection-3.4.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-rdfconnection-3.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..bb3eccf0284c23d27edf5039693f30491051c038 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-rdfconnection-3.4.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-shaded-guava-3.4.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-shaded-guava-3.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..31de884565ea70a731e57abca214ee23d41af45f Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-shaded-guava-3.4.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-tdb-3.4.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-tdb-3.4.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..a54ba4e3968145993ceea096073ea2ab11373f2d Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jena-tdb-3.4.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jsonld-java-0.10.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jsonld-java-0.10.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..8c98b7ba27b8a892b3e6af80f030aab9b021a842 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/jsonld-java-0.10.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/libthrift-0.9.3.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/libthrift-0.9.3.jar new file mode 100644 index 0000000000000000000000000000000000000000..f9221a9f958f2ac140e33a71abaf1d31adb6a3f7 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/libthrift-0.9.3.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/log4j-1.2.17.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/log4j-1.2.17.jar new file mode 100644 index 0000000000000000000000000000000000000000..1d425cf7d7e25f81be64d32c406ff66cfb6c4766 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/log4j-1.2.17.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/slf4j-api-1.7.25.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/slf4j-api-1.7.25.jar new file mode 100644 index 0000000000000000000000000000000000000000..0143c099699ee843cde6d95c9dbc7751039d2463 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/slf4j-api-1.7.25.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/slf4j-log4j12-1.7.25.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/slf4j-log4j12-1.7.25.jar new file mode 100644 index 0000000000000000000000000000000000000000..7d88a6e75bcee54464e70f57a595cab677ce77fc Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/slf4j-log4j12-1.7.25.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/xercesImpl-2.11.0.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/xercesImpl-2.11.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..0aaa990f3ecadf60d28b5395dc87bbe49da0cdd7 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/xercesImpl-2.11.0.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/xml-apis-1.4.01.jar b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/xml-apis-1.4.01.jar new file mode 100644 index 0000000000000000000000000000000000000000..46733464fc746776c331ecc51061f3a05e662fd1 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/libs/jena/lib/xml-apis-1.4.01.jar differ diff --git a/ARCHITECT/EclipsePlugin/plugin/plugin.xml b/ARCHITECT/EclipsePlugin/plugin/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..eb02ecb2c7206c320c33b609d54037e11edce919 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/plugin.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE project> +<?eclipse version="3.4"?> +<plugin> + + <extension + point="org.eclipse.ui.editors"> + <editor + class="eu.DECIDEh2020.architect.plugin.editor.MultiPageEditor" + contributorClass="eu.DECIDEh2020.architect.plugin.editor.MultiPageEditorContributor" + default="true" + extensions="json" + icon="icons/icon_000.jpg" + id="eu.DECIDEh2020.architect.plugin.editor.MultiPageEditor" + name="DECIDE Editor"> + </editor> + </extension> + <extension + point="org.eclipse.ui.newWizards"> + <category + name="DECIDE Wizards" + id="eu.DECIDEh2020.architect.plugin"> + </category> + <wizard + category="eu.DECIDEh2020.architect.plugin" + class="eu.DECIDEh2020.architect.plugin.descriptorWizard.NewProjectWizard" + finalPerspective="org.eclipse.jdt.ui.JavaPerspective" + icon="icons/icon_000.jpg" + id="eu.DECIDEh2020.architect.plugin.descriptorWizard.NewProjectWizard" + name="DECIDE project" + project="true"> + </wizard> + </extension> + <extension + id="eu.DECIDEh2020.architect.plugin.ProjectNature" + point="org.eclipse.core.resources.natures"> + <runtime> + <run + class="eu.DECIDEh2020.architect.plugin.natures.ProjectNature"> + </run> + </runtime> + </extension> + <extension + point="org.eclipse.ui.perspectives"> + <perspective + class="eu.DECIDEh2020.architect.plugin.perspectives.Perspective" + icon="icons/icon_000.jpg" + id="eu.DECIDEh2020.architect.plugin.perspective" + name="DECIDE Plug-in Perspective"> + </perspective> + </extension> + <extension + point="org.eclipse.ui.perspectiveExtensions"> + <perspectiveExtension + targetID="org.eclipse.jdt.ui.JavaPerspective"> + <view + id="eu.DECIDEh2020.architect.customnavigator.navigator" + minimized="false" + relationship="left" + relative="org.eclipse.ui.editorss"> + </view> + <newWizardShortcut + id="eu.DECIDEh2020.architect.plugin.descriptorWizard.NewProjectWizard"> + </newWizardShortcut> + </perspectiveExtension> + </extension> + +</plugin> diff --git a/ARCHITECT/EclipsePlugin/plugin/pom.xml b/ARCHITECT/EclipsePlugin/plugin/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..9f941479412dad90743323af0066b7c19d1568f6 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/pom.xml @@ -0,0 +1,13 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <artifactId>eu.DECIDEh2020.architect.plugin</artifactId> + <packaging>eclipse-plugin</packaging> + + <parent> + <groupId>de.decideh2020</groupId> + <artifactId>eu.DECIDEh2020.architect.releng</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../releng</relativePath> + </parent> + +</project> \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/ConfigPage.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/ConfigPage.java new file mode 100644 index 0000000000000000000000000000000000000000..404c4b3a227223b9c306ff27a66a4761561092a5 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/ConfigPage.java @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ + +package eu.DECIDEh2020.architect.plugin.descriptorWizard; + + +import org.apache.jena.rdf.model.Resource; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Label; +import org.eclipse.wb.swt.SWTResourceManager; + +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.plugin.layoutComponents.MicroserviceListComposite; +import eu.DECIDEh2020.architect.plugin.layoutComponents.NfrListViewer; +import eu.DECIDEh2020.architect.plugin.layoutComponents.PageCompleteListener; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; + +public class ConfigPage extends WizardPage { + + private Composite container; + private AppDescriptor project; + private MicroserviceListComposite microserviceList; + private Text txtProjectdescription; + + + + + + /** + * @wbp.parser.constructor + */ + public ConfigPage( AppDescriptor project) { + super("Project Configuration"); + // TODO Auto-generated constructor stub + this.project=project; + } + + + + @Override + public void createControl(Composite parent) { + container = new Composite(parent, SWT.NULL); + setControl(container); + container.setLayout(new GridLayout(1, false)); + + Composite compositeNFR = new Composite(container, SWT.NONE); + compositeNFR.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + GridLayout gl_compositeNFR = new GridLayout(2, false); + gl_compositeNFR.horizontalSpacing = 15; + gl_compositeNFR.verticalSpacing = 15; + compositeNFR.setLayout(gl_compositeNFR); + + Label lblNFRs = new Label(compositeNFR, SWT.NONE); + lblNFRs.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1)); + lblNFRs.setText("Project NFRs: "); + + NfrListViewer nfrListViewer = new NfrListViewer(compositeNFR, SWT.BORDER | SWT.V_SCROLL| SWT.MULTI); + + GridData gd_listNfrs = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); + gd_listNfrs.heightHint = 75; + nfrListViewer.setLayoutData(gd_listNfrs); + + nfrListViewer.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + HashSet<Resource> pNfrs = new HashSet<Resource>(); + for (Resource r: nfrListViewer.getSelection()) { + try { + pNfrs.add(r); + } catch (IllegalArgumentException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + project.setProjectNfrs(pNfrs); + } + }); + if(project.getProjectNfrs().size() != 0) { + nfrListViewer.addSelection(new ArrayList<Resource>(project.getProjectNfrs())); + } + addMicroserviceControls(); + + setPageComplete(false); + } + + private void addMicroserviceControls(){ + + Composite compositeProjectDescription = new Composite(container, SWT.NONE); + compositeProjectDescription.setLayout(new GridLayout(2, false)); + compositeProjectDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblAppDescription = new Label(compositeProjectDescription, SWT.NONE); + lblAppDescription.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); + lblAppDescription.setText("App Description:"); + + txtProjectdescription = new Text(compositeProjectDescription, SWT.BORDER | SWT.MULTI); + txtProjectdescription.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + project.setDescription(txtProjectdescription.getText()); + } + }); + txtProjectdescription.setText("ProjectDescription"); + GridData gd_txtProjectdescription = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + gd_txtProjectdescription.heightHint = 52; + txtProjectdescription.setLayoutData(gd_txtProjectdescription); + new Label(compositeProjectDescription, SWT.NONE); + + /* Button btnMonolithic = new Button(compositeProjectDescription, SWT.CHECK); + btnMonolithic.setText("monolithic");*/ + + Group grpMicroservices = new Group(container, SWT.NONE); + + grpMicroservices.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + grpMicroservices.setText("Microservices"); + grpMicroservices.setLayout(new GridLayout(1, false)); + + microserviceList = new MicroserviceListComposite(grpMicroservices,SWT.NONE, project, true,SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); + microserviceList.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + microserviceList.addPageCompleteListener(new PageCompleteListener() { + @Override + public void pageCompleted(Boolean complete) { + setPageComplete(complete); + } + }); + + } + + + + public void setVisible(boolean visible) { + super.setVisible(visible); + + if (visible) microserviceList.refresh(); + } + +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/MicroservicePage.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/MicroservicePage.java new file mode 100644 index 0000000000000000000000000000000000000000..90158adcd7de5d472ab4739d44d044ff00151de4 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/MicroservicePage.java @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ + +package eu.DECIDEh2020.architect.plugin.descriptorWizard; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.layout.GridLayout; + +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.appManager.models.Microservice; +import eu.DECIDEh2020.architect.plugin.layoutComponents.MicroserviceComposite; + +import java.util.LinkedList; + +import org.eclipse.swt.custom.ScrolledComposite; + +public class MicroservicePage extends WizardPage { + + private ScrolledComposite scrolledComposite; + private Composite container; + private AppDescriptor project; + + + + + public MicroservicePage(AppDescriptor project) { + super("Microservice Settings"); + setTitle("Microservice Settings"); + setDescription("Configure each Microservice here"); + this.project=project; + } + + + + @Override + public void createControl(Composite parent) { + + scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL); + + scrolledComposite.setExpandHorizontal(true); + scrolledComposite.setExpandVertical(true); + setControl(scrolledComposite); + + + container = new Composite(scrolledComposite, SWT.NONE); + scrolledComposite.setContent(container); + container.setLayout(new GridLayout(1, false)); + + + scrolledComposite.setExpandVertical( true ); + scrolledComposite.setExpandHorizontal( true ); + scrolledComposite.addListener( SWT.Resize, event -> { + int width = scrolledComposite.getClientArea().width; + scrolledComposite.setMinSize( parent.computeSize( width, SWT.DEFAULT ) ); + } ); + + + + + /* + + Microservice m = new Microservice(); + m.setRepo("Repo"); + m.getRepo().endsWith("o"); + addMicroserviceComposite(m); + */ + setPageComplete(true); + } + + private void addMicroserviceComposite(Microservice microservice){ + if(microservice!=null) { + + @SuppressWarnings("unused") + Composite msvContainer = new MicroserviceComposite(container, microservice); + } + + } + + public void setMicroservices(){ + + Control[] children = container.getChildren(); + for (int i = 0 ; i < children.length; i++) { + children[i].dispose(); + } + + addMicroservices(); + container.requestLayout(); + int width = scrolledComposite.getClientArea().width; + scrolledComposite.setMinSize( scrolledComposite.getParent().computeSize( width, SWT.DEFAULT ) ); + scrolledComposite.requestLayout(); + + } + private void addMicroservices() { + + LinkedList<Microservice> microservices = project.getMicroservices(); + if(microservices.size()>0){ + for(Microservice m: microservices) { + addMicroserviceComposite(m); + } + + } + + + } +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/MonolithPage.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/MonolithPage.java new file mode 100644 index 0000000000000000000000000000000000000000..e624d016da0983322c6c089564c2dec47ccaba20 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/MonolithPage.java @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.descriptorWizard; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + +public class MonolithPage extends WizardPage { + + /** + * Create the wizard. + */ + public MonolithPage() { + super("wizardPage"); + + setTitle("Monolith Page"); + setDescription("Wizard Page description"); + } + + /** + * Create contents of the wizard. + * @param parent + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + + + + + + setControl(container); + } + +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectPage.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectPage.java new file mode 100644 index 0000000000000000000000000000000000000000..f5db0a3d452d790cf0a49b28eb7961902ffebca3 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectPage.java @@ -0,0 +1,383 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.descriptorWizard; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; + +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.appManager.persistence.GitHandler.Repository; + +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; + +import java.net.URISyntaxException; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.jgit.transport.URIish; +import org.eclipse.core.databinding.beans.PojoProperties; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; + +public class NewProjectPage extends WizardNewProjectCreationPage { + private DataBindingContext m_bindingContext; + + + private Composite container; + private AppDescriptor project; + private Repository repo; + private Text txtUser; + private Text txtPassword; + private Text txtPort; + private Text txtReponame; + private Text txtUri; + private Text txtHost; + private Text txtRepopath; + private Combo comboProtocol; + private Button btnSecurestore; + private Button btnCreateLocalRepository; + private Button btnOpenLocalRepository; + private Button btnCloneRemoteRepository; + + public NewProjectPage(String pageName, AppDescriptor project) { + super(pageName); + this.project = project; + repo = new Repository(); + + } + + @Override + public void createControl(Composite parent) { + super.createControl(parent); + Composite p = (Composite) getControl(); + + + p.setLayout(new GridLayout(1, false)); + container = new Composite(p, SWT.NONE); + container.setLayout(new GridLayout(1, false)); + container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + + Composite compositeLocal_Remote = new Composite(container, SWT.NONE); + compositeLocal_Remote.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + compositeLocal_Remote.setLayout(new FillLayout(SWT.HORIZONTAL)); + + btnOpenLocalRepository = new Button(compositeLocal_Remote, SWT.RADIO); + btnOpenLocalRepository.setText("Open Local repository"); + + btnCreateLocalRepository = new Button(compositeLocal_Remote, SWT.RADIO); + + + btnCreateLocalRepository.setText("Create Local repository"); + + btnCloneRemoteRepository = new Button(compositeLocal_Remote, SWT.RADIO); + + btnCloneRemoteRepository.setText("Clone Remote Repository"); + + Group grpGitRepository = new Group(container, SWT.NONE); + grpGitRepository.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + grpGitRepository.setText("Git Repository"); + grpGitRepository.setLayout(new GridLayout(1, false)); + + Composite composite_1 = new Composite(grpGitRepository, SWT.NONE); + composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + composite_1.setLayout(new GridLayout(2, false)); + + Label lblName = new Label(composite_1, SWT.NONE); + lblName.setText("Name:"); + + txtReponame = new Text(composite_1, SWT.BORDER); + txtReponame.setEnabled(false); + txtReponame.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + + + } + }); + txtReponame.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Composite composite = new Composite(grpGitRepository, SWT.NONE); + composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + composite.setLayout(new GridLayout(1, false)); + + Group grpLocation = new Group(composite, SWT.NONE); + grpLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + grpLocation.setText("Location"); + grpLocation.setLayout(new GridLayout(2, false)); + + Label lblUri = new Label(grpLocation, SWT.NONE); + lblUri.setText("URI:"); + + txtUri = new Text(grpLocation, SWT.BORDER); + + txtUri.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblHost = new Label(grpLocation, SWT.NONE); + lblHost.setText("Host:"); + + txtHost = new Text(grpLocation, SWT.BORDER); + txtHost.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblRepositoryPath = new Label(grpLocation, SWT.NONE); + lblRepositoryPath.setText("Repository Path:"); + + txtRepopath = new Text(grpLocation, SWT.BORDER); + txtRepopath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + + Group grpConnection = new Group(composite, SWT.NONE); + grpConnection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + grpConnection.setText("Connection"); + grpConnection.setLayout(new GridLayout(2, false)); + + Label lblProtocol = new Label(grpConnection, SWT.NONE); + lblProtocol.setText("Protocol:"); + + comboProtocol = new Combo(grpConnection, SWT.READ_ONLY); + comboProtocol.setItems(new String[] {"https", "ssh"}); + comboProtocol.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + comboProtocol.select(0); + + Label lblPort = new Label(grpConnection, SWT.NONE); + lblPort.setText("Port:"); + + txtPort = new Text(grpConnection, SWT.BORDER); + txtPort.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + + Group grpAuthentication = new Group(composite, SWT.NONE); + grpAuthentication.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + grpAuthentication.setText("Authentication"); + grpAuthentication.setLayout(new GridLayout(2, false)); + + Label lblUser = new Label(grpAuthentication, SWT.NONE); + lblUser.setText("User:"); + + txtUser = new Text(grpAuthentication, SWT.BORDER); + txtUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblPassword = new Label(grpAuthentication, SWT.NONE); + lblPassword.setText("Password:"); + + txtPassword = new Text(grpAuthentication, SWT.BORDER | SWT.PASSWORD); + txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblStoreInSecure = new Label(grpAuthentication, SWT.NONE); + lblStoreInSecure.setText("Store in Secure Store:"); + + + txtUri.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + URIish uri = null; + try { + if (!txtUri.getText().isEmpty()){ + uri = new URIish(txtUri.getText()); + } + } catch (URISyntaxException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + + } + if (uri!=null) { + txtHost.setText(uri.getHost()!=null?uri.getHost():""); + txtRepopath.setText(uri.getPath()!=null?uri.getPath():""); + + comboProtocol.setText(uri.getScheme()!=null?uri.getScheme():"ssh"); + txtUser.setText(uri.getUser()!=null?uri.getUser():""); + txtPassword.setText(uri.getPass()!=null?uri.getPass():""); + + + if (uri.getPort()>=0) { + txtPort.setText(String.valueOf(uri.getPort())); + } + + + } + setPageComplete(true); + } + }); + + btnSecurestore = new Button(grpAuthentication, SWT.CHECK); + txtUri.setEnabled(false); + txtHost.setEnabled(false); + txtRepopath.setEnabled(false); + comboProtocol.setEnabled(false); + txtPort.setEnabled(false); + txtUser.setEnabled(false); + txtPassword.setEnabled(false); + btnSecurestore.setEnabled(false); + + btnOpenLocalRepository.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + txtReponame.setEnabled(false); + txtUri.setEnabled(false); + txtHost.setEnabled(false); + txtRepopath.setEnabled(false); + comboProtocol.setEnabled(false); + txtPort.setEnabled(false); + txtUser.setEnabled(false); + txtPassword.setEnabled(false); + btnSecurestore.setEnabled(false); + repo.setNewRepo(false); + repo.setLocalRepo(true); + + setPageComplete(true); + getWizard().getContainer().updateButtons(); + getWizard().getContainer().updateButtons(); + + } + }); + + btnCreateLocalRepository.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + txtReponame.setEnabled(false); + txtUri.setEnabled(false); + txtHost.setEnabled(false); + txtRepopath.setEnabled(false); + comboProtocol.setEnabled(false); + txtPort.setEnabled(false); + txtUser.setEnabled(false); + txtPassword.setEnabled(false); + btnSecurestore.setEnabled(false); + repo.setNewRepo(true); + + setPageComplete(true); + getWizard().getContainer().updateButtons(); + getWizard().getContainer().updateButtons(); + } + }); + + + btnCloneRemoteRepository.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + txtReponame.setEnabled(false); + txtUri.setEnabled(true); + txtHost.setEnabled(true); + txtRepopath.setEnabled(true); + comboProtocol.setEnabled(true); + txtPort.setEnabled(true); + txtUser.setEnabled(true); + txtPassword.setEnabled(true); + btnSecurestore.setEnabled(true); + repo.setNewRepo(false); + repo.setLocalRepo(false); + + setPageComplete(true); + getWizard().getContainer().updateButtons(); + getWizard().getContainer().updateButtons(); + } + }); + btnCreateLocalRepository.setSelection(true); + setPageComplete(false); + // required to avoid an error in the system + setControl(p); + m_bindingContext = initDataBindings(); + + + } + + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.wizard.WizardPage#setPageComplete(boolean) + */ + @Override + public void setPageComplete(boolean complete) { + Boolean thisComplete = false; + if ((btnOpenLocalRepository != null && btnOpenLocalRepository.getSelection()) + || (btnCreateLocalRepository != null && btnCreateLocalRepository.getSelection())) { + thisComplete = true; + } else { + if (repo != null && repo.getURI() != null && !repo.getURI().isEmpty()) { + thisComplete = true; + } + } + thisComplete = thisComplete && this.getProjectName()!=null && this.getProjectName()!="" && getErrorMessage()== null; + + super.setPageComplete(thisComplete && complete); + if (getWizard() != null && getWizard().getContainer() != null) { + getWizard().getContainer().updateButtons(); + } + //System.out.println("NewProject Page Complete: "+ isPageComplete()); + } + + public boolean isPageComplete() { + if (project != null) { + project.setName(getProjectName()); + } + return super.isPageComplete(); + } + + public Repository getRepository() { + return repo; + } + + protected DataBindingContext initDataBindings() { + DataBindingContext bindingContext = new DataBindingContext(); + // + IObservableValue observeTextTxtReponameObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtReponame); + IObservableValue nameRepoObserveValue = PojoProperties.value("name").observe(repo); + bindingContext.bindValue(observeTextTxtReponameObserveWidget, nameRepoObserveValue, null, null); + // + IObservableValue observeTextTxtUriObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtUri); + IObservableValue uRIRepoObserveValue = PojoProperties.value("URI").observe(repo); + bindingContext.bindValue(observeTextTxtUriObserveWidget, uRIRepoObserveValue, null, null); + // + IObservableValue observeTextTxtHostObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtHost); + IObservableValue hostRepoObserveValue = PojoProperties.value("host").observe(repo); + bindingContext.bindValue(observeTextTxtHostObserveWidget, hostRepoObserveValue, null, null); + // + IObservableValue observeTextTxtRepopathObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtRepopath); + IObservableValue pathRepoObserveValue = PojoProperties.value("path").observe(repo); + bindingContext.bindValue(observeTextTxtRepopathObserveWidget, pathRepoObserveValue, null, null); + // + IObservableValue observeTextComboProtocolObserveWidget = WidgetProperties.text().observe(comboProtocol); + IObservableValue protocolRepoObserveValue = PojoProperties.value("protocol").observe(repo); + bindingContext.bindValue(observeTextComboProtocolObserveWidget, protocolRepoObserveValue, null, null); + // + IObservableValue observeTextTextPortObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtPort); + IObservableValue portRepoObserveValue = PojoProperties.value("port").observe(repo); + bindingContext.bindValue(observeTextTextPortObserveWidget, portRepoObserveValue, null, null); + // + IObservableValue observeTextTxtUserObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtUser); + IObservableValue userRepoObserveValue = PojoProperties.value("user").observe(repo); + bindingContext.bindValue(observeTextTxtUserObserveWidget, userRepoObserveValue, null, null); + // + IObservableValue observeTextTxtPasswordObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtPassword); + IObservableValue passwordRepoObserveValue = PojoProperties.value("password").observe(repo); + bindingContext.bindValue(observeTextTxtPasswordObserveWidget, passwordRepoObserveValue, null, null); + // + IObservableValue observeSelectionBtnSecurestoreObserveWidget = WidgetProperties.selection().observe(btnSecurestore); + IObservableValue secureStorageRepoObserveValue = PojoProperties.value("secureStorage").observe(repo); + bindingContext.bindValue(observeSelectionBtnSecurestoreObserveWidget, secureStorageRepoObserveValue, null, null); + // + return bindingContext; + } +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectSupport.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectSupport.java new file mode 100644 index 0000000000000000000000000000000000000000..b7161726170c8dece55b7fc64042ae324c573aa2 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectSupport.java @@ -0,0 +1,245 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.descriptorWizard; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; + +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.appManager.persistence.GitHandler; +import eu.DECIDEh2020.architect.appManager.persistence.GitHandler.Repository; +import eu.DECIDEh2020.architect.appManager.persistence.JsonHandler; +import eu.DECIDEh2020.architect.plugin.natures.ProjectNature; + +public class NewProjectSupport { + /** + * For this marvelous project we need to: - create the default Eclipse project - + * add the custom project nature - create the folder structure + * + * @param projectName + * @param location + * @param natureId + * @return + */ + public static IProject createProject(String projectName, URI location, IProgressMonitor monitor, Repository repo, + NewProjectWizard wizard) throws CoreException { + Assert.isNotNull(projectName); + Assert.isTrue(projectName.trim().length() > 0); + + + GitHandler githandler = new GitHandler(repo); + + File dir; + if (location == null) { + dir = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation() + File.separator + projectName); + } else { + dir = new File(location + File.separator + projectName); + } + + if (!repo.isLocalRepo() && !repo.isNewRepo()) { + try { + githandler.cloneRepositoryTo(dir); + // Note: the call() returns an opened repository already which needs to be + // closed to avoid file handle leaks! + System.out.println("Created repository: " + githandler.getDirectory()); + } catch (InvalidRemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TransportException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (GitAPIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if (repo.isLocalRepo() && repo.isNewRepo()) { + + try { + githandler.createRepositoryIn(dir); + } catch (IllegalStateException | GitAPIException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (!repo.isLocalRepo() && repo.isNewRepo()) { + // TODO create remote repo + } + + IProject project = createBaseProject(projectName, location); + try { + addNature(project); + + /* + * String[] paths = { "schema", //$NON-NLS-1$ "deployment-files/java", + * //$NON-NLS-1$ "clause/java/source/hidden-clause"}; //$NON-NLS-1$ + */ + // addToProjectStructure(project, paths); + if (repo.isNewRepo()) { + createFile(project, monitor, wizard); + }else { + openFile(project.getFile(new Path("DECIDE.json")), monitor, wizard); + } + + } catch (CoreException e) { + e.printStackTrace(); + project = null; + } + + + + return project; + } + + private static void createFile(IProject project, IProgressMonitor monitor, NewProjectWizard wizard) + throws CoreException { + // create a sample file + final String fileName = "DECIDE.json"; + monitor.beginTask("Creating " + fileName, 2); + + final IFile file = project.getFile(new Path(fileName)); + try { + InputStream stream = openContentStream(wizard.getProject()); + if (file.exists()) { + file.setContents(stream, true, true, monitor); + } else { + file.create(stream, true, monitor); + } + stream.close(); + } catch (IOException e) { + } + monitor.worked(1); + openFile(file,monitor, wizard); + + } + + private static void openFile(IFile file, IProgressMonitor monitor,NewProjectWizard wizard) { + monitor.setTaskName("Opening file for editing..."); + wizard.getShell().getDisplay().asyncExec(new Runnable() { + public void run() { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try { + IDE.openEditor(page, file, true); + } catch (PartInitException e) { + } + } + }); + monitor.worked(1); + } + + private static InputStream openContentStream(AppDescriptor project) { + + + String contents = JsonHandler.fromAppDescriptor(project); + return new ByteArrayInputStream(contents.getBytes()); + } + + private static void throwCoreException(String message) throws CoreException { + IStatus status = new Status(IStatus.ERROR, "eu.DECIDEh2020.architect.plugin", IStatus.OK, message, null); + throw new CoreException(status); + } + + /** + * Just do the basics: create a basic project. + * + * @param location + * @param projectName + */ + private static IProject createBaseProject(String projectName, URI location) { + // it is acceptable to use the ResourcesPlugin class + IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + + if (!newProject.exists()) { + URI projectLocation = location; + IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName()); + if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) { + projectLocation = null; + } + + desc.setLocationURI(projectLocation); + try { + newProject.create(desc, null); + if (!newProject.isOpen()) { + newProject.open(null); + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + + return newProject; + } + + private static void createFolder(IFolder folder) throws CoreException { + IContainer parent = folder.getParent(); + if (parent instanceof IFolder) { + createFolder((IFolder) parent); + } + if (!folder.exists()) { + folder.create(false, true, null); + } + } + + /** + * Create a folder structure with a parent root, overlay, and a few child + * folders. + * + * @param newProject + * @param paths + * @throws CoreException + */ + private static void addToProjectStructure(IProject newProject, String[] paths) throws CoreException { + for (String path : paths) { + IFolder etcFolders = newProject.getFolder(path); + createFolder(etcFolders); + } + } + + private static void addNature(IProject project) throws CoreException { + if (!project.hasNature(ProjectNature.NATURE_ID)) { + IProjectDescription description = project.getDescription(); + String[] prevNatures = description.getNatureIds(); + String[] newNatures = new String[prevNatures.length + 1]; + System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); + newNatures[prevNatures.length] = ProjectNature.NATURE_ID; + description.setNatureIds(newNatures); + + IProgressMonitor monitor = null; + project.setDescription(description, monitor); + } + } + +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectWizard.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectWizard.java new file mode 100644 index 0000000000000000000000000000000000000000..3721f622559a182c2c53e45ff7ba631a9b6d1982 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/descriptorWizard/NewProjectWizard.java @@ -0,0 +1,202 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.descriptorWizard; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; +import org.eclipse.core.runtime.*; +import java.net.URI; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.ui.*; + +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.appManager.persistence.GitHandler.Repository; + + +/** + * This is a sample new wizard. Its role is to create a new file resource in the + * provided container. If the container resource (a folder or a project) is + * selected in the workspace when the wizard is opened, it will accept it as the + * target container. The wizard creates one file with the extension "mpe". If a + * sample multi-page editor (also available as a template) is registered for the + * same extension, it will be able to open it. + */ + +public class NewProjectWizard extends Wizard implements INewWizard, IExecutableExtension { + @SuppressWarnings("unused") + private ISelection selection; + @SuppressWarnings("unused") + private IConfigurationElement _configurationElement; + private MicroservicePage microservicePage; + private NewProjectPage projectPage; + private ConfigPage configPage; + private MonolithPage monolithPage; + private AppDescriptor project; + + /** + * Constructor for SampleNewWizard. + */ + public NewProjectWizard() { + super(); + setNeedsProgressMonitor(true); + setWindowTitle("DECIDE project wizard"); + project = new AppDescriptor(); + } + + public AppDescriptor getProject() { + return project; + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() { + super.addPages(); + + projectPage = new NewProjectPage("From Scratch Project Wizard", project); + projectPage.setTitle("New DECIDE Project"); + projectPage.setDescription("Create a new DECIDE project."); + addPage(projectPage); + + configPage = new ConfigPage(project); + addPage(configPage); + + microservicePage = new MicroservicePage(project); + addPage(microservicePage); + monolithPage = new MonolithPage(); + addPage(monolithPage); + + } + + /** + * This method is called when 'Finish' button is pressed in the wizard. We will + * create an operation and run it using wizard as execution context. + */ + public boolean performFinish() { + + final String name = projectPage.getProjectName(); + URI loc = null; + if (!projectPage.useDefaults()) { + loc = projectPage.getLocationURI(); + System.err.println("location: " + loc.toString()); //$NON-NLS-1$ + } // else location == null + final URI location = loc; + final Repository repo = projectPage.getRepository(); + + final NewProjectWizard wizard = this; + IRunnableWithProgress op = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + NewProjectSupport.createProject(name, location, monitor, repo, wizard); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }; + try { + getContainer().run(true, false, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + e.printStackTrace(); + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + StringWriter sw = new StringWriter(); + realException.printStackTrace(new PrintWriter(sw)); + String exceptionAsString = sw.toString(); + MessageDialog.openError(getShell(), "Error", exceptionAsString); + return false; + } + + + + + BasicNewProjectResourceWizard.updatePerspective(_configurationElement); + + return true && project.getMicroservices().size() > 0; + } + + + + @Override + public IWizardPage getNextPage(IWizardPage currentPage) { + + + if (currentPage == configPage) { + + microservicePage.setDescription("set Microservices: "); + microservicePage.setMicroservices(); + return microservicePage; + } else if (currentPage == projectPage) { + Repository repo = projectPage.getRepository(); + if (!repo.isNewRepo()) { + configPage.setPageComplete(true); + if(!canFinish()) { + getContainer().updateButtons();} + //System.out.println("Config Page Complete: "+configPage.isPageComplete()); + + return null; + }else { + configPage.setPageComplete(project!=null && !project.getMicroservices().isEmpty()); + + //System.out.println("Config Page Complete: "+configPage.isPageComplete()); + return configPage; + } + + } + return null; + } + + + /** + * We will initialize file contents with a sample text. + */ + + /** + * We will accept the selection in the workbench to see if we can initialize + * from it. + * + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + IPerspectiveRegistry ipr = workbench.getPerspectiveRegistry(); + for (IPerspectiveDescriptor ipd : ipr.getPerspectives()) { + //System.out.println("Label: " + ipd.getLabel() + " - ID: " + ipd.getId() + " - Description: " + ipd.getDescription()); + } + + } + + @Override + public void setInitializationData(IConfigurationElement config, String propertyName, Object data) + throws CoreException { + + _configurationElement = config; + + } +} \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/editor/MultiPageEditor.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/editor/MultiPageEditor.java new file mode 100644 index 0000000000000000000000000000000000000000..6453cf35dc44c0781f41249d697048bfbd24122b --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/editor/MultiPageEditor.java @@ -0,0 +1,359 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.editor; + + +import java.util.ArrayList; + +import org.apache.jena.rdf.model.Resource; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.*; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.part.MultiPageEditorPart; +import org.eclipse.ui.part.MultiPageEditorSite; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.views.contentoutline.*; +import org.eclipse.wst.json.core.contenttype.ContentTypeIdForJSON; +import org.eclipse.wst.sse.ui.StructuredTextEditor; + +import com.google.gson.JsonSyntaxException; + +import eu.DECIDEh2020.architect.appManager.persistence.JsonHandler; +import eu.DECIDEh2020.architect.appManager.persistence.JsonHandler.AppDescriptorWrapper; +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.appManager.models.Microservice; +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; +import eu.DECIDEh2020.architect.plugin.layoutComponents.PatternPageComposite; +import eu.DECIDEh2020.architect.plugin.layoutComponents.ProjectPageComposite; + + +/** + * An example showing how to create a multi-page editor. + * This example has 3 pages: + * <ul> + * <li>page 0 contains a nested text editor. + * <li>page 1 allows you to change the font used in page 2 + * <li>page 2 shows the words in page 0 in sorted order + * </ul> + */ +public class MultiPageEditor extends MultiPageEditorPart implements IResourceChangeListener{ + + /** The text editor used in the json page. */ + private StructuredTextEditor editor; + + private AppDescriptor project; + private Patterns patterns = Patterns.createDefaultPatterns(); + + /** The composite used for the project page */ + private ProjectPageComposite ppage; + + private PatternPageComposite patPage; + + private IContentOutlinePage contentOutlinePage; + /** + * Creates a multi-page editor example. + */ + public MultiPageEditor() { + super(); + ResourcesPlugin.getWorkspace().addResourceChangeListener(this); + } + /** + * Creates the page of the multi-page editor, + * which contains a json editor. + */ + void createJSONPage() { + try { + editor = new StructuredTextEditor(); + int index = addPage(editor, getEditorInput()); + setPageText(index, editor.getTitle()); + + + } catch (PartInitException e) { + ErrorDialog.openError( + getSite().getShell(), + "Error creating nested text editor", + null, + e.getStatus()); + } + + } + /** + * Creates page 1 of the multi-page editor, + * which allows you to change the font used in page 2. + */ + void createProjectPage() { + + fromJSON(); + ppage = new ProjectPageComposite(getContainer(), project); + int index = addPage(ppage); + setPageText(index, "Project"); + } + /** + * Creates page 2 of the multi-page editor, + * which shows the pattern recommender. + */ + void createPatternPage() { + + patPage = new PatternPageComposite(getContainer(), SWT.NONE,patterns); + + + int index = addPage(patPage); + setPageText(index, "Patterns"); + } + /** + * Creates the pages of the multi-page editor. + */ + protected void createPages() { + createJSONPage(); + createProjectPage(); + createPatternPage(); + setActivePage(1); + refreshOutlineView(); + } + /** + * The <code>MultiPageEditorPart</code> implementation of this + * <code>IWorkbenchPart</code> method disposes all nested editors. + * Subclasses may extend. + */ + public void dispose() { + ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); + super.dispose(); + } + /** + * Saves the multi-page editor's document. + */ + public void doSave(IProgressMonitor monitor) { + getEditor(0).doSave(monitor); + } + /** + * Saves the multi-page editor's document as another file. + * Also updates the text for page 0's tab, and updates this multi-page editor's input + * to correspond to the nested editor's. + */ + public void doSaveAs() { + IEditorPart editor = getEditor(0); + editor.doSaveAs(); + setPageText(0, editor.getTitle()); + setInput(editor.getEditorInput()); + } + /* (non-Javadoc) + * Method declared on IEditorPart + */ + public void gotoMarker(IMarker marker) { + setActivePage(0); + IDE.gotoMarker(getEditor(0), marker); + } + /** + * The <code>MultiPageEditorExample</code> implementation of this method + * checks that the input is an instance of <code>IFileEditorInput</code>. + */ + public void init(IEditorSite site, IEditorInput editorInput) + throws PartInitException { + if (!(editorInput instanceof IFileEditorInput)) + throw new PartInitException("Invalid Input: Must be IFileEditorInput"); + super.init(site, editorInput); + } + /* (non-Javadoc) + * Method declared on IEditorPart. + */ + public boolean isSaveAsAllowed() { + return true; + } + + /** + * Calculates the contents of the then visible page when the it is activated. + */ + protected void pageChange(int newPageIndex) { + super.pageChange(newPageIndex); + + switch (newPageIndex) { + case 0: + toJSON(); + break; + case 1: + fromJSON(); + ppage.refreshContent(project); + break; + case 2: + toJSON(); + recomputeNFRs(); + + break; + } + + } + /** + * Closes all project files on project close. + */ + public void resourceChanged(final IResourceChangeEvent event){ + if(event.getType() == IResourceChangeEvent.PRE_CLOSE){ + Display.getDefault().asyncExec(new Runnable(){ + public void run(){ + IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages(); + for (int i = 0; i<pages.length; i++){ + if(((FileEditorInput)editor.getEditorInput()).getFile().getProject().equals(event.getResource())){ + IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput()); + pages[i].closeEditor(editorPart,true); + } + } + } + }); + } + } + + void recomputeNFRs() { + java.util.List<Resource> nfrs = new ArrayList<Resource>();; + for(Microservice m: project.getMicroservices()) { + nfrs.addAll(m.getNfrs()); + } + patPage.updatePatterns(nfrs); + } + + + + /** + * Converts JSON into a project Object + */ + void fromJSON() { + + + + String editorText = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get(); + AppDescriptorWrapper app = null; + try { + app = JsonHandler.toAppDescriptor(editorText); + } catch (JsonSyntaxException e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + MessageDialog.openWarning(getSite().getShell(), "JSON file corrupt",e.getLocalizedMessage()); + + } + if (app != null) { + + if( app.isOldVersion()){ + MessageDialog.openWarning(getSite().getShell(), "Older version detected", + "The application description file has a different Versionnumber than the one used in this version of " + + "the DECIDE plugin. This means, that some fields might be missing or that some pages of the editor " + + "might not work correctly. " + + "\nFile version is: " + app.getFileVersion() + + "\nPlugin uses: "+AppDescriptor.plugin_version +"."); + } + + + project = app.getAppDescriptor(); + } + if (project == null) { + System.out.println("project is null after reading JSON"); + } + + + + + } + + + + /** + * Converts a project Object into JSON + */ + void toJSON() { + if (project != null) { + + // convert app descriptor object to json string + String contents = JsonHandler.fromAppDescriptor(project); + // get editor content + String editorText = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get(); + + // if new json string is different from editor content, replace old with new + if (contents != editorText) + editor.getDocumentProvider().getDocument(editor.getEditorInput()).set(contents); + + } + } + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public Object getAdapter(Class key) { + if (key.equals(IContentOutlinePage.class)) { + //return showOutlineView() ? getContentOutlinePage() : null; + return getContentOutlinePage(); + } else { + return super.getAdapter(key); + } + } + + + /** + * This accesses a cached version of the content outliner. + */ + public IContentOutlinePage getContentOutlinePage() { + if (contentOutlinePage == null) { + contentOutlinePage = (IContentOutlinePage) editor.getAdapter(IContentOutlinePage.class); + + } + return contentOutlinePage; + } + + /** + * @see org.eclipse.ui.part.MultiPageEditorPart#createSite(org.eclipse.ui.IEditorPart) + */ + protected IEditorSite createSite(IEditorPart page) { + IEditorSite site = null; + if (page == editor) { + site = new MultiPageEditorSite(this, page) { + public String getId() { + // Sets this ID so nested editor is configured for JSON source + return ContentTypeIdForJSON.ContentTypeID_JSON + ".source"; //$NON-NLS-1$; + } + }; + } + else { + site = super.createSite(page); + } + return site; + } + /** + * Sorts the words in page 0, and shows them in page 2. + */ + void sortWords() { + + + } + + public void refreshOutlineView() { + //get the activePage + IWorkbenchPage wp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + //Find desired view by its visual ID + IViewPart myView=wp.findView("org.eclipse.ui.views.ContentOutline"); + + //Hide the view : + wp.hideView(myView); + try { + //show the view again + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.ui.views.ContentOutline"); + } catch (PartInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/editor/MultiPageEditorContributor.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/editor/MultiPageEditorContributor.java new file mode 100644 index 0000000000000000000000000000000000000000..1be6a169c0dd50e0b5d307d18c12218949c96a88 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/editor/MultiPageEditorContributor.java @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.editor; + +import org.eclipse.jface.action.*; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.ide.IDEActionFactory; +import org.eclipse.ui.part.MultiPageEditorActionBarContributor; +import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.ui.texteditor.ITextEditorActionConstants; + +/** + * Manages the installation/deinstallation of global actions for multi-page editors. + * Responsible for the redirection of global actions to the active editor. + * Multi-page contributor replaces the contributors for the individual editors in the multi-page editor. + */ +public class MultiPageEditorContributor extends MultiPageEditorActionBarContributor { + private IEditorPart activeEditorPart; + private Action sampleAction; + /** + * Creates a multi-page contributor. + */ + public MultiPageEditorContributor() { + super(); + createActions(); + } + /** + * Returns the action registed with the given text editor. + * @return IAction or null if editor is null. + */ + protected IAction getAction(ITextEditor editor, String actionID) { + return (editor == null ? null : editor.getAction(actionID)); + } + /* (non-JavaDoc) + * Method declared in AbstractMultiPageEditorActionBarContributor. + */ + + public void setActivePage(IEditorPart part) { + if (activeEditorPart == part) + return; + + activeEditorPart = part; + + IActionBars actionBars = getActionBars(); + if (actionBars != null) { + + ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null; + + actionBars.setGlobalActionHandler( + ActionFactory.DELETE.getId(), + getAction(editor, ITextEditorActionConstants.DELETE)); + actionBars.setGlobalActionHandler( + ActionFactory.UNDO.getId(), + getAction(editor, ITextEditorActionConstants.UNDO)); + actionBars.setGlobalActionHandler( + ActionFactory.REDO.getId(), + getAction(editor, ITextEditorActionConstants.REDO)); + actionBars.setGlobalActionHandler( + ActionFactory.CUT.getId(), + getAction(editor, ITextEditorActionConstants.CUT)); + actionBars.setGlobalActionHandler( + ActionFactory.COPY.getId(), + getAction(editor, ITextEditorActionConstants.COPY)); + actionBars.setGlobalActionHandler( + ActionFactory.PASTE.getId(), + getAction(editor, ITextEditorActionConstants.PASTE)); + actionBars.setGlobalActionHandler( + ActionFactory.SELECT_ALL.getId(), + getAction(editor, ITextEditorActionConstants.SELECT_ALL)); + actionBars.setGlobalActionHandler( + ActionFactory.FIND.getId(), + getAction(editor, ITextEditorActionConstants.FIND)); + actionBars.setGlobalActionHandler( + IDEActionFactory.BOOKMARK.getId(), + getAction(editor, IDEActionFactory.BOOKMARK.getId())); + actionBars.updateActionBars(); + } + } + private void createActions() { + sampleAction = new Action() { + public void run() { + MessageDialog.openInformation(null, "Wizardtest", "Sample Action Executed"); + } + }; + sampleAction.setText("Sample Action"); + sampleAction.setToolTipText("Sample Action tool tip"); + sampleAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages(). + getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK)); + } + public void contributeToMenu(IMenuManager manager) { + IMenuManager menu = new MenuManager("Editor &Menu"); + manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, menu); + menu.add(sampleAction); + } + public void contributeToToolBar(IToolBarManager manager) { + manager.add(new Separator()); + manager.add(sampleAction); + } +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/ContentChangeListener.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/ContentChangeListener.java new file mode 100644 index 0000000000000000000000000000000000000000..94d0ddc441548bce04fc9f8b98e2411a15149282 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/ContentChangeListener.java @@ -0,0 +1,19 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.layoutComponents; + +public interface ContentChangeListener { + + public void contentChanged(); +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/MicroserviceComposite.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/MicroserviceComposite.java new file mode 100644 index 0000000000000000000000000000000000000000..46e58ce1968542ab2168cfcc2e4878a667c7c9cc --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/MicroserviceComposite.java @@ -0,0 +1,375 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.layoutComponents; + +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Text; +import org.eclipse.wb.swt.SWTResourceManager; + +import eu.DECIDEh2020.architect.appManager.models.Microservice; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.Viewer; +import org.apache.jena.rdf.model.Resource; +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.core.databinding.beans.PojoProperties; + +public class MicroserviceComposite extends Composite { + private DataBindingContext m_bindingContext; + + private static class DependecyLabelProvider extends LabelProvider { + public Image getImage(Object element) { + return null; + } + + public String getText(Object element) { + return (String) element; + } + } + + private static class DependecyContentProvider implements IStructuredContentProvider { + public Object[] getElements(Object inputElement) { + return ((Microservice) inputElement).getDependencies().toArray(); + } + + public void dispose() { + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + } + + Color background = SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND); + private Button btnStateless; + private Microservice microservice; + private java.util.List<ContentChangeListener> contentChangeListeners = new ArrayList<ContentChangeListener>(); + private Text txtAddDependency; + private Text msRepo; + + + + + /** + * Create the composite. + * + * @param parent + * @param style + */ + public MicroserviceComposite(Composite parent, Microservice microservice, Color background) { + super(parent, SWT.None); + this.background = background; + setBackground(background); + this.microservice = microservice; + + this.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); + this.setLayout(new FillLayout(SWT.HORIZONTAL)); + + Group grpMicroservice = new Group(this, SWT.NONE); + grpMicroservice.setBackground(background); + grpMicroservice.setText(microservice.getName()); + grpMicroservice.setLayout(new FillLayout(SWT.HORIZONTAL)); + + Composite composite = new Composite(grpMicroservice, SWT.NONE); + composite.setBackground(background); + GridLayout gl_composite = new GridLayout(2, false); + gl_composite.marginLeft = 10; + gl_composite.marginRight = 10; + composite.setLayout(gl_composite); + + Label lblNewLabel = new Label(composite, SWT.NONE); + lblNewLabel.setBackground(background); + lblNewLabel.setText("Microservice Name:"); + + Text textMsvName = new Text(composite, SWT.BORDER); + textMsvName.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + microservice.setName(textMsvName.getText()); + grpMicroservice.setText(microservice.getName()); + setContentChanged(); + } + }); + textMsvName.setText(grpMicroservice.getText()); + textMsvName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblProgrammingLanguage = new Label(composite, SWT.NONE); + lblProgrammingLanguage.setBackground(background); + lblProgrammingLanguage.setText("Programming Language:"); + + Combo comboProgrammingLanguage = new Combo(composite, SWT.NONE); + comboProgrammingLanguage.addKeyListener(new KeyAdapter() { + + @Override + public void keyReleased(KeyEvent e) { + microservice.setLanguage(comboProgrammingLanguage.getText()); + } + }); + + comboProgrammingLanguage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + comboProgrammingLanguage.setItems(new String[] { "Java", "Go", "Ruby" }); + + // set combobox to language. if language not in Combobox, add it + String msvLang = microservice.getLanguage(); + int index = -1; + if (msvLang != null && !msvLang.isEmpty()) { + index = comboProgrammingLanguage.indexOf(msvLang); + } + if (index >= 0) { + comboProgrammingLanguage.select(index); + } else if (index == -1 && !msvLang.isEmpty()) { + comboProgrammingLanguage.add(msvLang, 0); + comboProgrammingLanguage.select(0); + } + + comboProgrammingLanguage.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + microservice.setLanguage(comboProgrammingLanguage.getText()); + } + }); + + Label lblType = new Label(composite, SWT.NONE); + lblType.setBackground(background); + lblType.setText("Type:"); + + Combo comboType = new Combo(composite, SWT.READ_ONLY); + comboType.setItems(new String[] { "Backend", "Database" }); + String msvType = microservice.getType(); + if (msvType != null && !msvType.isEmpty()) { + comboType.select(comboType.indexOf(msvType)); + } + + comboType.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + microservice.setType(comboType.getText()); + } + }); + + comboType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblNfr = new Label(composite, SWT.NONE); + lblNfr.setBackground(background); + lblNfr.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblNfr.setText("NFRs:"); + + NfrListViewer nfrList = new NfrListViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); + + // select all nfrs in this microservice + if (microservice.getNfrs().size() != 0) { + + nfrList.addSelection(new ArrayList<Resource>(microservice.getNfrs())); + } + + nfrList.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + HashSet<Resource> mscNfrs = new HashSet<Resource>(); + for (Resource r : nfrList.getSelection()) { + try { + mscNfrs.add(r); + } catch (IllegalArgumentException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + microservice.setNfrs(mscNfrs); + } + }); + + GridData gd_nfrList = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); + gd_nfrList.widthHint = 448; + nfrList.setLayoutData(gd_nfrList); + + Label lblDependencies = new Label(composite, SWT.NONE); + lblDependencies.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblDependencies.setText("Dependencies:"); + lblDependencies.setBackground(background); + + Composite dependenciesComposite = new Composite(composite, SWT.NONE); + GridLayout gl_dependenciesComposite = new GridLayout(2, false); + gl_dependenciesComposite.marginLeft = -5; + dependenciesComposite.setLayout(gl_dependenciesComposite); + dependenciesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + dependenciesComposite.setBackground(background); + + ListViewer listViewer = new ListViewer(dependenciesComposite, SWT.BORDER | SWT.V_SCROLL); + List dependencyList = listViewer.getList(); + + GridData gd_dependencyList = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); + gd_dependencyList.minimumHeight = 85; + gd_dependencyList.heightHint = 85; + dependencyList.setLayoutData(gd_dependencyList); + listViewer.setLabelProvider(new DependecyLabelProvider()); + listViewer.setContentProvider(new DependecyContentProvider()); + listViewer.setInput(microservice); + + Composite DepBttnComposite = new Composite(dependenciesComposite, SWT.NONE); + DepBttnComposite.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1)); + FillLayout fl_DepBttnComposite = new FillLayout(SWT.VERTICAL); + fl_DepBttnComposite.spacing = 5; + DepBttnComposite.setLayout(fl_DepBttnComposite); + DepBttnComposite.setBackground(background); + + Button btnRemove = new Button(DepBttnComposite, SWT.NONE); + btnRemove.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (dependencyList.getSelectionCount() == 1) { + int i= dependencyList.getSelectionIndex(); + ArrayList<String> deps = microservice.getDependencies(); + deps.remove(i); + listViewer.refresh(); + } + } + }); + btnRemove.setText("Remove"); + + txtAddDependency = new Text(dependenciesComposite, SWT.BORDER); + txtAddDependency.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Button btnAdd = new Button(dependenciesComposite, SWT.NONE); + btnAdd.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + microservice.addDependency(txtAddDependency.getText()); + listViewer.refresh(); + txtAddDependency.setText(""); + } + }); + btnAdd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + btnAdd.setText("Add"); + + dependencyList.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (dependencyList.getSelectionCount() == 1) { + btnRemove.setEnabled(true); + }else { + btnRemove.setEnabled(false); + } + } + }); + + new Label(composite, SWT.NONE); + + btnStateless = new Button(composite, SWT.CHECK); + btnStateless.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + btnStateless.setSelection(microservice.isStateless()); + btnStateless.setBackground(background); + btnStateless.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + microservice.setStateless(btnStateless.getSelection()); + } + }); + btnStateless.setText("Stateless"); + + Label lblMsRepo = new Label(composite, SWT.NONE); + lblMsRepo.setBackground(background); + lblMsRepo.setText("Microservice Repo : "); + + msRepo = new Text(composite, SWT.BORDER); + msRepo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + new Label(composite, SWT.NONE); +/* + Composite composite_msRepo_buttons = new Composite(composite, SWT.NONE); + composite_msRepo_buttons.setBackground(background); + FillLayout fl_composite_msRepo_buttons = new FillLayout(SWT.HORIZONTAL); + fl_composite_msRepo_buttons.spacing = 5; + composite_msRepo_buttons.setLayout(fl_composite_msRepo_buttons); + + Button btnAddNewRepo = new Button(composite_msRepo_buttons, SWT.NONE); + btnAddNewRepo.setEnabled(false); + btnAddNewRepo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + NewMscvWizard mscw = new NewMscvWizard(); + WizardDialog dialog = new WizardDialog(getShell(), mscw); + if (dialog.open() == Window.OK) { + msRepo.setText(mscw.getProject()); + } else { + msRepo.setText(""); + + } + + } + }); + btnAddNewRepo.setText("Add New Microservice");*/ + m_bindingContext = initDataBindings(); + + + } + + /** + * Create the composite. + * + * @param parent + * @param microservice + * @wbp.parser.constructor + */ + public MicroserviceComposite(Composite parent, Microservice microservice) { + this(parent, microservice, SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); + + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + public void addContentChangeListener(ContentChangeListener contentChangedListener) { + contentChangeListeners.add(contentChangedListener); + } + + public void setContentChanged() { + for (ContentChangeListener ccl : contentChangeListeners) { + ccl.contentChanged(); + } + } + + protected DataBindingContext initDataBindings() { + DataBindingContext bindingContext = new DataBindingContext(); + // + IObservableValue observeTextMsRepoObserveWidget = WidgetProperties.text(SWT.Modify).observe(msRepo); + IObservableValue repoMicroserviceObserveValue = PojoProperties.value("repo").observe(microservice); + bindingContext.bindValue(observeTextMsRepoObserveWidget, repoMicroserviceObserveValue, null, null); + // + return bindingContext; + } +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/MicroserviceListComposite.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/MicroserviceListComposite.java new file mode 100644 index 0000000000000000000000000000000000000000..48d2755c06b1c2a5e119d4943f43b999b89e29b7 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/MicroserviceListComposite.java @@ -0,0 +1,239 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.layoutComponents; + +import java.util.ArrayList; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Spinner; + +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.appManager.models.Microservice; + + +public class MicroserviceListComposite extends Composite { + private AppDescriptor project; + private ListViewer listViewerMscvs; + private java.util.List<PageCompleteListener> pageCompleteListeners = new ArrayList<PageCompleteListener>(); + private java.util.List<ContentChangeListener> contentChangeListeners = new ArrayList<ContentChangeListener>(); + + private static class MicroserviceLabelProvider extends LabelProvider { + public Image getImage(Object element) { + return null; + } + public String getText(Object element) { + return ((Microservice) element).getName(); + } + } + + + private static class MicroserviceContentProvider implements IStructuredContentProvider { + public Object[] getElements(Object inputElement) { + return ((AppDescriptor) inputElement).getMicroservices().toArray(); + } + public void dispose() { + } + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + } + + + + /** + * Create the composite. + * @param parent + * @param style + */ + public MicroserviceListComposite(Composite parent, int style, AppDescriptor project, Boolean showListLabel, Color background) { + super(parent, SWT.NONE); + this.project = project; + setBackground(background); + setLayout(new GridLayout(2, false)); + + Composite composite = new Composite(this, SWT.NONE); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + composite.setLayout(new GridLayout(2, false)); + composite.setBackground(background); + + + // only show this label if needed + if(showListLabel) { + Label lblListMscv = new Label(composite, SWT.NONE); + lblListMscv.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblListMscv.setText("List of Microservices:"); + lblListMscv.setBackground(background); + } + + listViewerMscvs = new ListViewer(composite, SWT.BORDER | SWT.V_SCROLL); + List listMscvs = listViewerMscvs.getList(); + listMscvs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + listViewerMscvs.setLabelProvider(new MicroserviceLabelProvider()); + listViewerMscvs.setContentProvider(new MicroserviceContentProvider()); + listViewerMscvs.setInput(project); + + + + + + + Composite compositeMscvUpDown = new Composite(this, SWT.NONE); + compositeMscvUpDown.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); + FillLayout fl_compositeMscvUpDown = new FillLayout(SWT.VERTICAL); + fl_compositeMscvUpDown.marginHeight = 5; + fl_compositeMscvUpDown.spacing = 5; + compositeMscvUpDown.setLayout(fl_compositeMscvUpDown); + compositeMscvUpDown.setBackground(background); + + Button btnUp = new Button(compositeMscvUpDown, SWT.NONE); + btnUp.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + project.changeIndex(listMscvs.getSelectionIndex(), -1); + listViewerMscvs.refresh(); + setContentChanged(); + } + }); + btnUp.setEnabled(false); + btnUp.setText("Up"); + + Button btnDown = new Button(compositeMscvUpDown, SWT.NONE); + btnDown.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + //move(-1); + project.changeIndex(listMscvs.getSelectionIndex(), 1); + listViewerMscvs.refresh(); + setContentChanged(); + } + }); + btnDown.setEnabled(false); + btnDown.setText("Down"); + + Composite composite_1 = new Composite(this, SWT.NONE); + composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + composite_1.setLayout(new GridLayout(2, false)); + composite_1.setBackground(background); + + Label lblAddMicroservices = new Label(composite_1, SWT.NONE); + lblAddMicroservices.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + lblAddMicroservices.setText("Add Microservices:"); + lblAddMicroservices.setBackground(background); + + Composite compositeMscvAdd = new Composite(composite_1, SWT.NONE); + FillLayout fl_compositeMscvAdd = new FillLayout(SWT.HORIZONTAL); + fl_compositeMscvAdd.spacing = 15; + compositeMscvAdd.setLayout(fl_compositeMscvAdd); + compositeMscvAdd.setBackground(background); + + Spinner spinner = new Spinner(compositeMscvAdd, SWT.BORDER); + spinner.setMinimum(1); + spinner.setSelection(1); + + Button btnAddMscv = new Button(compositeMscvAdd, SWT.NONE); + btnAddMscv.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + project.addMicroservices(spinner.getSelection()); + listViewerMscvs.refresh(); + setContentChanged(); + setPageComplete(project.getMicroservices().size()>0); + } + }); + btnAddMscv.setText("Add"); + + + Button btnRemoveMsvc = new Button(this, SWT.NONE); + btnRemoveMsvc.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + project.removeMicroservice(listMscvs.getSelectionIndex()); + listViewerMscvs.refresh(); + setContentChanged(); + setPageComplete(project.getMicroservices().size()>0); + } + }); + btnRemoveMsvc.setEnabled(false); + btnRemoveMsvc.setText("Remove"); + + + listMscvs.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + if(listMscvs.getSelectionCount()==1) { + //TODO: Disabling buttons if topmost or bottommost does not work + if(listMscvs.getSelectionIndex()!=0)btnUp.setEnabled(true); + if(listMscvs.getSelectionIndex()!=listMscvs.getItemCount()-1)btnDown.setEnabled(true); + btnRemoveMsvc.setEnabled(true); + }else if(listMscvs.getSelectionCount()>0) { + btnRemoveMsvc.setEnabled(true); + btnUp.setEnabled(false); + btnDown.setEnabled(false); + + }else { + btnRemoveMsvc.setEnabled(false); + btnUp.setEnabled(false); + btnDown.setEnabled(false); + } + } + }); + + } + + public void refresh() { + listViewerMscvs.refresh(); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + public void addContentChangeListener(ContentChangeListener contentChangedListener) { + contentChangeListeners.add(contentChangedListener); + } + + public void addPageCompleteListener(PageCompleteListener pageCompleteListener) { + pageCompleteListeners.add(pageCompleteListener); + } + + public void setContentChanged() { + for(ContentChangeListener ccl : contentChangeListeners) { + ccl.contentChanged(); + } + } + + public void setPageComplete(Boolean complete) { + for(PageCompleteListener pcl : pageCompleteListeners) { + pcl.pageCompleted(complete); + } + } + +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/NfrListViewer.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/NfrListViewer.java new file mode 100644 index 0000000000000000000000000000000000000000..044058335f02b2897fb5024798d867ded0f94af8 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/NfrListViewer.java @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.layoutComponents; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.List; + + +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; + +import java.util.Arrays; +import java.util.EnumSet; +import java.util.HashSet; + +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.Statement; +import org.apache.jena.vocabulary.DCTerms; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; + +public class NfrListViewer extends Composite { + private static class NFRLabelProvider extends LabelProvider { + public Image getImage(Object element) { + return null; + } + public String getText(Object element) { + return ((Resource) element).getProperty(DCTerms.title).getString(); + } + } + + + private static class NFRContentProvider implements IStructuredContentProvider { + @SuppressWarnings("unchecked") + public Object[] getElements(Object inputElement) { + return ((java.util.List<Resource>) inputElement).toArray(); + + } + public void dispose() { + } + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + } + + private List list; + private ListViewer listViewer; + + /** + * Create the composite. + * @param parent + * @param style + */ + public NfrListViewer(Composite parent, int style) { + super(parent, SWT.NONE); + setLayout(new FillLayout(SWT.HORIZONTAL)); + Patterns patterns = Patterns.createDefaultPatterns(); + java.util.List<Resource> nfrs = patterns.listNFRs(); + + + listViewer = new ListViewer(this, style); + list = listViewer.getList(); + + + listViewer.setLabelProvider(new NFRLabelProvider()); + listViewer.setContentProvider(new NFRContentProvider()); + listViewer.setInput(nfrs); + + + } + + + public java.util.List<Resource> getSelection(){ + @SuppressWarnings("unchecked") + java.util.List<Resource> selection = listViewer.getStructuredSelection().toList(); + + return selection; + + + + + } + + + public void addSelection(java.util.List<Resource> nfrs) { + + + HashSet<String> selection = new HashSet<String>(Arrays.asList(list.getSelection())); + + for(Resource nfr: nfrs) { + Statement title = nfr.getProperty(DCTerms.title); + String stitle = title.getString(); + selection.add(stitle); + } + list.setSelection(selection.toArray(new String[selection.size()])); + + } + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + public void addSelectionListener(SelectionAdapter a) { + list.addSelectionListener(a); + } + + +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PageCompleteListener.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PageCompleteListener.java new file mode 100644 index 0000000000000000000000000000000000000000..726ac46e8936c83c6bb25a6b33fc38f446a036c3 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PageCompleteListener.java @@ -0,0 +1,19 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.layoutComponents; + +public interface PageCompleteListener { + + public void pageCompleted(Boolean complete); +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PatternDetailComposite.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PatternDetailComposite.java new file mode 100644 index 0000000000000000000000000000000000000000..e0f1ca12f020302355450fe8e9f9831d3cec5564 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PatternDetailComposite.java @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.layoutComponents; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.wb.swt.SWTResourceManager; + +import eu.DECIDEh2020.architect.cloudpatterns.DP; + +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.Statement; +import org.apache.jena.vocabulary.DCTerms; +import org.apache.jena.vocabulary.SKOS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.browser.Browser; + +public class PatternDetailComposite extends Composite { + private Text txtPatternType; + private Resource pattern; + private Text txtSubject; + private Text txtDescription; + private Text txtContext; + private Text txtSolution; + /** + * Create the composite. + * @param parent + * @param style + */ + public PatternDetailComposite(Composite parent, int style) { + super(parent, style); + + createGUI(); + + + } + private void createGUI() { + setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + setLayout(new GridLayout(2, false)); + + Label lblPatternType = new Label(this, SWT.NONE); + lblPatternType.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblPatternType.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblPatternType.setText("Type:"); + + txtPatternType = new Text(this, SWT.BORDER | SWT.READ_ONLY); + txtPatternType.setText("Fundamental Pattern"); + txtPatternType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblSubject = new Label(this, SWT.NONE); + lblSubject.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblSubject.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblSubject.setText("Subject:"); + + txtSubject = new Text(this, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL); + txtSubject.setText("subject"); + GridData gd_txtSubject = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + gd_txtSubject.heightHint = 50; + txtSubject.setLayoutData(gd_txtSubject); + + Label lblDescription = new Label(this, SWT.NONE); + lblDescription.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblDescription.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblDescription.setText("Description:"); + + txtDescription = new Text(this, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI); + txtDescription.setText("description"); + GridData gd_txtDescription = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + gd_txtDescription.heightHint = 75; + txtDescription.setLayoutData(gd_txtDescription); + + Label lblContext = new Label(this, SWT.NONE); + lblContext.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblContext.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblContext.setText("Context:"); + + txtContext = new Text(this, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL); + txtContext.setText("context"); + GridData gd_txtContext = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + gd_txtContext.heightHint = 75; + txtContext.setLayoutData(gd_txtContext); + + Label lblSolution = new Label(this, SWT.NONE); + lblSolution.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblSolution.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblSolution.setText("Solution:"); + + txtSolution = new Text(this, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI); + txtSolution.setText("solution"); + GridData gd_txtSolution = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + gd_txtSolution.heightHint = 75; + txtSolution.setLayoutData(gd_txtSolution); + updatePattern(null); + } + + public void updatePattern(Resource pattern) { + txtPatternType.setText(pattern!=null?pattern.getProperty(DCTerms.type).getResource().getProperty(SKOS.prefLabel).getString():""); + if(pattern!=null) { + + + Statement stmt = pattern.getProperty(DCTerms.subject); + + txtSubject.setText(stmt!=null?stmt.getString():""); + stmt= pattern.getProperty(DCTerms.description); + txtDescription.setText(stmt!=null?stmt.getString():""); + stmt= pattern.getProperty(DP.context); + txtContext.setText(stmt!=null?stmt.getString():""); + stmt= pattern.getProperty(DP.solution); + txtSolution.setText(stmt!=null?stmt.getString():""); + }else { + txtSubject.setText(""); + txtDescription.setText(""); + txtContext.setText(""); + txtSolution.setText(""); + + } + + redraw(); + } + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PatternPageComposite.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PatternPageComposite.java new file mode 100644 index 0000000000000000000000000000000000000000..426fac3ad33410e2b91398bf7b57f488d85e4412 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/PatternPageComposite.java @@ -0,0 +1,269 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.layoutComponents; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.layout.GridData; +import org.eclipse.wb.swt.SWTResourceManager; + +import eu.DECIDEh2020.architect.cloudpatterns.Patterns; + +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.widgets.List; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.custom.StyledText; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.vocabulary.DCTerms; +import org.eclipse.jface.text.TextViewer; +import org.eclipse.swt.widgets.Table; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.CheckStateChangedEvent; + + +public class PatternPageComposite extends Composite { + + private Patterns patterns; + private ListViewer listViewer_selected; + private CheckboxTableViewer checkboxTableViewer_bad,checkboxTableViewer_good; + private PatternDetailComposite patternDetailComposite; + private Table table_bad, table_good; + private java.util.List<Resource> selectedPatterns = new ArrayList<Resource>(); + + private static class PatternLabelProvider extends LabelProvider { + public Image getImage(Object element) { + return null; + } + public String getText(Object element) { + return ((Resource) element).getProperty(DCTerms.title).getString(); + } + } + + + private static class PatternContentProvider implements IStructuredContentProvider { + @SuppressWarnings("unchecked") + public Object[] getElements(Object inputElement) { + return ((java.util.List<Patterns>) inputElement).toArray(); + + } + public void dispose() { + } + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + } + + /** + * Create the composite. + * @param parent + * @param style + */ + public PatternPageComposite(Composite parent, int style, Patterns patterns) { + super(parent, style); + this.patterns= patterns; + createGUI(); + + + } + private void createGUI() { + setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + setLayout(new GridLayout(1, false)); + + CLabel lblDesignPatterns = new CLabel(this, SWT.NONE); + lblDesignPatterns.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.BOLD)); + lblDesignPatterns.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblDesignPatterns.setText("Design Patterns"); + + Label label = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL); + label.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.BOLD)); + label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Composite composite_1 = new Composite(this, SWT.NONE); + composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + composite_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + GridLayout gl_composite_1 = new GridLayout(2, true); + gl_composite_1.horizontalSpacing = 25; + composite_1.setLayout(gl_composite_1); + + Label lblSuggestedPatterns = new Label(composite_1, SWT.NONE); + lblSuggestedPatterns.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); + lblSuggestedPatterns.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + lblSuggestedPatterns.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblSuggestedPatterns.setText("Suggested Patterns"); + + Label lblPatternDetail = new Label(composite_1, SWT.NONE); + lblPatternDetail.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); + lblPatternDetail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + lblPatternDetail.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblPatternDetail.setText("Pattern detail"); + + Composite composite_2 = new Composite(composite_1, SWT.NONE); + composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + composite_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + composite_2.setLayout(new GridLayout(1, false)); + + + + checkboxTableViewer_good = CheckboxTableViewer.newCheckList(composite_2, SWT.BORDER | SWT.FULL_SELECTION); + table_good = checkboxTableViewer_good.getTable(); + + table_good.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + checkboxTableViewer_good.setLabelProvider(new PatternLabelProvider()); + checkboxTableViewer_good.setContentProvider(new PatternContentProvider()); + checkboxTableViewer_good.setInput(patterns.listPatterns()); + + + Label lblbadPatterns = new Label(composite_2, SWT.NONE); + lblbadPatterns.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + lblbadPatterns.setText("Bad Patterns"); + lblbadPatterns.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblbadPatterns.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); + + + + checkboxTableViewer_bad = CheckboxTableViewer.newCheckList(composite_2, SWT.BORDER | SWT.FULL_SELECTION); + checkboxTableViewer_bad.setAllGrayed(true); + + table_bad = checkboxTableViewer_bad.getTable(); + + table_bad.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + checkboxTableViewer_bad.setLabelProvider(new PatternLabelProvider()); + checkboxTableViewer_bad.setContentProvider(new PatternContentProvider()); + checkboxTableViewer_bad.setInput(patterns.listPatterns()); + + + + Label lblWhyNeccessary = new Label(composite_2, SWT.NONE); + lblWhyNeccessary.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); + lblWhyNeccessary.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + lblWhyNeccessary.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblWhyNeccessary.setText("Selected Patterns"); + + listViewer_selected = new ListViewer(composite_2, SWT.BORDER | SWT.V_SCROLL); + List list_selected = listViewer_selected.getList(); + + list_selected.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + list_selected.setBounds(0, 0, 88, 68); + listViewer_selected.setLabelProvider(new PatternLabelProvider()); + listViewer_selected.setContentProvider(new PatternContentProvider()); + listViewer_selected.setInput(selectedPatterns); + + patternDetailComposite = new PatternDetailComposite(composite_1, SWT.NONE); + patternDetailComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + + + checkboxTableViewer_good.addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + if(event.getChecked()) { + selectedPatterns.add((Resource) event.getElement()); + }else { + + selectedPatterns.remove(event.getElement()); + } + listViewer_selected.refresh(); + } + }); + + list_selected.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + int i= list_selected.getSelectionIndex(); + if(i>=0) { + Resource pattern = (Resource) listViewer_selected.getElementAt(i); + patternDetailComposite.updatePattern(pattern); + + } + } + }); + + table_bad.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + int i= table_bad.getSelectionIndex(); + if(i>=0) { + Resource pattern = (Resource) checkboxTableViewer_bad.getElementAt(i); + patternDetailComposite.updatePattern(pattern); + + } + } + }); + table_good.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + int i = table_good.getSelectionIndex(); + if(i>=0) { + Resource pattern = (Resource) checkboxTableViewer_good.getElementAt(i); + patternDetailComposite.updatePattern(pattern); + + } + } + }); + if(table_good.getItemCount()>0) { + table_good.select(0); + patternDetailComposite.updatePattern((Resource) checkboxTableViewer_good.getElementAt(0)); + } + } + + + + public void updatePatterns(java.util.List<Resource> nfrs) { + + java.util.List<Resource> inferredPatterns = patterns.inferPatterns(nfrs); + + + if(!inferredPatterns.equals((java.util.List<Resource>)checkboxTableViewer_good.getInput())) { + checkboxTableViewer_good.setInput(inferredPatterns); + selectedPatterns.clear(); + + + Object[] sr = checkboxTableViewer_good.getCheckedElements(); + + selectedPatterns.addAll((Collection<? extends Resource>) Arrays.asList(sr) ); + listViewer_selected.refresh(); + + } + + + + checkboxTableViewer_bad.setInput(patterns.inferBadPatterns(nfrs)); + + if(table_good.getItemCount()>0) { + table_good.select(0); + patternDetailComposite.updatePattern((Resource) checkboxTableViewer_good.getElementAt(0)); + }else { + patternDetailComposite.updatePattern(null); + } + + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/ProjectPageComposite.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/ProjectPageComposite.java new file mode 100644 index 0000000000000000000000000000000000000000..504aaec0e17548c4cc2371a57a937a54d7c8375f --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/layoutComponents/ProjectPageComposite.java @@ -0,0 +1,339 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.layoutComponents; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.LinkedList; + +import org.apache.jena.rdf.model.Resource; +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.core.databinding.beans.PojoProperties; +import org.eclipse.swt.graphics.Color; +import org.eclipse.wb.swt.SWTResourceManager; + +import eu.DECIDEh2020.architect.appManager.models.AppDescriptor; +import eu.DECIDEh2020.architect.appManager.models.Microservice; + +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.jface.text.TextViewer; + +public class ProjectPageComposite extends Composite { + private DataBindingContext m_bindingContext; + + private AppDescriptor project; + private Text txtProjectname; + private Color background; + private Composite pp = this; + private MicroserviceListComposite microserviceListComposite; + private StyledText styledText; + + + + /** + * Create the composite. + * @param parent + * @param style + */ + public ProjectPageComposite(Composite parent, AppDescriptor project) { + super(parent, SWT.NONE); + + this.project = project; + background= SWTResourceManager.getColor(SWT.COLOR_WHITE); + setBackground(background); + setContent(); + requestLayout(); + } + + private void setContent() { + Control[] children = this.getChildren(); + for (int i = 0 ; i < children.length; i++) { + children[i].dispose(); + } + setLayout(new GridLayout(1, true)); + + CLabel lblOverview = new CLabel(this, SWT.NONE); + lblOverview.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.BOLD)); + lblOverview.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblOverview.setText("Overview"); + + Label label = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL); + label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Composite container = new Composite(this, SWT.NONE); + container.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1)); + container.setBackground(background); + GridLayout gl_container = new GridLayout(2,true); + gl_container.horizontalSpacing = 25; + container.setLayout(gl_container); + + CLabel lblProject = new CLabel(container, SWT.NONE); + lblProject.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); + lblProject.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblProject.setBottomMargin(0); + lblProject.setTopMargin(0); + lblProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + lblProject.setText("Project"); + + CLabel lblMicroservices = new CLabel(container, SWT.NONE); + lblMicroservices.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); + lblMicroservices.setTopMargin(0); + lblMicroservices.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblMicroservices.setBottomMargin(0); + lblMicroservices.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + lblMicroservices.setText("Microservices"); + + + + Composite composite = new Composite(container, SWT.NONE); + composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); + composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + composite.setLayout(new GridLayout(1, false)); + + + + + + Composite projectInfo = new Composite(composite, SWT.NONE); + projectInfo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + projectInfo.setSize(202, 130); + projectInfo.setBackground(background); + projectInfo.setLayout(new GridLayout(2, false)); + + Label lblProjectname = new Label(projectInfo, SWT.NONE); + lblProjectname.setBackground(background); + lblProjectname.setSize(67, 15); + lblProjectname.setText("Projectname:"); + + txtProjectname = new Text(projectInfo, SWT.BORDER); + txtProjectname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + txtProjectname.setSize(74, 21); + + Label lblProjectNfrs = new Label(projectInfo, SWT.NONE); + lblProjectNfrs.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblProjectNfrs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblProjectNfrs.setText("Project NFRs:"); + + NfrListViewer nfrListViewer = new NfrListViewer(projectInfo, SWT.BORDER | SWT.V_SCROLL| SWT.MULTI); + nfrListViewer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + nfrListViewer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); + + CLabel lblDescription = new CLabel(projectInfo, SWT.NONE); + lblDescription.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblDescription.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblDescription.setText("Description"); + + TextViewer textViewer = new TextViewer(projectInfo, SWT.BORDER | SWT.WRAP); + styledText = textViewer.getTextWidget(); + GridData gd_styledText = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + gd_styledText.minimumHeight = 80; + styledText.setLayoutData(gd_styledText); + + CLabel lblDeploymentOrder = new CLabel(composite, SWT.NONE); + lblDeploymentOrder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + lblDeploymentOrder.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); + lblDeploymentOrder.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); + lblDeploymentOrder.setBottomMargin(0); + lblDeploymentOrder.setTopMargin(0); + lblDeploymentOrder.setText("Deployment Order"); + + microserviceListComposite = new MicroserviceListComposite(composite, SWT.NONE, project, false,SWTResourceManager.getColor(SWT.COLOR_WHITE)); + microserviceListComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1)); + + + + + + txtProjectname.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (project != null) project.setName(txtProjectname.getText()); + } + }); + + + + ScrolledComposite scrolledComposite = new ScrolledComposite(container, SWT.V_SCROLL); + + + scrolledComposite.addListener(SWT.Activate, new Listener() { + public void handleEvent(Event e) { + scrolledComposite.setFocus(); + } + }); + + scrolledComposite.addListener(SWT.MouseVerticalWheel, new Listener() { + public void handleEvent(Event event) { + int wheelCount = event.count; + wheelCount = (int) Math.ceil(wheelCount / 3.0f); + while (wheelCount < 0) { + scrolledComposite.getVerticalBar().setIncrement(4); + wheelCount++; + } + + while (wheelCount > 0) { + scrolledComposite.getVerticalBar().setIncrement(-4); + wheelCount--; + } + } + }); + + scrolledComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + + + + Composite mcontainer = new Composite(scrolledComposite, SWT.NONE); + mcontainer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + mcontainer.setLayout(new GridLayout(1, false)); + addMicroservices(mcontainer); + mcontainer.requestLayout(); + + scrolledComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1)); + scrolledComposite.setContent(mcontainer); + scrolledComposite.setExpandVertical( true ); + scrolledComposite.setExpandHorizontal( true ); + int width = scrolledComposite.getClientArea().width/2; + scrolledComposite.setMinSize( mcontainer.computeSize( width, SWT.DEFAULT ) ); + + scrolledComposite.addListener( SWT.Resize, event -> { + final int w = scrolledComposite.getClientArea().width/2; + scrolledComposite.setMinSize( mcontainer.computeSize( w, SWT.DEFAULT ) ); + } ); + + // + if(project != null && project.getProjectNfrs().size() != 0) { + nfrListViewer.addSelection(new ArrayList<Resource>(project.getProjectNfrs())); + } + //when the selection in the nfr list is changed, change the underlying set of NFR enums + nfrListViewer.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (project != null) { + HashSet<Resource> mscNfrs = new HashSet<Resource>(); + for (Resource r: nfrListViewer.getSelection()) { + try { + mscNfrs.add(r); + } catch (IllegalArgumentException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + project.setProjectNfrs(mscNfrs); + mcontainer.requestLayout(); + } + } + }); + microserviceListComposite.addContentChangeListener(new ContentChangeListener() { + + @Override + public void contentChanged() { + refreshMicroservices(mcontainer); + mcontainer.requestLayout(); + + int width = scrolledComposite.getClientArea().width/2; + scrolledComposite.setMinSize( mcontainer.computeSize( width, SWT.DEFAULT ) ); + } + + }); + + m_bindingContext = initDataBindings(); + scrolledComposite.requestLayout(); + requestLayout(); + + } + + public void refreshContent(AppDescriptor project) { + this.project = project; + setContent(); + } + + public void refreshMicroservices(Composite microserviceContainer) { + + Control[] children = microserviceContainer.getChildren(); + for (int i = 0 ; i < children.length; i++) { + children[i].dispose(); + } + addMicroservices(microserviceContainer); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + + private void addMicroserviceComposite(Composite container,Microservice microservice){ + MicroserviceComposite msvContainer = new MicroserviceComposite(container, microservice, background); + msvContainer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + msvContainer.addContentChangeListener(new ContentChangeListener() { + + @Override + public void contentChanged() { + microserviceListComposite.refresh(); + + } + + }); + } + + + private void addMicroservices(Composite container) { + if (project== null)return; + LinkedList<Microservice> microservices = project.getMicroservices(); + if(microservices.size()>0){ + for(Microservice m: microservices) { + addMicroserviceComposite(container,m); + } + + } + //to test in designer + + /*Microservice m = new Microservice(); + addMicroserviceComposite(container,m);*/ + + + } + protected DataBindingContext initDataBindings() { + DataBindingContext bindingContext = new DataBindingContext(); + // + IObservableValue observeTextTxtProjectnameObserveWidget = WidgetProperties.text(new int[]{SWT.Modify, SWT.FocusOut}).observe(txtProjectname); + IObservableValue nameProjectObserveValue = PojoProperties.value("name").observe(project); + bindingContext.bindValue(observeTextTxtProjectnameObserveWidget, nameProjectObserveValue, null, null); + // + IObservableValue observeTextStyledTextObserveWidget = WidgetProperties.text(SWT.Modify).observe(styledText); + IObservableValue descriptionProjectObserveValue = PojoProperties.value("description").observe(project); + bindingContext.bindValue(observeTextStyledTextObserveWidget, descriptionProjectObserveValue, null, null); + // + return bindingContext; + } +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/natures/ProjectNature.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/natures/ProjectNature.java new file mode 100644 index 0000000000000000000000000000000000000000..37ad49e7c02e6fae5e0474888ced0a8aefde3ed7 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/natures/ProjectNature.java @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.natures; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; + +public class ProjectNature implements IProjectNature { + public static final String NATURE_ID = "eu.DECIDEh2020.architect.plugin.ProjectNature"; //$NON-NLS-1$ + private IProject project; + + @Override + public void configure() throws CoreException { + // TODO Auto-generated method stub + + } + + @Override + public void deconfigure() throws CoreException { + // TODO Auto-generated method stub + + } + + @Override + public IProject getProject() { + // TODO Auto-generated method stub + return project; + } + + @Override + public void setProject(IProject project) { + // TODO Auto-generated method stub + this.project = project; + } + +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/perspectives/Perspective.java b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/perspectives/Perspective.java new file mode 100644 index 0000000000000000000000000000000000000000..7585ea704a5ecdaa80495a15576112f02af41aac --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/eu/DECIDEh2020/architect/plugin/perspectives/Perspective.java @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Torben Jastrow (Fraunhofer FOKUS) +* +* **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ +package eu.DECIDEh2020.architect.plugin.perspectives; + +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class Perspective implements IPerspectiveFactory { + + @Override + public void createInitialLayout(IPageLayout layout) { + // TODO Auto-generated method stub + + } + +} diff --git a/ARCHITECT/EclipsePlugin/plugin/src/org/eclipse/wb/swt/SWTResourceManager.java b/ARCHITECT/EclipsePlugin/plugin/src/org/eclipse/wb/swt/SWTResourceManager.java new file mode 100644 index 0000000000000000000000000000000000000000..d8a285807adcefed53ca8b9d3af0f7d9881e1a13 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/plugin/src/org/eclipse/wb/swt/SWTResourceManager.java @@ -0,0 +1,447 @@ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Google, Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.wb.swt; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Display; + +/** + * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc. + * <p> + * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the + * operating system resources managed by cached objects when those objects and OS resources are no longer + * needed (e.g. on application shutdown) + * <p> + * This class may be freely distributed as part of any application or plugin. + * <p> + * @author scheglov_ke + * @author Dan Rubel + */ +public class SWTResourceManager { + //////////////////////////////////////////////////////////////////////////// + // + // Color + // + //////////////////////////////////////////////////////////////////////////// + private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>(); + /** + * Returns the system {@link Color} matching the specific ID. + * + * @param systemColorID + * the ID value for the color + * @return the system {@link Color} matching the specific ID + */ + public static Color getColor(int systemColorID) { + Display display = Display.getCurrent(); + return display.getSystemColor(systemColorID); + } + /** + * Returns a {@link Color} given its red, green and blue component values. + * + * @param r + * the red component of the color + * @param g + * the green component of the color + * @param b + * the blue component of the color + * @return the {@link Color} matching the given red, green and blue component values + */ + public static Color getColor(int r, int g, int b) { + return getColor(new RGB(r, g, b)); + } + /** + * Returns a {@link Color} given its RGB value. + * + * @param rgb + * the {@link RGB} value of the color + * @return the {@link Color} matching the RGB value + */ + public static Color getColor(RGB rgb) { + Color color = m_colorMap.get(rgb); + if (color == null) { + Display display = Display.getCurrent(); + color = new Color(display, rgb); + m_colorMap.put(rgb, color); + } + return color; + } + /** + * Dispose of all the cached {@link Color}'s. + */ + public static void disposeColors() { + for (Color color : m_colorMap.values()) { + color.dispose(); + } + m_colorMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // Image + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps image paths to images. + */ + private static Map<String, Image> m_imageMap = new HashMap<String, Image>(); + /** + * Returns an {@link Image} encoded by the specified {@link InputStream}. + * + * @param stream + * the {@link InputStream} encoding the image data + * @return the {@link Image} encoded by the specified input stream + */ + protected static Image getImage(InputStream stream) throws IOException { + try { + Display display = Display.getCurrent(); + ImageData data = new ImageData(stream); + if (data.transparentPixel > 0) { + return new Image(display, data, data.getTransparencyMask()); + } + return new Image(display, data); + } finally { + stream.close(); + } + } + /** + * Returns an {@link Image} stored in the file at the specified path. + * + * @param path + * the path to the image file + * @return the {@link Image} stored in the file at the specified path + */ + public static Image getImage(String path) { + Image image = m_imageMap.get(path); + if (image == null) { + try { + image = getImage(new FileInputStream(path)); + m_imageMap.put(path, image); + } catch (Exception e) { + image = getMissingImage(); + m_imageMap.put(path, image); + } + } + return image; + } + /** + * Returns an {@link Image} stored in the file at the specified path relative to the specified class. + * + * @param clazz + * the {@link Class} relative to which to find the image + * @param path + * the path to the image file, if starts with <code>'/'</code> + * @return the {@link Image} stored in the file at the specified path + */ + public static Image getImage(Class<?> clazz, String path) { + String key = clazz.getName() + '|' + path; + Image image = m_imageMap.get(key); + if (image == null) { + try { + image = getImage(clazz.getResourceAsStream(path)); + m_imageMap.put(key, image); + } catch (Exception e) { + image = getMissingImage(); + m_imageMap.put(key, image); + } + } + return image; + } + private static final int MISSING_IMAGE_SIZE = 10; + /** + * @return the small {@link Image} that can be used as placeholder for missing image. + */ + private static Image getMissingImage() { + Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); + // + GC gc = new GC(image); + gc.setBackground(getColor(SWT.COLOR_RED)); + gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); + gc.dispose(); + // + return image; + } + /** + * Style constant for placing decorator image in top left corner of base image. + */ + public static final int TOP_LEFT = 1; + /** + * Style constant for placing decorator image in top right corner of base image. + */ + public static final int TOP_RIGHT = 2; + /** + * Style constant for placing decorator image in bottom left corner of base image. + */ + public static final int BOTTOM_LEFT = 3; + /** + * Style constant for placing decorator image in bottom right corner of base image. + */ + public static final int BOTTOM_RIGHT = 4; + /** + * Internal value. + */ + protected static final int LAST_CORNER_KEY = 5; + /** + * Maps images to decorated images. + */ + @SuppressWarnings("unchecked") + private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY]; + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated + * @param decorator + * the {@link Image} to decorate the base image + * @return {@link Image} The resulting decorated image + */ + public static Image decorateImage(Image baseImage, Image decorator) { + return decorateImage(baseImage, decorator, BOTTOM_RIGHT); + } + /** + * Returns an {@link Image} composed of a base image decorated by another image. + * + * @param baseImage + * the base {@link Image} that should be decorated + * @param decorator + * the {@link Image} to decorate the base image + * @param corner + * the corner to place decorator image + * @return the resulting decorated {@link Image} + */ + public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) { + if (corner <= 0 || corner >= LAST_CORNER_KEY) { + throw new IllegalArgumentException("Wrong decorate corner"); + } + Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner]; + if (cornerDecoratedImageMap == null) { + cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>(); + m_decoratedImageMap[corner] = cornerDecoratedImageMap; + } + Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage); + if (decoratedMap == null) { + decoratedMap = new HashMap<Image, Image>(); + cornerDecoratedImageMap.put(baseImage, decoratedMap); + } + // + Image result = decoratedMap.get(decorator); + if (result == null) { + Rectangle bib = baseImage.getBounds(); + Rectangle dib = decorator.getBounds(); + // + result = new Image(Display.getCurrent(), bib.width, bib.height); + // + GC gc = new GC(result); + gc.drawImage(baseImage, 0, 0); + if (corner == TOP_LEFT) { + gc.drawImage(decorator, 0, 0); + } else if (corner == TOP_RIGHT) { + gc.drawImage(decorator, bib.width - dib.width, 0); + } else if (corner == BOTTOM_LEFT) { + gc.drawImage(decorator, 0, bib.height - dib.height); + } else if (corner == BOTTOM_RIGHT) { + gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height); + } + gc.dispose(); + // + decoratedMap.put(decorator, result); + } + return result; + } + /** + * Dispose all of the cached {@link Image}'s. + */ + public static void disposeImages() { + // dispose loaded images + { + for (Image image : m_imageMap.values()) { + image.dispose(); + } + m_imageMap.clear(); + } + // dispose decorated images + for (int i = 0; i < m_decoratedImageMap.length; i++) { + Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i]; + if (cornerDecoratedImageMap != null) { + for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { + image.dispose(); + } + decoratedMap.clear(); + } + cornerDecoratedImageMap.clear(); + } + } + } + //////////////////////////////////////////////////////////////////////////// + // + // Font + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps font names to fonts. + */ + private static Map<String, Font> m_fontMap = new HashMap<String, Font>(); + /** + * Maps fonts to their bold versions. + */ + private static Map<Font, Font> m_fontToBoldFontMap = new HashMap<Font, Font>(); + /** + * Returns a {@link Font} based on its name, height and style. + * + * @param name + * the name of the font + * @param height + * the height of the font + * @param style + * the style of the font + * @return {@link Font} The font matching the name, height and style + */ + public static Font getFont(String name, int height, int style) { + return getFont(name, height, style, false, false); + } + /** + * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline + * flags are also supported. + * + * @param name + * the name of the font + * @param size + * the size of the font + * @param style + * the style of the font + * @param strikeout + * the strikeout flag (warning: Windows only) + * @param underline + * the underline flag (warning: Windows only) + * @return {@link Font} The font matching the name, height, style, strikeout and underline + */ + public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) { + String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline; + Font font = m_fontMap.get(fontName); + if (font == null) { + FontData fontData = new FontData(name, size, style); + if (strikeout || underline) { + try { + Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$ + Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$ + if (logFont != null && logFontClass != null) { + if (strikeout) { + logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ + } + if (underline) { + logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ + } + } + } catch (Throwable e) { + System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + font = new Font(Display.getCurrent(), fontData); + m_fontMap.put(fontName, font); + } + return font; + } + /** + * Returns a bold version of the given {@link Font}. + * + * @param baseFont + * the {@link Font} for which a bold version is desired + * @return the bold version of the given {@link Font} + */ + public static Font getBoldFont(Font baseFont) { + Font font = m_fontToBoldFontMap.get(baseFont); + if (font == null) { + FontData fontDatas[] = baseFont.getFontData(); + FontData data = fontDatas[0]; + font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); + m_fontToBoldFontMap.put(baseFont, font); + } + return font; + } + /** + * Dispose all of the cached {@link Font}'s. + */ + public static void disposeFonts() { + // clear fonts + for (Font font : m_fontMap.values()) { + font.dispose(); + } + m_fontMap.clear(); + // clear bold fonts + for (Font font : m_fontToBoldFontMap.values()) { + font.dispose(); + } + m_fontToBoldFontMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // Cursor + // + //////////////////////////////////////////////////////////////////////////// + /** + * Maps IDs to cursors. + */ + private static Map<Integer, Cursor> m_idToCursorMap = new HashMap<Integer, Cursor>(); + /** + * Returns the system cursor matching the specific ID. + * + * @param id + * int The ID value for the cursor + * @return Cursor The system cursor matching the specific ID + */ + public static Cursor getCursor(int id) { + Integer key = Integer.valueOf(id); + Cursor cursor = m_idToCursorMap.get(key); + if (cursor == null) { + cursor = new Cursor(Display.getDefault(), id); + m_idToCursorMap.put(key, cursor); + } + return cursor; + } + /** + * Dispose all of the cached cursors. + */ + public static void disposeCursors() { + for (Cursor cursor : m_idToCursorMap.values()) { + cursor.dispose(); + } + m_idToCursorMap.clear(); + } + //////////////////////////////////////////////////////////////////////////// + // + // General + // + //////////////////////////////////////////////////////////////////////////// + /** + * Dispose of cached objects and their underlying OS resources. This should only be called when the cached + * objects are no longer needed (e.g. on application shutdown). + */ + public static void dispose() { + disposeColors(); + disposeImages(); + disposeFonts(); + disposeCursors(); + } +} \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/plugin/swing2swt.jar b/ARCHITECT/EclipsePlugin/plugin/swing2swt.jar new file mode 100644 index 0000000000000000000000000000000000000000..a09053c46521dd13dd9d1ca6370b3e9324e24dde Binary files /dev/null and b/ARCHITECT/EclipsePlugin/plugin/swing2swt.jar differ diff --git a/ARCHITECT/EclipsePlugin/.gitkeep b/ARCHITECT/EclipsePlugin/plugin/test.xml similarity index 100% rename from ARCHITECT/EclipsePlugin/.gitkeep rename to ARCHITECT/EclipsePlugin/plugin/test.xml diff --git a/ARCHITECT/EclipsePlugin/releng/.project b/ARCHITECT/EclipsePlugin/releng/.project new file mode 100644 index 0000000000000000000000000000000000000000..43a73bfe165b5c923007df9ee52612292eafcb80 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/releng/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>releng</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + </natures> +</projectDescription> diff --git a/ARCHITECT/EclipsePlugin/releng/.settings/org.eclipse.m2e.core.prefs b/ARCHITECT/EclipsePlugin/releng/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..f897a7f1cb2389f85fe6381425d29f0a9866fb65 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/releng/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ARCHITECT/EclipsePlugin/releng/pom.xml b/ARCHITECT/EclipsePlugin/releng/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..9a2f0adcbfeef8da2b5f98ac8a59bb3af118c20b --- /dev/null +++ b/ARCHITECT/EclipsePlugin/releng/pom.xml @@ -0,0 +1,56 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>de.decideh2020</groupId> + <artifactId>eu.DECIDEh2020.architect.releng</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>pom</packaging> + + + + <properties> + <tycho.version>0.23.0</tycho.version> + + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <repositories> + <repository> + <id>Oxygen</id> + <layout>p2</layout> + <url>http://download.eclipse.org/releases/oxygen/</url> + </repository> + </repositories> + + <build> + <plugins> + <plugin> + <!-- enable tycho build extension --> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-maven-plugin</artifactId> + <version>${tycho.version}</version> + <extensions>true</extensions> + </plugin> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>target-platform-configuration</artifactId> + <version>${tycho.version}</version> + <configuration> + <environments> + <environment> + <os>win32</os> + <ws>win32</ws> + <arch>x86</arch> + </environment> + </environments> + </configuration> + </plugin> + </plugins> + </build> + + + <modules> + <module>../plugin</module> + <module>../feature</module> + <module>../site</module> + </modules> +</project> \ No newline at end of file diff --git a/ARCHITECT/EclipsePlugin/site/.gitignore b/ARCHITECT/EclipsePlugin/site/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b83d22266ac8aa2f8df2edef68082c789727841d --- /dev/null +++ b/ARCHITECT/EclipsePlugin/site/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/ARCHITECT/EclipsePlugin/site/.project b/ARCHITECT/EclipsePlugin/site/.project new file mode 100644 index 0000000000000000000000000000000000000000..7090d957fbcf2e507447fb68c56659eca8c8fcca --- /dev/null +++ b/ARCHITECT/EclipsePlugin/site/.project @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>site</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.pde.UpdateSiteBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.pde.UpdateSiteNature</nature> + </natures> +</projectDescription> diff --git a/ARCHITECT/EclipsePlugin/site/.settings/org.eclipse.core.resources.prefs b/ARCHITECT/EclipsePlugin/site/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000000000000000000000000000000000..99f26c0203a7844de00dbfc56e6a35d8ed3c022c --- /dev/null +++ b/ARCHITECT/EclipsePlugin/site/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/ARCHITECT/EclipsePlugin/site/.settings/org.eclipse.m2e.core.prefs b/ARCHITECT/EclipsePlugin/site/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..f897a7f1cb2389f85fe6381425d29f0a9866fb65 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/site/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ARCHITECT/EclipsePlugin/site/artifacts.jar b/ARCHITECT/EclipsePlugin/site/artifacts.jar new file mode 100644 index 0000000000000000000000000000000000000000..48dcbc692f3715c7b3fd72730713b95f41ab249a Binary files /dev/null and b/ARCHITECT/EclipsePlugin/site/artifacts.jar differ diff --git a/ARCHITECT/EclipsePlugin/site/category.xml b/ARCHITECT/EclipsePlugin/site/category.xml new file mode 100644 index 0000000000000000000000000000000000000000..68efbe7c61249b270c450dd118339db11c1011a2 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/site/category.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<site> + <feature url="features/eu.DECIDEh2020.architect.feature_1.0.0.qualifier.jar" id="eu.DECIDEh2020.architect.feature" version="1.0.0.qualifier"> + <category name="Architect"/> + </feature> + <category-def name="Architect" label="Architect"/> +</site> diff --git a/ARCHITECT/EclipsePlugin/site/content.jar b/ARCHITECT/EclipsePlugin/site/content.jar new file mode 100644 index 0000000000000000000000000000000000000000..75c7687fd4e361f3ccac7ca22a3ae127f154ad73 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/site/content.jar differ diff --git a/ARCHITECT/EclipsePlugin/site/features/eu.DECIDEh2020.architect.feature_1.0.0.201709251632.jar b/ARCHITECT/EclipsePlugin/site/features/eu.DECIDEh2020.architect.feature_1.0.0.201709251632.jar new file mode 100644 index 0000000000000000000000000000000000000000..2ad194742d3b1de470a9e7485cc5e1a65ad897e1 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/site/features/eu.DECIDEh2020.architect.feature_1.0.0.201709251632.jar differ diff --git a/ARCHITECT/EclipsePlugin/site/features/eu.DECIDEh2020.architect.feature_1.0.0.201709251634.jar b/ARCHITECT/EclipsePlugin/site/features/eu.DECIDEh2020.architect.feature_1.0.0.201709251634.jar new file mode 100644 index 0000000000000000000000000000000000000000..751feafdfdb26523e6fbf76a1dfea17f6071e7f9 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/site/features/eu.DECIDEh2020.architect.feature_1.0.0.201709251634.jar differ diff --git a/ARCHITECT/EclipsePlugin/site/plugins/eu.DECIDEh2020.architect.wizard_1.0.0.201709251632.jar b/ARCHITECT/EclipsePlugin/site/plugins/eu.DECIDEh2020.architect.wizard_1.0.0.201709251632.jar new file mode 100644 index 0000000000000000000000000000000000000000..37ce3f1e47a0d6b8e19d9f2fb5ae4ce1c95ab990 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/site/plugins/eu.DECIDEh2020.architect.wizard_1.0.0.201709251632.jar differ diff --git a/ARCHITECT/EclipsePlugin/site/plugins/eu.DECIDEh2020.architect.wizard_1.0.0.201709251634.jar b/ARCHITECT/EclipsePlugin/site/plugins/eu.DECIDEh2020.architect.wizard_1.0.0.201709251634.jar new file mode 100644 index 0000000000000000000000000000000000000000..fcb694edd36a579dc8f2be796c1cc52bc518fd83 Binary files /dev/null and b/ARCHITECT/EclipsePlugin/site/plugins/eu.DECIDEh2020.architect.wizard_1.0.0.201709251634.jar differ diff --git a/ARCHITECT/EclipsePlugin/site/pom.xml b/ARCHITECT/EclipsePlugin/site/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..b8983217f23c37780a622cd1495291a1d07b4900 --- /dev/null +++ b/ARCHITECT/EclipsePlugin/site/pom.xml @@ -0,0 +1,11 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <artifactId>eu.DECIDEh2020.architect.site</artifactId> + <packaging>eclipse-repository</packaging> + <parent> + <groupId>de.decideh2020</groupId> + <artifactId>eu.DECIDEh2020.architect.releng</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../releng</relativePath> + </parent> +</project> \ No newline at end of file diff --git a/AppController/.gitkeep b/AppController/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/AppController/pom.xml b/AppController/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..3f7189fcbf06a2744c875b0700654e64d48a7cf4 --- /dev/null +++ b/AppController/pom.xml @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>eu.DECIDEh2020.appcontroller</groupId> + <artifactId>eu.DECIDEh2020.appcontroller</artifactId> + <version>1.0-SNAPSHOT</version> + <name>AppController</name> + <packaging>jar</packaging> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptorRefs> + <descriptorRef>jar-with-dependencies</descriptorRef> + </descriptorRefs> + </configuration> + + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>attached</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + + <dependencies> + <dependency> + <groupId>org.eclipse.jgit</groupId> + <artifactId>org.eclipse.jgit</artifactId> + <version>4.4.1.201607150455-r</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.5</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.7.5</version> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20160810</version> + </dependency> + <dependency> + <groupId>com.googlecode.json-simple</groupId> + <artifactId>json-simple</artifactId> + <version>1.1.1</version> + </dependency> + </dependencies> + + +</project> + + + diff --git a/AppController/src/main/java/eu/DECIDEh2020/appcontroller/AppController.java b/AppController/src/main/java/eu/DECIDEh2020/appcontroller/AppController.java new file mode 100644 index 0000000000000000000000000000000000000000..8b93980e3096693410619215436b070cbfdf54bc --- /dev/null +++ b/AppController/src/main/java/eu/DECIDEh2020/appcontroller/AppController.java @@ -0,0 +1,402 @@ +package eu.DECIDEh2020.appcontroller; + +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.errors.GitAPIException; + +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import java.io.*; +import java.util.Date; +import java.util.ListIterator; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* Eclipse Public License version 2.0 which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Leo Li (Fraunhofer FOKUS) **Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu */ + + +public class AppController { + private Git GitRepository; + private String Username; + private String Password; + private String ApplicationDesc; + private String RepositoryUrl; + private String Directory; + + /** + * Constructor for the AppController. This constructor enables the possibility to use a username and a password for repositories which are private. + * + * @param Password The password which is used to access a git account. + * @param Username The username used to access a git account. + * @param ApplicationDesc The path of the application description file (not yet needed). + * @param RepositoryUrl The url of the to be used git repository (master repository). + * @param Directory The local directory to save the git repository content. + */ + public AppController(String Username, String Password, String ApplicationDesc, String RepositoryUrl, String Directory) { + this.ApplicationDesc = ApplicationDesc; + this.Username = Username; + this.Password = Password; + this.RepositoryUrl = RepositoryUrl; + this.Directory = Directory; + } + + /** + * Constructor for the AppController. This constructor may only be used on public git repositories. + * + * @param ApplicationDesc The path of the application description file (not yet needed). + * @param RepositoryUrl The url of the to be used git repository (master repository). + * @param Directory The local directory to save the git repository content. + */ + public AppController(String ApplicationDesc, String RepositoryUrl, String Directory) { + this.ApplicationDesc = ApplicationDesc; + this.RepositoryUrl = RepositoryUrl; + this.Directory = Directory; + } + + /** + * Clone the defined repository to the defined directory or if it already exists opens the repository. The method uses the git password and username to clone private repositories. + * + * @throws GitAPIException + * @throws IOException + */ + public void cloneRepositoryWithCred() throws GitAPIException, IOException { + if (!checkRepository()) { + GitRepository = Git.cloneRepository() + .setURI(RepositoryUrl) + .setDirectory(new File(Directory)) + .setCredentialsProvider(new UsernamePasswordCredentialsProvider(Username, Password)) + .setCloneAllBranches(true) + .call(); + } else GitRepository = Git.open(new File(Directory)); + } + + /** + * Clone the defined repository to the defined directory or if it already exists opens the repository. + * + * @throws GitAPIException + * @throws IOException + */ + public void cloneRepository() throws GitAPIException, IOException { + if (!checkRepository()) { + GitRepository = Git.cloneRepository() + .setURI(RepositoryUrl) + .setDirectory(new File(Directory)) + .setCloneAllBranches(true) + .call(); + } else GitRepository = Git.open(new File(Directory)); + } + + /** + * Pull new changes from defined repository which is private and include them into the local directory. + * + * @throws GitAPIException + * @throws IOException + */ + public void pullRepoWithCred() throws GitAPIException, IOException { + GitRepository = Git.open(new File(Directory)); + GitRepository + .pull() + .setCredentialsProvider(new UsernamePasswordCredentialsProvider(Username, Password)) + .call(); + } + + + /** + * Pull new changes from the defined repository and includes them in the local directory. + * + * @throws GitAPIException + * @throws IOException + */ + public void pullRepo() throws GitAPIException, IOException { + GitRepository = Git.open(new File(Directory)); + GitRepository + .pull() + .call(); + } + + /** + * Push new content to the repository. + * + * @throws GitAPIException + * @throws IOException + */ + public void pushRepo() throws GitAPIException, IOException { + GitRepository = Git.open(new File(Directory)); + GitRepository + .push() + .call(); + } + + /** + * Push new content to the private repository. + * + * @throws GitAPIException + * @throws IOException + */ + public void pushRepoWithCred() throws GitAPIException, IOException { + GitRepository = Git.open(new File(Directory)); + GitRepository + .push() + .setCredentialsProvider(new UsernamePasswordCredentialsProvider(Username, Password)) + .call(); + } + + + /** + * Add the JSONHistory file to the index to be commited next. + * + * @throws GitAPIException + * @throws IOException + */ + public void addHistory() throws GitAPIException, IOException { + GitRepository = Git.open(new File(Directory)); + GitRepository.add().addFilepattern("JSONHistory.json").call(); + } + + /** + * Commit the latest changes in the repository. + * + * @param message The commit message which has to be set by the commiter. + * @throws GitAPIException + * @throws IOException + */ + public void commitHistory(String message) throws GitAPIException, IOException { + GitRepository = Git.open(new File(Directory)); + GitRepository.commit().setMessage(message).call(); + } + + + /** + * Check if the directory to save the master repository already exists. + * + * @return Boolean value if the set directory already exists. + */ + private boolean checkRepository() { + File folder = new File(Directory); + if (folder.exists()) { + if (folder.isDirectory()) { + String[] content = folder.list(); + for (String file : content) { + if (file.equals(".git")) + return true; + } + } + } + return false; + } + + + /** + * Create a new SLABreach object and add it to the last saved deployment of the defined service in the existing history. + * + * @param serviceId A string to identify the microservice where a breach occurred. + * @param slaBreach A JSONObject which represents the new SLABreach. + * @throws IOException + */ + public void newBreach(String serviceId, JSONObject slaBreach) throws IOException { + JSONArray history = getHistory(); + JSONObject microservice; + JSONArray entry; + ListIterator listIterator = history.listIterator(); + for (int i = 0; i < history.size(); i++) { + JSONObject service = (JSONObject) listIterator.next(); + if (service.keySet().contains(serviceId)) { + microservice = service; + history.remove(service); + entry = (JSONArray) microservice.get(serviceId); + JSONObject date = (JSONObject) entry.get(entry.size() - 1); + entry.remove(entry.get(entry.size() - 1)); + JSONArray breaches = (JSONArray) date.get("sla_breaches"); + breaches.add(slaBreach); + JSONObject changed = new JSONObject(); + changed.put("date", date.get("date")); + changed.put("deployed_on", date.get("deployed_on")); + changed.put("sla_breaches", breaches); + entry.add(changed); + microservice.put(serviceId, entry); + history.add(microservice); + break; + } + } + try (FileWriter file = new FileWriter(Directory + "/JSONHistory.json")) { + file.write(history.toString()); + } + } + + + /** + * Create a new SLABreach object and add it to the defined dated deployment of the defined service in the existing history. + * + * @param date A string containing the date of the deployment to find the deployment where a new SLABreach is to set. + * @param serviceId The service id to identify the microservice where a new breach occurred. + * @param slaBreach A JSONObject which represents the new SLABreach. + */ + public void newBreach(String date, String serviceId, JSONObject slaBreach) throws IOException { + JSONArray history = getHistory(); + JSONObject microservice = null; + JSONArray entry; + ListIterator listIterator = history.listIterator(); + for (int i = 0; i < history.size(); i++) { + JSONObject service = (JSONObject) listIterator.next(); + if (service.keySet().contains(serviceId)) { + microservice = service; + } + } + if (microservice != null) { + entry = (JSONArray) microservice.get(serviceId); + ListIterator listIterator1 = entry.listIterator(); + for (int k = 0; k < entry.size(); k++) { + JSONObject holder = (JSONObject) listIterator1.next(); + if (holder.values().contains(date)) { + history.remove(microservice); + entry.remove(holder); + JSONArray breaches = (JSONArray) holder.get("sla_breaches"); + breaches.add(slaBreach); + JSONObject changed = new JSONObject(); + changed.put("date", holder.get("date")); + changed.put("deployed_on", holder.get("deployed_on")); + changed.put("sla_breaches", breaches); + entry.add(changed); + microservice.put(serviceId, entry); + history.add(microservice); + break; + } + } + } + try (FileWriter file = new FileWriter(Directory + "/JSONHistory.json")) { + file.write(history.toString()); + } + } + + + /** + * Create a new history entry in the existing history. If no history exists, create it aswell. + * + * @param serviceId The identifier of the deployed service. + * @param serviceProvider The Name/Identifier of the service provide used to deploy the service on. + */ + public void writeHistory(String serviceId, String serviceProvider) throws IOException { + JSONArray history = getHistory(); + // DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + String date = String.valueOf(new Date().getTime()); + JSONObject microservice = new JSONObject(); + JSONArray entry = new JSONArray(); + boolean found = false; + ListIterator listIterator = history.listIterator(); + for (int i = 0; i < history.size(); i++) { + JSONObject service = (JSONObject) listIterator.next(); + if (service.keySet().contains(serviceId)) { + microservice = service; + history.remove(service); + entry = (JSONArray) microservice.get(serviceId); + entry.add(newEntry(date, serviceProvider)); + microservice.put(serviceId, entry); + history.add(microservice); + found = true; + break; + } + } + if (!found) { + JSONObject his = (newEntry(date, serviceProvider)); + entry.add(his); + microservice.put(serviceId, entry); + history.add(microservice); + } + try (FileWriter file = new FileWriter(Directory + "/JSONHistory.json")) { + file.write(history.toString()); + } + } + + + /** + * Create a new entry to be added into the history. + * + * @return JSONObject which represents a possibly newly created entry for the history + */ + private JSONObject newEntry(String date, String serviceProvider) { + JSONObject history = new JSONObject(); + history.put("date", date); + history.put("deployed_on", serviceProvider); + history.put("sla_breaches", new JSONArray()); + return history; + } + + + /** + * Retrieve an existing or create a new history. + * + * @return JSONArray which gives a representation of the existing history or returns a new empty one + */ + private JSONArray getHistory() { + File folder = new File(Directory); + JSONParser parser = new JSONParser(); + if (folder.exists()) { + if (folder.isDirectory()) { + String[] content = folder.list(); + for (String file : content) { + if (file.contains("JSONHistory")) { + try { + return (JSONArray) parser.parse(new FileReader(Directory + "/" + file)); + } catch (ParseException | IOException e) { + e.printStackTrace(); + } + } + } + File history = new File(Directory + "/JSONHistory.json"); + } + } + return new JSONArray(); + } + + + public Git getGitRepository() { + return GitRepository; + } + + public void setGitRepository(Git gitRepository) { + GitRepository = gitRepository; + } + + public String getRepositoryUrl() { + return RepositoryUrl; + } + + public void setRepositoryUrl(String repositoryUrl) { + RepositoryUrl = repositoryUrl; + } + + public String getDirectory() { + return Directory; + } + + public void setDirectory(String directory) { + Directory = directory; + } + + public String getUsername() { + return Username; + } + + public void setUsername(String username) { + Username = username; + } + + public String getApplicationDesc() { + return ApplicationDesc; + } + + public void setApplicationDesc(String applicationDesc) { + ApplicationDesc = applicationDesc; + } +} \ No newline at end of file diff --git a/DevOpsFramework/MCSLAEditor/.gitignore b/DevOpsFramework/MCSLAEditor/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0a334987b3dc7908397187851d66ac85e7da78f4 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/.gitignore @@ -0,0 +1,117 @@ +# Created by .ignore support plugin (hsz.mobi) +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 +*.iml + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +### Maven template +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) +!/.mvn/wrapper/maven-wrapper.jar +### Eclipse template + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + diff --git a/DevOpsFramework/MCSLAEditor/.gitkeep b/DevOpsFramework/MCSLAEditor/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/DevOpsFramework/MCSLAEditor/Readme.md b/DevOpsFramework/MCSLAEditor/Readme.md deleted file mode 100644 index 9acfd34ccc8b07223947094d99959dc4956b037f..0000000000000000000000000000000000000000 --- a/DevOpsFramework/MCSLAEditor/Readme.md +++ /dev/null @@ -1 +0,0 @@ -Source code for most of the components for the DevOps framework will be released in February 2017. \ No newline at end of file diff --git a/DevOpsFramework/MCSLAEditor/pom.xml b/DevOpsFramework/MCSLAEditor/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..b88aa3ab7bc8d0ae158e757c66f21d1e1c103da4 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/pom.xml @@ -0,0 +1,136 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>eu.decide.src.kr1.mcsla</groupId> + <artifactId>decide.mcsla.editor</artifactId> + <version>0.0.1-SNAPSHOT</version> + <properties> + <jdk.version>1.8</jdk.version> + <zk.version>8.0.2.2-Eval</zk.version> + <spring.version>4.2.1.RELEASE</spring.version> + <commons-io>2.4</commons-io> + <maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format> + <packname>-${project.version}-FL-${maven.build.timestamp}</packname> + </properties> + <packaging>war</packaging> + <name>The mcsla.editor Project</name> + <description>The mcsla.editor Project</description> + <repositories> + <repository> + <id>ZK CE</id> + <name>ZK CE Repository</name> + <url>http://mavensync.zkoss.org/maven2</url> + </repository> + <repository> + <id>ZK EVAL</id> + <name>ZK Evaluation Repository</name> + <url>http://mavensync.zkoss.org/eval</url> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>zkmaven</id> + <name>ZK Maven Plugin Repository</name> + <url>http://mavensync.zkoss.org/maven2/</url> + </pluginRepository> + </pluginRepositories> + <dependencies> + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zkbind</artifactId> + <version>${zk.version}</version> + </dependency> + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zkmax</artifactId> + <version>${zk.version}</version> + </dependency> + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zuti</artifactId> + <version>${zk.version}</version> + </dependency> + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zkplus</artifactId> + <version>${zk.version}</version> + </dependency> + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zhtml</artifactId> + <version>${zk.version}</version> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons-io}</version> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.4.1</version> + </dependency> + + </dependencies> + <build> + <finalName>${project.artifactId}</finalName> + <plugins> + <!-- Run with Jetty --> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>7.6.8.v20121106</version> + <configuration> + <webAppConfig> + <contextPath>/${project.artifactId}</contextPath> + <allowDuplicateFragmentNames>true</allowDuplicateFragmentNames> + </webAppConfig> + <scanIntervalSeconds>5</scanIntervalSeconds> + </configuration> + </plugin> + <!-- Compile java --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.7.0</version> + <configuration> + <source>${jdk.version}</source> + <target>${jdk.version}</target> + </configuration> + </plugin> + <!-- Pack zips --> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.2</version> + <executions> + <execution> + <id>webapp</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <finalName>mcsla.editor${packname}</finalName> + <appendAssemblyId>false</appendAssemblyId> + <descriptors> + <descriptor>src/main/assembly/webapp.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/DevOpsFramework/MCSLAEditor/src/main/assembly/webapp.xml b/DevOpsFramework/MCSLAEditor/src/main/assembly/webapp.xml new file mode 100644 index 0000000000000000000000000000000000000000..153904efc0ec6100f96952810bb48f6141b8fc2b --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/assembly/webapp.xml @@ -0,0 +1,25 @@ +<assembly + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + <id>webapp</id> + <formats> + <format>zip</format> + </formats> + <fileSets> + <fileSet> + <directory>${project.basedir}/src/main/java</directory> + <outputDirectory>/${project.artifactId}/src</outputDirectory> + </fileSet> + <fileSet> + <directory>${project.basedir}/src/main/webapp</directory> + <outputDirectory>/${project.artifactId}/WebContent</outputDirectory> + </fileSet> + </fileSets> + <files> + <file> + <source>${project.build.directory}/${project.artifactId}.war</source> + <outputDirectory>/</outputDirectory> + </file> + </files> +</assembly> diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Csp.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Csp.java new file mode 100644 index 0000000000000000000000000000000000000000..2e42079dd6d794de408412b9693cb85d0a32fe1c --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Csp.java @@ -0,0 +1,60 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class Csp { + public UUID mCSP_id; + public String name; + public List<MicroserviceSLA> slas; + + public Csp() { + super(); + } + + public Csp(UUID uid, String name) { + super(); + this.mCSP_id = uid; + this.name = name; + List<MicroserviceSLA> slas = new ArrayList<>(); + this.setSlas(slas); + } + + public UUID getmCSP_id() { + return mCSP_id; + } + + public String getName() { + return name; + } + + public List<MicroserviceSLA> getSlas() { + return slas; + } + + public void setmCSP_id(UUID mCSP_id) { + this.mCSP_id = mCSP_id; + } + + public void setName(String name) { + this.name = name; + } + + public void setSlas(List<MicroserviceSLA> slas) { + this.slas = slas; + } + +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Expression.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Expression.java new file mode 100644 index 0000000000000000000000000000000000000000..6100079089510f5100b131528a5bac399c31ceb0 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Expression.java @@ -0,0 +1,43 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class Expression { + public String expression; + public String expressionLanguage; + public String unit; + + public String getExpression() { + return expression; + } + + public String getExpressionLanguage() { + return expressionLanguage; + } + + public String getUnit() { + return unit; + } + + public void setExpression(String expression) { + this.expression = expression; + } + + public void setExpressionLanguage(String expressionLanguage) { + this.expressionLanguage = expressionLanguage; + } + + public void setUnit(String unit) { + this.unit = unit; + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Mcsla.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Mcsla.java new file mode 100644 index 0000000000000000000000000000000000000000..407564c959b005002b86701d394bec6fac4920bb --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Mcsla.java @@ -0,0 +1,87 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +public class Mcsla { + public UUID mCSLA_id; + public String description; + public String visibility; + public String validityPeriod; + public List<MicroserviceSLA> microservice_SLAs; + + public Mcsla() { + super(); + } + + public Mcsla(UUID uid, String description, String visibility, String validityPeriod) { + super(); + this.mCSLA_id = uid; + this.description = description; + this.visibility = visibility; + this.validityPeriod = validityPeriod; + List<MicroserviceSLA> slas = new ArrayList<>(); + this.setMicroservice_SLAs(slas); + } + + public String getDescription() { + return description; + } + + public UUID getmCSLA_id() { + return mCSLA_id; + } + + public List<MicroserviceSLA> getMicroservice_SLAs() { + return microservice_SLAs; + } + + public String getValidityPeriod() { + return validityPeriod; + } + + public String getVisibility() { + return visibility; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setmCSLA_id(UUID mCSLA_id) { + this.mCSLA_id = mCSLA_id; + } + + public void setMicroservice_SLAs(List<MicroserviceSLA> microservice_SLAs) { + this.microservice_SLAs = microservice_SLAs; + } + + public void setValidityPeriod(String validityPeriod) { + this.validityPeriod = validityPeriod; + } + + public void setVisibility(String visibility) { + this.visibility = visibility; + } + +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Metric.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Metric.java new file mode 100644 index 0000000000000000000000000000000000000000..5e22aac13892b85ea34d0b758207a6b2c35d8817 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Metric.java @@ -0,0 +1,70 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class Metric { + public String metric_id; + public String descriptor; + public String scale; + public Parameter parameter; + public Expression expression; + public UnderlyingMetricRef underlyingMetricRef; + + public String getDescriptor() { + return descriptor; + } + + public Expression getExpression() { + return expression; + } + + public String getMetric_id() { + return metric_id; + } + + public Parameter getParameter() { + return parameter; + } + + public String getScale() { + return scale; + } + + public UnderlyingMetricRef getUnderlyingMetricRef() { + return underlyingMetricRef; + } + + public void setDescriptor(String descriptor) { + this.descriptor = descriptor; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public void setMetric_id(String metric_id) { + this.metric_id = metric_id; + } + + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + public void setScale(String scale) { + this.scale = scale; + } + + public void setUnderlyingMetricRef(UnderlyingMetricRef underlyingMetricRef) { + this.underlyingMetricRef = underlyingMetricRef; + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLA.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLA.java new file mode 100644 index 0000000000000000000000000000000000000000..e8a4fc531323405050cf6d1c74b264a2f146f1a6 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLA.java @@ -0,0 +1,100 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.List; + +public class MicroserviceSLA { + public String microservice_SLA_id; + public String __comment; + public String csp_id; + public String csp_name; + public String getCsp_name() { + return csp_name; + } + + public void setCsp_name(String csp_name) { + this.csp_name = csp_name; + } + + public String microservice_id; + public String visibility; + public String validityPeriod; + public List<MicroserviceSQO> microservice_SQOs; + public List<MicroserviceSLO> microservice_SLOs; + + public String getMicroservice_SLA_id() { + return microservice_SLA_id; + } + + public void setMicroservice_SLA_id(String microservice_SLA_id) { + this.microservice_SLA_id = microservice_SLA_id; + } + + public String get__comment() { + return __comment; + } + + public void set__comment(String __comment) { + this.__comment = __comment; + } + + public String getCsp_id() { + return csp_id; + } + + public void setCsp_id(String csp_id) { + this.csp_id = csp_id; + } + + public String getMicroservice_id() { + return microservice_id; + } + + public void setMicroservice_id(String microservice_id) { + this.microservice_id = microservice_id; + } + + public String getVisibility() { + return visibility; + } + + public void setVisibility(String visibility) { + this.visibility = visibility; + } + + public String getValidityPeriod() { + return validityPeriod; + } + + public void setValidityPeriod(String validityPeriod) { + this.validityPeriod = validityPeriod; + } + + public List<MicroserviceSQO> getMicroservice_SQOs() { + return microservice_SQOs; + } + + public void setMicroservice_SQOs(List<MicroserviceSQO> microservice_SQOs) { + this.microservice_SQOs = microservice_SQOs; + } + + public List<MicroserviceSLO> getMicroservice_SLOs() { + return microservice_SLOs; + } + + public void setMicroservice_SLOs(List<MicroserviceSLO> microservice_SLOs) { + this.microservice_SLOs = microservice_SLOs; + } + +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLO.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLO.java new file mode 100644 index 0000000000000000000000000000000000000000..0d4fffd26ab106987a4e67d67d9dda2f995ff4f7 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLO.java @@ -0,0 +1,129 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.List; + +public class MicroserviceSLO { + + public String microservice_SLO_id; + public String __comment; + public String termName; + public String monitoringResult; + public String value; + public String unit; + public String calculationFormula; + public List<ViolationTriggerRule> violationTriggerRule; + public Remedy remedy; + public String csp_id; + public String csp_name; + + public String getCsp_name() { + return csp_name; + } + + public void setCsp_name(String csp_name) { + this.csp_name = csp_name; + } + + public List<Metric> metrics; + + public String get__comment() { + return __comment; + } + + public String getCalculationFormula() { + return calculationFormula; + } + + public String getCsp_id() { + return csp_id; + } + + public List<Metric> getMetrics() { + return metrics; + } + + public String getMicroservice_SLO_id() { + return microservice_SLO_id; + } + + public String getMonitoringResult() { + return monitoringResult; + } + + public Remedy getRemedy() { + return remedy; + } + + public String getTermName() { + return termName; + } + + public String getUnit() { + return unit; + } + + public String getValue() { + return value; + } + + public List<ViolationTriggerRule> getViolationTriggerRule() { + return violationTriggerRule; + } + + public void set__comment(String __comment) { + this.__comment = __comment; + } + + public void setCalculationFormula(String calculationFormula) { + this.calculationFormula = calculationFormula; + } + + public void setCsp_id(String csp_id) { + this.csp_id = csp_id; + } + + public void setMetrics(List<Metric> metrics) { + this.metrics = metrics; + } + + public void setMicroservice_SLO_id(String microservice_SLO_id) { + this.microservice_SLO_id = microservice_SLO_id; + } + + public void setMonitoringResult(String monitoringResult) { + this.monitoringResult = monitoringResult; + } + + public void setRemedy(Remedy remedy) { + this.remedy = remedy; + } + + public void setTermName(String termName) { + this.termName = termName; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public void setValue(String value) { + this.value = value; + } + + public void setViolationTriggerRule(List<ViolationTriggerRule> violationTriggerRule) { + this.violationTriggerRule = violationTriggerRule; + } + +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSQO.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSQO.java new file mode 100644 index 0000000000000000000000000000000000000000..467e0c58fdc8ed981be7f6d681bc1eba4f9a63a0 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSQO.java @@ -0,0 +1,111 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.List; + +public class MicroserviceSQO { + + public String microservice_SQO_id; + public String __comment; + public String termName; + public String monitoringResult; + public String value; + public String unit; + public String calculationFormula; + public List<ViolationTriggerRule> violationTriggerRule; + public Remedy remedy; + + public List<Metric> metrics; + + public String get__comment() { + return __comment; + } + + public String getCalculationFormula() { + return calculationFormula; + } + + public List<Metric> getMetrics() { + return metrics; + } + + public String getMicroservice_SQO_id() { + return microservice_SQO_id; + } + + public String getMonitoringResult() { + return monitoringResult; + } + + public Remedy getRemedy() { + return remedy; + } + + public String getTermName() { + return termName; + } + + public String getUnit() { + return unit; + } + + public String getValue() { + return value; + } + + public List<ViolationTriggerRule> getViolationTriggerRule() { + return violationTriggerRule; + } + + public void set__comment(String __comment) { + this.__comment = __comment; + } + + public void setCalculationFormula(String calculationFormula) { + this.calculationFormula = calculationFormula; + } + + public void setMetrics(List<Metric> metrics) { + this.metrics = metrics; + } + + public void setMicroservice_SQO_id(String microservice_SLO_id) { + this.microservice_SQO_id = microservice_SLO_id; + } + + public void setMonitoringResult(String monitoringResult) { + this.monitoringResult = monitoringResult; + } + + public void setRemedy(Remedy remedy) { + this.remedy = remedy; + } + + public void setTermName(String termName) { + this.termName = termName; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public void setValue(String value) { + this.value = value; + } + + public void setViolationTriggerRule(List<ViolationTriggerRule> violationTriggerRule) { + this.violationTriggerRule = violationTriggerRule; + } + +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Parameter.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Parameter.java new file mode 100644 index 0000000000000000000000000000000000000000..8fee040445070fe9ef5695245870d4d0c9bfe466 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Parameter.java @@ -0,0 +1,54 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.UUID; + +public class Parameter { + public UUID parameter_id; + public String parameterStatement; + public String unit; + public String note; + + public String getNote() { + return note; + } + + public UUID getParameter_id() { + return parameter_id; + } + + public String getParameterStatement() { + return parameterStatement; + } + + public String getUnit() { + return unit; + } + + public void setNote(String note) { + this.note = note; + } + + public void setParameter_id(UUID parameter_id) { + this.parameter_id = parameter_id; + } + + public void setParameterStatement(String parameterStatement) { + this.parameterStatement = parameterStatement; + } + + public void setUnit(String unit) { + this.unit = unit; + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/ProjectConfig.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/ProjectConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..6e0103a323d17383a515ecaa16fea63c9987906c --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/ProjectConfig.java @@ -0,0 +1,59 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class ProjectConfig { + + private String gitremotepath; + private String gitusername; + + public ProjectConfig() { + super(); + } + + public ProjectConfig(String gitremotepath, String gitusername) { + super(); + setGitremotepath(gitremotepath); + setGitusername(gitusername); + } + + /** + * @return the gitremotepath + */ + public String getGitremotepath() { + return gitremotepath; + } + + /** + * @param gitremotepath + * the gitremotepath to set + */ + public void setGitremotepath(String gitremotepath) { + this.gitremotepath = gitremotepath; + } + + /** + * @return the gitusername + */ + public String getGitusername() { + return gitusername; + } + + /** + * @param gitusername + * the gitusername to set + */ + public void setGitusername(String gitusername) { + this.gitusername = gitusername; + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Remedy.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Remedy.java new file mode 100644 index 0000000000000000000000000000000000000000..d81fdfec83a6f968bf7621c054a0f360938a37d8 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/Remedy.java @@ -0,0 +1,52 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class Remedy { + public String type; + public int value; + public String unit; + public String validity; + + public String getType() { + return type; + } + + public String getUnit() { + return unit; + } + + public String getValidity() { + return validity; + } + + public int getValue() { + return value; + } + + public void setType(String type) { + this.type = type; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public void setValidity(String validity) { + this.validity = validity; + } + + public void setValue(int value) { + this.value = value; + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/UnderlyingMetricRef.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/UnderlyingMetricRef.java new file mode 100644 index 0000000000000000000000000000000000000000..fcc66b8cba301edfa8dac53f10e1ca093473cbd9 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/UnderlyingMetricRef.java @@ -0,0 +1,25 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class UnderlyingMetricRef { + public String refid; + + public String getRefid() { + return refid; + } + + public void setRefid(String refid) { + this.refid = refid; + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/ViolationTriggerRule.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/ViolationTriggerRule.java new file mode 100644 index 0000000000000000000000000000000000000000..72e63c729cea3d19d2733822518e9627fd454676 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/beans/ViolationTriggerRule.java @@ -0,0 +1,34 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class ViolationTriggerRule { + public int breaches_count; + public int viointerval; + + public int getBreaches_count() { + return breaches_count; + } + + public int getViointerval() { + return viointerval; + } + + public void setBreaches_count(int breaches_count) { + this.breaches_count = breaches_count; + } + + public void setViointerval(int viointerval) { + this.viointerval = viointerval; + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/JerseyClient.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/JerseyClient.java new file mode 100644 index 0000000000000000000000000000000000000000..cb91ddc0f53ee384429e6a697c73f246498097c6 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/JerseyClient.java @@ -0,0 +1,345 @@ +package eu.DECIDEh2020.mcsla.editor; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +import eu.DECIDEh2020.mcsla.beans.Csp; +import eu.DECIDEh2020.mcsla.beans.Mcsla; +import eu.DECIDEh2020.mcsla.beans.Metric; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLA; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLO; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSQO; +import eu.DECIDEh2020.mcsla.beans.ProjectConfig; +import eu.DECIDEh2020.mcsla.beans.Remedy; +import eu.DECIDEh2020.mcsla.beans.UnderlyingMetricRef; +import eu.DECIDEh2020.mcsla.beans.ViolationTriggerRule; +import eu.DECIDEh2020.mcsla.editor.configuration.AppConfig; +import eu.DECIDEh2020.mcsla.editor.service.ConfigFileService; + +public class JerseyClient { + // private static final String MCSLA_SRVICE_URL = + // "http://localhost:8080/decide.mcsla.srv"; + // private static final String SRV_MCSLAS = + // "http://localhost:8080/decide.mcsla.srv/mcslas"; + // private static final String SRV_MCSLA = + // "http://localhost:8080/decide.mcsla.srv/mcsla"; + // private static final String SRV_CSPS = + // "http://localhost:8080/decide.mcsla.srv/csps"; + // private static final String SRV_AGGREGATE = + // "http://localhost:8080/decide.mcsla.srv/aggregate"; + // private static final String SRV_CONFIG = + // "http://localhost:8080/decide.mcsla.srv/config"; + + private String m_serviceURL = "http://localhost:8080/decide.mcsla.srv"; + + public JerseyClient() { + super(); + System.out.println("JerseyClient......."); + ConfigFileService configService = getConfigService(); + this.m_serviceURL = configService.getServiceUrl(); + } + + private ConfigFileService getConfigService() { + AbstractApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); + ConfigFileService configService = (ConfigFileService) context.getBean("configFileService"); + context.close(); + return configService; + } + + @SuppressWarnings("unused") + private static MicroserviceSLA addSQOs(MicroserviceSLA sla) { + UUID uuid = UUID.randomUUID(); + + List<MicroserviceSQO> sqos = new ArrayList<>(); + MicroserviceSQO sqo = new MicroserviceSQO(); + sqo.setMicroservice_SQO_id(uuid.toString()); + sqo.set__comment("CPU Uitlization will not be less then 85% of the time Over a Day"); + sqo.setTermName("CPU-utilization"); + sqo.setMonitoringResult("result"); + sqo.setValue("95"); + sqo.setUnit("percentage"); + sqo.setCalculationFormula("CPU-utilization LT 85"); + List<ViolationTriggerRule> vtrs = new ArrayList<>(); + ViolationTriggerRule vtr = new ViolationTriggerRule(); + vtr.setBreaches_count(2); + vtr.setViointerval(30); + vtrs.add(vtr); + sqo.setViolationTriggerRule(vtrs); + Remedy remedy = new Remedy(); + remedy.setType("discount"); + remedy.setUnit("%"); + remedy.setValidity("P1D"); + remedy.setValue(5); + sqo.setRemedy(remedy); + + List<Metric> metrics = new ArrayList<>(); + Metric metric = new Metric(); + metric.setMetric_id("CSA_002"); + metric.setDescriptor("CloudServiceAvailability"); + UnderlyingMetricRef underlyingMetricRef = new UnderlyingMetricRef(); + underlyingMetricRef.setRefid("TQD_001"); + metric.setUnderlyingMetricRef(underlyingMetricRef); + metrics.add(metric); + sqo.setMetrics(metrics); + sqos.add(sqo); + sla.setMicroservice_SQOs(sqos); + return sla; + } + + public Mcsla createMCSLAexample(MicroserviceSLO slo) { + + UUID uid = UUID.randomUUID(); + String randomUUIDString = uid.toString(); + Mcsla mcsla = new Mcsla(); + mcsla.setmCSLA_id(uid); + String timeStamp = new SimpleDateFormat("yyyy.MM.dd HH.mm").format(Calendar.getInstance().getTime()); + mcsla.setDescription( + "This is MCSLA dummy description line created from createMCSLAexample method at:" + timeStamp); + mcsla.setVisibility("public"); + mcsla.setValidityPeriod("this is Validity Period line."); + List<MicroserviceSLA> slas = new ArrayList<>(); + + UUID uuid = UUID.randomUUID(); + MicroserviceSLA sla = new MicroserviceSLA(); + sla.setMicroservice_SLA_id(uuid.toString()); + + uuid = UUID.randomUUID(); + randomUUIDString = uuid.toString(); + // TODO fix this need valid CSP + sla.setCsp_id(randomUUIDString); + // TODO fix this need valid setValidityPeriod + sla.setValidityPeriod(Integer.toString(5)); + sla.setVisibility("public"); + uuid = UUID.randomUUID(); + randomUUIDString = uuid.toString(); + sla.setMicroservice_id(randomUUIDString); + + if (slo != null) { + sla.set__comment(slo.__comment); + List<MicroserviceSLO> slos = new ArrayList<>(); + slos.add(slo); + sla.setMicroservice_SLOs(slos); + + } + slas.add(sla); + mcsla.setMicroservice_SLAs(slas); + return mcsla; + + } + + public Mcsla buildMCSLAwithslos(Mcsla mcsla, List<MicroserviceSLO> slos, List<MicroserviceSQO> sqos) { + // TODO fix this default line + mcsla.setValidityPeriod("this is Validity Period line."); + List<MicroserviceSLA> slas = new ArrayList<>(); + + UUID uuid = UUID.randomUUID(); + MicroserviceSLA sla = new MicroserviceSLA(); + sla.setMicroservice_SLA_id(uuid.toString()); + + uuid = UUID.randomUUID(); + String randomUUIDString = uuid.toString(); + // TODO fix this need valid CSP + sla.setCsp_id(randomUUIDString); + // TODO fix this need valid setValidityPeriod + sla.setValidityPeriod(Integer.toString(5)); + sla.setVisibility("public"); + uuid = UUID.randomUUID(); + randomUUIDString = uuid.toString(); + sla.setMicroservice_id(randomUUIDString); + + if (slos != null) { + sla.setMicroservice_SLOs(slos); + } + if (sqos != null) { + sla.setMicroservice_SQOs(sqos); + } + slas.add(sla); + mcsla.setMicroservice_SLAs(slas); + return mcsla; + + } + + public ProjectConfig getProjectConfig() { + RestTemplate restTemplate = new RestTemplate(); + ProjectConfig pconfig = restTemplate.getForObject(m_serviceURL + "/config", ProjectConfig.class); + System.out.println("JerseyClient:getAppConfig:" + pconfig.getGitusername() + ", " + pconfig.getGitremotepath()); + return pconfig; + } + + public static void main(String[] args) { + + System.out.println("####################TEST MAIN START####################"); + JerseyClient jerseyClient = new JerseyClient(); + // jerseyClient.getMcslaDetails(); + // get currently used CSPs returns CSP SLAs + MicroserviceSLA[] slas = jerseyClient.getCspSLAs(); + System.out.println("Main:got CSP SLAs:" + slas.length); + // Prepare SLOs to send to MCSLA Aggregator + MicroserviceSLO[] slos = jerseyClient.buildSLOs(slas); + System.out.println("Main:got list SLOs:" + slos.length); + // Return aggregated SLO + MicroserviceSLO aggregatedSLO = jerseyClient.applyAggregationRules(slos); + if (aggregatedSLO != null) + System.out.println("Main:got aggregated SLO:" + aggregatedSLO.termName); + else + System.out.println("Main:got aggregated SLO is NULL :-("); + // if (true) + // return; + + Mcsla mcsla = jerseyClient.createMCSLAexample(aggregatedSLO); + jerseyClient.addMcsla(mcsla); + System.out.println("Main:addMcsla done."); + + DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + Date date = new Date(); + mcsla.setDescription("this is MCSLA UPDATED at:" + dateFormat.format(date) + " description line."); + mcsla = jerseyClient.updateMcsla(mcsla); + if (mcsla == null) { + System.out.println("Main:got updated mcsla is NULL :-("); + return; + } else + System.out.println("Main:updateMcsla done."); + + mcsla = jerseyClient.getMcslaById(mcsla.mCSLA_id.toString()); + System.out.println("Main:getMcslaById:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription()); + // jerseyClient.deleteMcsla(mcsla.getmCSLA_id()); + System.out.println("####################TEST MAIN DONE####################"); + + } + + public void addMcsla(Mcsla mcsla) { + // It is used to create new resource. Method POST + RestTemplate restTemplate = new RestTemplate(); + HttpEntity<Mcsla> request = new HttpEntity<>(mcsla); + Mcsla resMcsla = restTemplate.postForObject(m_serviceURL + "/mcslas", request, Mcsla.class); + if (resMcsla == null) + System.out.println("JerseyClient:addMcsla:FAILED"); + else + System.out.println("JerseyClient:addMcsla:" + resMcsla.getmCSLA_id() + ", " + resMcsla.getDescription()); + } + + public MicroserviceSLO applyAggregationRules(MicroserviceSLO[] slos) { + System.out.printf("JerseyClient:applyAggregationRules to %s SLOs %n", slos.length); + RestTemplate restTemplate = new RestTemplate(); + HttpEntity<MicroserviceSLO[]> requestEntity = new HttpEntity<MicroserviceSLO[]>(slos); + HttpEntity<MicroserviceSLO> response = restTemplate.exchange(m_serviceURL + "/aggregate", HttpMethod.POST, + requestEntity, MicroserviceSLO.class); + MicroserviceSLO resSLO = response.getBody(); + System.out.println( + "JerseyClient:applyAggregationRules:" + resSLO.getMicroservice_SLO_id() + ", " + resSLO.getTermName()); + return resSLO; + } + + public MicroserviceSLO[] buildSLOs(MicroserviceSLA[] slas) { + List<MicroserviceSLO> sloslist = new ArrayList<>(); + for (MicroserviceSLA sla : slas) { + if (sla.getMicroservice_SLOs() != null) + sloslist.addAll(sla.getMicroservice_SLOs()); + } + MicroserviceSLO[] slos = new MicroserviceSLO[sloslist.size()]; + slos = sloslist.toArray(slos); + return slos; + } + + public MicroserviceSQO[] buildSQOs(MicroserviceSLA[] slas) { + List<MicroserviceSQO> sqoslist = new ArrayList<>(); + for (MicroserviceSLA sla : slas) { + if (sla.getMicroservice_SQOs() != null) + sqoslist.addAll(sla.getMicroservice_SQOs()); + } + MicroserviceSQO[] sqos = new MicroserviceSQO[sqoslist.size()]; + sqos = sqoslist.toArray(sqos); + return sqos; + } + + public void deleteMcsla(UUID uid) { + RestTemplate restTemplate = new RestTemplate(); + String entityUrl = m_serviceURL + "/mcsla" + uid.toString(); + restTemplate.delete(entityUrl); + } + + public MicroserviceSLA[] getCspSLAs() { + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity<Csp[]> responseEntity = restTemplate.getForEntity(m_serviceURL + "/csps", Csp[].class); + Csp[] csplist = responseEntity.getBody(); + + List<MicroserviceSLA> slaslist = new ArrayList<>(); + // for each CSP get SLAs + for (int index = 0; index < csplist.length; index++) { + ResponseEntity<MicroserviceSLA[]> responseEntitylist = restTemplate.getForEntity( + m_serviceURL + "/csps" + "/{id}", MicroserviceSLA[].class, csplist[index].getmCSP_id()); + MicroserviceSLA[] slas = responseEntitylist.getBody(); + List<MicroserviceSLA> cspslas = new ArrayList<MicroserviceSLA>(Arrays.asList(slas)); + slaslist.addAll(cspslas); + } + + System.out.println("JerseyClient:getCspSLAs:" + slaslist.size()); + return slaslist.toArray(new MicroserviceSLA[slaslist.size()]); + } + + public Mcsla getMcslaById(String id) { + RestTemplate restTemplate = new RestTemplate(); + Mcsla mcsla = restTemplate.getForObject(m_serviceURL + "mcsla" + "/{id}", Mcsla.class, id); + System.out.println("JerseyClient:getMcslaById:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription()); + return mcsla; + } + + public Mcsla getMcsla() { + RestTemplate restTemplate = new RestTemplate(); + Mcsla mcsla = restTemplate.getForObject(m_serviceURL + "/mcsla", Mcsla.class); + System.out.println("JerseyClient:getMcsla:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription()); + return mcsla; + } + + public void getMcslaDetails() { + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity<Mcsla[]> responseEntity = restTemplate.getForEntity(m_serviceURL + "/mcslas", Mcsla[].class); + Mcsla[] list = responseEntity.getBody(); + // HttpStatus statusCode = responseEntity.getStatusCode(); + // System.out.println("HttpStatus:getMcslaDetails:" + + // statusCode.value()); + + for (int index = 0; index < list.length; index++) { + System.out.println(list[index].getmCSLA_id() + ", " + list[index].getDescription()); + } + } + + public Mcsla updateMcsla(Mcsla mcsla) { + // It is generally used to update resource, METHOD PUT + System.out.println("JerseyClient:updateMcsla:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription()); + RestTemplate restTemplate = new RestTemplate(); + HttpEntity<Mcsla> requestEntity = new HttpEntity<Mcsla>(mcsla); + HttpEntity<Mcsla> response = restTemplate.exchange(m_serviceURL + "/mcslas", HttpMethod.PUT, requestEntity, + Mcsla.class); + Mcsla resMcsla = response.getBody(); + if (resMcsla == null) + System.out.println("JerseyClient:updateMcsla:FAILED"); + return resMcsla; + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/configuration/AppConfig.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/configuration/AppConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..245ea32dde3ad88a5e56d43c253efba1ef9e515d --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/configuration/AppConfig.java @@ -0,0 +1,36 @@ +package eu.DECIDEh2020.mcsla.editor.configuration; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +@Configuration +@ComponentScan(basePackages = "eu.DECIDEh2020.mcsla") +@PropertySource(value = { "classpath:application.properties" }) +public class AppConfig { + + /* + * PropertySourcesPlaceHolderConfigurer Bean only required for @Value("{}") + * annotations. Remove this bean if you are not using @Value annotations for + * injecting properties. + */ + @Bean + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/configuration/ProjectEditorConfig.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/configuration/ProjectEditorConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..9c5d323fab999f51c1b334a681497ab3f614a2ca --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/configuration/ProjectEditorConfig.java @@ -0,0 +1,38 @@ +package eu.DECIDEh2020.mcsla.editor.configuration; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class ProjectEditorConfig { + + private String serviceURL; + + public ProjectEditorConfig() { + super(); + } + + public ProjectEditorConfig(String url) { + super(); + setServiceURL(url); + + } + + public String getServiceURL() { + return serviceURL; + } + + public void setServiceURL(String url) { + this.serviceURL = url; + } + +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/data/SlasData.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/data/SlasData.java new file mode 100644 index 0000000000000000000000000000000000000000..ff48b5a02157473134cfcd9f0013153030a74626 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/data/SlasData.java @@ -0,0 +1,69 @@ +package eu.DECIDEh2020.mcsla.editor.data; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.Arrays; +import java.util.List; + +import eu.DECIDEh2020.mcsla.editor.JerseyClient; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLA; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLO; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSQO; + +public class SlasData { + + static List<MicroserviceSLO> slos; + static List<MicroserviceSQO> sqos; + static List<MicroserviceSLO> aggs; + static MicroserviceSLA[] slas; + + public static List<MicroserviceSLO> getAllAGGs() { + //System.out.println("SlasData:getAllAGGs:...."); + JerseyClient jerseyClient = new JerseyClient(); + if (slas == null) + slas = jerseyClient.getCspSLAs(); + // Prepare SLOs to send to MCSLA Aggregator + MicroserviceSLO[] microserviceSLOs = jerseyClient.buildSLOs(slas); + //System.out.println("getAllAGGs:got list SLOs:" + microserviceSLOs.length); + // Return aggregated SLO + MicroserviceSLO aggregatedSLO = jerseyClient.applyAggregationRules(microserviceSLOs); + if (aggregatedSLO != null) + System.out.println("SlasData:getAllAGGs:got aggregated SLO:" + aggregatedSLO.termName); + else + System.out.println("SlasData:getAllAGGs:got aggregated SLO is NULL :-("); + aggs = Arrays.asList(aggregatedSLO); + //System.out.println("SlasData:getAllAGGs:" + aggs.size()); + return aggs; + } + + public static List<MicroserviceSLO> getAllSLOs() { + //System.out.println("SlasData:getAllSLOs:...."); + JerseyClient jerseyClient = new JerseyClient(); + if (slos == null) { + slos = Arrays.asList(jerseyClient.buildSLOs(jerseyClient.getCspSLAs())); + } + System.out.println("SlasData:getAllSLOs:" + slos.size()); + return slos; + } + + public static List<MicroserviceSQO> getAllSQOs() { + //System.out.println("SlasData:getAllSQOs:...."); + JerseyClient jerseyClient = new JerseyClient(); + if (sqos == null) { + sqos = Arrays.asList(jerseyClient.buildSQOs(jerseyClient.getCspSLAs())); + } + System.out.println("SlasData:getAllSQOs:" + sqos.size()); + return sqos; + } + +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/dual_listbox/DualListbox.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/dual_listbox/DualListbox.java new file mode 100644 index 0000000000000000000000000000000000000000..e3b6fd70f8765a4c8c8339d3011e4981a34e569e --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/dual_listbox/DualListbox.java @@ -0,0 +1,502 @@ +package eu.DECIDEh2020.mcsla.editor.dual_listbox; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import eu.DECIDEh2020.mcsla.editor.data.SlasData; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.select.SelectorComposer; +import org.zkoss.zk.ui.select.annotation.Listen; +import org.zkoss.zk.ui.select.annotation.Wire; +import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zul.Groupbox; +import org.zkoss.zul.Label; +import org.zkoss.zul.ListModelList; +import org.zkoss.zul.Listbox; +import org.zkoss.zul.Radio; +import org.zkoss.zul.Radiogroup; +import org.zkoss.zul.Selectbox; +import org.zkoss.zul.Textbox; +import org.zkoss.zul.Window; + +import eu.DECIDEh2020.mcsla.editor.JerseyClient; +import eu.DECIDEh2020.mcsla.beans.Mcsla; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLA; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLO; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSQO; +import eu.DECIDEh2020.mcsla.beans.ProjectConfig; + +public class DualListbox extends SelectorComposer<Component> { + private static final long serialVersionUID = 8243942703081449079L; + @Wire + private Window win; + @Wire + Groupbox mcslaGroupbox; + @Wire + private Listbox candidateLbSQOs; + @Wire + private Listbox candidateLbSLOs; + @Wire + private Listbox candidateLbAggs; + @Wire + private Listbox chosenLbsqos; + @Wire + private Listbox chosenLbslos; + @Wire + private Listbox chosenLbaggs; + @Wire + private Label mcslaIDLabel; + @Wire + private Label gitRemoteLabel; + @Wire + private Radiogroup visibilityRadiogroup; + @Wire + private Selectbox visibilitySelectbox; + @Wire + private Textbox descriptionTextbox; + + private ListModelList<MicroserviceSQO> candidateSQOModel; + private ListModelList<MicroserviceSQO> chosenSQODataModel; + private ListModelList<MicroserviceSLO> candidateSLOModel; + private ListModelList<MicroserviceSLO> chosenSLODataModel; + private ListModelList<MicroserviceSLO> candidateAGGModel; + private ListModelList<MicroserviceSLO> chosenAGGDataModel; + private ListModelList<String> modelVisibilityList; + private String[] visibilityList = { "public", "privat" }; + private ProjectConfig projectConfig; + private Mcsla mcsla; + + public DualListbox() { + // Executions.createComponents("/widgets/listbox/dual_listbox/v_dualListbox.zul", + // this, null); + // Selectors.wireComponents(this, this, false); + // Selectors.wireEventListeners(this, this); + } + + // This method will be called after all the child components under the component + // which has the composer applied to it are created, so we can change components + // attributes or even create other components in it. + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + + reloadUI(); + } + + private void reloadUI() { + chosenLbsqos.setModel(chosenSQODataModel = new ListModelList<MicroserviceSQO>()); + chosenLbslos.setModel(chosenSLODataModel = new ListModelList<MicroserviceSLO>()); + chosenLbaggs.setModel(chosenAGGDataModel = new ListModelList<MicroserviceSLO>()); + + chosenSQODataModel.setMultiple(true); + chosenSLODataModel.setMultiple(true); + chosenAGGDataModel.setMultiple(true); + + setSQOModel(SlasData.getAllSQOs()); + setSLOModel(SlasData.getAllSLOs()); + setAGGModel(SlasData.getAllAGGs()); + + JerseyClient jerseyClient = new JerseyClient(); + mcsla = jerseyClient.getMcsla(); + updateMcslaGUI(); + projectConfig = jerseyClient.getProjectConfig(); + gitRemoteLabel.setValue(projectConfig.getGitremotepath() + " (User:" + projectConfig.getGitusername() + ")"); + } + + public Mcsla getMcsla() { + return mcsla; + } + + /** + * @return the projectConfig + */ + public ProjectConfig getProjectConfig() { + return projectConfig; + } + + /** + * @param projectConfig + * the projectConfig to set + */ + public void setProjectConfig(ProjectConfig projectConfig) { + this.projectConfig = projectConfig; + } + + public ListModelList<String> getVisibilityList() { + modelVisibilityList = new ListModelList<String>(Arrays.asList(visibilityList)); + return modelVisibilityList; + } + + @Listen("onSelect = #visibilitySelectbox") + public void changeType() { + Set<String> types = ((ListModelList<String>) modelVisibilityList).getSelection(); + String visibility = types.iterator().next(); + mcsla.setVisibility(visibility); + showNotify("Visibility changed to: " + visibility, visibilitySelectbox); + } + + @Listen("onClick = #saveButton") + public void submit() { + JerseyClient jerseyClient = new JerseyClient(); + List<MicroserviceSLO> slos = getChosenSLODataList(); + // System.out.println("DualListBox:submit:slos:" + slos.size()); + List<MicroserviceSLO> aggslos = getChosenAGGDataList(); + // System.out.println("DualListBox:submit:aggslos:" + aggslos.size()); + slos.addAll(aggslos); + List<MicroserviceSQO> sqos = getChosenSQODataList(); + // System.out.println("DualListBox:submit:sqos:" + sqos.size()); + mcsla = jerseyClient.buildMCSLAwithslos(mcsla, slos, sqos); + jerseyClient.updateMcsla(mcsla); + showNotify("Your MCSLA is saved in Repository:" + projectConfig.getGitremotepath(), mcslaGroupbox); + } + + @Listen("onClick = #aggDetailsButton") + public void showAggDetails(Event event) { + Set<MicroserviceSLO> set = candidateAGGModel.getSelection(); + showNotify("Your MCSLA aggDetailsButton." + set.size(), mcslaGroupbox); + } + + @Listen("onClick = #loadButton") + public void loadMcsla() { + JerseyClient jerseyClient = new JerseyClient(); + mcsla = jerseyClient.getMcsla(); + updateMcslaGUI(); + showNotify("Get MCSLA from Repository:" + mcsla.getmCSLA_id(), mcslaIDLabel); + } + + @Listen("onClick = #createNewButton") + public void createNewMcsla() { + setSQOModel(SlasData.getAllSQOs()); + setSLOModel(SlasData.getAllSLOs()); + setAGGModel(SlasData.getAllAGGs()); + + JerseyClient jerseyClient = new JerseyClient(); + mcsla = jerseyClient.createMCSLAexample(null); + updateMcslaGUI(); + showNotify("Created new MCSLA:" + mcsla.getmCSLA_id(), mcslaIDLabel); + } + + private Set<MicroserviceSQO> buildSQOsSet(Mcsla mcsla) { + List<MicroserviceSLA> slas = mcsla.getMicroservice_SLAs(); + List<MicroserviceSQO> sqoslist = new ArrayList<>(); + for (MicroserviceSLA sla : slas) { + if (sla.getMicroservice_SQOs() != null) + sqoslist.addAll(sla.getMicroservice_SQOs()); + } + Set<MicroserviceSQO> sqosSet = new HashSet<MicroserviceSQO>(sqoslist); + System.out.println("DualListBox:buildSQOsSet:slos:" + sqosSet.size()); + return sqosSet; + } + + private Set<MicroserviceSLO> buildSLOsSet(Mcsla mcsla) { + List<MicroserviceSLA> slas = mcsla.getMicroservice_SLAs(); + List<MicroserviceSLO> sloslist = new ArrayList<>(); + for (MicroserviceSLA sla : slas) { + if (sla.getMicroservice_SLOs() != null) + sloslist.addAll(sla.getMicroservice_SLOs()); + } + Set<MicroserviceSLO> slosSet = new HashSet<MicroserviceSLO>(sloslist); + System.out.println("DualListBox:buildSLOsSet:slos:" + slosSet.size()); + return slosSet; + } + + private void updateMcslaGUI() { + mcslaIDLabel.setValue(mcsla.getmCSLA_id().toString()); + descriptionTextbox.setValue(mcsla.getDescription()); + modelVisibilityList.addToSelection(mcsla.getVisibility()); + chooseSetSQO(buildSQOsSet(mcsla)); + chooseSetSLO(buildSLOsSet(mcsla)); + + } + + @Listen("onChange = #descriptionTextbox") + public void changeTitle() { + String description = descriptionTextbox.getValue(); + mcsla.setDescription(description); + showNotify("MCSLA Description changed to: " + description, descriptionTextbox); + } + + @Listen("onCheck = #visibilityRadiogroup") + public void changeVisibility() { + Radio selectedItem = visibilityRadiogroup.getSelectedItem(); + // car.setAutoTransmission("automaticRadio".equals(selectedItem.getId())); + showNotify("MCSLA Visibility changed to: " + selectedItem.getLabel(), visibilityRadiogroup.getParent()); + } + + private void showNotify(String msg, Component ref) { + Clients.showNotification(msg, "info", ref, "end_center", 2000); + } + + @Listen("onClick = #chooseAllBtnAgg") + public void chooseAllItemAGG() { + chosenAGGDataModel.addAll(candidateAGGModel); + candidateAGGModel.clear(); + } + + @Listen("onClick = #chooseAllBtnSLO") + public void chooseAllItemSLO() { + chosenSLODataModel.addAll(candidateSLOModel); + candidateSLOModel.clear(); + } + + @Listen("onClick = #chooseAllBtnSQO") + public void chooseAllItemSQO() { + chosenSQODataModel.addAll(candidateSQOModel); + candidateSQOModel.clear(); + } + + // AGG + @Listen("onClick = #chooseBtnAgg") + public void chooseItemAGG() { + // Events.postEvent(new ChooseEventAGG(this, chooseOneAGG())); + chooseOneAGG(); + } + + // SLO + @Listen("onClick = #chooseBtnSLO") + public void chooseItemSLO() { + // Events.postEvent(new ChooseEventSLO(this, chooseOneSLO())); + chooseOneSLO(); + } + + // SQO + @Listen("onClick = #chooseBtnSQO") + public void chooseItemSQO() { + // Events.postEvent(new ChooseEventSQO(this, chooseOneSQO())); + chooseOneSQO(); + } + + // AGG + private Set<MicroserviceSLO> chooseOneAGG() { + Set<MicroserviceSLO> set = candidateAGGModel.getSelection(); + chosenAGGDataModel.addAll(set); + candidateAGGModel.removeAll(set); + return set; + } + + // SLO + private Set<MicroserviceSLO> chooseOneSLO() { + Set<MicroserviceSLO> set = candidateSLOModel.getSelection(); + chosenSLODataModel.addAll(set); + candidateSLOModel.removeAll(set); + return set; + } + + private Set<MicroserviceSQO> chooseOneSQO() { + Set<MicroserviceSQO> set = candidateSQOModel.getSelection(); + chosenSQODataModel.addAll(set); + candidateSQOModel.removeAll(set); + return set; + } + + // FIX this + private Set<MicroserviceSQO> chooseSetSQO(Set<MicroserviceSQO> set) { + System.out.println("DualListbox:chooseSetSQO:" + set.size()); + if (set.size() == 0) + return set; + + setSQOModel(SlasData.getAllSQOs()); + // chosenSQODataModel.clear(); + chosenSQODataModel.addAll(set); + + List<MicroserviceSQO> list2removeList = new ArrayList<MicroserviceSQO>(); + List<MicroserviceSQO> candidateSQOList = candidateSQOModel.getInnerList(); + for (Iterator<MicroserviceSQO> iterator = set.iterator(); iterator.hasNext();) { + MicroserviceSQO microserviceSQO1 = (MicroserviceSQO) iterator.next(); + for (Iterator<MicroserviceSQO> iterator2 = candidateSQOList.iterator(); iterator2.hasNext();) { + MicroserviceSQO microserviceSQO2 = (MicroserviceSQO) iterator2.next(); + if (microserviceSQO1.getMicroservice_SQO_id().equals(microserviceSQO2.getMicroservice_SQO_id())) { + list2removeList.add(microserviceSQO2); + } + } + } + boolean b = candidateSQOModel.removeAll(list2removeList); + System.out.println("DualListbox:chooseSetSQO:" + b); + + return set; + } + + // FIX this + private Set<MicroserviceSLO> chooseSetSLO(Set<MicroserviceSLO> set) { + System.out.println("DualListbox:chooseSetSLO:" + set.size()); + if (set.size() == 0) + return set; + setSLOModel(SlasData.getAllSLOs()); + // chosenSLODataModel.clear(); + chosenSLODataModel.addAll(set); + + List<MicroserviceSLO> list2removeList = new ArrayList<MicroserviceSLO>(); + List<MicroserviceSLO> candidateSLOList = candidateSLOModel.getInnerList(); + for (Iterator<MicroserviceSLO> iterator = set.iterator(); iterator.hasNext();) { + MicroserviceSLO microserviceSLO1 = (MicroserviceSLO) iterator.next(); + for (Iterator<MicroserviceSLO> iterator2 = candidateSLOList.iterator(); iterator2.hasNext();) { + MicroserviceSLO microserviceSLO2 = (MicroserviceSLO) iterator2.next(); + if (microserviceSLO1.getMicroservice_SLO_id().equals(microserviceSLO2.getMicroservice_SLO_id())) { + list2removeList.add(microserviceSLO2); + } + } + } + boolean b = candidateSLOModel.removeAll(list2removeList); + System.out.println("DualListbox:chooseSetSLO:" + b); + b = candidateAGGModel.removeAll(list2removeList); + System.out.println("DualListbox:chooseSetSLO:" + b); + return set; + } + + /** + * @return current chosen SLO data list + */ + public List<MicroserviceSLO> getChosenSLODataList() { + return new ArrayList<MicroserviceSLO>(chosenSLODataModel); + } + + /** + * @return current chosen SQO data list + */ + public List<MicroserviceSQO> getChosenSQODataList() { + return new ArrayList<MicroserviceSQO>(chosenSQODataModel); + } + + /** + * @return current chosen AGG data list + */ + public List<MicroserviceSLO> getChosenAGGDataList() { + return new ArrayList<MicroserviceSLO>(chosenAGGDataModel); + } + + /** + * Set new candidate AGG ListModelList. + * + * @param candidate + * is the data of candidate list model + */ + public void setAGGModel(List<MicroserviceSLO> candidate) { + candidateLbAggs.setModel(this.candidateAGGModel = new ListModelList<MicroserviceSLO>(candidate)); + this.candidateAGGModel.setMultiple(true); + chosenAGGDataModel.clear(); + } + + /** + * Set new candidate SLO ListModelList. + * + * @param candidate + * is the data of candidate list model + */ + public void setSLOModel(List<MicroserviceSLO> candidate) { + candidateLbSLOs.setModel(this.candidateSLOModel = new ListModelList<MicroserviceSLO>(candidate)); + this.candidateSLOModel.setMultiple(true); + chosenSLODataModel.clear(); + } + + /** + * Set new candidate SQO ListModelList. + * + * @param candidate + * is the data of candidate list model + */ + public void setSQOModel(List<MicroserviceSQO> candidate) { + candidateLbSQOs.setModel(this.candidateSQOModel = new ListModelList<MicroserviceSQO>(candidate)); + this.candidateSQOModel.setMultiple(true); + chosenSQODataModel.clear(); + } + + @Listen("onClick = #removeAllBtnAgg") + public void unchooseAllAgg() { + candidateAGGModel.addAll(chosenAGGDataModel); + chosenAGGDataModel.clear(); + } + + @Listen("onClick = #removeAllBtnSLO") + public void unchooseAllSLO() { + candidateSLOModel.addAll(chosenSLODataModel); + chosenSLODataModel.clear(); + } + + @Listen("onClick = #removeAllBtnSQO") + public void unchooseAllSQO() { + candidateSQOModel.addAll(chosenSQODataModel); + chosenSQODataModel.clear(); + } + + @Listen("onClick = #removeBtnAgg") + public void unchooseItemAGG() { + // Events.postEvent(new ChooseEventAGG(this, unchooseOneAGG())); + unchooseOneAGG(); + } + + @Listen("onClick = #removeBtnSLO") + public void unchooseItemSLO() { + // Events.postEvent(new ChooseEventSLO(this, unchooseOneSLO())); + unchooseOneSLO(); + } + + @Listen("onClick = #removeBtnSQO") + public void unchooseItemSQO() { + // Events.postEvent(new ChooseEventSQO(this, unchooseOneSQO())); + unchooseOneSQO(); + } + + private Set<MicroserviceSLO> unchooseOneAGG() { + Set<MicroserviceSLO> set = chosenAGGDataModel.getSelection(); + candidateAGGModel.addAll(set); + chosenAGGDataModel.removeAll(set); + return set; + } + + private Set<MicroserviceSLO> unchooseOneSLO() { + Set<MicroserviceSLO> set = chosenSLODataModel.getSelection(); + candidateSLOModel.addAll(set); + chosenSLODataModel.removeAll(set); + return set; + } + + private Set<MicroserviceSQO> unchooseOneSQO() { + Set<MicroserviceSQO> set = chosenSQODataModel.getSelection(); + candidateSQOModel.addAll(set); + chosenSQODataModel.removeAll(set); + return set; + } + + // Customized Event AGG + public class ChooseEventAGG extends Event { + private static final long serialVersionUID = -7554906383953342976L; + + public ChooseEventAGG(Component target, Set<MicroserviceSLO> data) { + super("onChoose", target, data); + } + } + + // Customized Event SLO + public class ChooseEventSLO extends Event { + private static final long serialVersionUID = -7444906383953342976L; + + public ChooseEventSLO(Component target, Set<MicroserviceSLO> data) { + super("onChoose", target, data); + } + } + + // Customized Event SQO + public class ChooseEventSQO extends Event { + private static final long serialVersionUID = -7334906383953342976L; + + public ChooseEventSQO(Component target, Set<MicroserviceSQO> data) { + super("onChoose", target, data); + } + } +} \ No newline at end of file diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/service/ConfigFileService.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/service/ConfigFileService.java new file mode 100644 index 0000000000000000000000000000000000000000..ec8e3b362e1cca5a59eaaf036d059c6dd7e24530 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/service/ConfigFileService.java @@ -0,0 +1,21 @@ +package eu.DECIDEh2020.mcsla.editor.service; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public interface ConfigFileService { + + public String getServiceUrl(); + + public void readValues(); +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/service/ConfigFileServiceImpl.java b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/service/ConfigFileServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..052e3eb57c70be2d57cac00b1b2a86cc105917be --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/java/eu/DECIDEh2020/mcsla/editor/service/ConfigFileServiceImpl.java @@ -0,0 +1,55 @@ +package eu.DECIDEh2020.mcsla.editor.service; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; + +@Service("configFileService") +public class ConfigFileServiceImpl implements ConfigFileService { + + private static final String DECIDE_MCSLA_SERVICE_URL = "decide.mcsla.service.url"; + + @Value("${decide.mcsla.service.url:http://localhost:8080/decide.mcsla.srv}") + private String serviceUrl; + + @Autowired + private Environment environment; + + /** + * @param serviceURL + * the serviceURL to set + */ + public void setServiceURL(String serviceURL) { + this.serviceUrl = serviceURL; + } + + public String getServiceUrl() { + String url = environment.getProperty(DECIDE_MCSLA_SERVICE_URL); + if (url != null) { + System.out.println("ConfigFileServiceImpl:getServiceUrl:" + url); + return url; + } else + return serviceUrl; + + } + + public void readValues() { + System.out.println( + "Getting property via Spring Environment User:" + environment.getProperty(DECIDE_MCSLA_SERVICE_URL)); + } + +} diff --git a/DevOpsFramework/MCSLAEditor/src/main/resources/application.properties b/DevOpsFramework/MCSLAEditor/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..2e4fa83728a2f3c3e3707986f8ec078a0a6bb4bf --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/resources/application.properties @@ -0,0 +1 @@ +decide.mcsla.service.url=http://decidehost:8080/decide.mcsla.srv diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/META-INF/MANIFEST.MF b/DevOpsFramework/MCSLAEditor/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..4e0a32ad65c8fd42f70eb1c043386ee2c57f8007 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,8 @@ +Manifest-Version: 1.0 +Specification-Title: ZK Application +Specification-Version: 1.0 +Specification-Vendor: +Implementation-Title: +Implementation-URL: http://your-website/ +Implementation-Version: 1.0 +Implementation-Vendor: diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/web.servlet-3.xml b/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/web.servlet-3.xml new file mode 100644 index 0000000000000000000000000000000000000000..340a528a84027ed0bba9243ed1d4a4ea567cfd68 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/web.servlet-3.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<web-app xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + version="3.0"> + + <description><![CDATA[MCSLA Editor Application]]></description> + <display-name>mcsla.editor</display-name> + + <!-- [Optional] + Uncomment if you want to use the ZK filter to post process the HTML output + generated by other technology, such as JSP and velocity. + <filter> + <filter-name>zkFilter</filter-name> + <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class> + <init-param> + <param-name>extension</param-name> + <param-value>html</param-value> + </init-param> + <init-param> + <param-name>compress</param-name> + <param-value>true</param-value> + </init-param> + </filter> + <filter-mapping> + <filter-name>zkFilter</filter-name> + <url-pattern>your URI pattern</url-pattern> + </filter-mapping> + --> +</web-app> diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/web.xml b/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..966d93a08918470ad1fd725490b3522c3e21d0fd --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,199 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> + + <description><![CDATA[MCSLA Editor Application]]></description> + <display-name>decide.mcsla.editor</display-name> + + <!-- //// --> + <!-- ZK --> + <listener> + <description>ZK listener for session cleanup</description> + <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class> + </listener> + <servlet> + <description>ZK loader for ZUML pages</description> + <servlet-name>zkLoader</servlet-name> + <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class> + + <!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet). + It must be the same as <url-pattern> for the update engine. + --> + <init-param> + <param-name>update-uri</param-name> + <param-value>/zkau</param-value> + </init-param> + <!-- Optional. Specifies whether to compress the output + of the ZK loader. It speeds up the transmission over slow Internet. + However, if you configure a filter to post-processing the + output, you might have to disable it. + + Default: true + <init-param> + <param-name>compress</param-name> + <param-value>true</param-value> + </init-param> + --> + <!-- [Optional] Specifies the default log level: OFF, ERROR, WARNING, + INFO, DEBUG and FINER. If not specified, the system default is used. + <init-param> + <param-name>log-level</param-name> + <param-value>OFF</param-value> + </init-param> + --> + <load-on-startup>1</load-on-startup><!-- Must --> + </servlet> + <servlet-mapping> + <servlet-name>zkLoader</servlet-name> + <url-pattern>*.zul</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>zkLoader</servlet-name> + <url-pattern>*.zhtml</url-pattern> + </servlet-mapping> + <!-- [Optional] Uncomment it if you want to use richlets. + <servlet-mapping> + <servlet-name>zkLoader</servlet-name> + <url-pattern>/zk/*</url-pattern> + </servlet-mapping> + --> + <servlet> + <description>The asynchronous update engine for ZK</description> + <servlet-name>auEngine</servlet-name> + <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> + + <!-- [Optional] Specifies whether to compress the output + of the ZK loader. It speeds up the transmission over slow Internet. + However, if your server will do the compression, you might have to disable it. + + Default: true + <init-param> + <param-name>compress</param-name> + <param-value>true</param-value> + </init-param> + --> + <!-- [Optional] Specifies the AU extension for particular prefix. + <init-param> + <param-name>extension0</param-name> + <param-value>/upload=com.my.MyUploader</param-value> + </init-param> + --> + </servlet> + <servlet-mapping> + <servlet-name>auEngine</servlet-name> + <url-pattern>/zkau/*</url-pattern> + </servlet-mapping> + + <!-- [Optional] + Uncomment if you want to use the ZK filter to post process the HTML output + generated by other technology, such as JSP and velocity. + <filter> + <filter-name>zkFilter</filter-name> + <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class> + <init-param> + <param-name>extension</param-name> + <param-value>html</param-value> + </init-param> + <init-param> + <param-name>compress</param-name> + <param-value>true</param-value> + </init-param> + </filter> + <filter-mapping> + <filter-name>zkFilter</filter-name> + <url-pattern>your URI pattern</url-pattern> + </filter-mapping> + --> + <!-- //// --> + + <!-- ///////////// --> + <!-- DSP (optional) + Uncomment it if you want to use DSP + However, it is turned on since zksandbox uses DSP to generate CSS. + <servlet> + <servlet-name>dspLoader</servlet-name> + <servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class> + <init-param> + <param-name>class-resource</param-name> + <param-value>true</param-value> + </init-param> + </servlet> + <servlet-mapping> + <servlet-name>dspLoader</servlet-name> + <url-pattern>*.dsp</url-pattern> + </servlet-mapping> + --> + + <!-- /////////// --> + <!-- [Optional] Session timeout --> + <session-config> + <session-timeout>60</session-timeout> + </session-config> + + <!-- [Optional] MIME mapping --> + <mime-mapping> + <extension>doc</extension> + <mime-type>application/vnd.ms-word</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gif</extension> + <mime-type>image/gif</mime-type> + </mime-mapping> + <mime-mapping> + <extension>htm</extension> + <mime-type>text/html</mime-type> + </mime-mapping> + <mime-mapping> + <extension>html</extension> + <mime-type>text/html</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jpeg</extension> + <mime-type>image/jpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jpg</extension> + <mime-type>image/jpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>js</extension> + <mime-type>text/javascript</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pdf</extension> + <mime-type>application/pdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>png</extension> + <mime-type>image/png</mime-type> + </mime-mapping> + <mime-mapping> + <extension>txt</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xls</extension> + <mime-type>application/vnd.ms-excel</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xml</extension> + <mime-type>text/xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>zhtml</extension> + <mime-type>text/html</mime-type> + </mime-mapping> + <mime-mapping> + <extension>zul</extension> + <mime-type>text/html</mime-type> + </mime-mapping> + + <welcome-file-list> + <welcome-file>index.zul</welcome-file> + <welcome-file>index.zhtml</welcome-file> + <welcome-file>index.html</welcome-file> + <welcome-file>index.htm</welcome-file> + </welcome-file-list> +</web-app> diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/zk.xml b/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/zk.xml new file mode 100644 index 0000000000000000000000000000000000000000..cbeaf49ad78a862a1684573e766a2354f629dd77 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/webapp/WEB-INF/zk.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<zk> + <!-- [Optional] + Uncomment if you want to defines the application's name + + <preference> + <name>org.zkoss.zk.ui.WebApp.name</name> + <value>mcsla.editor</value> + </preference> + --> + +</zk> diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/index.zul b/DevOpsFramework/MCSLAEditor/src/main/webapp/index.zul new file mode 100644 index 0000000000000000000000000000000000000000..cc9a127c85a4d45c62f15b1ce4bb032b6ac909f9 --- /dev/null +++ b/DevOpsFramework/MCSLAEditor/src/main/webapp/index.zul @@ -0,0 +1,273 @@ +<!-- Define Component Class --> +<!-- + Copyright (c) 2017 Fraunhofer FOKUS. + All rights reserved. This program and the accompanying materials + are made available under the terms of the + Eclipse Public License version 2.0 which accompanies + this distribution, and is available at + https://opensource.org/licenses/EPL-2.0 + + Contributors: + + Majid Salehi Ghamsari (Fraunhofer FOKUS) + + Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +--> +<?component name="dual-listbox" extends="div" class="decide.mcsla.editor.dual_listbox.DualListbox"?> +<window id="win" apply="eu.DECIDEh2020.mcsla.editor.dual_listbox.DualListbox"> + <!-- View of customized component DualListbox --> + <vlayout> + <groupbox width="1210px"> + <hlayout> + <div hflex="true">DECIDE MCSLA editor</div> + <div style="padding-right:20%"> + <image + src="/widgets/listbox/dual_listbox/img/logodecide.jpg" /> + </div> + </hlayout> + </groupbox> + <hlayout id="myhlayout" style="padding:10px"> + <groupbox id="losGroupbox" mold="3d" width="600px"> + <caption + image="/widgets/listbox/dual_listbox/img/signing-the-contract.png" + label="SQOs/SLOs" /> + <vlayout> + <hlayout> + <listbox id="candidateLbSQOs" hflex="1" + vflex="true" multiple="true" rows="6"> + <listhead> + <listheader label="SQO Term" + width="150px"> + </listheader> + <listheader label="Value" + width="40px"> + </listheader> + <listheader label="Comment" + width="400px"> + </listheader> + </listhead> + <template name="model"> + <listitem> + <listcell label="${each.termName }" /> + <listcell label="${each.value }" /> + <listcell + label="${each.__comment }" /> + </listitem> + </template> + </listbox> + <zscript><![CDATA[ + String imgPath = "/widgets/listbox/dual_listbox/img"; +]]></zscript> + <vbox spacing="10px" width="24px"> + <image style="cursor:pointer" + id="chooseAllBtnSQO" src="${imgPath}/rightrightarrow_g.png" /> + <image style="cursor:pointer" + id="chooseBtnSQO" src="${imgPath}/rightarrow_g.png" /> + <image style="cursor:pointer" + id="removeBtnSQO" src="${imgPath}/leftarrow_g.png" /> + <image style="cursor:pointer" + id="removeAllBtnSQO" src="${imgPath}/leftleftarrow_g.png" /> + </vbox> + </hlayout> + <hlayout> + <listbox id="candidateLbSLOs" hflex="1" + vflex="true" multiple="true" rows="5"> + <listhead> + <listheader label="SLO Term" + width="100px"> + </listheader> + <listheader label="Value" + width="40px"> + </listheader> + <listheader label="Provider" + width="60px"> + </listheader> + <listheader label="Comment" + width="400px"> + </listheader> + </listhead> + <template name="model"> + <listitem> + <listcell label="${each.termName }" /> + <listcell label="${each.value }" /> + <listcell label="${each.csp_name }" /> + <listcell + label="${each.__comment }" /> + </listitem> + </template> + </listbox> + <zscript><![CDATA[ + String imgPathslo = "/widgets/listbox/dual_listbox/img"; +]]></zscript> + <vbox spacing="10px" width="24px"> + <image style="cursor:pointer" + id="chooseAllBtnSLO" src="${imgPath}/rightrightarrow_g.png" /> + <image style="cursor:pointer" + id="chooseBtnSLO" src="${imgPath}/rightarrow_g.png" /> + <image style="cursor:pointer" + id="removeBtnSLO" src="${imgPath}/leftarrow_g.png" /> + <image style="cursor:pointer" + id="removeAllBtnSLO" src="${imgPath}/leftleftarrow_g.png" /> + </vbox> + </hlayout> + <hlayout> + <listbox id="candidateLbAggs" hflex="1" + vflex="true" multiple="true" rows="4"> + <listhead> + <listheader label="Aggregate Term" + width="150px"> + </listheader> + <listheader label="Value" + width="40px"> + </listheader> + <listheader label="Info" width="70px"> + </listheader> + <listheader label="Comment" + width="400px"> + </listheader> + </listhead> + <template name="model"> + <listitem> + <listcell label="${each.termName }" /> + <listcell label="${each.value }" /> + <listcell> + <button label="Details" + id="aggDetailsButton"> + </button> + </listcell> + <listcell + label="${each.__comment }" /> + </listitem> + </template> + </listbox> + + <zscript><![CDATA[ + String imgPathAgg = "/widgets/listbox/dual_listbox/img"; +]]></zscript> + <vbox spacing="10px" width="24px"> + <image style="cursor:pointer" + id="chooseAllBtnAgg" src="${imgPath}/rightrightarrow_g.png" /> + <image style="cursor:pointer" + id="chooseBtnAgg" src="${imgPath}/rightarrow_g.png" /> + <image style="cursor:pointer" + id="removeBtnAgg" src="${imgPath}/leftarrow_g.png" /> + <image style="cursor:pointer" + id="removeAllBtnAgg" src="${imgPath}/leftleftarrow_g.png" /> + </vbox> + </hlayout> + <groupbox> + <button id="saveButton" label="Save MCSLA" + image="/widgets/listbox/dual_listbox/img/save.png" /> + <button id="loadButton" + label="Load MCSLA from Repository" + image="/widgets/listbox/dual_listbox/img/open-file.png" /> + <button id="createNewButton" + label="Create new MCSLA" + image="/widgets/listbox/dual_listbox/img/new-page.png" /> + </groupbox> + </vlayout> + </groupbox> + <groupbox id="mcslaGroupbox" mold="3d" width="600px"> + <caption + image="/widgets/listbox/dual_listbox/img/contract.png" + label="MCSLA" /> + <vlayout> + <listbox id="chosenLbsqos" hflex="1" vflex="true" + multiple="true" rows="6"> + <listhead> + <listheader label="SQO Term" + width="150px"> + </listheader> + <listheader label="Value" width="40px"></listheader> + <listheader label="Comment" width="400px"></listheader> + </listhead> + <template name="model"> + <listitem> + <listcell label="${each.termName }" /> + <listcell label="${each.value }" /> + <listcell label="${each.__comment }" /> + </listitem> + </template> + </listbox> + <listbox id="chosenLbslos" hflex="1" vflex="true" + multiple="true" rows="6"> + <listhead> + <listheader label="SLO Term" + width="100px"> + </listheader> + <listheader label="Value" width="40px"></listheader> + <listheader label="Provider" width="60px"></listheader> + <listheader label="Comment" width="400px"></listheader> + </listhead> + <template name="model"> + <listitem> + <listcell label="${each.termName }" /> + <listcell label="${each.value }" /> + <listcell label="${each.csp_name }" /> + <listcell label="${each.__comment }" /> + </listitem> + </template> + </listbox> + <listbox id="chosenLbaggs" hflex="1" vflex="true" + multiple="true" rows="4"> + <listhead> + <listheader label="Aggregate Term" + width="100px"> + </listheader> + <listheader label="Value" width="40px"></listheader> + <listheader label="Comment" width="400px"></listheader> + </listhead> + <template name="model"> + <listitem> + <listcell label="${each.termName }" /> + <listcell label="${each.value }" /> + <listcell label="${each.__comment }" /> + </listitem> + </template> + </listbox> + </vlayout> + + <panel border="normal"> + <panelchildren> + <grid> + <columns> + <column width="100px" /> + <column /> + </columns> + <rows> + <row> + Project: + <label id="gitRemoteLabel" + value="${win$composer.projectConfig.gitremotepath}" /> + </row> + <row> + MCSLA ID: + <label id="mcslaIDLabel" + value="${win$composer.mcsla.mCSLA_id}" /> + </row> + <row> + Description: + <textbox rows="3" + id="descriptionTextbox" + value="${win$composer.mcsla.description}" + constraint="no empty" width="370px;" tabindex="11" /> + </row> + <row> + Visibility: + <selectbox id="visibilitySelectbox" + model="${win$composer.visibilityList}"> + <template name="model"> + <label value="${each}" /> + </template> + </selectbox> + </row> + + </rows> + </grid> + + </panelchildren> + </panel> + </groupbox> + </hlayout> + </vlayout> +</window> \ No newline at end of file diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/contract.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/contract.png new file mode 100644 index 0000000000000000000000000000000000000000..0a4b18e868c657fbc2ebc8f641a0ec779d8eb7e1 Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/contract.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/downarrow_g.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/downarrow_g.png new file mode 100644 index 0000000000000000000000000000000000000000..dd3b2e6227cf63d7152de7d442f668e264a88eba Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/downarrow_g.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/downdownarrow_g.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/downdownarrow_g.png new file mode 100644 index 0000000000000000000000000000000000000000..00bbd236624096a669e69458e76fd051ccd70dcd Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/downdownarrow_g.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/leftarrow_g.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/leftarrow_g.png new file mode 100644 index 0000000000000000000000000000000000000000..51db59207352a3aefd7e7ef92a2de11c743f3e4b Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/leftarrow_g.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/leftleftarrow_g.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/leftleftarrow_g.png new file mode 100644 index 0000000000000000000000000000000000000000..26c3f39c4678ed657725ecf39d28db51c9617552 Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/leftleftarrow_g.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/logodecide.jpg b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/logodecide.jpg new file mode 100644 index 0000000000000000000000000000000000000000..026d2281290597b67a683b8f6bafa0ff63079d6b Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/logodecide.jpg differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/new-page.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/new-page.png new file mode 100644 index 0000000000000000000000000000000000000000..c57598bf2fec5de2e8031da5ec0d3718b0a900b9 Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/new-page.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/open-file.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/open-file.png new file mode 100644 index 0000000000000000000000000000000000000000..bc0e45629e5f797f5557d9a7cf79e7bd29bdee7f Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/open-file.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/rightarrow_g.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/rightarrow_g.png new file mode 100644 index 0000000000000000000000000000000000000000..d496afc9beb1473e5cd1ab9826ff77da3af521e8 Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/rightarrow_g.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/rightrightarrow_g.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/rightrightarrow_g.png new file mode 100644 index 0000000000000000000000000000000000000000..6d999e7f617c32abf4ec80ff992a05e3d425760b Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/rightrightarrow_g.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/save.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/save.png new file mode 100644 index 0000000000000000000000000000000000000000..d3a6e059384ddedd5cd8d68b66ebe467c55a7bbf Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/save.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/signing-the-contract.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/signing-the-contract.png new file mode 100644 index 0000000000000000000000000000000000000000..3f32ab447ccccfce2d41f2a9ee085f43bc274721 Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/signing-the-contract.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/uparrow_g.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/uparrow_g.png new file mode 100644 index 0000000000000000000000000000000000000000..dc880fbdf2e5c479449d572d8ee2d9c0c28156b8 Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/uparrow_g.png differ diff --git a/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/upuparrow_g.png b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/upuparrow_g.png new file mode 100644 index 0000000000000000000000000000000000000000..dc3a40006a3d0e1f4056b6ad1239a1276dde1e77 Binary files /dev/null and b/DevOpsFramework/MCSLAEditor/src/main/webapp/widgets/listbox/dual_listbox/img/upuparrow_g.png differ diff --git a/DevOpsFramework/MCSLAService/.gitignore b/DevOpsFramework/MCSLAService/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0a334987b3dc7908397187851d66ac85e7da78f4 --- /dev/null +++ b/DevOpsFramework/MCSLAService/.gitignore @@ -0,0 +1,117 @@ +# Created by .ignore support plugin (hsz.mobi) +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 +*.iml + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +### Maven template +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) +!/.mvn/wrapper/maven-wrapper.jar +### Eclipse template + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + diff --git a/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/1.0/AppDescriptor-1.0.jar b/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/1.0/AppDescriptor-1.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..d22585c8109e4080e0eb9b839026265deff918e7 Binary files /dev/null and b/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/1.0/AppDescriptor-1.0.jar differ diff --git a/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/1.0/AppDescriptor-1.0.pom b/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/1.0/AppDescriptor-1.0.pom new file mode 100644 index 0000000000000000000000000000000000000000..71df920b55f48ffc07e71c2ab0e03b9d4ca6f7d5 --- /dev/null +++ b/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/1.0/AppDescriptor-1.0.pom @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>eu.DECIDEh2020.architect.plugin.models</groupId> + <artifactId>AppDescriptor</artifactId> + <version>1.0</version> + <description>POM was created from install:install-file</description> +</project> diff --git a/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/maven-metadata-local.xml b/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/maven-metadata-local.xml new file mode 100644 index 0000000000000000000000000000000000000000..89b7f2792bba6d7cf21e9c028c009f826912f86f --- /dev/null +++ b/DevOpsFramework/MCSLAService/libs/eu/DECIDEh2020/architect/plugin/models/AppDescriptor/maven-metadata-local.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metadata> + <groupId>eu.DECIDEh2020.architect.plugin.models</groupId> + <artifactId>AppDescriptor</artifactId> + <versioning> + <release>1.0</release> + <versions> + <version>1.0</version> + </versions> + <lastUpdated>20171116153712</lastUpdated> + </versioning> +</metadata> diff --git a/DevOpsFramework/MCSLAService/pom.xml b/DevOpsFramework/MCSLAService/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..6188b0b76e659c5a5750c3a1d0d3838006420734 --- /dev/null +++ b/DevOpsFramework/MCSLAService/pom.xml @@ -0,0 +1,86 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>eu.decide.src.kr1.mcsla</groupId> + <artifactId>decide.mcsla.srv</artifactId> + <packaging>war</packaging> + <version>0.0.1-SNAPSHOT</version> + <name>eu.decide.src.kr1.mcsla Maven Webapp</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> + <version>${spring.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.4.1</version> + </dependency> + <dependency> + <groupId>org.eclipse.jgit</groupId> + <artifactId>org.eclipse.jgit</artifactId> + <version>4.5.0.201609210915-r</version> + </dependency> + + <dependency> + <groupId>eu.DECIDEh2020.architect.plugin.models</groupId> + <artifactId>AppDescriptor</artifactId> + <version>1.0</version> + </dependency> + + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.6.2</version> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>project local</id> + <url>file://${project.basedir}/libs</url> + </repository> + </repositories> + + <build> + <finalName>decide.mcsla.srv</finalName> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.7.0</version> + <configuration> + <source>${jdk.version}</source> + <target>${jdk.version}</target> + </configuration> + </plugin> + + </plugins> + + </build> + <properties> + <spring.version>4.2.1.RELEASE</spring.version> + <jdk.version>1.8</jdk.version> + </properties> + +</project> diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Csp.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Csp.java new file mode 100644 index 0000000000000000000000000000000000000000..4ad6a3ffc658ced1ec1cd0f14029b8b2687e51cc --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Csp.java @@ -0,0 +1,60 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class Csp { + public UUID mCSP_id; + public String name; + public List<MicroserviceSLA> slas; + + public Csp() { + super(); + } + + public Csp(UUID uid, String name) { + super(); + this.mCSP_id = uid; + this.name = name; + List<MicroserviceSLA> slas = new ArrayList<>(); + this.setSlas(slas); + } + + public UUID getmCSP_id() { + return mCSP_id; + } + + public void setmCSP_id(UUID mCSP_id) { + this.mCSP_id = mCSP_id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List<MicroserviceSLA> getSlas() { + return slas; + } + + public void setSlas(List<MicroserviceSLA> slas) { + this.slas = slas; + } + +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Expression.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Expression.java new file mode 100644 index 0000000000000000000000000000000000000000..310e1751575a27ee41861ba02a6f445a52c02197 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Expression.java @@ -0,0 +1,43 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class Expression { + public String expression; + public String expressionLanguage; + public String unit; + + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } + + public String getExpressionLanguage() { + return expressionLanguage; + } + + public void setExpressionLanguage(String expressionLanguage) { + this.expressionLanguage = expressionLanguage; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Mcsla.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Mcsla.java new file mode 100644 index 0000000000000000000000000000000000000000..407564c959b005002b86701d394bec6fac4920bb --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Mcsla.java @@ -0,0 +1,87 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ + +public class Mcsla { + public UUID mCSLA_id; + public String description; + public String visibility; + public String validityPeriod; + public List<MicroserviceSLA> microservice_SLAs; + + public Mcsla() { + super(); + } + + public Mcsla(UUID uid, String description, String visibility, String validityPeriod) { + super(); + this.mCSLA_id = uid; + this.description = description; + this.visibility = visibility; + this.validityPeriod = validityPeriod; + List<MicroserviceSLA> slas = new ArrayList<>(); + this.setMicroservice_SLAs(slas); + } + + public String getDescription() { + return description; + } + + public UUID getmCSLA_id() { + return mCSLA_id; + } + + public List<MicroserviceSLA> getMicroservice_SLAs() { + return microservice_SLAs; + } + + public String getValidityPeriod() { + return validityPeriod; + } + + public String getVisibility() { + return visibility; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setmCSLA_id(UUID mCSLA_id) { + this.mCSLA_id = mCSLA_id; + } + + public void setMicroservice_SLAs(List<MicroserviceSLA> microservice_SLAs) { + this.microservice_SLAs = microservice_SLAs; + } + + public void setValidityPeriod(String validityPeriod) { + this.validityPeriod = validityPeriod; + } + + public void setVisibility(String visibility) { + this.visibility = visibility; + } + +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Metric.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Metric.java new file mode 100644 index 0000000000000000000000000000000000000000..5e22aac13892b85ea34d0b758207a6b2c35d8817 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Metric.java @@ -0,0 +1,70 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class Metric { + public String metric_id; + public String descriptor; + public String scale; + public Parameter parameter; + public Expression expression; + public UnderlyingMetricRef underlyingMetricRef; + + public String getDescriptor() { + return descriptor; + } + + public Expression getExpression() { + return expression; + } + + public String getMetric_id() { + return metric_id; + } + + public Parameter getParameter() { + return parameter; + } + + public String getScale() { + return scale; + } + + public UnderlyingMetricRef getUnderlyingMetricRef() { + return underlyingMetricRef; + } + + public void setDescriptor(String descriptor) { + this.descriptor = descriptor; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public void setMetric_id(String metric_id) { + this.metric_id = metric_id; + } + + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + public void setScale(String scale) { + this.scale = scale; + } + + public void setUnderlyingMetricRef(UnderlyingMetricRef underlyingMetricRef) { + this.underlyingMetricRef = underlyingMetricRef; + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLA.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLA.java new file mode 100644 index 0000000000000000000000000000000000000000..e8a4fc531323405050cf6d1c74b264a2f146f1a6 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLA.java @@ -0,0 +1,100 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.List; + +public class MicroserviceSLA { + public String microservice_SLA_id; + public String __comment; + public String csp_id; + public String csp_name; + public String getCsp_name() { + return csp_name; + } + + public void setCsp_name(String csp_name) { + this.csp_name = csp_name; + } + + public String microservice_id; + public String visibility; + public String validityPeriod; + public List<MicroserviceSQO> microservice_SQOs; + public List<MicroserviceSLO> microservice_SLOs; + + public String getMicroservice_SLA_id() { + return microservice_SLA_id; + } + + public void setMicroservice_SLA_id(String microservice_SLA_id) { + this.microservice_SLA_id = microservice_SLA_id; + } + + public String get__comment() { + return __comment; + } + + public void set__comment(String __comment) { + this.__comment = __comment; + } + + public String getCsp_id() { + return csp_id; + } + + public void setCsp_id(String csp_id) { + this.csp_id = csp_id; + } + + public String getMicroservice_id() { + return microservice_id; + } + + public void setMicroservice_id(String microservice_id) { + this.microservice_id = microservice_id; + } + + public String getVisibility() { + return visibility; + } + + public void setVisibility(String visibility) { + this.visibility = visibility; + } + + public String getValidityPeriod() { + return validityPeriod; + } + + public void setValidityPeriod(String validityPeriod) { + this.validityPeriod = validityPeriod; + } + + public List<MicroserviceSQO> getMicroservice_SQOs() { + return microservice_SQOs; + } + + public void setMicroservice_SQOs(List<MicroserviceSQO> microservice_SQOs) { + this.microservice_SQOs = microservice_SQOs; + } + + public List<MicroserviceSLO> getMicroservice_SLOs() { + return microservice_SLOs; + } + + public void setMicroservice_SLOs(List<MicroserviceSLO> microservice_SLOs) { + this.microservice_SLOs = microservice_SLOs; + } + +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLO.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLO.java new file mode 100644 index 0000000000000000000000000000000000000000..0d4fffd26ab106987a4e67d67d9dda2f995ff4f7 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSLO.java @@ -0,0 +1,129 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.List; + +public class MicroserviceSLO { + + public String microservice_SLO_id; + public String __comment; + public String termName; + public String monitoringResult; + public String value; + public String unit; + public String calculationFormula; + public List<ViolationTriggerRule> violationTriggerRule; + public Remedy remedy; + public String csp_id; + public String csp_name; + + public String getCsp_name() { + return csp_name; + } + + public void setCsp_name(String csp_name) { + this.csp_name = csp_name; + } + + public List<Metric> metrics; + + public String get__comment() { + return __comment; + } + + public String getCalculationFormula() { + return calculationFormula; + } + + public String getCsp_id() { + return csp_id; + } + + public List<Metric> getMetrics() { + return metrics; + } + + public String getMicroservice_SLO_id() { + return microservice_SLO_id; + } + + public String getMonitoringResult() { + return monitoringResult; + } + + public Remedy getRemedy() { + return remedy; + } + + public String getTermName() { + return termName; + } + + public String getUnit() { + return unit; + } + + public String getValue() { + return value; + } + + public List<ViolationTriggerRule> getViolationTriggerRule() { + return violationTriggerRule; + } + + public void set__comment(String __comment) { + this.__comment = __comment; + } + + public void setCalculationFormula(String calculationFormula) { + this.calculationFormula = calculationFormula; + } + + public void setCsp_id(String csp_id) { + this.csp_id = csp_id; + } + + public void setMetrics(List<Metric> metrics) { + this.metrics = metrics; + } + + public void setMicroservice_SLO_id(String microservice_SLO_id) { + this.microservice_SLO_id = microservice_SLO_id; + } + + public void setMonitoringResult(String monitoringResult) { + this.monitoringResult = monitoringResult; + } + + public void setRemedy(Remedy remedy) { + this.remedy = remedy; + } + + public void setTermName(String termName) { + this.termName = termName; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public void setValue(String value) { + this.value = value; + } + + public void setViolationTriggerRule(List<ViolationTriggerRule> violationTriggerRule) { + this.violationTriggerRule = violationTriggerRule; + } + +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSQO.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSQO.java new file mode 100644 index 0000000000000000000000000000000000000000..78b5b010562cb682d6e755009c306c81d77f4db4 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/MicroserviceSQO.java @@ -0,0 +1,111 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.List; + +public class MicroserviceSQO { + + public String microservice_SQO_id; + public String __comment; + public String termName; + public String monitoringResult; + public String value; + public String unit; + public String calculationFormula; + public List<ViolationTriggerRule> violationTriggerRule; + public Remedy remedy; + + public List<Metric> metrics; + + public String get__comment() { + return __comment; + } + + public String getCalculationFormula() { + return calculationFormula; + } + + public List<Metric> getMetrics() { + return metrics; + } + + public String getMicroservice_SQO_id() { + return microservice_SQO_id; + } + + public String getMonitoringResult() { + return monitoringResult; + } + + public Remedy getRemedy() { + return remedy; + } + + public String getTermName() { + return termName; + } + + public String getUnit() { + return unit; + } + + public String getValue() { + return value; + } + + public List<ViolationTriggerRule> getViolationTriggerRule() { + return violationTriggerRule; + } + + public void set__comment(String __comment) { + this.__comment = __comment; + } + + public void setCalculationFormula(String calculationFormula) { + this.calculationFormula = calculationFormula; + } + + public void setMetrics(List<Metric> metrics) { + this.metrics = metrics; + } + + public void setMicroservice_SQO_id(String microservice_SQO_id) { + this.microservice_SQO_id = microservice_SQO_id; + } + + public void setMonitoringResult(String monitoringResult) { + this.monitoringResult = monitoringResult; + } + + public void setRemedy(Remedy remedy) { + this.remedy = remedy; + } + + public void setTermName(String termName) { + this.termName = termName; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public void setValue(String value) { + this.value = value; + } + + public void setViolationTriggerRule(List<ViolationTriggerRule> violationTriggerRule) { + this.violationTriggerRule = violationTriggerRule; + } + +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Parameter.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Parameter.java new file mode 100644 index 0000000000000000000000000000000000000000..55d1f984ad1ae90abf5a254d4372bbc17cf3fdf8 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Parameter.java @@ -0,0 +1,54 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.UUID; + +public class Parameter { + public UUID parameter_id; + public String parameterStatement; + public String unit; + public String note; + + public UUID getParameter_id() { + return parameter_id; + } + + public void setParameter_id(UUID parameter_id) { + this.parameter_id = parameter_id; + } + + public String getParameterStatement() { + return parameterStatement; + } + + public void setParameterStatement(String parameterStatement) { + this.parameterStatement = parameterStatement; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getNote() { + return note; + } + + public void setNote(String note) { + this.note = note; + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Remedy.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Remedy.java new file mode 100644 index 0000000000000000000000000000000000000000..d81fdfec83a6f968bf7621c054a0f360938a37d8 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/Remedy.java @@ -0,0 +1,52 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class Remedy { + public String type; + public int value; + public String unit; + public String validity; + + public String getType() { + return type; + } + + public String getUnit() { + return unit; + } + + public String getValidity() { + return validity; + } + + public int getValue() { + return value; + } + + public void setType(String type) { + this.type = type; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public void setValidity(String validity) { + this.validity = validity; + } + + public void setValue(int value) { + this.value = value; + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/UnderlyingMetricRef.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/UnderlyingMetricRef.java new file mode 100644 index 0000000000000000000000000000000000000000..fcc66b8cba301edfa8dac53f10e1ca093473cbd9 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/UnderlyingMetricRef.java @@ -0,0 +1,25 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class UnderlyingMetricRef { + public String refid; + + public String getRefid() { + return refid; + } + + public void setRefid(String refid) { + this.refid = refid; + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/ViolationTriggerRule.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/ViolationTriggerRule.java new file mode 100644 index 0000000000000000000000000000000000000000..72e63c729cea3d19d2733822518e9627fd454676 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/beans/ViolationTriggerRule.java @@ -0,0 +1,34 @@ +package eu.DECIDEh2020.mcsla.beans; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class ViolationTriggerRule { + public int breaches_count; + public int viointerval; + + public int getBreaches_count() { + return breaches_count; + } + + public int getViointerval() { + return viointerval; + } + + public void setBreaches_count(int breaches_count) { + this.breaches_count = breaches_count; + } + + public void setViointerval(int viointerval) { + this.viointerval = viointerval; + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/configuration/AppConfig.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/configuration/AppConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..8d964f2e6317d5100d291683f30420b7a2c0e8d7 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/configuration/AppConfig.java @@ -0,0 +1,36 @@ +package eu.DECIDEh2020.mcsla.service.configuration; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +@Configuration +@ComponentScan(basePackages = "eu.DECIDEh2020.mcsla") +@PropertySource(value = { "classpath:application.properties" }) +public class AppConfig { + + /* + * PropertySourcesPlaceHolderConfigurer Bean only required for @Value("{}") + * annotations. Remove this bean if you are not using @Value annotations for + * injecting properties. + */ + @Bean + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/configuration/ProjectConfig.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/configuration/ProjectConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..30733d08026fde0ecf2ad8cd11ba8e5e2f03ae69 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/configuration/ProjectConfig.java @@ -0,0 +1,60 @@ +package eu.DECIDEh2020.mcsla.service.configuration; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public class ProjectConfig { + + private String gitremotepath; + private String gitusername; + + public ProjectConfig() { + super(); + } + + public ProjectConfig(String gitremotepath, String gitusername) { + super(); + setGitremotepath(gitremotepath); + setGitusername(gitusername); + } + + /** + * @return the gitremotepath + */ + public String getGitremotepath() { + return gitremotepath; + } + + /** + * @param gitremotepath + * the gitremotepath to set + */ + public void setGitremotepath(String gitremotepath) { + this.gitremotepath = gitremotepath; + } + + /** + * @return the gitusername + */ + public String getGitusername() { + return gitusername; + } + + /** + * @param gitusername + * the gitusername to set + */ + public void setGitusername(String gitusername) { + this.gitusername = gitusername; + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/controller/McslaController.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/controller/McslaController.java new file mode 100644 index 0000000000000000000000000000000000000000..e9a8316fe8fb8d0ee77633e8bf6dc648b0c44336 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/controller/McslaController.java @@ -0,0 +1,104 @@ +package eu.DECIDEh2020.mcsla.service.controller; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.util.List; + +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import eu.DECIDEh2020.mcsla.beans.Csp; +import eu.DECIDEh2020.mcsla.beans.Mcsla; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLA; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLO; +import eu.DECIDEh2020.mcsla.service.configuration.ProjectConfig; +import eu.DECIDEh2020.mcsla.service.service.McslaService; + +@RestController +public class McslaController { + + McslaService mcslaService = new McslaService(); + + // operation on MCSLA repo + @RequestMapping(value = "/mcsla", method = RequestMethod.GET, headers = "Accept=application/json") + public Mcsla getMcslaFromRepo() { + System.out.println("McslaController:getMcslaFromRepo:----------------------"); + return mcslaService.getMcsla(); + } + + // operation on MCSLAs + @RequestMapping(value = "/mcslas", method = RequestMethod.GET, headers = "Accept=application/json") + public List<Mcsla> getMcslas() { + System.out.println("McslaController:getMcslas:----------------------"); + List<Mcsla> listOfMcslas = mcslaService.getAllMcslas(); + return listOfMcslas; + } + + @RequestMapping(value = "/mcslas/{id}", method = RequestMethod.GET, headers = "Accept=application/json") + public Mcsla getMcslaById(@PathVariable String id) { + System.out.println("McslaController:getMcslaById:----------------------"); + return mcslaService.getMcsla(id); + } + + // add MCSLA to repository and update the reference in Application description + @RequestMapping(value = "/mcslas", method = RequestMethod.POST, headers = "Accept=application/json") + public Mcsla addMcsla(@RequestBody Mcsla mcsla) { + System.out.println("McslaController:addMcsla:----------------------"); + return mcslaService.addMcsla(mcsla); + } + + @RequestMapping(value = "/mcslas", method = RequestMethod.PUT, headers = "Accept=application/json") + public Mcsla updateMcsla(@RequestBody Mcsla mcsla) { + System.out.println("McslaController:updateMcsla:----------------------"); + return mcslaService.updateMcsla(mcsla); + } + + @RequestMapping(value = "/mcslas/{id}", method = RequestMethod.DELETE, headers = "Accept=application/json") + public void deleteMcsla(@PathVariable("id") String id) { + System.out.println("McslaController:deleteMcsla:----------------------"); + mcslaService.deleteMcsla(id); + } + + // operation on SLOs + @RequestMapping(value = "/aggregate", method = RequestMethod.POST, headers = "Accept=application/json") + public MicroserviceSLO aggregate(@RequestBody List<MicroserviceSLO> slos) { + System.out.println("McslaController:aggregate:----------------------"); + return mcslaService.aggregate(slos); + } + + @RequestMapping(value = "/config", method = RequestMethod.GET, headers = "Accept=application/json") + public ProjectConfig getProjectConfig() { + System.out.println("McslaController:getProjectConfig:----------------------"); + ProjectConfig projectConfig = mcslaService.getProjectConfig(); + return projectConfig; + } + + // operation on CSPs will be delivered later by acsmi + @RequestMapping(value = "/csps", method = RequestMethod.GET, headers = "Accept=application/json") + public List<Csp> getCsps() { + System.out.println("McslaController:getCsps:----------------------"); + List<Csp> listOfCsps = mcslaService.getAllCsps(); + return listOfCsps; + } + + // operation on CSPs will be delivered later by acsmi + @RequestMapping(value = "/csps/{id}", method = RequestMethod.GET, headers = "Accept=application/json") + public List<MicroserviceSLA> getCspSLAsById(@PathVariable String id) { + System.out.println("McslaController:getCspSLAsById:----------------------"); + return mcslaService.getCspSLAs(id); + } +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/git/GitControl.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/git/GitControl.java new file mode 100644 index 0000000000000000000000000000000000000000..3bd2a803f18b6b5f8297442f0d6c7913a525f4ac --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/git/GitControl.java @@ -0,0 +1,205 @@ +package eu.DECIDEh2020.mcsla.service.git; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Iterator; +import java.util.UUID; + +import org.eclipse.jgit.api.AddCommand; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.PushCommand; +import org.eclipse.jgit.api.errors.CanceledException; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.DetachedHeadException; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidConfigurationException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.NoFilepatternException; +import org.eclipse.jgit.api.errors.NoHeadException; +import org.eclipse.jgit.api.errors.NoMessageException; +import org.eclipse.jgit.api.errors.RefNotFoundException; +import org.eclipse.jgit.api.errors.WrongRepositoryStateException; +import org.eclipse.jgit.internal.storage.file.FileRepository; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.transport.CredentialsProvider; +import org.eclipse.jgit.transport.PushResult; +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.support.AbstractApplicationContext; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import eu.DECIDEh2020.architect.plugin.models.AppDescriptor; +import eu.DECIDEh2020.mcsla.beans.Mcsla; +import eu.DECIDEh2020.mcsla.service.configuration.AppConfig; +import eu.DECIDEh2020.mcsla.service.service.ConfigFileService; + +public class GitControl { + + private String localPath, remotePath; + private Repository localRepo; + private Git git; + private CredentialsProvider cp; + private String username; + private String userpassword; + + public GitControl() throws IOException { + System.out.println("GitControl:....."); + this.localPath = System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID(); + ConfigFileService configService = getConfigService(); + this.remotePath = configService.getGitremotepath(); + this.username = configService.getGitusername(); + this.userpassword = configService.getGituserpassword(); + + this.localRepo = new FileRepository(localPath + "/.git"); + cp = new UsernamePasswordCredentialsProvider(this.username, this.userpassword); + git = new Git(localRepo); + } + + public GitControl(String localPath, String remotePath, String username, String password) throws IOException { + System.out.println("GitControl:....."); + this.localPath = localPath; + this.remotePath = remotePath; + this.username = username; + this.userpassword = password; + + this.localRepo = new FileRepository(localPath + "/.git"); + cp = new UsernamePasswordCredentialsProvider(this.username, this.userpassword); + git = new Git(localRepo); + } + + public void pushMcslaToRepo(Mcsla mcsla) + throws IOException, NoFilepatternException, GitAPIException, FileNotFoundException, NoHeadException, + NoMessageException, ConcurrentRefUpdateException, WrongRepositoryStateException, InvalidRemoteException, + InvalidConfigurationException, DetachedHeadException, CanceledException, RefNotFoundException { + System.out.println("GitControl:pushMcslaToRepo:....."); + // Clone repository + try { + cloneRepo(); + + } catch (Exception e) { + e.printStackTrace(); + } + + /* + * try (FileWriter writer = new FileWriter(localPath + "/MCSLA" + ".json")) { + * Gson gsonb = new GsonBuilder().setPrettyPrinting().create(); + * gsonb.toJson(mcsla, writer); + * + * } catch (IOException e) { e.printStackTrace(); } + */ + + Gson gson = new Gson(); + String APPLICATIONDES = localPath + "/DECIDE" + ".json"; + AppDescriptor appDescriptor = gson.fromJson(new FileReader(APPLICATIONDES), AppDescriptor.class); + System.out.println("GitControl:pushToRepo:appDescriptor:" + appDescriptor.getIDString()); + // appDescriptor.setApp_mcsla(mcsla.mCSLA_id); //old + appDescriptor.setApp_mcsla(mcsla); + // System.out.println("GitControl:pushToRepo:mCSLA_id:" + + // appDescriptor.getApp_mcsla()); + + try (FileWriter writer = new FileWriter(APPLICATIONDES)) { + Gson gsonb = new GsonBuilder().setPrettyPrinting().create(); + gsonb.toJson(appDescriptor, writer); + + } catch (IOException e) { + e.printStackTrace(); + } + + // Add files to repository + addToRepo(); + // Commit with a custom message + commitToRepo("Modified from MCSLA editor, updated the MCSLA:" + mcsla.mCSLA_id); + // Push commits + pushToRepo(); + // Pull + pullFromRepo(); + } + + public Mcsla getMcslaFromRepo() + throws IOException, NoFilepatternException, GitAPIException, FileNotFoundException, NoHeadException, + NoMessageException, ConcurrentRefUpdateException, WrongRepositoryStateException, InvalidRemoteException, + InvalidConfigurationException, DetachedHeadException, CanceledException, RefNotFoundException { + System.out.println("GitControl:getMcslaFromRepo:....."); + try { + cloneRepo(); + + } catch (Exception e) { + e.printStackTrace(); + } + + Gson gson = new Gson(); + String APPLICATIONDES = localPath + "/DECIDE" + ".json"; + AppDescriptor appDescriptor = gson.fromJson(new FileReader(APPLICATIONDES), AppDescriptor.class); + System.out.println("GitControl:getMcslaFromRepo:appDescriptor:" + appDescriptor.getIDString()); + // appDescriptor.setApp_mcsla(mcsla.mCSLA_id); //old + String jsonMcslaInString = gson.toJson(appDescriptor.getApp_mcsla()); + Mcsla mcsla = gson.fromJson(jsonMcslaInString, Mcsla.class); + System.out.println("GitControl:getMcslaFromRepo:mCSLA_id:" + mcsla.getmCSLA_id() + " Description:" + + mcsla.getDescription()); + return mcsla; + } + + public void cloneRepo() throws IOException, NoFilepatternException, GitAPIException { + Git.cloneRepository().setURI(remotePath) + .setCredentialsProvider(new UsernamePasswordCredentialsProvider(this.username, this.userpassword)) + .setDirectory(new File(localPath)).call(); + + } + + public void addToRepo() throws IOException, NoFilepatternException, GitAPIException { + AddCommand add = git.add(); + add.addFilepattern(".").call(); + } + + public void commitToRepo(String message) throws IOException, NoHeadException, NoMessageException, + ConcurrentRefUpdateException, JGitInternalException, WrongRepositoryStateException, GitAPIException { + git.commit().setMessage(message).call(); + } + + public void pushToRepo() throws IOException, JGitInternalException, InvalidRemoteException, GitAPIException { + PushCommand pc = git.push(); + pc.setCredentialsProvider(cp).setForce(true).setPushAll(); + try { + Iterator<PushResult> it = pc.call().iterator(); + if (it.hasNext()) { + System.out.println(it.next().toString()); + } + } catch (InvalidRemoteException e) { + e.printStackTrace(); + } + } + + public void pullFromRepo() + throws IOException, WrongRepositoryStateException, InvalidConfigurationException, DetachedHeadException, + InvalidRemoteException, CanceledException, RefNotFoundException, NoHeadException, GitAPIException { + git.pull().setCredentialsProvider(new UsernamePasswordCredentialsProvider(this.username, this.userpassword)) + .call(); + } + + private ConfigFileService getConfigService() { + AbstractApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); + ConfigFileService configService = (ConfigFileService) context.getBean("configFileService"); + context.close(); + return configService; + } + +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/ConfigFileService.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/ConfigFileService.java new file mode 100644 index 0000000000000000000000000000000000000000..deb9fbbbc75edd32719e9b55ff1f8d782fd46834 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/ConfigFileService.java @@ -0,0 +1,25 @@ +package eu.DECIDEh2020.mcsla.service.service; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +public interface ConfigFileService { + + public String getGitremotepath(); + + public String getGitusername(); + + public String getGituserpassword(); + + public void readValues(); +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/ConfigFileServiceImpl.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/ConfigFileServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..4e56eb0b302d8354e56bb22e4e782cf2fabedf42 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/ConfigFileServiceImpl.java @@ -0,0 +1,85 @@ +package eu.DECIDEh2020.mcsla.service.service; + +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; + +@Service("configFileService") +public class ConfigFileServiceImpl implements ConfigFileService { + + private static final String DECIDE_APP_GIT_REMOTE_PATH = "decide.app.git.remote-path"; + private static final String DECIDE_APP_GIT_USER_NAME = "decide.app.git.user-name"; + private static final String DECIDE_APP_GIT_USER_PASSWORD = "decide.app.git.user-password"; + @Value("${decide.app.git.remote-path:https://gitlab.fokus.fraunhofer.de/decide/test.git}") + private String gitremotepath; + @Value("${decide.app.git.user-name:decideuser}") + private String gitusername; + @Value("${decide.app.git.user-password:decidepassword}") + private String gituserpassword; + + @Autowired + private Environment environment; + + public String getGitremotepath() { + String envRemotepath = environment.getProperty(DECIDE_APP_GIT_REMOTE_PATH); + if (envRemotepath != null) + return envRemotepath; + else + return gitremotepath; + + } + + public String getGitusername() { + String envUsername = environment.getProperty(DECIDE_APP_GIT_USER_NAME); + if (envUsername != null) + return envUsername; + else + return gitusername; + } + + public String getGituserpassword() { + String envUserpassword = environment.getProperty(DECIDE_APP_GIT_USER_PASSWORD); + if (envUserpassword != null) + return envUserpassword; + else + return gituserpassword; + } + + public void readValues() { + System.out.println( + "Getting property via Spring Environment User:" + environment.getProperty(DECIDE_APP_GIT_USER_NAME)); + System.out.println("Getting property via Spring Environment Remotepath:" + + environment.getProperty(DECIDE_APP_GIT_REMOTE_PATH)); + System.out.println("Destination gitremotepath : " + gitremotepath); + System.out.println("Destination gitusername : " + gitusername); + //System.out.println("Destination gituserpassword : " + gituserpassword); + + } + + public void setGitremotepath(String gitremotepath) { + this.gitremotepath = gitremotepath; + } + + public void setGitusername(String gitusername) { + this.gitusername = gitusername; + } + + public void setGituserpassword(String gituserpassword) { + this.gituserpassword = gituserpassword; + } + +} diff --git a/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/McslaService.java b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/McslaService.java new file mode 100644 index 0000000000000000000000000000000000000000..37b6928e40c12d233f81883338bec82ce9741567 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/java/eu/DECIDEh2020/mcsla/service/service/McslaService.java @@ -0,0 +1,437 @@ +package eu.DECIDEh2020.mcsla.service.service; +/* +* Copyright (c) 2017 Fraunhofer FOKUS. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the +* <<licensing_schema_to_be_decided>> which accompanies +* this distribution, and is available at +* https://opensource.org/licenses/EPL-2.0 +* +* Contributors: +* +* Majid Salehi Ghamsari Fraunhofer FOKUS +**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu +*/ +import java.io.IOException; +import java.text.NumberFormat; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.UUID; + +import org.eclipse.jgit.api.errors.GitAPIException; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.support.AbstractApplicationContext; + +import eu.DECIDEh2020.mcsla.beans.Csp; +import eu.DECIDEh2020.mcsla.beans.Mcsla; +import eu.DECIDEh2020.mcsla.beans.Metric; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLA; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLO; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSQO; +import eu.DECIDEh2020.mcsla.beans.Remedy; +import eu.DECIDEh2020.mcsla.beans.UnderlyingMetricRef; +import eu.DECIDEh2020.mcsla.beans.ViolationTriggerRule; +import eu.DECIDEh2020.mcsla.service.configuration.AppConfig; +import eu.DECIDEh2020.mcsla.service.configuration.ProjectConfig; +import eu.DECIDEh2020.mcsla.service.git.GitControl; + +/* + * It is just a helper class which should be replaced by database implementation. + * It is not very well written class, it is just used for demonstration. + */ + +public class McslaService { + + private static final String SERVICE_COMPOSITION_DIFFEREN_VENDORS_PATTERN = "ServiceCompositionDifferenVendorsPattern"; + private static final String SERVICE_COMPOSITION_REPLICATION_PATTERN = "ServiceCompositionReplicationPattern"; + private static final String SERVICE_COMPOSITION__SIMPLE_PATTERN = "ServiceCompositionPattern"; + static HashMap<UUID, Mcsla> mcslaIdMap = getMcslaIdMap(); + static HashMap<UUID, Csp> cspIdMap = getCspIdMap(); + // private static Logger logger = LoggerFactory.getLogger(McslaService.class); + + private static MicroserviceSLA addSLOs(MicroserviceSLA sla) { + + List<MicroserviceSLO> slos = new ArrayList<>(); + MicroserviceSLO slo = createExampleUPtimeSLO("99,9"); + slo.setCsp_id(sla.getCsp_id()); + slo.setCsp_name(sla.getCsp_name()); + slos.add(slo); + slo = createExampleUtilizationSLO(); + slo.setCsp_id(sla.getCsp_id()); + slo.setCsp_name(sla.getCsp_name()); + slos.add(slo); + sla.setMicroservice_SLOs(slos); + return sla; + } + + private static Csp addSomeSLAs2CSP(Csp csp, int j) { + + UUID uid = UUID.randomUUID(); + String randomUUIDString = uid.toString(); + + List<MicroserviceSLA> slas = new ArrayList<>(); + int i = 0; + do { + i++; + UUID uuid = UUID.randomUUID(); + MicroserviceSLA sla = new MicroserviceSLA(); + sla.setMicroservice_SLA_id(uuid.toString()); + sla.set__comment("UPtime from CSP " + csp.getName() + + " gives a clear picture of the overall performance of the cloud(UPTIME)."); + sla.setCsp_id(csp.getmCSP_id().toString()); + sla.setCsp_name(csp.getName()); + sla.setValidityPeriod(Integer.toString(i)); + sla.setVisibility("private"); + uuid = UUID.randomUUID(); + randomUUIDString = uuid.toString(); + sla.setMicroservice_id(randomUUIDString); + sla = addSQOs(sla); + sla = addSLOs(sla); + slas.add(sla); + } while (i < j); + + csp.setSlas(slas); + + return csp; + + } + + private static MicroserviceSLA addSQOs(MicroserviceSLA sla) { + List<MicroserviceSQO> sqos = new ArrayList<>(); + MicroserviceSQO sqo = createExampleSQO("95"); + sqos.add(sqo); + sqo = createExampleSQO("97"); + sqos.add(sqo); + sla.setMicroservice_SQOs(sqos); + return sla; + } + + private static MicroserviceSLO createExampleUPtimeSLO(String uptime) { + MicroserviceSLO slo = new MicroserviceSLO(); + UUID uuid = UUID.randomUUID(); + slo.setMicroservice_SLO_id(uuid.toString()); + slo.set__comment("UPtime will not be less then " + uptime + "% of the time Over a Day"); + slo.setTermName("Uptime-SLO"); + slo.setMonitoringResult("result"); + slo.setValue(uptime); + slo.setUnit("percentage"); + slo.setCalculationFormula("Uptime GT " + uptime); + List<ViolationTriggerRule> vtrs = new ArrayList<>(); + ViolationTriggerRule vtr = new ViolationTriggerRule(); + vtr.setBreaches_count(2); + vtr.setViointerval(30); + vtrs.add(vtr); + slo.setViolationTriggerRule(vtrs); + Remedy remedy = new Remedy(); + remedy.setType("discount"); + remedy.setUnit("%"); + remedy.setValidity("P1D"); + remedy.setValue(5); + slo.setRemedy(remedy); + + List<Metric> metrics = new ArrayList<>(); + Metric metric = new Metric(); + metric.setMetric_id("CSA_002"); + metric.setDescriptor("CloudServiceAvailability"); + UnderlyingMetricRef underlyingMetricRef = new UnderlyingMetricRef(); + underlyingMetricRef.setRefid("TQD_001"); + metric.setUnderlyingMetricRef(underlyingMetricRef); + metrics.add(metric); + slo.setMetrics(metrics); + return slo; + } + + private static MicroserviceSLO createExampleUtilizationSLO() { + MicroserviceSLO slo = new MicroserviceSLO(); + UUID uuid = UUID.randomUUID(); + slo.setMicroservice_SLO_id(uuid.toString()); + slo.set__comment("CPU Utilization will not be less then 95% of the time Over a Day"); + slo.setTermName("CPU-utilization-SLO"); + slo.setMonitoringResult("result"); + slo.setValue("95"); + slo.setUnit("percentage"); + slo.setCalculationFormula("CPU-utilization LT 95"); + List<ViolationTriggerRule> vtrs = new ArrayList<>(); + ViolationTriggerRule vtr = new ViolationTriggerRule(); + vtr.setBreaches_count(2); + vtr.setViointerval(30); + vtrs.add(vtr); + slo.setViolationTriggerRule(vtrs); + Remedy remedy = new Remedy(); + remedy.setType("discount"); + remedy.setUnit("%"); + remedy.setValidity("P1D"); + remedy.setValue(5); + slo.setRemedy(remedy); + + List<Metric> metrics = new ArrayList<>(); + Metric metric = new Metric(); + metric.setMetric_id("CSA_002"); + metric.setDescriptor("CloudServiceAvailability"); + UnderlyingMetricRef underlyingMetricRef = new UnderlyingMetricRef(); + underlyingMetricRef.setRefid("TQD_001"); + metric.setUnderlyingMetricRef(underlyingMetricRef); + metrics.add(metric); + slo.setMetrics(metrics); + return slo; + } + + private static MicroserviceSQO createExampleSQO(String value) { + MicroserviceSQO sqo = new MicroserviceSQO(); + UUID uuid = UUID.randomUUID(); + sqo.setMicroservice_SQO_id(uuid.toString()); + sqo.set__comment("CPU Uitlization will not be less then 95% of the time Over a Day"); + sqo.setTermName("CPU-utilization-SQO"); + sqo.setMonitoringResult("result"); + sqo.setValue(value); + sqo.setUnit("percentage"); + sqo.setCalculationFormula("CPU-utilization LT 95"); + List<ViolationTriggerRule> vtrs = new ArrayList<>(); + ViolationTriggerRule vtr = new ViolationTriggerRule(); + vtr.setBreaches_count(2); + vtr.setViointerval(30); + vtrs.add(vtr); + sqo.setViolationTriggerRule(vtrs); + Remedy remedy = new Remedy(); + remedy.setType("discount"); + remedy.setUnit("%"); + remedy.setValidity("P1D"); + remedy.setValue(5); + sqo.setRemedy(remedy); + + List<Metric> metrics = new ArrayList<>(); + Metric metric = new Metric(); + metric.setMetric_id("CSA_002"); + metric.setDescriptor("CloudServiceAvailability"); + UnderlyingMetricRef underlyingMetricRef = new UnderlyingMetricRef(); + underlyingMetricRef.setRefid("TQD_001"); + metric.setUnderlyingMetricRef(underlyingMetricRef); + metrics.add(metric); + sqo.setMetrics(metrics); + return sqo; + } + + public static HashMap<UUID, Csp> getCspIdMap() { + return cspIdMap; + } + + public static HashMap<UUID, Mcsla> getMcslaIdMap() { + return mcslaIdMap; + } + + public McslaService() { + super(); + + System.out.println("McslaService start...."); + + if (mcslaIdMap == null) { + createMcslaHashmap(); + } + if (cspIdMap == null) { + createCspHashmap(); + } + } + + public Mcsla addMcsla(Mcsla mcsla) { + if (mcsla.getmCSLA_id() == null) + mcsla.setmCSLA_id(UUID.randomUUID()); + mcslaIdMap.put(mcsla.getmCSLA_id(), mcsla); + + // Push to repository + try { + GitControl gc = new GitControl(); + gc.pushMcslaToRepo(mcsla); + } catch (IOException | GitAPIException e) { + System.out.println("McslaService:addMcsla:FAILED"); + e.printStackTrace(); + return null; + } + + return mcsla; + } + + public MicroserviceSLO aggregate(List<MicroserviceSLO> slos) { + return doAggregation(slos, SERVICE_COMPOSITION__SIMPLE_PATTERN); + } + + private MicroserviceSLO doAggregation(List<MicroserviceSLO> slos, String pattern) { + System.out.println("McslaService:doAggregation:" + pattern); + String operation = "SUMtype"; + double calculatedUptime = 100; + if (pattern.equalsIgnoreCase(SERVICE_COMPOSITION__SIMPLE_PATTERN)) + operation = "SUMtype"; + if (pattern.equalsIgnoreCase(SERVICE_COMPOSITION_REPLICATION_PATTERN)) + operation = "MINtype"; + if (pattern.equalsIgnoreCase(SERVICE_COMPOSITION_DIFFEREN_VENDORS_PATTERN)) + operation = "ORtype"; + + for (Iterator<MicroserviceSLO> iterator = slos.iterator(); iterator.hasNext();) { + MicroserviceSLO microserviceSLO = (MicroserviceSLO) iterator.next(); + // TODO FIX THIS Uptime-SLO? + if (microserviceSLO.termName.equalsIgnoreCase("Uptime-SLO")) + calculatedUptime = caluculate(microserviceSLO.getValue(), operation, calculatedUptime); + } + MicroserviceSLO aggSlo = createExampleUPtimeSLO(String.valueOf(calculatedUptime)); + aggSlo.csp_name = "!Aggregated!"; + return aggSlo; + } + + private static double round(double value, int precision) { + int scale = (int) Math.pow(10, precision); + return (double) Math.round(value * scale) / scale; + } + + private double caluculate(String value, String operation, double olduptime) { + // System.out.println("McslaService:caluculate:value:" + value + " oldtime:" + + // olduptime); + double downtime = 0; + if (operation.equalsIgnoreCase("SUMtype")) { + NumberFormat format = NumberFormat.getInstance(Locale.FRANCE); + Number number = null; + try { + number = format.parse(value); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + double d = number.doubleValue(); + downtime = 100 - d; + } + // System.out.println("McslaService:caluculate:downtime:" + downtime); + double newtime = olduptime - downtime; + // System.out.println("McslaService:caluculate:newtime:" + newtime); + + return round(newtime, 1); + } + + private void createCspHashmap() { + cspIdMap = new HashMap<UUID, Csp>(); + // Creating some objects of CSP while initializing + Csp csp1 = new Csp(UUID.randomUUID(), "Amazon"); + addSomeSLAs2CSP(csp1, 1); + Csp csp2 = new Csp(UUID.randomUUID(), "Azure"); + addSomeSLAs2CSP(csp2, 1); + Csp csp3 = new Csp(UUID.randomUUID(), "IBM"); + addSomeSLAs2CSP(csp3, 1); + // Csp csp4 = new Csp(UUID.randomUUID(), "Telekom"); + // addSomeSLAs2CSP(csp4, 1); + + cspIdMap.put(csp1.getmCSP_id(), csp1); + cspIdMap.put(csp2.getmCSP_id(), csp2); + cspIdMap.put(csp3.getmCSP_id(), csp3); + // cspIdMap.put(csp4.getmCSP_id(), csp4); + + } + + private void createMcslaHashmap() { + + mcslaIdMap = new HashMap<UUID, Mcsla>(); + // Creating some objects of Mcsla while initializing + Mcsla m1 = new Mcsla(UUID.randomUUID(), "this is MCSLA1 description line.", "public", + "this is MCSLA1 setValidityPeriod line."); + Mcsla m2 = new Mcsla(UUID.randomUUID(), "this is MCSLA2 description line.", "public", + "this is MCSLA2 setValidityPeriod line."); + Mcsla m3 = new Mcsla(UUID.randomUUID(), "this is MCSLA3 description line.", "private", + "this is MCSLA3 setValidityPeriod line."); + Mcsla m4 = new Mcsla(UUID.randomUUID(), "this is MCSLA4 description line.", "public", + "this is MCSLA4 setValidityPeriod line."); + Mcsla m5 = new Mcsla(UUID.randomUUID(), "this is MCSLA5 description line.", "public", + "this is MCSLA5 setValidityPeriod line."); + + mcslaIdMap.put(m1.getmCSLA_id(), m1); + mcslaIdMap.put(m2.getmCSLA_id(), m2); + mcslaIdMap.put(m3.getmCSLA_id(), m3); + mcslaIdMap.put(m4.getmCSLA_id(), m4); + mcslaIdMap.put(m5.getmCSLA_id(), m5); + } + + public void deleteMcsla(String id) { + UUID uid = UUID.fromString(id); + mcslaIdMap.remove(uid); + } + + public List<Csp> getAllCsps() { + List<Csp> csps = new ArrayList<Csp>(cspIdMap.values()); + return csps; + } + + public List<Mcsla> getAllMcslas() { + ConfigFileService configService = getConfigService(); + //configService.readValues(); + System.out.println("McslaService:updateMcsla:id:" + configService.getGitremotepath()); + + List<Mcsla> mcslas = new ArrayList<Mcsla>(mcslaIdMap.values()); + return mcslas; + } + + private ConfigFileService getConfigService() { + AbstractApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); + ConfigFileService configService = (ConfigFileService) context.getBean("configFileService"); + context.close(); + return configService; + } + + public List<MicroserviceSLA> getCspSLAs(String id) { + UUID uid = UUID.fromString(id); + Csp csp = cspIdMap.get(uid); + return csp.getSlas(); + } + + public Mcsla getMcsla(String id) { + UUID uid = UUID.fromString(id); + Mcsla mcsla = mcslaIdMap.get(uid); + return mcsla; + } + + public Mcsla updateMcsla(Mcsla mcsla) { + UUID uid = mcsla.getmCSLA_id(); + if (uid == null) + return null; + System.out.println("McslaService:updateMcsla:id:" + uid); + mcslaIdMap.put(uid, mcsla); + + // Push to repository + try { + GitControl gc = new GitControl(); + gc.pushMcslaToRepo(mcsla); + } catch (IOException | GitAPIException e) { + // TODO Auto-generated catch block + System.out.println("McslaService:updateMcsla:FAILED"); + e.printStackTrace(); + return null; + } + System.out.println("McslaService:updateMcsla:--Done--"); + return mcsla; + + } + + public ProjectConfig getProjectConfig() { + + ConfigFileService configService = getConfigService(); + ProjectConfig projectConfig = new ProjectConfig(configService.getGitremotepath(), + configService.getGitusername()); + return projectConfig; + } + + // operation on GET MCSLAfrom repo + public Mcsla getMcsla() { + Mcsla mcsla; + // Get from repository + try { + GitControl gc = new GitControl(); + mcsla = gc.getMcslaFromRepo(); + } catch (IOException | GitAPIException e) { + // TODO Auto-generated catch block + System.out.println("McslaService:getMcsla:FAILED"); + e.printStackTrace(); + return null; + } + System.out.println("McslaService:getMcsla:--Done--"); + return mcsla; + } + +} diff --git a/DevOpsFramework/MCSLAService/src/main/resources/application.properties b/DevOpsFramework/MCSLAService/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..3a5d92dff8a5c58311f76cac58dc33fe78ece973 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/resources/application.properties @@ -0,0 +1,6 @@ +logging.level.com.concretepage= INFO +decide.app.git.remote-path= https://gitlab.fokus.fraunhofer.de/tja/test.git +decide.app.git.user-name= test +decide.app.git.user-password= testpassword +# this is just for test the srv with JerseyClient.java +# decide.mcsla.srv=http://localhost:8080/decide.mcsla.srv \ No newline at end of file diff --git a/DevOpsFramework/MCSLAService/src/main/webapp/WEB-INF/springrest-servlet.xml b/DevOpsFramework/MCSLAService/src/main/webapp/WEB-INF/springrest-servlet.xml new file mode 100644 index 0000000000000000000000000000000000000000..196b41073904e16cf1e8155fe553ae98762b7c17 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/webapp/WEB-INF/springrest-servlet.xml @@ -0,0 +1,12 @@ + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> + + <mvc:annotation-driven /> + <context:component-scan base-package="eu.DECIDEh2020.mcsla.service.controller" /> + +</beans> + diff --git a/DevOpsFramework/MCSLAService/src/main/webapp/WEB-INF/web.xml b/DevOpsFramework/MCSLAService/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..12c49881c8876d6f35095748c0a45dbdb65adf1a --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,19 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>Archetype Created Web Application</display-name> + <servlet> + <servlet-name>springrest</servlet-name> + <servlet-class> + org.springframework.web.servlet.DispatcherServlet + </servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>springrest</servlet-name> + <url-pattern>/</url-pattern> + </servlet-mapping> +</web-app> diff --git a/DevOpsFramework/MCSLAService/src/main/webapp/index.jsp b/DevOpsFramework/MCSLAService/src/main/webapp/index.jsp new file mode 100644 index 0000000000000000000000000000000000000000..700676689f817f6ae81bfaf5a116ffa722f9cda0 --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/main/webapp/index.jsp @@ -0,0 +1,17 @@ +<html> + <body> + <h2>DECIDE MCSLA Service (v2)</h2> + <p> + Get method All <a href="http://localhost:8080/decide.mcsla.srv/mcslas">mcslas</a> + </p> + <p> + Get method <a href="http://localhost:8080/decide.mcsla.srv/mcsla">mcsla</a> + </p> + <p> + Get method All <a href="http://localhost:8080/decide.mcsla.srv/csps">csps</a> + </p> + <p> + Get method <a href="http://localhost:8080/decide.mcsla.srv/config">config</a> + </p> + </body> +</html> \ No newline at end of file diff --git a/DevOpsFramework/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/JerseyClient.java b/DevOpsFramework/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/JerseyClient.java new file mode 100644 index 0000000000000000000000000000000000000000..40218e649a97ad5dc2209b9f43f9c204c9d1262c --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/JerseyClient.java @@ -0,0 +1,249 @@ +package eu.DECIDEh2020.mcsla.service.tests; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +import eu.DECIDEh2020.mcsla.beans.Csp; +import eu.DECIDEh2020.mcsla.beans.Mcsla; +import eu.DECIDEh2020.mcsla.beans.Metric; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLA; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSLO; +import eu.DECIDEh2020.mcsla.beans.MicroserviceSQO; +import eu.DECIDEh2020.mcsla.beans.Remedy; +import eu.DECIDEh2020.mcsla.beans.UnderlyingMetricRef; +import eu.DECIDEh2020.mcsla.beans.ViolationTriggerRule; +import eu.DECIDEh2020.mcsla.service.configuration.ProjectConfig; + +public class JerseyClient { + private static final String SRV_MCSLAS = "http://localhost:8080/decide.mcsla.srv/mcslas"; + private static final String SRV_CSPS = "http://localhost:8080/decide.mcsla.srv/csps"; + private static final String SRV_CONFIG = "http://localhost:8080/decide.mcsla.srv/config"; + private static final String SRV_AGGREGATE = "http://localhost:8080/decide.mcsla.srv/aggregate"; + + public static void main(String[] args) { + + System.out.println("####################TEST MAIN START####################"); + JerseyClient jerseyClient = new JerseyClient(); + ProjectConfig config = jerseyClient.getProjectConfig(); + System.out.println( + "Main:got ProjectConfig user:" + config.getGitusername() + " path:" + config.getGitremotepath()); + // jerseyClient.getMcslaDetails(); + // get currently used CSPs returns CSP SLAs + MicroserviceSLA[] slas = jerseyClient.getCspSLAs(); + System.out.println("Main:got CSP SLAs:" + slas.length); + // Prepare SLOs to send to MCSLA Aggregator + MicroserviceSLO[] slos = buildSLOs(slas); + System.out.println("Main:got list SLOs:" + slos.length); + // Return aggregated SLO + MicroserviceSLO aggregatedSLO = jerseyClient.applyAggregationRules(slos); + if (aggregatedSLO != null) + System.out.println("Main:got aggregated SLO:" + aggregatedSLO.termName); + else + System.out.println("Main:got aggregated SLO is NULL :-("); + // if (true) + // return; + Mcsla mcsla = createMCSLAexample(aggregatedSLO); + jerseyClient.addMcsla(mcsla); + System.out.println("Main:addMcsla done."); + + DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + Date date = new Date(); + mcsla.setDescription("this is MCSLA UPDATED at:" + dateFormat.format(date) + " description line."); + mcsla = jerseyClient.updateMcsla(mcsla); + if (mcsla == null) { + System.out.println("Main:got updated mcsla is NULL :-("); + return; + } else + System.out.println("Main:updateMcsla done."); + + mcsla = jerseyClient.getMcslaById(mcsla.mCSLA_id.toString()); + System.out.println("Main:getMcslaById:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription()); + // jerseyClient.deleteMcsla(mcsla.getmCSLA_id()); + System.out.println("####################TEST MAIN DONE####################"); + + } + + private ProjectConfig getProjectConfig() { + RestTemplate restTemplate = new RestTemplate(); + ProjectConfig pconfig = restTemplate.getForObject(SRV_CONFIG, ProjectConfig.class); + System.out.println("JerseyClient:getAppConfig:" + pconfig.getGitusername() + ", " + pconfig.getGitremotepath()); + return pconfig; + } + + @SuppressWarnings("unused") + private static MicroserviceSLA addSQOs(MicroserviceSLA sla) { + UUID uuid = UUID.randomUUID(); + + List<MicroserviceSQO> sqos = new ArrayList<>(); + MicroserviceSQO sqo = new MicroserviceSQO(); + sqo.setMicroservice_SQO_id(uuid.toString()); + sqo.set__comment("CPU Uitlization will not be less then 85% of the time Over a Day"); + sqo.setTermName("CPU-utilization"); + sqo.setMonitoringResult("result"); + sqo.setValue("95"); + sqo.setUnit("percentage"); + sqo.setCalculationFormula("CPU-utilization LT 85"); + List<ViolationTriggerRule> vtrs = new ArrayList<>(); + ViolationTriggerRule vtr = new ViolationTriggerRule(); + vtr.setBreaches_count(2); + vtr.setViointerval(30); + vtrs.add(vtr); + sqo.setViolationTriggerRule(vtrs); + Remedy remedy = new Remedy(); + remedy.setType("discount"); + remedy.setUnit("%"); + remedy.setValidity("P1D"); + remedy.setValue(5); + sqo.setRemedy(remedy); + + List<Metric> metrics = new ArrayList<>(); + Metric metric = new Metric(); + metric.setMetric_id("CSA_002"); + metric.setDescriptor("CloudServiceAvailability"); + UnderlyingMetricRef underlyingMetricRef = new UnderlyingMetricRef(); + underlyingMetricRef.setRefid("TQD_001"); + metric.setUnderlyingMetricRef(underlyingMetricRef); + metrics.add(metric); + sqo.setMetrics(metrics); + sqos.add(sqo); + sla.setMicroservice_SQOs(sqos); + return sla; + } + + private static MicroserviceSLO[] buildSLOs(MicroserviceSLA[] slas) { + List<MicroserviceSLO> sloslist = new ArrayList<>(); + for (MicroserviceSLA sla : slas) { + if (sla.getMicroservice_SLOs() != null) + sloslist.addAll(sla.getMicroservice_SLOs()); + } + MicroserviceSLO[] slos = new MicroserviceSLO[sloslist.size()]; + slos = sloslist.toArray(slos); + return slos; + } + + private static Mcsla createMCSLAexample(MicroserviceSLO slo) { + + UUID uid = UUID.randomUUID(); + String randomUUIDString = uid.toString(); + Mcsla mcsla = new Mcsla(); + mcsla.setmCSLA_id(uid); + mcsla.setDescription("this is MCSLA dummy description line created from createMCSLAexample method."); + mcsla.setVisibility("public"); + mcsla.setValidityPeriod("this is Validity Period line."); + List<MicroserviceSLA> slas = new ArrayList<>(); + + UUID uuid = UUID.randomUUID(); + MicroserviceSLA sla = new MicroserviceSLA(); + sla.setMicroservice_SLA_id(uuid.toString()); + sla.set__comment(slo.__comment); + uuid = UUID.randomUUID(); + randomUUIDString = uuid.toString(); + // TODO fix this need valid CSP + sla.setCsp_id(randomUUIDString); + // TODO fix this need valid setValidityPeriod + sla.setValidityPeriod(Integer.toString(5)); + sla.setVisibility("public"); + uuid = UUID.randomUUID(); + randomUUIDString = uuid.toString(); + sla.setMicroservice_id(randomUUIDString); + List<MicroserviceSLO> slos = new ArrayList<>(); + + slos.add(slo); + sla.setMicroservice_SLOs(slos); + slas.add(sla); + mcsla.setMicroservice_SLAs(slas); + + return mcsla; + + } + + public void addMcsla(Mcsla mcsla) { + // It is used to create new resource. Method POST + RestTemplate restTemplate = new RestTemplate(); + HttpEntity<Mcsla> request = new HttpEntity<>(mcsla); + Mcsla resMcsla = restTemplate.postForObject(SRV_MCSLAS, request, Mcsla.class); + if (resMcsla == null) + System.out.println("JerseyClient:addMcsla:FAILED"); + else + System.out.println("JerseyClient:addMcsla:" + resMcsla.getmCSLA_id() + ", " + resMcsla.getDescription()); + } + + private MicroserviceSLO applyAggregationRules(MicroserviceSLO[] slos) { + System.out.printf("JerseyClient:applyAggregationRules to %s SLOs %n", slos.length); + RestTemplate restTemplate = new RestTemplate(); + HttpEntity<MicroserviceSLO[]> requestEntity = new HttpEntity<MicroserviceSLO[]>(slos); + HttpEntity<MicroserviceSLO> response = restTemplate.exchange(SRV_AGGREGATE, HttpMethod.POST, requestEntity, + MicroserviceSLO.class); + MicroserviceSLO resSLO = response.getBody(); + System.out.println( + "JerseyClient:applyAggregationRules:" + resSLO.getMicroservice_SLO_id() + ", " + resSLO.getTermName()); + return resSLO; + } + + public void deleteMcsla(UUID uid) { + RestTemplate restTemplate = new RestTemplate(); + String entityUrl = SRV_MCSLAS + "/" + uid.toString(); + restTemplate.delete(entityUrl); + } + + public MicroserviceSLA[] getCspSLAs() { + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity<Csp[]> responseEntity = restTemplate.getForEntity(SRV_CSPS, Csp[].class); + Csp[] csplist = responseEntity.getBody(); + + List<MicroserviceSLA> slaslist = new ArrayList<>(); + // for each CSP get SLAs + for (int index = 0; index < csplist.length; index++) { + ResponseEntity<MicroserviceSLA[]> responseEntitylist = restTemplate.getForEntity(SRV_CSPS + "/{id}", + MicroserviceSLA[].class, csplist[index].getmCSP_id()); + MicroserviceSLA[] slas = responseEntitylist.getBody(); + List<MicroserviceSLA> cspslas = new ArrayList<MicroserviceSLA>(Arrays.asList(slas)); + slaslist.addAll(cspslas); + } + + System.out.println("JerseyClient:getCspSLAs:" + slaslist.size()); + return slaslist.toArray(new MicroserviceSLA[slaslist.size()]); + } + + public Mcsla getMcslaById(String id) { + RestTemplate restTemplate = new RestTemplate(); + Mcsla mcsla = restTemplate.getForObject(SRV_MCSLAS + "/{id}", Mcsla.class, id); + System.out.println("JerseyClient:getMcslaById:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription()); + return mcsla; + } + + public void getMcslaDetails() { + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity<Mcsla[]> responseEntity = restTemplate.getForEntity(SRV_MCSLAS, Mcsla[].class); + Mcsla[] list = responseEntity.getBody(); + // HttpStatus statusCode = responseEntity.getStatusCode(); + // System.out.println("HttpStatus:getMcslaDetails:" + + // statusCode.value()); + + for (int index = 0; index < list.length; index++) { + System.out.println(list[index].getmCSLA_id() + ", " + list[index].getDescription()); + } + } + + public Mcsla updateMcsla(Mcsla mcsla) { + // It is generally used to update resource, METHOD PUT + System.out.println("JerseyClient:updateMcsla:" + mcsla.getmCSLA_id() + ", " + mcsla.getDescription()); + RestTemplate restTemplate = new RestTemplate(); + HttpEntity<Mcsla> requestEntity = new HttpEntity<Mcsla>(mcsla); + HttpEntity<Mcsla> response = restTemplate.exchange(SRV_MCSLAS, HttpMethod.PUT, requestEntity, Mcsla.class); + Mcsla resMcsla = response.getBody(); + if (resMcsla == null) + System.out.println("JerseyClient:updateMcsla:FAILED"); + return resMcsla; + } +} diff --git a/DevOpsFramework/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/TestGit.java b/DevOpsFramework/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/TestGit.java new file mode 100644 index 0000000000000000000000000000000000000000..f2a068022cf0fe18ef959bcd98d5403ed34c4c2d --- /dev/null +++ b/DevOpsFramework/MCSLAService/src/test/java/eu/DECIDEh2020/mcsla/service/tests/TestGit.java @@ -0,0 +1,89 @@ +package eu.DECIDEh2020.mcsla.service.tests; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import java.util.UUID; + +import org.eclipse.jgit.api.errors.CanceledException; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.DetachedHeadException; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidConfigurationException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.NoFilepatternException; +import org.eclipse.jgit.api.errors.NoHeadException; +import org.eclipse.jgit.api.errors.NoMessageException; +import org.eclipse.jgit.api.errors.RefNotFoundException; +import org.eclipse.jgit.api.errors.WrongRepositoryStateException; + +import eu.DECIDEh2020.mcsla.beans.Mcsla; +import eu.DECIDEh2020.mcsla.service.git.GitControl; + +public class TestGit { + + public static void main(String[] args) throws IOException, GitAPIException { + + Mcsla mcsla = new Mcsla(UUID.randomUUID(), "this is MCSLA3 description line.", "public", + "this is MCSLA3 setValidityPeriod line."); + pushToRepo(mcsla); + + getFromRepo(); + + } + + private static void getFromRepo() + throws IOException, NoFilepatternException, GitAPIException, FileNotFoundException, NoHeadException, + NoMessageException, ConcurrentRefUpdateException, WrongRepositoryStateException, InvalidRemoteException, + InvalidConfigurationException, DetachedHeadException, CanceledException, RefNotFoundException { + + GitControl gc = new GitControl(); + // Push to repository + Mcsla mcsla = gc.getMcslaFromRepo(); + System.out.println("TestGit:getFromRepo:" + mcsla.getmCSLA_id()); + } + + private static void pushToRepo(Mcsla mcsla) + throws IOException, NoFilepatternException, GitAPIException, FileNotFoundException, NoHeadException, + NoMessageException, ConcurrentRefUpdateException, WrongRepositoryStateException, InvalidRemoteException, + InvalidConfigurationException, DetachedHeadException, CanceledException, RefNotFoundException { + + GitControl gc = new GitControl(); + // Push to repository + gc.pushMcslaToRepo(mcsla); + } + + @SuppressWarnings("unused") + private static String getProperty(String key) { + Properties prop = new Properties(); + InputStream input = null; + String value = null; + try { + + String propertiesfilename = "application.properties"; + input = TestGit.class.getClassLoader().getResourceAsStream(propertiesfilename); + if (input == null) { + System.out.println("Sorry, unable to find properties file:" + propertiesfilename); + return null; + } + + prop.load(input); + + value = prop.getProperty(key); + + } catch (IOException ex) { + ex.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return value; + } + +} \ No newline at end of file