use of org.eclipse.winery.model.tosca.yaml.YTParameterDefinition in project winery by eclipse.
the class YamlBuilder method buildCallOperationActivityDefinition.
public YTActivityDefinition buildCallOperationActivityDefinition(Object object, Parameter<YTActivityDefinition> parameter) {
if (Objects.isNull(object)) {
return null;
}
try {
// to support the short form notation
if (object instanceof String) {
return new YTCallOperationActivityDefinition((String) object);
}
Map<String, Object> map = (Map<String, Object>) object;
YTCallOperationActivityDefinition callOperation = new YTCallOperationActivityDefinition(stringValue(map.get(YamlSpecKeywords.OPERATION)));
Map<String, YTParameterDefinition> inputs = buildParameterDefinitions(map.get(YamlSpecKeywords.INPUTS), new Parameter<>(parameter.getContext()).addContext(YamlSpecKeywords.INPUTS).setValue(parameter.getValue()));
callOperation.setInputs(inputs);
return callOperation;
} catch (ClassCastException e) {
LOGGER.error("Unsupported format for the CallOperationActivityDefinition");
LOGGER.error(e.getMessage());
return null;
}
}
use of org.eclipse.winery.model.tosca.yaml.YTParameterDefinition in project winery by eclipse.
the class YamlBuilder method buildOperationDefinition.
@Nullable
@SuppressWarnings("unchecked")
public YTOperationDefinition buildOperationDefinition(Object object, Parameter<YTOperationDefinition> parameter) {
if (Objects.isNull(object) || !validate(YTOperationDefinition.class, object, parameter)) {
return null;
}
if (!(object instanceof Map)) {
return null;
}
Map<String, Object> map = (Map<String, Object>) object;
String description = buildDescription(map.get(YamlSpecKeywords.DESCRIPTION));
Map<String, YTParameterDefinition> inputs = buildParameterDefinitions(map.get(YamlSpecKeywords.INPUTS), new Parameter<>(parameter.getContext()).addContext(YamlSpecKeywords.INPUTS).setValue(parameter.getValue()));
Map<String, YTParameterDefinition> outputs = buildParameterDefinitions(map.get(YamlSpecKeywords.OUTPUTS), new Parameter<>(parameter.getContext()).addContext(YamlSpecKeywords.OUTPUTS).setValue(parameter.getValue()));
YTImplementation implementation = buildImplementation(map.get(YamlSpecKeywords.IMPLEMENTATION), new Parameter<YTImplementation>(parameter.getContext()).addContext(YamlSpecKeywords.IMPLEMENTATION));
return new YTOperationDefinition.Builder().setDescription(description).setInputs(inputs).setOutputs(outputs).setImplementation(implementation).build();
}
use of org.eclipse.winery.model.tosca.yaml.YTParameterDefinition in project winery by eclipse.
the class FromCanonical method convert.
public YTMapActivityDefinition convert(TActivityDefinition node) {
if (Objects.isNull(node)) {
return null;
}
// TODO support other activity definition types
if (node instanceof TCallOperationActivityDefinition) {
TCallOperationActivityDefinition canonicalDef = (TCallOperationActivityDefinition) node;
YTCallOperationActivityDefinition yamlDef = new YTCallOperationActivityDefinition(canonicalDef.getOperation());
Map<String, YTParameterDefinition> inputs = canonicalDef.getInputs().stream().map(this::convert).flatMap(m -> m.entrySet().stream()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
yamlDef.setInputs(inputs);
return new YTMapActivityDefinition().setMap(Collections.singletonMap(YamlSpecKeywords.CALL_OPERATION, yamlDef));
}
return new YTMapActivityDefinition();
}
use of org.eclipse.winery.model.tosca.yaml.YTParameterDefinition in project winery by eclipse.
the class ToCanonical method convert.
private ParameterDefinition convert(YTParameterDefinition node, String name) {
if (node == null) {
return null;
}
ParameterDefinition p = new ParameterDefinition();
p.setKey(name);
p.setType(node.getType());
p.setDescription(node.getDescription());
p.setRequired(node.getRequired());
p.setDefaultValue(ValueHelper.toString(node.getDefault()));
p.setValue(ValueHelper.toString(node.getValue()));
return p;
}
Aggregations