- private void processVfTosca(Map<String, String> idTypeStore, Model resourceModel,
- List<NodeTemplate> resourceNodes) {
- boolean foundProvidingService = false;
-
- for (NodeTemplate resourceNodeTemplate : resourceNodes) {
- String nodeTypeName = normaliseNodeTypeName(resourceNodeTemplate);
- Model resourceNode = Model.getModelFor(nodeTypeName);
- if (resourceNode instanceof ProvidingService) {
- foundProvidingService = true;
- Map<String, Property> nodeProperties = resourceNodeTemplate.getProperties();
- if (nodeProperties.get("providing_service_uuid") == null
- || nodeProperties.get("providing_service_invariant_uuid") == null) {
- throw new IllegalArgumentException(String.format(GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING,
- resourceModel.getModelId()));
- }
- Map<String, String> properties = populateStringProperties(nodeProperties);
- properties.put(VERSION, "1.0");
- resourceNode.populateModelIdentificationInformation(properties);
- resourceModel.addResource((Resource) resourceNode);
- } else if (resourceNode instanceof Resource && !(resourceNode.getWidgetType().equals(Widget.Type.L3_NET))) {
- idTypeStore.put(resourceNode.getModelNameVersionId(), nodeTypeName);
- resourceModel.addResource((Resource) resourceNode);
+ /**
+ * If the specified resourceNode is a type of Resource, add it to the specified resourceModel. If the Resource type
+ * is ProvidingService then return true, otherwise return false.
+ *
+ * @param resourceModel
+ * parent Resource
+ * @param metaData
+ * for populating the Resource IDs
+ * @param resourceNode
+ * any Model (will be ignored if not a Resource)
+ * @param nodeProperties
+ * the node properties
+ * @return whether or not a ProvidingService was processed
+ */
+ private boolean processModel(Model resourceModel, Metadata metaData, Resource resourceNode,
+ Map<String, Property> nodeProperties) {
+ boolean foundProvidingService = resourceNode != null
+ && (boolean) Optional.ofNullable(resourceNode.getProperties().get("providingService")).orElse(false);
+
+ if (foundProvidingService) {
+ processProvidingService(resourceModel, resourceNode, nodeProperties);
+ } else if (resourceNode != null && resourceNode.getModelType() == ModelType.RESOURCE
+ && !resourceNode.hasWidgetType("L3_NET")) {
+ if (metaData != null) {
+ resourceNode.populateModelIdentificationInformation(metaData.getAllProperties());