Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald Oakes committed Dec 5, 2019
1 parent 11611ab commit 6ca5212
Show file tree
Hide file tree
Showing 23 changed files with 438 additions and 17 deletions.
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
Expand Up @@ -22,6 +22,7 @@ customTask.pagelet=2
decision.png=1
documentWebService.pagelet=1
dynamicJava.pagelet=1
email.png=1
emailNotification.pagelet=1
emailTemplate.html=3
eventCheck.pagelet=2
Expand All @@ -32,7 +33,7 @@ hub_logo.png=1
invoke.jpg=1
invokeMultiple.pagelet=2
invokeSubprocess.pagelet=2
java.jpg=1
java.png=1
jdbcSql.pagelet=1
jmsAdapter.pagelet=1
ldap.pagelet=1
Expand All @@ -44,7 +45,6 @@ misc.png=1
multiRest.pagelet=2
multisub.png=1
note.png=1
notice.gif=1
pause.png=1
process.jpg=2
processFinish.pagelet=1
Expand All @@ -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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed mdw-workflow/assets/com/centurylink/mdw/base/java.jpg
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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 @@ -26,7 +26,7 @@ buildKt.gradle=4
collector.png=1
dependenciesWait.pagelet=3
error.png=1
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Incident.java=1
PrioritizationRules.xlsx=1
PrioritizationStrategy.java=1
ServiceNowActivity.java=1
ServiceNowAdapter.java=1
ServiceNowTask.task=1
adapter.pagelet=1
servicenow.pagelet=1
servicenow.png=1
159 changes: 159 additions & 0 deletions mdw-workflow/assets/com/centurylink/mdw/servicenow/Incident.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package com.centurylink.mdw.servicenow;

import com.centurylink.mdw.model.Jsonable;
import org.json.JSONObject;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;

public class Incident implements Jsonable {

public Incident() {
}

public Incident(JSONObject json) {

shortDescription = json.optString("short_description", null);
description = json.optString("description", null);
assignmentGroup = json.optString("assignment_group", null);
if (json.has("group_list"))
groupList = Arrays.asList(json.getString("group_list").split(","));
if (json.has("impact"))
impact = Level.of(json.getInt("impact"));
if (json.has("urgency"))
impact = Level.of(json.getInt("urgency"));
category = json.optString("category", null);
caller = json.optString("caller", null);
if (json.has("due_date"))
dueDate = LocalDateTime.parse(json.getString("due_date"), glideDateFormat);
correlationId = json.optString("correlation_id", null);
correlationDisplay = json.optString("correlation_display", null);
}

public enum Level {
High(1),
Medium(2),
Low(3);

public final int level;
Level(int level) {
this.level = level;
}

public static Level of(int level) {
for (Level l : Level.values()) {
if (l.level == level)
return l;
}
return null;
}

public String toString() {
return level + " - " + super.toString();
}
}

/**
* Maps to "Task Name" in MDW task
*/
private String shortDescription;
public String getShortDescription() { return shortDescription; }
public void setShortDescription(String shortDescription) { this.shortDescription = shortDescription; }

private String description;
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }

/**
* Ref corresponding to MDW workgroup (attribute of Workgroup)
*/
private String assignmentGroup;
public String getAssignmentGroup() { return assignmentGroup; }
public void setAssignmentGroup(String assignmentGroup) { this.assignmentGroup = assignmentGroup; }

/**
* List of group refs if multiple
*/
private List<String> groupList;
public List<String> getGroupList() { return groupList; }
public void setGroupList(List<String> groupList) { this.groupList = groupList; }

/**
* Effect incident has on business
*/
private Level impact;
public Level getImpact() { return impact; }
public void setImpact(Level impact) { this.impact = impact; }

/**
* Extent to which the incident's resolution can bear delay
* (maps to "Priority" of MDW tasks)
*/
private Level urgency;
public Level getUrgency() { return urgency; }
public void setUrgency(Level urgency) { this.urgency = urgency; }

/**
* How quickly the service desk should address the incident
* (calculated based on impact and urgency)
* <a href="https://docs.servicenow.com/bundle/istanbul-it-service-management/page/product/incident-management/reference/r_PrioritizationOfIncidents.html">https://docs.servicenow.com/bundle/istanbul-it-service-management/page/product/incident-management/reference/r_PrioritizationOfIncidents.html</a>
*/
private int priority;
public int getPriority() { return priority; }
public void setPriority(int priority) { this.priority = priority; }

private String category;
public String getCategory() { return category; }
public void setCategory(String category) { this.category = category; }

private LocalDateTime dueDate;
public LocalDateTime getDueDate() { return dueDate; }
public void setDueDate(LocalDateTime dueDate) { this.dueDate = dueDate; }

/**
* Populated with the MDW task instance id or process instance id
*/
private String correlationId;
public String getCorrelationId() { return correlationId; }
public void setCorrelationId(String correlationId) { this.correlationId = correlationId; }

