use of org.eclipse.winery.model.tosca.TDataType 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;
}
use of org.eclipse.winery.model.tosca.TDataType in project winery by eclipse.
the class IRepository method getReferencedDefinitionsChildIds.
default Collection<DefinitionsChildId> getReferencedDefinitionsChildIds(DataTypeId id) {
Set<DefinitionsChildId> ids = new HashSet<>();
TDataType definition = this.getElement(id);
// cast is safe because TDataType can only use YamlPropertiesDefinitions
getReferencedDefinitionsOfProperties(ids, definition.getProperties());
return ids;
}
use of org.eclipse.winery.model.tosca.TDataType in project winery by eclipse.
the class ToCanonical method convert.
public TDataType convert(YTDataType node, String id) {
String name = fixNamespaceDuplication(id, node.getMetadata().get("targetNamespace"));
TDataType.Builder builder = new TDataType.Builder(name).addConstraints(convertList(node.getConstraints(), this::convert));
fillEntityTypeProperties(node, builder);
TDataType result = builder.build();
// FIXME need to actually transform the node.getProperties() to an xml schema
// to be able to import it and add a PropertiesDefinition reference to that schema
String namespace = this.namespace;
if (namespace == null) {
// attempt to patch namespace with the definitions' targetNamespace
namespace = result.getTargetNamespace();
}
if (namespace == null) {
LOGGER.warn("Could not determine namespace for DataType {}. Imports may be incorrect!", id);
return result;
}
TImport importDefinition = new TImport.Builder(Namespaces.XML_NS).setLocation(EncodingUtil.URLencode(namespace) + ".xsd").setNamespace(namespace).build();
if (!this.imports.contains(importDefinition)) {
this.imports.add(importDefinition);
}
return result;
}
Aggregations