Skip to content

Instantly share code, notes, and snippets.

@eduardolundgren
Created August 16, 2011 00:34
Show Gist options
  • Save eduardolundgren/1148207 to your computer and use it in GitHub Desktop.
Save eduardolundgren/1148207 to your computer and use it in GitHub Desktop.
Kaleo definition JSONML Array
{
"workflow-definition": {
"-xmlns": "urn:liferay.com:liferay-workflow_6.1.0",
"-xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"-xsi:schemaLocation": "urn:liferay.com:liferay-workflow_6.1.0 http://www.liferay.com/dtd/liferay-workflow-definition_6_1_0.xsd",
"name": "Category Specific Approval",
"description": "A single approver can approve a workflow content.",
"version": "1",
"state": [
{
"name": "created",
"initial": "true",
"transitions": {
"transition": {
"name": "Determine Branch",
"target": "determine-branch",
"default": "true"
}
}
},
{
"name": "approved",
"actions": {
"action": {
"name": "approve",
"script": "
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.toStatus(\"approved\"), workflowContext);
",
"script-language": "groovy",
"execution-type": "onEntry"
}
}
}
],
"condition": {
"name": "determine-branch",
"script": "
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portlet.asset.model.AssetCategory;
import com.liferay.portlet.asset.model.AssetEntry;
import com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil;
import java.util.List;
String className = (String)workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME);
long classPK = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPK);
List<AssetCategory> assetCategories = assetEntry.getCategories();
returnValue = \"Content Review\";
for (AssetCategory assetCategory : assetCategories) {
String categoryName = assetCategory.getName();
if (categoryName.equals(\"legal\")) {
returnValue = \"Legal Review\";
return;
}
}
",
"script-language": "groovy",
"transitions": {
"transition": [
{
"name": "Legal Review",
"target": "legal-review",
"default": "false"
},
{
"name": "Content Review",
"target": "content-review",
"default": "false"
}
]
}
},
"task": [
{
"name": "update",
"actions": {
"notification": {
"name": "Creator Modification Notification",
"description": "Creator Modification Notification desc",
"template": "Your submission was rejected by a reviewer, please modify and resubmit.",
"template-language": "text",
"notification-type": "email",
"execution-type": "onAssignment",
"recipients": {
"address": "eduardo@gmail.com",
"roles": {
"role": [
{
"role-type": "organization",
"name": "Organization Administrator"
},
{
"role-type": "organization",
"name": "Organization Content Reviewer"
}
]
}
}
}
},
"assignments": {
},
"transitions": {
"transition": {
"name": "resubmit",
"target": "determine-branch",
"default": "true"
}
}
},
{
"name": "content-review",
"actions": {
"notification": {
"name": "Review Notification",
"template": "You have a new submission waiting for your review in the workflow.",
"template-language": "text",
"notification-type": "email",
"execution-type": "onAssignment"
}
},
"assignments": {
"roles": {
"role": [
{
"role-type": "organization",
"name": "Organization Administrator"
},
{
"role-type": "organization",
"name": "Organization Content Reviewer"
},
{
"role-type": "organization",
"name": "Organization Owner"
},
{
"role-type": "regular",
"name": "Administrator"
},
{
"role-type": "regular",
"name": "Portal Content Reviewer"
},
{
"role-type": "site",
"name": "Site Administrator"
},
{
"role-type": "site",
"name": "Site Content Reviewer"
},
{
"role-type": "site",
"name": "Site Owner"
}
]
}
},
"task-timers": {
"task-timer": {
"blocking": "false",
"delay": {
"duration": "1",
"scale": "hour"
},
"timer-actions": {
"timer-notification": {
"template-language": "text",
"notification-type": "im"
}
}
}
},
"transitions": {
"transition": [
{
"name": "approve",
"target": "approved",
"default": "true"
},
{
"name": "reject",
"target": "update",
"default": "false"
}
]
}
},
{
"name": "legal-review",
"actions": {
"notification": {
"name": "Review Notification",
"template": "You have a new submission waiting for your review in the workflow.",
"template-language": "text",
"notification-type": "email",
"execution-type": "onAssignment"
}
},
"assignments": {
"roles": {
"role": [
{
"role-type": "organization",
"name": "Organization Administrator"
},
{
"role-type": "organization",
"name": "Organization Legal Reviewer"
},
{
"role-type": "organization",
"name": "Organization Owner"
},
{
"role-type": "regular",
"name": "Administrator"
},
{
"role-type": "regular",
"name": "Portal Legal Reviewer"
},
{
"role-type": "site",
"name": "Site Administrator"
},
{
"role-type": "site",
"name": "Site Legal Reviewer"
},
{
"role-type": "site",
"name": "Site Owner"
}
]
}
},
"transitions": {
"transition": [
{
"name": "approve",
"target": "approved",
"default": "true"
},
{
"name": "reject",
"target": "update",
"default": "false"
}
]
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment