for (Policy policy : policyList) {
                        
                        // extract policy metadata
-                       String policyUuid = policy.getMetaData().getOrDefault("UUID", "").toString(); 
-                       String policyInvariantUuid = policy.getMetaData().getOrDefault("invariantUUID", "").toString();
-                       String policyCustomizationUuid = policy.getMetaData().getOrDefault("customizationUUID", "").toString();
+                       String policyUuid = policy.getMetaDataObj().getAllProperties().getOrDefault("UUID", "").toString();
+                       String policyInvariantUuid = policy.getMetaDataObj().getAllProperties().getOrDefault("invariantUUID", "").toString();
+                       String policyCustomizationUuid = policy.getMetaDataObj().getAllProperties().getOrDefault("customizationUUID", "").toString();
                        
                        // cleanup existing RESOURCE_POLICY data
                        Map<String, String> cleanupParams = new HashMap<String, String>();
                        addParameter("policy_uuid", policyUuid, policyParams);
                        addParameter("policy_customization_uuid", policyCustomizationUuid, policyParams);
                        addParameter("policy_invariant_uuid", policyInvariantUuid, policyParams);
-                       addParameter("policy_name", policy.getMetaData().getOrDefault(PARAM_NAME_KEY, "").toString(), policyParams);
-                       addParameter(PARAM_VERSION_KEY, policy.getMetaData().getOrDefault(PARAM_VERSION_KEY, "").toString(), policyParams);
-                       addParameter("policy_type", policy.getMetaData().getOrDefault(PARAM_TYPE_KEY, "").toString(), policyParams);
+                       addParameter("policy_name", policy.getMetaDataObj().getAllProperties().getOrDefault(PARAM_NAME_KEY, "").toString(), policyParams);
+                       addParameter(PARAM_VERSION_KEY, policy.getMetaDataObj().getAllProperties().getOrDefault(PARAM_VERSION_KEY, "").toString(), policyParams);
+                       addParameter("policy_type", policy.getType(), policyParams);
                        
                        // extract properties
                        addParameter("property_type", extractValue(policy, PARAM_TYPE_KEY), policyParams);
                for (Policy policy : policyList) {
                        
                        // extract policy metadata
-                       String policyUuid = policy.getMetaData().getOrDefault("UUID", "").toString();
-                       String policyInvariantUuid = policy.getMetaData().getOrDefault("invariantUUID", "").toString();
+                       String policyUuid = policy.getMetaDataObj().getAllProperties().getOrDefault("UUID", "").toString();
+                       String policyInvariantUuid = policy.getMetaDataObj().getAllProperties().getOrDefault("invariantUUID", "").toString();
                        
                        // cleanup existing RESOURCE_POLICY data
                        Map<String, String> cleanupParams = new HashMap<String, String>();
                        Map<String, String> policyParams = new HashMap<String, String>();
                        addParameter("policy_uuid", policyUuid, policyParams);
                        addParameter("policy_invariant_uuid", policyInvariantUuid, policyParams);
-                       addParameter("policy_name", policy.getMetaData().getOrDefault("name", "").toString(), policyParams);
-                       addParameter("version", policy.getMetaData().getOrDefault("version", "").toString(), policyParams);
+                       addParameter("policy_name", policy.getMetaDataObj().getAllProperties().getOrDefault("name", "").toString(), policyParams);
+                       addParameter("version", policy.getMetaDataObj().getAllProperties().getOrDefault("version", "").toString(), policyParams);
                        addParameter("policy_type", policy.getType(), policyParams);
                        
                        // extract properties
                        
                        // insert into RESOURCE_POLICY_TO_TARGET_NODE_MAPPING
                        List<String> policyTargetNameList = policy.getTargets();
+                       if (policyTargetNameList == null) {
+                               continue;
+                       }
+
                        for (String targetName : policyTargetNameList) {
                                NodeTemplate targetNode = sdcCsarHelper.getNodeTemplateByName(targetName);
                                
                for (Policy policy : policyList) {
                        
                        // extract policy metadata
-                       String policyUuid = policy.getMetaData().getOrDefault("UUID", "").toString();
-                       String policyInvariantUuid = policy.getMetaData().getOrDefault("invariantUUID", "").toString();
+                       String policyUuid = policy.getMetaDataObj().getAllProperties().getOrDefault("UUID", "").toString();
+                       String policyInvariantUuid = policy.getMetaDataObj().getAllProperties().getOrDefault("invariantUUID", "").toString();
                        
                        // cleanup existing RESOURCE_POLICY data
                        Map<String, String> cleanupParams = new HashMap<String, String>();
                        Map<String, String> policyParams = new HashMap<String, String>();
                        addParameter("policy_uuid", policyUuid, policyParams);
                        addParameter("policy_invariant_uuid", policyInvariantUuid, policyParams);
-                       String policyName = policy.getMetaData().getOrDefault(PARAM_NAME_KEY, "").toString();
+                       String policyName = policy.getMetaDataObj().getAllProperties().getOrDefault(PARAM_NAME_KEY, "").toString();
                        addParameter("policy_name", policyName, policyParams);
-                       addParameter(PARAM_VERSION_KEY, policy.getMetaData().getOrDefault(PARAM_VERSION_KEY, "").toString(), policyParams);
+                       addParameter(PARAM_VERSION_KEY, policy.getMetaDataObj().getAllProperties().getOrDefault(PARAM_VERSION_KEY, "").toString(), policyParams);
                        addParameter("policy_type", policy.getType(), policyParams);
                        
                        // extract properties
                        
                        // insert into RESOURCE_POLICY_TO_TARGET_NODE_MAPPING
                        List<NodeTemplate> targetNodeList = sdcCsarHelper.getPolicyTargetsFromOrigin(nodeTemplate, policyName);
+                       if (targetNodeList == null) {
+                               continue;
+                       }
+
                        for (NodeTemplate targetNode : targetNodeList) {
                                //NodeTemplate targetNode = sdcCsarHelper.getNodeTemplateByName(targetName);
                                if (targetNode == null) {                                       
 
 import java.util.Map;
 
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
 import org.onap.sdc.toscaparser.api.Group;
 import org.onap.sdc.toscaparser.api.NodeTemplate;
-import org.onap.sdc.toscaparser.api.Policy;
+import org.onap.sdc.toscaparser.api.Property;
 import org.onap.sdc.toscaparser.api.elements.Metadata;
 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
 import org.slf4j.Logger;
        
        private void insertVFtoNetworkRoleMappingData () throws IOException {
                
-               // For each VF, insert VF_TO_NETWORK_ROLE_MAPPING data
-               List<NodeTemplate> cpNodes = sdcCsarHelper.getCpListByVf(getCustomizationUUIDNoQuotes());
-               for (NodeTemplate cpNode : cpNodes){
-
-                       // Insert into VF_TO_NETWORK_ROLE_MAPPING vf_customization_uuid and network_role
-                       String cpNetworkRole = sdcCsarHelper.getNodeTemplatePropertyLeafValue(cpNode, "network_role");
+               // Cleanup existing VF_TO_NETWORK_ROLE_MAPPING for this VF
+               try {
+                       cleanUpExistingToscaData("VF_TO_NETWORK_ROLE_MAPPING", "vf_customization_uuid", getCustomizationUUID());
+               } catch (IOException e) {
+                       LOG.error("Could not cleanup Tosca CSAR data into the VF_TO_NETWORK_ROLE_MAPPING table");
+                       throw new IOException (e);
+               }       
+               
+               // For this VF, insert VF_TO_NETWORK_ROLE_MAPPING data
+               EntityQuery entityQueryCP = EntityQuery.newBuilder(SdcTypes.CP).build();
+           TopologyTemplateQuery topologyTemplateQueryVF = TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(getCustomizationUUIDNoQuotes()).build();
+           List<IEntityDetails> cpEntities = sdcCsarHelper.getEntity(entityQueryCP, topologyTemplateQueryVF, true);
+           
+               for (IEntityDetails entity: cpEntities ) {              
+                       
+                       Map<String, Property> properties = entity.getProperties();
+                       if (properties.containsKey("network_role")) {
 
-                       try {
-                               cleanUpExistingToscaData("VF_TO_NETWORK_ROLE_MAPPING", "vf_customization_uuid", getCustomizationUUID());
-                               LOG.info("Call insertToscaData for VF_TO_NETWORK_ROLE_MAPPING where vf_customization_uuid = " + getCustomizationUUID());
-                               insertToscaData("insert into VF_TO_NETWORK_ROLE_MAPPING (vf_customization_uuid, network_role) values (" +
-                               getCustomizationUUID() + ", \"" + cpNetworkRole + "\")", null);
-                       } catch (IOException e) {
-                               LOG.error("Could not insert Tosca CSAR data into the VF_TO_NETWORK_ROLE_MAPPING table");
-                               throw new IOException (e);
+                               Property networkRoleProperty = properties.get("network_role");
+                               if (networkRoleProperty != null && networkRoleProperty.getValue() != null) {
+                                       String cpNetworkRole = networkRoleProperty.getValue().toString();
+                                       LOG.debug("insertVFtoNetworkRoleMappingData: " + "VF: "  + getCustomizationUUID() + ", networkRole = " + cpNetworkRole);
+                                       
+                                       // Only insert unique network_role values for this VF
+                                       boolean networkRoleExists = false;
+                                       Map<String, String> networkRoleyKeys = new HashMap<String, String>();
+                                       networkRoleyKeys.put("vf_customization_uuid", getCustomizationUUID());
+                                       networkRoleyKeys.put("network_role", "\"" + cpNetworkRole + "\"");                      
+                                       networkRoleExists = checkForExistingToscaData("VF_TO_NETWORK_ROLE_MAPPING", networkRoleyKeys);
+                                       
+                                       if (networkRoleExists == false) {
+                                               try {
+                                                       //cleanUpExistingToscaData("VF_TO_NETWORK_ROLE_MAPPING", "vf_customization_uuid", getCustomizationUUID());
+                                                       LOG.info("Call insertToscaData for VF_TO_NETWORK_ROLE_MAPPING where vf_customization_uuid = " + getCustomizationUUID());
+                                                       insertToscaData("insert into VF_TO_NETWORK_ROLE_MAPPING (vf_customization_uuid, network_role) values (" +
+                                                       getCustomizationUUID() + ", \"" + cpNetworkRole + "\")", null);
+                                               } catch (IOException e) {
+                                                       LOG.error("Could not insert Tosca CSAR data into the VF_TO_NETWORK_ROLE_MAPPING table");
+                                                       throw new IOException (e);
+                                               }                                                       
+                                       }
+                               }
                        }
 
                } // CP loop