Search in sources :

Example 6 with RelationshipTypeId

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

the class Splitting method getInputParamListofIncomingRelationshipTemplates.

public List<TParameter> getInputParamListofIncomingRelationshipTemplates(TTopologyTemplate topologyTemplate, List<TRelationshipTemplate> listOfIncomingRelationshipTemplates) {
    List<TParameter> listOfInputs = new ArrayList<>();
    IRepository repo = RepositoryFactory.getRepository();
    for (TRelationshipTemplate incomingRelationshipTemplate : listOfIncomingRelationshipTemplates) {
        TNodeTemplate incomingNodetemplate = ModelUtilities.getSourceNodeTemplateOfRelationshipTemplate(topologyTemplate, incomingRelationshipTemplate);
        NodeTypeId incomingNodeTypeId = new NodeTypeId(incomingNodetemplate.getType());
        TNodeType incomingNodeType = repo.getElement(incomingNodeTypeId);
        List<TInterface> incomingNodeTypeInterfaces = incomingNodeType.getInterfaces();
        RelationshipTypeId incomingRelationshipTypeId = new RelationshipTypeId(incomingRelationshipTemplate.getType());
        if (!incomingNodeTypeInterfaces.isEmpty()) {
            TInterface relevantInterface = null;
            List<TInterface> connectionInterfaces = incomingNodeTypeInterfaces.stream().filter(tInterface -> tInterface.getIdFromIdOrNameField().contains("connection")).collect(Collectors.toList());
            if (connectionInterfaces.size() > 1) {
                TNodeTemplate targetNodeTemplate = ModelUtilities.getTargetNodeTemplateOfRelationshipTemplate(topologyTemplate, incomingRelationshipTemplate);
                for (TInterface tInterface : connectionInterfaces) {
                    int separator = tInterface.getIdFromIdOrNameField().lastIndexOf("/");
                    String prefixRelation = tInterface.getIdFromIdOrNameField().substring(separator + 1);
                    if (targetNodeTemplate.getName() != null && targetNodeTemplate.getName().toLowerCase().contains(prefixRelation.toLowerCase())) {
                        relevantInterface = tInterface;
                    }
                }
            } else {
                relevantInterface = connectionInterfaces.get(0);
            }
            if (relevantInterface != null) {
                for (TOperation tOperation : relevantInterface.getOperations()) {
                    List<TParameter> inputParameters = tOperation.getInputParameters();
                    if (inputParameters != null) {
                        listOfInputs.addAll(inputParameters);
                    }
                }
            }
        }
    }
    return listOfInputs;
}
Also used : SortedSet(java.util.SortedSet) RequirementTypeId(org.eclipse.winery.model.ids.definitions.RequirementTypeId) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) ArrayList(java.util.ArrayList) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) TParameter(org.eclipse.winery.model.tosca.TParameter) TCapabilityType(org.eclipse.winery.model.tosca.TCapabilityType) VersionSupport(org.eclipse.winery.model.version.VersionSupport) BackendUtils(org.eclipse.winery.repository.backend.BackendUtils) Map(java.util.Map) TRequirement(org.eclipse.winery.model.tosca.TRequirement) Util(org.eclipse.winery.repository.common.Util) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) ListUtils.listIsNotNullOrEmpty(org.eclipse.winery.common.ListUtils.listIsNotNullOrEmpty) Set(java.util.Set) IOException(java.io.IOException) TNodeType(org.eclipse.winery.model.tosca.TNodeType) Collectors(java.util.stream.Collectors) TInterface(org.eclipse.winery.model.tosca.TInterface) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) RepositoryFactory(org.eclipse.winery.repository.backend.RepositoryFactory) CapabilityTypeId(org.eclipse.winery.model.ids.definitions.CapabilityTypeId) Objects(java.util.Objects) List(java.util.List) DASpecification(org.eclipse.winery.repository.driverspecificationandinjection.DASpecification) TCapability(org.eclipse.winery.model.tosca.TCapability) IRepository(org.eclipse.winery.repository.backend.IRepository) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) Optional(java.util.Optional) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) TOperation(org.eclipse.winery.model.tosca.TOperation) ModelUtilities(org.eclipse.winery.model.tosca.utils.ModelUtilities) DriverInjection(org.eclipse.winery.repository.driverspecificationandinjection.DriverInjection) QName(javax.xml.namespace.QName) TRequirementType(org.eclipse.winery.model.tosca.TRequirementType) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) TInterface(org.eclipse.winery.model.tosca.TInterface) ArrayList(java.util.ArrayList) TNodeType(org.eclipse.winery.model.tosca.TNodeType) TOperation(org.eclipse.winery.model.tosca.TOperation) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) TParameter(org.eclipse.winery.model.tosca.TParameter) IRepository(org.eclipse.winery.repository.backend.IRepository) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Example 7 with RelationshipTypeId

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

the class Splitting method getMatchingRelationshipType.

/**
 */
private TRelationshipType getMatchingRelationshipType(TRequirement requirement, TCapability capability) {
    TRelationshipType matchingRelationshipType = null;
    SortedSet<RelationshipTypeId> relTypeIds = RepositoryFactory.getRepository().getAllDefinitionsChildIds(RelationshipTypeId.class);
    List<TRelationshipType> relationshipTypes = new ArrayList<>();
    for (RelationshipTypeId id : relTypeIds) {
        relationshipTypes.add(RepositoryFactory.getRepository().getElement(id));
    }
    Map<String, String> requirementProperties = ModelUtilities.getPropertiesKV(requirement);
    Map<String, String> capabilityProperties = ModelUtilities.getPropertiesKV(capability);
    /* If the property "requiredRelationshipType" is defined for the requirement and the capability this relationship type
           has to be taken - if the specified relationship type is not available, no relationship type is chosen */
    if (requirementProperties != null && capabilityProperties != null && requirementProperties.containsKey("requiredRelationshipType") && capabilityProperties.containsKey("requiredRelationshipType") && requirementProperties.get("requiredRelationshipType").equals(capabilityProperties.get("requiredRelationshipType")) && requirementProperties.get("requiredRelationshipType") != null) {
        // Assumption: We work on basic KV properties here
        QName referencedRelationshipType = QName.valueOf((String) requirementProperties.get("requiredRelationshipType"));
        RelationshipTypeId relTypeId = new RelationshipTypeId(referencedRelationshipType);
        if (relTypeIds.stream().anyMatch(rti -> rti.equals(relTypeId))) {
            return RepositoryFactory.getRepository().getElement(relTypeId);
        }
    } else {
        QName requirementTypeQName = requirement.getType();
        RequirementTypeId reqTypeId = new RequirementTypeId(requirement.getType());
        TRequirementType requirementType = RepositoryFactory.getRepository().getElement(reqTypeId);
        QName capabilityTypeQName = capability.getType();
        CapabilityTypeId capTypeId = new CapabilityTypeId(capability.getType());
        TCapabilityType capabilityType = RepositoryFactory.getRepository().getElement(capTypeId);
        List<TRelationshipType> availableMatchingRelationshipTypes = new ArrayList<>();
        availableMatchingRelationshipTypes.clear();
        while (requirementType != null && capabilityType != null) {
            // relationship type with valid source origin requirement type or empty and valid target origin capability type
            for (TRelationshipType rt : relationshipTypes) {
                if ((rt.getValidSource() == null || rt.getValidSource().getTypeRef().equals(requirementTypeQName)) && (rt.getValidTarget() != null && rt.getValidTarget().getTypeRef().equals(capabilityTypeQName))) {
                    availableMatchingRelationshipTypes.add(rt);
                }
            }
            if (!availableMatchingRelationshipTypes.isEmpty() && availableMatchingRelationshipTypes.size() == 1) {
                return availableMatchingRelationshipTypes.get(0);
            } else if (!availableMatchingRelationshipTypes.isEmpty() && availableMatchingRelationshipTypes.size() > 1) {
                return null;
            } else if (requirementType.getDerivedFrom() != null || capabilityType.getDerivedFrom() != null) {
                TCapabilityType derivedFromCapabilityType = null;
                TRequirementType derivedFromRequirementType = null;
                availableMatchingRelationshipTypes.clear();
                List<TRelationshipType> additionalMatchingRelationshipTypes = new ArrayList<>();
                if (capabilityType.getDerivedFrom() != null) {
                    QName derivedFromCapabilityTypeRef = capabilityType.getDerivedFrom().getTypeRef();
                    CapabilityTypeId derivedFromCapTypeId = new CapabilityTypeId(derivedFromCapabilityTypeRef);
                    derivedFromCapabilityType = RepositoryFactory.getRepository().getElement(derivedFromCapTypeId);
                    for (TRelationshipType rt : relationshipTypes) {
                        if ((rt.getValidSource() == null || rt.getValidSource().getTypeRef().equals(requirementTypeQName)) && (rt.getValidTarget() != null && rt.getValidTarget().getTypeRef().equals(derivedFromCapabilityTypeRef))) {
                            availableMatchingRelationshipTypes.add(rt);
                        }
                    }
                }
                if (requirementType.getDerivedFrom() != null) {
                    QName derivedFromRequirementTypeRef = requirementType.getDerivedFrom().getTypeRef();
                    RequirementTypeId derivedFromReqTypeId = new RequirementTypeId(derivedFromRequirementTypeRef);
                    derivedFromRequirementType = RepositoryFactory.getRepository().getElement(derivedFromReqTypeId);
                    for (TRelationshipType rt : relationshipTypes) {
                        if ((rt.getValidSource() != null && rt.getValidSource().getTypeRef().equals(derivedFromRequirementTypeRef)) && (rt.getValidTarget() != null && rt.getValidTarget().getTypeRef().equals(capabilityTypeQName))) {
                            additionalMatchingRelationshipTypes.add(rt);
                        }
                    }
                }
                availableMatchingRelationshipTypes.addAll(additionalMatchingRelationshipTypes);
                if (!availableMatchingRelationshipTypes.isEmpty() && availableMatchingRelationshipTypes.size() == 1) {
                    return availableMatchingRelationshipTypes.get(0);
                } else if (!availableMatchingRelationshipTypes.isEmpty() && availableMatchingRelationshipTypes.size() > 1) {
                    return null;
                }
                requirementType = derivedFromRequirementType;
                capabilityType = derivedFromCapabilityType;
            }
        }
        TCapabilityType basisCapabilityType = getBasisCapabilityType(capability.getType());
        for (TRelationshipType relationshipType : relationshipTypes) {
            if (basisCapabilityType != null && basisCapabilityType.getName().equalsIgnoreCase("container") && relationshipType.getName().equalsIgnoreCase("hostedon") && relationshipType.getValidSource() == null && (relationshipType.getValidTarget() == null || relationshipType.getValidTarget().getTypeRef().getLocalPart().equalsIgnoreCase("container"))) {
                return relationshipType;
            }
            if (basisCapabilityType != null && basisCapabilityType.getName().equalsIgnoreCase("endpoint") && relationshipType.getName().equalsIgnoreCase("connectsto") && relationshipType.getValidSource() == null && (relationshipType.getValidTarget() == null || relationshipType.getValidTarget().getTypeRef().getLocalPart().equalsIgnoreCase("endpoint"))) {
                return relationshipType;
            }
        }
    }
    return matchingRelationshipType;
}
Also used : TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) CapabilityTypeId(org.eclipse.winery.model.ids.definitions.CapabilityTypeId) QName(javax.xml.namespace.QName) RequirementTypeId(org.eclipse.winery.model.ids.definitions.RequirementTypeId) ArrayList(java.util.ArrayList) TCapabilityType(org.eclipse.winery.model.tosca.TCapabilityType) TRequirementType(org.eclipse.winery.model.tosca.TRequirementType)

