-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Donald Oakes
committed
Dec 5, 2019
1 parent
11611ab
commit 6ca5212
Showing
23 changed files
with
438 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
mdw-workflow/assets/com/centurylink/mdw/servicenow/.mdw/package.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
9 changes: 9 additions & 0 deletions
9
mdw-workflow/assets/com/centurylink/mdw/servicenow/.mdw/versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
159
mdw-workflow/assets/com/centurylink/mdw/servicenow/Incident.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+12 KB
mdw-workflow/assets/com/centurylink/mdw/servicenow/PrioritizationRules.xlsx
Binary file not shown.
32 changes: 32 additions & 0 deletions
32
mdw-workflow/assets/com/centurylink/mdw/servicenow/PrioritizationStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
mdw-workflow/assets/com/centurylink/mdw/servicenow/ServiceNowAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
mdw-workflow/assets/com/centurylink/mdw/servicenow/ServiceNowTask.task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
Oops, something went wrong.