From fe2fa3048fc33e753566cc45f143094e31b7cf92 Mon Sep 17 00:00:00 2001 From: tosmers Date: Mon, 21 Nov 2016 17:30:10 +0000 Subject: [PATCH] [UPDATE] - applies all recent changes from ng core classes to trunk core with regard to exporting git-svn-id: https://svn.libreccm.org/ccm/trunk@4447 8810af33-2d31-482b-a856-94f89814c4df --- .../portation/cmd/ExportCliTool.java | 37 +++++---- .../arsdigita/portation/cmd/ExportHelper.java | 26 ++++-- .../portation/conversion/MainConverter.java | 4 +- .../portation/conversion/NgCollection.java | 6 +- .../core/security/PermissionConversion.java | 17 ++-- ...ion.java => AssignableTaskConversion.java} | 70 ++++++++++------ .../core/workflow/WorkflowConversion.java | 37 ++++++++- .../workflow/WorkflowTemplateConversion.java | 49 +++++++++++ .../modules/core/categorization/Category.java | 2 +- .../modules/core/core/CcmObject.java | 9 +- .../modules/core/security/Permission.java | 6 +- .../{UserTask.java => AssignableTask.java} | 8 +- ...ler.java => AssignableTaskMarshaller.java} | 2 +- .../portation/modules/core/workflow/Task.java | 42 ++++++---- .../modules/core/workflow/TaskAssignment.java | 8 +- .../modules/core/workflow/TaskComment.java | 76 +++++++++++++++++ .../modules/core/workflow/TaskState.java | 34 ++++++++ .../modules/core/workflow/Workflow.java | 82 +++++++++++++++++-- .../modules/core/workflow/WorkflowState.java | 33 ++++++++ .../core/workflow/WorkflowTemplate.java | 35 ++++++++ .../WorkflowTemplateMarshaller.java} | 9 +- .../core/workflow/util/StateMapper.java | 63 ++++++++++++++ .../workflow/simple/TaskComment.java | 11 ++- .../arsdigita/workflow/simple/UserTask.java | 2 +- .../arsdigita/workflow/simple/Workflow.java | 10 +++ .../workflow/simple/WorkflowTemplate.java | 41 ++++++++-- 26 files changed, 599 insertions(+), 120 deletions(-) rename ccm-core/src/com/arsdigita/portation/conversion/core/workflow/{UserTaskConversion.java => AssignableTaskConversion.java} (70%) create mode 100644 ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowTemplateConversion.java rename ccm-core/src/com/arsdigita/portation/modules/core/workflow/{UserTask.java => AssignableTask.java} (93%) rename ccm-core/src/com/arsdigita/portation/modules/core/workflow/{UserTaskMarshaller.java => AssignableTaskMarshaller.java} (92%) create mode 100644 ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskComment.java create mode 100644 ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskState.java create mode 100644 ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowState.java create mode 100644 ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowTemplate.java rename ccm-core/src/com/arsdigita/portation/modules/core/{core/CcmObjectMarshaller.java => workflow/WorkflowTemplateMarshaller.java} (77%) create mode 100644 ccm-core/src/com/arsdigita/portation/modules/core/workflow/util/StateMapper.java diff --git a/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java b/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java index 0d85cbca4..3c7771cff 100644 --- a/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java +++ b/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java @@ -145,14 +145,19 @@ public class ExportCliTool extends Program { ExportHelper.exportRoleMemberships(); break; + case "workflowTemplates": + convert(); + ExportHelper.exportWorkflowTemplates(); + break; + case "workflows": convert(); ExportHelper.exportWorkflows(); break; - case "userTasks": + case "assignableTasks": convert(); - ExportHelper.exportUserTasks(); + ExportHelper.exportAssignableTasks(); break; case "taskAssignments": @@ -173,8 +178,9 @@ public class ExportCliTool extends Program { ExportHelper.exportGroupMemberships(); ExportHelper.exportRoles(); ExportHelper.exportRoleMemberships(); + ExportHelper.exportWorkflowTemplates(); ExportHelper.exportWorkflows(); - ExportHelper.exportUserTasks(); + ExportHelper.exportAssignableTasks(); ExportHelper.exportTaskAssignments(); ExportHelper.exportPermissions(); break; @@ -219,19 +225,20 @@ public class ExportCliTool extends Program { "\t\t Exports the chosen module class to a file.\n" + "\n" + "Available module-classes for export:\n" + - " \t\t categories \t\t all categories of the system\n" + - " \t\t categorizations \t\t all categorizations of the system\n" + - " \t\t users \t\t all users of the system\n" + - " \t\t groups \t\t all groups of the system\n" + - " \t\t groupMemberships\t\t all groupsMemberships of the system\n" + - " \t\t roles \t\t all roles of the system\n" + - " \t\t roleMemberships \t\t all roleMemberships of the system\n" + - " \t\t workflows \t\t all workflows of the system\n" + - " \t\t userTasks \t\t all userTasks of the system\n" + - " \t\t taskAssignments \t\t all taskAssignments of the system\n" + - " \t\t permissions \t\t all permissions of the system\n" + + " \t\t categories \t\t all categories of the system\n" + + " \t\t categorizations \t\t all categorizations of the system\n" + + " \t\t users \t\t all users of the system\n" + + " \t\t groups \t\t all groups of the system\n" + + " \t\t groupMemberships \t\t all groupsMemberships of the system\n" + + " \t\t roles \t\t all roles of the system\n" + + " \t\t roleMemberships \t\t all roleMemberships of the system\n" + + " \t\t workflowTemplates \t\t all workflowTemplates of the system\n" + + " \t\t workflows \t\t all workflows of the system\n" + + " \t\t assignableTasks \t\t all assignableTasks of the system\n" + + " \t\t taskAssignments \t\t all taskAssignments of the system\n" + + " \t\t permissions \t\t all permissions of the system\n" + " \n" + - " \t\t all_core \t\t all objects of the entire core module" + + " \t\t all_core \t\t all objects of the entire core module" + "\n" + "Do use for exporting java objects of a specified class.\n" + "\n" diff --git a/ccm-core/src/com/arsdigita/portation/cmd/ExportHelper.java b/ccm-core/src/com/arsdigita/portation/cmd/ExportHelper.java index 871f05c70..cb63aa996 100644 --- a/ccm-core/src/com/arsdigita/portation/cmd/ExportHelper.java +++ b/ccm-core/src/com/arsdigita/portation/cmd/ExportHelper.java @@ -29,8 +29,9 @@ import com.arsdigita.portation.modules.core.security.RoleMarshaller; import com.arsdigita.portation.modules.core.security.RoleMembershipMarshaller; import com.arsdigita.portation.modules.core.security.UserMarshaller; import com.arsdigita.portation.modules.core.workflow.TaskAssignmentMarshaller; -import com.arsdigita.portation.modules.core.workflow.UserTaskMarshaller; +import com.arsdigita.portation.modules.core.workflow.AssignableTaskMarshaller; import com.arsdigita.portation.modules.core.workflow.WorkflowMarshaller; +import com.arsdigita.portation.modules.core.workflow.WorkflowTemplateMarshaller; import java.util.ArrayList; @@ -106,6 +107,15 @@ class ExportHelper { (NgCollection.roleMemberships.values())); } + static void exportWorkflowTemplates() { + WorkflowTemplateMarshaller workflowTemplateMarshaller = new + WorkflowTemplateMarshaller(); + workflowTemplateMarshaller.prepare(Format.XML, pathName, + "workflowTemplates", indentation); + workflowTemplateMarshaller.exportList(new ArrayList<>(NgCollection + .workflowTemplates.values())); + } + static void exportWorkflows() { WorkflowMarshaller workflowMarshaller = new WorkflowMarshaller(); @@ -115,13 +125,13 @@ class ExportHelper { (NgCollection.workflows.values())); } - static void exportUserTasks() { - UserTaskMarshaller userTaskMarshaller = new - UserTaskMarshaller(); - userTaskMarshaller.prepare(Format.XML, pathName, - "userTasks", indentation); - userTaskMarshaller.exportList(new ArrayList<> - (NgCollection.userTasks.values())); + static void exportAssignableTasks() { + AssignableTaskMarshaller assignableTaskMarshaller = new + AssignableTaskMarshaller(); + assignableTaskMarshaller.prepare(Format.XML, pathName, + "assignableTasks", indentation); + assignableTaskMarshaller.exportList(new ArrayList<> + (NgCollection.assignableTasks.values())); } static void exportTaskAssignments() { diff --git a/ccm-core/src/com/arsdigita/portation/conversion/MainConverter.java b/ccm-core/src/com/arsdigita/portation/conversion/MainConverter.java index 740aec9b6..af3a69dcf 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/MainConverter.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/MainConverter.java @@ -23,7 +23,7 @@ import com.arsdigita.portation.conversion.core.security.GroupConversion; import com.arsdigita.portation.conversion.core.security.PermissionConversion; import com.arsdigita.portation.conversion.core.security.RoleConversion; import com.arsdigita.portation.conversion.core.security.UserConversion; -import com.arsdigita.portation.conversion.core.workflow.UserTaskConversion; +import com.arsdigita.portation.conversion.core.workflow.AssignableTaskConversion; import com.arsdigita.portation.conversion.core.workflow.WorkflowConversion; /** @@ -48,7 +48,7 @@ public class MainConverter { GroupConversion.convertAll(); RoleConversion.convertAll(); WorkflowConversion.convertAll(); - UserTaskConversion.convertAll(); + AssignableTaskConversion.convertAll(); PermissionConversion.convertAll(); } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/NgCollection.java b/ccm-core/src/com/arsdigita/portation/conversion/NgCollection.java index 2780b8561..dffbf5395 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/NgCollection.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/NgCollection.java @@ -28,10 +28,11 @@ import com.arsdigita.portation.modules.core.security.Permission; import com.arsdigita.portation.modules.core.security.Role; import com.arsdigita.portation.modules.core.security.RoleMembership; import com.arsdigita.portation.modules.core.security.User; +import com.arsdigita.portation.modules.core.workflow.AssignableTask; import com.arsdigita.portation.modules.core.workflow.Task; import com.arsdigita.portation.modules.core.workflow.TaskAssignment; -import com.arsdigita.portation.modules.core.workflow.UserTask; import com.arsdigita.portation.modules.core.workflow.Workflow; +import com.arsdigita.portation.modules.core.workflow.WorkflowTemplate; import java.util.HashMap; import java.util.Map; @@ -58,8 +59,9 @@ public class NgCollection { public static Map roleMemberships = new HashMap<>(); public static Map workflows = new HashMap<>(); + public static Map workflowTemplates = new HashMap<>(); public static Map tasks = new HashMap<>(); - public static Map userTasks = new HashMap<>(); + public static Map assignableTasks = new HashMap<>(); public static Map taskAssignments = new HashMap<>(); public static Map permissions = new HashMap<>(); diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java index 1f35a0b81..6df7b0515 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/security/PermissionConversion.java @@ -100,18 +100,19 @@ public class PermissionConversion { } /** - * Method recreating the association to class {@link Role} representing the - * {@code grantee} of a Permission. Because the {@code grantee} in the - * trunk-{@link com.arsdigita.kernel.permissions.Permission} is instance - * of the trunk-{@link Party}-class, there need to be separated two + * Method for recreating the association to class {@link Role}, which + * represents the {@code grantee} of a Permission. Because the {@code + * grantee} in the + * trunk-{@link com.arsdigita.kernel.permissions.Permission} is an instance + * of the trunk-{@link Party}-class, there have to be two separate * cases: * a) were the {@code grantee} of the trunk-system is of class - * {@link com.arsdigita.kernel.Group} therefore listing {@code - * Roles}, represented by this {@code Group}, which represent + * {@link com.arsdigita.kernel.Group} and therefore listing {@code + * Roles} represented by this {@code Group}, which represent * the {@code grantee} of ng-{@link Permission}s. * b) were the {@code grantee} of the trunk-system is of class - * {@link com.arsdigita.kernel.User} therefore having no {@code - * Role}-representation, which has specifically to be created. + * {@link com.arsdigita.kernel.User} and therefore having no {@code + * Role}-representation yet, which has specifically to be created. * * @param trunkPermissions List of all * {@link com.arsdigita.kernel.permissions.Permission}s diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/UserTaskConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java similarity index 70% rename from ccm-core/src/com/arsdigita/portation/conversion/core/workflow/UserTaskConversion.java rename to ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java index ef9cd2187..79e0b13fc 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/UserTaskConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java @@ -24,8 +24,9 @@ import com.arsdigita.kernel.RoleCollection; import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.modules.core.security.Role; import com.arsdigita.portation.modules.core.security.User; +import com.arsdigita.portation.modules.core.workflow.AssignableTask; import com.arsdigita.portation.modules.core.workflow.TaskAssignment; -import com.arsdigita.portation.modules.core.workflow.UserTask; +import com.arsdigita.portation.modules.core.workflow.TaskComment; import com.arsdigita.portation.modules.core.workflow.Workflow; import com.arsdigita.workflow.simple.Task; @@ -35,91 +36,106 @@ import java.util.List; /** * Class for converting all * trunk-{@link com.arsdigita.workflow.simple.UserTask}s into - * ng-{@link UserTask}s as preparation for a successful export of all trunk + * ng-{@link AssignableTask}s as preparation for a successful export of all trunk * classes into the new ng-system. * * @author Tobias Osmers + * @version created on 11/21/16 + */ +public class WorkflowTemplateConversion { + + /** + * Retrieves all + * trunk-{@link com.arsdigita.workflow.simple.WorkflowTemplate}s from + * the persistent storage and collects them in a list. Then calls for + * creating the equivalent ng-{@link WorkflowTemplate}s. + */ + public static void convertAll() { + List + trunkWorkflowTemplates = com.arsdigita.workflow.simple + .WorkflowTemplate.getAllObjectWorkflowTemplates(); + + trunkWorkflowTemplates.forEach(WorkflowTemplate::new); + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java index 319414252..2129a1578 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java @@ -44,7 +44,7 @@ import java.util.Locale; * @author Tobias Osmers<\a> * @version created on 6/15/16 */ -public class CcmObject implements Portable { +public class CcmObject { private long objectId; @@ -73,11 +71,6 @@ public class CcmObject implements Portable { NgCollection.ccmObjects.put(this.objectId, this); } - @Override - public AbstractMarshaller getMarshaller() { - return new CcmObjectMarshaller(); - } - public long getObjectId() { return objectId; } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/Permission.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/Permission.java index 27d11e341..e53dbb745 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/Permission.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/Permission.java @@ -41,8 +41,8 @@ public class Permission implements Portable { private CcmObject object; @JsonBackReference private Role grantee; - private User creationUser; + private User creationUser; private Date creationDate; private String creationIp; @@ -59,8 +59,8 @@ public class Permission implements Portable { //this.object; //this.grantee; - //this.creationUser + //this.creationUser this.creationDate = trunkPermission.getCreationDate(); this.creationIp = trunkPermission.getCreationIP(); @@ -79,8 +79,8 @@ public class Permission implements Portable { this.object = ngPermission.getObject(); this.grantee = ngPermission.getGrantee(); - this.creationUser = ngPermission.getCreationUser(); + this.creationUser = ngPermission.getCreationUser(); this.creationDate = ngPermission.getCreationDate(); this.creationIp = ngPermission.getCreationIp(); diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/UserTask.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTask.java similarity index 93% rename from ccm-core/src/com/arsdigita/portation/modules/core/workflow/UserTask.java rename to ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTask.java index 5722c0ef6..bf56bdbed 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/UserTask.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTask.java @@ -32,7 +32,7 @@ import java.util.List; * @author Tobias Osmers<\a> * @version created on 6/15/16 */ -public class UserTaskMarshaller extends AbstractMarshaller { +public class AssignableTaskMarshaller extends AbstractMarshaller { } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Task.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Task.java index 70d54849e..b07f0f6a4 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Task.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Task.java @@ -20,13 +20,14 @@ package com.arsdigita.portation.modules.core.workflow; import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.modules.core.l10n.LocalizedString; +import com.arsdigita.portation.modules.core.workflow.util.StateMapper; import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonManagedReference; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.UUID; /** * @author Tobias Osmers + * @version created on 11/18/16 + */ +public class TaskComment { + + private long commentId; + private String uuid; + + private String comment; + private User author; + + public TaskComment(com.arsdigita.workflow.simple.TaskComment + trunkTaskComment) { + this.commentId = trunkTaskComment.getCommentID().longValue(); + this.uuid = UUID.randomUUID().toString(); + this.comment = trunkTaskComment.getComment(); + //author + } + + public long getCommentId() { + return commentId; + } + + public void setCommentId(final long commentId) { + this.commentId = commentId; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public String getComment() { + return comment; + } + + public void setComment(final String comment) { + this.comment = comment; + } + + public User getAuthor() { + return author; + } + + public void setAuthor(final User author) { + this.author = author; + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskState.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskState.java new file mode 100644 index 000000000..4fbbce991 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskState.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.portation.modules.core.workflow; + +/** + * The possible states of a {@link Task}. + * + * @author Tobias Osmers<\a> @@ -35,26 +38,47 @@ import java.util.Locale; public class Workflow implements Portable { private long workflowId; + private String uuid; + + private WorkflowTemplate template; private LocalizedString name; private LocalizedString description; - //Todo: private WorkflowTemplate workflowTemplate; + private WorkflowState workflowState; + private boolean active; + private TaskState tasksState; + + private CcmObject object; @JsonManagedReference private List tasks; - public Workflow(final com.arsdigita.workflow.simple.Workflow trunkWorkFlow) { + + public Workflow(final com.arsdigita.workflow.simple.Workflow + trunkWorkFlow, boolean template) { this.workflowId = trunkWorkFlow.getID().longValue(); + this.uuid = UUID.randomUUID().toString(); + + //template this.name = new LocalizedString(); - this.name.addValue(Locale.ENGLISH, trunkWorkFlow.getDisplayName()); + this.name.addValue(Locale.getDefault(), trunkWorkFlow.getDisplayName()); this.description = new LocalizedString(); - this.description.addValue(Locale.ENGLISH, trunkWorkFlow.getDescription()); + this.description.addValue(Locale.getDefault(), + trunkWorkFlow.getDescription()); + + this.workflowState = StateMapper.mapWorkflowState(trunkWorkFlow + .getProcessState()); + this.active = trunkWorkFlow.isActive(); + this.tasksState = StateMapper.mapTaskState(trunkWorkFlow.getState()); + + //object this.tasks = new ArrayList<>(); - NgCollection.workflows.put(this.workflowId, this); + if (!template) + NgCollection.workflows.put(this.workflowId, this); } @Override @@ -70,6 +94,22 @@ public class Workflow implements Portable { this.workflowId = workflowId; } + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public WorkflowTemplate getTemplate() { + return template; + } + + public void setTemplate(final WorkflowTemplate template) { + this.template = template; + } + public LocalizedString getName() { return name; } @@ -86,6 +126,38 @@ public class Workflow implements Portable { this.description = description; } + public WorkflowState getWorkflowState() { + return workflowState; + } + + public void setWorkflowState(final WorkflowState workflowState) { + this.workflowState = workflowState; + } + + public boolean isActive() { + return active; + } + + public void setActive(final boolean active) { + this.active = active; + } + + public TaskState getTasksState() { + return tasksState; + } + + public void setTasksState(final TaskState tasksState) { + this.tasksState = tasksState; + } + + public CcmObject getObject() { + return object; + } + + public void setObject(final CcmObject object) { + this.object = object; + } + public List getTasks() { return tasks; } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowState.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowState.java new file mode 100644 index 000000000..2e65360c8 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowState.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.portation.modules.core.workflow; + +/** + * @author Tobias Osmers + * @version created on 11/18/16 + */ +public class WorkflowTemplate extends Workflow { + + public WorkflowTemplate(com.arsdigita.workflow.simple.WorkflowTemplate + trunkWorkFlowTemplate) { + super(trunkWorkFlowTemplate, true); + + NgCollection.workflowTemplates.put(this.getWorkflowId(), this); + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObjectMarshaller.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowTemplateMarshaller.java similarity index 77% rename from ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObjectMarshaller.java rename to ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowTemplateMarshaller.java index 2e1701d9f..ff1edfa9f 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObjectMarshaller.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowTemplateMarshaller.java @@ -16,13 +16,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ -package com.arsdigita.portation.modules.core.core; +package com.arsdigita.portation.modules.core.workflow; import com.arsdigita.portation.AbstractMarshaller; /** - * @author Tobias Osmers + * @version created on 11/21/16 */ -public class CcmObjectMarshaller extends AbstractMarshaller { +public class WorkflowTemplateMarshaller extends + AbstractMarshaller { } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/util/StateMapper.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/util/StateMapper.java new file mode 100644 index 000000000..4d9be1f78 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/util/StateMapper.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.portation.modules.core.workflow.util; + +import com.arsdigita.portation.modules.core.workflow.TaskState; +import com.arsdigita.portation.modules.core.workflow.WorkflowState; +import com.arsdigita.workflow.simple.Task; +import com.arsdigita.workflow.simple.Workflow; + +/** + * @author getAllObjectUserTasks() { List userTaskList = new ArrayList<>(); diff --git a/ccm-core/src/com/arsdigita/workflow/simple/Workflow.java b/ccm-core/src/com/arsdigita/workflow/simple/Workflow.java index eb7cba937..ed93fcd5d 100755 --- a/ccm-core/src/com/arsdigita/workflow/simple/Workflow.java +++ b/ccm-core/src/com/arsdigita/workflow/simple/Workflow.java @@ -343,6 +343,16 @@ public class Workflow extends Task { return getProcessStateInt((String) get(PROCESS_STATE)); } + /** + * Retrieves the state of the process as String. + * + * @return The process state + * + */ + public String getProcessStateString() { + return (String) get(PROCESS_STATE); + } + /** * Internal method to set the state from the DB, 'stopped', * 'started','deleted', 'init' are allowed diff --git a/ccm-core/src/com/arsdigita/workflow/simple/WorkflowTemplate.java b/ccm-core/src/com/arsdigita/workflow/simple/WorkflowTemplate.java index b3536b451..316355ee1 100755 --- a/ccm-core/src/com/arsdigita/workflow/simple/WorkflowTemplate.java +++ b/ccm-core/src/com/arsdigita/workflow/simple/WorkflowTemplate.java @@ -18,16 +18,21 @@ */ package com.arsdigita.workflow.simple; -import java.util.Iterator; -import java.util.Collections; -import java.math.BigDecimal; - +import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.domain.DomainCollection; import com.arsdigita.kernel.ACSObject; +import com.arsdigita.kernel.User; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; +import com.arsdigita.persistence.Session; +import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.metadata.ObjectType; -import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.kernel.User; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; /** * @@ -181,4 +186,28 @@ public class WorkflowTemplate extends Workflow { public OID getObjectOID() { return null; } + + /** + * Retrieves all objects of this type stored in the database. Very + * necessary for exporting all entities of the current work environment. + * + * @return List of all workflows + */ + public static List getAllObjectWorkflowTemplates() { + List workflowTemplateList = new ArrayList<>(); + + final Session session = SessionManager.getSession(); + DomainCollection collection = new DomainCollection( + session.retrieve(WorkflowTemplate.BASE_DATA_OBJECT_TYPE)); + + while (collection.next()) { + WorkflowTemplate workflow = (WorkflowTemplate) collection.getDomainObject(); + if (workflow != null) { + workflowTemplateList.add(workflow); + } + } + + collection.close(); + return workflowTemplateList; + } }