use of org.eclipse.winery.model.tosca.yaml.support.TMapImportDefinition in project winery by eclipse.
the class SchemaVisitor method visit.
public Map<QName, Map<String, QName>> visit(TServiceTemplate node, Path path, Path outpath, String namespace) {
for (TMapImportDefinition map : node.getImports()) {
for (Map.Entry<String, TImportDefinition> entry : map.entrySet()) {
Reader reader = Reader.getReader();
try {
TServiceTemplate serviceTemplate = reader.parse(entry.getValue(), path, entry.getValue().getNamespaceUri());
visit(serviceTemplate, new Parameter(outpath, entry.getValue().getNamespaceUri()).setBuildSchema(false));
} catch (MultiException e) {
setException(e);
}
}
}
this.visit(node, new Parameter(outpath, namespace));
return propertyDefinition;
}
use of org.eclipse.winery.model.tosca.yaml.support.TMapImportDefinition in project winery by eclipse.
the class SchemaVisitor method visit.
@Override
public Result visit(TServiceTemplate node, Parameter parameter) {
Map<String, TDataType> tmpDataTypes = this.data_types;
this.data_types = node.getDataTypes();
for (TMapImportDefinition map : node.getImports()) {
for (Map.Entry<String, TImportDefinition> entry : map.entrySet()) {
addImport(entry.getValue().getNamespaceUri(), new AbstractMap.SimpleEntry<>(entry));
}
}
// init localDataTypesList
node.getDataTypes().forEach((key, value) -> this.localDatatypeNames.add(key));
// Default: parameter.datatype is not set -> visit all datatype nodes
QName type = parameter.getDatatype();
if (type == null) {
for (Map.Entry<String, TDataType> entry : node.getDataTypes().entrySet()) {
if (entry.getValue() != null) {
entry.getValue().accept(this, parameter.copy().addContext("datatypes", entry.getKey()));
}
}
visitChildes(node, parameter);
} else // Optimized: parameter.datatype is set and defined in this service template
if (type.getNamespaceURI().equals(parameter.getNamespace()) && this.localDatatypeNames.contains(type.getLocalPart())) {
node.getDataTypes().get(parameter.getDatatype().getLocalPart()).accept(this, parameter.copy().addContext("datatypes", parameter.getDatatype().getLocalPart()));
}
if (parameter.getBuildSchema()) {
for (Map.Entry<String, SchemaBuilder> entry : schemaBuilders.entrySet()) {
Document document = entry.getValue().build();
WriterUtils.saveType(document, parameter.getPath(), parameter.getNamespace(), entry.getValue().getNamespace());
}
}
this.data_types = tmpDataTypes;
return null;
}
Aggregations