summaryrefslogtreecommitdiffstats
path: root/winery/org.eclipse.winery.common/src
diff options
context:
space:
mode:
authorhuangjian <huang.jian12@zte.com.cn>2016-08-31 16:47:33 +0800
committerhuangjian <huang.jian12@zte.com.cn>2016-08-31 16:47:33 +0800
commitfa49e78cc199526a9e33b59c5194f8e3bf0f0952 (patch)
tree3478e867a8f304266dbceca6e992cceca410ede4 /winery/org.eclipse.winery.common/src
parent159d40f0011559c8f82338b29dca1bffd700f2c8 (diff)
Add winery source code
Change-Id: I1c5088121d79b71098c3cba1996c6f784737532e Issue-id: TOSCA-49 Signed-off-by: huangjian <huang.jian12@zte.com.cn>
Diffstat (limited to 'winery/org.eclipse.winery.common/src')
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/META-INF/MANIFEST.MF3
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ModelUtilities.java670
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/RepositoryFileReference.java84
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/StringEncodedAndDecoded.java88
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/TOSCADocumentBuilderFactory.java73
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/Util.java603
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/beans/NamespaceIdOptionalName.java57
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/Defaults.java25
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/MimeTypes.java26
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/Namespaces.java28
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/QNames.java23
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/GenericId.java56
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/IdNames.java31
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/IdUtil.java104
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/Namespace.java32
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/XMLId.java32
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ArtifactTemplateId.java32
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ArtifactTypeId.java33
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/CapabilityTypeId.java33
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTemplateId.java42
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTypeId.java33
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTypeImplementationId.java26
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/NodeTypeId.java33
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/NodeTypeImplementationId.java26
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/PolicyTemplateId.java32
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/PolicyTypeId.java33
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RelationshipTypeId.java32
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RelationshipTypeImplementationId.java26
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RequirementTypeId.java32
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ServiceTemplateId.java33
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/TOSCAComponentId.java116
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/TopologyGraphElementEntityTypeId.java36
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/imports/GenericImportId.java64
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/imports/XSDImportId.java36
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/package-info.java17
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/PlanId.java22
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/PlansId.java28
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/TOSCAElementId.java77
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/package-info.java17
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/IWineryRepository.java149
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/IWineryRepositoryCommon.java42
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/QNameAlreadyExistsException.java18
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/QNameWithName.java24
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/PropertyDefinitionKV.java59
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/PropertyDefinitionKVList.java31
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/WinerysPropertiesDefinition.java77
-rw-r--r--winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/package-info.java29
-rw-r--r--winery/org.eclipse.winery.common/src/main/resources/TOSCA-v1.0.xsd791
-rw-r--r--winery/org.eclipse.winery.common/src/test/java/.gitkeep0
-rw-r--r--winery/org.eclipse.winery.common/src/test/java/META-INF/MANIFEST.MF3
-rw-r--r--winery/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/ModelUtilitiesTest.java13
-rw-r--r--winery/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/TestUtil.java48
52 files changed, 4078 insertions, 0 deletions
diff --git a/winery/org.eclipse.winery.common/src/main/java/META-INF/MANIFEST.MF b/winery/org.eclipse.winery.common/src/main/java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..254272e
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ModelUtilities.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ModelUtilities.java
new file mode 100644
index 0000000..92d8ec9
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ModelUtilities.java
@@ -0,0 +1,670 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.winery.common.constants.Namespaces;
+import org.eclipse.winery.common.constants.QNames;
+import org.eclipse.winery.common.propertydefinitionkv.PropertyDefinitionKV;
+import org.eclipse.winery.common.propertydefinitionkv.PropertyDefinitionKVList;
+import org.eclipse.winery.common.propertydefinitionkv.WinerysPropertiesDefinition;
+import org.eclipse.winery.model.tosca.TBoundaryDefinitions;
+import org.eclipse.winery.model.tosca.TCapability;
+import org.eclipse.winery.model.tosca.TCapabilityDefinition;
+import org.eclipse.winery.model.tosca.TEntityTemplate;
+import org.eclipse.winery.model.tosca.TEntityType;
+import org.eclipse.winery.model.tosca.TExtensibleElements;
+import org.eclipse.winery.model.tosca.TNodeTemplate;
+import org.eclipse.winery.model.tosca.TNodeTemplate.Capabilities;
+import org.eclipse.winery.model.tosca.TNodeTemplate.Requirements;
+import org.eclipse.winery.model.tosca.TNodeType;
+import org.eclipse.winery.model.tosca.TPlan;
+import org.eclipse.winery.model.tosca.TPlans;
+import org.eclipse.winery.model.tosca.TRelationshipTemplate;
+import org.eclipse.winery.model.tosca.TRelationshipTemplate.SourceElement;
+import org.eclipse.winery.model.tosca.TRelationshipTemplate.TargetElement;
+import org.eclipse.winery.model.tosca.TRelationshipType;
+import org.eclipse.winery.model.tosca.TRequirement;
+import org.eclipse.winery.model.tosca.TRequirementDefinition;
+import org.eclipse.winery.model.tosca.TServiceTemplate;
+import org.eclipse.winery.model.tosca.TTopologyTemplate;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+public class ModelUtilities {
+
+ private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ModelUtilities.class);
+
+
+ /**
+ * This is a special method for Winery. Winery allows to define a property
+ * definition by specifying name/type values. Instead of parsing the
+ * extensible elements returned TDefinitions, this method is a convenience
+ * method to access this information
+ *
+ * @param t the entitytype to read the properties definition from
+ * @return a WinerysPropertiesDefinition object, which includes a map of
+ * name/type-pairs denoting the associated property definitions. A
+ * default element name and namespace is added if it is not defined
+ * in the underlying XML. null if no Winery specific KV properties
+ * are defined for the given entity type
+ */
+ public static WinerysPropertiesDefinition getWinerysPropertiesDefinition(TEntityType et) {
+ // similar implementation as org.eclipse.winery.repository.resources.entitytypes.properties.PropertiesDefinitionResource.getListFromEntityType(TEntityType)
+ WinerysPropertiesDefinition res = null;
+ for (Object o : et.getAny()) {
+ if (o instanceof WinerysPropertiesDefinition) {
+ res = (WinerysPropertiesDefinition) o;
+ }
+ }
+
+ if (res != null) {
+ // we put defaults if elementname and namespace have not been set
+
+ if (res.getElementName() == null) {
+ res.setElementName("Properties");
+ }
+
+ if (res.getNamespace() == null) {
+ // we use the targetnamespace of the original element
+ String ns = et.getTargetNamespace();
+ if (!ns.endsWith("/")) {
+ ns += "/";
+ }
+ ns += "propertiesdefinition/winery";
+ res.setNamespace(ns);
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * This is a special method for Winery. Winery allows to define a property
+ * by specifying name/value values. Instead of parsing the XML contained in
+ * TNodeType, this method is a convenience method to access this information
+ *
+ * The return type "Properties" is used because of the key/value properties.
+ *
+ * @param template the node template to get the associated properties
+ */
+ public static Properties getPropertiesKV(TEntityTemplate template) {
+ Properties properties = new Properties();
+ org.eclipse.winery.model.tosca.TEntityTemplate.Properties tprops = template.getProperties();
+ if (tprops != null) {
+ // no checking for validity, just reading
+ Element el = (Element) tprops.getAny();
+ if (el == null) {
+ // somehow invalid .tosca. We return empty properties instead of throwing a NPE
+ return properties;
+ }
+ NodeList childNodes = el.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node item = childNodes.item(i);
+ if (item instanceof Element) {
+ String key = item.getLocalName();
+ String value = item.getTextContent();
+ properties.put(key, value);
+ }
+ }
+ }
+ return properties;
+ }
+
+ /**
+ * This is a special method for Winery. Winery allows to define a property
+ * by specifying name/value values. We convert the given Properties to XML.
+ *
+ * @param wpd the Winery's properties definition of the type of the given
+ * template (i.e., wpd =
+ * getWinerysPropertiesDefinition(template.getType()))
+ * @param template the node template to set the associated properties
+ */
+ public static void setPropertiesKV(WinerysPropertiesDefinition wpd, TEntityTemplate template, Properties properties) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ try {
+ db = dbf.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ ModelUtilities.logger.debug(e.getMessage(), e);
+ throw new IllegalStateException("Could not instantiate document builder", e);
+ }
+ Document doc = db.newDocument();
+
+ Element root = doc.createElementNS(wpd.getNamespace(), wpd.getElementName());
+ doc.appendChild(root);
+
+ // we produce the serialization in the same order the XSD would be generated (because of the usage of xsd:sequence)
+ for (PropertyDefinitionKV prop : wpd.getPropertyDefinitionKVList()) {
+ // we always write the element tag as the XSD forces that
+ Element element = doc.createElementNS(wpd.getNamespace(), prop.getKey());
+ root.appendChild(element);
+ String value = properties.getProperty(prop.getKey());
+ if (value != null) {
+ Text text = doc.createTextNode(value);
+ element.appendChild(text);
+ }
+ }
+
+ org.eclipse.winery.model.tosca.TEntityTemplate.Properties tprops = new org.eclipse.winery.model.tosca.TEntityTemplate.Properties();
+ tprops.setAny(doc.getDocumentElement());
+ template.setProperties(tprops);
+ }
+
+ /**
+ * Generates a XSD when Winery's K/V properties are used. This method is put
+ * here instead of WinerysPropertiesDefinitionResource to avoid generating
+ * the subresource
+ *
+ * public because of the usage by TOSCAEXportUtil
+ *
+ * @return empty Document, if Winery's Properties Definition is not fully
+ * filled (e.g., no wrapping element defined)
+ */
+ public static Document getWinerysPropertiesDefinitionXSDAsDocument(WinerysPropertiesDefinition wpd) {
+ /*
+ * This is a quick hack: an XML schema container is created for each
+ * element. Smarter solution: create a hash from namespace to XML schema
+ * element and re-use that for each new element
+ * Drawback of "smarter" solution: not a single XSD file any more
+ */
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder;
+ try {
+ docBuilder = docFactory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ ModelUtilities.logger.debug(e.getMessage(), e);
+ throw new IllegalStateException("Could not instantiate document builder", e);
+ }
+ Document doc = docBuilder.newDocument();
+
+ if (!ModelUtilities.allRequiredFieldsNonNull(wpd)) {
+ // wpd not fully filled -> valid XSD cannot be provided
+ // fallback: add comment and return "empty" document
+ Comment comment = doc.createComment("Required fields are missing in Winery's key/value properties definition.");
+ doc.appendChild(comment);
+ return doc;
+ }
+
+ // create XSD schema container
+ Element schemaElement = doc.createElementNS(XMLConstants.W3C_XML_SCHEMA_NS_URI, "schema");
+ doc.appendChild(schemaElement);
+ schemaElement.setAttribute("elementFormDefault", "qualified");
+ schemaElement.setAttribute("attributeFormDefault", "unqualified");
+ schemaElement.setAttribute("targetNamespace", wpd.getNamespace());
+
+ // create XSD element itself
+ Element el = doc.createElementNS(XMLConstants.W3C_XML_SCHEMA_NS_URI, "element");
+ schemaElement.appendChild(el);
+ el.setAttribute("name", wpd.getElementName());
+ Element el2 = doc.createElementNS(XMLConstants.W3C_XML_SCHEMA_NS_URI, "complexType");
+ el.appendChild(el2);
+ el = el2;
+ el2 = doc.createElementNS(XMLConstants.W3C_XML_SCHEMA_NS_URI, "sequence");
+ el.appendChild(el2);
+ el = el2;
+
+ // currently, "xsd" is a hardcoded prefix in the type definition
+ el.setAttribute("xmlns:xsd", XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+ for (PropertyDefinitionKV prop : wpd.getPropertyDefinitionKVList()) {
+ el2 = doc.createElementNS(XMLConstants.W3C_XML_SCHEMA_NS_URI, "element");
+ el.appendChild(el2);
+ el2.setAttribute("name", prop.getKey());
+ // prop.getType has the prefix included
+ el2.setAttribute("type", prop.getType());
+ }
+
+ return doc;
+ }
+
+ /**
+ * Removes an existing Winery's Properties definition. If no such definition
+ * exists, the TEntityType is not modified
+ */
+ public static void removeWinerysPropertiesDefinition(TEntityType et) {
+ for (Iterator<Object> iterator = et.getAny().iterator(); iterator.hasNext();) {
+ Object o = iterator.next();
+ if (o instanceof WinerysPropertiesDefinition) {
+ iterator.remove();
+ break;
+ }
+ }
+ }
+
+ public static void replaceWinerysPropertiesDefinition(TEntityType et, WinerysPropertiesDefinition wpd) {
+ ModelUtilities.removeWinerysPropertiesDefinition(et);
+ et.getAny().add(wpd);
+ }
+
+ public static String getBorderColor(TNodeType nt) {
+ String borderColor = nt.getOtherAttributes().get(QNames.QNAME_BORDER_COLOR);
+ if (borderColor == null) {
+ borderColor = Util.getColor(nt.getName());
+ }
+ return borderColor;
+ }
+
+ public static String getColor(TRelationshipType rt) {
+ String color = rt.getOtherAttributes().get(QNames.QNAME_COLOR);
+ if (color == null) {
+ color = Util.getColor(rt.getName());
+ }
+ return color;
+ }
+
+ /**
+ * Returns the Properties. If no properties exist, the element is created
+ *
+ * @return
+ */
+ public static org.eclipse.winery.model.tosca.TBoundaryDefinitions.Properties getProperties(TBoundaryDefinitions defs) {
+ org.eclipse.winery.model.tosca.TBoundaryDefinitions.Properties properties = defs.getProperties();
+ if (properties == null) {
+ properties = new org.eclipse.winery.model.tosca.TBoundaryDefinitions.Properties();
+ defs.setProperties(properties);
+ }
+ return properties;
+ }
+
+ /**
+ * Special method to get the name of an extensible element as the TOSCA
+ * specification does not have a separate super type for elements with a
+ * name
+ *
+ * {@link
+ * org.eclipse.winery.common.Util.instanceSupportsNameAttribute(Class<?
+ * extends TOSCAComponentId>)} is related
+ *
+ * @param e the extensible element offering a name attribute (besides an id
+ * attribute)
+ * @return the name of the extensible element
+ * @throws IllegalStateException if e does not offer the method "getName"
+ */
+ public static String getName(TExtensibleElements e) {
+ Method method;
+ Object res;
+ try {
+ method = e.getClass().getMethod("getName");
+ res = method.invoke(e);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ return (String) res;
+ }
+
+ /**
+ * Returns the name of the given element. If the name does not exist or is
+ * empty, the id is returned
+ *
+ * {@see getName}
+ *
+ * @return the name if there is a name field, if not, the id is returned. In
+ * case there is a Name field,
+ */
+ public static String getNameWithIdFallBack(TExtensibleElements ci) {
+ Method method;
+ String res = null;
+ try {
+ method = ci.getClass().getMethod("getName");
+ res = (String) method.invoke(ci);
+ } catch (Exception e) {
+ }
+ if (StringUtils.isEmpty(res)) {
+ try {
+ method = ci.getClass().getMethod("getId");
+ res = (String) method.invoke(ci);
+ } catch (Exception e2) {
+ throw new IllegalStateException(e2);
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Special method to set the name of an extensible element as the TOSCA
+ * specification does not have a separate super type for elements with a
+ * name
+ *
+ * @param e the extensible element offering a name attribute (besides an id
+ * attribute)
+ * @param name the new name
+ * @throws IllegalStateException if e does not offer the method "getName"
+ */
+ public static void setName(TExtensibleElements e, String name) {
+ Method method;
+ try {
+ method = e.getClass().getMethod("setName", String.class);
+ method.invoke(e, name);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ public static boolean allRequiredFieldsNonNull(WinerysPropertiesDefinition wpd) {
+ boolean valid = wpd.getNamespace() != null;
+ valid = valid && (wpd.getElementName() != null);
+ if (valid) {
+ PropertyDefinitionKVList propertyDefinitionKVList = wpd.getPropertyDefinitionKVList();
+ valid = (propertyDefinitionKVList != null);
+ if (valid) {
+ for (PropertyDefinitionKV def : propertyDefinitionKVList) {
+ valid = valid && (def.getKey() != null);
+ valid = valid && (def.getType() != null);
+ }
+ }
+ }
+ return valid;
+ }
+
+ /**
+ * @return null if no explicit left is set
+ */
+ public static String getLeft(TNodeTemplate nodeTemplate) {
+ Map<QName, String> otherAttributes = nodeTemplate.getOtherAttributes();
+ String left = otherAttributes.get(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "x"));
+ return left;
+ }
+
+ /**
+ * @return null if no explicit left is set
+ */
+ public static String getTop(TNodeTemplate nodeTemplate) {
+ Map<QName, String> otherAttributes = nodeTemplate.getOtherAttributes();
+ String top = otherAttributes.get(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "y"));
+ return top;
+ }
+
+ /**
+ * locates targetObjectRef inside a topology template
+ *
+ * @param topologyTemplate the topology template to search in
+ * @param targetObjectRef the object ref as String
+ *
+ * @return null if not found, otherwise the entity template in the topology
+ */
+ public static TEntityTemplate findNodeTemplateOrRequirementOfNodeTemplateOrCapabilityOfNodeTemplateOrRelationshipTemplate(TTopologyTemplate topologyTemplate, String targetObjectRef) {
+ // We cannot use XMLs id pointing capabilities as we work on the Java model
+ // Other option: modify the stored XML directly. This is more error prune than walking through the whole topology
+ for (TEntityTemplate t : topologyTemplate.getNodeTemplateOrRelationshipTemplate()) {
+ if (t instanceof TNodeTemplate) {
+ if (t.getId().equals(targetObjectRef)) {
+ return t;
+ }
+ TNodeTemplate nt = (TNodeTemplate) t;
+
+ Requirements requirements = nt.getRequirements();
+ if (requirements != null) {
+ for (TRequirement req : requirements.getRequirement()) {
+ if (req.getId().equals(targetObjectRef)) {
+ return req;
+ }
+ }
+ }
+
+ Capabilities capabilities = nt.getCapabilities();
+ if (capabilities != null) {
+ for (TCapability cap : capabilities.getCapability()) {
+ if (cap.getId().equals(targetObjectRef)) {
+ return cap;
+ }
+ }
+ }
+
+ } else {
+ assert (t instanceof TRelationshipTemplate);
+ if (t.getId().equals(targetObjectRef)) {
+ return t;
+ }
+ }
+ }
+
+ // no return hit inside the loop: nothing was found
+ return null;
+ }
+
+ /**
+ * Returns the id of the given element
+ *
+ * The TOSCA specification does NOT always put an id field. In the case of
+ * EntityTypes and EntityTypeImplementations, there is no id, but a name
+ * field
+ *
+ * This method abstracts from that fact.
+ */
+ public static String getId(TExtensibleElements ci) {
+ Method method;
+ Object res;
+ try {
+ method = ci.getClass().getMethod("getId");
+ res = method.invoke(ci);
+ } catch (Exception e) {
+ // If no "getId" method is there, we try "getName"
+ try {
+ method = ci.getClass().getMethod("getName");
+ res = method.invoke(ci);
+ } catch (Exception e2) {
+ throw new IllegalStateException(e2);
+ }
+ }
+ return (String) res;
+ }
+
+ /**
+ * Resolves a given id as requirement in the given ServiceTemplate
+ *
+ * @return null if not found
+ */
+ public static TRequirement resolveRequirement(TServiceTemplate serviceTemplate, String reference) {
+ TRequirement resolved = null;
+ for (TEntityTemplate tmpl : serviceTemplate.getTopologyTemplate().getNodeTemplateOrRelationshipTemplate()) {
+ if (tmpl instanceof TNodeTemplate) {
+ TNodeTemplate n = (TNodeTemplate) tmpl;
+ Requirements requirements = n.getRequirements();
+ if (requirements != null) {
+ for (TRequirement req : n.getRequirements().getRequirement()) {
+ if (req.getId().equals(reference)) {
+ resolved = req;
+ }
+ }
+ }
+ }
+ }
+ return resolved;
+ }
+
+ public static TCapability resolveCapability(TServiceTemplate serviceTemplate, String reference) {
+ TCapability resolved = null;
+ for (TEntityTemplate tmpl : serviceTemplate.getTopologyTemplate().getNodeTemplateOrRelationshipTemplate()) {
+ if (tmpl instanceof TNodeTemplate) {
+ TNodeTemplate n = (TNodeTemplate) tmpl;
+ Capabilities capabilities = n.getCapabilities();
+ if (capabilities != null) {
+ for (TCapability cap : n.getCapabilities().getCapability()) {
+ if (cap.getId().equals(reference)) {
+ resolved = cap;
+ }
+ }
+ }
+ }
+ }
+ return resolved;
+ }
+
+ public static TNodeTemplate resolveNodeTemplate(TServiceTemplate serviceTemplate, String reference) {
+ TNodeTemplate resolved = null;
+ for (TEntityTemplate tmpl : serviceTemplate.getTopologyTemplate().getNodeTemplateOrRelationshipTemplate()) {
+ if (tmpl instanceof TNodeTemplate) {
+ TNodeTemplate n = (TNodeTemplate) tmpl;
+ if (n.getId().equals(reference)) {
+ resolved = n;
+ }
+ }
+ }
+ return resolved;
+ }
+
+ public static TRelationshipTemplate resolveRelationshipTemplate(TServiceTemplate serviceTemplate, String reference) {
+ TRelationshipTemplate resolved = null;
+ for (TEntityTemplate tmpl : serviceTemplate.getTopologyTemplate().getNodeTemplateOrRelationshipTemplate()) {
+ if (tmpl instanceof TRelationshipTemplate) {
+ TRelationshipTemplate n = (TRelationshipTemplate) tmpl;
+ if (n.getId().equals(reference)) {
+ resolved = n;
+ }
+ }
+ }
+ return resolved;
+ }
+
+ public static TPlan resolvePlan(TServiceTemplate serviceTemplate, String reference) {
+ TPlan resolved = null;
+ TPlans plans = serviceTemplate.getPlans();
+ if (plans == null) {
+ return null;
+ }
+ for (TPlan p : plans.getPlan()) {
+ if (p.getId().equals(reference)) {
+ resolved = p;
+ }
+ }
+ return resolved;
+ }
+
+ /**
+ * Sets the x coordinate of a {@link TNodeTemplate}.
+ *
+ * @param nodeTemplate
+ * the nodeTemplate to be altered
+ * @param coordinate
+ * the value of the coordinate to be set
+ * @return
+ * the altered {@link TNodeTemplate}
+ */
+ public static TNodeTemplate setLeft(TNodeTemplate nodeTemplate, String coordinate) {
+
+ Map<QName, String> otherNodeTemplateAttributes = nodeTemplate.getOtherAttributes();
+ otherNodeTemplateAttributes.put(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "x"), coordinate);
+
+ return nodeTemplate;
+ }
+
+ /**
+ * Sets the y coordinate of a {@link TNodeTemplate}.
+ *
+ * @param nodeTemplate
+ * the nodeTemplate to be altered
+ * @param coordinate
+ * the value of the coordinate to be set
+ * @return
+ * the altered {@link TNodeTemplate}
+ */
+ public static TNodeTemplate setTop(TNodeTemplate nodeTemplate, String coordinate) {
+
+ Map<QName, String> otherNodeTemplateAttributes = nodeTemplate.getOtherAttributes();
+ otherNodeTemplateAttributes.put(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "y"), coordinate);
+
+ return nodeTemplate;
+
+ }
+
+ /**
+ * This method instantiates a {@link TNodeTemplate} for a given {@link TNodeType}.
+ *
+ * @param nodeType
+ * the {@link TNodeType} used for the {@link TNodeTemplate} instantiation.
+ *
+ * @return the instantiated {@link TNodeTemplate}
+ */
+ public static TNodeTemplate instantiateNodeTemplate(TNodeType nodeType) {
+
+ TNodeTemplate nodeTemplate = new TNodeTemplate();
+
+ nodeTemplate.setId(UUID.randomUUID().toString());
+ nodeTemplate.setName(nodeType.getName());
+ nodeTemplate.setType(new QName(nodeType.getTargetNamespace(), nodeType.getName()));
+
+ // add capabilities to the NodeTemplate
+ if (nodeType.getCapabilityDefinitions() != null) {
+ for (TCapabilityDefinition cd : nodeType.getCapabilityDefinitions().getCapabilityDefinition()) {
+ TCapability capa = new TCapability();
+ capa.setId(UUID.randomUUID().toString());
+ capa.setName(cd.getCapabilityType().getLocalPart());
+ capa.setType(new QName(cd.getCapabilityType().getNamespaceURI(), cd.getCapabilityType().getLocalPart()));
+ nodeTemplate.setCapabilities(new Capabilities());
+ nodeTemplate.getCapabilities().getCapability().add(capa);
+ }
+ }
+
+ // add requirements
+ if (nodeType.getRequirementDefinitions() != null && nodeType.getRequirementDefinitions().getRequirementDefinition() != null) {
+ Requirements requirementsNode = new Requirements();
+ nodeTemplate.setRequirements(requirementsNode);
+ for (TRequirementDefinition definition : nodeType.getRequirementDefinitions().getRequirementDefinition()) {
+ TRequirement newRequirement = new TRequirement();
+ newRequirement.setName(definition.getName());
+ newRequirement.setId(definition.getName());
+ newRequirement.setType(definition.getRequirementType());
+ nodeTemplate.getRequirements().getRequirement().add(newRequirement);
+ }
+ }
+
+ return nodeTemplate;
+ }
+
+ /**
+ * This method instantiates a {@link TRelationshipTemplate} for a given {@link TRelationshipType}.
+ *
+ * @param nodeType
+ * the {@link TRelationshipType} used for the {@link TRelationshipTemplate} instantiation.
+ * @param sourceNodeTemplate
+ * the source {@link TNodeTemplate} of the connection
+ * @param targetNodeTemplate
+ * the target {@link TNodeTemplate} of the connection
+ *
+ * @return the instantiated {@link TRelationshipTemplate}
+ */
+ public static TRelationshipTemplate instantiateRelationshipTemplate(TRelationshipType relationshipType, TNodeTemplate sourceNodeTemplate, TNodeTemplate targetNodeTemplate) {
+
+ TRelationshipTemplate relationshipTemplate = new TRelationshipTemplate();
+ relationshipTemplate.setId(UUID.randomUUID().toString());
+ relationshipTemplate.setName(relationshipType.getName());
+ relationshipTemplate.setType(new QName(relationshipType.getTargetNamespace(), relationshipType.getName()));
+
+ // connect the NodeTemplates
+ SourceElement source = new SourceElement();
+ source.setRef(sourceNodeTemplate);
+ relationshipTemplate.setSourceElement(source);
+ TargetElement target = new TargetElement();
+ target.setRef(targetNodeTemplate);
+ relationshipTemplate.setTargetElement(target);
+
+ return relationshipTemplate;
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/RepositoryFileReference.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/RepositoryFileReference.java
new file mode 100644
index 0000000..68fb22f
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/RepositoryFileReference.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common;
+
+import org.eclipse.winery.common.ids.GenericId;
+
+/**
+ * Holds a reference to a file "object" stored in the repository
+ *
+ * Directories are NOT supported as we would have to reflect parent
+ * relationships there, too.
+ *
+ * One has to create TOSCAelementId-objects for directories (e.g., scc-data)
+ */
+public class RepositoryFileReference implements Comparable<RepositoryFileReference> {
+
+ protected final GenericId parent;
+ protected final String fileName;
+
+
+ /**
+ * @param parent the id of the toscaElement the file is nested in
+ * @param fileName the file name. <em>Must not</em> contain any illegal
+ * characters. java.nio.Path cannot be used as Path is tied to a
+ * FileSystem
+ */
+ public RepositoryFileReference(GenericId parent, String fileName) {
+ if (parent == null) {
+ throw new IllegalArgumentException("Parent must not be null.");
+ }
+ if (fileName == null) {
+ throw new IllegalArgumentException("Filename must not be null.");
+ }
+ this.parent = parent;
+ this.fileName = fileName;
+ }
+
+ public GenericId getParent() {
+ return this.parent;
+ }
+
+ public String getFileName() {
+ return this.fileName;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof RepositoryFileReference) {
+ RepositoryFileReference otherRef = (RepositoryFileReference) obj;
+ return (otherRef.fileName.equals(this.fileName)) && (otherRef.getParent().equals(this.getParent()));
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return this.getParent().hashCode() ^ this.getFileName().hashCode();
+ }
+
+ @Override
+ public int compareTo(RepositoryFileReference o) {
+ int res;
+ res = this.parent.compareTo(o.parent);
+ if (res == 0) {
+ res = this.fileName.compareTo(o.fileName);
+ }
+ return res;
+ }
+
+ @Override
+ public String toString() {
+ return this.getParent().toString() + "/" + this.getFileName();
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/StringEncodedAndDecoded.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/StringEncodedAndDecoded.java
new file mode 100644
index 0000000..cac7a44
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/StringEncodedAndDecoded.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common;
+
+
+
+/**
+ * Meta class to handle things, where a String (URI, NCName, ...) may be
+ * URLencoded
+ */
+public class StringEncodedAndDecoded implements Comparable<StringEncodedAndDecoded> {
+
+ private String decoded = null;
+ private String encoded = null;
+
+
+ /**
+ * @param uri the URI to store
+ * @param URLencoded true iff the given URI is URLencoded
+ */
+ public StringEncodedAndDecoded(String uri, boolean URLencoded) {
+ if (URLencoded) {
+ this.encoded = uri;
+ } else {
+ this.decoded = uri;
+ }
+ }
+
+ public String getDecoded() {
+ if (this.decoded == null) {
+ this.decoded = Util.URLdecode(this.encoded);
+ }
+ return this.decoded;
+ }
+
+ public String getEncoded() {
+ if (this.encoded == null) {
+ this.encoded = Util.URLencode(this.decoded);
+ }
+ return this.encoded;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.getDecoded().hashCode();
+ }
+
+ /**
+ * @return the URL path fragment to be used in an URL
+ */
+ public String getPathFragment() {
+ return this.getEncoded();
+ }
+
+ @Override
+ public String toString() {
+ return this.getDecoded();
+ }
+
+ @Override
+ public int compareTo(StringEncodedAndDecoded o) {
+ return this.getDecoded().compareTo(o.getDecoded());
+ }
+
+ /**
+ * Compares with the given object <br />
+ * Equality checking is made based on the decoded String
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof String) {
+ return this.getDecoded().equals(o);
+ } else if (o instanceof StringEncodedAndDecoded) {
+ return ((StringEncodedAndDecoded) o).getDecoded().equals(this.getDecoded());
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/TOSCADocumentBuilderFactory.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/TOSCADocumentBuilderFactory.java
new file mode 100644
index 0000000..74a0e26
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/TOSCADocumentBuilderFactory.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common;
+
+import java.net.URL;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
+
+/**
+ * Class to produce DocumentBuilders with a pre-loaded TOSCA XSD.
+ *
+ * In a separate class as TOSCA XSD loading takes a few seconds
+ */
+public class TOSCADocumentBuilderFactory {
+
+ private static final Logger logger = LoggerFactory.getLogger(TOSCADocumentBuilderFactory.class);
+
+ public static final TOSCADocumentBuilderFactory INSTANCE = new TOSCADocumentBuilderFactory();
+ private final DocumentBuilderFactory factory;
+
+
+ public TOSCADocumentBuilderFactory() {
+ this.factory = DocumentBuilderFactory.newInstance();
+
+ this.factory.setNamespaceAware(true);
+
+ // we do not need DTD validation
+ this.factory.setValidating(false);
+
+ // we do XSD validation
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema;
+ URL resource = this.getClass().getResource("/TOSCA-v1.0.xsd");
+ try {
+ // takes a few seconds to load
+ schema = schemaFactory.newSchema(resource);
+ this.factory.setSchema(schema);
+ } catch (SAXException e) {
+ // TODO: load xml.xsd in offline mode
+ TOSCADocumentBuilderFactory.logger.error("Schema could not be initalized", e);
+ TOSCADocumentBuilderFactory.logger.debug("We continue nevertheless to enable offline usage");
+ }
+ }
+
+ public DocumentBuilder getTOSCADocumentBuilder() {
+ DocumentBuilder db;
+ try {
+ db = this.factory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw new IllegalStateException("document builder could not be initalized", e);
+ }
+ return db;
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/Util.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/Util.java
new file mode 100644
index 0000000..702bf41
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/Util.java
@@ -0,0 +1,603 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchema;
+import javax.xml.namespace.QName;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.taglibs.standard.functions.Functions;
+import org.eclipse.winery.common.ids.GenericId;
+import org.eclipse.winery.common.ids.definitions.ArtifactTemplateId;
+import org.eclipse.winery.common.ids.definitions.EntityTemplateId;
+import org.eclipse.winery.common.ids.definitions.EntityTypeId;
+import org.eclipse.winery.common.ids.definitions.EntityTypeImplementationId;
+import org.eclipse.winery.common.ids.definitions.PolicyTemplateId;
+import org.eclipse.winery.common.ids.definitions.ServiceTemplateId;
+import org.eclipse.winery.common.ids.definitions.TOSCAComponentId;
+import org.eclipse.winery.common.ids.definitions.imports.GenericImportId;
+import org.eclipse.winery.common.ids.definitions.imports.XSDImportId;
+import org.eclipse.winery.common.ids.elements.TOSCAElementId;
+import org.eclipse.winery.model.tosca.TEntityType;
+import org.eclipse.winery.model.tosca.TExtensibleElements;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
+public class Util {
+
+ private static final Logger logger = LoggerFactory.getLogger(Util.class);
+
+ public static final String FORBIDDEN_CHARACTER_REPLACEMENT = "_";
+
+
+ public static String URLdecode(String s) {
+ try {
+ return URLDecoder.decode(s, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException();
+ }
+ }
+
+ public static String URLencode(String s) {
+ try {
+ return URLEncoder.encode(s, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException();
+ }
+ }
+
+ public static String DoubleURLencode(String s) {
+ return Util.URLencode(Util.URLencode(s));
+ }
+
+ /**
+ * Encodes the namespace and the localname of the given qname, separated by
+ * "/"
+ *
+ * @return <double encoded namespace>"/"<double encoded localname>
+ */
+ public static String DoubleURLencode(QName qname) {
+ String ns = Util.DoubleURLencode(qname.getNamespaceURI());
+ String localName = Util.DoubleURLencode(qname.getLocalPart());
+ return ns + "/" + localName;
+ }
+
+ public static boolean isRelativeURI(String uri) {
+ URI u;
+ try {
+ u = new URI(uri);
+ } catch (URISyntaxException e) {
+ Util.logger.debug(e.getMessage(), e);
+ // fallback
+ return false;
+ }
+ return !u.isAbsolute();
+ }
+
+ /**
+ * @param c the element directly nested below a definitions element in XML
+ */
+ public static String getURLpathFragmentForCollection(Class<? extends TExtensibleElements> c) {
+ String res = c.getName().toLowerCase();
+ int lastDot = res.lastIndexOf('.');
+ // classname is something like <package>.T<type>. We are only interested
+ // in "<type>". Therefore "+2" from the dot onwards
+ res = res.substring(lastDot + 2);
+ res = res + "s";
+ return res;
+ }
+
+ public static String getEverythingBetweenTheLastDotAndBeforeId(Class<? extends GenericId> cls) {
+ String res = cls.getName();
+ // Everything between the last "." and before "Id" is the Type
+ int dotIndex = res.lastIndexOf('.');
+ assert (dotIndex >= 0);
+ return res.substring(dotIndex + 1, res.length() - "Id".length());
+ }
+
+ public static String getTypeForElementId(Class<? extends TOSCAElementId> idClass) {
+ return Util.getEverythingBetweenTheLastDotAndBeforeId(idClass);
+ }
+
+ /**
+ * @return Singular type name for the given id. E.g., "ServiceTemplateId"
+ * gets "ServiceTemplate"
+ */
+ public static String getTypeForComponentId(Class<? extends TOSCAComponentId> idClass) {
+ return Util.getEverythingBetweenTheLastDotAndBeforeId(idClass);
+ }
+
+ /**
+ * Returns the root path fragment for the given
+ * AbstractComponentIntanceResource
+ *
+ * With trailing slash
+ *
+ * @return [ComponentName]s/
+ */
+ public static String getRootPathFragment(Class<? extends TOSCAComponentId> idClass) {
+ // quick handling of imports special case
+ // in the package naming, all other component instances have a this intermediate location, but not in the URLs
+ // The package handling is in {@link org.eclipse.winery.repository.Utils.getIntermediateLocationStringForType(String, String)}
+ String res;
+ if (GenericImportId.class.isAssignableFrom(idClass)) {
+ // this fires if idClass is a sub class from ImportCollectionId
+ // special treatment for imports
+ res = "imports/";
+ if (XSDImportId.class.isAssignableFrom(idClass)) {
+ res = res + "http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema/";
+ } else {
+ throw new IllegalStateException("Not possible to determine local storage for generic imports class");
+ }
+ // we have the complete root path fragment
+ return res;
+ } else {
+ res = "";
+ }
+ res = res + Util.getTypeForComponentId(idClass);
+ res = res.toLowerCase();
+ res = res + "s";
+ res = res + "/";
+ return res;
+ }
+
+ /**
+ * Just calls @link{qname2href}
+ *
+ * Introduced because of JSP error
+ * "The method qname2href(String, Class<? extends TExtensibleElements>, QName) in the type Util is not applicable for the arguments (String, Class<TNodeType>, QName, String)"
+ */
+ public static String qname2hrefWithName(String repositoryUrl, Class<? extends TExtensibleElements> element, QName qname, String name) {
+ return Util.qname2href(repositoryUrl, element, qname, name);
+ }
+
+ /**
+ *
+ * @param repositoryUrl the URL to the repository
+ * @param element the element directly nested below a definitions element in
+ * XML
+ * @param qname the QName of the element
+ * @param name (optional) if not null, the name to display as text in the
+ * reference. Default: localName of the QName
+ * @return an <code>a</code> HTML element pointing to the given id
+ */
+ public static String qname2href(String repositoryUrl, Class<? extends TExtensibleElements> element, QName qname, String name) {
+ if (StringUtils.isEmpty(repositoryUrl)) {
+ throw new IllegalArgumentException("Repository URL must not be empty.");
+ }
+ if (element == null) {
+ throw new IllegalArgumentException("Element class must not be null.");
+ }
+ if (qname == null) {
+ return "(none)";
+ }
+
+ String absoluteURL = repositoryUrl + "/" + Util.getURLpathFragmentForCollection(element) + "/" + Util.DoubleURLencode(qname.getNamespaceURI()) + "/" + Util.DoubleURLencode(qname.getLocalPart());
+
+ if (name == null) {
+ // fallback if no name is given
+ name = qname.getLocalPart();
+ }
+ // sanitize name
+ name = Functions.escapeXml(name);
+
+ String res = "<a target=\"_blank\" data-qname=\"" + qname + "\" href=\"" + absoluteURL + "\">" + name + "</a>";
+ return res;
+ }
+
+ /**
+ *
+ * @param repositoryUrl the URL to the repository
+ * @param element the element directly nested below a definitions element in
+ * XML
+ * @param qname the QName of the element
+ * @return an <code>a</code> HTML element pointing to the given id
+ */
+ public static String qname2href(String repositoryUrl, Class<? extends TExtensibleElements> element, QName qname) {
+ return Util.qname2href(repositoryUrl, element, qname, null);
+ }
+
+ /**
+ * Returns a visual rendering of minInstances
+ *
+ * @param minInstances the value to render
+ */
+ public static String renderMinInstances(Integer minInstances) {
+ if ((minInstances == null) || (minInstances == 1)) {
+ // == null: default value: display nothing -- *never* happens:
+ // the function *always* returns 1 even, if no explicit value is set. Therefore, we also display "" if the default value 1 is set
+ return "";
+ } else {
+ return Integer.toString(minInstances);
+ }
+ }
+
+ /**
+ * Returns a visual rendering of maxInstances
+ *
+ * @param maxInstances the value to render
+ */
+ public static String renderMaxInstances(String maxInstances) {
+ if ((maxInstances == null) || (maxInstances.equals("1"))) {
+ // default value display nothing
+ // "1" is returned even if no explicit value has been set.
+ return "";
+ } else if (maxInstances.equals("unbounded")) {
+ return "&infin;";
+ } else {
+ // maxInstance is a plain integer
+ // return as is
+ return maxInstances;
+ }
+ }
+
+ /**
+ * @return the local name of a Class representing a TOSCA element
+ */
+ private static String getLocalName(@SuppressWarnings("rawtypes") Class clazz) {
+ String localName = clazz.getName();
+ // a class defined within another class is written as superclass$class. E.g., EntityTemplate$Properties
+ // We use the real class name
+ int pos = localName.lastIndexOf('$');
+ if (pos == -1) {
+ pos = localName.lastIndexOf('.');
+ }
+ localName = localName.substring(pos + 1);
+ if (localName.equals("TDocumentation")) {
+ // special case for documentation: the local name starts with a lower case letter
+ localName = "documentation";
+ } else if (localName.startsWith("T")) {
+ localName = localName.substring(1);
+ }
+ return localName;
+ }
+
+ public static <T extends Object> JAXBElement<T> getJAXBElement(Class<T> clazz, T obj) {
+ String namespace = null;
+ XmlRootElement xmlRootElement = clazz.getAnnotation(XmlRootElement.class);
+ if (xmlRootElement != null) {
+ namespace = xmlRootElement.namespace();
+ if ("##default".equals(namespace)) {
+ XmlSchema xmlSchema = clazz.getPackage().getAnnotation(XmlSchema.class);
+ if (xmlSchema != null) {
+ namespace = xmlSchema.namespace();
+ } else {
+ // trigger default handling
+ namespace = null;
+ }
+ }
+ }
+ if (namespace == null) {
+ // fallback non-specified namespaces
+ namespace = org.eclipse.winery.common.constants.Namespaces.TOSCA_NAMESPACE;
+ }
+ String localName = Util.getLocalName(clazz);
+ QName qname = new QName(namespace, localName);
+ JAXBElement<T> rootElement = new JAXBElement<T>(qname, clazz, obj);
+ return rootElement;
+ }
+
+ /**
+ * Method similar to {@link
+ * org.eclipse.winery.repository.Utils.getXMLAsString(Class, Object)}.
+ *
+ * Differences:
+ * <ul>
+ * <li>XML processing instruction is not included in the header</li>
+ * <li>JAXBcontext is created at each call</li>
+ * </ul>
+ */
+ public static <T extends Object> String getXMLAsString(Class<T> clazz, T obj) throws Exception {
+ // copied from Utils java, but we create an own JAXBcontext here
+ // JAXBSupport cannot be used as this relies on a MockElement, which we do not want to factor out to winery.common
+
+ JAXBContext context;
+ try {
+ // For winery classes, eventually the package+jaxb.index method could be better. See http://stackoverflow.com/a/3628525/873282
+ // @formatter:off
+ context = JAXBContext.newInstance(
+ TEntityType.class);
+ // @formatter:on
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
+
+ JAXBElement<T> rootElement = Util.getJAXBElement(clazz, obj);
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ m.setProperty(Marshaller.JAXB_FRAGMENT, true);
+ // m.setProperty("com.sun.xml.bind.namespacePrefixMapper", JAXBSupport.prefixMapper);
+
+ StringWriter w = new StringWriter();
+ try {
+ m.marshal(rootElement, w);
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
+ String res = w.toString();
+ return res;
+ }
+
+ public static String getXMLAsString(Element el) {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer t;
+ try {
+ t = tf.newTransformer();
+ } catch (TransformerConfigurationException e) {
+ throw new IllegalStateException("Could not instantiate Transformer", e);
+ }
+ t.setOutputProperty(OutputKeys.INDENT, "yes");
+ Source source = new DOMSource(el);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ Result target = new StreamResult(os);
+ try {
+ t.transform(source, target);
+ } catch (TransformerException e) {
+ Util.logger.debug(e.getMessage(), e);
+ throw new IllegalStateException("Could not transform dom node to string", e);
+ }
+ return os.toString();
+ }
+
+ /**
+ * Determines whether the instance belonging to the given id supports the
+ * "name" attribute. This cannot be done using the super class as the TOSCA
+ * specification treats that differently in the case of EntityTemplates
+ *
+ * NOTE: The respective subclasses of AbstractComponentInstanceResource have
+ * to implement {@link org.eclipse.winery.repository.resources.IHasName}
+ *
+ * @param id the id to test
+ * @return true if the TOSCA model class belonging to the given id supports
+ * the method "getName()" in addition to "getId()"
+ */
+ public static boolean instanceSupportsNameAttribute(Class<? extends TOSCAComponentId> idClass) {
+ if (ServiceTemplateId.class.isAssignableFrom(idClass)) {
+ return true;
+ } else if ((EntityTypeId.class.isAssignableFrom(idClass)) || (EntityTypeImplementationId.class.isAssignableFrom(idClass))) {
+ // name is available, but no id attribute
+ return false;
+ } else if (GenericImportId.class.isAssignableFrom(idClass)) {
+ return false;
+ } else {
+ assert (EntityTemplateId.class.isAssignableFrom(idClass));
+ if (ArtifactTemplateId.class.isAssignableFrom(idClass)) {
+ return true;
+ } else if (PolicyTemplateId.class.isAssignableFrom(idClass)) {
+ return true;
+ } else {
+ throw new IllegalStateException("Unimplemented branch to determine if getName() exists");
+ }
+ }
+ }
+
+ public static String getLastURIPart(String loc) {
+ int posSlash = loc.lastIndexOf('/');
+ String fileName = loc.substring(posSlash + 1);
+ return fileName;
+ }
+
+ /**
+ * Determines a color belonging to the given name
+ */
+ public static String getColor(String name) {
+ int hash = name.hashCode();
+ // trim to 3*8=24 bits
+ hash = hash & 0xFFFFFF;
+ // check if color is more than #F0F0F0, i.e., too light
+ if (((hash & 0xF00000) >= 0xF00000) && (((hash & 0x00F000) >= 0x00F000) && ((hash & 0x0000F0) >= 0x0000F0))) {
+ // set one high bit to zero for each channel. That makes the overall color darker
+ hash = hash & 0xEFEFEF;
+ }
+ String colorStr = String.format("#%06x", hash);
+ return colorStr;
+ }
+
+ /**
+ * Determines the name of the CSS class used for relationshipTypes at
+ * nodeTemplateRenderer.tag
+ */
+ public static String makeCSSName(String namespace, String localName) {
+ // according to http://stackoverflow.com/a/79022/873282 everything is allowed
+ // However, {namespace}id does NOT work
+ String res = namespace + "_" + localName;
+ res = res.replaceAll("[^\\w\\d_]", "_");
+ return res;
+ }
+
+ /**
+ * @see {@link org.eclipse.winery.common.Util.makeCSSName(String, String)}
+ */
+ public static String makeCSSName(QName qname) {
+ return Util.makeCSSName(qname.getNamespaceURI(), qname.getLocalPart());
+ }
+
+ public static SortedMap<String, SortedSet<String>> convertQNameListToNamespaceToLocalNameList(List<QName> list) {
+ SortedMap<String, SortedSet<String>> res = new TreeMap<>();
+ for (QName qname : list) {
+ SortedSet<String> localNameSet = res.get(qname.getNamespaceURI());
+ if (localNameSet == null) {
+ localNameSet = new TreeSet<>();
+ res.put(qname.getNamespaceURI(), localNameSet);
+ }
+ localNameSet.add(qname.getLocalPart());
+ }
+ return res;
+ }
+
+ public static String namespaceToJavaPackage(String namespace) {
+ URI uri;
+ try {
+ uri = new URI(namespace);
+ } catch (URISyntaxException e) {
+ Util.logger.debug(e.getMessage(), e);
+ return "uri.invalid";
+ }
+ StringBuilder sb = new StringBuilder();
+
+ String host = uri.getHost();
+ if (host != null) {
+ Util.addReversed(sb, host, "\\.");
+ }
+
+ String path = uri.getPath();
+ if (!path.equals("")) {
+ if (path.startsWith("/")) {
+ // remove first slash
+ path = path.substring(1);
+ }
+
+ // and then handle the string
+ Util.addAsIs(sb, path, "/");
+ }
+
+ // remove the final dot
+ sb.replace(sb.length() - 1, sb.length(), "");
+
+ return Util.cleanName(sb.toString());
+ }
+
+ private static String cleanName(String s) {
+ // TODO: Integrate with other name cleaning functions. "." should not be replaced as it is used as separator in the java package name
+ // @formatter:off
+ return s.replace(":", Util.FORBIDDEN_CHARACTER_REPLACEMENT)
+ .replace("/", Util.FORBIDDEN_CHARACTER_REPLACEMENT)
+ .replace(" ", Util.FORBIDDEN_CHARACTER_REPLACEMENT)
+ .replace("-", Util.FORBIDDEN_CHARACTER_REPLACEMENT);
+ // @formatter:on
+ }
+
+
+ /*
+ * Valid chars: See
+ * <ul>
+ * <li>http://www.w3.org/TR/REC-xml-names/#NT-NCName</li>
+ * <li>http://www.w3.org/TR/REC-xml/#NT-Name</li>
+ * </ul>
+ */
+ // NameCharRange \u10000-\ueffff is not supported by Java
+ private static final String NCNameStartChar_RegExp = "[A-Z_a-z\u00c0-\u00d6\u00d8\u00f6\u00f8\u02ff\u0370\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]";
+ private static final String NCNameChar_RegExp = Util.NCNameStartChar_RegExp + "|[-\\.0-9\u00B7\u0300-\u036F\u203F-\u2040]";
+ private static final Pattern NCNameStartChar_Pattern = Pattern.compile(Util.NCNameStartChar_RegExp);
+ private static final Pattern NCNameChar_RegExp_Pattern = Pattern.compile(Util.NCNameChar_RegExp);
+
+
+ /**
+ * Removes all non-NCName characters from the given string and returns the
+ * result
+ *
+ * This function should be consistent with
+ * org.eclipse.winery.common.Util.cleanName(String)
+ *
+ * TODO: This method seems to be equal to {@link
+ * org.eclipse.winery.repository.Utils.createXMLidAsString(String)}. These
+ * methods should be merged.
+ *
+ */
+ public static String makeNCName(String text) {
+ if (StringUtils.isEmpty(text)) {
+ return text;
+ }
+
+ StringBuffer res = new StringBuffer();
+
+ // handle start
+ String start = text.substring(0, 1);
+ Matcher m = Util.NCNameStartChar_Pattern.matcher(start);
+ if (m.matches()) {
+ res.append(start);
+ } else {
+ // not a valid character
+ res.append("_");
+ }
+
+ // handle remaining characters;
+ for (int i = 1; i < text.length(); i++) {
+ String s = text.substring(i, i + 1);
+ m = Util.NCNameChar_RegExp_Pattern.matcher(s);
+ if (m.matches()) {
+ res.append(s);
+ } else {
+ // not a valid character
+ res.append("_");
+ }
+ }
+
+ return res.toString();
+ }
+
+ private static void addAsIs(StringBuilder sb, String s, String separator) {
+ if (s.isEmpty()) {
+ return;
+ }
+ String[] split = s.split(separator);
+ for (int i = 0; i < split.length; i++) {
+ sb.append(split[i]);
+ sb.append(".");
+ }
+ }
+
+ private static void addReversed(StringBuilder sb, String s, String separator) {
+ String[] split = s.split(separator);
+ for (int i = split.length - 1; i >= 0; i--) {
+ sb.append(split[i]);
+ sb.append(".");
+ }
+ }
+
+ /**
+ * Bridge to client.getType(). Just calls client getType(), used by
+ * functions.tld.
+ *
+ * We suppress compiler warnings as JSP 2.0 do not offer support for
+ * generics, but we're using JSP 2.0...
+ *
+ * @param client the repository client to use
+ * @param qname the QName to resolve
+ * @param clazz the class the QName is describing
+ * @return {@inheritDoc}
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static org.eclipse.winery.model.tosca.TEntityType getType(org.eclipse.winery.common.interfaces.IWineryRepository client, javax.xml.namespace.QName qname, java.lang.Class clazz) {
+ return client.getType(qname, clazz);
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/beans/NamespaceIdOptionalName.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/beans/NamespaceIdOptionalName.java
new file mode 100644
index 0000000..872cb04
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/beans/NamespaceIdOptionalName.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.beans;
+
+/**
+ * Bean containing
+ * <ul>
+ * <li>namespace</li>
+ * <li>id</li>
+ * <li>name</li>
+ * </ul>
+ * The name field is optional
+ */
+public class NamespaceIdOptionalName {
+
+ private String namespace;
+ private String id;
+ private String name = null;
+
+
+ public NamespaceIdOptionalName() {
+
+ }
+
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+} \ No newline at end of file
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/Defaults.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/Defaults.java
new file mode 100644
index 0000000..a3e1368
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/Defaults.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.constants;
+
+public class Defaults {
+
+ public static final String DEFAULT_RT_HOVER_COLOR = "black";
+
+ // files are in src/main/webapp/images/relationshiptype
+ // convention: below the prefix, then the filename is either ...Left.png or ...Right.png
+ public static final String DEFAULT_RT_ARROWHEAD_SOURCE = "none";
+ public static final String DEFAULT_RT_ARROWHEAD_TARGET = "PlainArrow";
+
+ public static final String DEFAULT_RT_DASH = "plain";
+ public static final String DEFAULT_RT_LINEWIDTH = "1";
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/MimeTypes.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/MimeTypes.java
new file mode 100644
index 0000000..f79593c
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/MimeTypes.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.constants;
+
+/**
+ * See also {@link org.eclipse.winery.repository.backend.constants.MediaTypes}
+ */
+public class MimeTypes {
+
+ public static final String MIMETYPE_TOSCA_DEFINITIONS = "application/vnd.oasis.tosca.definitions";
+
+ // text/xsd is NOT used for XSD as text/xml is rendered correctly in browsers
+ public static final String MIMETYPE_XSD = "text/xml";
+
+ public static final String MIMETYPE_ZIP = "application/zip";
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/Namespaces.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/Namespaces.java
new file mode 100644
index 0000000..897aa69
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/Namespaces.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013-2014 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.constants;
+
+/**
+ * Defines namespace constants not available in Java7's XMLConstants
+ */
+public class Namespaces {
+
+ public static final String TOSCA_NAMESPACE = "http://docs.oasis-open.org/tosca/ns/2011/12";
+ public static final String TOSCA_WINERY_EXTENSIONS_NAMESPACE = "http://www.opentosca.org/winery/extensions/tosca/2013/02/12";
+
+ // XML Schema namespace is defined at Java7's XMLConstants.W3C_XML_SCHEMA_NS_URI
+
+ public static final String URI_BPMN20_MODEL = "http://www.omg.org/spec/BPMN/20100524/MODEL";
+ public static final String URI_BPMN4TOSCA_20 = "http://www.opentosca.org/bpmn4tosca";
+ public static final String URI_BPEL20_ABSTRACT = "http://docs.oasis-open.org/wsbpel/2.0/process/abstract";
+ public static final String URI_BPEL20_EXECUTABLE = "http://docs.oasis-open.org/wsbpel/2.0/process/executable";
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/QNames.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/QNames.java
new file mode 100644
index 0000000..dcc5de0
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/constants/QNames.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.constants;
+
+import javax.xml.namespace.QName;
+
+public class QNames {
+
+ public static final QName QNAME_BORDER_COLOR = new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "bordercolor");
+ public static final QName QNAME_COLOR = new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "color");
+
+ // Boolean flag to indicate that the import is generated via the Winery Properties Defintion
+ public static final QName QNAME_WINERYS_PROPERTIES_DEFINITION_ATTRIBUTE = new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "wpd");
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/GenericId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/GenericId.java
new file mode 100644
index 0000000..756137e
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/GenericId.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids;
+
+/**
+ * Superclass for all IDs appearing in Winery. These are:
+ * <ul>
+ * <li>All IDs of elements directly nested in a Definitions element</li>
+ * <li>Subelements of those</li>
+ * </ul>
+ *
+ * We assume that TOSCAcomponentId is always the root node of nested IDs
+ *
+ */
+public abstract class GenericId implements Comparable<GenericId> {
+
+ private final XMLId xmlId;
+
+
+ protected GenericId(XMLId xmlId) {
+ this.xmlId = xmlId;
+ }
+
+ /**
+ * @return null if (this instanceof TOSCAcomponentId). In that case, the
+ * element is already the root element
+ */
+ public abstract GenericId getParent();
+
+ /**
+ * @return the XML id of this thing
+ */
+ public XMLId getXmlId() {
+ return this.xmlId;
+ }
+
+ @Override
+ public abstract boolean equals(Object obj);
+
+ @Override
+ public abstract int hashCode();
+
+ @Override
+ public String toString() {
+ return this.getClass().toString() + " / " + this.getXmlId().toString();
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/IdNames.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/IdNames.java
new file mode 100644
index 0000000..fb1af16
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/IdNames.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids;
+
+/**
+ * The names of ids, used to set XMLids for collections of things
+ */
+public class IdNames {
+
+ public static final String DEPLOYMENTARTIFACTS = "deploymentartifacts";
+ public static final String INSTANCESTATES = "instancestates";
+ public static final String INTERFACES = "interfaces"; // used at node type
+ public static final String INPUTPARAMETERS = "inputParameters";
+ public static final String IMPLEMENTATIONARTIFACTS = "implementationartifacts";
+ public static final String NODETEMPLATES = "nodetemplates";
+ public static final String OUTPUTPARAMETERS = "outputParameters";
+ public static final String PROPERTIES = "properties";
+ public static final String RELATIONSHIPTEMPLATES = "relationshiptemplates";
+ public static final String SOURCEINTERFACES = "sourceinterfaces";
+ public static final String TARGETINTERFACES = "targetinterfaces";
+ public static final String TOPOLOGYTEMPATE = "topologytemplate";
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/IdUtil.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/IdUtil.java
new file mode 100644
index 0000000..90970f1
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/IdUtil.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids;
+
+import org.eclipse.winery.common.Util;
+import org.eclipse.winery.common.ids.definitions.TOSCAComponentId;
+import org.eclipse.winery.common.ids.elements.TOSCAElementId;
+
+/**
+ * Helper methods for Winery's Id system
+ */
+public class IdUtil {
+
+ /**
+ * Returns the namespace where the given Id is nested in. As the id is not a
+ * TOSCAComponentId, it cannot be directly asked for its parent. Merely, the
+ * parent has to be asked for its namespace. The parent, in turn, if it is
+ * no TOSCAComponentId has to ask his parent.
+ *
+ * @param id the id refering to an element, where the namespace has to be
+ * checked for
+ * @return the namespace of the element denoted by id
+ */
+ public static Namespace getNamespace(GenericId id) {
+ if (id instanceof TOSCAComponentId) {
+ return ((TOSCAComponentId) id).getNamespace();
+ } else {
+ return IdUtil.getNamespace(id.getParent());
+ }
+ }
+
+ /**
+ * Executes the real conversion to a path fragment
+ *
+ * @param id the id to transform to a path
+ * @param doubleEncode true if each sub fragment should be double encoded,
+ * false if it should be encoded only once
+ * @return
+ */
+ private static String getPathFragment(final GenericId id, final boolean doubleEncode) {
+ String toInsert;
+ if (id instanceof TOSCAComponentId) {
+ // @return "[ComponentName]s/{namespace}/{id}/"
+ TOSCAComponentId tId = (TOSCAComponentId) id;
+ String res = Util.getRootPathFragment(tId.getClass());
+ toInsert = tId.getNamespace().getEncoded();
+ if (doubleEncode) {
+ toInsert = Util.URLencode(toInsert);
+ }
+ res = res + toInsert + "/";
+ toInsert = tId.getXmlId().getEncoded();
+ if (doubleEncode) {
+ toInsert = Util.URLencode(toInsert);
+ }
+ res = res + toInsert + "/";
+ return res;
+ } else if (id instanceof TOSCAElementId) {
+ toInsert = id.getXmlId().getEncoded();
+ if (doubleEncode) {
+ toInsert = Util.URLencode(toInsert);
+ }
+ return IdUtil.getPathFragment(id.getParent()) + toInsert + "/";
+ } else {
+ throw new IllegalStateException("Unknown subclass of GenericId " + id.getClass());
+ }
+ }
+
+ /**
+ * Returns the fragment of the path belonging to the id
+ *
+ * For instance, an Id of type ServiceTemplateId has
+ * <code>servicetemplates/{encoded ns}/{encoded name}/</code>
+ *
+ * @param id the element to return the path fragment for
+ * @return the path fragment. This is <em>not</em> intended to be used
+ * inside a URL
+ */
+ public static String getPathFragment(GenericId id) {
+ return IdUtil.getPathFragment(id, false);
+ }
+
+ /**
+ * Returns the fragment of the URL path belonging to the id
+ *
+ * For instance, an Id of type ServiceTemplateId has
+ * <code>servicetemplates/{double encoded ns}/{double encoded name}/</encode>
+ *
+ * @param id the element to return the path fragment for
+ * @return the path fragment to be used inside an URL
+ */
+ public static String getURLPathFragment(GenericId id) {
+ return IdUtil.getPathFragment(id, true);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/Namespace.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/Namespace.java
new file mode 100644
index 0000000..a848c14
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/Namespace.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013,2015 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.winery.common.StringEncodedAndDecoded;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Namespace extends StringEncodedAndDecoded {
+
+ private static final Logger logger = LoggerFactory.getLogger(Namespace.class);
+
+
+ public Namespace(String uri, boolean URLencoded) {
+ super(uri, URLencoded);
+ if (StringUtils.isEmpty(uri)) {
+ Namespace.logger.error("Empty URI has been passed to Namespace constructor.");
+ // throw new IllegalArgumentException("uri must not be empty or null.");
+ }
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/XMLId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/XMLId.java
new file mode 100644
index 0000000..67bfb9f
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/XMLId.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids;
+
+import org.eclipse.winery.common.StringEncodedAndDecoded;
+
+/**
+ * Handles an ID given in the XML
+ *
+ * We need to have this class as IDs are also passed at URIs at requests. To
+ * ease handling, we use StringEncodedAndDecoded
+ *
+ * There is no check for valid XMLids (AKA allowed NCname characters). This is
+ * OK as, for instance, properties make use of this fact and store the name as
+ * ID
+ */
+public class XMLId extends StringEncodedAndDecoded {
+
+ public XMLId(String id, boolean URLencoded) {
+ super(id, URLencoded);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ArtifactTemplateId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ArtifactTemplateId.java
new file mode 100644
index 0000000..d74c986
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ArtifactTemplateId.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public class ArtifactTemplateId extends EntityTemplateId {
+
+ public ArtifactTemplateId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public ArtifactTemplateId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public ArtifactTemplateId(QName qname) {
+ super(qname);
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ArtifactTypeId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ArtifactTypeId.java
new file mode 100644
index 0000000..80de6a9
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ArtifactTypeId.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public class ArtifactTypeId extends EntityTypeId {
+
+ public ArtifactTypeId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public ArtifactTypeId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public ArtifactTypeId(QName qname) {
+ this(new Namespace(qname.getNamespaceURI(), false), new XMLId(qname.getLocalPart(), false));
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/CapabilityTypeId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/CapabilityTypeId.java
new file mode 100644
index 0000000..18268c9
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/CapabilityTypeId.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class CapabilityTypeId extends EntityTypeId {
+
+ public CapabilityTypeId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public CapabilityTypeId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public CapabilityTypeId(QName qname) {
+ super(qname);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTemplateId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTemplateId.java
new file mode 100644
index 0000000..16995b2
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTemplateId.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+import org.eclipse.winery.common.ids.elements.TOSCAElementId;
+
+/**
+ * ArtifactTemplates, PolicyTemplates, and ServiceTemplates are
+ * <em>directly nested</em> in a Definitions element. RelationshipTemplates and
+ * NodeTemplates are not. When approaching an EntityTemplateId, it is a thing
+ * directly nested in a Definitions element.
+ *
+ * The others have {@link TOSCAElementId} as parent
+ */
+public abstract class EntityTemplateId extends TOSCAComponentId {
+
+ public EntityTemplateId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public EntityTemplateId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public EntityTemplateId(QName qname) {
+ super(qname);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTypeId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTypeId.java
new file mode 100644
index 0000000..6378baf
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTypeId.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public abstract class EntityTypeId extends TOSCAComponentId {
+
+ public EntityTypeId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public EntityTypeId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public EntityTypeId(QName type) {
+ super(type);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTypeImplementationId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTypeImplementationId.java
new file mode 100644
index 0000000..cc10800
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/EntityTypeImplementationId.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public abstract class EntityTypeImplementationId extends TOSCAComponentId {
+
+ public EntityTypeImplementationId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public EntityTypeImplementationId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/NodeTypeId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/NodeTypeId.java
new file mode 100644
index 0000000..d1410c0
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/NodeTypeId.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class NodeTypeId extends TopologyGraphElementEntityTypeId {
+
+ public NodeTypeId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public NodeTypeId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public NodeTypeId(QName type) {
+ super(type);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/NodeTypeImplementationId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/NodeTypeImplementationId.java
new file mode 100644
index 0000000..48ab36a
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/NodeTypeImplementationId.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class NodeTypeImplementationId extends EntityTypeImplementationId {
+
+ public NodeTypeImplementationId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public NodeTypeImplementationId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/PolicyTemplateId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/PolicyTemplateId.java
new file mode 100644
index 0000000..ff9e4b8
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/PolicyTemplateId.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class PolicyTemplateId extends EntityTemplateId {
+
+ public PolicyTemplateId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public PolicyTemplateId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public PolicyTemplateId(QName qname) {
+ super(qname);
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/PolicyTypeId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/PolicyTypeId.java
new file mode 100644
index 0000000..48d4a4c
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/PolicyTypeId.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class PolicyTypeId extends EntityTypeId {
+
+ public PolicyTypeId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public PolicyTypeId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public PolicyTypeId(QName qname) {
+ super(qname);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RelationshipTypeId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RelationshipTypeId.java
new file mode 100644
index 0000000..1648b09
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RelationshipTypeId.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class RelationshipTypeId extends TopologyGraphElementEntityTypeId {
+
+ public RelationshipTypeId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public RelationshipTypeId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+ public RelationshipTypeId(QName qname) {
+ super(qname);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RelationshipTypeImplementationId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RelationshipTypeImplementationId.java
new file mode 100644
index 0000000..61c0238
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RelationshipTypeImplementationId.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class RelationshipTypeImplementationId extends EntityTypeImplementationId {
+
+ public RelationshipTypeImplementationId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public RelationshipTypeImplementationId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RequirementTypeId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RequirementTypeId.java
new file mode 100644
index 0000000..4b01833
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/RequirementTypeId.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class RequirementTypeId extends EntityTypeId {
+
+ public RequirementTypeId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public RequirementTypeId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public RequirementTypeId(QName qname) {
+ super(qname);
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ServiceTemplateId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ServiceTemplateId.java
new file mode 100644
index 0000000..7001a49
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/ServiceTemplateId.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+public final class ServiceTemplateId extends EntityTemplateId {
+
+ public ServiceTemplateId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public ServiceTemplateId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public ServiceTemplateId(QName qname) {
+ super(qname);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/TOSCAComponentId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/TOSCAComponentId.java
new file mode 100644
index 0000000..e9ce856
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/TOSCAComponentId.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.GenericId;
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+/**
+ * Identifies a TOSCA component. Each component is required to be identified
+ * subclasses this class
+ *
+ * A TOSCAcomponentId has a namespace and an id within that namespace. In XML,
+ * the ID might be serialized as NCName (in the case of EntityTypes and
+ * EntityTemplates) and as xs:id (in the case of EntityTypeImplementations)
+ *
+ * Components are elements, which may appear directly nested in TDefinitions:
+ * <ul>
+ * <li>ServiceTemplates,</li>
+ * <li>EntityTypes,</li
+ * <li>EntityTypeImplementations,</li>
+ * <li>EntityTemplates</li>
+ * </ul>
+ */
+public abstract class TOSCAComponentId extends GenericId {
+
+ private final Namespace namespace;
+
+
+ public TOSCAComponentId(Namespace namespace, XMLId xmlId) {
+ super(xmlId);
+ this.namespace = namespace;
+ }
+
+ /**
+ * Creates a new id based on strings. This constructor is required for
+ * {@link AbstractComponentsResource}
+ *
+ * @param ns the namespace to be used
+ * @param id the id to be used
+ * @param URLencoded true: both Strings are URLencoded, false: both Strings
+ * are not URLencoded
+ */
+ public TOSCAComponentId(String ns, String id, boolean URLencoded) {
+ this(new Namespace(ns, URLencoded), new XMLId(id, URLencoded));
+ }
+
+ public TOSCAComponentId(QName qname) {
+ this(qname.getNamespaceURI(), qname.getLocalPart(), false);
+ }
+
+ public QName getQName() {
+ QName qname = new QName(this.getNamespace().getDecoded(), this.getXmlId().getDecoded());
+ return qname;
+ }
+
+ public Namespace getNamespace() {
+ return this.namespace;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.namespace.hashCode() ^ this.getXmlId().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof TOSCAComponentId)) {
+ return false;
+ } else {
+ TOSCAComponentId other = (TOSCAComponentId) obj;
+ return this.getXmlId().equals(other.getXmlId()) && this.namespace.equals(other.namespace);
+ }
+ }
+
+ @Override
+ public String toString() {
+ QName qn = this.getQName();
+ return this.getClass().toString() + " / " + qn.toString();
+ }
+
+ @Override
+ public GenericId getParent() {
+ return null;
+ }
+
+ @Override
+ public int compareTo(GenericId o1) {
+ if (o1 instanceof TOSCAComponentId) {
+ TOSCAComponentId o = (TOSCAComponentId) o1;
+ int res = this.getXmlId().compareTo(o.getXmlId());
+ if (res == 0) {
+ res = this.getNamespace().compareTo(o.getNamespace());
+ }
+ return res;
+ } else {
+ // comparing TOSCAcomponentIDs with non-TOSCAcomponentIDs is not
+ // possible
+ throw new IllegalStateException();
+ }
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/TopologyGraphElementEntityTypeId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/TopologyGraphElementEntityTypeId.java
new file mode 100644
index 0000000..9eceb42
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/TopologyGraphElementEntityTypeId.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+/**
+ * An instance of this class is either a NodeTypeId or a RelationShipTypeId
+ */
+public abstract class TopologyGraphElementEntityTypeId extends EntityTypeId {
+
+ public TopologyGraphElementEntityTypeId(Namespace namespace, XMLId xmlId) {
+ super(namespace, xmlId);
+ }
+
+ public TopologyGraphElementEntityTypeId(String ns, String id, boolean URLencoded) {
+ super(ns, id, URLencoded);
+ }
+
+ public TopologyGraphElementEntityTypeId(QName type) {
+ super(type);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/imports/GenericImportId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/imports/GenericImportId.java
new file mode 100644
index 0000000..3b81236
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/imports/GenericImportId.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions.imports;
+
+import org.apache.commons.io.FilenameUtils;
+import org.eclipse.winery.model.tosca.TImport;
+import org.eclipse.winery.common.Util;
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+import org.eclipse.winery.common.ids.definitions.TOSCAComponentId;
+
+/**
+ * class for import ids (not used for definitions)
+ *
+ * // Convention: id of import is filename without extension
+ */
+public class GenericImportId extends TOSCAComponentId {
+
+ private final String type;
+
+
+ /**
+ * @param type the importType (e.g., MimeTypes.MIMETYPE_XSD)
+ */
+ public GenericImportId(Namespace namespace, XMLId xmlId, String type) {
+ super(namespace, xmlId);
+ this.type = type;
+ }
+
+ public GenericImportId(String ns, String id, boolean encoded, String type) {
+ super(ns, id, encoded);
+ this.type = type;
+ }
+
+ /**
+ * Generates an ImportId based on an TImport object The import has to be an
+ * import created by winery. This method uses the convention that the id is
+ * derived from the location
+ *
+ * @param i the TImport element to derive an id from
+ */
+ public GenericImportId(TImport i) {
+ this(i.getNamespace(), GenericImportId.getId(i), false, i.getImportType());
+ }
+
+ private static String getId(TImport i) {
+ String fileName = Util.getLastURIPart(i.getLocation());
+ String id = FilenameUtils.removeExtension(fileName);
+ return id;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/imports/XSDImportId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/imports/XSDImportId.java
new file mode 100644
index 0000000..940e8d3
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/imports/XSDImportId.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.definitions.imports;
+
+import javax.xml.XMLConstants;
+
+import org.eclipse.winery.common.ids.Namespace;
+import org.eclipse.winery.common.ids.XMLId;
+
+/**
+ * Models an import of type XML Schema Definition
+ *
+ * Required for a special treatment in {@link
+ * org.eclipse.winery.repository.Utils.
+ * getAllXSDefinitionsForTypeAheadSelection(short)}
+ */
+public class XSDImportId extends GenericImportId {
+
+ public XSDImportId(String ns, String id, boolean encoded) {
+ super(ns, id, encoded, XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ }
+
+ public XSDImportId(Namespace ns, XMLId id) {
+ super(ns, id, XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/package-info.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/package-info.java
new file mode 100644
index 0000000..ac34b49
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/definitions/package-info.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+/**
+ * This package contains ids for all components, which are directly nested in a
+ * definitions element. See CSPRD01, Section 4.1
+ */
+package org.eclipse.winery.common.ids.definitions;
+
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/PlanId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/PlanId.java
new file mode 100644
index 0000000..49c2c2a
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/PlanId.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.elements;
+
+import org.eclipse.winery.common.ids.XMLId;
+
+public class PlanId extends TOSCAElementId {
+
+ public PlanId(PlansId parent, XMLId xmlId) {
+ super(parent, xmlId);
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/PlansId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/PlansId.java
new file mode 100644
index 0000000..bd703dd
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/PlansId.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.elements;
+
+import org.eclipse.winery.common.ids.XMLId;
+import org.eclipse.winery.common.ids.definitions.ServiceTemplateId;
+
+/**
+ * Pseudo-Id for plans nested in one service template
+ *
+ * results in the path "plans/"
+ */
+public class PlansId extends TOSCAElementId {
+
+ public PlansId(ServiceTemplateId parent) {
+ super(parent, new XMLId("plans", true));
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/TOSCAElementId.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/TOSCAElementId.java
new file mode 100644
index 0000000..139a567
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/TOSCAElementId.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.ids.elements;
+
+import org.eclipse.winery.common.ids.GenericId;
+import org.eclipse.winery.common.ids.XMLId;
+
+/**
+ * Models an ID of a TOSCA element, which is NOT a TOSCAcomponentId
+ *
+ * It has a parent and an xmlId
+ */
+public abstract class TOSCAElementId extends GenericId {
+
+ private final GenericId parent;
+
+
+ public TOSCAElementId(GenericId parent, XMLId xmlId) {
+ super(xmlId);
+ this.parent = parent;
+ }
+
+ @Override
+ public GenericId getParent() {
+ return this.parent;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof TOSCAElementId) {
+ TOSCAElementId otherId = (TOSCAElementId) obj;
+ // the XML id has to be equal and the parents have to be equal
+ return (otherId.getXmlId().equals(this.getXmlId())) && (otherId.getParent().equals(this.getParent()));
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo(GenericId o1) {
+ if (o1 instanceof TOSCAElementId) {
+ TOSCAElementId o = (TOSCAElementId) o1;
+ if (this.getParent().equals(o.getParent())) {
+ return this.getXmlId().compareTo(o.getXmlId());
+ } else {
+ return this.getParent().compareTo(o.getParent());
+ }
+ } else {
+ // comparing TOSCAcomponentIDs with non-TOSCAcomponentIDs is not
+ // possible
+ throw new IllegalStateException();
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return this.getParent().hashCode() ^ this.getXmlId().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ String res;
+ res = this.getClass().toString() + " / " + this.getXmlId().getDecoded();
+ res += "\n";
+ res += "parent: " + this.getParent().toString();
+ return res;
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/package-info.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/package-info.java
new file mode 100644
index 0000000..0fd2942
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/ids/elements/package-info.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+/**
+ * This package contains ids for all TOSCA element, which are <b>NOT</b>
+ * directly nested in a definitions element.
+ */
+package org.eclipse.winery.common.ids.elements;
+
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/IWineryRepository.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/IWineryRepository.java
new file mode 100644
index 0000000..5cfe754
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/IWineryRepository.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.interfaces;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.SortedSet;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.GenericId;
+import org.eclipse.winery.common.ids.definitions.TOSCAComponentId;
+import org.eclipse.winery.model.tosca.TDefinitions;
+import org.eclipse.winery.model.tosca.TEntityType;
+import org.eclipse.winery.model.tosca.TTopologyTemplate;
+
+/**
+ * This interface is used by the repository client to get access to the
+ * repository.
+ *
+ * This interface should be removed and the client should be able to use
+ * "IWineryRepositoryCommon" only.
+ */
+public interface IWineryRepository extends IWineryRepositoryCommon {
+
+ /**
+ * Returns all namespaces used by all known TOSCA components and namespaces
+ * where a prefix is defined for
+ *
+ * String is used as return type as Java's QName also uses String as
+ * parameter to denote a namespace
+ */
+ public SortedSet<String> getNamespaces();
+
+ /**
+ * Returns a list of the QNames of all available types. Types can be node
+ * types, service templates, artifact types, artifact templates.
+ *
+ * This method obsoletes methods like "getQNameListOfAllArtifactTypes": One
+ * just has to call getQNameListOfAllTypes(TArtifactType.class)
+ *
+ * @return List of QNames of all types
+ */
+ <T extends TEntityType> List<QName> getQNameListOfAllTypes(Class<T> type);
+
+ /**
+ * Get the TEntityType belonging to the given QName
+ *
+ * @return null if there is no data on the server
+ */
+ <T extends TEntityType> T getType(QName qname, Class<T> type);
+
+ /**
+ * Queries the repository for instances of the given type. Returns pairs of
+ * QNames and names. The names are added as some component instances do
+ * carry a name.
+ *
+ * If the component instance does not carry an explicit name, the localName
+ * of the QName is used as name.
+ *
+ * @param type the type to get all instances of
+ * @return a collection of QName/name pairs
+ */
+ Collection<QNameWithName> getListOfAllInstances(Class<? extends TOSCAComponentId> type);
+
+ /**
+ * Returns the associated name for the given id.
+ *
+ * Since not all TOSCA entities have names, this method may only be used for
+ * entities supporting names. If it is used for entities not having a name,
+ * null is returned.
+ *
+ * @param id references the entity to query for a name
+ * @return the name or null if no name is available
+ */
+ String getName(GenericId id);
+
+ /**
+ * Returns a list of all available types. Types can be node types, service
+ * templates, artifact types. Note that artifact templates are
+ * TEntityTemplates and thus cannot be retrieved by this method.
+ *
+ * This method obsoletes methods like "getAllArtifactTypes": One just has to
+ * call getallTypes(TArtifactType.class)
+ *
+ * @return List of all types
+ */
+ <T extends TEntityType> Collection<T> getAllTypes(Class<T> type);
+
+ /**
+ * @return List of all types with associated elements (such as deployment
+ * artifacts). Each type is nested in a separate Definitions Element
+ */
+ <T extends TEntityType> Collection<TDefinitions> getAllTypesWithAssociatedElements(Class<T> type);
+
+ /**
+ * Returns the topology template associated to the given service template
+ *
+ * @param serviceTemplate a QName of the sericeTemplate with full namespace
+ * @return null if nothing is found
+ */
+ TTopologyTemplate getTopologyTemplate(QName serviceTemplate);
+
+ /**
+ * Replaces (or creates) the provided topology template
+ *
+ * @param serviceTemplate the service template the given topolgoy template
+ * belongs to
+ * @param topologyTemplate the topology template to use
+ */
+ void setTopologyTemplate(QName serviceTemplate, TTopologyTemplate topologyTemplate) throws Exception;
+
+ /**
+ * Returns a reference to the artifact type registered for the given file
+ * extensions. Returns null if no such artifact type exists.
+ *
+ * @param extension the file extension to look up.
+ * @return Reference in the form of a QName to the artifact type matching
+ * the given file extension.
+ */
+ QName getArtifactTypeQNameForExtension(String extension);
+
+ /**
+ * Creates a component of the type idClass.
+ *
+ * @param qname
+ * @param type
+ * @throws QNameAlreadyExistsException
+ */
+ void createComponent(QName qname, Class<? extends TOSCAComponentId> idClass) throws QNameAlreadyExistsException;
+
+ /**
+ * Creates the specified artifact template
+ *
+ * @param qname the namespace and name of the artifact template
+ * @param artifactType the artifact type of the artifact template
+ * @throws QNameAlreadyExistsException if the given QName already exists
+ */
+ void createArtifactTemplate(QName qname, QName artifactType) throws QNameAlreadyExistsException;
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/IWineryRepositoryCommon.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/IWineryRepositoryCommon.java
new file mode 100644
index 0000000..7221489
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/IWineryRepositoryCommon.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.interfaces;
+
+import java.io.IOException;
+
+import org.eclipse.winery.common.ids.GenericId;
+
+/**
+ * Enables access to the winery repository via Ids defined in package
+ * {@link org.eclipse.winery.common.ids}
+ *
+ * Methods are moved from
+ * {@link org.eclipse.winery.repository.backend.IGenericRepository} to here as
+ * soon there is an implementation for them. The ultimate goal is to eliminate
+ * IGenericRepository
+ *
+ * These methods are shared between {@link IWineryRepository} and
+ * {@link org.eclipse.winery.repository.backend.IRepository}
+ */
+public interface IWineryRepositoryCommon {
+
+ /**
+ * Deletes the TOSCA element <b>and all sub elements</b> referenced by the
+ * given id from the repository
+ *
+ * We assume that each id is a directory
+ *
+ * @param id
+ */
+ public void forceDelete(GenericId id) throws IOException;
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/QNameAlreadyExistsException.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/QNameAlreadyExistsException.java
new file mode 100644
index 0000000..d089935
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/QNameAlreadyExistsException.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.interfaces;
+
+public class QNameAlreadyExistsException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/QNameWithName.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/QNameWithName.java
new file mode 100644
index 0000000..96c2e43
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/interfaces/QNameWithName.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.interfaces;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This class is used to pass around QNames with associated names in string
+ * format
+ */
+public class QNameWithName {
+
+ public QName qname;
+ public String name;
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/PropertyDefinitionKV.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/PropertyDefinitionKV.java
new file mode 100644
index 0000000..f8cc236
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/PropertyDefinitionKV.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.propertydefinitionkv;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "PropertyDefinition")
+public class PropertyDefinitionKV {
+
+ private String key;
+ private String type;
+
+
+ public PropertyDefinitionKV() {
+ super();
+ }
+
+ public PropertyDefinitionKV(String key, String type) {
+ super();
+ this.setKey(key);
+ this.setType(type);
+ }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public void setKey(String key) {
+ if (key == null) {
+ throw new IllegalArgumentException();
+ }
+ this.key = key;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ if (type == null) {
+ throw new IllegalArgumentException();
+ }
+ this.type = type;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.key.hashCode();
+ }
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/PropertyDefinitionKVList.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/PropertyDefinitionKVList.java
new file mode 100644
index 0000000..445bda6
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/PropertyDefinitionKVList.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.propertydefinitionkv;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "PropertyDefinitions")
+public class PropertyDefinitionKVList extends ArrayList<PropertyDefinitionKV> {
+
+ private static final long serialVersionUID = -6442041855597987094L;
+
+
+ @XmlElement(name = "PropertyDefinition")
+ public List<PropertyDefinitionKV> getPropertyDefinitionKVs() {
+ return this;
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/WinerysPropertiesDefinition.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/WinerysPropertiesDefinition.java
new file mode 100644
index 0000000..548e87b
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/WinerysPropertiesDefinition.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common.propertydefinitionkv;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.eclipse.winery.common.constants.Namespaces;
+
+/**
+ * This is Winery's main extension element for a key/value based properties
+ * definition
+ */
+@XmlRootElement(name = "PropertiesDefinition")
+public class WinerysPropertiesDefinition {
+
+ private String namespace;
+ private String elementName;
+ private PropertyDefinitionKVList propertyDefinitionKVList;
+ private Boolean isDerivedFromXSD = Boolean.FALSE;
+
+
+ @XmlAttribute(name = "namespace")
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ @XmlAttribute(name = "elementname")
+ public String getElementName() {
+ return this.elementName;
+ }
+
+ public void setElementName(String localName) {
+ this.elementName = localName;
+ }
+
+ @XmlElement(name = "properties")
+ public PropertyDefinitionKVList getPropertyDefinitionKVList() {
+ return this.propertyDefinitionKVList;
+ }
+
+ public void setPropertyDefinitionKVList(PropertyDefinitionKVList propertyDefinitionKVList) {
+ this.propertyDefinitionKVList = propertyDefinitionKVList;
+ }
+
+ /**
+ * @return null if not derived from XSD, "Boolean.TRUE" otherwise. This
+ * leads JAXB to write the attribute only if derivedFromXSD is true
+ */
+ @XmlAttribute(name = "derivedFromXSD", namespace = Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE)
+ public Boolean getIsDerivedFromXSD() {
+ if ((this.isDerivedFromXSD != null) && (this.isDerivedFromXSD)) {
+ return Boolean.TRUE;
+ } else {
+ return null;
+ }
+ }
+
+ public void setIsDerivedFromXSD(Boolean isDerivedFromXSD) {
+ this.isDerivedFromXSD = isDerivedFromXSD;
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/package-info.java b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/package-info.java
new file mode 100644
index 0000000..169e755
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/java/org/eclipse/winery/common/propertydefinitionkv/package-info.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+/**
+ * This package defines the data structures for key/value property handling
+ *
+ * The XML Schema is generated based on the user configuration. The namespace
+ * for the schema is the namespace of the respective type with
+ * {@code /propertiesdefinition/<localname>} appended, where {@code <localname>}
+ * is the local name of the entity type, where the properties definition is
+ * defined.
+ *
+ */
+@XmlSchema(namespace = Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, elementFormDefault = XmlNsForm.QUALIFIED)
+package org.eclipse.winery.common.propertydefinitionkv;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlSchema;
+
+import org.eclipse.winery.common.constants.Namespaces;
+
diff --git a/winery/org.eclipse.winery.common/src/main/resources/TOSCA-v1.0.xsd b/winery/org.eclipse.winery.common/src/main/resources/TOSCA-v1.0.xsd
new file mode 100644
index 0000000..8bed0e0
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/main/resources/TOSCA-v1.0.xsd
@@ -0,0 +1,791 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Topology and Orchestration Specification for Cloud Applications Version 1.0
+ Committee Specification Draft 08
+ 09 May 2013
+ Copyright (c) OASIS Open 2013. All rights reserved.
+ Source: http://docs.oasis-open.org/tosca/TOSCA/v1.0/csd08/schemas/
+-->
+<xs:schema targetNamespace="http://docs.oasis-open.org/tosca/ns/2011/12" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="http://docs.oasis-open.org/tosca/ns/2011/12" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+ <xs:element name="documentation" type="tDocumentation"/>
+ <xs:complexType name="tDocumentation" mixed="true">
+ <xs:sequence>
+ <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="source" type="xs:anyURI"/>
+ <xs:attribute ref="xml:lang"/>
+ </xs:complexType>
+ <xs:complexType name="tExtensibleElements">
+ <xs:sequence>
+ <xs:element ref="documentation" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+ <xs:complexType name="tImport">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:attribute name="namespace" type="xs:anyURI"/>
+ <xs:attribute name="location" type="xs:anyURI"/>
+ <xs:attribute name="importType" type="importedURI" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:element name="Definitions">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="tDefinitions"/>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="tDefinitions">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Extensions" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Extension" type="tExtension" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Import" type="tImport" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="Types" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:choice maxOccurs="unbounded">
+ <xs:element name="ServiceTemplate" type="tServiceTemplate"/>
+ <xs:element name="NodeType" type="tNodeType"/>
+ <xs:element name="NodeTypeImplementation" type="tNodeTypeImplementation"/>
+ <xs:element name="RelationshipType" type="tRelationshipType"/>
+ <xs:element name="RelationshipTypeImplementation" type="tRelationshipTypeImplementation"/>
+ <xs:element name="RequirementType" type="tRequirementType"/>
+ <xs:element name="CapabilityType" type="tCapabilityType"/>
+ <xs:element name="ArtifactType" type="tArtifactType"/>
+ <xs:element name="ArtifactTemplate" type="tArtifactTemplate"/>
+ <xs:element name="PolicyType" type="tPolicyType"/>
+ <xs:element name="PolicyTemplate" type="tPolicyTemplate"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:ID" use="required"/>
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ <xs:attribute name="targetNamespace" type="xs:anyURI" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tServiceTemplate">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Tags" type="tTags" minOccurs="0"/>
+ <xs:element name="BoundaryDefinitions" type="tBoundaryDefinitions" minOccurs="0"/>
+ <xs:element name="TopologyTemplate" type="tTopologyTemplate"/>
+ <xs:element name="Plans" type="tPlans" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:ID" use="required"/>
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ <xs:attribute name="targetNamespace" type="xs:anyURI"/>
+ <xs:attribute name="substitutableNodeType" type="xs:QName" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tTags">
+ <xs:sequence>
+ <xs:element name="Tag" type="tTag" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="tTag">
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="value" type="xs:string" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tBoundaryDefinitions">
+ <xs:sequence>
+ <xs:element name="Properties" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##other"/>
+ <xs:element name="PropertyMappings" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="PropertyMapping" type="tPropertyMapping" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="PropertyConstraints" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="PropertyConstraint" type="tPropertyConstraint" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Requirements" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Requirement" type="tRequirementRef" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Capabilities" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Capability" type="tCapabilityRef" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Policies" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Policy" type="tPolicy" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Interfaces" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Interface" type="tExportedInterface" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="tPropertyMapping">
+ <xs:attribute name="serviceTemplatePropertyRef" type="xs:string" use="required"/>
+ <xs:attribute name="targetObjectRef" type="xs:IDREF" use="required"/>
+ <xs:attribute name="targetPropertyRef" type="xs:string" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tRequirementRef">
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ <xs:attribute name="ref" type="xs:IDREF" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tCapabilityRef">
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ <xs:attribute name="ref" type="xs:IDREF" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tEntityType" abstract="true">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Tags" type="tTags" minOccurs="0"/>
+ <xs:element name="DerivedFrom" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="typeRef" type="xs:QName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="PropertiesDefinition" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="element" type="xs:QName"/>
+ <xs:attribute name="type" type="xs:QName"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:NCName" use="required"/>
+ <xs:attribute name="abstract" type="tBoolean" default="no"/>
+ <xs:attribute name="final" type="tBoolean" default="no"/>
+ <xs:attribute name="targetNamespace" type="xs:anyURI" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tEntityTemplate" abstract="true">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Properties" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##other" processContents="lax"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="PropertyConstraints" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="PropertyConstraint" type="tPropertyConstraint" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:ID" use="required"/>
+ <xs:attribute name="type" type="xs:QName" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tNodeTemplate">
+ <xs:complexContent>
+ <xs:extension base="tEntityTemplate">
+ <xs:sequence>
+ <xs:element name="Requirements" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Requirement" type="tRequirement" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Capabilities" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Capability" type="tCapability" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Policies" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Policy" type="tPolicy" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="DeploymentArtifacts" type="tDeploymentArtifacts" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ <xs:attribute name="minInstances" type="xs:int" use="optional" default="1"/>
+ <xs:attribute name="maxInstances" use="optional" default="1">
+ <xs:simpleType>
+ <xs:union>
+ <xs:simpleType>
+ <xs:restriction base="xs:nonNegativeInteger">
+ <xs:pattern value="([1-9]+[0-9]*)"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="unbounded"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:union>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tTopologyTemplate">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:choice maxOccurs="unbounded">
+ <xs:element name="NodeTemplate" type="tNodeTemplate"/>
+ <xs:element name="RelationshipTemplate" type="tRelationshipTemplate"/>
+ </xs:choice>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tRelationshipType">
+ <xs:complexContent>
+ <xs:extension base="tEntityType">
+ <xs:sequence>
+ <xs:element name="InstanceStates" type="tTopologyElementInstanceStates" minOccurs="0"/>
+ <xs:element name="SourceInterfaces" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Interface" type="tInterface" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="TargetInterfaces" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Interface" type="tInterface" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="ValidSource" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="typeRef" type="xs:QName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="ValidTarget" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="typeRef" type="xs:QName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tRelationshipTypeImplementation">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Tags" type="tTags" minOccurs="0"/>
+ <xs:element name="DerivedFrom" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="relationshipTypeImplementationRef" type="xs:QName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="RequiredContainerFeatures" type="tRequiredContainerFeatures" minOccurs="0"/>
+ <xs:element name="ImplementationArtifacts" type="tImplementationArtifacts" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:NCName" use="required"/>
+ <xs:attribute name="targetNamespace" type="xs:anyURI" use="optional"/>
+ <xs:attribute name="relationshipType" type="xs:QName" use="required"/>
+ <xs:attribute name="abstract" type="tBoolean" use="optional" default="no"/>
+ <xs:attribute name="final" type="tBoolean" use="optional" default="no"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tRelationshipTemplate">
+ <xs:complexContent>
+ <xs:extension base="tEntityTemplate">
+ <xs:sequence>
+ <xs:element name="SourceElement">
+ <xs:complexType>
+ <xs:attribute name="ref" type="xs:IDREF" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="TargetElement">
+ <xs:complexType>
+ <xs:attribute name="ref" type="xs:IDREF" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="RelationshipConstraints" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="RelationshipConstraint" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="constraintType" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tNodeType">
+ <xs:complexContent>
+ <xs:extension base="tEntityType">
+ <xs:sequence>
+ <xs:element name="RequirementDefinitions" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="RequirementDefinition" type="tRequirementDefinition" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CapabilityDefinitions" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="CapabilityDefinition" type="tCapabilityDefinition" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="InstanceStates" type="tTopologyElementInstanceStates" minOccurs="0"/>
+ <xs:element name="Interfaces" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Interface" type="tInterface" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tNodeTypeImplementation">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Tags" type="tTags" minOccurs="0"/>
+ <xs:element name="DerivedFrom" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="nodeTypeImplementationRef" type="xs:QName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="RequiredContainerFeatures" type="tRequiredContainerFeatures" minOccurs="0"/>
+ <xs:element name="ImplementationArtifacts" type="tImplementationArtifacts" minOccurs="0"/>
+ <xs:element name="DeploymentArtifacts" type="tDeploymentArtifacts" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:NCName" use="required"/>
+ <xs:attribute name="targetNamespace" type="xs:anyURI" use="optional"/>
+ <xs:attribute name="nodeType" type="xs:QName" use="required"/>
+ <xs:attribute name="abstract" type="tBoolean" use="optional" default="no"/>
+ <xs:attribute name="final" type="tBoolean" use="optional" default="no"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tRequirementType">
+ <xs:complexContent>
+ <xs:extension base="tEntityType">
+ <xs:attribute name="requiredCapabilityType" type="xs:QName" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tRequirementDefinition">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Constraints" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Constraint" type="tConstraint" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="requirementType" type="xs:QName" use="required"/>
+ <xs:attribute name="lowerBound" type="xs:int" use="optional" default="1"/>
+ <xs:attribute name="upperBound" use="optional" default="1">
+ <xs:simpleType>
+ <xs:union>
+ <xs:simpleType>
+ <xs:restriction base="xs:nonNegativeInteger">
+ <xs:pattern value="([1-9]+[0-9]*)"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="unbounded"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:union>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tRequirement">
+ <xs:complexContent>
+ <xs:extension base="tEntityTemplate">
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tCapabilityType">
+ <xs:complexContent>
+ <xs:extension base="tEntityType"/>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tCapabilityDefinition">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Constraints" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Constraint" type="tConstraint" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="capabilityType" type="xs:QName" use="required"/>
+ <xs:attribute name="lowerBound" type="xs:int" use="optional" default="1"/>
+ <xs:attribute name="upperBound" use="optional" default="1">
+ <xs:simpleType>
+ <xs:union>
+ <xs:simpleType>
+ <xs:restriction base="xs:nonNegativeInteger">
+ <xs:pattern value="([1-9]+[0-9]*)"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="unbounded"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:union>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tCapability">
+ <xs:complexContent>
+ <xs:extension base="tEntityTemplate">
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tArtifactType">
+ <xs:complexContent>
+ <xs:extension base="tEntityType"/>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tArtifactTemplate">
+ <xs:complexContent>
+ <xs:extension base="tEntityTemplate">
+ <xs:sequence>
+ <xs:element name="ArtifactReferences" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ArtifactReference" type="tArtifactReference" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tDeploymentArtifacts">
+ <xs:sequence>
+ <xs:element name="DeploymentArtifact" type="tDeploymentArtifact" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="tDeploymentArtifact">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="artifactType" type="xs:QName" use="required"/>
+ <xs:attribute name="artifactRef" type="xs:QName" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tImplementationArtifacts">
+ <xs:sequence>
+ <xs:element name="ImplementationArtifact" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="tImplementationArtifact"/>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="tImplementationArtifact">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ <xs:attribute name="interfaceName" type="xs:anyURI" use="optional"/>
+ <xs:attribute name="operationName" type="xs:NCName" use="optional"/>
+ <xs:attribute name="artifactType" type="xs:QName" use="required"/>
+ <xs:attribute name="artifactRef" type="xs:QName" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tPlans">
+ <xs:sequence>
+ <xs:element name="Plan" type="tPlan" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="targetNamespace" type="xs:anyURI" use="optional"/>
+ </xs:complexType>
+ <xs:complexType name="tPlan">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Precondition" type="tCondition" minOccurs="0"/>
+ <xs:element name="InputParameters" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="InputParameter" type="tParameter" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="OutputParameters" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="OutputParameter" type="tParameter" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:choice>
+ <xs:element name="PlanModel">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##other" processContents="lax"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="PlanModelReference">
+ <xs:complexType>
+ <xs:attribute name="reference" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:ID" use="required"/>
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ <xs:attribute name="planType" type="xs:anyURI" use="required"/>
+ <xs:attribute name="planLanguage" type="xs:anyURI" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tPolicyType">
+ <xs:complexContent>
+ <xs:extension base="tEntityType">
+ <xs:sequence>
+ <xs:element name="AppliesTo" type="tAppliesTo" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="policyLanguage" type="xs:anyURI" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tPolicyTemplate">
+ <xs:complexContent>
+ <xs:extension base="tEntityTemplate">
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tAppliesTo">
+ <xs:sequence>
+ <xs:element name="NodeTypeReference" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="typeRef" type="xs:QName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="tPolicy">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:attribute name="name" type="xs:string" use="optional"/>
+ <xs:attribute name="policyType" type="xs:QName" use="required"/>
+ <xs:attribute name="policyRef" type="xs:QName" use="optional"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tConstraint">
+ <xs:sequence>
+ <xs:any namespace="##other" processContents="lax"/>
+ </xs:sequence>
+ <xs:attribute name="constraintType" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tPropertyConstraint">
+ <xs:complexContent>
+ <xs:extension base="tConstraint">
+ <xs:attribute name="property" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tExtensions">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="Extension" type="tExtension" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tExtension">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:attribute name="namespace" type="xs:anyURI" use="required"/>
+ <xs:attribute name="mustUnderstand" type="tBoolean" use="optional" default="yes"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tParameter">
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="type" type="xs:string" use="required"/>
+ <xs:attribute name="required" type="tBoolean" use="optional" default="yes"/>
+ </xs:complexType>
+ <xs:complexType name="tInterface">
+ <xs:sequence>
+ <xs:element name="Operation" type="tOperation" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tExportedInterface">
+ <xs:sequence>
+ <xs:element name="Operation" type="tExportedOperation" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tOperation">
+ <xs:complexContent>
+ <xs:extension base="tExtensibleElements">
+ <xs:sequence>
+ <xs:element name="InputParameters" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="InputParameter" type="tParameter" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="OutputParameters" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="OutputParameter" type="tParameter" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:NCName" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="tExportedOperation">
+ <xs:choice>
+ <xs:element name="NodeOperation">
+ <xs:complexType>
+ <xs:attribute name="nodeRef" type="xs:IDREF" use="required"/>
+ <xs:attribute name="interfaceName" type="xs:anyURI" use="required"/>
+ <xs:attribute name="operationName" type="xs:NCName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="RelationshipOperation">
+ <xs:complexType>
+ <xs:attribute name="relationshipRef" type="xs:IDREF" use="required"/>
+ <xs:attribute name="interfaceName" type="xs:anyURI" use="required"/>
+ <xs:attribute name="operationName" type="xs:NCName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Plan">
+ <xs:complexType>
+ <xs:attribute name="planRef" type="xs:IDREF" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:NCName" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tCondition">
+ <xs:sequence>
+ <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="expressionLanguage" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tTopologyElementInstanceStates">
+ <xs:sequence>
+ <xs:element name="InstanceState" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="state" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="tArtifactReference">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="Include">
+ <xs:complexType>
+ <xs:attribute name="pattern" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Exclude">
+ <xs:complexType>
+ <xs:attribute name="pattern" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:choice>
+ <xs:attribute name="reference" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="tRequiredContainerFeatures">
+ <xs:sequence>
+ <xs:element name="RequiredContainerFeature" type="tRequiredContainerFeature" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="tRequiredContainerFeature">
+ <xs:attribute name="feature" type="xs:anyURI" use="required"/>
+ </xs:complexType>
+ <xs:simpleType name="tBoolean">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="yes"/>
+ <xs:enumeration value="no"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="importedURI">
+ <xs:restriction base="xs:anyURI"/>
+ </xs:simpleType>
+</xs:schema>
diff --git a/winery/org.eclipse.winery.common/src/test/java/.gitkeep b/winery/org.eclipse.winery.common/src/test/java/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/test/java/.gitkeep
diff --git a/winery/org.eclipse.winery.common/src/test/java/META-INF/MANIFEST.MF b/winery/org.eclipse.winery.common/src/test/java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..254272e
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/test/java/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/winery/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/ModelUtilitiesTest.java b/winery/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/ModelUtilitiesTest.java
new file mode 100644
index 0000000..650241d
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/ModelUtilitiesTest.java
@@ -0,0 +1,13 @@
+package org.eclipse.winery.common;
+
+import org.junit.Test;
+
+public class ModelUtilitiesTest {
+
+ @Test
+ public void setPropertiesKV() {
+ // TODO: add some test here
+ // The test is difficult as a node type has to be generated with a wineryspropertiesdefinition, ...
+ }
+
+}
diff --git a/winery/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/TestUtil.java b/winery/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/TestUtil.java
new file mode 100644
index 0000000..8c0c924
--- /dev/null
+++ b/winery/org.eclipse.winery.common/src/test/java/org/eclipse/winery/common/TestUtil.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2013 University of Stuttgart.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * Oliver Kopp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.winery.common;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestUtil {
+
+ @Test
+ public void testNamespaceToJavaPackageFullURL() {
+ Assert.assertEquals("org.example.www.tosca.nodetypes", Util.namespaceToJavaPackage("http://www.example.org/tosca/nodetypes"));
+ }
+
+ @Test
+ public void testNamespaceToJavaPackageURLWithHostOnly() {
+ Assert.assertEquals("org.example.www", Util.namespaceToJavaPackage("http://www.example.org/"));
+ }
+
+ @Test
+ public void testNamespaceToJavaPackageURLWithHostOnlyAndNoFinalSlash() {
+ Assert.assertEquals("org.example.www", Util.namespaceToJavaPackage("http://www.example.org"));
+ }
+
+ @Test
+ public void testNamespaceToJavaPackageURLWithNoHost() {
+ Assert.assertEquals("plainNCname", Util.namespaceToJavaPackage("plainNCname"));
+ }
+
+ @Test
+ public void testNCNameFromURL() {
+ Assert.assertEquals("http___www.example.org", Util.makeNCName("http://www.example.org"));
+ }
+
+ @Test
+ public void testNCNameFromNCName() {
+ Assert.assertEquals("NCName", Util.makeNCName("NCName"));
+ }
+}