public static Map<String, Object> addInterfaceTypeElement(Component component) {
Map<String, Object> toscaInterfaceTypes = new HashMap<>();
if ((component instanceof Service) || (component instanceof Product)) {
- return toscaInterfaceTypes;
+ return null;
}
final Map<String, InterfaceDefinition> interfaces = ((Resource) component).getInterfaces();
final Map<String, OperationDataDefinition> operations = interfaceDefinition.getOperations();
Map<String, Object> toscaOperations = new HashMap<>();
- for (String operationName : operations.keySet()) {
- toscaOperations.put(operationName,
+ for (String operationId : operations.keySet()) {
+ toscaOperations.put(operations.get(operationId).getName(),
null); //currently not initializing any of the operations' fields as it is not needed
}
toscaInterfaceDefinition.setType(toscaResourceName);
final Map<String, OperationDataDefinition> operations = interfaceDefinition.getOperations();
Map<String, Object> toscaOperations = new HashMap<>();
- ToscaLifecycleOperationDefinition toscaOperation = new ToscaLifecycleOperationDefinition();
String operationArtifactPath;
for (Map.Entry<String, OperationDataDefinition> operationEntry : operations.entrySet()) {
+ ToscaLifecycleOperationDefinition toscaOperation = new ToscaLifecycleOperationDefinition();
if (isArtifactPresent(operationEntry)) {
operationArtifactPath = OperationArtifactUtil
.createOperationArtifactPath(component.getNormalizedName(),
operationEntry.getValue());
toscaOperation.setImplementation(operationArtifactPath);
}
- fillToscaOperation(operationEntry.getValue(), toscaOperation);
+ toscaOperation.setDescription(operationEntry.getValue().getDescription());
+ fillToscaOperationInputs(operationEntry.getValue(), toscaOperation);
toscaOperations.put(operationEntry.getValue().getName(), toscaOperation);
}
}
/***
- * workaround : currently "defaultp" is not being converted to "default" by the relevant code in ToscaExportHandler
- * any string key named "default" will have its named changed to "default"
+ * workaround for : currently "defaultp" is not being converted to "default" by the relevant code in ToscaExportHandler
+ * any string key named "defaultp" will have its named changed to "default"
* @param operationsMap the map to update
*/
private static void handleDefaults(Map<String, Object> operationsMap) {
return false;
}
- private static void fillToscaOperation(OperationDataDefinition operation,
+ private static void fillToscaOperationInputs(OperationDataDefinition operation,
ToscaLifecycleOperationDefinition toscaOperation) {
if (Objects.isNull(operation.getInputs())) {
return;
}
- Map<String, ToscaProperty> inputs = new HashMap<>();
+ Map<String, ToscaProperty> toscaInputs = new HashMap<>();
for (OperationInputDefinition input : operation.getInputs().getListToscaDataDefinition()) {
ToscaProperty toscaInput = new ToscaProperty();
toscaInput.setType(DEFAULT_INPUT_TYPE);
toscaInput.setDefaultp(createDefaultValue(getLastPartOfName(input.getInputId())));
- inputs.put(input.getName(), toscaInput);
+ toscaInputs.put(input.getName(), toscaInput);
}
- toscaOperation.setInputs(inputs);
+ toscaOperation.setInputs(toscaInputs);
}
private static Map<String, List<String>> createDefaultValue(String propertyName) {
Assert.assertTrue(toscaRepresentation.getMainYaml().contains("resourceName:"));
Assert.assertTrue(toscaRepresentation.getMainYaml().contains("inputs:"));
Assert.assertFalse(toscaRepresentation.getMainYaml().contains("defaultp"));
+ Assert.assertTrue(toscaRepresentation.getMainYaml().contains("has description"));
+ Assert.assertTrue(toscaRepresentation.getMainYaml().contains("naming_function_"));
Assert.assertTrue(toscaRepresentation.getMainYaml().contains("com.some.resource.or.other.resourceName"));
}
Assert.assertFalse(toscaRepresentation.getMainYaml().contains("input_"));
Assert.assertFalse(toscaRepresentation.getMainYaml().contains("defaultp"));
Assert.assertTrue(toscaRepresentation.getMainYaml().contains("resourceNameNoInputs:"));
+ Assert.assertTrue(toscaRepresentation.getMainYaml().contains("has description"));
Assert.assertTrue(toscaRepresentation.getMainYaml().contains("com.some.resource.or.other.resourceName"));
}
for (int i = 0; i < numOfOps; i++) {
final OperationDataDefinition operation = new OperationDataDefinition();
operation.setName("name_for_op_" + i);
+ operation.setDescription( "op "+i+" has description");
final ArtifactDataDefinition implementation = new ArtifactDataDefinition();
implementation.setArtifactName(i + "_createBPMN.bpmn");
operation.setImplementation(implementation);