diff options
40 files changed, 356 insertions, 1024 deletions
diff --git a/gui-editors/gui-editor-apex/pom.xml b/gui-editors/gui-editor-apex/pom.xml index 52d8b96..c0f3819 100644 --- a/gui-editors/gui-editor-apex/pom.xml +++ b/gui-editors/gui-editor-apex/pom.xml @@ -65,7 +65,7 @@ </dependency> <dependency> <groupId>org.onap.policy.apex-pdp.model</groupId> - <artifactId>model-api</artifactId> + <artifactId>model</artifactId> <version>${policy.apex-pdp.version}</version> </dependency> <dependency> @@ -93,6 +93,10 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-ext</artifactId> + </dependency> </dependencies> <build> diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java index a5113e9..cc95b4b 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/EventHandler.java @@ -114,7 +114,7 @@ public class EventHandler implements RestCommandHandler { ApexApiResult result = session.getApexModelEdited().createEvent(jsonbean.getName(), jsonbean.getVersion(), jsonbean.getNameSpace(), jsonbean.getSource(), jsonbean.getTarget(), jsonbean.getUuid(), - jsonbean.getDescription()); + jsonbean.getDescription(), null); if (result.isOk()) { result = createEventParameters(session, jsonbean); @@ -193,7 +193,7 @@ public class EventHandler implements RestCommandHandler { if (result.isOk()) { result = session.getApexModelEdited().createEvent(jsonbean.getName(), jsonbean.getVersion(), jsonbean.getNameSpace(), jsonbean.getSource(), jsonbean.getTarget(), jsonbean.getUuid(), - jsonbean.getDescription()); + jsonbean.getDescription(), null); if (result.isOk() && jsonbean.getParameters() != null) { result = createEventParameters(session, jsonbean); diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java index 07051f2..c34b63e 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/ModelHandler.java @@ -246,7 +246,7 @@ public class ModelHandler implements RestCommandHandler { ApexApiResult result = session.getApexModel().getModelKey(); - LOGGER.exit("Model/GetKey" + (result != null && result.isOk() ? OK : NOT_OK)); + LOGGER.exit("Model/GetKey" + (result.isOk() ? OK : NOT_OK)); return result; } @@ -451,7 +451,7 @@ public class ModelHandler implements RestCommandHandler { String version) { // Look up the key information for the name and version var keyInfoJsonObject = lookupKeyInfo(session, name, version); - if (keyInfoJsonObject == null || keyInfoJsonObject.get(APEX_KEY_INFO) != null) { + if (keyInfoJsonObject == null || keyInfoJsonObject.get(APEX_KEY_INFO) == null) { return false; } diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java index 48daf9f..f92490b 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/RestSession.java @@ -49,9 +49,10 @@ public class RestSession { // Recurring string constants private static final String ENGINE_SERVICE_PARAMETERS = "engineServiceParameters"; private static final String POLICY_TYPE_IMPL = "policy_type_impl"; + private static final String APEX_POLICY_MODEL = "apexPolicyModel"; // The ID of the session - private int sessionId; + private final int sessionId; // The TOSCA Service Template of the session private ToscaServiceTemplate toscaServiceTemplate; @@ -79,14 +80,14 @@ public class RestSession { e); } - this.apexModel = new ApexModelFactory().createApexModel(null, true); + this.apexModel = new ApexModelFactory().createApexModel(null); } /** * Load the policy model from a TOSCA Service Template. * * @param toscaServiceTemplateString The TOSCA service template string - * @return the result of the lading operation + * @return the result of the loading operation */ public ApexApiResult loadFromString(final String toscaServiceTemplateString) { try { @@ -105,21 +106,42 @@ public class RestSession { return new ApexApiResult(Result.FAILED, "no policies found on incoming TOSCA service template"); } - @SuppressWarnings("unchecked") - var apexEngineServiceParameterMap = (Map<String, Object>) toscaServiceTemplate - .getToscaTopologyTemplate().getPoliciesAsMap().values().iterator().next().getProperties() - .get(ENGINE_SERVICE_PARAMETERS); - String apexModelString; try { - apexModelString = new StandardCoder().encode(apexEngineServiceParameterMap.get(POLICY_TYPE_IMPL)); - } catch (CoderException e) { + apexModelString = extractPolicyModel(toscaServiceTemplate); + } catch (Exception e) { return new ApexApiResult(Result.FAILED, "APEX model not found TOSCA Service template", e); } return apexModelEdited.loadFromString(apexModelString); } + private String extractPolicyModel(ToscaServiceTemplate toscaServiceTemplate) + throws IllegalArgumentException, CoderException { + // Check for "engineServiceParameters" + @SuppressWarnings("unchecked") + var engineServiceParameterMap = (Map<String, Object>) toscaServiceTemplate + .getToscaTopologyTemplate().getPoliciesAsMap().values().iterator().next().getProperties() + .get(ENGINE_SERVICE_PARAMETERS); + if (null == engineServiceParameterMap) { + throw new IllegalArgumentException(ENGINE_SERVICE_PARAMETERS + " not found in toscaServiceTemplate"); + } + + // Check for "policy_type_impl" + @SuppressWarnings("unchecked") + var policyTypeImplMap = (Map<String, Object>) engineServiceParameterMap.get(POLICY_TYPE_IMPL); + if (null == policyTypeImplMap) { + throw new IllegalArgumentException(POLICY_TYPE_IMPL + " not found in toscaServiceTemplate"); + } + + // Check for "apexPolicyModel", this is sometimes used to encapsulate policy models + @SuppressWarnings("unchecked") + var policyModelMap = (Map<String, Object>) policyTypeImplMap.get(APEX_POLICY_MODEL); + + // Encode "apexPolicyModel" if present, otherwise encode "policy_type_impl" + return new StandardCoder().encode(policyModelMap != null ? policyModelMap : policyTypeImplMap); + } + /** * Commence making changes to the Apex model. * @@ -130,7 +152,7 @@ public class RestSession { return new ApexApiResult(Result.FAILED, "model is already being edited"); } - apexModelEdited = apexModel.clone(); + apexModelEdited = apexModel.getCopy(); return new ApexApiResult(); } @@ -234,13 +256,4 @@ public class RestSession { public ApexModel getApexModelEdited() { return apexModelEdited; } - - /** - * Get the edited or unedited Apex model of the session. - * - * @return the apexModel - */ - public ApexModel getApexModelToDownload() { - return apexModelEdited == null ? apexModel : apexModelEdited; - } } diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java index 581fdd7..554eca9 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/TaskHandler.java @@ -27,7 +27,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; import org.onap.policy.apex.model.modelapi.ApexApiResult; import org.onap.policy.apex.model.modelapi.ApexApiResult.Result; import org.onap.policy.apex.model.policymodel.concepts.AxTask; -import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanField; import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanKeyRef; import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanLogic; import org.onap.policy.gui.editors.apex.rest.handling.bean.BeanTask; @@ -140,15 +139,7 @@ public class TaskHandler implements RestCommandHandler { * can be retrieved using {@link ApexApiResult#getMessages()} */ private ApexApiResult createTaskContent(final RestSession session, final BeanTask jsonbean) { - ApexApiResult result = createInputFields(session, jsonbean); - - if (result.isOk()) { - result = createOutputFields(session, jsonbean); - } - - if (result.isOk()) { - result = createTaskLogic(session, jsonbean); - } + ApexApiResult result = createTaskLogic(session, jsonbean); if (result.isOk()) { result = createTaskParameters(session, jsonbean); @@ -161,102 +152,6 @@ public class TaskHandler implements RestCommandHandler { } /** - * Create the input fields for the task. - * - * @param session the Apex model editing session - * @param jsonbean the ban containing the fields - * @return the result of the operation - */ - private ApexApiResult createInputFields(final RestSession session, final BeanTask jsonbean) { - var result = new ApexApiResult(); - - if (jsonbean.getInputFields() == null || jsonbean.getInputFields().isEmpty()) { - return result; - } - - for (final Entry<String, BeanField> fieldEntry : jsonbean.getInputFields().entrySet()) { - if (fieldEntry.getValue() == null) { - result.setResult(Result.FAILED); - result.addMessage("Null task input field information for field \"" + fieldEntry.getKey() + IN_TASK - + jsonbean.getName() + ":" + jsonbean.getVersion() - + ". The task was created, but there was an error adding the input fields." - + TASK_PARTIALLY_DEFINED); - continue; - } - - if (fieldEntry.getKey() == null || !fieldEntry.getKey().equals(fieldEntry.getValue().getLocalName())) { - result.setResult(Result.FAILED); - result.addMessage("Invalid task input field information for field \"" + fieldEntry.getKey() + IN_TASK - + jsonbean.getName() + ":" + jsonbean.getVersion() + ". The localName of the field (\"" - + fieldEntry.getValue().getLocalName() + "\") is not the same as the field name. " - + "The task was created, but there was an error adding the input fields." + TASK_PARTIALLY_DEFINED); - } else { - ApexApiResult fieldCreationResult = session.getApexModelEdited().createTaskInputField( - jsonbean.getName(), jsonbean.getVersion(), fieldEntry.getKey(), fieldEntry.getValue().getName(), - fieldEntry.getValue().getVersion(), fieldEntry.getValue().isOptional()); - - if (fieldCreationResult.isNok()) { - result.setResult(fieldCreationResult.getResult()); - result.addMessage("Failed to add task input field information for field \"" + fieldEntry.getKey() - + IN_TASK + jsonbean.getName() + ":" + jsonbean.getVersion() - + ". The task was created, but there was an error adding the input fields." - + TASK_PARTIALLY_DEFINED); - } - } - } - - return result; - } - - /** - * Create the output fields for the task. - * - * @param session the Apex model editing session - * @param jsonbean the ban containing the fields - * @return the result of the operation - */ - private ApexApiResult createOutputFields(final RestSession session, final BeanTask jsonbean) { - var result = new ApexApiResult(); - - if (jsonbean.getOutputFields() == null || jsonbean.getOutputFields().isEmpty()) { - return result; - } - - for (final Entry<String, BeanField> fieldEntry : jsonbean.getOutputFields().entrySet()) { - if (fieldEntry.getValue() == null) { - result.setResult(Result.FAILED); - result.addMessage("Null task output field information for field \"" + fieldEntry.getKey() + IN_TASK - + jsonbean.getName() + ":" + jsonbean.getVersion() - + ". The task was created, but there was an error adding the output fields." - + TASK_PARTIALLY_DEFINED); - continue; - } - - if (fieldEntry.getKey() == null || !fieldEntry.getKey().equals(fieldEntry.getValue().getLocalName())) { - result.setResult(Result.FAILED); - result.addMessage("Invalid task output field information for field \"" + fieldEntry.getKey() + IN_TASK - + jsonbean.getName() + ":" + jsonbean.getVersion() + ". The localName of the field (\"" - + fieldEntry.getValue().getLocalName() + "\") is not the same as the field name. " - + "The task was created, but there was an error adding the output fields." - + TASK_PARTIALLY_DEFINED); - } else { - ApexApiResult fieldCreationResult = session.getApexModelEdited().createTaskOutputField( - jsonbean.getName(), jsonbean.getVersion(), fieldEntry.getKey(), fieldEntry.getValue().getName(), - fieldEntry.getValue().getVersion(), fieldEntry.getValue().isOptional()); - if (fieldCreationResult.isNok()) { - result.setResult(fieldCreationResult.getResult()); - result.addMessage("Failed to add task output field information for field \"" + fieldEntry.getKey() - + IN_TASK + jsonbean.getName() + ":" + jsonbean.getVersion() - + ". The task was created, but there was an error adding the output fields." - + TASK_PARTIALLY_DEFINED); - } - } - } - - return result; - } - - /** * Create the task logic for the task. * * @param session the Apex model editing session diff --git a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanTask.java b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanTask.java index eebfc92..3c4d392 100644 --- a/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanTask.java +++ b/gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/handling/bean/BeanTask.java @@ -38,8 +38,6 @@ public class BeanTask extends BeanBase { private String uuid = null; private String description = null; private BeanLogic taskLogic = null; - private Map<String, BeanField> inputFields = null; - private Map<String, BeanField> outputFields = null; private Map<String, BeanTaskParameter> parameters = null; private BeanKeyRef[] contexts = null; @@ -49,7 +47,7 @@ public class BeanTask extends BeanBase { @Override public String toString() { return "BeanTask [name=" + name + ", version=" + version + ", uuid=" + uuid + ", description=" + description - + ", taskLogic=" + taskLogic + ", inputFields=" + inputFields + ", outputFields=" + outputFields - + ", parameters=" + parameters + ", contexts=" + Arrays.toString(contexts) + "]"; + + ", taskLogic=" + taskLogic + ", parameters=" + parameters + ", contexts=" + Arrays.toString(contexts) + + "]"; } } diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexAjax.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexAjax.js index b583ffd..fcd64df 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexAjax.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexAjax.js @@ -40,17 +40,16 @@ function ajax_get(requestURL, callback) { }); } -function ajax_getWithKeyInfo(requestURL, objectType, callback, keyNam) { +function ajax_getWithKeyInfo(requestURL, callback, keyNam) { let keyName = keyNam || "key"; let keyInfoURL = window.restRootURL + "/KeyInformation/Get?name=&version="; ajax_get(keyInfoURL, function(dataKeyInfos) { ajax_get(requestURL, function(data) { var keyInfos = []; for (let value of dataKeyInfos.messages) { - var ki = JSON.parse(value).apexKeyInfo; - keyInfos.push(ki); + keyInfos.push(JSON.parse(value)); } - var object = JSON.parse(data.messages[0])[objectType]; + var object = JSON.parse(data.messages[0]); var keyInfo = keyInfos.filter(function(ki) { return ki.key.name === object[keyName].name && ki.key.version === object[keyName].version; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextAlbumEditForm.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextAlbumEditForm.js index 687d7b3..1270b91 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextAlbumEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextAlbumEditForm.js @@ -32,7 +32,7 @@ function editContextAlbumForm_createContextAlbum(formParent) { var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (let value of data2.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; + var contextSchema = JSON.parse(value); contextSchemas.push({ "name" : contextSchema.key.name, "version" : contextSchema.key.version, @@ -58,13 +58,13 @@ function editContextAlbumForm_deleteContextAlbum(parent, name, version) { function editContextAlbumForm_viewContextAlbum(parent, name, version) { var requestURL = window.restRootURL + "/ContextAlbum/Get?name=" + name + "&version=" + version; - ajax_getWithKeyInfo(requestURL, "apexContextAlbum", function(contextAlbum) { + ajax_getWithKeyInfo(requestURL, function(contextAlbum) { // Get all contextSchemas too for album item schema requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (let value of data2.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; + var contextSchema = JSON.parse(value); contextSchemas.push({ "name" : contextSchema.key.name, "version" : contextSchema.key.version, @@ -79,13 +79,13 @@ function editContextAlbumForm_viewContextAlbum(parent, name, version) { function editContextAlbumForm_editContextAlbum(formParent, name, version) { var requestURL = window.restRootURL + "/ContextAlbum/Get?name=" + name + "&version=" + version; - ajax_getWithKeyInfo(requestURL, "apexContextAlbum", function(contextAlbum) { + ajax_getWithKeyInfo(requestURL, function(contextAlbum) { // Get all contextSchemas too for album item schema requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (let value of data2.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; + var contextSchema = JSON.parse(value); contextSchemas.push({ "name" : contextSchema.key.name, "version" : contextSchema.key.version, diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextAlbumTab.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextAlbumTab.js index fe9bcbb..a01a370 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextAlbumTab.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextAlbumTab.js @@ -39,7 +39,7 @@ function contextAlbumTab_activate() { $("#contextAlbumTableBody").find("tr:gt(0)").remove(); for (let value of data.messages) { - var contextAlbum = JSON.parse(value).apexContextAlbum; + var contextAlbum = JSON.parse(value); var contextAlbumRow_tr = document.createElement("tr"); diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextSchemaEditForm.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextSchemaEditForm.js index 06c4402..6c5a753 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextSchemaEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextSchemaEditForm.js @@ -46,14 +46,14 @@ function editContextSchemaForm_deleteContextSchema(parent, name, version) { function editContextSchemaForm_viewContextSchema(parent, name, version) { var requestURL = window.restRootURL + "/ContextSchema/Get?name=" + name + "&version=" + version; - ajax_getWithKeyInfo(requestURL, "apexContextSchema", function(contextSchema) { + ajax_getWithKeyInfo(requestURL, function(contextSchema) { editContextSchemaForm_activate(parent, "VIEW", contextSchema); }); } function editContextSchemaForm_editContextSchema(formParent, name, version) { var requestURL = window.restRootURL + "/ContextSchema/Get?name=" + name + "&version=" + version; - ajax_getWithKeyInfo(requestURL, "apexContextSchema", function(contextSchema) { + ajax_getWithKeyInfo(requestURL, function(contextSchema) { editContextSchemaForm_activate(formParent, "EDIT", contextSchema); }); } diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextSchemaTab.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextSchemaTab.js index 12f2e11..cfd402b 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextSchemaTab.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexContextSchemaTab.js @@ -37,7 +37,7 @@ function contextSchemaTab_activate() { $("#contextSchemaTableBody").find("tr:gt(0)").remove(); for (let value of data.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; + var contextSchema = JSON.parse(value); var contextSchemaRow_tr = document.createElement("tr"); var contextSchemaid = contextSchema.key.name + ":" + contextSchema.key.version; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexEventEditForm.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexEventEditForm.js index cc14b63..07805d7 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexEventEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexEventEditForm.js @@ -52,7 +52,7 @@ function editEventForm_createEvent(formParent) { var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (let value of data2.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; + var contextSchema = JSON.parse(value); var dt = { "name" : contextSchema.key.name, "version" : contextSchema.key.version, @@ -67,13 +67,13 @@ function editEventForm_createEvent(formParent) { function editEventForm_editEvent_inner(formParent, name, version, viewOrEdit) { var requestURL = window.restRootURL + "/Event/Get?name=" + name + "&version=" + version; - ajax_getWithKeyInfo(requestURL, "apexEvent", function(event) { + ajax_getWithKeyInfo(requestURL, function(event) { // Get all contextSchemas too for event params requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (let value of data2.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; + var contextSchema = JSON.parse(value); contextSchemas.push({ "name" : contextSchema.key.name, "version" : contextSchema.key.version, diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexEventTab.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexEventTab.js index cc431b5..f8780a9 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexEventTab.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexEventTab.js @@ -41,7 +41,7 @@ function eventTab_activate() { for (let value of data.messages) { - var event = JSON.parse(value).apexEvent; + var event = JSON.parse(value); var eventTableRow_tr = document.createElement("tr"); var eventid = event.key.name + ":" + event.key.version; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexFiles.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexFiles.js index f24534f..0395cee 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexFiles.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexFiles.js @@ -38,7 +38,7 @@ function files_fileOpen() { localStorage.setItem("apex_model_loaded", true); requestURL = window.restRootURL + "/Model/GetKey"; ajax_get(requestURL, function(data) { - var modelKey = JSON.parse(data.messages[0]).apexArtifactKey; + var modelKey = JSON.parse(data.messages[0]); pageControl_modelMode(modelKey.name, modelKey.version, fileName); }); }); diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexKeyInformationTab.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexKeyInformationTab.js index 814725a..45bfac8 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexKeyInformationTab.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexKeyInformationTab.js @@ -38,7 +38,7 @@ function keyInformationTab_activate() { $("#keyInformationTableBody").find("tr:gt(0)").remove(); for (let value of data.messages) { - var keyInfo = JSON.parse(value).apexKeyInfo; + var keyInfo = JSON.parse(value); var keyInfoRow_tr = document.createElement("tr"); var keyInfoRow = diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexMain.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexMain.js index da75fc9..46934d1 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexMain.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexMain.js @@ -125,7 +125,7 @@ function main_getRestRootURL() { ajax_get(requestURL, function(data) { $("#statusMessageTable").append("<tr><td> REST root URL set to: " + restRootURL + "</td></tr>"); if (localStorage.getItem("apex_model_loaded")) { - const modelKey = JSON.parse(data.messages[0]).apexArtifactKey; + const modelKey = JSON.parse(data.messages[0]); pageControl_modelMode(modelKey.name, modelKey.version, modelFileName); if (localStorage.getItem("apex_tab_index")) { $("#mainTabs").tabs({ diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexNewModelForm.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexNewModelForm.js index ff48d8f..e62aa9e 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexNewModelForm.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexNewModelForm.js @@ -224,7 +224,7 @@ function newModelForm_submitPressed() { requestURL = window.restRootURL + "/Model/GetKey"; ajax_get(requestURL, function(data) { - var modelKey = JSON.parse(data.messages[0]).apexArtifactKey; + var modelKey = JSON.parse(data.messages[0]); var modelFileName = modelKey.name + ".json"; pageControl_modelMode(modelKey.name, modelKey.version, modelFileName); }); diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexPolicyEditForm.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexPolicyEditForm.js index cf046c1..ca1aba4 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexPolicyEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexPolicyEditForm.js @@ -48,7 +48,7 @@ function editPolicyForm_deletePolicy(parent, name, version) { function editPolicyForm_viewPolicy(formParent, name, version) { // get the policy var requestURL = window.restRootURL + "/Policy/Get?name=" + name + "&version=" + version; - ajax_getWithKeyInfo(requestURL, "apexPolicy", function(policy) { + ajax_getWithKeyInfo(requestURL, function(policy) { editPolicyForm_editPolicy_inner(formParent, policy, "VIEW"); }, "policyKey"); } @@ -56,7 +56,7 @@ function editPolicyForm_viewPolicy(formParent, name, version) { function editPolicyForm_editPolicy(formParent, name, version) { // get the policy var requestURL = window.restRootURL + "/Policy/Get?name=" + name + "&version=" + version; - ajax_getWithKeyInfo(requestURL, "apexPolicy", function(policy) { + ajax_getWithKeyInfo(requestURL, function(policy) { editPolicyForm_editPolicy_inner(formParent, policy, "EDIT"); }, "policyKey"); } @@ -67,7 +67,7 @@ function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { var contextSchemas = new Array(); ajax_get(requestURL, function(data2) { for (let value of data2.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; + var contextSchema = JSON.parse(value); contextSchemas.push({ "name" : contextSchema.key.name, "version" : contextSchema.key.version, @@ -80,7 +80,7 @@ function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { var tasks = new Array(); ajax_get(requestURL, function(data3) { for (let value of data3.messages) { - var task = JSON.parse(value).apexTask; + var task = JSON.parse(value); tasks.push({ "name" : task.key.name, "version" : task.key.version, @@ -93,7 +93,7 @@ function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { var albums = new Array(); ajax_get(requestURL, function(data4) { for (let value of data4.messages) { - var album = JSON.parse(value).apexContextAlbum; + var album = JSON.parse(value); albums.push({ "name" : album.key.name, "version" : album.key.version, @@ -106,7 +106,7 @@ function editPolicyForm_editPolicy_inner(formParent, policy, viewOrEdit) { var events = new Array(); ajax_get(requestURL, function(data5) { for (let value of data5.messages) { - var event = JSON.parse(value).apexEvent; + var event = JSON.parse(value); events.push({ "name" : event.key.name, "version" : event.key.version, diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexPolicyTab.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexPolicyTab.js index 902bb2a..b86a5ca 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexPolicyTab.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexPolicyTab.js @@ -39,7 +39,7 @@ function policyTab_activate() { $("#policyTableBody").find("tr:gt(0)").remove(); for (let value of data.messages) { - var policy = JSON.parse(value).apexPolicy; + var policy = JSON.parse(value); var policyRow_tr = document.createElement("tr"); var policyid = policy.policyKey.name + ":" + policy.policyKey.version; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskEditForm.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskEditForm.js index ea33904..972fe22 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskEditForm.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskEditForm.js @@ -29,36 +29,21 @@ import { showHideTextarea } from "./showhideTextarea"; import {keyInformationTab_reset} from "./ApexKeyInformationTab"; function editTaskForm_createTask(formParent) { - // Get all contextSchemas too for task input/outputfields - var requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; - var contextSchemas = new Array(); - ajax_get(requestURL, function(data2) { - for (let value of data2.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; - var dt = { - "name" : contextSchema.key.name, - "version" : contextSchema.key.version, - "displaytext" : contextSchema.key.name + ":" + contextSchema.key.version, - "contextSchema" : contextSchema + // Get all contextAlbums too for task context album references + var requestURL = window.restRootURL + "/ContextAlbum/Get?name=&version="; + var contextAlbums = new Array(); + ajax_get(requestURL, function(data3) { + for (let value of data3.messages) { + var contextAlbum = JSON.parse(value); + var ca = { + "name" : contextAlbum.key.name, + "version" : contextAlbum.key.version, + "displaytext" : contextAlbum.key.name + ":" + contextAlbum.key.version, + "contextAlbum" : contextAlbum }; - contextSchemas.push(dt); + contextAlbums.push(ca); } - // Get all contextAlbums too for task context album references - requestURL = window.restRootURL + "/ContextAlbum/Get?name=&version="; - var contextAlbums = new Array(); - ajax_get(requestURL, function(data3) { - for (let value of data3.messages) { - var contextAlbum = JSON.parse(value).apexContextAlbum; - var ca = { - "name" : contextAlbum.key.name, - "version" : contextAlbum.key.version, - "displaytext" : contextAlbum.key.name + ":" + contextAlbum.key.version, - "contextAlbum" : contextAlbum - }; - contextAlbums.push(ca); - } - editTaskForm_activate(formParent, "CREATE", null, contextSchemas, contextAlbums); - }); + editTaskForm_activate(formParent, "CREATE", null, contextAlbums); }); } @@ -84,41 +69,27 @@ function editTaskForm_editTask(formParent, name, version) { function editTaskForm_editTask_inner(formParent, name, version, viewOrEdit) { var requestURL = window.restRootURL + "/Task/Get?name=" + name + "&version=" + version; - ajax_getWithKeyInfo(requestURL, "apexTask", function(task) { - // Get all contextSchemas too for task inputfields - requestURL = window.restRootURL + "/ContextSchema/Get?name=&version="; - var contextSchemas = new Array(); - ajax_get(requestURL, function(data2) { - for (let value of data2.messages) { - var contextSchema = JSON.parse(value).apexContextSchema; - contextSchemas.push({ - "name" : contextSchema.key.name, - "version" : contextSchema.key.version, - "displaytext" : contextSchema.key.name + ":" + contextSchema.key.version, - "contextSchema" : contextSchema - }); + ajax_getWithKeyInfo(requestURL, function(task) { + // Get all contextAlbums too for task context album references + requestURL = window.restRootURL + "/ContextAlbum/Get?name=&version="; + var contextAlbums = new Array(); + ajax_get(requestURL, function(data3) { + for (let value of data3.messages) { + var contextAlbum = JSON.parse(value); + var ca = { + "name" : contextAlbum.key.name, + "version" : contextAlbum.key.version, + "displaytext" : contextAlbum.key.name + ":" + contextAlbum.key.version, + "contextAlbum" : contextAlbum + }; + contextAlbums.push(ca); } - // Get all contextAlbums too for task context album references - requestURL = window.restRootURL + "/ContextAlbum/Get?name=&version="; - var contextAlbums = new Array(); - ajax_get(requestURL, function(data3) { - for (let value of data3.messages) { - var contextAlbum = JSON.parse(value).apexContextAlbum; - var ca = { - "name" : contextAlbum.key.name, - "version" : contextAlbum.key.version, - "displaytext" : contextAlbum.key.name + ":" + contextAlbum.key.version, - "contextAlbum" : contextAlbum - }; - contextAlbums.push(ca); - } - editTaskForm_activate(formParent, viewOrEdit, task, contextSchemas, contextAlbums); - }); + editTaskForm_activate(formParent, viewOrEdit, task, contextAlbums); }); }); } -function editTaskForm_activate(parent, operation, task, contextSchemas, contextAlbums) { +function editTaskForm_activate(parent, operation, task, contextAlbums) { apexUtils_removeElement("editTaskFormDiv"); var formParent = document.getElementById(parent); @@ -262,122 +233,6 @@ function editTaskForm_activate(parent, operation, task, contextSchemas, contextA } descriptionTextArea.readOnly = edit_disabled; - // input fields - var inputfieldsLI = document.createElement("li"); - formul.appendChild(inputfieldsLI); - var inputfieldsLabel = document.createElement("label"); - inputfieldsLI.appendChild(inputfieldsLabel); - inputfieldsLabel.setAttribute("for", "editTaskFormInputFieldsTable"); - inputfieldsLabel.innerHTML = "Task Input Fields: "; - var inputfieldstable = document.createElement("table"); - inputfieldstable.setAttribute("id", "editTaskFormInputFieldsTable"); - inputfieldstable.setAttribute("name", "editTaskFormInputFieldsTable"); - inputfieldstable.setAttribute("class", "table-taskinputfield"); - inputfieldsLI.appendChild(inputfieldstable); - var inputfieldstable_head = document.createElement("thead"); - inputfieldstable.appendChild(inputfieldstable_head); - var inputfieldstable_head_tr = document.createElement("tr"); - inputfieldstable_head.appendChild(inputfieldstable_head_tr); - inputfieldstable_head_tr.appendChild(document.createElement("th")); // empty, - // for - // delete - // button - var inputfieldstable_head_th = document.createElement("th"); - inputfieldstable_head_tr.appendChild(inputfieldstable_head_th); - inputfieldstable_head_th.innerHTML = "Input Field Name: "; - inputfieldstable_head_th.setAttribute("class", "table-taskinputfield-heading form-heading"); - inputfieldstable_head_th = document.createElement("th"); - inputfieldstable_head_tr.appendChild(inputfieldstable_head_th); - inputfieldstable_head_th.innerHTML = "Input Field Type/Schema: "; - inputfieldstable_head_th.setAttribute("class", "table-taskinputfield-heading form-heading"); - inputfieldstable_head_th = document.createElement("th"); - inputfieldstable_head_tr.appendChild(inputfieldstable_head_th); - inputfieldstable_head_th.innerHTML = "Optional: "; - inputfieldstable_head_th.setAttribute("class", "table-eventparam-heading form-heading"); - var inputfieldstable_body = document.createElement("tbody"); - inputfieldstable.appendChild(inputfieldstable_body); - // Add the inputfields - if (task && task.inputFields && task.inputFields.entry) { - for (let inputfieldEntry of task.inputFields.entry) { - var contextSchema = inputfieldEntry.value.fieldSchemaKey; - contextSchema["displaytext"] = contextSchema.name + ":" + contextSchema.version; - editTaskForm_addTaskInputField(inputfieldstable_body, (createEditOrView == "VIEW"), inputfieldEntry.key, - inputfieldEntry.value.optional, contextSchema, contextSchemas); - } - } - // add the New Input Field button - if (createEditOrView == "CREATE" || createEditOrView == "EDIT") { - var inputfieldTR = document.createElement("tr"); - inputfieldTR.setAttribute("class", "field-taskinputfield-tr.new"); - inputfieldstable_body.appendChild(inputfieldTR); - var inputfieldTD = document.createElement("td"); - inputfieldTD.setAttribute("colspan", "3"); - inputfieldTR.appendChild(inputfieldTD); - var addInputFieldInput = createAddFormButton(); - inputfieldTD.appendChild(addInputFieldInput); - addInputFieldInput.onclick = function() { - editTaskForm_addTaskInputField(inputfieldstable_body, false, null, false, null, contextSchemas); - }; - } - - // output fields - var outputfieldsLI = document.createElement("li"); - formul.appendChild(outputfieldsLI); - var outputfieldsLabel = document.createElement("label"); - outputfieldsLI.appendChild(outputfieldsLabel); - outputfieldsLabel.setAttribute("for", "editTaskFormOutputFieldsTable"); - outputfieldsLabel.innerHTML = "Task Output Fields: "; - var outputfieldstable = document.createElement("table"); - outputfieldstable.setAttribute("id", "editTaskFormOutputFieldsTable"); - outputfieldstable.setAttribute("name", "editTaskFormOutputFieldsTable"); - outputfieldstable.setAttribute("class", "table-taskoutputfield"); - outputfieldsLI.appendChild(outputfieldstable); - var outputfieldstable_head = document.createElement("thead"); - outputfieldstable.appendChild(outputfieldstable_head); - var outputfieldstable_head_tr = document.createElement("tr"); - outputfieldstable_head.appendChild(outputfieldstable_head_tr); - outputfieldstable_head_tr.appendChild(document.createElement("th")); // empty, - // for - // delete - // button - var outputfieldstable_head_th = document.createElement("th"); - outputfieldstable_head_tr.appendChild(outputfieldstable_head_th); - outputfieldstable_head_th.innerHTML = "Output Field Name: "; - outputfieldstable_head_th.setAttribute("class", "table-taskoutputfield-heading form-heading"); - outputfieldstable_head_th = document.createElement("th"); - outputfieldstable_head_tr.appendChild(outputfieldstable_head_th); - outputfieldstable_head_th.innerHTML = "Output Field Type/Schema: "; - outputfieldstable_head_th.setAttribute("class", "table-taskoutputfield-heading form-heading"); - outputfieldstable_head_th = document.createElement("th"); - outputfieldstable_head_tr.appendChild(outputfieldstable_head_th); - outputfieldstable_head_th.innerHTML = "Optional: "; - outputfieldstable_head_th.setAttribute("class", "table-eventparam-heading form-heading"); - var outputfieldstable_body = document.createElement("tbody"); - outputfieldstable.appendChild(outputfieldstable_body); - // Add the outputfields - if (task && task.outputFields && task.outputFields.entry) { - for (let outputfieldEntry of task.outputFields.entry) { - contextSchema = outputfieldEntry.value.fieldSchemaKey; - contextSchema["displaytext"] = contextSchema.name + ":" + contextSchema.version; - editTaskForm_addTaskOutputField(outputfieldstable_body, (createEditOrView == "VIEW"), outputfieldEntry.key, - outputfieldEntry.value.optional, contextSchema, contextSchemas); - } - } - // add the New Output Field button - if (createEditOrView == "CREATE" || createEditOrView == "EDIT") { - var outputfieldTR = document.createElement("tr"); - outputfieldTR.setAttribute("class", "field-taskoutputfield-tr.new"); - outputfieldstable_body.appendChild(outputfieldTR); - var outputfieldTD = document.createElement("td"); - outputfieldTD.setAttribute("colspan", "3"); - outputfieldTR.appendChild(outputfieldTD); - var addOutputFieldInput = createAddFormButton(); - outputfieldTD.appendChild(addOutputFieldInput); - addOutputFieldInput.onclick = function() { - editTaskForm_addTaskOutputField(outputfieldstable_body, false, null, false, null, contextSchemas); - }; - } - // tasklogic var tasklogicLI = document.createElement("li"); formul.appendChild(tasklogicLI); @@ -581,144 +436,6 @@ function editTaskForm_activate(parent, operation, task, contextSchemas, contextA scrollToTop(); } -function editTaskForm_addTaskInputField(parentTBody, disabled, name, optional, contextSchema, contextSchemas) { - var random_suffix = formUtils_generateUUID(); - - var inputfieldTR = parentTBody.insertRow(parentTBody.rows.length - 1); - inputfieldTR.setAttribute("inputfield_id", random_suffix); - inputfieldTR.setAttribute("class", "field-taskinputfield-tr"); - if (name == null && contextSchema == null && !disabled) { - inputfieldTR.setAttribute("class", "field-taskinputfield-tr.new field-add-new"); - $(inputfieldTR).show("fast"); - } - - var deleteTD = document.createElement("td"); - inputfieldTR.appendChild(deleteTD); - var deleteDiv = document.createElement("div"); - deleteTD.appendChild(deleteDiv); - if (!disabled) { - deleteDiv.setAttribute("class", "ebIcon ebIcon_interactive ebIcon_delete"); - deleteDiv.onclick = function(event) { - $(inputfieldTR).hide("fast", function() { - inputfieldTR.parentNode.removeChild(inputfieldTR); - }); - } - } else { - deleteDiv.setAttribute("class", "ebIcon ebIcon_interactive ebIcon_delete ebIcon_disabled"); - } - var nameTD = document.createElement("td"); - inputfieldTR.appendChild(nameTD); - var nameInput = document.createElement("input"); - nameTD.appendChild(nameInput); - nameInput.setAttribute("id", "editTaskFormInputFieldName" + "_" + random_suffix); - nameInput.setAttribute("type", "text"); - nameInput.setAttribute("name", "editTaskFormInputFieldName" + "_" + random_suffix); - nameInput.setAttribute("class", "field-taskinputfield-name ebInput ebInput_width_xLong"); - if (name == null && contextSchema == null && !disabled) { - nameInput.setAttribute("class", "field-taskinputfield-name.new ebInput ebInput_width_xLong"); - } - nameInput.setAttribute("placeholder", "Input Field Name"); - if (name) { - nameInput.value = name; - } - nameInput.readOnly = disabled; - - var contextSchemaTD = document.createElement("td"); - inputfieldTR.appendChild(contextSchemaTD); - - var selectDiv = dropdownList("editTaskFormInputFieldContextSchema" + "_" + random_suffix, contextSchemas, - contextSchema, disabled, null) - contextSchemaTD.appendChild(selectDiv); - - var inputOptionalTD = document.createElement("td"); - inputOptionalTD.setAttribute("class", "field-checkbox-center"); - inputfieldTR.appendChild(inputOptionalTD); - var inputOptional = document.createElement("input"); - inputOptional.setAttribute("type", "checkbox"); - inputOptional.setAttribute("id", "editTaskFormInputFieldOptional" + "_" + random_suffix); - inputOptional.setAttribute("name", "editTaskFormInputFieldOptional" + "_" + random_suffix); - inputOptional.setAttribute("class", "field-eventparam-optional"); - if (name == null && contextSchema == null && !disabled) { - inputOptional.setAttribute("class", "field-eventparam-optional.new"); - } - if (optional) { - inputOptional.checked = true; - } else { - inputOptional.checked = false; - } - inputOptional.disabled = disabled; - inputOptionalTD.appendChild(inputOptional); -} - -function editTaskForm_addTaskOutputField(parentTBody, disabled, name, optional, contextSchema, contextSchemas) { - var random_suffix = formUtils_generateUUID(); - - var outputfieldTR = parentTBody.insertRow(parentTBody.rows.length - 1); - outputfieldTR.setAttribute("outputfield_id", random_suffix); - outputfieldTR.setAttribute("class", "field-taskoutputfield-tr"); - if (name == null && contextSchema == null && !disabled) { - outputfieldTR.setAttribute("class", "field-taskoutputfield-tr.new field-add-new"); - $(outputfieldTR).show("fast"); - } - - var deleteTD = document.createElement("td"); - outputfieldTR.appendChild(deleteTD); - var deleteDiv = document.createElement("div"); - deleteTD.appendChild(deleteDiv); - if (!disabled) { - deleteDiv.setAttribute("class", "ebIcon ebIcon_interactive ebIcon_delete"); - deleteDiv.onclick = function(event) { - $(outputfieldTR).hide("fast", function() { - outputfieldTR.parentNode.removeChild(outputfieldTR); - }); - } - } else { - deleteDiv.setAttribute("class", "ebIcon ebIcon_interactive ebIcon_delete ebIcon ebIcon_disabled"); - } - var nameTD = document.createElement("td"); - outputfieldTR.appendChild(nameTD); - var nameInput = document.createElement("input"); - nameTD.appendChild(nameInput); - nameInput.setAttribute("id", "editTaskFormOutputFieldName" + "_" + random_suffix); - nameInput.setAttribute("type", "text"); - nameInput.setAttribute("name", "editTaskFormOutputFieldName" + "_" + random_suffix); - nameInput.setAttribute("class", "field-taskoutputfield-name ebInput ebInput_width_xLong"); - if (name == null && contextSchema == null && !disabled) { - nameInput.setAttribute("class", "field-taskoutputfield-name.new ebInput ebInput_width_xLong"); - } - nameInput.setAttribute("placeholder", "Output Field Name"); - if (name) { - nameInput.value = name; - } - nameInput.readOnly = disabled; - - var contextSchemaTD = document.createElement("td"); - outputfieldTR.appendChild(contextSchemaTD); - - var selectDiv = dropdownList("editTaskFormOutputFieldContextSchema" + "_" + random_suffix, contextSchemas, - contextSchema, disabled, null) - contextSchemaTD.appendChild(selectDiv); - - var outputOptionalTD = document.createElement("td"); - outputOptionalTD.setAttribute("class", "field-checkbox-center"); - outputfieldTR.appendChild(outputOptionalTD); - var outputOptional = document.createElement("input"); - outputOptional.setAttribute("type", "checkbox"); - outputOptional.setAttribute("id", "editTaskFormOutputFieldOptional" + "_" + random_suffix); - outputOptional.setAttribute("name", "editTaskFormOutputFieldOptional" + "_" + random_suffix); - outputOptional.setAttribute("class", "field-eventparam-optional"); - if (name == null && contextSchema == null && !disabled) { - outputOptional.setAttribute("class", "field-eventparam-optional.new"); - } - if (optional) { - outputOptional.checked = true; - } else { - outputOptional.checked = false; - } - outputOptional.disabled = disabled; - outputOptionalTD.appendChild(outputOptional); -} - function editTaskForm_addTaskParameter(parentTBody, disabled, name, value) { var random_suffix = formUtils_generateUUID(); @@ -840,75 +557,6 @@ function editTaskForm_submitPressed() { var name = document.getElementById('editTaskFormNameInput').value; var version = document.getElementById('editTaskFormVersionInput').value; - // get the task inputfields - var taskbean_inputfields = null; - var inputfieldstablerows = document.getElementById("editTaskFormInputFieldsTable").rows; - if (inputfieldstablerows && inputfieldstablerows.length > 2) { - taskbean_inputfields = new Object(); - for (var i = 1; i < inputfieldstablerows.length - 1; i++) { - var inputfieldTR = inputfieldstablerows[i]; - if (inputfieldTR && inputfieldTR.getAttribute("inputfield_id")) { - var inputfield_id = inputfieldTR.getAttribute("inputfield_id"); - var inputfieldname = document.getElementById("editTaskFormInputFieldName" + "_" + inputfield_id).value; - var inputfield_optional = document.getElementById("editTaskFormInputFieldOptional" + "_" - + inputfield_id).checked; - var inputfield_dt = document.getElementById("editTaskFormInputFieldContextSchema" + "_" + inputfield_id - + "_dropdownList").selectedOption; - if (taskbean_inputfields[inputfieldname]) { - alert("Task \"" + name + "\" contains more than one Input Field called \"" + inputfieldname + "\""); - return false; - } - if (inputfield_dt == null) { - alert("Task \"" + name + "\" has no selected Context Item Schema for the Input Field called \"" - + inputfieldname + "\""); - return false; - } - var inputfield_dt_name = inputfield_dt.name; - var inputfield_dt_version = inputfield_dt.version; - taskbean_inputfields[inputfieldname] = { - "localName" : inputfieldname, - "name" : inputfield_dt_name, - "version" : inputfield_dt_version, - "optional" : inputfield_optional - }; - } - } - } - // get the task outputfields - var taskbean_outputfields = null; - var outputfieldstablerows = document.getElementById("editTaskFormOutputFieldsTable").rows; - if (outputfieldstablerows && outputfieldstablerows.length > 2) { - taskbean_outputfields = new Object(); - for (var g = 1; g < outputfieldstablerows.length - 1; g++) { - var outputfieldTR = outputfieldstablerows[g]; - if (outputfieldTR && outputfieldTR.getAttribute("outputfield_id")) { - var outputfield_id = outputfieldTR.getAttribute("outputfield_id"); - var outputfieldname = document.getElementById("editTaskFormOutputFieldName" + "_" + outputfield_id).value; - var outputfield_optional = document.getElementById("editTaskFormOutputFieldOptional" + "_" - + outputfield_id).checked; - var outputfield_dt = document.getElementById("editTaskFormOutputFieldContextSchema" + "_" - + outputfield_id + "_dropdownList").selectedOption; - if (taskbean_outputfields[outputfieldname]) { - alert("Task \"" + name + "\" contains more than one Output Field called \"" + outputfieldname - + "\""); - return false; - } - if (outputfield_dt == null) { - alert("Task \"" + name + "\" has no selected Context Item Schema for the Output Field called \"" - + outputfieldname + "\""); - return false; - } - var outputfield_dt_name = outputfield_dt.name; - var outputfield_dt_version = outputfield_dt.version; - taskbean_outputfields[outputfieldname] = { - "localName" : outputfieldname, - "name" : outputfield_dt_name, - "version" : outputfield_dt_version, - "optional" : outputfield_optional - }; - } - } - } // get the logic fields var logicfield = document.getElementById("editTaskFormTaskLogicTextArea_textarea").value; var logictype = document.getElementById("editTaskFormTaskLogicTypeInput").value; @@ -916,6 +564,10 @@ function editTaskForm_submitPressed() { alert("Task \"" + name + "\" has no Task Logic Type"); return false; } + if (logicfield == null || logicfield == "") { + alert("Task \"" + name + "\" has no Task Logic"); + return false; + } var tasklogic = { "logic" : logicfield, "logicFlavour" : logictype @@ -981,8 +633,6 @@ function editTaskForm_submitPressed() { "uuid" : document.getElementById('editTaskFormUuidInput').value, "description" : document.getElementById('editTaskFormDescriptionTextArea').value, "taskLogic" : tasklogic, - "inputFields" : taskbean_inputfields, - "outputFields" : taskbean_outputfields, "parameters" : taskbean_parameters, "contexts" : taskbean_context } @@ -1009,8 +659,6 @@ function editTaskForm_submitPressed() { export { editTaskForm_activate, editTaskForm_addTaskContext, - editTaskForm_addTaskInputField, - editTaskForm_addTaskOutputField, editTaskForm_addTaskParameter, editTaskForm_cancelPressed, editTaskForm_createTask, diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js index afd0cad..eaf014f 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js @@ -39,7 +39,7 @@ function taskTab_activate() { $("#taskTableBody").find("tr:gt(0)").remove(); for (let value of data.messages) { - const task = JSON.parse(value).apexTask; + const task = JSON.parse(value); const taskRow_tr = document.createElement("tr"); @@ -51,36 +51,6 @@ function taskTab_activate() { task.taskLogic.logicFlavour + "</td>"; - taskTableRow += "<td><table class='ebTable'><thead><tr class='headerRow'><th>Field Name</th><th>Field Type/Schema</th><th>Optional</th></tr></thead><tbody>"; - for (let fieldEntry of task.inputFields.entry) { - - taskTableRow += - "<tr><td>" + - fieldEntry.key + - "</td>" + - "<td>" + - fieldEntry.value.fieldSchemaKey.name + ":" + fieldEntry.value.fieldSchemaKey.version + - "<td>" + - fieldEntry.value.optional + - "</td></tr>"; - } - taskTableRow += "</tbody></table></td>"; - - taskTableRow += "<td><table class='ebTable'><thead><tr class='headerRow'><th>Field Name</th><th>Field Type/Schema</th><th>Optional</th></tr></thead><tbody>"; - for (let fieldEntry of task.outputFields.entry) { - - taskTableRow += - "<tr><td>" + - fieldEntry.key + - "</td>" + - "<td>" + - fieldEntry.value.fieldSchemaKey.name + ":" + fieldEntry.value.fieldSchemaKey.version + - "<td>" + - fieldEntry.value.optional + - "</td></tr>"; - } - taskTableRow += "</tbody></table></td>"; - taskTableRow += "<td><table class='ebTable'><thead><tr class='headerRow'><th>Parameter Name</th><th>Default Value</th></tr></thead><tbody>"; for (let parameterEntry of task.taskParameters.entry) { @@ -156,16 +126,6 @@ function taskTab_create() { taskTableLogicFlavourHeader.setAttribute("id", "taskTableLogicFlavourHeader"); taskTableLogicFlavourHeader.appendChild(document.createTextNode("Logic Flavour")); - var taskTableInputFieldHeader = document.createElement("th"); - taskTableHeaderRow.appendChild(taskTableInputFieldHeader); - taskTableInputFieldHeader.setAttribute("id", "taskTableInputFieldHeader"); - taskTableInputFieldHeader.appendChild(document.createTextNode("Input Fields")); - - var taskTableOutputFieldHeader = document.createElement("th"); - taskTableHeaderRow.appendChild(taskTableOutputFieldHeader); - taskTableOutputFieldHeader.setAttribute("id", "taskTableOutputFieldHeader"); - taskTableOutputFieldHeader.appendChild(document.createTextNode("Output Fields")); - var taskTableParameterHeader = document.createElement("th"); taskTableHeaderRow.appendChild(taskTableParameterHeader); taskTableParameterHeader.setAttribute("id", "taskTableParameterHeader"); diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexUtils.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexUtils.js index 2b18559..7ae7ebf 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexUtils.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexUtils.js @@ -86,6 +86,12 @@ function createEditArea(id, options, callback) { var is_editable = options.hasOwnProperty("is_editable") ? options.is_editable : true; var toolbar = options.toolbar ? options.toolbar : "select_font, |, highlight, reset_highlight"; + var inlineScript = 'function onEditAreaChange(id) { $("#"+id).val(editAreaLoader.getValue(id)); }'; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.appendChild(document.createTextNode(inlineScript)); + document.body.appendChild(script); + setTimeout(function() { editAreaLoader.init({ id : id, @@ -101,10 +107,6 @@ function createEditArea(id, options, callback) { } -function onEditAreaChange(id) { - $("#" + id).val(editAreaLoader.getValue(id)); -} - function isFirefox() { return (navigator.userAgent.indexOf("Firefox") != -1); } diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexAjax.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexAjax.test.js index 362a1f9..9880328 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexAjax.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexAjax.test.js @@ -60,49 +60,79 @@ test('Test ajax_get success', (done) => { test('Test ajax_getWithKeyInfo success', (done) => { const myCallback = jest.fn((actual) => { expect(actual).toEqual({ - key: { - name: "name1", - version: "version1" - }, + key: { name: "name1", version: "version1" }, uuid: "UUID1", description: "description1" }); done(); }); - data.messages = [ - '{"apexKeyInfo": {"UUID": "UUID1", "description": "description1", "key":{"name": "name1", "version":' + - ' "version1"}}, "objectType": {"key": {"name": "name1", "version": "version1"}}}' - ]; const jqXHR = {status: 200, responseText: ""}; $.ajax = jest.fn().mockImplementation((args) => { - args.success(data, null, jqXHR); - }); - mod.ajax_getWithKeyInfo("requestUrl", "objectType", myCallback, undefined); + if (args.url.endsWith("/KeyInformation/Get?name=&version=")) { + var results1 = { + messages: [ + JSON.stringify({ + UUID: "UUID1", + description: "description1", + key: { name: "name1", version: "version1" } + }) + ], + result: 'SUCCESS' + }; + args.success(results1, null, jqXHR); + } else if (args.url === "requestUrl") { + var results2 = { + messages: [ + JSON.stringify({ + key: { name: "name1", version: "version1" } + }) + ], + result: 'SUCCESS' + }; + args.success(results2, null, jqXHR); + } + }); + mod.ajax_getWithKeyInfo("requestUrl", myCallback, undefined); }); test('Test ajax_getWithKeyInfo with custom key success', (done) => { const myCallback = jest.fn((actual) => { expect(actual).toEqual({ - customKey: { - name: "name1", - version: "version1" - }, + customKey: { name: "name1", version: "version1" }, uuid: "UUID1", description: "description1" }); done(); }); - data.messages = [ - '{"apexKeyInfo": {"UUID": "UUID1", "description": "description1", "key":{"name": "name1",' + - ' "version": "version1"}}, "objectType": {"customKey": {"name": "name1", "version": "version1"}}}' - ]; const jqXHR = {status: 200, responseText: ""}; $.ajax = jest.fn().mockImplementation((args) => { - args.success(data, null, jqXHR); - }); - mod.ajax_getWithKeyInfo("requestUrl", "objectType", myCallback, "customKey"); + if (args.url.endsWith("/KeyInformation/Get?name=&version=")) { + var results1 = { + messages: [ + JSON.stringify({ + UUID: "UUID1", + description: "description1", + key: { name: "name1", version: "version1" } + }) + ], + result: 'SUCCESS' + }; + args.success(results1, null, jqXHR); + } else if (args.url === "requestUrl") { + var results2 = { + messages: [ + JSON.stringify({ + customKey: { name: "name1", version: "version1" } + }) + ], + result: 'SUCCESS' + }; + args.success(results2, null, jqXHR); + } + }); + mod.ajax_getWithKeyInfo("requestUrl", myCallback, "customKey"); }); test('Test ajax_delete error', () => { diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexContextAlbumEditForm.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexContextAlbumEditForm.test.js index e5268fe..61f4e8e 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexContextAlbumEditForm.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexContextAlbumEditForm.test.js @@ -25,9 +25,7 @@ const formUtils_generateDescription = require('../ApexFormUtils'); let data = { messages: [ - '{"apexContextSchema": {"key":{"name": "name1", "version": "version1"}}, "apexTask":{"key":{"name": "name1", "version": "version1"}},' + - '"apexContextAlbum":{"key":{"name": "name1", "version": "version1"},"itemSchema":{}},"apexEvent":{"key":{"name": "name1", "version": "version1"}},' + - '"apexPolicy":{"policyKey":{"name": "name1", "version": "version1"}}, "apexKeyInfo":{"key":{"name": "name1", "version": "version1"}}}' + JSON.stringify({key: {name: "name1", version: "0.0.1"}, itemSchema: {}}) ], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexContextSchemaTab.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexContextSchemaTab.test.js index 9c7ca8c..243190f 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexContextSchemaTab.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexContextSchemaTab.test.js @@ -20,11 +20,9 @@ const mod = require('../ApexContextSchemaTab'); -let data = { +const data = { messages: [ - '{"apexContextSchema": {"key":{"name": "name1", "version": "version1"}}, "apexTask":{"key":{"name": "name1", "version": "version1"}},' + - '"apexContextAlbum":{"key":{"name": "name1", "version": "version1"}},"apexEvent":{"key":{"name": "name1", "version": "version1"}},' + - '"apexPolicy":{"policyKey":{"name": "name1", "version": "version1"}}, "apexKeyInfo":{"key":{"name": "name1", "version": "version1"}}}' + JSON.stringify({key: {name: "name1", version: "0.0.1"}}) ], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexEventEditForm.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexEventEditForm.test.js index c1ac98b..f98577e 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexEventEditForm.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexEventEditForm.test.js @@ -26,9 +26,7 @@ const keyInformationTab_reset = require('../ApexKeyInformationTab'); let data = { messages: [ - '{"apexContextSchema": {"key":{"name": "name1", "version": "version1"}}, "apexTask":{"key":{"name": "name1", "version": "version1"}},' + - '"apexContextAlbum":{"key":{"name": "name1", "version": "version1"}},"apexEvent":{"key":{"name": "name1", "version": "version1"}},' + - '"apexPolicy":{"policyKey":{"name": "name1", "version": "version1"}}, "apexKeyInfo":{"key":{"name": "name1", "version": "version1"}}}' + JSON.stringify({key: {name: "name1", version: "0.0.1"}}) ], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexEventTab.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexEventTab.test.js index 50d1101..cc9f722 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexEventTab.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexEventTab.test.js @@ -29,18 +29,23 @@ test('Test activate', () => { document.body.innerHTML = '<div id="eventsTab"></div>'; const data = { - useHttps: 'useHttps', - hostname: 'hostname', - port: 'port', - username: 'username', - password: 'password', messages: [ - '{"apexEvent" : {"key": {"name": "name1", "version":"version1"}, "nameSpace":"nameSpace1",' + - ' "source":"source1", "target":"target1", "parameter": ' + - '{"entry": [{"key": "key1", "value": {"optional":"optional", "fieldSchemaKey": ' + - '{"name": "name2", "version":"version2"}}}]}}}' + JSON.stringify({ + key: { name: "name1", version: "version1" }, + nameSpace: "nameSpace1", + source: "source1", + target: "target1", + parameter: { + entry: [{ + key: "key1", + value: { + optional: "optional", + fieldSchemaKey: { name: "name2", version: "version2" } + } + }] + } + }) ], - content: ['01', '02'], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexFiles.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexFiles.test.js index 9e2307a..566939c 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexFiles.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexFiles.test.js @@ -21,11 +21,9 @@ const mod = require('../ApexFiles'); const resultForm_activate = require('../ApexResultForm'); -let data = { +const data = { messages: [ - '{"apexContextSchema": {"key":{"name": "name1", "version": "version1"}}, "apexTask":{"key":{"name": "name1", "version": "version1"}},' + - '"apexContextAlbum":{"key":{"name": "name1", "version": "version1"},"itemSchema":{}},"apexEvent":{"key":{"name": "name1", "version": "version1"}},' + - '"apexPolicy":{"policyKey":{"name": "name1", "version": "version1"}}, "apexKeyInfo":{"key":{"name": "name1", "version": "version1"}}}' + JSON.stringify({key: {name: "name1", version: "0.0.1"}}) ], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexKeyInformationTab.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexKeyInformationTab.test.js index fb49214..260454a 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexKeyInformationTab.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexKeyInformationTab.test.js @@ -23,16 +23,13 @@ const ApexKeyInformationTab = require("../ApexKeyInformationTab"); test("Test keyInformationTab_activate", () => { document.body.innerHTML = '<div id ="keyInformationTab"></div>'; const data = { - useHttps: 'useHttps', - hostname: 'hostname', - port: 'port', - username: 'username', - password: 'password', messages: [ - '{"apexKeyInfo": {"UUID": "UUID1", "description": "description1", "key":{"name": "name1", "version":' + - ' "version1"}}, "objectType": {"key": {"name": "name1", "version": "version1"}}}' + JSON.stringify({ + UUID: "UUID1", + description: "description1", + key: {name: "name1", version: "version1"} + }) ], - content: ['01', '02'], result: 'SUCCESS' }; $.ajax = jest.fn().mockImplementation((args) => { diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexMain.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexMain.test.js index c825370..8018577 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexMain.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexMain.test.js @@ -31,16 +31,8 @@ require('../../dist/js/jquery-ui-1.12.1/jquery-ui.js'); const data = { messages: [ - '{' + - ' "apexArtifactKey": {' + - ' "key": {' + - ' "name": "name1",' + - ' "version": "version1"' + - ' }' + - ' }' + - '}' + JSON.stringify({ key: { name: "name1", version: "version1" }}) ], - content: ['01', '02'], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm.test.js index fc92934..202ebc9 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyEditForm.test.js @@ -31,9 +31,10 @@ const policy = { } let data = { messages: [ - '{"apexContextSchema": {"key":{"name": "name1", "version": "version1"}}, "apexTask":{"key":{"name": "name1", "version": "version1"}},' + - '"apexContextAlbum":{"key":{"name": "name1", "version": "version1"}},"apexEvent":{"key":{"name": "name1", "version": "version1"}},' + - '"apexPolicy":{"policyKey":{"name": "name1", "version": "version1"}}, "apexKeyInfo":{"key":{"name": "name1", "version": "version1"}}}' + JSON.stringify({ + key: {name: "name1", version: "0.0.1"}, + policyKey: {name: "name1", version: "0.0.1"}, + }) ], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyTab.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyTab.test.js index 58714c6..50ec488 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyTab.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexPolicyTab.test.js @@ -28,158 +28,150 @@ test('Test policyTab_activate', () => { document.body.innerHTML = '<div id="policiesTab"></div>'; const data = { - useHttps: 'useHttps', - hostname: 'hostname', - port: 'port', - username: 'username', - password: 'password', messages: [ - '{' + - ' "apexPolicy": {' + - ' "policyKey": {' + - ' "name": "name1",' + - ' "version": "version1"' + - ' },' + - ' "template": "template1",' + - ' "firstState": "key11",' + - ' "state": {' + - ' "entry": [' + - ' {' + - ' "key": "key1",' + - ' "value": {' + - ' "trigger": {' + - ' "name": "name2",' + - ' "version": "version2"' + - ' },' + - ' "taskReferences": {' + - ' "entry": [' + - ' {' + - ' "key": {' + - ' "name": "name3",' + - ' "version": "version3"' + - ' },' + - ' "version": "version2",' + - ' "value": {' + - ' "outputType": "outputType1",' + - ' "output": {' + - ' "localName": "localName1"' + - ' }' + - ' }' + - ' }' + - ' ]' + - ' },' + - ' "defaultTask": {' + - ' "name": "name4",' + - ' "version": "version4"' + - ' },' + - ' "taskSelectionLogic": {' + - ' "logicFlavour": "logicFlavour1"' + - ' },' + - ' "stateOutputs": {' + - ' "entry": [' + - ' {' + - ' "key": "key2",' + - ' "value": {' + - ' "nextState": {' + - ' "localName": "localName2"' + - ' },' + - ' "outgoingEvent": {' + - ' "name": "name4",' + - ' "version": "version4"' + - ' }' + - ' }' + - ' }' + - ' ]' + - ' },' + - ' "stateFinalizerLogicMap": {' + - ' "entry": [' + - ' {' + - ' "key": "key3",' + - ' "value": {' + - ' "logicFlavour": "logicFlavour2"' + - ' }' + - ' }' + - ' ]' + - ' },' + - ' "contextAlbumReference": [' + - ' {' + - ' "name": "name5",' + - ' "version": "version5"' + - ' }' + - ' ]' + - ' }' + - ' },' + - ' {' + - ' "key": "key11",' + - ' "value": {' + - ' "trigger": {' + - ' "name": "name12",' + - ' "version": "version12"' + - ' },' + - ' "taskReferences": {' + - ' "entry": [' + - ' {' + - ' "key": {' + - ' "name": "name13",' + - ' "version": "version13"' + - ' },' + - ' "version": "version12",' + - ' "value": {' + - ' "outputType": "outputType11",' + - ' "output": {' + - ' "localName": "localName11"' + - ' }' + - ' }' + - ' }' + - ' ]' + - ' },' + - ' "defaultTask": {' + - ' "name": "name14",' + - ' "version": "version14"' + - ' },' + - ' "taskSelectionLogic": {' + - ' "logicFlavour": "logicFlavour11"' + - ' },' + - ' "stateOutputs": {' + - ' "entry": [' + - ' {' + - ' "key": "key12",' + - ' "value": {' + - ' "nextState": {' + - ' "localName": "localName12"' + - ' },' + - ' "outgoingEvent": {' + - ' "name": "name14",' + - ' "version": "version14"' + - ' }' + - ' }' + - ' }' + - ' ]' + - ' },' + - ' "stateFinalizerLogicMap": {' + - ' "entry": [' + - ' {' + - ' "key": "key13",' + - ' "value": {' + - ' "logicFlavour": "logicFlavour12"' + - ' }' + - ' }' + - ' ]' + - ' },' + - ' "contextAlbumReference": [' + - ' {' + - ' "name": "name15",' + - ' "version": "version15"' + - ' }' + - ' ]' + - ' }' + - ' }' + - ' ]' + - ' }' + - ' }' + - '}' + JSON.stringify({ + policyKey: { + name: "name1", + version: "version1" + }, + template: "template1", + firstState: "key11", + state: { + entry: [ + { + key: "key1", + value: { + trigger: { + name: "name2", + version: "version2" + }, + taskReferences: { + entry: [ + { + key: { + name: "name3", + version: "version3" + }, + version: "version2", + value: { + outputType: "outputType1", + output: { + localName: "localName1" + } + } + } + ] + }, + defaultTask: { + name: "name4", + version: "version4" + }, + taskSelectionLogic: { + logicFlavour: "logicFlavour1" + }, + stateOutputs: { + entry: [ + { + key: "key2", + value: { + nextState: { + localName: "localName2" + }, + outgoingEvent: { + name: "name4", + version: "version4" + } + } + } + ] + }, + stateFinalizerLogicMap: { + entry: [ + { + key: "key3", + value: { + logicFlavour: "logicFlavour2" + } + } + ] + }, + contextAlbumReference: [ + { + name: "name5", + version: "version5" + } + ] + } + }, + { + key: "key11", + value: { + trigger: { + name: "name12", + version: "version12" + }, + taskReferences: { + entry: [ + { + key: { + name: "name13", + version: "version13" + }, + version: "version12", + value: { + outputType: "outputType11", + output: { + localName: "localName11" + } + } + } + ] + }, + defaultTask: { + name: "name14", + version: "version14" + }, + taskSelectionLogic: { + logicFlavour: "logicFlavour11" + }, + stateOutputs: { + entry: [ + { + key: "key12", + value: { + nextState: { + localName: "localName12" + }, + outgoingEvent: { + name: "name14", + version: "version14" + } + } + } + ] + }, + stateFinalizerLogicMap: { + entry: [ + { + key: "key13", + value: { + logicFlavour: "logicFlavour12" + } + } + ] + }, + contextAlbumReference: [ + { + name: "name15", + version: "version15" + } + ] + } + } + ] + } + }) ], - content: ['01', '02'], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js index fdc30d7..d2f8eaa 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskEditForm.test.js @@ -42,8 +42,6 @@ const task = { taskLogic: { logicFlavour: 'testFlav' }, - inputFields : {entry: [{key: "key1", value: {fieldSchemaKey: { name : "name2", version : "version2"}}}]}, - outputFields : {entry: [{key: "key01", value: {fieldSchemaKey: { name : "name02", version : "version02"}}}]}, taskParameters: {entry: [{key: 'testKey',value: {defaultValue: 'testValue'}}]}, contextAlbumReference : [{name : 'contextEntry.name',version : 'contextEntry.version', displaytext : 'contextName'}, {name : 'contextEntry.name2',version : 'contextEntry.version2', displaytext : 'contextName2'}, @@ -52,9 +50,7 @@ const task = { let data = { messages: [ - '{"apexContextSchema": {"key":{"name": "name1", "version": "version1"}}, "apexTask":{"key":{"name": "name1", "version": "version1"}},' + - '"apexContextAlbum":{"key":{"name": "name1", "version": "version1"}},"apexEvent":{"key":{"name": "name1", "version": "version1"}},' + - '"apexPolicy":{"policyKey":{"name": "name1", "version": "version1"}}, "apexKeyInfo":{"key":{"name": "name1", "version": "version1"}}}' + JSON.stringify({key: {name: "name1", version: "0.0.1"}}) ], result: 'SUCCESS' }; @@ -116,22 +112,6 @@ test('Test Edit Task Inner', () => { expect(mock_activate).toBeCalled(); }); -test('Test editTaskForm_addTaskInputField', () => { - const mock_activate = jest.fn(mod.editTaskForm_addTaskInputField); - let contextSchemas = new Array(); - contextSchemas.push(contextSchema); - mock_activate(parentTBody, true, 'name', null, contextSchema, contextSchemas); - expect(mock_activate).toBeCalled(); -}); - -test('Test editTaskForm_addTaskOutputField', () => { - const mock_activate = jest.fn(mod.editTaskForm_addTaskOutputField); - let contextSchemas = new Array(); - contextSchemas.push(contextSchema); - mock_activate(parentTBody, true, 'name', null, contextSchema, contextSchemas); - expect(mock_activate).toBeCalled(); -}); - test('Test editTaskForm_addTaskParameter', () => { const mock_activate = jest.fn(mod.editTaskForm_addTaskParameter); mock_activate(parentTBody, true, 'name', null); @@ -200,9 +180,9 @@ test('Test editTaskForm_submitPressed with page', () => { document.documentElement.innerHTML = '<html><head></head><body>' + '<table id="editTaskFormInputFieldsTable" value="v0">' + - '<tr class="table" inputfield_id="a1" outputfield_id="b1" param_id="c1" context_id="d1" value="v1"><td>cell1</td><td>cell2</td></tr>' + - '<tr class="table" inputfield_id="a2" outputfield_id="b2" param_id="c2" context_id="d2" value="v2"><td>cell3</td><td>cell4</td></tr>' + - '<tr class="table" inputfield_id="a3" outputfield_id="b3" param_id="c3" context_id="d3" value="v3"><td>cell5</td><td>cell6</td></tr>' + + '<tr class="table" param_id="a1" context_id="b1" value="v1"><td>cell1</td><td>cell2</td></tr>' + + '<tr class="table" param_id="a2" context_id="b2" value="v2"><td>cell3</td><td>cell4</td></tr>' + + '<tr class="table" param_id="a3" context_id="b3" value="v3"><td>cell5</td><td>cell6</td></tr>' + '</table>' + '</body></html>'; let documentSpy = jest.spyOn(document, 'getElementById'); diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskTab.test.js b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskTab.test.js index bf5faee..4f0d94f 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskTab.test.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/__test__/ApexTaskTab.test.js @@ -22,13 +22,13 @@ const mod = require('../ApexTaskTab'); let data = { messages: [ - '{"apexContextSchema": {"key":{"name": "name1", "version": "version1"}}, "apexTask":{"key":{"name": "name1", "version": "version1"},' + - '"taskLogic":{"logicFlavour":"logicFlavour"},"inputFields":{"entry": [{"key":"","value":{"fieldSchemaKey":{"name":"name"}}}]},' + - '"outputFields":{"entry": [{"key":"","value":{"fieldSchemaKey":{"name":"name"}}}]},' + - '"taskParameters":{"entry": [{"key":"","value":{"fieldSchemaKey":{"name":"name"}}}]},'+ - '"contextAlbumReference":[{"name":"name", "version":"version"}]},'+ - '"apexContextAlbum":{"key":{"name": "name1", "version": "version1"}},"apexEvent":{"key":{"name": "name1", "version": "version1"}},' + - '"apexPolicy":{"policyKey":{"name": "name1", "version": "version1"}}, "apexKeyInfo":{"key":{"name": "name1", "version": "version1"}}}' + JSON.stringify({ + key: {name: "name1", version: "version1"}, + taskLogic: {logicFlavour: "logicFlavour"}, + taskParameters: {entry: [{key: "", value: {fieldSchemaKey: {name: "name"}}}]}, + contextAlbumReference: [{name: "name", version: "version"}], + policyKey: {name: "name1", version: "version1"}, + }) ], result: 'SUCCESS' }; diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/showhideTextarea.js b/gui-editors/gui-editor-apex/src/main/webapp/js/showhideTextarea.js index 8c98d3f..c5fe428 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/js/showhideTextarea.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/showhideTextarea.js @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020-2021 Nordix Foundation. + * Modifications Copyright (C) 2020-2022 Nordix Foundation. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,6 +20,8 @@ * ============LICENSE_END========================================================= */ +import {createEditArea} from "./ApexUtils"; + function showHideTextarea_display_hide(showHideDivprefix) { var ta = document.getElementById(showHideDivprefix + "_textarea"); var sh = document.getElementById(showHideDivprefix + "_showhide"); diff --git a/gui-editors/gui-editor-apex/src/main/webapp/webpack.config.js b/gui-editors/gui-editor-apex/src/main/webapp/webpack.config.js index 9efbbc6..e7e4523 100644 --- a/gui-editors/gui-editor-apex/src/main/webapp/webpack.config.js +++ b/gui-editors/gui-editor-apex/src/main/webapp/webpack.config.js @@ -10,6 +10,6 @@ module.exports = { devServer: { contentBase: path.join(__dirname, 'dist'), compress: true, - port: 9000 - } -};
\ No newline at end of file + port: 9000, + }, +}; diff --git a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java index e5f24ff..90a9b4d 100644 --- a/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java +++ b/gui-editors/gui-editor-apex/src/test/java/org/onap/policy/gui/editors/apex/rest/handling/ApexEditorRestResourceTest.java @@ -781,76 +781,6 @@ class ApexEditorRestResourceTest { result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) .content(entityString).contentType(APPLICATION_JSON)); assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - entityString = "{" + "\"name\" : \"HowsItGoing\"," + "\"version\" : \"0.0.2\"," - + "\"inputFields\" : {\"IField0\" : {\"name\" : \"StringType\", \"version\" : \"0.0.1\", " - + "\"localName\" : \"IField0\", \"optional\" : false}}," - + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\"," - + "\"description\" : \"A description of hello\"" + "}"; - result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) - .content(entityString).contentType(APPLICATION_JSON)); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - entityString = "{" + "\"name\" : \"Hi\"," + "\"version\" : \"0.0.2\"," - + "\"inputFields\" : {\"IField0\" : null}," - + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\"," - + "\"description\" : \"A description of hello\"" + "}"; - result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) - .content(entityString).contentType(APPLICATION_JSON)); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - entityString = "{" + "\"name\" : \"GoodDay\"," + "\"version\" : \"0.0.2\"," - + "\"inputFields\" : {\"IField0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\", " - + "\"localName\" : \"IField0\", \"optional\" : false}}," - + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\"," - + "\"description\" : \"A description of hello\"" + "}"; - result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) - .content(entityString).contentType(APPLICATION_JSON)); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - entityString = "{" + "\"name\" : \"Howdy\"," + "\"version\" : \"0.0.2\"," - + "\"inputFields\" : {\"IField0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\", " - + "\"localName\" : \"NotIField0\", \"optional\" : false}}," - + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\"," - + "\"description\" : \"A description of hello\"" + "}"; - result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) - .content(entityString).contentType(APPLICATION_JSON)); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - entityString = "{" + "\"name\" : \"HowsItGoing2\"," + "\"version\" : \"0.0.2\"," - + "\"outputFields\" : {\"OField0\" : {\"name\" : \"StringType\", \"version\" : \"0.0.1\", " - + "\"localName\" : \"OField0\", \"optional\" : false}}," - + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\"," - + "\"description\" : \"A description of hello\"" + "}"; - result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) - .content(entityString).contentType(APPLICATION_JSON)); - assertEquals(ApexApiResult.Result.SUCCESS, result.getResult()); - - entityString = "{" + "\"name\" : \"Hi2\"," + "\"version\" : \"0.0.2\"," - + "\"outputFields\" : {\"OField0\" : null}," - + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\"," - + "\"description\" : \"A description of hello\"" + "}"; - result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) - .content(entityString).contentType(APPLICATION_JSON)); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); - - entityString = "{" + "\"name\" : \"GoodDay2\"," + "\"version\" : \"0.0.2\"," - + "\"outputFields\" : {\"OField0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\"," - + " \"localName\" : \"OField0\", \"optional\" : false}}," - + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\"," - + "\"description\" : \"A description of hello\"" + "}"; - result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) - .content(entityString).contentType(APPLICATION_JSON)); - assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult()); - - entityString = "{" + "\"name\" : \"Howdy2\"," + "\"version\" : \"0.0.2\"," - + "\"outputFields\" : {\"OField0\" : {\"name\" : \"NonExistantType\", \"version\" : \"0.0.1\", " - + "\"localName\" : \"NotOField0\", \"optional\" : false}}," - + "\"uuid\" : \"1fa2e430-f2b2-11e6-bc64-92361f002799\"," - + "\"description\" : \"A description of hello\"" + "}"; - result = apexRequest(post(BASE_URL + "/Task/Create", sessionId) - .content(entityString).contentType(APPLICATION_JSON)); - assertEquals(ApexApiResult.Result.FAILED, result.getResult()); } @Test diff --git a/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json index 9e3ea51..096e64a 100644 --- a/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json +++ b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.json @@ -439,74 +439,6 @@ "name": "task", "version": "0.0.1" }, - "inputFields": { - "entry": [ - { - "key": "IEPAR0", - "value": { - "key": "IEPAR0", - "fieldSchemaKey": { - "name": "eventContextItem0", - "version": "0.0.1" - } - } - }, - { - "key": "IEPAR1", - "value": { - "key": "IEPAR1", - "fieldSchemaKey": { - "name": "eventContextItem1", - "version": "0.0.1" - } - } - } - ] - }, - "outputFields": { - "entry": [ - { - "key": "OE0PAR0", - "value": { - "key": "OE0PAR0", - "fieldSchemaKey": { - "name": "eventContextItem0", - "version": "0.0.1" - } - } - }, - { - "key": "OE0PAR1", - "value": { - "key": "OE0PAR1", - "fieldSchemaKey": { - "name": "eventContextItem1", - "version": "0.0.1" - } - } - }, - { - "key": "OE1PAR0", - "value": { - "key": "OE1PAR0", - "fieldSchemaKey": { - "name": "eventContextItem0", - "version": "0.0.1" - } - } - }, - { - "key": "OE1PAR1", - "value": { - "key": "OE1PAR1", - "fieldSchemaKey": { - "name": "eventContextItem1", - "version": "0.0.1" - } - } - } - ] - }, "taskParameters": { "entry": [ { diff --git a/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.yaml b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.yaml index 201085c..54bb592 100644 --- a/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.yaml +++ b/gui-editors/gui-editor-apex/src/test/resources/models/PolicyModel.yaml @@ -307,46 +307,6 @@ topology_template: key: name: task version: 0.0.1 - inputFields: - entry: - - key: IEPAR0 - value: - key: IEPAR0 - fieldSchemaKey: - name: eventContextItem0 - version: 0.0.1 - - key: IEPAR1 - value: - key: IEPAR1 - fieldSchemaKey: - name: eventContextItem1 - version: 0.0.1 - outputFields: - entry: - - key: OE0PAR0 - value: - key: OE0PAR0 - fieldSchemaKey: - name: eventContextItem0 - version: 0.0.1 - - key: OE0PAR1 - value: - key: OE0PAR1 - fieldSchemaKey: - name: eventContextItem1 - version: 0.0.1 - - key: OE1PAR0 - value: - key: OE1PAR0 - fieldSchemaKey: - name: eventContextItem0 - version: 0.0.1 - - key: OE1PAR1 - value: - key: OE1PAR1 - fieldSchemaKey: - name: eventContextItem1 - version: 0.0.1 taskParameters: entry: - key: taskParameter0 @@ -40,8 +40,8 @@ <description>Code for all the Policy GUI's.</description> <properties> - <policy.apex-pdp.version>2.4.0</policy.apex-pdp.version> - <policy.common.version>1.10.1-SNAPSHOT</policy.common.version> + <policy.apex-pdp.version>2.7.1-SNAPSHOT</policy.apex-pdp.version> + <policy.common.version>1.10.2-SNAPSHOT</policy.common.version> <policy.models.version>2.6.1-SNAPSHOT</policy.models.version> <jacoco.dataFile>${project.basedir}/../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile> <sonar.javascript.lcov.reportPaths>${project.basedir}/target/code-coverage/lcov.info</sonar.javascript.lcov.reportPaths> |