aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-03-24 08:51:20 -0700
committersebdet <sebastien.determe@intl.att.com>2020-03-24 08:51:20 -0700
commite65d457a2dfd6ebb5e1f5a28b74f05c16c285dc3 (patch)
treec1b72bb7924c826484b89d931f6a4a298082e64a /src/main/java/org
parentafac3121bfacc4d81903b1d8492613b0b77d3298 (diff)
Improve metadata support
Improve the metadata support for CDS and default values Issue-ID: CLAMP-786 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: I8a24e31a93ff1e288ec8f0f6d522b1b15d39a8d2
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/clamp/clds/config/DefaultDictionaryElements.java167
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java35
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java53
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java162
-rw-r--r--src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java2
5 files changed, 307 insertions, 112 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/DefaultDictionaryElements.java b/src/main/java/org/onap/clamp/clds/config/DefaultDictionaryElements.java
new file mode 100644
index 00000000..d9b017b5
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/config/DefaultDictionaryElements.java
@@ -0,0 +1,167 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.config;
+
+import javax.annotation.PostConstruct;
+import org.onap.clamp.tosca.Dictionary;
+import org.onap.clamp.tosca.DictionaryElement;
+import org.onap.clamp.tosca.DictionaryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+@Configuration
+@Profile("default-dictionary-elements")
+public class DefaultDictionaryElements {
+
+ @Autowired
+ private DictionaryService dictionaryService;
+
+ /**
+ * Init method.
+ */
+ @PostConstruct
+ public void init() {
+ preProvisionDefaultActors();
+ preProvisionDefaultOperations();
+ }
+
+ private void preProvisionDefaultActors () {
+ // Set up dictionary elements
+ Dictionary actorDictionary = new Dictionary();
+ actorDictionary.setName("DefaultActors");
+ actorDictionary.setSecondLevelDictionary(0);
+ actorDictionary.setSubDictionaryType("");
+
+ DictionaryElement elementSo = new DictionaryElement();
+ elementSo.setName("SO");
+ elementSo.setShortName("SO");
+ elementSo.setType("string");
+ elementSo.setDescription("SO component");
+ actorDictionary.addDictionaryElements(elementSo);
+
+ DictionaryElement elementSdnc = new DictionaryElement();
+ elementSdnc.setName("SDNC");
+ elementSdnc.setShortName("SDNC");
+ elementSdnc.setType("string");
+ elementSdnc.setDescription("SDNC component");
+ actorDictionary.addDictionaryElements(elementSdnc);
+
+ DictionaryElement elementAppc = new DictionaryElement();
+ elementAppc.setName("APPC");
+ elementAppc.setShortName("APPC");
+ elementAppc.setType("string");
+ elementAppc.setDescription("APPC component");
+ actorDictionary.addDictionaryElements(elementAppc);
+
+ DictionaryElement elementVfc = new DictionaryElement();
+ elementVfc.setName("VFC");
+ elementVfc.setShortName("VFC");
+ elementVfc.setType("string");
+ elementVfc.setDescription("VFC component");
+ actorDictionary.addDictionaryElements(elementVfc);
+
+ DictionaryElement elementSdnr = new DictionaryElement();
+ elementSdnr.setName("SDNR");
+ elementSdnr.setShortName("SDNR");
+ elementSdnr.setType("string");
+ elementSdnr.setDescription("SDNR component");
+ actorDictionary.addDictionaryElements(elementSdnr);
+
+ dictionaryService.saveOrUpdateDictionary(actorDictionary);
+ }
+
+ private void preProvisionDefaultOperations () {
+ // Set up dictionary elements
+ Dictionary operationDictionary = new Dictionary();
+ operationDictionary.setName("DefaultOperations");
+ operationDictionary.setSecondLevelDictionary(0);
+ operationDictionary.setSubDictionaryType("");
+
+ DictionaryElement elementRestart = new DictionaryElement();
+ elementRestart.setName("Restart");
+ elementRestart.setShortName("Restart (APPC operation)");
+ elementRestart.setType("string");
+ elementRestart.setDescription("APPC operation");
+ operationDictionary.addDictionaryElements(elementRestart);
+
+ DictionaryElement elementRebuild = new DictionaryElement();
+ elementRebuild.setName("Rebuild");
+ elementRebuild.setShortName("Rebuild (APPC operation)");
+ elementRebuild.setType("string");
+ elementRebuild.setDescription("APPC operation");
+ operationDictionary.addDictionaryElements(elementRebuild);
+
+ DictionaryElement elementMigrate = new DictionaryElement();
+ elementMigrate.setName("Migrate");
+ elementMigrate.setShortName("Migrate (APPC operation)");
+ elementMigrate.setType("string");
+ elementMigrate.setDescription("APPC operation");
+ operationDictionary.addDictionaryElements(elementMigrate);
+
+ DictionaryElement elementHealthCheck = new DictionaryElement();
+ elementHealthCheck.setName("Health-Check");
+ elementHealthCheck.setShortName("Health-Check (APPC operation)");
+ elementHealthCheck.setType("string");
+ elementHealthCheck.setDescription("APPC operation");
+ operationDictionary.addDictionaryElements(elementHealthCheck);
+
+ DictionaryElement elementModifyConfig = new DictionaryElement();
+ elementModifyConfig.setName("ModifyConfig");
+ elementModifyConfig.setShortName("ModifyConfig (APPC/VFC operation)");
+ elementModifyConfig.setType("string");
+ elementModifyConfig.setDescription("APPC/VFC operation");
+ operationDictionary.addDictionaryElements(elementModifyConfig);
+
+ DictionaryElement elementVfModuleCreate = new DictionaryElement();
+ elementVfModuleCreate.setName("VF Module Create");
+ elementVfModuleCreate.setShortName("VF Module Create (SO operation)");
+ elementVfModuleCreate.setType("string");
+ elementVfModuleCreate.setDescription("SO operation");
+ operationDictionary.addDictionaryElements(elementVfModuleCreate);
+
+ DictionaryElement elementVfModuleDelete = new DictionaryElement();
+ elementVfModuleDelete.setName("VF Module Delete");
+ elementVfModuleDelete.setShortName("VF Module Delete (SO operation)");
+ elementVfModuleDelete.setType("string");
+ elementVfModuleDelete.setDescription("SO operation");
+ operationDictionary.addDictionaryElements(elementVfModuleDelete);
+
+ DictionaryElement elementReroute = new DictionaryElement();
+ elementReroute.setName("Reroute");
+ elementReroute.setShortName("Reroute (SDNC operation)");
+ elementReroute.setType("string");
+ elementReroute.setDescription("SDNC operation");
+ operationDictionary.addDictionaryElements(elementReroute);
+
+ DictionaryElement elementBandwidthOnDemand = new DictionaryElement();
+ elementBandwidthOnDemand.setName("BandwidthOnDemand");
+ elementBandwidthOnDemand.setShortName("BandwidthOnDemand (SDNC operation)");
+ elementBandwidthOnDemand.setType("string");
+ elementBandwidthOnDemand.setDescription("SDNC operation");
+ operationDictionary.addDictionaryElements(elementBandwidthOnDemand);
+
+ dictionaryService.saveOrUpdateDictionary(operationDictionary);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
index dbd8ee1b..92401190 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
@@ -32,8 +32,6 @@ import javax.annotation.PostConstruct;
import org.onap.clamp.clds.tosca.update.execution.cds.ToscaMetadataCdsProcess;
import org.onap.clamp.clds.tosca.update.execution.target.ToscaMetadataTargetProcess;
import org.onap.clamp.loop.service.Service;
-import org.onap.clamp.tosca.Dictionary;
-import org.onap.clamp.tosca.DictionaryElement;
import org.onap.clamp.tosca.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -73,38 +71,5 @@ public class ToscaMetadataExecutor {
public void init() {
mapOfProcesses.put("CDS", new ToscaMetadataCdsProcess());
mapOfProcesses.put("CSAR_RESOURCES", new ToscaMetadataTargetProcess());
-
- preProvisionDictionaryTable();
}
-
- private void preProvisionDictionaryTable() {
- // Set up dictionary elements
- Dictionary actorDictionary = new Dictionary();
- actorDictionary.setName("DefaultActor");
- actorDictionary.setSecondLevelDictionary(0);
- actorDictionary.setSubDictionaryType("");
-
- DictionaryElement elementSo = new DictionaryElement();
- elementSo.setName("SO");
- elementSo.setShortName("SO");
- elementSo.setType("string");
- elementSo.setDescription("SO component");
- actorDictionary.addDictionaryElements(elementSo);
-
- DictionaryElement elementSdnc = new DictionaryElement();
- elementSdnc.setName("SDNC");
- elementSdnc.setShortName("SDNC");
- elementSdnc.setType("string");
- elementSdnc.setDescription("SDNC component");
- actorDictionary.addDictionaryElements(elementSdnc);
-
- DictionaryElement elementCds = new DictionaryElement();
- elementCds.setName("CDS");
- elementCds.setShortName("CDS");
- elementCds.setType("string");
- elementCds.setDescription("CDS component");
- actorDictionary.addDictionaryElements(elementCds);
-
- dictionaryService.saveOrUpdateDictionary(actorDictionary);
- }
}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
index cf9e010b..b1c88903 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
@@ -43,31 +43,34 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
@Override
public void executeProcess(String parameters, JsonObject childObject, Service serviceModel) {
switch (parameters) {
+ case "actor":
+ JsonArray jsonArray = new JsonArray();
+ jsonArray.add("CDS");
+ addToJsonArray(childObject, "enum", jsonArray);
+ break;
case "payload":
- childObject.add("anyOf", generatePayload(serviceModel));
+ generatePayload(childObject, serviceModel);
break;
case "operation":
- childObject.add("enum", generateOperation(serviceModel));
+ generateOperation(childObject, serviceModel);
break;
}
}
- private static JsonArray generatePayload(Service serviceModel) {
- JsonArray schemaAnyOf = new JsonArray();
- schemaAnyOf.addAll(generatePayloadPerResource("VF", serviceModel));
- schemaAnyOf.addAll(generatePayloadPerResource("PNF", serviceModel));
- return schemaAnyOf;
+ private static void generatePayload(JsonObject childObject, Service serviceModel) {
+ generatePayloadPerResource(childObject, "VF", serviceModel);
+ generatePayloadPerResource(childObject, "PNF", serviceModel);
}
- private static JsonArray generateOperation(Service serviceModel) {
- JsonArray schemaEnum = new JsonArray();
- schemaEnum.addAll(generateOperationPerResource("VF", serviceModel));
- schemaEnum.addAll(generateOperationPerResource("PNF", serviceModel));
- return schemaEnum;
+ private static void generateOperation(JsonObject childObject, Service serviceModel) {
+ generateOperationPerResource(childObject, "VF", serviceModel);
+ generateOperationPerResource(childObject, "PNF", serviceModel);
}
- private static JsonArray generateOperationPerResource(String resourceName, Service serviceModel) {
+ private static void generateOperationPerResource(JsonObject childObject, String resourceName,
+ Service serviceModel) {
JsonArray schemaEnum = new JsonArray();
+ JsonArray schemaTitle = new JsonArray();
for (Map.Entry<String, JsonElement> entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName)
.entrySet()) {
JsonObject controllerProperties = entry.getValue().getAsJsonObject()
@@ -75,14 +78,23 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
if (controllerProperties != null) {
for (String workflowsEntry : controllerProperties.getAsJsonObject("workflows").keySet()) {
schemaEnum.add(workflowsEntry);
+ schemaTitle.add(workflowsEntry + " (CDS operation)");
}
}
}
- return schemaEnum;
+ addToJsonArray(childObject, "enum", schemaEnum);
+ if (childObject.get("options") == null) {
+ JsonObject optionsSection = new JsonObject();
+ childObject.add("options", optionsSection);
+ }
+ addToJsonArray(childObject.getAsJsonObject("options"), "enum_titles", schemaTitle);
+
}
- private static JsonArray generatePayloadPerResource(String resourceName, Service serviceModel) {
+ private static void generatePayloadPerResource(JsonObject childObject, String resourceName,
+ Service serviceModel) {
JsonArray schemaAnyOf = new JsonArray();
+
for (Map.Entry<String, JsonElement> entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName)
.entrySet()) {
JsonObject controllerProperties = entry.getValue().getAsJsonObject()
@@ -98,7 +110,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
}
}
- return schemaAnyOf;
+ addToJsonArray(childObject, "enum", schemaAnyOf);
}
private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) {
@@ -110,4 +122,13 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
payloadResult.add("data", workFlow.getAsJsonObject("inputs"));
return payloadResult;
}
+
+ private static void addToJsonArray(JsonObject childObject, String section, JsonArray value) {
+ if (childObject.getAsJsonArray(section) != null) {
+ childObject.getAsJsonArray(section).addAll(value);
+ }
+ else {
+ childObject.add(section, value);
+ }
+ }
}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java b/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
index 8aff9668..33e08427 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
@@ -73,13 +73,17 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
((LinkedHashMap<String, Object>) childNodeMap.get(ToscaSchemaConstants.METADATA)).forEach((key,
value) -> {
if (key.equalsIgnoreCase(ToscaSchemaConstants.METADATA_CLAMP_POSSIBLE_VALUES)) {
- if (((String) value).contains(ToscaSchemaConstants.DICTIONARY)) {
- processDictionaryElements((String) value, childObject, dictionaryService);
- }
- if (((String) value).contains("ClampExecution:")) {
- executeClampProcess(((String) value).replaceAll("ClampExecution:", ""), childObject,
- serviceModel, toscaMetadataExecutor);
+ String[] multipleValues = ((String) value).split(",");
+ for (String multipleValue : multipleValues) {
+ if (multipleValue.contains(ToscaSchemaConstants.DICTIONARY)) {
+ processDictionaryElements(multipleValue, childObject, dictionaryService);
+ }
+ if (multipleValue.contains("ClampExecution:")) {
+ executeClampProcess(multipleValue.replaceAll("ClampExecution:", ""), childObject,
+ serviceModel, toscaMetadataExecutor);
+ }
}
+
}
});
}
@@ -91,75 +95,113 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
toscaMetadataExecutor.executeTheProcess(processInfo, childObject, serviceModel);
}
- private static void processDictionaryElements(String dictionaryReference, JsonObject childObject,
- DictionaryService dictionaryService) {
- String[] dictionaryKeyArray =
- dictionaryReference.substring(dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
- dictionaryReference.length()).split("#");
- if (dictionaryKeyArray.length > 1) {
- // We support only one # as of now.
- List<DictionaryElement> dictionaryElements = null;
- if (dictionaryKeyArray.length == 2) {
- dictionaryElements = new ArrayList<>(dictionaryService.getDictionary(dictionaryKeyArray[0])
- .getDictionaryElements());
- JsonArray subDictionaryNames = new JsonArray();
- new ArrayList<DictionaryElement>(dictionaryService.getDictionary(dictionaryKeyArray[1])
- .getDictionaryElements()).forEach(elem -> subDictionaryNames.add(elem.getShortName()));
-
- JsonArray jsonArray = new JsonArray();
-
- Optional.of(dictionaryElements).get().stream().forEach(c -> {
- JsonObject jsonObject = new JsonObject();
- jsonObject.addProperty(JsonEditorSchemaConstants.TYPE, getJsonType(c.getType()));
- if (c.getType() != null
- && c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
- jsonObject.addProperty(JsonEditorSchemaConstants.MIN_LENGTH, 1);
+ /**
+ * For dictionary with multiple levels (defined by #).
+ *
+ * @param dictionaryKeyArray the array containing the different elements
+ * @param childObject the structure getting the new entries
+ * @param dictionaryService the dictionary service bean
+ */
+ private static void processComplexDictionaryElements(String[] dictionaryKeyArray, JsonObject childObject,
+ DictionaryService dictionaryService) {
+ // We support only one # as of now.
+ List<DictionaryElement> dictionaryElements = null;
+ if (dictionaryKeyArray.length == 2) {
+ dictionaryElements = new ArrayList<>(dictionaryService.getDictionary(dictionaryKeyArray[0])
+ .getDictionaryElements());
+ JsonArray subDictionaryNames = new JsonArray();
+ new ArrayList<DictionaryElement>(dictionaryService.getDictionary(dictionaryKeyArray[1])
+ .getDictionaryElements()).forEach(elem -> subDictionaryNames.add(elem.getShortName()));
+
+ JsonArray jsonArray = new JsonArray();
+
+ Optional.of(dictionaryElements).get().forEach(c -> {
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.addProperty(JsonEditorSchemaConstants.TYPE, getJsonType(c.getType()));
+ if (c.getType() != null
+ && c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+ jsonObject.addProperty(JsonEditorSchemaConstants.MIN_LENGTH, 1);
- }
- jsonObject.addProperty(JsonEditorSchemaConstants.ID, c.getName());
- jsonObject.addProperty(JsonEditorSchemaConstants.LABEL, c.getShortName());
- jsonObject.add(JsonEditorSchemaConstants.OPERATORS, subDictionaryNames);
- jsonArray.add(jsonObject);
- });
+ }
+ jsonObject.addProperty(JsonEditorSchemaConstants.ID, c.getName());
+ jsonObject.addProperty(JsonEditorSchemaConstants.LABEL, c.getShortName());
+ jsonObject.add(JsonEditorSchemaConstants.OPERATORS, subDictionaryNames);
+ jsonArray.add(jsonObject);
+ });
- JsonObject filterObject = new JsonObject();
- filterObject.add(JsonEditorSchemaConstants.FILTERS, jsonArray);
+ JsonObject filterObject = new JsonObject();
+ filterObject.add(JsonEditorSchemaConstants.FILTERS, jsonArray);
- childObject.addProperty(JsonEditorSchemaConstants.TYPE,
- JsonEditorSchemaConstants.TYPE_QBLDR);
- // TO invoke validation on such parameters
- childObject.addProperty(JsonEditorSchemaConstants.MIN_LENGTH, 1);
- childObject.add(JsonEditorSchemaConstants.QSSCHEMA, filterObject);
+ childObject.addProperty(JsonEditorSchemaConstants.TYPE,
+ JsonEditorSchemaConstants.TYPE_QBLDR);
+ // TO invoke validation on such parameters
+ childObject.addProperty(JsonEditorSchemaConstants.MIN_LENGTH, 1);
+ childObject.add(JsonEditorSchemaConstants.QSSCHEMA, filterObject);
- }
}
- else {
- List<DictionaryElement> dictionaryElements =
- new ArrayList<>(dictionaryService.getDictionary(dictionaryKeyArray[0]).getDictionaryElements());
- JsonArray dictionaryNames = new JsonArray();
- JsonArray dictionaryFullNames = new JsonArray();
- dictionaryElements.stream().forEach(c -> {
- // Json type will be translated before Policy creation
- if (c.getType() != null && !c.getType().equalsIgnoreCase("json")) {
- dictionaryFullNames.add(c.getName());
- }
- dictionaryNames.add(c.getShortName());
- });
+ }
+
+ /**
+ * For dictionary with single entry.
+ *
+ * @param dictionaryKeyArray the array containing the different elements
+ * @param childObject the structure getting the new entries
+ * @param dictionaryService the dictionary service bean
+ */
+ private static void processSimpleDictionaryElements(String[] dictionaryKeyArray, JsonObject childObject,
+ DictionaryService dictionaryService) {
+ JsonArray dictionaryNames = new JsonArray();
+ JsonArray dictionaryFullNames = new JsonArray();
+ dictionaryService.getDictionary(dictionaryKeyArray[0]).getDictionaryElements().forEach(c -> {
+ // Json type will be translated before Policy creation
+ if (c.getType() != null && !c.getType().equalsIgnoreCase("json")) {
+ dictionaryFullNames.add(c.getName());
+ }
+ dictionaryNames.add(c.getShortName());
+ });
- if (dictionaryFullNames.size() > 0) {
+ if (dictionaryFullNames.size() > 0) {
+ if (childObject.get(JsonEditorSchemaConstants.ENUM) != null) {
+ childObject.get(JsonEditorSchemaConstants.ENUM).getAsJsonArray().add(dictionaryFullNames);
+ }
+ else {
childObject.add(JsonEditorSchemaConstants.ENUM, dictionaryFullNames);
- // Add Enum titles for generated translated values during JSON instance
- // generation
- JsonObject enumTitles = new JsonObject();
- enumTitles.add(JsonEditorSchemaConstants.ENUM_TITLES, dictionaryNames);
+ }
+ // Add Enum titles for generated translated values during JSON instance
+ // generation
+ JsonObject enumTitles = new JsonObject();
+ enumTitles.add(JsonEditorSchemaConstants.ENUM_TITLES, dictionaryNames);
+ if (childObject.get(JsonEditorSchemaConstants.OPTIONS) != null) {
+ childObject.get(JsonEditorSchemaConstants.OPTIONS).getAsJsonArray().add(enumTitles);
+ }
+ else {
childObject.add(JsonEditorSchemaConstants.OPTIONS, enumTitles);
}
+
+ }
+ else {
+ if (childObject.get(JsonEditorSchemaConstants.ENUM) != null) {
+ childObject.get(JsonEditorSchemaConstants.ENUM).getAsJsonArray().add(dictionaryNames);
+ }
else {
childObject.add(JsonEditorSchemaConstants.ENUM, dictionaryNames);
}
}
}
+ private static void processDictionaryElements(String dictionaryReference, JsonObject childObject,
+ DictionaryService dictionaryService) {
+ String[] dictionaryKeyArray =
+ dictionaryReference.substring(dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
+ dictionaryReference.length()).split("#");
+ if (dictionaryKeyArray.length > 1) {
+ processComplexDictionaryElements(dictionaryKeyArray, childObject, dictionaryService);
+ }
+ else {
+ processSimpleDictionaryElements(dictionaryKeyArray, childObject, dictionaryService);
+ }
+ }
+
private static String getJsonType(String toscaType) {
String jsonType = null;
if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)) {
diff --git a/src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java b/src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java
index ac054d8a..0c3f677a 100644
--- a/src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java
+++ b/src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java
@@ -61,7 +61,7 @@ public class PolicyEngineController {
this.policyEngineServices = policyEngineService;
}
- @Scheduled(fixedRate = 120000)
+ @Scheduled(fixedRate = 300000)
public synchronized void synchronizeAllPolicies() {
policyEngineServices.synchronizeAllPolicies();
lastInstantExecuted = Instant.now();