Search in sources :

Example 1 with TInterfaceDefinition

use of org.eclipse.winery.model.tosca.TInterfaceDefinition in project winery by eclipse.

the class IRepository method getReferencedDefinitionsChildIds.

default Collection<DefinitionsChildId> getReferencedDefinitionsChildIds(NodeTypeId id) {
    Collection<NodeTypeImplementationId> allNodeTypeImplementations = this.getAllElementsReferencingGivenType(NodeTypeImplementationId.class, id.getQName());
    Collection<DefinitionsChildId> ids = new HashSet<>(allNodeTypeImplementations);
    final TNodeType nodeType = this.getElement(id);
    // Add all referenced requirement types, but only in XML mode.
    // For YAML mode add referenced RelationshipType and CapabilityType, if present
    List<TRequirementDefinition> reqDefs = nodeType.getRequirementDefinitions();
    if (reqDefs != null) {
        for (TRequirementDefinition reqDef : reqDefs) {
            // if either of these is set, we're dealing with a type defined in YAML
            if (Objects.nonNull(reqDef.getRelationship()) || Objects.nonNull(reqDef.getCapability()) || Objects.nonNull(reqDef.getNode())) {
                if (Objects.nonNull(reqDef.getRelationship())) {
                    ids.add(new RelationshipTypeId(reqDef.getRelationship()));
                }
                if (Objects.nonNull(reqDef.getCapability())) {
                    ids.add(new CapabilityTypeId(reqDef.getCapability()));
                }
                if (Objects.nonNull(reqDef.getNode())) {
                    ids.add(new NodeTypeId(reqDef.getNode()));
                }
            } else {
                RequirementTypeId reqTypeId = new RequirementTypeId(reqDef.getRequirementType());
                ids.add(reqTypeId);
            }
        }
    }
    // add all referenced capability types
    List<TCapabilityDefinition> capabilityDefinitions = nodeType.getCapabilityDefinitions();
    if (capabilityDefinitions != null) {
        for (TCapabilityDefinition capDef : capabilityDefinitions) {
            CapabilityTypeId capTypeId = new CapabilityTypeId(capDef.getCapabilityType());
            ids.add(capTypeId);
            // Add all types referenced in valid source types
            if (Objects.nonNull(capDef.getValidSourceTypes())) {
                capDef.getValidSourceTypes().forEach(sourceType -> ids.add(new NodeTypeId(sourceType)));
            }
        }
    }
    List<TInterfaceDefinition> interfaceDefinitions = nodeType.getInterfaceDefinitions();
    if (Objects.nonNull(interfaceDefinitions) && !interfaceDefinitions.isEmpty()) {
        for (TInterfaceDefinition intDef : interfaceDefinitions) {
            InterfaceTypeId interfaceTypeId = new InterfaceTypeId(intDef.getType());
            ids.add(interfaceTypeId);
        }
    }
    // Store all referenced artifact types
    List<TArtifact> artifacts = nodeType.getArtifacts();
    if (Objects.nonNull(artifacts)) {
        artifacts.forEach(a -> ids.add(new ArtifactTypeId(a.getType())));
    }
    getReferencedDefinitionsOfProperties(ids, nodeType.getProperties());
    return ids;
}
Also used : NodeTypeImplementationId(org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) DefinitionsChildId(org.eclipse.winery.model.ids.definitions.DefinitionsChildId) CapabilityTypeId(org.eclipse.winery.model.ids.definitions.CapabilityTypeId) ArtifactTypeId(org.eclipse.winery.model.ids.definitions.ArtifactTypeId) TNodeType(org.eclipse.winery.model.tosca.TNodeType) InterfaceTypeId(org.eclipse.winery.model.ids.definitions.InterfaceTypeId) RequirementTypeId(org.eclipse.winery.model.ids.definitions.RequirementTypeId) TArtifact(org.eclipse.winery.model.tosca.TArtifact) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) TRequirementDefinition(org.eclipse.winery.model.tosca.TRequirementDefinition) TCapabilityDefinition(org.eclipse.winery.model.tosca.TCapabilityDefinition) TInterfaceDefinition(org.eclipse.winery.model.tosca.TInterfaceDefinition) HashSet(java.util.HashSet)

Example 2 with TInterfaceDefinition

use of org.eclipse.winery.model.tosca.TInterfaceDefinition in project winery by eclipse.

the class ToCanonical method convert.

private TInterfaceDefinition convert(YTInterfaceDefinition node, String id) {
    if (Objects.isNull(node)) {
        return null;
    }
    TInterfaceDefinition def = new TInterfaceDefinition();
    def.setId(id);
    def.setName(id);
    def.setType(node.getType());
    def.setInputs(convert(node.getInputs()));
    def.setOperations(convert(node.getOperations()));
    return def;
}
Also used : YTInterfaceDefinition(org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition) TInterfaceDefinition(org.eclipse.winery.model.tosca.TInterfaceDefinition)

Aggregations

TInterfaceDefinition (org.eclipse.winery.model.tosca.TInterfaceDefinition)2 HashSet (java.util.HashSet)1 ArtifactTypeId (org.eclipse.winery.model.ids.definitions.ArtifactTypeId)1 CapabilityTypeId (org.eclipse.winery.model.ids.definitions.CapabilityTypeId)1 DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)1 InterfaceTypeId (org.eclipse.winery.model.ids.definitions.InterfaceTypeId)1 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)1 NodeTypeImplementationId (org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId)1 RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)1 RequirementTypeId (org.eclipse.winery.model.ids.definitions.RequirementTypeId)1 TArtifact (org.eclipse.winery.model.tosca.TArtifact)1 TCapabilityDefinition (org.eclipse.winery.model.tosca.TCapabilityDefinition)1 TNodeType (org.eclipse.winery.model.tosca.TNodeType)1 TRequirementDefinition (org.eclipse.winery.model.tosca.TRequirementDefinition)1 YTInterfaceDefinition (org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition)1