Example 8 with RelationshipTypeId

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

the class GenericArtifactsResource method findInterface.

private Optional<TInterface> findInterface(EntityTypeId id, String interfaceName) {
    TInterface i;
    List<TInterface> interfaces = new ArrayList<>();
    IRepository repository = RepositoryFactory.getRepository();
    if (this.res instanceof NodeTypeImplementationResource || this.res instanceof NodeTypeImplementationsResource) {
        TNodeType nodeType = repository.getElement((NodeTypeId) id);
        if (nodeType.getInterfaces() != null) {
            interfaces.addAll(nodeType.getInterfaces());
        }
    } else if (this.res instanceof RelationshipTypeImplementationResource || this.res instanceof RelationshipTypeImplementationsResource) {
        TRelationshipType relationshipType = repository.getElement((RelationshipTypeId) id);
        if (relationshipType.getSourceInterfaces() != null) {
            interfaces.addAll(relationshipType.getSourceInterfaces());
        }
        if (relationshipType.getTargetInterfaces() != null) {
            interfaces.addAll(relationshipType.getTargetInterfaces());
        }
        if (relationshipType.getInterfaces() != null) {
            interfaces.addAll(relationshipType.getInterfaces());
        }
    }
    Iterator<TInterface> it = interfaces.iterator();
    do {
        i = it.next();
        if (i.getName().equals(interfaceName)) {
            return Optional.of(i);
        }
    } while (it.hasNext());
    return Optional.empty();
}
Also used : TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) RelationshipTypeImplementationsResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationsResource) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) TInterface(org.eclipse.winery.model.tosca.TInterface) INodeTemplateResourceOrNodeTypeImplementationResourceOrRelationshipTypeImplementationResource(org.eclipse.winery.repository.rest.resources._support.INodeTemplateResourceOrNodeTypeImplementationResourceOrRelationshipTypeImplementationResource) RelationshipTypeImplementationResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationResource) NodeTypeImplementationsResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationsResource) ArrayList(java.util.ArrayList) NodeTypeImplementationResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource) IRepository(org.eclipse.winery.repository.backend.IRepository) TNodeType(org.eclipse.winery.model.tosca.TNodeType)