/**
* Either "Process Instance" or "Task Instance"
*/
private String correlationDisplay;
public String getCorrelationDisplay() { return correlationDisplay; }
public void setCorrelationDisplay(String correlationDisplay) { this.correlationDisplay = correlationDisplay; }

/**
* Ref corresponding to MDW User who is considered incident creator (attribute of User)
*/
private String caller;
public String getCaller() { return caller; }
public void setCaller(String caller) { this.caller = caller; }

@Override
public JSONObject getJson() {
JSONObject json = create();
json.put("short_description", shortDescription);
json.putOpt("description", description);
json.putOpt("assignment_group", assignmentGroup);
if (groupList != null && !groupList.isEmpty())
json.put("group_list", String.join(",", groupList));
if (impact != null)
json.put("impact", impact.level);
if (urgency != null)
json.put("urgency", urgency.level);
json.putOpt("category", category);
json.putOpt("caller", caller);
if (dueDate != null)
json.put("due_date", glideDateFormat.format(dueDate));
json.optString("correlation_id", correlationId);
json.optString("correlation_display", correlationDisplay);

return json;
}

private static DateTimeFormatter glideDateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.centurylink.mdw.servicenow;

import com.centurylink.mdw.common.StrategyException;
import com.centurylink.mdw.drools.RulesBasedStrategy;
import com.centurylink.mdw.model.task.TaskTemplate;

import java.util.Date;

/**
* TODO: probably we don't need this if we can use PrioritizationRules.xlsx.
*/
public class PrioritizationStrategy extends RulesBasedStrategy implements com.centurylink.mdw.observer.task.PrioritizationStrategy {

@Override
protected String getKnowledgeBaseAttributeName() {
return null;
}

@Override
public Date determineDueDate(TaskTemplate taskTemplate) throws StrategyException {
return null;
}

/**
* Calculated based on these rules:
* <a href="https://docs.servicenow.com/bundle/istanbul-it-service-management/page/product/incident-management/reference/r_PrioritizationOfIncidents.html">https://docs.servicenow.com/bundle/istanbul-it-service-management/page/product/incident-management/reference/r_PrioritizationOfIncidents.html</a>
*/
@Override
public int determinePriority(TaskTemplate taskTemplate, Date dueDate) throws StrategyException {
return 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.centurylink.mdw.servicenow;

import com.centurylink.mdw.activity.ActivityException;
import com.centurylink.mdw.activity.types.AdapterActivity;
import com.centurylink.mdw.activity.types.NotificationActivity;
import com.centurylink.mdw.config.PropertyException;
import com.centurylink.mdw.model.workflow.ActivityRuntimeContext;
import com.centurylink.mdw.workflow.activity.DefaultActivityImpl;
import com.centurylink.mdw.annotations.Activity;
import com.centurylink.mdw.workflow.adapter.http.BasicAuthProvider;
import com.centurylink.mdw.workflow.adapter.rest.RestServiceAdapter;

import java.util.Map;

@Activity(value="ServiceNow Adapter", category=AdapterActivity.class,
icon="com.centurylink.mdw.servicenow/servicenow.png",
pagelet="com.centurylink.mdw.servicenow/adapter.pagelet")
public class ServiceNowAdapter extends RestServiceAdapter {

@Override
protected String getHttpMethod() throws ActivityException {
return "POST";
}

@Override
public Map<String,String> getRequestHeaders() {
Map<String,String> requestHeaders = super.getRequestHeaders();
requestHeaders.put("Content-Type", "application/json");
return requestHeaders;
}

@Override
public Object getAuthProvider() throws ActivityException {
String user = getAttribute(AUTH_USER);
String password = getAttribute(AUTH_PASSWORD);
return new BasicAuthProvider(user, password);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"attributes": {
"FormName": "Autoform",
"Notices": "[[\"Open\",\"\",\"\",\"com.centurylink.mdw.workflow.task.notifier.TaskEmailNotifier\"],[\"Assigned\",\"\",\"\",\"com.centurylink.mdw.workflow.task.notifier.TaskEmailNotifier\"],[\"Completed\",\"\",\"\",\"com.centurylink.mdw.workflow.task.notifier.TaskEmailNotifier\"],[\"Cancelled\",\"\",\"\",\"com.centurylink.mdw.workflow.task.notifier.TaskEmailNotifier\"],[\"In Progress\",\"\",\"\",\"com.centurylink.mdw.workflow.task.notifier.TaskEmailNotifier\"],[\"Alert\",\"\",\"\",\"com.centurylink.mdw.workflow.task.notifier.TaskEmailNotifier\"],[\"Jeopardy\",\"\",\"\",\"com.centurylink.mdw.workflow.task.notifier.TaskEmailNotifier\"],[\"Forward\",\"\",\"\",\"com.centurylink.mdw.workflow.task.notifier.TaskEmailNotifier\"]]"
},
"category": "GEN",
"logicalId": "ServiceNowTask",
"name": "${incident.shortDescription}",
"version": "0"
}

0 comments on commit 6ca5212

Please sign in to comment.