Skip to content

Commit

Permalink
#842 doctypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald Oakes committed Jun 4, 2020
1 parent 8182fe2 commit b618f7d
Show file tree
Hide file tree
Showing 83 changed files with 861 additions and 886 deletions.
3 changes: 2 additions & 1 deletion docs/_docs/code/knowledge-transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ title: MDW Knowledge Transfer Sessions
- [Listeners/Handlers](#listeners-handlers)
- [Adapters](#adapters)
- [Manual Tasks](#manual-tasks)
- [Build and Environments](#build-and-env)
- [Fallout/Exception Handling](#fallout-exception-handling)
- [MDWHub/JSX Assets](#mdwhub-jsx-assets)
- [Dashboard](#dashboard)
- [Autotests](#autotests)
- [Milestones](#milestones)
- [CLI](#cli)
- [MDW Studio](#mdw-studio)
- [Build and Environments](#build-and-env)
59 changes: 10 additions & 49 deletions mdw-common/src/com/centurylink/mdw/activity/types/TaskActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,22 @@
*/
package com.centurylink.mdw.activity.types;

import com.centurylink.mdw.constant.TaskAttributeConstant;


/**
* Interface for all Manual Task activities.
* Manual Task activities.
*/
public interface TaskActivity extends GeneralActivity {

static final String ATTRIBUTE_TASK_LOGICAL_ID = "TaskLogicalId";
static final String ATTRIBUTE_TASK_NAME = "TaskName";
static final String ATTRIBUTE_TASK_DESC = "Task Description";
static final String ATTRIBUTE_TASK_CATEGORY = "Category";
static final String ATTRIBUTE_TASK_OBSERVER = "Observer";
static final String ATTRIBUTE_TASK_SLA = TaskAttributeConstant.TASK_SLA;
static final String ATTRIBUTE_TASK_SLA_UNITS = "SLAUnits";
static final String ATTRIBUTE_TASK_ALERT_INTERVAL = "AlertInterval";
static final String ATTRIBUTE_TASK_ALERT_INTERVAL_UNITS = "AlertIntervalUnits";
static final String ATTRIBUTE_TASK_GROUPS = TaskAttributeConstant.GROUPS;
static final String ATTRIBUTE_TASK_VARIABLES = "Variables";
static final String ATTRIBUTE_TASK_NOTICES = TaskAttributeConstant.NOTICES;
static final String ATTRIBUTE_NOTICE_GROUPS = TaskAttributeConstant.NOTICE_GROUPS;
static final String ATTRIBUTE_RECIPIENT_EMAILS = TaskAttributeConstant.RECIPIENT_EMAILS;
static final String ATTRIBUTE_CC_GROUPS = TaskAttributeConstant.CC_GROUPS;
static final String ATTRIBUTE_TASK_AUTOASSIGN = TaskAttributeConstant.AUTO_ASSIGN;
static final String ATTRIBUTE_AUTO_ASSIGN_RULES = TaskAttributeConstant.AUTO_ASSIGN_RULES;
static final String ATTRIBUTE_TASK_ROUTING = TaskAttributeConstant.ROUTING_STRATEGY;
static final String ATTRIBUTE_ROUTING_RULES = TaskAttributeConstant.ROUTING_RULES;
static final String ATTRIBUTE_SUBTASK_STRATEGY = TaskAttributeConstant.SUBTASK_STRATEGY;
static final String ATTRIBUTE_SUBTASK_RULES = TaskAttributeConstant.SUBTASK_RULES;
static final String ATTRIBUTE_INDEX_PROVIDER = TaskAttributeConstant.INDEX_PROVIDER;
static final String ATTRIBUTE_ASSIGNEE_VAR = TaskAttributeConstant.ASSIGNEE_VAR;
static final String ATTRIBUTE_TASK_ID = "TaskId"; // set by loader - not persisted
static final String ATTRIBUTE_FORM_NAME = "FormName";
static final String ATTRIBUTE_FORM_VERSION = "FormVersion";
static final String ATTRIBUTE_FORM_DATA_VAR = "FormDataVar";
static final String ATTRIBUTE_CUSTOM_PAGE = TaskAttributeConstant.CUSTOM_PAGE;
static final String ATTRIBUTE_CUSTOM_PAGE_ASSET_VERSION = TaskAttributeConstant.CUSTOM_PAGE_ASSET_VERSION;
static final String ATTRIBUTE_RENDERING = TaskAttributeConstant.RENDERING_ENGINE;
static final String ATTRIBUTE_TASK_INDICES = TaskAttributeConstant.INDICES;
static final String ATTRIBUTE_TASK_PRIORITIZATION = TaskAttributeConstant.PRIORITY_STRATEGY;
static final String ATTRIBUTE_TASK_PRIORITY = TaskAttributeConstant.PRIORITY;
static final String ATTRIBUTE_PRIORITIZATION_RULES = TaskAttributeConstant.PRIORITIZATION_RULES;
static final String ATTRIBUTE_SERVICE_PROCESSES = TaskAttributeConstant.SERVICE_PROCESSES;

static final String ATTRVALUE_CREATE_NEW_FORM = "(new form - click View Form to create)";
String ATTRIBUTE_TASK_VARIABLES = "Variables";

static final String VARIABLE_DISPLAY_NOTDISPLAYED = "Not Displayed";
static final String VARIABLE_DISPLAY_OPTIONAL = "Optional";
static final String VARIABLE_DISPLAY_REQUIRED = "Required";
static final String VARIABLE_DISPLAY_READONLY = "Read Only";
static final String VARIABLE_DISPLAY_HIDDEN = "Hidden";
String VARIABLE_DISPLAY_NOTDISPLAYED = "Not Displayed";
String VARIABLE_DISPLAY_OPTIONAL = "Optional";
String VARIABLE_DISPLAY_REQUIRED = "Required";
String VARIABLE_DISPLAY_READONLY = "Read Only";
String VARIABLE_DISPLAY_HIDDEN = "Hidden";

static final String TASK_CREATE_RESPONSE_ID_PREFIX = "Task instance created - ID=";
String TASK_CREATE_RESPONSE_ID_PREFIX = "Task instance created - ID=";

// these attributes indicate new-style task template
static final String ATTRIBUTE_TASK_TEMPLATE = "TASK_TEMPLATE";
static final String ATTRIBUTE_TASK_TEMPLATE_VERSION = "TASK_TEMPLATE_assetVersion";
String ATTRIBUTE_TASK_TEMPLATE = "TASK_TEMPLATE";
String ATTRIBUTE_TASK_TEMPLATE_VERSION = "TASK_TEMPLATE_assetVersion";
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@

public class DomDocumentTranslator extends DocumentReferenceTranslator implements XmlDocumentTranslator {

public Object realToObject(String str) throws TranslationException {
@Override
public Object toObject(String str, String type) throws TranslationException {
try {
return DomHelper.toDomDocument(str);
} catch (Exception e) {
throw new TranslationException(e.getMessage(), e);
}
}

public String realToString(Object obj) throws TranslationException {
@Override
public String toString(Object obj, String variableType) throws TranslationException {

try {
Document document = (Document) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
@Deprecated
public class GroovyNodeTranslator extends DocumentReferenceTranslator implements XmlDocumentTranslator {

public Object realToObject(String str) throws TranslationException {
public Object toObject(String str, String type) throws TranslationException {
try {
return new XmlParser().parseText(str);
} catch (Exception e) {
throw new TranslationException(e.getMessage(), e);
}
}

public String realToString(Object obj) throws TranslationException {
public String toString(Object obj, String variableType) throws TranslationException {
StringWriter writer = null;
try {
Node node = (Node) obj;
Expand All @@ -63,7 +63,7 @@ public String realToString(Object obj) throws TranslationException {
public Document toDomDocument(Object obj) throws TranslationException {
// TODO: avoid reparsing
try {
return DomHelper.toDomDocument(realToString(obj));
return DomHelper.toDomDocument(toString(obj, null));
}
catch (Exception ex) {
throw new TranslationException(ex.getMessage(), ex);
Expand All @@ -72,7 +72,7 @@ public Document toDomDocument(Object obj) throws TranslationException {

public Object fromDomNode(org.w3c.dom.Node domNode) throws TranslationException {
try {
return realToObject(DomHelper.toXml(domNode));
return toObject(DomHelper.toXml(domNode), null);
}
catch (Exception ex) {
throw new TranslationException(ex.getMessage(), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
import com.centurylink.mdw.translator.DocumentReferenceTranslator;
import com.centurylink.mdw.translator.TranslationException;

@SuppressWarnings("unused")
public class IntegerListTranslator extends DocumentReferenceTranslator {

@Override
public Object realToObject(String str) throws TranslationException {
public Object toObject(String str, String type) throws TranslationException {
try {
List<Integer> intList = new ArrayList<Integer>();
List<Integer> intList = new ArrayList<>();
JSONArray jsonArray = new JSONArray(str);
for (int i = 0; i < jsonArray.length(); i++)
intList.add((Integer)jsonArray.opt(i));
Expand All @@ -41,7 +42,8 @@ public Object realToObject(String str) throws TranslationException {
}

@SuppressWarnings("unchecked")
public String realToString(Object obj) throws TranslationException {
@Override
public String toString(Object obj, String variableType) throws TranslationException {
List<Integer> intList = (List<Integer>) obj;
JSONArray jsonArray = new JSONArray();
for (Integer integer : intList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

public class JavaObjectTranslator extends DocumentReferenceTranslator {

public Object realToObject(String str) throws TranslationException {
@Override
public Object toObject(String str, String type) throws TranslationException {
ObjectInputStream ois = null;
try {
byte[] decoded = decodeBase64(str);
Expand Down Expand Up @@ -76,7 +77,8 @@ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, Clas
}
}

public String realToString(Object obj) throws TranslationException {
@Override
public String toString(Object obj, String variableType) throws TranslationException {
if (!(obj instanceof Serializable))
throw new TranslationException("Object must implement java.io.Serializable: " + obj.getClass());

Expand Down Expand Up @@ -106,5 +108,4 @@ protected byte[] decodeBase64(String inputString) {
protected String encodeBase64(byte[] inputBytes) {
return new String(Base64.encodeBase64(inputBytes));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@
import com.centurylink.mdw.translator.JsonTranslator;
import com.centurylink.mdw.translator.TranslationException;

@SuppressWarnings("unused")
public class JsonObjectTranslator extends DocumentReferenceTranslator implements JsonTranslator {

public Object realToObject(String str) throws TranslationException {
@Override
public Object toObject(String str, String type) throws TranslationException {
try {
return new JsonObject(str);
} catch (JSONException e) {
throw new TranslationException(e.getMessage(), e);
}
}

public String realToString(Object obj) throws TranslationException {
public String toString(Object obj, String variableType) throws TranslationException {
try {
JSONObject jsonObject = (JSONObject) obj;
return jsonObject.toString(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@

public class JsonableTranslator extends DocumentReferenceTranslator implements JsonTranslator {

public Object realToObject(String str) throws TranslationException {
/**
* TODO honor runtime type
*/
@Override
public Object toObject(String str, String type) throws TranslationException {
try {
JSONObject json = new JsonObject(str);
return createJsonable(json);
Expand All @@ -35,7 +39,11 @@ public Object realToObject(String str) throws TranslationException {
}
}

public String realToString(Object obj) throws TranslationException {
/**
* TODO prop-driven JSONABLE_TYPE population
*/
@Override
public String toString(Object obj, String variableType) throws TranslationException {
Jsonable jsonable = (Jsonable) obj;
JSONObject json = new JsonObject();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*/
package com.centurylink.mdw.common.translator.impl;

import java.util.ArrayList;
import java.util.List;

import com.centurylink.mdw.translator.DocumentReferenceTranslator;
import com.centurylink.mdw.translator.TranslationException;
import org.json.JSONArray;
import org.json.JSONException;

import com.centurylink.mdw.translator.DocumentReferenceTranslator;
import com.centurylink.mdw.translator.TranslationException;
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("unused")
public class LongListTranslator extends DocumentReferenceTranslator {

@Override
public Object realToObject(String str) throws TranslationException {
public Object toObject(String str, String type) throws TranslationException {
try {
List<Long> longList = new ArrayList<Long>();
List<Long> longList = new ArrayList<>();
JSONArray jsonArray = new JSONArray(str);
for (int i = 0; i < jsonArray.length(); i++)
longList.add(jsonArray.opt(i) == null ? null : jsonArray.getLong(i));
Expand All @@ -41,12 +41,11 @@ public Object realToObject(String str) throws TranslationException {
}

@SuppressWarnings("unchecked")
public String realToString(Object obj) throws TranslationException {
public String toString(Object obj, String variableType) throws TranslationException {
List<Long> longList = (List<Long>) obj;
JSONArray jsonArray = new JSONArray();
for (Long longElement : longList)
jsonArray.put(longElement);
return jsonArray.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
import com.centurylink.mdw.translator.JsonTranslator;
import com.centurylink.mdw.translator.TranslationException;

public class StringDocumentTranslator extends DocumentReferenceTranslator implements JsonTranslator
{
public Object realToObject(String str) throws TranslationException {
public class StringDocumentTranslator extends DocumentReferenceTranslator implements JsonTranslator {

@Override
public Object toObject(String str, String type) throws TranslationException {
return str;
}

public String realToString(Object obj) throws TranslationException {
@Override
public String toString(Object obj, String variableType) throws TranslationException {
return obj.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import com.centurylink.mdw.translator.DocumentReferenceTranslator;
import com.centurylink.mdw.translator.TranslationException;

@SuppressWarnings("unused")
public class StringListTranslator extends DocumentReferenceTranslator {

@Override
public Object realToObject(String str) throws TranslationException {
public Object toObject(String str, String type) throws TranslationException {
try {
List<String> stringList = new ArrayList<>();
JSONArray jsonArray = new JSONArray(str);
Expand All @@ -41,7 +42,8 @@ public Object realToObject(String str) throws TranslationException {
}

@SuppressWarnings("unchecked")
public String realToString(Object obj) throws TranslationException {
@Override
public String toString(Object obj, String variableType) throws TranslationException {
List<String> stringList = (List<String>) obj;
JSONArray jsonArray = new JSONArray();
for (String string : stringList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
import com.centurylink.mdw.translator.DocumentReferenceTranslator;
import com.centurylink.mdw.translator.TranslationException;

@SuppressWarnings("unused")
public class StringStringMapTranslator extends DocumentReferenceTranslator {

@Override
public Object realToObject(String str) throws TranslationException {
public Object toObject(String str, String type) throws TranslationException {
try {
Map<String,String> stringMap = new HashMap<>();
JSONObject jsonObject = new JsonObject(str);
Expand All @@ -47,7 +48,8 @@ public Object realToObject(String str) throws TranslationException {
}

@SuppressWarnings("unchecked")
public String realToString(Object obj) throws TranslationException {
@Override
public String toString(Object obj, String variableType) throws TranslationException {
Map<String,String> stringMap = (Map<String,String>) obj;
JSONObject jsonObject = new JsonObject();
Iterator<String> it = stringMap.keySet().iterator();
Expand Down
Loading

0 comments on commit b618f7d

Please sign in to comment.