use of com.day.cq.workflow.model.WorkflowModel in project acs-aem-commons by Adobe-Consulting-Services.
the class InitFormServlet method doGet.
@Override
protected final void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
final JsonObject json = new JsonObject();
// Runners
accumulate(json, KEY_RUNNER_TYPES, withLabelValue("AEM Workflow", AEMWorkflowRunnerImpl.class.getName()));
accumulate(json, KEY_RUNNER_TYPES, withLabelValue("Synthetic Workflow (Single-threaded)", SyntheticWorkflowRunnerImpl.class.getName()));
accumulate(json, KEY_RUNNER_TYPES, withLabelValue("Synthetic Workflow (Multi-threaded)", FastActionManagerRunnerImpl.class.getName()));
// Query Types
accumulate(json, KEY_QUERY_TYPES, withLabelValue("QueryBuilder", "queryBuilder"));
accumulate(json, KEY_QUERY_TYPES, withLabelValue("List", "list"));
accumulate(json, KEY_QUERY_TYPES, withLabelValue("xPath", "xpath"));
accumulate(json, KEY_QUERY_TYPES, withLabelValue("JCR-SQL2", "JCR-SQL2"));
accumulate(json, KEY_QUERY_TYPES, withLabelValue("JCR-SQL", "JCR-SQL"));
// User Event Data
accumulate(json, KEY_USER_EVENT_DATA, withLabelValue("Custom user-event-data", ""));
accumulate(json, KEY_USER_EVENT_DATA, withLabelValue("changedByWorkflowProcess", "changedByWorkflowProcess"));
accumulate(json, KEY_USER_EVENT_DATA, withLabelValue("acs-aem-commons.bulk-workflow-manager", "acs-aem-commons.bulk-workflow-manager"));
// Workflow Models
final WorkflowSession workflowSession = workflowService.getWorkflowSession(request.getResourceResolver().adaptTo(Session.class));
try {
final WorkflowModel[] workflowModels = workflowSession.getModels();
for (final WorkflowModel workflowModel : workflowModels) {
boolean transientWorkflow = TransientWorkflowUtil.isTransient(request.getResourceResolver(), workflowModel.getId());
String workflowLabel = workflowModel.getTitle();
if (transientWorkflow) {
workflowLabel += " ( Transient )";
}
JsonObject jsonWorkflow = withLabelValue(workflowLabel, workflowModel.getId());
jsonWorkflow.addProperty("transient", transientWorkflow);
accumulate(json, "workflowModels", jsonWorkflow);
}
response.getWriter().write(json.toString());
} catch (WorkflowException e) {
log.error("Could not create workflow model drop-down.", e);
JSONErrorUtil.sendJSONError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not collect workflows", e.getMessage());
}
}
use of com.day.cq.workflow.model.WorkflowModel in project acs-aem-commons by Adobe-Consulting-Services.
the class InitServlet method getFormJSONObject.
/**
* Get the JSON data to populate the Workflow Removal form.
*
* @param resourceResolver
* @return
* @throws WorkflowException
* @throws JSONException
*/
private JSONObject getFormJSONObject(final ResourceResolver resourceResolver) throws WorkflowException, JSONException {
final JSONObject json = new JSONObject();
final WorkflowSession workflowSession = workflowService.getWorkflowSession(resourceResolver.adaptTo(Session.class));
final WorkflowModel[] workflowModels = workflowSession.getModels();
for (final WorkflowModel workflowModel : workflowModels) {
final JSONObject jsonWorkflow = new JSONObject();
jsonWorkflow.put("title", workflowModel.getTitle());
jsonWorkflow.put("id", workflowModel.getId());
json.accumulate("workflowModels", jsonWorkflow);
}
json.put("statuses", new JSONArray(Arrays.asList(WORKFLOW_STATUSES)));
return json;
}
use of com.day.cq.workflow.model.WorkflowModel in project acs-aem-commons by Adobe-Consulting-Services.
the class SyntheticWorkflowSessionTest method setUp.
@Before
public void setUp() {
session = new SyntheticWorkflowSession(new SyntheticWorkflowRunnerImpl(), resourceResolver.adaptTo(Session.class));
workflowData = new SyntheticWorkflowData("JCR_PATH", "/content/test");
workflowData.getMetaDataMap().put("cat", "meow");
workflowData.getMetaDataMap().put("bird", "ka-kaw");
syntheticWorkflow = new SyntheticWorkflow("test", workflowData);
SyntheticWorkItem syntheticWorkItem = SyntheticWorkItem.createSyntheticWorkItem(syntheticWorkflow.getWorkflowData());
wrappedWorkItem = (WorkItem) Proxy.newProxyInstance(WrappedSyntheticWorkItem.class.getClassLoader(), new Class[] { WorkItem.class, WrappedSyntheticWorkItem.class }, syntheticWorkItem);
SyntheticRoute syntheticRoute = new SyntheticRoute(false);
route = (Route) syntheticRoute;
workItemFilter = new WorkItemFilter() {
@Override
public boolean doInclude(WorkItem workItem) {
return false;
}
};
workflowModelFilter = new WorkflowModelFilter() {
@Override
public boolean doInclude(WorkflowModel workflowModel) {
return false;
}
};
}
Aggregations