Search in sources :

Example 1 with DataTypeId

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

the class BackendUtils method createWrapperDefinitionsAndInitialEmptyElement.

public static TDefinitions createWrapperDefinitionsAndInitialEmptyElement(IRepository repository, DefinitionsChildId id) {
    final TDefinitions definitions = createWrapperDefinitions(id, repository);
    HasIdInIdOrNameField element;
    if (id instanceof RelationshipTypeImplementationId) {
        element = new TRelationshipTypeImplementation();
    } else if (id instanceof NodeTypeImplementationId) {
        element = new TNodeTypeImplementation();
    } else if (id instanceof RequirementTypeId) {
        element = new TRequirementType();
    } else if (id instanceof NodeTypeId) {
        element = new TNodeType();
    } else if (id instanceof RelationshipTypeId) {
        element = new TRelationshipType();
    } else if (id instanceof CapabilityTypeId) {
        element = new TCapabilityType();
    } else if (id instanceof DataTypeId) {
        element = new TDataType();
    } else if (id instanceof ArtifactTypeId) {
        element = new TArtifactType();
    } else if (id instanceof PolicyTypeId) {
        element = new TPolicyType();
    } else if (id instanceof PolicyTemplateId) {
        element = new TPolicyTemplate();
    } else if (id instanceof ServiceTemplateId) {
        element = new TServiceTemplate();
    } else if (id instanceof ArtifactTemplateId) {
        element = new TArtifactTemplate();
    } else if (id instanceof ComplianceRuleId) {
        element = new OTComplianceRule(new OTComplianceRule.Builder(id.getXmlId().getDecoded()));
    } else if (id instanceof PatternRefinementModelId) {
        element = new OTPatternRefinementModel(new OTPatternRefinementModel.Builder());
    } else if (id instanceof TopologyFragmentRefinementModelId) {
        element = new OTTopologyFragmentRefinementModel(new OTPatternRefinementModel.Builder());
    } else if (id instanceof TestRefinementModelId) {
        element = new OTTestRefinementModel(new OTTestRefinementModel.Builder());
    } else if (id instanceof InterfaceTypeId) {
        element = new TInterfaceType();
    } else if (id instanceof XSDImportId) {
        // TImport has no id; thus directly generating it without setting an id
        TImport tImport = new TImport();
        definitions.setElement(tImport);
        return definitions;
    } else {
        throw new IllegalStateException("Unhandled id branch. Could happen for XSDImportId");
    }
    copyIdToFields(element, id);
    definitions.setElement((TExtensibleElements) element);
    return definitions;
}
Also used : OTTopologyFragmentRefinementModel(org.eclipse.winery.model.tosca.extensions.OTTopologyFragmentRefinementModel) ArtifactTypeId(org.eclipse.winery.model.ids.definitions.ArtifactTypeId) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) TestRefinementModelId(org.eclipse.winery.model.ids.extensions.TestRefinementModelId) TImport(org.eclipse.winery.model.tosca.TImport) TCapabilityType(org.eclipse.winery.model.tosca.TCapabilityType) TDataType(org.eclipse.winery.model.tosca.TDataType) OTTestRefinementModel(org.eclipse.winery.model.tosca.extensions.OTTestRefinementModel) TRequirementType(org.eclipse.winery.model.tosca.TRequirementType) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) HasIdInIdOrNameField(org.eclipse.winery.model.tosca.HasIdInIdOrNameField) ComplianceRuleId(org.eclipse.winery.model.ids.extensions.ComplianceRuleId) InterfaceTypeId(org.eclipse.winery.model.ids.definitions.InterfaceTypeId) TArtifactType(org.eclipse.winery.model.tosca.TArtifactType) TPolicyType(org.eclipse.winery.model.tosca.TPolicyType) TopologyFragmentRefinementModelId(org.eclipse.winery.model.ids.extensions.TopologyFragmentRefinementModelId) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) NodeTypeImplementationId(org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId) XSDImportId(org.eclipse.winery.model.ids.definitions.imports.XSDImportId) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) CapabilityTypeId(org.eclipse.winery.model.ids.definitions.CapabilityTypeId) RelationshipTypeImplementationId(org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) ArtifactTemplateId(org.eclipse.winery.model.ids.definitions.ArtifactTemplateId) TNodeType(org.eclipse.winery.model.tosca.TNodeType) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) TPolicyTemplate(org.eclipse.winery.model.tosca.TPolicyTemplate) PatternRefinementModelId(org.eclipse.winery.model.ids.extensions.PatternRefinementModelId) PolicyTypeId(org.eclipse.winery.model.ids.definitions.PolicyTypeId) TRelationshipTypeImplementation(org.eclipse.winery.model.tosca.TRelationshipTypeImplementation) RequirementTypeId(org.eclipse.winery.model.ids.definitions.RequirementTypeId) DataTypeId(org.eclipse.winery.model.ids.definitions.DataTypeId) TInterfaceType(org.eclipse.winery.model.tosca.TInterfaceType) PolicyTemplateId(org.eclipse.winery.model.ids.definitions.PolicyTemplateId) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) OTComplianceRule(org.eclipse.winery.model.tosca.extensions.OTComplianceRule) OTPatternRefinementModel(org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel)

