Search in sources :

Example 16 with NodeTypeImplementationId

use of org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId 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 17 with NodeTypeImplementationId

use of org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId 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)17 QName (javax.xml.namespace.QName)11 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)10 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)8 RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)7 RelationshipTypeImplementationId (org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId)7 ArrayList (java.util.ArrayList)6 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)6 CapabilityTypeId (org.eclipse.winery.model.ids.definitions.CapabilityTypeId)5 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)5 TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)5 IOException (java.io.IOException)4 ArtifactTypeId (org.eclipse.winery.model.ids.definitions.ArtifactTypeId)4 DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)4 PolicyTypeId (org.eclipse.winery.model.ids.definitions.PolicyTypeId)4 RequirementTypeId (org.eclipse.winery.model.ids.definitions.RequirementTypeId)4 IRepository (org.eclipse.winery.repository.backend.IRepository)4 Collection (java.util.Collection)3 Collectors (java.util.stream.Collectors)3 InterfaceTypeId (org.eclipse.winery.model.ids.definitions.InterfaceTypeId)3