From 46b926fdacf597c1afc7136230d72562444008f6 Mon Sep 17 00:00:00 2001 From: liboNet Date: Wed, 31 Oct 2018 10:03:49 +0800 Subject: Add more logics about fields value for OOF model To align with OOF/Policy/SO, need add below: . resource should be set as name field of SDC resource. . identity should be set as a concatenation of PolicyType + "_" + Resource . value of flavorDirective's type, expected from OOF, is "flavor_directives" . policyScope should add the name of service from SDC to align with that from SO. . Update the Testcase Change-Id: I57f461ef51e0f50e6096c9c9ba84c5832cb13656 Issue-ID: POLICY-1227 Signed-off-by: liboNet --- .../distribution/reception/decoding/pdpx/ExtractFromNode.java | 9 ++++++--- .../reception/decoding/pdpx/PolicyDecoderCsarPdpx.java | 3 +++ .../reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java index 4f822b20..02b57552 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java @@ -38,6 +38,7 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.toscaparser.api.CapabilityAssignment; import org.onap.sdc.toscaparser.api.CapabilityAssignments; +import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.NodeTemplate; import org.onap.sdc.toscaparser.api.RequirementAssignment; @@ -82,8 +83,8 @@ public class ExtractFromNode { * @throws PolicyDecodingException if extract fails */ public Content extractInfo(final NodeTemplate node) throws PolicyDecodingException { - - LOGGER.debug("the meta data of this nodetemplate = " + sdcCsarHelper.getNodeTemplateMetadata(node)); + Metadata metaData = sdcCsarHelper.getNodeTemplateMetadata(node); + LOGGER.debug("the meta data of this nodetemplate = " + metaData); final List lnodeChild = sdcCsarHelper.getNodeTemplateChildren(node); LOGGER.debug("the size of lnodeChild = " + lnodeChild.size()); @@ -105,6 +106,8 @@ public class ExtractFromNode { LOGGER.debug("the size of cp is =" + lnodeVduCp.size()); final Content content = new Content(); + content.setResources(metaData.getValue("name")); + content.setIdentity(content.getPolicyType() + "_" + content.getResources()); extractInfoVdu(lnodeVdu, content); extractInfoVduCp(lnodeVduCp, content); if (content.getFlavorFeatures().isEmpty()) { @@ -128,7 +131,7 @@ public class ExtractFromNode { flavorAttribute.setAttributeName("flavorName"); flavorAttribute.setAttributeValue(""); final Directive flavorDirective = new Directive(); - flavorDirective.setType("flavor_directive"); + flavorDirective.setType("flavor_directives"); flavorDirective.getAttributes().add(flavorAttribute); final FlavorFeature flavorFeature = new FlavorFeature(); flavorFeature.setId(sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, "name")); diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java index 97ca3f5e..14519757 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java @@ -55,6 +55,8 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder