diff options
author | Wang,Frank(gw1218) <gw1218@att.com> | 2018-03-15 13:06:31 -0500 |
---|---|---|
committer | Wang,Frank(gw1218) <gw1218@att.com> | 2018-03-20 11:13:59 -0500 |
commit | 6e00f46e0c2ee4dbbdb0e222e6f361210d1a0da1 (patch) | |
tree | bdda1b96bc392a9df1e12f3f06cad70179b01644 /POLICY-SDK-APP/src/main/java | |
parent | 82b62ca5dd3ae30aab7999b5959e1c07eb1d3d1f (diff) |
Add Matching Fields For MS Model
Fixed the missing function of matching fields for TOSCA Model
Issue-ID: POLICY-655
Change-Id: I41017a4cf01df7f4c36e086f76d169e3e216dc34
Signed-off-by: guangxingwang <gw1218@att.com>
Signed-off-by: Wang,Frank(gw1218) <gw1218@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main/java')
-rw-r--r-- | POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java index ab4ea6d2d..422c18a31 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java @@ -113,7 +113,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType; @RequestMapping("/") public class CreateDcaeMicroServiceController extends RestrictedBaseController { private static final Logger LOGGER = FlexLogger.getLogger(CreateDcaeMicroServiceController.class); - + private Map<String, String> matchableValues; private static CommonClassDao commonClassDao; public static CommonClassDao getCommonClassDao() { @@ -151,7 +151,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { public static final String DEFAULT=".default"; public static final String REQUIRED=".required"; public static final String MANYFALSE=":MANY-false"; - + public static final String MATCHABLE=".matchable"; @Autowired private CreateDcaeMicroServiceController(CommonClassDao commonClassDao){ @@ -520,6 +520,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { HashMap<String,String> parseDataNodes(Map<String,String> map){ HashMap<String,String> dataMapForJson=new HashMap <>(); + matchableValues = new HashMap <>(); for(String uniqueDataKey: uniqueDataKeys){ if(uniqueDataKey.contains("%")){ String[] uniqueDataKeySplit= uniqueDataKey.split("%"); @@ -538,6 +539,15 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { String requiredValue= map.get(findRequired); LOGGER.info("requiredValue is:"+ requiredValue); + String matchable =DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+MATCHABLE; + + String matchableValue= map.get(matchable); + + if("true".equalsIgnoreCase(matchableValue)){ + String key=uniqueDataKeySplit[uniqueDataKeySplit.length -1]; + matchableValues.put(key, "matching-true"); + } + StringBuilder attributeIndividualStringBuilder= new StringBuilder(); attributeIndividualStringBuilder.append(typeValue+":defaultValue-"); attributeIndividualStringBuilder.append(defaultValue+":required-"); @@ -545,6 +555,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { dataMapForJson.put(uniqueDataKey, attributeIndividualStringBuilder.toString()); } else if(typeValue != null && typeValue.equalsIgnoreCase(LIST)){ + + String findList= DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+".entry_schema.type"; String listValue=map.get(findList); if(listValue!=null){ @@ -569,6 +581,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { break; } else{ + if(constraintsValue.contains("=")){ + constraintsValue = constraintsValue.replace("=", "equal-sign"); + } dataConstraints.add(constraintsValue); dataListBuffer.append(constraintsValue+","); } @@ -588,6 +603,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { dataMapForJson.put(uniqueDataKey, referenceIndividualStringBuilder.toString()); } + }else{ + matchableValues.put(uniqueDataKey, "matching-true"); } } return dataMapForJson; @@ -695,9 +712,15 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { attributeIndividualStringBuilder.append(keyValues.get("default")+":required-"); attributeIndividualStringBuilder.append(keyValues.get("required")+":MANY-false"); attributeStringBuilder.append(attributeIndividualStringBuilder+","); - + if("true".equalsIgnoreCase(keyValues.get("matchable"))){ + matchableValues.put(keySetString, "matching-true"); + } } else if(keyValues.get("type") != null && keyValues.get("type").equalsIgnoreCase(LIST)){ + + if("true".equalsIgnoreCase(keyValues.get("matchable"))){ + matchableValues.put(keySetString, "matching-true"); + } //List Datatype Set<String> keys= keyValues.keySet(); Iterator<String> itr=keys.iterator(); @@ -731,6 +754,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } }else{ //User defined Datatype. + if("true".equalsIgnoreCase(keyValues.get("matchable"))){ + matchableValues.put(keySetString, "matching-true"); + } String value=keyValues.get("type"); if(value != null && !value.isEmpty()){ String trimValue=value.substring(value.lastIndexOf('.')+1); @@ -1612,7 +1638,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { msAttributes.setAttribute(returnAttributeList); msAttributes.setSubClass(this.retmap); - + msAttributes.setMatchingSet(matchableValues); HashMap<String, String> returnReferenceList =new HashMap<>(); returnReferenceList.put(className, this.referenceAttributes); msAttributes.setRefAttribute(returnReferenceList); |