Search in sources :

Example 1 with TActivityDefinition

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

the class ToCanonical method convert.

public TActivityDefinition convert(YTMapActivityDefinition node) {
    if (Objects.isNull(node) || node.getMap().isEmpty()) {
        return null;
    }
    for (YTActivityDefinition value : node.getMap().values()) {
        if (value instanceof YTCallOperationActivityDefinition) {
            YTCallOperationActivityDefinition yamlDef = (YTCallOperationActivityDefinition) value;
            TCallOperationActivityDefinition canonicalDef = new TCallOperationActivityDefinition(yamlDef.getOperation());
            List<ParameterDefinition> inputs = yamlDef.getInputs().entrySet().stream().map(entry -> convert(entry.getValue(), entry.getKey())).collect(Collectors.toList());
            canonicalDef.setInputs(inputs);
            return canonicalDef;
        }
    }
    return null;
}
Also used : TEventFilterDefinition(org.eclipse.winery.model.tosca.TEventFilterDefinition) Arrays(java.util.Arrays) TBoundaryDefinitions(org.eclipse.winery.model.tosca.TBoundaryDefinitions) YTImportDefinition(org.eclipse.winery.model.tosca.yaml.YTImportDefinition) TArtifact(org.eclipse.winery.model.tosca.TArtifact) ValueHelper(org.eclipse.winery.model.tosca.yaml.support.ValueHelper) HasInheritance(org.eclipse.winery.model.tosca.HasInheritance) StringUtils(org.apache.commons.lang3.StringUtils) YTTriggerDefinition(org.eclipse.winery.model.tosca.yaml.YTTriggerDefinition) EncodingUtil(org.eclipse.winery.model.ids.EncodingUtil) TRelationshipTypeImplementation(org.eclipse.winery.model.tosca.TRelationshipTypeImplementation) YTPolicyDefinition(org.eclipse.winery.model.tosca.yaml.YTPolicyDefinition) YTRequirementDefinition(org.eclipse.winery.model.tosca.yaml.YTRequirementDefinition) YTMapActivityDefinition(org.eclipse.winery.model.tosca.yaml.support.YTMapActivityDefinition) Map(java.util.Map) TArtifactType(org.eclipse.winery.model.tosca.TArtifactType) Defaults(org.eclipse.winery.model.converter.support.Defaults) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) TEntityType(org.eclipse.winery.model.tosca.TEntityType) TActivityDefinition(org.eclipse.winery.model.tosca.TActivityDefinition) Set(java.util.Set) TImplementation(org.eclipse.winery.model.tosca.TImplementation) YTTopologyTemplateDefinition(org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition) YTPropertyAssignment(org.eclipse.winery.model.tosca.yaml.YTPropertyAssignment) Stream(java.util.stream.Stream) YTGroupDefinition(org.eclipse.winery.model.tosca.yaml.YTGroupDefinition) YTPropertyDefinition(org.eclipse.winery.model.tosca.yaml.YTPropertyDefinition) TCapability(org.eclipse.winery.model.tosca.TCapability) YTRequirementAssignment(org.eclipse.winery.model.tosca.yaml.YTRequirementAssignment) QName(javax.xml.namespace.QName) TRequirementType(org.eclipse.winery.model.tosca.TRequirementType) NonNull(org.eclipse.jdt.annotation.NonNull) TPolicy(org.eclipse.winery.model.tosca.TPolicy) YTNodeType(org.eclipse.winery.model.tosca.yaml.YTNodeType) TRequirementDefinition(org.eclipse.winery.model.tosca.TRequirementDefinition) TypeConverter(org.eclipse.winery.repository.yaml.converter.support.TypeConverter) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) YTActivityDefinition(org.eclipse.winery.model.tosca.yaml.YTActivityDefinition) YTNodeTemplate(org.eclipse.winery.model.tosca.yaml.YTNodeTemplate) TCapabilityType(org.eclipse.winery.model.tosca.TCapabilityType) TArtifactReference(org.eclipse.winery.model.tosca.TArtifactReference) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) TSchema(org.eclipse.winery.model.tosca.TSchema) YTCapabilityType(org.eclipse.winery.model.tosca.yaml.YTCapabilityType) TCapabilityDefinition(org.eclipse.winery.model.tosca.TCapabilityDefinition) YTOperationDefinition(org.eclipse.winery.model.tosca.yaml.YTOperationDefinition) YTImplementationArtifactDefinition(org.eclipse.winery.repository.yaml.converter.support.extension.YTImplementationArtifactDefinition) File(java.io.File) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) TCallOperationActivityDefinition(org.eclipse.winery.model.tosca.TCallOperationActivityDefinition) YTEntityType(org.eclipse.winery.model.tosca.yaml.YTEntityType) ParameterDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.ParameterDefinition) YTSchemaDefinition(org.eclipse.winery.model.tosca.yaml.YTSchemaDefinition) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) TGroupDefinition(org.eclipse.winery.model.tosca.TGroupDefinition) YTGroupType(org.eclipse.winery.model.tosca.yaml.YTGroupType) YTPropertyAssignmentOrDefinition(org.eclipse.winery.model.tosca.yaml.YTPropertyAssignmentOrDefinition) LoggerFactory(org.slf4j.LoggerFactory) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) TPolicyType(org.eclipse.winery.model.tosca.TPolicyType) Nullable(org.eclipse.jdt.annotation.Nullable) YTRelationshipType(org.eclipse.winery.model.tosca.yaml.YTRelationshipType) InheritanceUtils(org.eclipse.winery.repository.yaml.converter.support.InheritanceUtils) TRequirement(org.eclipse.winery.model.tosca.TRequirement) YTArtifactDefinition(org.eclipse.winery.model.tosca.yaml.YTArtifactDefinition) AttributeDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.AttributeDefinition) YTInterfaceDefinition(org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition) TTriggerDefinition(org.eclipse.winery.model.tosca.TTriggerDefinition) YTPolicyType(org.eclipse.winery.model.tosca.yaml.YTPolicyType) YTRelationshipTemplate(org.eclipse.winery.model.tosca.yaml.YTRelationshipTemplate) YTCapabilityAssignment(org.eclipse.winery.model.tosca.yaml.YTCapabilityAssignment) TNodeType(org.eclipse.winery.model.tosca.TNodeType) Collectors(java.util.stream.Collectors) TInterface(org.eclipse.winery.model.tosca.TInterface) YTInterfaceType(org.eclipse.winery.model.tosca.yaml.YTInterfaceType) Objects(java.util.Objects) TInterfaceType(org.eclipse.winery.model.tosca.TInterfaceType) List(java.util.List) IRepository(org.eclipse.winery.repository.backend.IRepository) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) YTCapabilityDefinition(org.eclipse.winery.model.tosca.yaml.YTCapabilityDefinition) AssignmentBuilder(org.eclipse.winery.repository.yaml.converter.support.AssignmentBuilder) TInterfaceDefinition(org.eclipse.winery.model.tosca.TInterfaceDefinition) YTParameterDefinition(org.eclipse.winery.model.tosca.yaml.YTParameterDefinition) YTCallOperationActivityDefinition(org.eclipse.winery.model.tosca.yaml.YTCallOperationActivityDefinition) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) HashMap(java.util.HashMap) YTImplementation(org.eclipse.winery.model.tosca.yaml.YTImplementation) Function(java.util.function.Function) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) HashSet(java.util.HashSet) YTAttributeDefinition(org.eclipse.winery.model.tosca.yaml.YTAttributeDefinition) ConstraintClauseKV(org.eclipse.winery.model.tosca.extensions.kvproperties.ConstraintClauseKV) TParameter(org.eclipse.winery.model.tosca.TParameter) YTArtifactType(org.eclipse.winery.model.tosca.yaml.YTArtifactType) TImport(org.eclipse.winery.model.tosca.TImport) Logger(org.slf4j.Logger) TGroupType(org.eclipse.winery.model.tosca.TGroupType) TImplementationArtifact(org.eclipse.winery.model.tosca.TImplementationArtifact) TOperationDefinition(org.eclipse.winery.model.tosca.TOperationDefinition) TTag(org.eclipse.winery.model.tosca.TTag) TDataType(org.eclipse.winery.model.tosca.TDataType) Namespaces(org.eclipse.winery.model.converter.support.Namespaces) YTMapRequirementAssignment(org.eclipse.winery.model.tosca.yaml.support.YTMapRequirementAssignment) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) YTConstraintClause(org.eclipse.winery.model.tosca.yaml.YTConstraintClause) YTDataType(org.eclipse.winery.model.tosca.yaml.YTDataType) Metadata(org.eclipse.winery.model.tosca.yaml.support.Metadata) Collections(java.util.Collections) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) YTActivityDefinition(org.eclipse.winery.model.tosca.yaml.YTActivityDefinition) YTCallOperationActivityDefinition(org.eclipse.winery.model.tosca.yaml.YTCallOperationActivityDefinition) TCallOperationActivityDefinition(org.eclipse.winery.model.tosca.TCallOperationActivityDefinition) YTCallOperationActivityDefinition(org.eclipse.winery.model.tosca.yaml.YTCallOperationActivityDefinition) ParameterDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.ParameterDefinition) YTParameterDefinition(org.eclipse.winery.model.tosca.yaml.YTParameterDefinition)