Example 9 with RelationshipTypeId

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

the class DataFlowResource method parseDataFlowToServiceTemplate.

@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response parseDataFlowToServiceTemplate(DataFlowModel dataFlowModel) {
    if (Objects.isNull(dataFlowModel)) {
        return Response.status(Response.Status.BAD_REQUEST).entity("Passed data flow model is null!").build();
    }
    if (Objects.isNull(dataFlowModel.getId().getNamespaceURI())) {
        return Response.status(Response.Status.BAD_REQUEST).entity("Namespace must be defined for the data flow " + "model ID!").build();
    }
    IRepository repo = RepositoryFactory.getRepository();
    ServiceTemplateId templateId = new ServiceTemplateId(dataFlowModel.getId());
    if (repo.exists(templateId)) {
        return Response.status(Response.Status.CONFLICT).entity("ServiceTemplate with name of the data flow model already exists!").build();
    }
    TDefinitions definitions = BackendUtils.createWrapperDefinitionsAndInitialEmptyElement(repo, templateId);
    TServiceTemplate serviceTemplate = definitions.getServiceTemplates().stream().filter(template -> template.getId().equals(templateId.getQName().getLocalPart()) && templateId.getQName().getNamespaceURI().equals(template.getTargetNamespace())).findFirst().orElse(null);
    if (Objects.isNull(serviceTemplate)) {
        return Response.serverError().entity("Unable to create ServiceTemplate for the given data flow model!").build();
    }
    TTopologyTemplate topology = serviceTemplate.getTopologyTemplate();
    if (Objects.isNull(topology)) {
        topology = new TTopologyTemplate.Builder().build();
    }
    // iterate over all filters of the data flow and create corresponding NodeTemplates
    for (DataFlowModel.Filter filter : dataFlowModel.getFilters()) {
        if (Objects.isNull(filter.getType())) {
            return Response.serverError().entity("Type is missing for a filter!").build();
        }
        NodeTypeId nodeTypeId = BackendUtils.getDefinitionsChildId(NodeTypeId.class, filter.getType());
        if (!repo.exists(nodeTypeId)) {
            TNodeType newNodeType = new TNodeType.Builder(nodeTypeId.getQName().getLocalPart()).setTargetNamespace(nodeTypeId.getQName().getNamespaceURI()).build();
            try {
                BackendUtils.persist(repo, nodeTypeId, newNodeType);
            } catch (IOException e) {
                return Response.serverError().entity("Unable to create NodeType " + filter.getType() + " which is not contained in the repository!").build();
            }
        }
        topology = handleFilter(topology, nodeTypeId, filter.getId(), filter.getProperties(), filter.getArtifacts(), filter.getLocation(), filter.getProvider());
        if (Objects.isNull(topology)) {
            return Response.serverError().entity("Unable to handle filter with name: " + filter.getId()).build();
        }
    }
    // without available connectsTo RelationshipType the transformation can not be done
    RelationshipTypeId relationTypeId = BackendUtils.getDefinitionsChildId(RelationshipTypeId.class, ToscaBaseTypes.connectsToRelationshipType);
    if (!repo.exists(relationTypeId)) {
        return Response.serverError().entity("Unable to parse data flow model without available connectsTo " + "RelationshipType!").build();
    }
    // create connectsTo RelationshipTemplates between NodeTemplates corresponding to connected filters
    for (DataFlowModel.Pipes pipe : dataFlowModel.getPipes()) {
        if (Objects.isNull(pipe.getSource()) || Objects.isNull(pipe.getTarget())) {
            return Response.serverError().entity("Unable to create RelationshipTemplate for pipe with source or " + "target equal to null!").build();
        }
        TNodeTemplate source = topology.getNodeTemplate(pipe.getSource());
        TNodeTemplate target = topology.getNodeTemplate(pipe.getTarget());
        if (Objects.isNull(source) || Objects.isNull(target)) {
            return Response.serverError().entity("Unable to find NodeTemplates for relation with source: " + pipe.getSource() + " and target: " + pipe.getTarget()).build();
        }
        TRelationshipTemplate relationshipTemplate = createRelationshipTemplate(relationTypeId, source, target, pipe.getDataTransferType());
        if (Objects.isNull(relationshipTemplate)) {
            return Response.serverError().entity("Unable to create RelationshipTemplate between " + source.getId() + " and " + target.getId()).build();
        }
        topology.addRelationshipTemplate(relationshipTemplate);
    }
    serviceTemplate.setTopologyTemplate(topology);
    try {
        BackendUtils.persist(repo, templateId, definitions);
        return Response.created(new URI(RestUtils.getAbsoluteURL(templateId))).build();
    } catch (IOException e) {
        return Response.serverError().entity("IOException while persisting ServiceTemplate for data flow model!").build();
    } catch (URISyntaxException e) {
        return Response.serverError().entity("Unable to parse URI for created ServiceTemplate!").build();
    }
}
Also used : RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) DataFlowModel(org.eclipse.winery.repository.rest.resources.apiData.DataFlowModel) URI(java.net.URI) TNodeType(org.eclipse.winery.model.tosca.TNodeType) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) IRepository(org.eclipse.winery.repository.backend.IRepository) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 10 with RelationshipTypeId

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

