Skip to content

Commit

Permalink
#781 and #782
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald Oakes committed Jan 9, 2020
1 parent 720f8e9 commit 4f9cdfe
Show file tree
Hide file tree
Showing 33 changed files with 819 additions and 45 deletions.
20 changes: 9 additions & 11 deletions mdw-common/src/com/centurylink/mdw/model/task/TaskInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@
*/
package com.centurylink.mdw.model.task;

import static com.centurylink.mdw.constant.TaskAttributeConstant.TASK_INSTANCE_JSONNAME;
import com.centurylink.mdw.constant.OwnerType;
import com.centurylink.mdw.model.Instance;
import com.centurylink.mdw.model.Jsonable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.centurylink.mdw.constant.OwnerType;
import com.centurylink.mdw.model.Instance;
import com.centurylink.mdw.model.Jsonable;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import static com.centurylink.mdw.constant.TaskAttributeConstant.TASK_INSTANCE_JSONNAME;

/**
* Value object corresponding to a TaskInstance persistable. Includes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected Map<String,ValueExpression> getValueExpressionMap() {
if (valueExpressionMap == null) {
valueExpressionMap = super.getValueExpressionMap();
valueExpressionMap.put("context", new ValueExpressionLiteral(this, Object.class));
valueExpressionMap.put("task", new ValueExpressionLiteral(this, Object.class)); //for backward compatibility
valueExpressionMap.put("task", new ValueExpressionLiteral(this.taskInstance, Object.class));
valueExpressionMap.put("taskInstanceId", new ValueExpressionLiteral(this.getTaskInstance().getTaskInstanceId(), String.class));
valueExpressionMap.put("taskName", new ValueExpressionLiteral(this.getTaskTemplate().getTaskName(), String.class));
valueExpressionMap.put("due", new ValueExpressionLiteral(this.getTaskInstance().getDue(), Instant.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ protected Map<String,ValueExpression> getValueExpressionMap() {
if (valueExpressionMap == null) {
valueExpressionMap = new HashMap<>();
valueExpressionMap.put("context", new ValueExpressionLiteral(this, Object.class));
valueExpressionMap.put("process", new ValueExpressionLiteral(this.processInstance, Object.class));
valueExpressionMap.put("masterRequestId", new ValueExpressionLiteral(getMasterRequestId(), String.class));
valueExpressionMap.put("mdwHubUrl", new ValueExpressionLiteral(ApplicationContext.getMdwHubUrl(), String.class));
valueExpressionMap.put("processInstanceId", new ValueExpressionLiteral(this.getProcessInstanceId(), String.class));
valueExpressionMap.put("processName", new ValueExpressionLiteral(this.process.getName(), String.class));
valueExpressionMap.put("process", new ValueExpressionLiteral(this.processInstance, Object.class));
valueExpressionMap.put("variables", new ValueExpressionLiteral(this.getVariables() , Object.class));
valueExpressionMap.put("props", new ValueExpressionLiteral(this.getPropertyAccessorMap(), Map.class));
valueExpressionMap.put("env", new ValueExpressionLiteral(this.getEnvironmentAccessorMap(), Map.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static TaskInstance createTaskInstance(Long taskId, String masterRequestId, Long
}

// create instance indices for template based general tasks (MDW 5.1) and all template based tasks (MDW 5.2)
if (indexes!=null && !indexes.isEmpty()) {
if (indexes != null && !indexes.isEmpty()) {
new TaskDataAccess().setTaskInstanceIndices(helper.getTaskInstance().getTaskInstanceId(), indexes);
}
// create instance groups for template based tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public List<String> getNotifierSpecs(Long taskId, Long processInstanceId, String
Process process = eventManager.findProcessByProcessInstanceId(processInstanceId);
if (process != null && process.getActivities() != null) {
TaskTemplate taskVO = TaskTemplateCache.getTaskTemplate(taskId);
// for compatibility with notifiers registered on activities
for (Activity activity : process.getActivities()) {
if (taskVO.getLogicalId().equals(activity.getAttribute(TaskAttributeConstant.TASK_LOGICAL_ID))) {
noticesAttr = activity.getAttribute(TaskAttributeConstant.NOTICES);
Expand All @@ -95,7 +96,7 @@ public List<String> getNotifierSpecs(Long taskId, Long processInstanceId, String
if (!StringUtils.isBlank(noticesAttr)) {
return parseNoticiesAttr(noticesAttr, outcome);
}
return getNotifierSpecs(taskId, outcome); // For compatibility
return getNotifierSpecs(taskId, outcome);
} catch (Exception ex) {
logger.severeException(ex.getMessage(), ex);
return null;
Expand Down
6 changes: 3 additions & 3 deletions mdw-workflow/assets/com/centurylink/mdw/base/.mdw/versions
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ActivityLogCleanup.java=2
AutoFormManualTask.pagelet=11
CustomManualTask.pagelet=10
AutoFormManualTask.pagelet=12
CustomManualTask.pagelet=11
LogRollerStartup.java=1
MdwRpcWebService.wsdl=2
PauseActivity.java=5
Expand Down Expand Up @@ -53,7 +53,7 @@ processStart.pagelet=1
publishEvent.pagelet=1
publishEventRest.pagelet=2
receive.gif=1
restService.pagelet=1
restService.pagelet=2
rpcWebService.pagelet=1
script.gif=1
scriptEvaluator.pagelet=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
</DROPDOWN>
<TABLE NAME="Notices" MODIFYONLY="true" DEFAULT="$DefaultNotices" SECTION="Notices">
<TEXT LABEL="Outcome" READONLY="true" VW="150"/>
<DROPDOWN LABEL="Template" SOURCE="RuleSets" TYPE="JSON,TEXT,MARKDOWN,HTML" VW="200"/>
<DROPDOWN LABEL="Version" SOURCE="AssetVersion"/>
<TEXT LABEL="Notifier Class(es)" VW="350"/>
<DROPDOWN LABEL="Template" SOURCE="RuleSets" TYPE="JSON,TEXT,MARKDOWN,HTML" VW="350"/>
<DROPDOWN LABEL="Version" SOURCE="AssetVersion" VW="100"/>
<TEXT LABEL="Notifier Class(es)"/>
</TABLE>
<HYPERLINK URL="help/taskNotices.html" SECTION="Notices">Task Notices Help</HYPERLINK>
<NOTE SECTION="Recipients" VH="65">Overrides task workgroups for notices.</NOTE>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
</DROPDOWN>
<TABLE NAME="Notices" MODIFYONLY="true" DEFAULT="$DefaultNotices" SECTION="Notices">
<TEXT LABEL="Outcome" READONLY="true" VW="150"/>
<DROPDOWN LABEL="Template" SOURCE="RuleSets" TYPE="JSON,TEXT,MARKDOWN,HTML" VW="200"/>
<DROPDOWN LABEL="Version" SOURCE="AssetVersion"/>
<TEXT LABEL="Notifier Class(es)" VW="350"/>
<DROPDOWN LABEL="Template" SOURCE="RuleSets" TYPE="JSON,TEXT,MARKDOWN,HTML" VW="350"/>
<DROPDOWN LABEL="Version" SOURCE="AssetVersion" VW="100"/>
<TEXT LABEL="Notifier Class(es)"/>
</TABLE>
<HYPERLINK URL="help/taskNotices.html" SECTION="Notices">Task Notices Help</HYPERLINK>
<NOTE SECTION="Recipients" VH="65">Overrides task workgroups for notices.</NOTE>
Expand Down
10 changes: 5 additions & 5 deletions mdw-workflow/assets/com/centurylink/mdw/base/restService.pagelet
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"name": "REQUEST_VARIABLE",
"source": "DocumentVariables",
"type": "dropdown",
"vw": "200"
"vw": "250"
},
{
"label": "Response Variable",
"name": "RESPONSE_VARIABLE",
"source": "DocumentVariables",
"type": "dropdown",
"vw": "200"
"vw": "250"
},
{
"label": "Coerce Response to Type",
Expand All @@ -44,7 +44,7 @@
"name": "HeadersVariable",
"source": "DocumentVariables",
"type": "dropdown",
"vw": "200"
"vw": "250"
},
{
"label": "Connect Timeout (ms)",
Expand Down Expand Up @@ -94,15 +94,15 @@
"name": "AuthUser",
"section": "Authentication",
"type": "text",
"vw": "200"
"vw": "400"
},
{
"default": "${env['mdw.app.password']}",
"label": "Password",
"name": "AuthPassword",
"section": "Authentication",
"type": "text",
"vw": "200"
"vw": "400"
},
{
"name": "Do not store app.password in config.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DroolsKnowledgeBaseCache.java=3
Excel2007Parser.java=3
KnowledgeBaseAsset.java=2
RulesBasedAutoAssignStrategy.java=4
RulesBasedPrioritizationStrategy.java=3
RulesBasedPrioritizationStrategy.java=5
RulesBasedRoutingStrategy.java=2
RulesBasedStrategy.java=2
RulesBasedSubTaskStrategy.java=2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ public class RulesBasedPrioritizationStrategy extends RulesBasedStrategy impleme
@SuppressWarnings("unchecked")
public Date determineDueDate(TaskTemplate taskTemplate) throws StrategyException {

TaskInstance taskInstanceVO = new TaskInstance(); // for holding values
TaskInstance taskInstance = new TaskInstance(); // for holding values

// execute rules only once (results are stored in taskInstanceVO)
// execute rules only once (results are stored in taskInstance)
KieBase knowledgeBase = getKnowledgeBase();
StatelessKieSession knowledgeSession = knowledgeBase.newStatelessKieSession();

List<Object> facts = new ArrayList<Object>();
List<Object> facts = new ArrayList<>();
facts.add(getParameters());
knowledgeSession.setGlobal("taskTemplate", taskTemplate);
knowledgeSession.setGlobal("taskInstance", taskInstanceVO);
knowledgeSession.setGlobal("taskInstance", taskInstance);

knowledgeSession.execute(CommandFactory.newInsertElements(facts));

return Date.from(taskInstanceVO.getDue());
return Date.from(taskInstance.getDue());
}

public int determinePriority(TaskTemplate taskTemplate, Date dueDate) throws StrategyException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Update.java=2
WorstCaseConsolidator.java=1
buildKt.gradle=4
collector.png=1
dependenciesWait.pagelet=4
dependenciesWait.pagelet=3
error.png=2
microserviceRest.pagelet=1
microserviceRest.pagelet=2
orchestrator.pagelet=1
orchestrator.png=1
plan.png=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
"label": "Microservice Name",
"name": "Microservice",
"type": "text",
"vw": "200"
"vw": "250"
},
{
"label": "Request Variable",
"name": "REQUEST_VARIABLE",
"source": "DocumentVariables",
"type": "dropdown",
"vw": "200"
"vw": "250"
},
{
"label": "Response Variable",
"name": "RESPONSE_VARIABLE",
"source": "DocumentVariables",
"type": "dropdown",
"vw": "200"
"vw": "250"
},
{
"label": "Coerce Response to Type",
Expand All @@ -51,7 +51,7 @@
"name": "HeadersVariable",
"source": "DocumentVariables",
"type": "dropdown",
"vw": "200"
"vw": "250"
},
{
"label": "Connect Timeout (ms)",
Expand Down Expand Up @@ -113,15 +113,15 @@
"name": "AuthUser",
"section": "Authentication",
"type": "text",
"vw": "200"
"vw": "400"
},
{
"default": "${env['mdw.app.password']}",
"label": "Password",
"name": "AuthPassword",
"section": "Authentication",
"type": "text",
"vw": "200"
"vw": "400"
},
{
"name": "Do not store app.password in config.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schemaVersion: '6.1'
name: com.centurylink.mdw.servicenow
version: 0.0.01
12 changes: 12 additions & 0 deletions mdw-workflow/assets/com/centurylink/mdw/servicenow/.mdw/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
GlideDateTime.java=1
Incident.java=3
IncidentTemplate.yaml=1
ServiceNowAdapter.java=1
ServiceNowTask.pagelet=2
ServiceNowTaskActivity.java=1
TaskNotifier.java=2
adapter.pagelet=1
readme.md=1
servicenow.png=1
servicenow_task.png=1
task.pagelet=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.centurylink.mdw.servicenow;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
* Date format used by ServiceNow.
*/
public class GlideDateTime {
public static DateTimeFormatter FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

private LocalDateTime localDateTime;
public LocalDateTime getLocalDateTime() { return localDateTime; }

GlideDateTime(LocalDateTime localDateTime) {
this.localDateTime = localDateTime;
}

GlideDateTime(long epochMillis) {
this.localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMillis), ZoneId.systemDefault());
}

GlideDateTime(String formattedDateTime) {
this.localDateTime = LocalDateTime.parse(formattedDateTime, FORMAT);
}

@Override
public String toString() {
return FORMAT.format(this.localDateTime);
}
}

0 comments on commit 4f9cdfe

Please sign in to comment.