Search in sources :

Example 1 with XTEntityType

use of org.eclipse.winery.model.tosca.xml.XTEntityType in project winery by eclipse.

the class ToCanonical method fillEntityTypeProperties.

private <Builder extends TEntityType.Builder<Builder>, Value extends XTEntityType> void fillEntityTypeProperties(Builder builder, Value xml) {
    if (xml.getTags() != null) {
        builder.addTags(xml.getTags().stream().map(this::convert).collect(Collectors.toList()));
    }
    if (xml.getDerivedFrom() != null) {
        TEntityType.DerivedFrom derived = new TEntityType.DerivedFrom();
        derived.setTypeRef(xml.getDerivedFrom().getTypeRef());
        builder.setDerivedFrom(derived);
    }
    if (xml.getPropertiesDefinition() != null) {
        if (xml.getPropertiesDefinition().getElement() != null) {
            builder.setProperties(new TEntityType.XmlElementDefinition(xml.getPropertiesDefinition().getElement()));
        } else if (xml.getPropertiesDefinition().getType() != null) {
            builder.setProperties(new TEntityType.XmlTypeDefinition(xml.getPropertiesDefinition().getType()));
        } else {
            throw new IllegalStateException("If a PropertiesDefinition is given, either Element or Type must be specified!");
        }
    }
    if (xml.getAny().stream().anyMatch(anyElement -> anyElement instanceof WinerysPropertiesDefinition)) {
        WinerysPropertiesDefinition def = xml.getAny().stream().filter(el -> el instanceof WinerysPropertiesDefinition).map(WinerysPropertiesDefinition.class::cast).findFirst().orElse(null);
        builder.setProperties(def);
        // remove the element we've recognized as a property to avoid duplicating it in the canonical model
        xml.getAny().remove(def);
    }
    builder.setAbstract(xml.getAbstract() == XTBoolean.YES);
    builder.setFinal(xml.getFinal() == XTBoolean.YES);
    builder.setTargetNamespace(xml.getTargetNamespace());
    fillExtensibleElementsProperties(builder, xml);
}
Also used : XHasId(org.eclipse.winery.model.tosca.xml.XHasId) XTPropertyConstraint(org.eclipse.winery.model.tosca.xml.XTPropertyConstraint) XTNodeType(org.eclipse.winery.model.tosca.xml.XTNodeType) TBoundaryDefinitions(org.eclipse.winery.model.tosca.TBoundaryDefinitions) TArtifact(org.eclipse.winery.model.tosca.TArtifact) XTCapabilityDefinition(org.eclipse.winery.model.tosca.xml.XTCapabilityDefinition) XTEntityType(org.eclipse.winery.model.tosca.xml.XTEntityType) OTTopologyFragmentRefinementModel(org.eclipse.winery.model.tosca.extensions.OTTopologyFragmentRefinementModel) XTInterface(org.eclipse.winery.model.tosca.xml.XTInterface) TRelationshipTypeImplementation(org.eclipse.winery.model.tosca.TRelationshipTypeImplementation) XTParameter(org.eclipse.winery.model.tosca.xml.XTParameter) OTComplianceRule(org.eclipse.winery.model.tosca.extensions.OTComplianceRule) XTConstraint(org.eclipse.winery.model.tosca.xml.XTConstraint) OTRelationDirection(org.eclipse.winery.model.tosca.extensions.OTRelationDirection) TArtifactType(org.eclipse.winery.model.tosca.TArtifactType) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) TEntityType(org.eclipse.winery.model.tosca.TEntityType) XTNodeTypeImplementation(org.eclipse.winery.model.tosca.xml.XTNodeTypeImplementation) XTRequirement(org.eclipse.winery.model.tosca.xml.XTRequirement) WinerysPropertiesDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.WinerysPropertiesDefinition) XTRelationshipTemplate(org.eclipse.winery.model.tosca.xml.XTRelationshipTemplate) XTOperation(org.eclipse.winery.model.tosca.xml.XTOperation) XTRelationshipType(org.eclipse.winery.model.tosca.xml.XTRelationshipType) XOTPropertyKV(org.eclipse.winery.model.tosca.xml.extensions.XOTPropertyKV) Stream(java.util.stream.Stream) TCapability(org.eclipse.winery.model.tosca.TCapability) XOTRelationMapping(org.eclipse.winery.model.tosca.xml.extensions.XOTRelationMapping) XTPlan(org.eclipse.winery.model.tosca.xml.XTPlan) QName(javax.xml.namespace.QName) TRequirementType(org.eclipse.winery.model.tosca.TRequirementType) TExtension(org.eclipse.winery.model.tosca.TExtension) NonNull(org.eclipse.jdt.annotation.NonNull) OTStringList(org.eclipse.winery.model.tosca.extensions.OTStringList) XOTPatternRefinementModel(org.eclipse.winery.model.tosca.xml.extensions.XOTPatternRefinementModel) TPolicy(org.eclipse.winery.model.tosca.TPolicy) XTPolicyTemplate(org.eclipse.winery.model.tosca.xml.XTPolicyTemplate) XTDeploymentArtifact(org.eclipse.winery.model.tosca.xml.XTDeploymentArtifact) XTArtifactTemplate(org.eclipse.winery.model.tosca.xml.XTArtifactTemplate) OTRelationMapping(org.eclipse.winery.model.tosca.extensions.OTRelationMapping) OTDeploymentArtifactMapping(org.eclipse.winery.model.tosca.extensions.OTDeploymentArtifactMapping) RelationshipSourceOrTarget(org.eclipse.winery.model.tosca.RelationshipSourceOrTarget) TRequirementDefinition(org.eclipse.winery.model.tosca.TRequirementDefinition) XTExportedInterface(org.eclipse.winery.model.tosca.xml.XTExportedInterface) XTRequirementDefinition(org.eclipse.winery.model.tosca.xml.XTRequirementDefinition) TExportedInterface(org.eclipse.winery.model.tosca.TExportedInterface) TCapabilityType(org.eclipse.winery.model.tosca.TCapabilityType) XOTPermutationMapping(org.eclipse.winery.model.tosca.xml.extensions.XOTPermutationMapping) TArtifactReference(org.eclipse.winery.model.tosca.TArtifactReference) XTPolicy(org.eclipse.winery.model.tosca.xml.XTPolicy) TCapabilityRef(org.eclipse.winery.model.tosca.TCapabilityRef) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) OTAttributeMappingType(org.eclipse.winery.model.tosca.extensions.OTAttributeMappingType) XOTTopologyFragmentRefinementModel(org.eclipse.winery.model.tosca.xml.extensions.XOTTopologyFragmentRefinementModel) XOTComplianceRule(org.eclipse.winery.model.tosca.xml.extensions.XOTComplianceRule) TCapabilityDefinition(org.eclipse.winery.model.tosca.TCapabilityDefinition) XTTag(org.eclipse.winery.model.tosca.xml.XTTag) OTStayMapping(org.eclipse.winery.model.tosca.extensions.OTStayMapping) TRequirementRef(org.eclipse.winery.model.tosca.TRequirementRef) OTParticipant(org.eclipse.winery.model.tosca.extensions.OTParticipant) XTEntityTypeImplementation(org.eclipse.winery.model.tosca.xml.XTEntityTypeImplementation) TPropertyMapping(org.eclipse.winery.model.tosca.TPropertyMapping) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) XOTStringList(org.eclipse.winery.model.tosca.xml.extensions.XOTStringList) XTNodeTemplate(org.eclipse.winery.model.tosca.xml.XTNodeTemplate) XTRequiredContainerFeature(org.eclipse.winery.model.tosca.xml.XTRequiredContainerFeature) XOTAttributeMapping(org.eclipse.winery.model.tosca.xml.extensions.XOTAttributeMapping) XTArtifactReference(org.eclipse.winery.model.tosca.xml.XTArtifactReference) XTExtension(org.eclipse.winery.model.tosca.xml.XTExtension) OTPrmMapping(org.eclipse.winery.model.tosca.extensions.OTPrmMapping) XTCondition(org.eclipse.winery.model.tosca.xml.XTCondition) TOperation(org.eclipse.winery.model.tosca.TOperation) XTImplementationArtifact(org.eclipse.winery.model.tosca.xml.XTImplementationArtifact) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) TGroupDefinition(org.eclipse.winery.model.tosca.TGroupDefinition) LoggerFactory(org.slf4j.LoggerFactory) XTRequirementType(org.eclipse.winery.model.tosca.xml.XTRequirementType) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) OTBehaviorPatternMapping(org.eclipse.winery.model.tosca.extensions.OTBehaviorPatternMapping) TPolicyType(org.eclipse.winery.model.tosca.TPolicyType) XTDocumentation(org.eclipse.winery.model.tosca.xml.XTDocumentation) Nullable(org.eclipse.jdt.annotation.Nullable) XTEntityTemplate(org.eclipse.winery.model.tosca.xml.XTEntityTemplate) TRequirement(org.eclipse.winery.model.tosca.TRequirement) OTRefinementModel(org.eclipse.winery.model.tosca.extensions.OTRefinementModel) OTTestRefinementModel(org.eclipse.winery.model.tosca.extensions.OTTestRefinementModel) XOTStayMapping(org.eclipse.winery.model.tosca.xml.extensions.XOTStayMapping) XTPolicyType(org.eclipse.winery.model.tosca.xml.XTPolicyType) XOTTestRefinementModel(org.eclipse.winery.model.tosca.xml.extensions.XOTTestRefinementModel) XTArtifact(org.eclipse.winery.model.tosca.xml.XTArtifact) TDocumentation(org.eclipse.winery.model.tosca.TDocumentation) TCondition(org.eclipse.winery.model.tosca.TCondition) TNodeType(org.eclipse.winery.model.tosca.TNodeType) Collectors(java.util.stream.Collectors) HasId(org.eclipse.winery.model.tosca.HasId) TInterface(org.eclipse.winery.model.tosca.TInterface) XOTPrmMapping(org.eclipse.winery.model.tosca.xml.extensions.XOTPrmMapping) Objects(java.util.Objects) XTCapability(org.eclipse.winery.model.tosca.xml.XTCapability) List(java.util.List) TExtensibleElements(org.eclipse.winery.model.tosca.TExtensibleElements) TPlan(org.eclipse.winery.model.tosca.TPlan) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) XTCapabilityRef(org.eclipse.winery.model.tosca.xml.XTCapabilityRef) XOTBehaviorPatternMapping(org.eclipse.winery.model.tosca.xml.extensions.XOTBehaviorPatternMapping) OTPropertyKV(org.eclipse.winery.model.tosca.extensions.kvproperties.OTPropertyKV) XTArtifactType(org.eclipse.winery.model.tosca.xml.XTArtifactType) XTServiceTemplate(org.eclipse.winery.model.tosca.xml.XTServiceTemplate) OTAttributeMapping(org.eclipse.winery.model.tosca.extensions.OTAttributeMapping) XTImport(org.eclipse.winery.model.tosca.xml.XTImport) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) XRelationshipSourceOrTarget(org.eclipse.winery.model.tosca.xml.XRelationshipSourceOrTarget) Function(java.util.function.Function) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) XTBoundaryDefinitions(org.eclipse.winery.model.tosca.xml.XTBoundaryDefinitions) OTPatternRefinementModel(org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel) XOTRefinementModel(org.eclipse.winery.model.tosca.xml.extensions.XOTRefinementModel) TPropertyConstraint(org.eclipse.winery.model.tosca.TPropertyConstraint) TParameter(org.eclipse.winery.model.tosca.TParameter) TInstanceState(org.eclipse.winery.model.tosca.TInstanceState) XOTDeploymentArtifactMapping(org.eclipse.winery.model.tosca.xml.extensions.XOTDeploymentArtifactMapping) TConstraint(org.eclipse.winery.model.tosca.TConstraint) XTDefinitions(org.eclipse.winery.model.tosca.xml.XTDefinitions) OTPermutationMapping(org.eclipse.winery.model.tosca.extensions.OTPermutationMapping) TEntityTypeImplementation(org.eclipse.winery.model.tosca.TEntityTypeImplementation) XTRequirementRef(org.eclipse.winery.model.tosca.xml.XTRequirementRef) TImport(org.eclipse.winery.model.tosca.TImport) XTExportedOperation(org.eclipse.winery.model.tosca.xml.XTExportedOperation) XTExtensibleElements(org.eclipse.winery.model.tosca.xml.XTExtensibleElements) XTBoolean(org.eclipse.winery.model.tosca.xml.XTBoolean) TRequiredContainerFeature(org.eclipse.winery.model.tosca.TRequiredContainerFeature) Logger(org.slf4j.Logger) TImplementationArtifact(org.eclipse.winery.model.tosca.TImplementationArtifact) XTCapabilityType(org.eclipse.winery.model.tosca.xml.XTCapabilityType) XTTopologyTemplate(org.eclipse.winery.model.tosca.xml.XTTopologyTemplate) TTag(org.eclipse.winery.model.tosca.TTag) XTPropertyMapping(org.eclipse.winery.model.tosca.xml.XTPropertyMapping) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) XTRelationshipTypeImplementation(org.eclipse.winery.model.tosca.xml.XTRelationshipTypeImplementation) Collections(java.util.Collections) TPolicyTemplate(org.eclipse.winery.model.tosca.TPolicyTemplate) TExportedOperation(org.eclipse.winery.model.tosca.TExportedOperation) XTEntityType(org.eclipse.winery.model.tosca.xml.XTEntityType) TEntityType(org.eclipse.winery.model.tosca.TEntityType) WinerysPropertiesDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.WinerysPropertiesDefinition)

Aggregations

Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 QName (javax.xml.namespace.QName)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 HasId (org.eclipse.winery.model.tosca.HasId)1 RelationshipSourceOrTarget (org.eclipse.winery.model.tosca.RelationshipSourceOrTarget)1 TArtifact (org.eclipse.winery.model.tosca.TArtifact)1 TArtifactReference (org.eclipse.winery.model.tosca.TArtifactReference)1 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)1 TArtifactType (org.eclipse.winery.model.tosca.TArtifactType)1 TBoundaryDefinitions (org.eclipse.winery.model.tosca.TBoundaryDefinitions)1 TCapability (org.eclipse.winery.model.tosca.TCapability)1 TCapabilityDefinition (org.eclipse.winery.model.tosca.TCapabilityDefinition)1 TCapabilityRef (org.eclipse.winery.model.tosca.TCapabilityRef)1 TCapabilityType (org.eclipse.winery.model.tosca.TCapabilityType)1