aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2023-03-23 11:25:23 +0000
committerImam hussain <imam.hussain@est.tech>2023-04-03 11:13:18 +0000
commit7565f810f9fa50c8140843b2f81e8fb428815154 (patch)
tree5ff3ef43bd7434db7c0bd462db295a2726052c61
parent3dff1c221e58de6a81cf6bbdfb84fdf97665e484 (diff)
Provide tosca function capability to all nested levels
Tosca function capability is provided to all nested levels of list, map and custom types Issue-ID: SDC-4445 Signed-off-by: Imam hussain <imam.hussain@est.tech> Change-Id: I29907bdac83d3cadf90aa0a2ed538002132b4789
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java15
-rw-r--r--catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts79
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-be-model.ts2
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-fe-model.ts1
-rw-r--r--catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html4
-rw-r--r--catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts76
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts51
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts33
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts11
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts35
-rw-r--r--catalog-ui/src/app/ng2/services/data-type.service.ts14
12 files changed, 199 insertions, 124 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 96366194d3..f43f7de860 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -2077,7 +2077,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (jsonObject.has(path.get(0))) {
objectForPath = jsonObject.get(path.get(0));
} else {
- if (StringUtils.isNumeric(path.get(0))) {
+ if (path.size() > 1 && StringUtils.isNumeric(path.get(1))) {
objectForPath = new JSONArray();
} else {
objectForPath = new JSONObject();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
index 247fff9bc6..ef7363a1a3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
@@ -61,6 +61,9 @@ public class PropertyValueConstraintValidationUtil {
private static final String IGNORE_PROPERTY_VALUE_START_WITH_INPUT = "{\"get_input\":";
private static final String IGNORE_PROPERTY_VALUE_START_WITH_PROPERTY = "{\"get_property\":";
private static final String IGNORE_PROPERTY_VALUE_START_WITH_ATTRIBUTE = "{\"get_attribute\":";
+ private static final String IGNORE_PROPERTY_VALUE_INPUT = "{get_input=";
+ private static final String IGNORE_PROPERTY_VALUE_PROPERTY = "{get_property=";
+ private static final String IGNORE_PROPERTY_VALUE_ATTRIBUTE = "{get_attribute=";
private Map<String, DataTypeDefinition> dataTypeDefinitionCache;
private final ObjectMapper objectMapper = new ObjectMapper();
private final List<String> errorMessages = new ArrayList<>();
@@ -159,8 +162,10 @@ public class PropertyValueConstraintValidationUtil {
}
private boolean isValueAToscaFunction(PropertyDefinition propertyDefinition) {
- return propertyDefinition.getToscaFunction() != null || propertyDefinition.getValue() != null && (propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_INPUT) || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_PROPERTY)
- || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_ATTRIBUTE));
+ return (propertyDefinition.getToscaFunction() != null) || (propertyDefinition.getValue() != null
+ && ((propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_INPUT) || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_PROPERTY)
+ || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_ATTRIBUTE) || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_ATTRIBUTE)
+ || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_PROPERTY) || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_INPUT))));
}
private void checkAndEvaluatePrimitiveProperty(PropertyDefinition propertyDefinition, DataTypeDefinition dataTypeDefinition) {
@@ -197,10 +202,8 @@ public class PropertyValueConstraintValidationUtil {
if (propertyDefinition.getSubPropertyToscaFunctions() != null) {
for (SubPropertyToscaFunction subPropertyToscaFunction : propertyDefinition.getSubPropertyToscaFunctions()) {
final List<String> path = subPropertyToscaFunction.getSubPropertyPath();
- if (path.size() == 1) {
- if (path.get(0).equals(prop.getName())) {
- return;
- }
+ if (path.size() == 1 && path.get(0).equals(prop.getName())) {
+ return;
}
if (path.size() > 1) {
if (path.get(0).equals(propertyDefinition.getToscaSubPath()) && path.get(1).equals(prop.getName())) {
diff --git a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
index 7ca1fee21d..c4ba64a8af 100644
--- a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
+++ b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
@@ -48,22 +48,34 @@ export class DerivedFEProperty extends PropertyBEModel {
mapInlist: boolean
inputName: string;
parentMapKey: string;
+ toscaPath: string[];
constructor(property: PropertyBEModel, parentName?: string, createChildOfListOrMap?: boolean, key?:string, value?:any) {
if (!createChildOfListOrMap) { //creating a standard derived prop
super(property);
+ this.toscaPath = [];
this.parentName = parentName ? parentName : null;
this.propertiesName = (parentName) ? parentName + '#' + property.name : property.name;
this.canBeDeclared = true; //defaults to true
+ if (property instanceof DerivedFEProperty) {
+ this.toscaPath = property.toscaPath != null ? property.toscaPath : [];
+ } else {
+ this.toscaPath = property.parentToscaPath != null ? property.parentToscaPath : property.parentToscaPath;
+ }
+ if (this.toscaPath.length == 0 && parentName != null && parentName.indexOf('#') != -1) {
+ let lastparent = parentName.split('#');
+ this.toscaPath.push(lastparent[lastparent.length - 1]);
+ }
+ this.toscaPath.push(property.name);
} else { //creating a direct child of list or map (ie. Item that can be deleted, with UUID instead of name)
super(null);
- if(property.subPropertyToscaFunctions != null){
- property.subPropertyToscaFunctions.forEach((item : SubPropertyToscaFunction) => {
- if(item.subPropertyPath[0] === key){
- this.toscaFunction = item.toscaFunction;
- }
- });
+ let toscaPathCopy = null;
+ if (property instanceof DerivedFEProperty) {
+ toscaPathCopy = property.toscaPath != null ? property.toscaPath .toString() : null;
+ } else {
+ toscaPathCopy = property.parentToscaPath != null ? property.parentToscaPath.toString() : null;
}
+ this.toscaPath = toscaPathCopy != null ? toscaPathCopy.split(",") : [];
this.isChildOfListOrMap = true;
this.canBeDeclared = false;
this.name = UUID.UUID();
@@ -72,16 +84,35 @@ export class DerivedFEProperty extends PropertyBEModel {
if (property.type == PROPERTY_TYPES.LIST) {
let parentKey : string = null;
- if(property.value != null) {
- const valueJson = JSON.parse(property.value);
- if (key != '') {
- parentKey = key;
- }else{
- let indexNumber = Number(Object.keys(valueJson).sort().reverse()[0]) + 1;
- parentKey = indexNumber.toString();
+ if (property instanceof DerivedFEProperty) {
+ if (property.valueObj != '') {
+ if (key != '') {
+ let listIndex = Number(key);
+ if (!isNaN(listIndex)) {
+ this.toscaPath.push(key);
+ } else {
+ let newIndex = Object.keys(property.valueObj).findIndex(valueKey => (valueKey == key));
+ this.toscaPath.push(newIndex.toString());
+ }
+ } else {
+ let toscaIndex = Object.keys(property.valueObj).sort().reverse()[0];
+ this.toscaPath.push((Number(toscaIndex) + 1).toString());
+ }
+ } else {
+ this.toscaPath.push("0");
+ }
+ } else {
+ if (property instanceof PropertyFEModel && property.valueObj != '') {
+ if (key != '') {
+ parentKey = key;
+ }else{
+ let toscaIndex = Object.keys(property.valueObj).sort().reverse()[0];
+ parentKey = (Number(toscaIndex) + 1).toString();
+ }
+ } else {
+ parentKey = "0";
}
- }else {
- parentKey = "0";
+ this.toscaPath.push(parentKey);
}
if (property.schemaType != PROPERTY_TYPES.MAP) {
this.mapKey = parentKey;
@@ -118,7 +149,14 @@ export class DerivedFEProperty extends PropertyBEModel {
} else {
this.schema = new SchemaPropertyGroupModel(new SchemaProperty(property.schema.property));
}
-
+ if (this.toscaPath != null) {
+ let lastIndex = this.toscaPath[this.toscaPath.length - 1];
+ if(this.mapKey != lastIndex){
+ this.toscaPath.push(this.mapKey);
+ }
+ } else {
+ this.toscaPath.push(this.mapKey);
+ }
}
this.valueObj = (this.type == PROPERTY_TYPES.JSON && typeof value == 'object') ? JSON.stringify(value) : value;
if (value != null) {
@@ -126,7 +164,14 @@ export class DerivedFEProperty extends PropertyBEModel {
}
this.updateValueObjOrig();
}
- // this.constraints = property ? property.constraints : null;
+ this.parentToscaPath = this.toscaPath;
+ if(property.subPropertyToscaFunctions != null){
+ property.subPropertyToscaFunctions.forEach((item : SubPropertyToscaFunction) => {
+ if(item.subPropertyPath.toString() === this.toscaPath.toString() && this.uniqueId == null){
+ this.toscaFunction = item.toscaFunction;
+ }
+ });
+ }
this.valueObjIsValid = true;
this.derivedDataType = this.getDerivedPropertyType();
this.inputName = property.inputName;
diff --git a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
index e4c0f8165c..a939ed0fda 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
@@ -79,6 +79,7 @@ export class PropertyBEModel {
toscaGetFunction: ToscaGetFunctionDto;
toscaFunction: ToscaFunction;
subPropertyToscaFunctions: SubPropertyToscaFunction[];
+ parentToscaPath: string[] = [];
constructor(property?: PropertyBEModel) {
if (property) {
@@ -106,6 +107,7 @@ export class PropertyBEModel {
this.inputPath = property.inputPath;
this.inputName = property.inputName;
this.metadata = property.metadata;
+ this.parentToscaPath = property.parentToscaPath;
if (property.toscaFunction) {
this.toscaFunction = property.toscaFunction;
} else if (property.toscaGetFunction) {
diff --git a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
index 49baefd4e0..1f73d2e4ec 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
@@ -182,6 +182,7 @@ export class PropertyFEModel extends PropertyBEModel {
const oldActualMapKey = childProp.getActualMapKey();
childProp.mapKey = newMapKey;
+ childProp.toscaPath[childProp.toscaPath.length - 1] = newMapKey;
if (childProp.mapKey === null) { // null -> remove map key
childProp.mapKeyError = null;
} else if (!childProp.mapKey) {
diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
index 956bb05356..038f5f5317 100644
--- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
+++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
@@ -25,7 +25,7 @@
<div class="inner-cell-div" tooltip="{{property.name}}"><span>{{property.name}}</span></div>
</div>
<div class="table-cell" *ngIf="!canBeDeclared && !property.isChildOfListOrMap">
- <checkbox *ngIf="nestedLevel == 2" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || property.mapKey == '' || checkboxDisabled" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
+ <checkbox *ngIf="nestedLevel >= 2" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || checkboxDisabled" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
<div class="inner-cell-div" tooltip="{{property.name}}"><span>{{property.name}}</span></div>
</div> <!-- simple children of complex type within map or list -->
<div class="table-cell map-entry" *ngIf="property.isChildOfListOrMap && propType == derivedPropertyTypes.MAP && !property.mapInlist"><!-- map left cell -->
@@ -44,7 +44,7 @@
<!-- RIGHT CELL OR FULL WIDTH CELL-->
<ng-container *ngIf="propType == derivedPropertyTypes.SIMPLE || property.isDeclared || (property.isToscaFunction() && !property.isChildOfListOrMap) || (property.isChildOfListOrMap && propType == derivedPropertyTypes.MAP && property.schema.property.isSimpleType)">
<div class="table-cell">
- <checkbox class="{{propType == derivedPropertyTypes.MAP ? 'inline-checkBox' : 'inline-checkBox-List'}}" *ngIf="((nestedLevel == 1 || nestedLevel == 2) && property.isChildOfListOrMap && property.schema.property.isSimpleType)" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || property.mapKey == '' || checkboxDisabled" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
+ <checkbox class="{{propType == derivedPropertyTypes.MAP ? 'inline-checkBox' : 'inline-checkBox-List'}}" *ngIf="(property.isChildOfListOrMap && property.schema.property.isSimpleType)" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || property.mapKey == '' || checkboxDisabled" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
<dynamic-element class="value-input"
pattern="validationUtils.getValidationPattern(property.type)"
[value]="(property.isDeclared || property.isToscaFunction()) ? property.value : property.valueObj"
diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
index e53cf01848..7be44c3075 100644
--- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
+++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
@@ -160,26 +160,12 @@ export class DynamicPropertyComponent {
createNewChildProperty = (): void => {
- let mapKeyValue = this.property instanceof DerivedFEProperty ? this.property.mapKey : "";
let parentToscaFunction = null;
- if (this.property.type == PROPERTY_TYPES.LIST && mapKeyValue === "") {
- if (this.property.value != null) {
- const valueJson = JSON.parse(this.property.value);
- if (this.property instanceof PropertyFEModel && this.property.expandedChildPropertyId != null) {
- let indexNumber = Number(Object.keys(valueJson).sort().reverse()[0]) + 1;
- mapKeyValue = indexNumber.toString();
- }else{
- mapKeyValue = Object.keys(valueJson).sort().reverse()[0];
- }
- }else {
- mapKeyValue = "0";
- }
- }
if (this.property.type == PROPERTY_TYPES.MAP && this.property instanceof DerivedFEProperty && this.property.mapInlist) {
parentToscaFunction = this.property.toscaFunction;
this.property.toscaFunction = null;
}
- let newProps: Array<DerivedFEProperty> = this.propertiesUtils.createListOrMapChildren(this.property, mapKeyValue, null);
+ let newProps: Array<DerivedFEProperty> = this.propertiesUtils.createListOrMapChildren(this.property, '', null);
this.propertiesUtils.assignFlattenedChildrenValues(this.property.valueObj, [newProps[0]], this.property.propertiesName);
if (this.property instanceof PropertyFEModel) {
@@ -257,21 +243,45 @@ export class DynamicPropertyComponent {
return;
}
let oldKey = item.getActualMapKey();
- let keyIndex : number = 0;
- if(item.parentMapKey != null && oldKey != null) {
- keyIndex = 1;
- }
- if(item.parentMapKey != null && oldKey == null) {
- oldKey = item.parentMapKey;
- }
if (this.property.subPropertyToscaFunctions !== null) {
+ let deletedIndex = item.toscaPath.length > 0 ? Number(item.toscaPath[item.toscaPath.length - 1]) : null;
+ let parentIndex = item.toscaPath.length > 1 ? item.toscaPath.splice(0,item.toscaPath.length - 2) : null;
let tempSubToscaFunction: SubPropertyToscaFunction[] = [];
+ let toscaPathMap = new Map();
this.property.subPropertyToscaFunctions.forEach((subToscaItem : SubPropertyToscaFunction) => {
- if(subToscaItem.subPropertyPath[keyIndex] != oldKey){
+ if ((subToscaItem.subPropertyPath.toString()).indexOf(item.toscaPath.toString()) == -1) {
tempSubToscaFunction.push(subToscaItem);
+ } else {
+ if (item.derivedDataType == DerivedPropertyType.LIST ) {
+ if (parentIndex != null) {
+ if ((subToscaItem.subPropertyPath.toString()).indexOf(parentIndex.toString()) != -1
+ && subToscaItem.subPropertyPath.length > parentIndex.length) {
+ let nextIndex = Number(subToscaItem.subPropertyPath[parentIndex.length]);
+ if(!isNaN(nextIndex) && !isNaN(deletedIndex) && nextIndex > deletedIndex) {
+ let revisedPAth = subToscaItem.subPropertyPath;
+ revisedPAth[parentIndex.length] = (nextIndex - 1).toString();
+ toscaPathMap.set(subToscaItem.subPropertyPath.toString(),revisedPAth.toString());
+ }
+ }
+ } else {
+ if (subToscaItem.subPropertyPath.length == 1 && !isNaN(deletedIndex)) {
+ let nextElementIndex = Number(subToscaItem.subPropertyPath[0]);
+ if (!isNaN(nextElementIndex) && nextElementIndex > deletedIndex) {
+ subToscaItem.subPropertyPath[0] = (nextElementIndex - 1).toString();
+ }
+ }
+ }
+ }
}
});
this.property.subPropertyToscaFunctions = tempSubToscaFunction;
+ if (item.derivedDataType == DerivedPropertyType.LIST && parentIndex != null && toscaPathMap.size > 0) {
+ this.property.flattenedChildren.forEach((childProperties : DerivedFEProperty) => {
+ if (toscaPathMap.has(childProperties.toscaPath.toString())) {
+ childProperties.toscaPath = toscaPathMap.get(childProperties.toscaPath.toString());
+ }
+ });
+ }
}
if (item.derivedDataType == DerivedPropertyType.MAP && !item.mapInlist) {
delete itemParent.valueObj[oldKey];
@@ -299,16 +309,13 @@ export class DynamicPropertyComponent {
updateChildKeyInParent(childProp: DerivedFEProperty, newMapKey: string) {
if (this.property instanceof PropertyFEModel) {
let oldKey = childProp.getActualMapKey();
+ let oldToscaPath = childProp.toscaPath;
this.property.childPropMapKeyUpdated(childProp, newMapKey);
- this.property.flattenedChildren.forEach(tempDervObj => {
- if (childProp.propertiesName === tempDervObj.parentName) {
- tempDervObj.mapKey = newMapKey;
- }
- });
+ this.updateChildMapKey(this.property.flattenedChildren, childProp.propertiesName, newMapKey);
if (this.property.subPropertyToscaFunctions != null) {
this.property.subPropertyToscaFunctions.forEach((item : SubPropertyToscaFunction) => {
- if(item.subPropertyPath[0] === oldKey){
- item.subPropertyPath = [newMapKey];
+ if(item.subPropertyPath === oldToscaPath){
+ item.subPropertyPath = childProp.toscaPath;
}
});
}
@@ -316,6 +323,15 @@ export class DynamicPropertyComponent {
}
}
+ updateChildMapKey(childProps: Array<DerivedFEProperty>, parentName: string, newMapKey: string) {
+ childProps.forEach(tempDervObj => {
+ if (parentName === tempDervObj.parentName) {
+ tempDervObj.mapKey = newMapKey;
+ tempDervObj.toscaPath[tempDervObj.toscaPath.length - 2] = newMapKey;
+ }
+ });
+ }
+
preventInsertItem = (property:DerivedFEProperty):boolean => {
if(property.type == PROPERTY_TYPES.MAP && property.valueObj != null && Object.keys(property.valueObj).indexOf('') > -1 ){
return true;
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
index 17bb1a63cc..0e3e13917a 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
@@ -585,6 +585,18 @@ export class PropertiesAssignmentComponent {
modal.instance.open();
}
+ private deleteToscaValue(valueJson : any, currentKey: string[]) {
+ if(currentKey.length == 1) {
+ if (Array.isArray(valueJson) && !isNaN(Number(currentKey[0]))) {
+ valueJson.splice(Number(currentKey[0]),1);
+ } else {
+ delete valueJson[currentKey[0]];
+ }
+ } else {
+ this.deleteToscaValue(valueJson[currentKey[0]],currentKey.splice(1,currentKey.length -1));
+ }
+ }
+
private clearCheckedInstancePropertyValue() {
const checkedInstanceProperty: PropertyBEModel = this.buildCheckedInstanceProperty();
const currentValue : any = checkedInstanceProperty.value;
@@ -594,37 +606,15 @@ export class PropertiesAssignmentComponent {
if (checkedInstanceProperty instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel>checkedInstanceProperty).propertiesName){
const propertiesNameArray = (<PropertyDeclareAPIModel>checkedInstanceProperty).propertiesName;
const parts = propertiesNameArray.split("#");
- let currentKey = [];
- if (this.isListOrMap(checkedInstanceProperty.type)) {
- if (checkedInstanceProperty.schemaType == PROPERTY_TYPES.MAP) {
- currentKey.push((<DerivedFEProperty>checkedInstanceProperty.input).parentMapKey);
- }
- currentKey.push((<DerivedFEProperty>checkedInstanceProperty.input).mapKey);
- if (checkedInstanceProperty.schemaType != PROPERTY_TYPES.MAP && this.isComplexSchemaType(checkedInstanceProperty.schemaType)) {
- currentKey.push(parts.reverse()[0]);
- }
- }
+ let currentKey = (<DerivedFEProperty>checkedInstanceProperty.input).toscaPath;
if (propertiesNameArray.length > 1){
const index = checkedInstanceProperty.subPropertyToscaFunctions.findIndex(existingSubPropertyToscaFunction => this.areEqual(existingSubPropertyToscaFunction.subPropertyPath, currentKey.length > 0 ? currentKey : parts.slice(1)));
checkedInstanceProperty.subPropertyToscaFunctions.splice(index, 1);
}
if(currentValue !== null && currentKey.length > 0){
let valueJson = JSON.parse(currentValue);
- if(currentKey.length >1){
- let innerObj = valueJson[currentKey[0]];
- delete innerObj[currentKey[1]];
- valueJson[currentKey[0]] = innerObj;
- }else{
- delete valueJson[currentKey[0]];
- }
- if (checkedInstanceProperty.type == PROPERTY_TYPES.LIST && currentKey.length == 1) {
- let listValue = valueJson.filter(function (item) {
- return item != null && item != '';
- });
- checkedInstanceProperty.value = JSON.stringify(listValue);
- } else {
- checkedInstanceProperty.value = JSON.stringify(valueJson);
- }
+ this.deleteToscaValue(valueJson, currentKey);
+ checkedInstanceProperty.value = JSON.stringify(valueJson);
}
}
if (this.selectedInstanceData instanceof ComponentInstance) {
@@ -648,16 +638,7 @@ export class PropertiesAssignmentComponent {
if (checkedProperty instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel>checkedProperty).propertiesName){
const propertiesName = (<PropertyDeclareAPIModel>checkedProperty).propertiesName;
const parts = propertiesName.split("#");
- let currentKey = [];
- if (this.isListOrMap(checkedProperty.type)) {
- if (checkedProperty.schemaType == PROPERTY_TYPES.MAP) {
- currentKey.push((<DerivedFEProperty>checkedProperty.input).parentMapKey);
- }
- currentKey.push((<DerivedFEProperty>checkedProperty.input).mapKey);
- if (checkedProperty.schemaType != PROPERTY_TYPES.MAP && this.isComplexSchemaType(checkedProperty.schemaType)) {
- currentKey.push(parts.reverse()[0]);
- }
- }
+ let currentKey = (<DerivedFEProperty>checkedProperty.input).toscaPath;
if (checkedProperty.subPropertyToscaFunctions == null){
checkedProperty.subPropertyToscaFunctions = [];
}
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
index bc5345c386..8dd4ca96ec 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
@@ -105,15 +105,14 @@ export class PropertiesUtils {
newProps.push(parentProp);
if (!property.schema.property.isSimpleType) {
- let additionalChildren:Array<DerivedFEProperty> = this.createFlattenedChildren(property.schema.property.type, parentProp.propertiesName, key);
+ let additionalChildren:Array<DerivedFEProperty> = this.createFlattenedChildren(property.schema.property.type, parentProp.propertiesName, key, parentProp.toscaPath);
this.assignFlattenedChildrenValues(parentProp.valueObj, additionalChildren, parentProp.propertiesName);
additionalChildren.forEach(prop => {
prop.canBeDeclared = false;
if (property.subPropertyToscaFunctions != null) {
const subToscaFunctArray : SubPropertyToscaFunction[] = property.subPropertyToscaFunctions;
subToscaFunctArray.forEach(subToscaFunct => {
- const keyArray : string[] = subToscaFunct.subPropertyPath;
- if (keyArray.length > 1 && prop.mapKey == keyArray[0] && prop.name == keyArray[1]) {
+ if (subToscaFunct.subPropertyPath.toString() === prop.toscaPath.toString()) {
prop.toscaFunction = subToscaFunct.toscaFunction;
}
});
@@ -128,13 +127,15 @@ export class PropertiesUtils {
/**
* Creates derivedFEProperties of a specified type and returns them.
*/
- private createFlattenedChildren = (type: string, parentName: string, key: string):Array<DerivedFEProperty> => {
+ private createFlattenedChildren = (type: string, parentName: string, key: string, toscaPath?: string[]):Array<DerivedFEProperty> => {
let tempProps: Array<DerivedFEProperty> = [];
let dataTypeObj: DataTypeModel = this.dataTypeService.getDataTypeByTypeName(type);
- this.dataTypeService.getDerivedDataTypeProperties(dataTypeObj, tempProps, parentName);
- tempProps.forEach(tempDervObj => {
- tempDervObj.mapKey = key;
- });
+ this.dataTypeService.getDerivedDataTypeProperties(dataTypeObj, tempProps, parentName, toscaPath);
+ if (key != '') {
+ tempProps.forEach(tempDervObj => {
+ tempDervObj.mapKey = key;
+ });
+ }
return _.sortBy(tempProps, ['propertiesName']);
}
@@ -161,6 +162,16 @@ export class PropertiesUtils {
property.flattenedChildren.push(...this.createListOrMapChildren(lastCreatedChild, keyNested, nestedValue[keyNested]));
});
}
+ if (property.flattenedChildren && property.subPropertyToscaFunctions) {
+ property.flattenedChildren.forEach((prop, index) => {
+ property.subPropertyToscaFunctions.forEach(subPropertyToscaFunction => {
+ const toscaFunctionPath = subPropertyToscaFunction.subPropertyPath.join('#');
+ if (subPropertyToscaFunction.subPropertyPath.toString() === prop.toscaPath.toString()) {
+ prop.toscaFunction = subPropertyToscaFunction.toscaFunction;
+ }
+ });
+ });
+ }
});
} else if (property.derivedDataType === DerivedPropertyType.COMPLEX) {
property.flattenedChildren = this.createFlattenedChildren(property.type, property.name, "");
@@ -183,11 +194,11 @@ export class PropertiesUtils {
const subPropertyPath = prop.propertiesName.substring(prop.propertiesName.indexOf(topLevelPropertyName) + topLevelPropertyName.length + 1);
subPropertyToscaFunctions.forEach(subPropertyToscaFunction => {
const toscaFunctionPath = subPropertyToscaFunction.subPropertyPath.join('#');
- if (subPropertyPath === toscaFunctionPath){
+ if (subPropertyPath === toscaFunctionPath || subPropertyToscaFunction.subPropertyPath.toString() === prop.toscaPath.toString()) {
prop.toscaFunction = subPropertyToscaFunction.toscaFunction;
}
- })
- })
+ });
+ });
}
/*
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
index 9ea0c8f214..d46ac2eb10 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
@@ -114,16 +114,7 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
if (this.property instanceof PropertyDeclareAPIModel && this.property.subPropertyToscaFunctions && (<PropertyDeclareAPIModel> this.property).propertiesName){
let propertiesPath = (<PropertyDeclareAPIModel> this.property).propertiesName.split("#");
if (propertiesPath.length > 1){
- let keyToFind = [];
- if (this.property.type == PROPERTY_TYPES.MAP || this.property.type == PROPERTY_TYPES.LIST) {
- if (this.property.type == PROPERTY_TYPES.LIST && this.property.schemaType == PROPERTY_TYPES.MAP) {
- keyToFind.push((<DerivedFEProperty>this.property.input).parentMapKey);
- }
- keyToFind.push((<DerivedFEProperty>this.property.input).mapKey);
- if (this.property.schemaType != PROPERTY_TYPES.MAP && PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.property.schemaType) === -1) {
- keyToFind.push(propertiesPath.reverse()[0]);
- }
- }
+ let keyToFind = (<DerivedFEProperty>this.property.input).toscaPath;
let subPropertyToscaFunction = this.property.subPropertyToscaFunctions.find(subPropertyToscaFunction => this.areEqual(subPropertyToscaFunction.subPropertyPath, keyToFind.length > 0 ? keyToFind : propertiesPath.slice(1)));
if (subPropertyToscaFunction){
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
index b0146cc1cf..656d7d6d71 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
@@ -264,11 +264,21 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
private propertyTypeToString() {
if (this.isSubProperty()){
- if ((this.typeHasSchema(this.property.type) && this.property instanceof PropertyDeclareAPIModel &&
- (<PropertyDeclareAPIModel> this.property).input instanceof DerivedFEProperty) || this.compositionMap) {
+ if ((this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel> this.property).input instanceof DerivedFEProperty)
+ || this.compositionMap) {
if(this.isComplexType(this.property.schemaType) && !this.compositionMap){
- let propertySchemaType = (<PropertyDeclareAPIModel> this.property).input.type;
- return propertySchemaType == PROPERTY_TYPES.MAP ? PROPERTY_TYPES.STRING : propertySchemaType;
+ let mapChildProp : DerivedFEProperty = (<DerivedFEProperty> (<PropertyDeclareAPIModel> this.property).input);
+ let propertySchemaType = mapChildProp.type;
+ if (this.property.type == PROPERTY_TYPES.MAP || propertySchemaType == PROPERTY_TYPES.MAP) {
+ if (mapChildProp.mapKey != '' && mapChildProp.mapKey != null && mapChildProp.schema.property.type != null) {
+ propertySchemaType = mapChildProp.schema.property.type;
+ }
+ }
+ if ((propertySchemaType == PROPERTY_TYPES.MAP || (propertySchemaType == PROPERTY_TYPES.LIST && mapChildProp.schema.property.type == PROPERTY_TYPES.MAP))
+ && mapChildProp.isChildOfListOrMap) {
+ propertySchemaType = PROPERTY_TYPES.STRING;
+ }
+ return propertySchemaType;
}else{
return this.property.schema.property.type;
}
@@ -379,10 +389,13 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
private hasSameType(property: PropertyBEModel | AttributeBEModel): boolean {
if (this.typeHasSchema(this.property.type)) {
if ((this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel> this.property).input instanceof DerivedFEProperty) || this.compositionMap) {
- if(this.isComplexType(this.property.schemaType) && !this.compositionMap){
- let propertySchemaType = (<PropertyDeclareAPIModel> this.property).input.type;
- propertySchemaType = propertySchemaType == PROPERTY_TYPES.MAP ? PROPERTY_TYPES.STRING : propertySchemaType;
- return property.type === propertySchemaType;
+ let childObject : DerivedFEProperty = (<DerivedFEProperty>(<PropertyDeclareAPIModel> this.property).input);
+ let childSchemaType = this.property.schemaType != null ? this.property.schemaType : childObject.type;
+ if(this.isComplexType(childSchemaType) && !this.compositionMap){
+ if (childObject.type == PROPERTY_TYPES.MAP && childObject.isChildOfListOrMap) {
+ return property.type === PROPERTY_TYPES.STRING;
+ }
+ return property.type === childObject.type;
}else{
return property.type === this.property.schema.property.type;
}
@@ -393,7 +406,11 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
return property.type === this.property.type && this.property.schema.property.type === property.schema.property.type;
}
if (this.property.schema.property.isDataType && this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel>this.property).propertiesName){
- let typeToMatch = this.getType((<PropertyDeclareAPIModel>this.property).propertiesName.split("#").slice(1), this.property.type);
+ let typeToMatch = (<PropertyDeclareAPIModel> this.property).input.type;
+ let childObject : DerivedFEProperty = (<DerivedFEProperty>(<PropertyDeclareAPIModel> this.property).input);
+ if (childObject.type == PROPERTY_TYPES.MAP && childObject.isChildOfListOrMap) {
+ typeToMatch = PROPERTY_TYPES.STRING;
+ }
return property.type === typeToMatch;
}
diff --git a/catalog-ui/src/app/ng2/services/data-type.service.ts b/catalog-ui/src/app/ng2/services/data-type.service.ts
index d4af634cec..6eead12134 100644
--- a/catalog-ui/src/app/ng2/services/data-type.service.ts
+++ b/catalog-ui/src/app/ng2/services/data-type.service.ts
@@ -140,16 +140,24 @@ export class DataTypeService {
return null;
}
- public getDerivedDataTypeProperties(dataTypeObj: DataTypeModel, propertiesArray: Array<DerivedFEProperty>, parentName: string) {
+ public getDerivedDataTypeProperties(dataTypeObj: DataTypeModel, propertiesArray: Array<DerivedFEProperty>, parentName: string, toscaPath?: string[]) {
//push all child properties to array
+ const parentToscaPath = toscaPath != null ? toscaPath.toString() : null;
if (!dataTypeObj) return;
if (dataTypeObj.properties) {
dataTypeObj.properties.forEach((derivedProperty) => {
+ derivedProperty.parentToscaPath = parentToscaPath != null ? parentToscaPath.split(',') : [];
+ let innerToscaPath = null;
if (dataTypeObj.name !== PROPERTY_DATA.OPENECOMP_ROOT || derivedProperty.name !== PROPERTY_DATA.SUPPLEMENTAL_DATA) {//The requirement is to not display the property supplemental_data
- propertiesArray.push(new DerivedFEProperty(derivedProperty, parentName));
+ const childProperty : DerivedFEProperty = new DerivedFEProperty(derivedProperty, parentName);
+ innerToscaPath = childProperty.toscaPath;
+ propertiesArray.push(childProperty);
}
+
let derivedDataTypeObj: DataTypeModel = this.getDataTypeByTypeName(derivedProperty.type);
- this.getDerivedDataTypeProperties(derivedDataTypeObj, propertiesArray, parentName + "#" + derivedProperty.name);
+ if (dataTypeObj && dataTypeObj.properties) {
+ this.getDerivedDataTypeProperties(derivedDataTypeObj, propertiesArray, parentName + "#" + derivedProperty.name, innerToscaPath);
+ }
});
}
//recurse parent (derivedFrom), in case one of parents contains properties