Search in sources :

Example 6 with RelationshipTypeImplementationId

use of org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId in project winery by eclipse.

the class YamlRepository method putContentToFile.

/**
 * Converts incoming xml input stream to yaml service template and writes it to file
 *
 * @param ref         repository file reference
 * @param inputStream input stream to write to file
 * @param mediaType   Media Type
 */
@Override
public void putContentToFile(RepositoryFileReference ref, InputStream inputStream, MediaType mediaType) throws IOException {
    if (mediaType.equals(MediaTypes.MEDIATYPE_TOSCA_DEFINITIONS)) {
        // use throwable as way to track the callgraph
        LOGGER.error("Use of InputStream overload to write definitions with callpath", new Throwable());
    }
    Path targetPath = this.ref2AbsolutePath(ref);
    inputStream = convertToServiceTemplate(ref, inputStream, mediaType);
    writeInputStreamToPath(targetPath, inputStream);
    if (ref.getParent() instanceof NodeTypeImplementationId || ref.getParent() instanceof RelationshipTypeImplementationId) {
        clearCache();
    }
}
Also used : Path(java.nio.file.Path) NodeTypeImplementationId(org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId) RelationshipTypeImplementationId(org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId)

Example 7 with RelationshipTypeImplementationId

use of org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId in project winery by eclipse.

the class YamlRepository method convertGenericId.

/**
 * Converts Generic id of non existing XML Definitions in compatible YAML Definition
 *
 * @param id GenericId
 * @return converted Generic Id
 */
private GenericId convertGenericId(GenericId id) {
    if (id instanceof NodeTypeImplementationId) {
        return new NodeTypeId(((NodeTypeImplementationId) id).getQName());
    } else if (id instanceof RelationshipTypeImplementationId) {
        return new RelationshipTypeId(((RelationshipTypeImplementationId) id).getQName());
    } else if (id instanceof ArtifactTemplateId) {
        QName qName = ((ArtifactTemplateId) id).getQName();
        Matcher nameMatcher = namePattern.matcher(qName.getLocalPart());
        if (nameMatcher.matches()) {
            String typeName = nameMatcher.group(2);
            if (nameMatcher.group(3).equalsIgnoreCase("nodetypes")) {
                return new NodeTypeId(new QName(qName.getNamespaceURI(), typeName));
            } else {
                return new RelationshipTypeId(new QName(qName.getNamespaceURI(), typeName));
            }
        } else {
            return new NodeTypeId(new QName(qName.getNamespaceURI(), "Cache"));
        }
    }
    return null;
}
Also used : NodeTypeImplementationId(org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) Matcher(java.util.regex.Matcher) QName(javax.xml.namespace.QName) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) RelationshipTypeImplementationId(org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId) ArtifactTemplateId(org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)

Aggregations

NodeTypeImplementationId (org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId)7 RelationshipTypeImplementationId (org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId)7 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)5 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)5 RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)5 CapabilityTypeId (org.eclipse.winery.model.ids.definitions.CapabilityTypeId)4 PolicyTypeId (org.eclipse.winery.model.ids.definitions.PolicyTypeId)4 QName (javax.xml.namespace.QName)3 ArtifactTypeId (org.eclipse.winery.model.ids.definitions.ArtifactTypeId)3 RequirementTypeId (org.eclipse.winery.model.ids.definitions.RequirementTypeId)3 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)3 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)3 Path (java.nio.file.Path)2 DataTypeId (org.eclipse.winery.model.ids.definitions.DataTypeId)2 InterfaceTypeId (org.eclipse.winery.model.ids.definitions.InterfaceTypeId)2 PolicyTemplateId (org.eclipse.winery.model.ids.definitions.PolicyTemplateId)2 TDefinitions (org.eclipse.winery.model.tosca.TDefinitions)2 TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1