use of org.eclipse.winery.model.tosca.yaml.support.Metadata in project winery by eclipse.
the class FromCanonical method convert.
@NonNull
public Map<String, YTNodeTemplate> convert(TNodeTemplate node, @NonNull List<TRelationshipTemplate> rTs) {
if (Objects.isNull(node)) {
return new LinkedHashMap<>();
}
Metadata meta = new Metadata();
if (Objects.nonNull(node.getX()) && Objects.nonNull(node.getY())) {
meta.add(org.eclipse.winery.model.converter.support.Defaults.X_COORD, node.getX());
meta.add(org.eclipse.winery.model.converter.support.Defaults.Y_COORD, node.getY());
}
if (Objects.nonNull(node.getName())) {
meta.add(org.eclipse.winery.model.converter.support.Defaults.DISPLAY_NAME, node.getName());
}
return Collections.singletonMap(node.getIdFromIdOrNameField(), new YTNodeTemplate.Builder(convert(node.getType(), new NodeTypeId(node.getType()))).setProperties(convert(node.getProperties())).setMetadata(meta).setRequirements(convertRequirements(node.getRequirements())).setCapabilities(convert(node.getCapabilities())).setArtifacts(convert(node.getArtifacts())).build());
}
use of org.eclipse.winery.model.tosca.yaml.support.Metadata in project winery by eclipse.
the class FromCanonical method convert.
public Map<String, YTInterfaceType> convert(TInterfaceType node) {
if (Objects.isNull(node)) {
return null;
}
Map<String, YTOperationDefinition> ops = new HashMap<>();
node.getOperations().forEach((key, value) -> ops.putAll(convert(value)));
YTInterfaceType.Builder interfaceBuilder = new YTInterfaceType.Builder().setDescription(node.getDescription()).setOperations(ops).setDerivedFrom(convert(node.getDerivedFrom(), node.getClass()));
String typeName = node.getName();
if (Objects.nonNull(node.getTargetNamespace()) && !node.getTargetNamespace().isEmpty()) {
Metadata metadata = new Metadata();
metadata.put("targetNamespace", node.getTargetNamespace());
interfaceBuilder.addMetadata(metadata);
if (Objects.nonNull(typeName)) {
typeName = node.getTargetNamespace().concat(".").concat(typeName);
}
}
return Collections.singletonMap(typeName, interfaceBuilder.build());
}
use of org.eclipse.winery.model.tosca.yaml.support.Metadata in project winery by eclipse.
the class ReflectionTest method testServiceTemplates.
@ParameterizedTest
@MethodSource("getYamlFiles")
public void testServiceTemplates(Path fileName) throws Exception {
Metadata metadata = getMetadata(fileName);
String exception = metadata.get("exception");
String assertValue = metadata.get("assert");
String keyName = metadata.get("keyname");
String assertTypeof = metadata.get("assert-typeof");
testServiceTemplates(fileName, exception, keyName, assertValue, assertTypeof);
}
use of org.eclipse.winery.model.tosca.yaml.support.Metadata in project winery by eclipse.
the class YamlBuilder method buildMetadata.
@Nullable
public Metadata buildMetadata(Object object) {
if (Objects.isNull(object)) {
return null;
}
@SuppressWarnings("unchecked") Map<String, Object> tmp = (Map<String, Object>) object;
Metadata metadata = new Metadata();
tmp.entrySet().stream().filter(entry -> Objects.nonNull(entry.getValue())).forEach(entry -> {
metadata.put(entry.getKey(), stringValue(entry.getValue()));
if (entry.getValue() instanceof Date) {
SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSSZ");
date.setTimeZone(TimeZone.getTimeZone("UTC"));
metadata.put(entry.getKey(), date.format(entry.getValue()));
}
});
return metadata;
}
Aggregations