diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java')
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java | 155 |
1 files changed, 61 insertions, 94 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java index 4b9ed4f45e..db6f37ad85 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdc.enrichment.impl.tosca; import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE; @@ -39,105 +38,73 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire; import org.openecomp.sdc.versioning.dao.types.Version; - public class ComponentQuestionnaireData { - ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface(); - ComponentDependencyModelDao componentDependencyModelDao = - ComponentDependencyModelDaoFactory.getInstance().createInterface(); - - private Map<String, String> sourceToTargetComponent; - - public Map<String, String> getSourceToTargetComponent() { - return sourceToTargetComponent; - } - - public void setSourceToTargetComponent(Map<String, String> sourceToTargetComponent) { - this.sourceToTargetComponent = sourceToTargetComponent; - } - - public Map<String, Map<String, Object>> getPropertiesfromCompQuestionnaire(String key, - Version version) { - Map<String, Map<String, Object>> componentProperties = new HashMap<>(); - - final Collection<ComponentEntity> componentEntities = - componentDao.listCompositionAndQuestionnaire(key, version); - - Map<String, String> sourceToTarget = new HashMap<>(); - - for (ComponentEntity component : componentEntities) { - Map<String, Object> questionnaireParams = new HashMap<>(); - - final ComponentQuestionnaire componentQuestionnaire = - JsonUtil.json2Object(component.getQuestionnaireData(), ComponentQuestionnaire.class); - - final ComponentData componentData = - JsonUtil.json2Object(component.getCompositionData(), ComponentData.class); - - sourceToTarget.put(component.getId(), componentData.getDisplayName()); - - String nfcNamingCode = componentQuestionnaire.getGeneral().getNfcNamingCode(); - questionnaireParams.put(NFC_NAMING_CODE, nfcNamingCode); + ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface(); + ComponentDependencyModelDao componentDependencyModelDao = ComponentDependencyModelDaoFactory.getInstance().createInterface(); + private Map<String, String> sourceToTargetComponent; - String vfcDescription = componentQuestionnaire.getGeneral().getNfcFunction(); - questionnaireParams.put(EnrichmentConstants.NFC_FUNCTION, vfcDescription); - - - if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null) { - String mandatory = componentQuestionnaire.getHighAvailabilityAndLoadBalancing() - .getIsComponentMandatory(); - questionnaireParams.put(MANDATORY, mandatory); - - String mode = componentQuestionnaire.getHighAvailabilityAndLoadBalancing() - .getHighAvailabilityMode(); - - questionnaireParams.put(HIGH_AVAIL_MODE, mode); - } - - final Integer maxVms = - componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute() - .getNumOfVMs() != null ? componentQuestionnaire.getCompute().getNumOfVMs() - .getMaximum() : null) : null; - - final Integer minVms = - componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute() - .getNumOfVMs() != null ? componentQuestionnaire.getCompute().getNumOfVMs() - .getMinimum() : null) : null; - - questionnaireParams.put(MIN_INSTANCES, minVms != null && minVms == 0 ? null : minVms); - questionnaireParams.put(MAX_INSTANCES, maxVms != null && maxVms == 0 ? null : maxVms); - - if (!questionnaireParams.isEmpty()) { - componentProperties.put(JsonUtil.json2Object(component.getCompositionData(), - ComponentData.class).getDisplayName(), questionnaireParams); - } + public Map<String, String> getSourceToTargetComponent() { + return sourceToTargetComponent; } - setSourceToTargetComponent(sourceToTarget); - - return componentProperties; - } - - public Map<String, List<String>> populateDependencies(String vspId, Version version, Map<String, - String> componentNameData) { - Collection<ComponentDependencyModelEntity> componentDependencies = - componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null)); - - Map<String, List<String>> dependencies = new HashMap<>(); - List<String> targetComponents; - for (ComponentDependencyModelEntity dependency : componentDependencies) { - String sourceComponentName = componentNameData.get(dependency.getSourceComponentId()); - String targetComponentName = componentNameData.get(dependency.getTargetComponentId()); - if (!dependencies.containsKey(sourceComponentName)) { - targetComponents = new ArrayList<>(); - } else { - targetComponents = dependencies.get(sourceComponentName); - } - targetComponents.add(targetComponentName); - dependencies.put(sourceComponentName, targetComponents); + public void setSourceToTargetComponent(Map<String, String> sourceToTargetComponent) { + this.sourceToTargetComponent = sourceToTargetComponent; } - return dependencies; - } + public Map<String, Map<String, Object>> getPropertiesfromCompQuestionnaire(String key, Version version) { + Map<String, Map<String, Object>> componentProperties = new HashMap<>(); + final Collection<ComponentEntity> componentEntities = componentDao.listCompositionAndQuestionnaire(key, version); + Map<String, String> sourceToTarget = new HashMap<>(); + for (ComponentEntity component : componentEntities) { + Map<String, Object> questionnaireParams = new HashMap<>(); + final ComponentQuestionnaire componentQuestionnaire = JsonUtil + .json2Object(component.getQuestionnaireData(), ComponentQuestionnaire.class); + final ComponentData componentData = JsonUtil.json2Object(component.getCompositionData(), ComponentData.class); + sourceToTarget.put(component.getId(), componentData.getDisplayName()); + String nfcNamingCode = componentQuestionnaire.getGeneral().getNfcNamingCode(); + questionnaireParams.put(NFC_NAMING_CODE, nfcNamingCode); + String vfcDescription = componentQuestionnaire.getGeneral().getNfcFunction(); + questionnaireParams.put(EnrichmentConstants.NFC_FUNCTION, vfcDescription); + if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null) { + String mandatory = componentQuestionnaire.getHighAvailabilityAndLoadBalancing().getIsComponentMandatory(); + questionnaireParams.put(MANDATORY, mandatory); + String mode = componentQuestionnaire.getHighAvailabilityAndLoadBalancing().getHighAvailabilityMode(); + questionnaireParams.put(HIGH_AVAIL_MODE, mode); + } + final Integer maxVms = + componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute().getNumOfVMs() != null ? componentQuestionnaire + .getCompute().getNumOfVMs().getMaximum() : null) : null; + final Integer minVms = + componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute().getNumOfVMs() != null ? componentQuestionnaire + .getCompute().getNumOfVMs().getMinimum() : null) : null; + questionnaireParams.put(MIN_INSTANCES, minVms != null && minVms == 0 ? null : minVms); + questionnaireParams.put(MAX_INSTANCES, maxVms != null && maxVms == 0 ? null : maxVms); + if (!questionnaireParams.isEmpty()) { + componentProperties + .put(JsonUtil.json2Object(component.getCompositionData(), ComponentData.class).getDisplayName(), questionnaireParams); + } + } + setSourceToTargetComponent(sourceToTarget); + return componentProperties; + } + public Map<String, List<String>> populateDependencies(String vspId, Version version, Map<String, String> componentNameData) { + Collection<ComponentDependencyModelEntity> componentDependencies = componentDependencyModelDao + .list(new ComponentDependencyModelEntity(vspId, version, null)); + Map<String, List<String>> dependencies = new HashMap<>(); + List<String> targetComponents; + for (ComponentDependencyModelEntity dependency : componentDependencies) { + String sourceComponentName = componentNameData.get(dependency.getSourceComponentId()); + String targetComponentName = componentNameData.get(dependency.getTargetComponentId()); + if (!dependencies.containsKey(sourceComponentName)) { + targetComponents = new ArrayList<>(); + } else { + targetComponents = dependencies.get(sourceComponentName); + } + targetComponents.add(targetComponentName); + dependencies.put(sourceComponentName, targetComponents); + } + return dependencies; + } } |