the class IRepository method getReferencedDefinitionsChildIds.

default Collection<DefinitionsChildId> getReferencedDefinitionsChildIds(ServiceTemplateId id) {
    // We have to use a HashSet to ensure that no duplicate ids are added<
    // E.g., there may be multiple relationship templates having the same type
    Collection<DefinitionsChildId> ids = new HashSet<>();
    TServiceTemplate serviceTemplate = this.getElement(id);
    // add included things to export queue
    TBoundaryDefinitions boundaryDefs;
    if ((boundaryDefs = serviceTemplate.getBoundaryDefinitions()) != null) {
        List<TPolicy> policies = boundaryDefs.getPolicies();
        if (policies != null) {
            for (TPolicy policy : policies) {
                PolicyTypeId policyTypeId = new PolicyTypeId(policy.getPolicyType());
                ids.add(policyTypeId);
                PolicyTemplateId policyTemplateId = new PolicyTemplateId(policy.getPolicyRef());
                ids.add(policyTemplateId);
            }
        }
    // reqs and caps don't have to be exported here as they are references to existing reqs/caps (of nested node templates)
    }
    final TTopologyTemplate topology = serviceTemplate.getTopologyTemplate();
    if (topology != null) {
        if (Objects.nonNull(topology.getPolicies())) {
            topology.getPolicies().stream().filter(Objects::nonNull).forEach(p -> {
                QName type = p.getPolicyType();
                PolicyTypeId policyTypeIdId = new PolicyTypeId(type);
                ids.add(policyTypeIdId);
            });
        }
        for (TEntityTemplate entityTemplate : topology.getNodeTemplateOrRelationshipTemplate()) {
            QName qname = entityTemplate.getType();
            if (entityTemplate instanceof TNodeTemplate) {
                ids.add(new NodeTypeId(qname));
                TNodeTemplate n = (TNodeTemplate) entityTemplate;
                // crawl through policies
                List<TPolicy> policies = n.getPolicies();
                if (policies != null) {
                    for (TPolicy pol : policies) {
                        QName type = pol.getPolicyType();
                        PolicyTypeId ctId = new PolicyTypeId(type);
                        ids.add(ctId);
                        QName template = pol.getPolicyRef();
                        if (template != null) {
                            PolicyTemplateId policyTemplateId = new PolicyTemplateId(template);
                            ids.add(policyTemplateId);
                        }
                    }
                }
                // Crawl RequirementTypes and Capabilities for their references
                getReferencedRequirementTypeIds(ids, n);
                getCapabilitiesReferences(ids, n);
                // TODO: this information is collected differently for YAML and XML modes
                // crawl through deployment artifacts
                List<TDeploymentArtifact> deploymentArtifacts = n.getDeploymentArtifacts();
                if (deploymentArtifacts != null) {
                    for (TDeploymentArtifact da : deploymentArtifacts) {
                        if (da.getArtifactType() != null) {
                            // This is considered Nullable, because the test case ConsistencyCheckerTest#hasError
                            // expects an empty artifactType and thus it may be null.
                            ids.add(new ArtifactTypeId(da.getArtifactType()));
                        }
                        if (da.getArtifactRef() != null) {
                            ids.add(new ArtifactTemplateId(da.getArtifactRef()));
                        }
                    }
                }
                // Store all referenced artifact types
                List<TArtifact> artifacts = n.getArtifacts();
                if (Objects.nonNull(artifacts)) {
                    artifacts.forEach(a -> ids.add(new ArtifactTypeId(a.getType())));
                }
                TNodeType nodeType = this.getElement(new NodeTypeId(qname));
                if (Objects.nonNull(nodeType.getInterfaceDefinitions())) {
                    nodeType.getInterfaceDefinitions().stream().filter(Objects::nonNull).forEach(iDef -> {
                        if (Objects.nonNull(iDef.getType())) {
                            ids.add(new InterfaceTypeId(iDef.getType()));
                        }
                    });
                }
            } else {
                assert (entityTemplate instanceof TRelationshipTemplate);
                ids.add(new RelationshipTypeId(qname));
            }
        }
    }
    return ids;
}
Also used : RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) DefinitionsChildId(org.eclipse.winery.model.ids.definitions.DefinitionsChildId) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) ArtifactTypeId(org.eclipse.winery.model.ids.definitions.ArtifactTypeId) QName(javax.xml.namespace.QName) TBoundaryDefinitions(org.eclipse.winery.model.tosca.TBoundaryDefinitions) ArtifactTemplateId(org.eclipse.winery.model.ids.definitions.ArtifactTemplateId) TNodeType(org.eclipse.winery.model.tosca.TNodeType) PolicyTypeId(org.eclipse.winery.model.ids.definitions.PolicyTypeId) InterfaceTypeId(org.eclipse.winery.model.ids.definitions.InterfaceTypeId) TArtifact(org.eclipse.winery.model.tosca.TArtifact) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) TPolicy(org.eclipse.winery.model.tosca.TPolicy) PolicyTemplateId(org.eclipse.winery.model.ids.definitions.PolicyTemplateId) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) HashSet(java.util.HashSet) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate)

Aggregations

RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)18 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)12 QName (javax.xml.namespace.QName)9 TNodeType (org.eclipse.winery.model.tosca.TNodeType)9 TRelationshipType (org.eclipse.winery.model.tosca.TRelationshipType)9 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)7 CapabilityTypeId (org.eclipse.winery.model.ids.definitions.CapabilityTypeId)7 DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)7 ArrayList (java.util.ArrayList)6 ArtifactTypeId (org.eclipse.winery.model.ids.definitions.ArtifactTypeId)6 NodeTypeImplementationId (org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId)6 PolicyTypeId (org.eclipse.winery.model.ids.definitions.PolicyTypeId)6 RequirementTypeId (org.eclipse.winery.model.ids.definitions.RequirementTypeId)6 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)6 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)6 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)6 RelationshipTypeImplementationId (org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId)5 TDefinitions (org.eclipse.winery.model.tosca.TDefinitions)5 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)5 HashSet (java.util.HashSet)4