Example 2 with TActivityDefinition

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

the class FromCanonical method convert.

public YTMapActivityDefinition convert(TActivityDefinition node) {
    if (Objects.isNull(node)) {
        return null;
    }
    // TODO support other activity definition types
    if (node instanceof TCallOperationActivityDefinition) {
        TCallOperationActivityDefinition canonicalDef = (TCallOperationActivityDefinition) node;
        YTCallOperationActivityDefinition yamlDef = new YTCallOperationActivityDefinition(canonicalDef.getOperation());
        Map<String, YTParameterDefinition> inputs = canonicalDef.getInputs().stream().map(this::convert).flatMap(m -> m.entrySet().stream()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
        yamlDef.setInputs(inputs);
        return new YTMapActivityDefinition().setMap(Collections.singletonMap(YamlSpecKeywords.CALL_OPERATION, yamlDef));
    }
    return new YTMapActivityDefinition();
}
Also used : TBoundaryDefinitions(org.eclipse.winery.model.tosca.TBoundaryDefinitions) YTImportDefinition(org.eclipse.winery.model.tosca.yaml.YTImportDefinition) RequirementTypeId(org.eclipse.winery.model.ids.definitions.RequirementTypeId) TArtifact(org.eclipse.winery.model.tosca.TArtifact) YTTriggerDefinition(org.eclipse.winery.model.tosca.yaml.YTTriggerDefinition) TRelationshipTypeImplementation(org.eclipse.winery.model.tosca.TRelationshipTypeImplementation) YTPolicyDefinition(org.eclipse.winery.model.tosca.yaml.YTPolicyDefinition) YTRequirementDefinition(org.eclipse.winery.model.tosca.yaml.YTRequirementDefinition) YTMapActivityDefinition(org.eclipse.winery.model.tosca.yaml.support.YTMapActivityDefinition) Map(java.util.Map) TArtifactType(org.eclipse.winery.model.tosca.TArtifactType) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) TEntityType(org.eclipse.winery.model.tosca.TEntityType) TActivityDefinition(org.eclipse.winery.model.tosca.TActivityDefinition) Constants(org.eclipse.winery.common.Constants) TImplementation(org.eclipse.winery.model.tosca.TImplementation) YTRelationshipDefinition(org.eclipse.winery.model.tosca.yaml.YTRelationshipDefinition) WinerysPropertiesDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.WinerysPropertiesDefinition) YTTopologyTemplateDefinition(org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) CapabilityTypeId(org.eclipse.winery.model.ids.definitions.CapabilityTypeId) YTPropertyAssignment(org.eclipse.winery.model.tosca.yaml.YTPropertyAssignment) PropertyDefinitionKV(org.eclipse.winery.model.tosca.extensions.kvproperties.PropertyDefinitionKV) Stream(java.util.stream.Stream) YTGroupDefinition(org.eclipse.winery.model.tosca.yaml.YTGroupDefinition) YTPropertyDefinition(org.eclipse.winery.model.tosca.yaml.YTPropertyDefinition) TCapability(org.eclipse.winery.model.tosca.TCapability) YTRequirementAssignment(org.eclipse.winery.model.tosca.yaml.YTRequirementAssignment) QName(javax.xml.namespace.QName) TRequirementType(org.eclipse.winery.model.tosca.TRequirementType) NonNull(org.eclipse.jdt.annotation.NonNull) TPolicy(org.eclipse.winery.model.tosca.TPolicy) YTNodeType(org.eclipse.winery.model.tosca.yaml.YTNodeType) TRequirementDefinition(org.eclipse.winery.model.tosca.TRequirementDefinition) YTSubstitutionMappings(org.eclipse.winery.model.tosca.yaml.YTSubstitutionMappings) Defaults(org.eclipse.winery.model.tosca.yaml.support.Defaults) YTMapImportDefinition(org.eclipse.winery.model.tosca.yaml.support.YTMapImportDefinition) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) YTNodeTemplate(org.eclipse.winery.model.tosca.yaml.YTNodeTemplate) ArtifactTemplateId(org.eclipse.winery.model.ids.definitions.ArtifactTemplateId) TCapabilityType(org.eclipse.winery.model.tosca.TCapabilityType) TArtifactReference(org.eclipse.winery.model.tosca.TArtifactReference) DefinitionsChildId(org.eclipse.winery.model.ids.definitions.DefinitionsChildId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) TSchema(org.eclipse.winery.model.tosca.TSchema) ArtifactTypeId(org.eclipse.winery.model.ids.definitions.ArtifactTypeId) YTCapabilityType(org.eclipse.winery.model.tosca.yaml.YTCapabilityType) TCapabilityDefinition(org.eclipse.winery.model.tosca.TCapabilityDefinition) TDeploymentOrImplementationArtifact(org.eclipse.winery.model.tosca.TDeploymentOrImplementationArtifact) YTOperationDefinition(org.eclipse.winery.model.tosca.yaml.YTOperationDefinition) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) TCallOperationActivityDefinition(org.eclipse.winery.model.tosca.TCallOperationActivityDefinition) YTEntityType(org.eclipse.winery.model.tosca.yaml.YTEntityType) ParameterDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.ParameterDefinition) YTSchemaDefinition(org.eclipse.winery.model.tosca.yaml.YTSchemaDefinition) TOperation(org.eclipse.winery.model.tosca.TOperation) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) TGroupDefinition(org.eclipse.winery.model.tosca.TGroupDefinition) YTGroupType(org.eclipse.winery.model.tosca.yaml.YTGroupType) YamlSpecKeywords(org.eclipse.winery.model.tosca.yaml.support.YamlSpecKeywords) YTPropertyAssignmentOrDefinition(org.eclipse.winery.model.tosca.yaml.YTPropertyAssignmentOrDefinition) LoggerFactory(org.slf4j.LoggerFactory) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) TPolicyType(org.eclipse.winery.model.tosca.TPolicyType) YamlRepository(org.eclipse.winery.repository.yaml.YamlRepository) Nullable(org.eclipse.jdt.annotation.Nullable) YTRelationshipType(org.eclipse.winery.model.tosca.yaml.YTRelationshipType) TRequirement(org.eclipse.winery.model.tosca.TRequirement) YTArtifactDefinition(org.eclipse.winery.model.tosca.yaml.YTArtifactDefinition) AttributeDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.AttributeDefinition) YTInterfaceDefinition(org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition) TTriggerDefinition(org.eclipse.winery.model.tosca.TTriggerDefinition) YTPolicyType(org.eclipse.winery.model.tosca.yaml.YTPolicyType) YTRelationshipTemplate(org.eclipse.winery.model.tosca.yaml.YTRelationshipTemplate) HashBiMap(org.eclipse.collections.impl.bimap.mutable.HashBiMap) YTCapabilityAssignment(org.eclipse.winery.model.tosca.yaml.YTCapabilityAssignment) TDocumentation(org.eclipse.winery.model.tosca.TDocumentation) TNodeType(org.eclipse.winery.model.tosca.TNodeType) Collectors(java.util.stream.Collectors) TInterface(org.eclipse.winery.model.tosca.TInterface) YTInterfaceType(org.eclipse.winery.model.tosca.yaml.YTInterfaceType) Objects(java.util.Objects) TInterfaceType(org.eclipse.winery.model.tosca.TInterfaceType) YTEventFilterDefinition(org.eclipse.winery.model.tosca.yaml.YTEventFilterDefinition) YTRelationshipAssignment(org.eclipse.winery.model.tosca.yaml.YTRelationshipAssignment) List(java.util.List) YamlExporter(org.eclipse.winery.repository.yaml.export.YamlExporter) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) YTCapabilityDefinition(org.eclipse.winery.model.tosca.yaml.YTCapabilityDefinition) Optional(java.util.Optional) TInterfaceDefinition(org.eclipse.winery.model.tosca.TInterfaceDefinition) YTParameterDefinition(org.eclipse.winery.model.tosca.yaml.YTParameterDefinition) YTCallOperationActivityDefinition(org.eclipse.winery.model.tosca.yaml.YTCallOperationActivityDefinition) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) HashMap(java.util.HashMap) YTImplementation(org.eclipse.winery.model.tosca.yaml.YTImplementation) YTMapRequirementDefinition(org.eclipse.winery.model.tosca.yaml.support.YTMapRequirementDefinition) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) YTAttributeDefinition(org.eclipse.winery.model.tosca.yaml.YTAttributeDefinition) TypeConverter(org.eclipse.winery.model.converter.support.xml.TypeConverter) ConstraintClauseKV(org.eclipse.winery.model.tosca.extensions.kvproperties.ConstraintClauseKV) TParameter(org.eclipse.winery.model.tosca.TParameter) YTArtifactType(org.eclipse.winery.model.tosca.yaml.YTArtifactType) InterfaceTypeId(org.eclipse.winery.model.ids.definitions.InterfaceTypeId) TEntityTypeImplementation(org.eclipse.winery.model.tosca.TEntityTypeImplementation) PolicyTypeId(org.eclipse.winery.model.ids.definitions.PolicyTypeId) Logger(org.slf4j.Logger) TGroupType(org.eclipse.winery.model.tosca.TGroupType) TImplementationArtifact(org.eclipse.winery.model.tosca.TImplementationArtifact) TOperationDefinition(org.eclipse.winery.model.tosca.TOperationDefinition) TTag(org.eclipse.winery.model.tosca.TTag) TDataType(org.eclipse.winery.model.tosca.TDataType) Namespaces(org.eclipse.winery.model.converter.support.Namespaces) YTMapRequirementAssignment(org.eclipse.winery.model.tosca.yaml.support.YTMapRequirementAssignment) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) YTConstraintClause(org.eclipse.winery.model.tosca.yaml.YTConstraintClause) YTDataType(org.eclipse.winery.model.tosca.yaml.YTDataType) Metadata(org.eclipse.winery.model.tosca.yaml.support.Metadata) Collections(java.util.Collections) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) YTMapActivityDefinition(org.eclipse.winery.model.tosca.yaml.support.YTMapActivityDefinition) YTCallOperationActivityDefinition(org.eclipse.winery.model.tosca.yaml.YTCallOperationActivityDefinition) YTParameterDefinition(org.eclipse.winery.model.tosca.yaml.YTParameterDefinition) TCallOperationActivityDefinition(org.eclipse.winery.model.tosca.TCallOperationActivityDefinition) YTCallOperationActivityDefinition(org.eclipse.winery.model.tosca.yaml.YTCallOperationActivityDefinition) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashBiMap(org.eclipse.collections.impl.bimap.mutable.HashBiMap) HashMap(java.util.HashMap)

Aggregations

ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 QName (javax.xml.namespace.QName)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 Namespaces (org.eclipse.winery.model.converter.support.Namespaces)2 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)2 TActivityDefinition (org.eclipse.winery.model.tosca.TActivityDefinition)2 TArtifact (org.eclipse.winery.model.tosca.TArtifact)2 TArtifactReference (org.eclipse.winery.model.tosca.TArtifactReference)2 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)2 TArtifactType (org.eclipse.winery.model.tosca.TArtifactType)2 TBoundaryDefinitions (org.eclipse.winery.model.tosca.TBoundaryDefinitions)2