Example 2 with DataTypeId

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

the class IRepository method getReferencedDefinitionsOfProperties.

default void getReferencedDefinitionsOfProperties(Collection<DefinitionsChildId> ids, TEntityType.PropertiesDefinition properties) {
    if (Objects.nonNull(properties)) {
        // Only the YamlPropertiesDefinitions are referencing additional elements
        if (properties instanceof TEntityType.YamlPropertiesDefinition) {
            List<TEntityType.YamlPropertyDefinition> props = ((TEntityType.YamlPropertiesDefinition) properties).getProperties();
            Queue<TSchema> schemata = new LinkedList<>();
            for (TEntityType.YamlPropertyDefinition def : props) {
                if (!def.getType().getNamespaceURI().isEmpty()) {
                    ids.add(new DataTypeId(def.getType()));
                }
                schemata.add(def.getKeySchema());
                schemata.add(def.getEntrySchema());
            }
            while (!schemata.isEmpty()) {
                TSchema current = schemata.poll();
                if (current == null) {
                    continue;
                }
                if (!current.getType().getNamespaceURI().isEmpty()) {
                    ids.add(new DataTypeId(current.getType()));
                }
                schemata.add(current.getKeySchema());
                schemata.add(current.getEntrySchema());
            }
        }
    }
}
Also used : TSchema(org.eclipse.winery.model.tosca.TSchema) TEntityType(org.eclipse.winery.model.tosca.TEntityType) DataTypeId(org.eclipse.winery.model.ids.definitions.DataTypeId) LinkedList(java.util.LinkedList)

Example 3 with DataTypeId

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

the class YamlRepository method getRequestedDefinition.

/**
 * Parses only requested Definition from converted yaml service template
 *
 * @param id          Definitions Child id
 * @param definitions converted definitions
 * @return requested definitions
 */
