X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2Fxml%2Fgenerator%2Fapi%2FAaiArtifactGenerator.java;h=11c1471a304b78cf2008b7c925250d705948a489;hb=bfde3ef00beb3c6f31cebfd12e90b9b9cdcc492e;hp=8742de3d6e0c1af8ce28b818744028b317d9c98f;hpb=5a6fd49a6aca3a567464527335b107746e28f3bd;p=aai%2Fbabel.git diff --git a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java index 8742de3..11c1471 100644 --- a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java +++ b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2019 European Software Marketing Ltd. + * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2017-2019 European Software Marketing Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ import org.onap.aai.babel.xml.generator.model.Model; import org.onap.aai.babel.xml.generator.model.Resource; import org.onap.aai.babel.xml.generator.model.Service; import org.onap.aai.babel.xml.generator.model.Widget; -import org.onap.aai.babel.xml.generator.model.Widget.Type; +import org.onap.aai.babel.xml.generator.model.WidgetType; import org.onap.aai.babel.xml.generator.types.ModelType; import org.onap.aai.cl.api.Logger; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; @@ -69,7 +69,7 @@ public class AaiArtifactGenerator implements ArtifactGenerator { private static final String GENERATOR_AAI_INVALID_SERVICE_VERSION = "Cannot generate artifacts. Service version is incorrect"; - private AaiModelGenerator modelGenerator = new AaiModelGeneratorImpl(); + private AaiModelGenerator modelGenerator = new AaiModelGenerator(); @Override public GenerationData generateArtifact(byte[] csarArchive, List input, @@ -82,7 +82,6 @@ public class AaiArtifactGenerator implements ArtifactGenerator { } try { - ArtifactGeneratorToscaParser.initWidgetConfiguration(); ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(configLocation); } catch (IOException e) { log.error(ApplicationMsgs.LOAD_PROPERTIES, e, configLocation); @@ -124,8 +123,9 @@ public class AaiArtifactGenerator implements ArtifactGenerator { * interface to the TOSCA parser * @return the generated Artifacts (containing XML models) * @throws XmlArtifactGenerationException + * if the configured widget mappings do not support processed widget type(s) */ - private GenerationData generateAllArtifacts(final String serviceVersion, ISdcCsarHelper csarHelper) + public GenerationData generateAllArtifacts(final String serviceVersion, ISdcCsarHelper csarHelper) throws XmlArtifactGenerationException { List serviceNodeTemplates = csarHelper.getServiceNodeTemplates(); if (serviceNodeTemplates == null) { @@ -182,6 +182,7 @@ public class AaiArtifactGenerator implements ArtifactGenerator { * @param serviceModel * @return the generated Models * @throws XmlArtifactGenerationException + * if the configured widget mappings do not support processed widget type(s) */ private List generateResourceModels(ISdcCsarHelper csarHelper, List serviceNodeTemplates, Service serviceModel) throws XmlArtifactGenerationException { @@ -201,6 +202,16 @@ public class AaiArtifactGenerator implements ArtifactGenerator { return resources; } + /** + * @param csarHelper + * @param serviceModel + * @param resources + * @param serviceGroups + * @param parser + * @param nodeTemplate + * @throws XmlArtifactGenerationException + * if the configured widget mappings do not support processed widget type(s) + */ private void generateModelFromNodeTemplate(ISdcCsarHelper csarHelper, Service serviceModel, List resources, final List serviceGroups, ArtifactGeneratorToscaParser parser, NodeTemplate nodeTemplate) throws XmlArtifactGenerationException { @@ -242,14 +253,22 @@ public class AaiArtifactGenerator implements ArtifactGenerator { if (model != null) { Metadata metadata = nodeTemplate.getMetaData(); if (metadata != null && parser.hasAllottedResource(metadata.getAllProperties()) - && model.getWidgetType() == Type.VF) { - model = new Resource(Type.ALLOTTED_RESOURCE, true); + && model.hasWidgetType("VF")) { + model = new Resource(WidgetType.valueOf("ALLOTTED_RESOURCE"), true); } } return model; } + /** + * @param csarHelper + * @param resources + * @param parser + * @param nodeTemplate + * @throws XmlArtifactGenerationException + * if the configured widget mappings do not support processed widget type(s) + */ private void generateResourceModel(ISdcCsarHelper csarHelper, List resources, ArtifactGeneratorToscaParser parser, NodeTemplate nodeTemplate) throws XmlArtifactGenerationException { Resource resourceModel = getModelFor(parser, nodeTemplate); @@ -268,11 +287,11 @@ public class AaiArtifactGenerator implements ArtifactGenerator { } if (parser.hasSubCategoryTunnelXConnect(serviceMetadata) && parser.hasAllottedResource(serviceMetadata)) { - resourceModel.addWidget(Widget.getWidget(Type.TUNNEL_XCONNECT)); + resourceModel.addWidget(Widget.createWidget("TUNNEL_XCONNECT")); } resources.addAll(parser.processInstanceGroups(resourceModel, nodeTemplate)); - resources.add((Resource) resourceModel); + resources.add(resourceModel); } /**