summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/utils/common-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/utils/common-utils.ts')
-rw-r--r--catalog-ui/src/app/utils/common-utils.ts34
1 files changed, 33 insertions, 1 deletions
diff --git a/catalog-ui/src/app/utils/common-utils.ts b/catalog-ui/src/app/utils/common-utils.ts
index 97177949ee..1868550225 100644
--- a/catalog-ui/src/app/utils/common-utils.ts
+++ b/catalog-ui/src/app/utils/common-utils.ts
@@ -19,7 +19,7 @@
*/
import * as _ from "lodash";
-import {Module, AttributeModel, ResourceInstance, PropertyModel, InputFEModel} from "../models";
+import {Module, AttributeModel, ResourceInstance, PropertyModel, InputFEModel, OperationModel} from "../models";
import {ComponentInstanceFactory} from "./component-instance-factory";
import {InputBEModel, PropertyBEModel, RelationshipModel} from "app/models";
import { PolicyInstance } from "app/models/graph/zones/policy-instance";
@@ -126,5 +126,37 @@ export class CommonUtils {
return policies;
}
+
+ static initInterfaceOperations(interfaces: any): Array<OperationModel> {
+
+ return _.reduce(interfaces, (acc, interf: any) => {
+
+ return acc.concat(
+ _.map(interf.operations,
+ ({description, name, uniqueId, inputs, outputs}) => {
+ const operation = new OperationModel({
+ description,
+ operationType: name,
+ uniqueId
+ });
+ if (inputs) {
+ const inputParams = _.map(inputs.listToscaDataDefinition, (input:any) => {
+ return {paramName: input.name, paramId: input.inputId};
+ });
+ operation.createInputParamsList(inputParams);
+ }
+ if (outputs) {
+ const outputParams = _.map(outputs.listToscaDataDefinition, (output:any) => {
+ return {paramName: output.name, paramId: output.outputId};
+ });
+ operation.createOutputParamsList(outputParams);
+ }
+ return operation;
+ }
+ )
+ );
+
+ }, []);
+ }
}