private TDefinitions getRequestedDefinition(DefinitionsChildId id, TDefinitions definitions) {
    if (id instanceof ArtifactTemplateId) {
        String artifactName = getNameOfArtifactFromArtifactName(id.getQName().getLocalPart());
        List<TArtifactTemplate> artifactTemplates = definitions.getArtifactTemplates();
        List<TArtifactTemplate> requestedArtifactTemplates = new ArrayList<>();
        for (TArtifactTemplate artifactTemplate : artifactTemplates) {
            if (artifactTemplate.getId().equalsIgnoreCase(artifactName)) {
                requestedArtifactTemplates.add(artifactTemplate);
                TDefinitions.Builder requestedDefinitions = getEmptyDefinition(definitions);
                requestedDefinitions.addArtifactTemplates(requestedArtifactTemplates);
                return requestedDefinitions.build();
            }
        }
        // we did not find the artifact template id (this should not happen!)
        LOGGER.error("requested artifact template id (" + id.toReadableString() + ") cannot be extracted from definitions object!");
        return definitions;
    } else {
        TDefinitions.Builder requestedDefinitions = getEmptyDefinition(definitions);
        if (id instanceof NodeTypeId) {
            requestedDefinitions.addNodeTypes(definitions.getNodeTypes());
        } else if (id instanceof RelationshipTypeId) {
            requestedDefinitions.addRelationshipTypes(definitions.getRelationshipTypes());
        } else if (id instanceof NodeTypeImplementationId) {
            requestedDefinitions.addNodeTypeImplementations(definitions.getNodeTypeImplementations());
        } else if (id instanceof RelationshipTypeImplementationId) {
            requestedDefinitions.addRelationshipTypeImplementations(definitions.getRelationshipTypeImplementations());
        } else if (id instanceof ArtifactTypeId) {
            requestedDefinitions.addArtifactTypes(definitions.getArtifactTypes());
        } else if (id instanceof CapabilityTypeId) {
            requestedDefinitions.addCapabilityTypes(definitions.getCapabilityTypes());
        } else if (id instanceof DataTypeId) {
            requestedDefinitions.addDataTypes(definitions.getDataTypes());
        } else if (id instanceof RequirementTypeId) {
            requestedDefinitions.addRequirementTypes(definitions.getRequirementTypes());
        } else if (id instanceof PolicyTypeId) {
            requestedDefinitions.addPolicyTypes(definitions.getPolicyTypes());
        } else if (id instanceof InterfaceTypeId) {
            requestedDefinitions.addInterfaceTypes(definitions.getInterfaceTypes());
        } else {
            // we do not need to filter anything
            return definitions;
        }
        return requestedDefinitions.build();
    }
}
Also used : NodeTypeImplementationId(org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) ArtifactTypeId(org.eclipse.winery.model.ids.definitions.ArtifactTypeId) CapabilityTypeId(org.eclipse.winery.model.ids.definitions.CapabilityTypeId) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) ArrayList(java.util.ArrayList) RelationshipTypeImplementationId(org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId) ArtifactTemplateId(org.eclipse.winery.model.ids.definitions.ArtifactTemplateId) PolicyTypeId(org.eclipse.winery.model.ids.definitions.PolicyTypeId) InterfaceTypeId(org.eclipse.winery.model.ids.definitions.InterfaceTypeId) DataTypeId(org.eclipse.winery.model.ids.definitions.DataTypeId) RequirementTypeId(org.eclipse.winery.model.ids.definitions.RequirementTypeId) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions)

Aggregations

DataTypeId (org.eclipse.winery.model.ids.definitions.DataTypeId)3 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)2 ArtifactTypeId (org.eclipse.winery.model.ids.definitions.ArtifactTypeId)2 CapabilityTypeId (org.eclipse.winery.model.ids.definitions.CapabilityTypeId)2 InterfaceTypeId (org.eclipse.winery.model.ids.definitions.InterfaceTypeId)2 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)2 NodeTypeImplementationId (org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId)2 PolicyTypeId (org.eclipse.winery.model.ids.definitions.PolicyTypeId)2 RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)2 RelationshipTypeImplementationId (org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId)2 RequirementTypeId (org.eclipse.winery.model.ids.definitions.RequirementTypeId)2 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)2 TDefinitions (org.eclipse.winery.model.tosca.TDefinitions)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 PolicyTemplateId (org.eclipse.winery.model.ids.definitions.PolicyTemplateId)1 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)1 XSDImportId (org.eclipse.winery.model.ids.definitions.imports.XSDImportId)1 ComplianceRuleId (org.eclipse.winery.model.ids.extensions.ComplianceRuleId)1 PatternRefinementModelId (org.eclipse.winery.model.ids.extensions.PatternRefinementModelId)1