@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TEntityType)) return false; TEntityType that = (TEntityType) o; return Objects.equals(getDescription(), that.getDescription()) && Objects.equals(getVersion(), that.getVersion()) && Objects.equals(getDerivedFrom(), that.getDerivedFrom()) && Objects.equals(getProperties(), that.getProperties()) && Objects.equals(getAttributes(), that.getAttributes()) && Objects.equals(getMetadata(), that.getMetadata()); }
@Override public Result visit(TEntityType node, Parameter parameter) { if (node instanceof TDataType || node.getProperties().isEmpty()) { return null; } // BuildPlan for assignments Map<String, QName> plan = new LinkedHashMap<>(); String name = parameter.getKey() + "_Properties"; SchemaBuilder builder = new SchemaBuilder(parameter.getNamespace()); Map<String, String> imports = new LinkedHashMap<>(); for (Map.Entry<String, TPropertyDefinition> entry : node.getProperties().entrySet()) { builder.addElements(entry.getKey(), entry.getValue()); QName type = entry.getValue().getType(); if (type.getNamespaceURI() != null && !type.getNamespaceURI().equals(Namespaces.YAML_NS)) { imports.put(type.getNamespaceURI(), type.getLocalPart()); } plan.put(entry.getKey(), entry.getValue().getType()); } imports.forEach((key, value) -> builder.addImports(key, getRelativeFileName(key))); Document document = builder.buildComplexType(name, true).build(); WriterUtils.saveType(document, parameter.getPath(), parameter.getNamespace(), name); WriterUtils.storeTypes(parameter.getPath(), name, parameter.getNamespace(), name); this.propertyDefinition.put(new QName(parameter.getNamespace(), name), plan); return null; }
@Override public int hashCode() { return Objects.hash(getDescription(), getVersion(), getDerivedFrom(), getProperties(), getAttributes(), getMetadata()); }
public Builder(TEntityType entityType) { this.description = entityType.getDescription(); this.version = entityType.getVersion(); this.derivedFrom = entityType.getDerivedFrom(); this.properties = entityType.getProperties(); this.attributes = entityType.getAttributes(); this.metadata = entityType.getMetadata(); }
@Override public String toString() { return "TEntityType{" + "description='" + getDescription() + '\'' + ", version=" + getVersion() + ", derivedFrom=" + getDerivedFrom() + ", properties=" + getProperties() + ", attributes=" + getAttributes() + ", metadata=" + getMetadata() + '}'; }
@Override public R visit(TEntityType node, P parameter) { return reduce(Stream.of( visitElement(node.getVersion(), parameter, "version"), visitElement(node.getProperties(), parameter, "properties"), visitElement(node.getAttributes(), parameter, "attributes"), visitElement(node.getMetadata(), parameter, "metadata") )); }
public Printer visit(TEntityType node, Parameter parameter) { return new Printer(parameter.getIndent()) .printKeyValue("description", node.getDescription()) .printKeyValue("version", node.getVersion()) .printKeyValue("derived_from", node.getDerivedFrom()) .print(printMap("properties", node.getProperties(), parameter)) .print(printMap("attributes", node.getAttributes(), parameter)) .print(node.getMetadata().accept(this, parameter)); }
/** * Converts TOSCA YAML EntityTypes to TOSCA XML EntityTypes * <p> * Additional element version added to tag. Missing elements abstract, final will not be set. Missing element * targetNamespace is searched in metadata * * @param node TOSCA YAML EntityType * @return TOSCA XML EntityType */ private <T extends TEntityType.Builder<T>> T convert(org.eclipse.winery.model.tosca.yaml.TEntityType node, T builder) { builder.addDocumentation(node.getDescription()) .setDerivedFrom(node.getDerivedFrom()) .addTags(convertMetadata(node.getMetadata())) .setTargetNamespace(node.getMetadata().get("targetNamespace")); if (node.getVersion() != null) { TTag tag = new TTag(); tag.setName("version"); tag.setValue(node.getVersion().getVersion()); builder.addTags(tag); } if (!node.getProperties().isEmpty()) { builder.setPropertiesDefinition(convertPropertyDefinition(builder.build().getIdFromIdOrNameField() + "_Properties")); } return builder; }