aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/utils/common-utils.ts
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
committerMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
commited64b5edff15e702493df21aa3230b81593e6133 (patch)
treea4cb01fdaccc34930a8db403a3097c0d1e40914b /catalog-ui/src/app/utils/common-utils.ts
parent280f8015d06af1f41a3ef12e8300801c7a5e0d54 (diff)
[SDC-29] catalog 1707 rebase commit.
Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/utils/common-utils.ts')
-rw-r--r--catalog-ui/src/app/utils/common-utils.ts96
1 files changed, 96 insertions, 0 deletions
diff --git a/catalog-ui/src/app/utils/common-utils.ts b/catalog-ui/src/app/utils/common-utils.ts
new file mode 100644
index 0000000000..d8019d2f96
--- /dev/null
+++ b/catalog-ui/src/app/utils/common-utils.ts
@@ -0,0 +1,96 @@
+import {Module, AttributeModel, ResourceInstance, PropertyModel, InputFEModel} from "../models";
+import {ComponentInstanceFactory} from "./component-instance-factory";
+import {PropertyBEModel, RelationshipModel} from "app/models";
+
+export class CommonUtils {
+
+ static initProperties(propertiesObj:Array<PropertyModel>, uniqueId?:string):Array<PropertyModel> {
+
+ let properties = new Array<PropertyModel>();
+ if (propertiesObj) {
+ _.forEach(propertiesObj, (property:PropertyModel):void => {
+ if (uniqueId) {
+ property.readonly = property.parentUniqueId != uniqueId;
+ }
+ properties.push(new PropertyModel(property));
+ });
+ }
+ return properties;
+ };
+
+ static initAttributes(attributesObj:Array<AttributeModel>, uniqueId?:string):Array<AttributeModel> {
+
+ let attributes = new Array<AttributeModel>();
+ if (attributesObj) {
+ _.forEach(attributesObj, (attribute:AttributeModel):void => {
+ if (uniqueId) {
+ attribute.readonly = attribute.parentUniqueId != uniqueId;
+ }
+ attributes.push(new AttributeModel(attribute));
+ });
+ }
+ return attributes;
+ };
+
+ static initComponentInstances(componentInstanceObj:Array<ResourceInstance>):Array<ResourceInstance> {
+
+ let componentInstances = new Array<ResourceInstance>();
+ if (componentInstanceObj) {
+ _.forEach(componentInstanceObj, (instance:ResourceInstance):void => {
+ componentInstances.push(ComponentInstanceFactory.createComponentInstance(instance));
+ });
+ }
+ return componentInstances;
+ };
+
+ static initModules(moduleArrayObj:Array<Module>):Array<Module> {
+
+ let modules = new Array<Module>();
+
+ if (moduleArrayObj) {
+ _.forEach(moduleArrayObj, (module:Module):void => {
+ if (module.type === "org.openecomp.groups.VfModule") {
+ modules.push(new Module(module));
+ }
+ });
+ }
+ return modules;
+ };
+
+ static initInputs(inputsObj:Array<PropertyBEModel>):Array<PropertyBEModel> {
+
+ let inputs = new Array<PropertyBEModel>();
+
+ if(inputsObj) {
+ _.forEach(inputsObj, (input:PropertyBEModel):void => {
+ inputs.push(new PropertyBEModel(input));
+ })
+ }
+
+ return inputs;
+ }
+
+ static initBeProperties(propertiesObj: Array<PropertyBEModel>): Array<PropertyBEModel> {
+
+ let properties = new Array<PropertyBEModel>();
+
+ if (propertiesObj) {
+ _.forEach(propertiesObj, (property: PropertyBEModel): void => {
+ properties.push(new PropertyBEModel(property));
+ })
+ }
+
+ return properties;
+ }
+
+ static initComponentInstanceRelations = (componentInstanceRelationsObj:Array<RelationshipModel>):Array<RelationshipModel> => {
+ if (componentInstanceRelationsObj) {
+ let componentInstancesRelations: Array<RelationshipModel> = [];
+ _.forEach(componentInstanceRelationsObj, (instanceRelation:RelationshipModel):void => {
+ componentInstancesRelations.push(new RelationshipModel(instanceRelation));
+ });
+ return componentInstancesRelations;
+ }
+ };
+}
+