- 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
master
tosmers 2016-11-21 17:30:10 +00:00
parent d62cafc077
commit fe2fa3048f
26 changed files with 599 additions and 120 deletions

View File

@ -145,14 +145,19 @@ public class ExportCliTool extends Program {
ExportHelper.exportRoleMemberships(); ExportHelper.exportRoleMemberships();
break; break;
case "workflowTemplates":
convert();
ExportHelper.exportWorkflowTemplates();
break;
case "workflows": case "workflows":
convert(); convert();
ExportHelper.exportWorkflows(); ExportHelper.exportWorkflows();
break; break;
case "userTasks": case "assignableTasks":
convert(); convert();
ExportHelper.exportUserTasks(); ExportHelper.exportAssignableTasks();
break; break;
case "taskAssignments": case "taskAssignments":
@ -173,8 +178,9 @@ public class ExportCliTool extends Program {
ExportHelper.exportGroupMemberships(); ExportHelper.exportGroupMemberships();
ExportHelper.exportRoles(); ExportHelper.exportRoles();
ExportHelper.exportRoleMemberships(); ExportHelper.exportRoleMemberships();
ExportHelper.exportWorkflowTemplates();
ExportHelper.exportWorkflows(); ExportHelper.exportWorkflows();
ExportHelper.exportUserTasks(); ExportHelper.exportAssignableTasks();
ExportHelper.exportTaskAssignments(); ExportHelper.exportTaskAssignments();
ExportHelper.exportPermissions(); ExportHelper.exportPermissions();
break; break;
@ -226,8 +232,9 @@ public class ExportCliTool extends Program {
" \t\t groupMemberships \t\t all groupsMemberships 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 roles \t\t all roles of the system\n" +
" \t\t roleMemberships \t\t all roleMemberships 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 workflows \t\t all workflows of the system\n" +
" \t\t userTasks \t\t all userTasks 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 taskAssignments \t\t all taskAssignments of the system\n" +
" \t\t permissions \t\t all permissions of the system\n" + " \t\t permissions \t\t all permissions of the system\n" +
" \n" + " \n" +

View File

@ -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.RoleMembershipMarshaller;
import com.arsdigita.portation.modules.core.security.UserMarshaller; import com.arsdigita.portation.modules.core.security.UserMarshaller;
import com.arsdigita.portation.modules.core.workflow.TaskAssignmentMarshaller; 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.WorkflowMarshaller;
import com.arsdigita.portation.modules.core.workflow.WorkflowTemplateMarshaller;
import java.util.ArrayList; import java.util.ArrayList;
@ -106,6 +107,15 @@ class ExportHelper {
(NgCollection.roleMemberships.values())); (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() { static void exportWorkflows() {
WorkflowMarshaller workflowMarshaller = new WorkflowMarshaller workflowMarshaller = new
WorkflowMarshaller(); WorkflowMarshaller();
@ -115,13 +125,13 @@ class ExportHelper {
(NgCollection.workflows.values())); (NgCollection.workflows.values()));
} }
static void exportUserTasks() { static void exportAssignableTasks() {
UserTaskMarshaller userTaskMarshaller = new AssignableTaskMarshaller assignableTaskMarshaller = new
UserTaskMarshaller(); AssignableTaskMarshaller();
userTaskMarshaller.prepare(Format.XML, pathName, assignableTaskMarshaller.prepare(Format.XML, pathName,
"userTasks", indentation); "assignableTasks", indentation);
userTaskMarshaller.exportList(new ArrayList<> assignableTaskMarshaller.exportList(new ArrayList<>
(NgCollection.userTasks.values())); (NgCollection.assignableTasks.values()));
} }
static void exportTaskAssignments() { static void exportTaskAssignments() {

View File

@ -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.PermissionConversion;
import com.arsdigita.portation.conversion.core.security.RoleConversion; import com.arsdigita.portation.conversion.core.security.RoleConversion;
import com.arsdigita.portation.conversion.core.security.UserConversion; 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; import com.arsdigita.portation.conversion.core.workflow.WorkflowConversion;
/** /**
@ -48,7 +48,7 @@ public class MainConverter {
GroupConversion.convertAll(); GroupConversion.convertAll();
RoleConversion.convertAll(); RoleConversion.convertAll();
WorkflowConversion.convertAll(); WorkflowConversion.convertAll();
UserTaskConversion.convertAll(); AssignableTaskConversion.convertAll();
PermissionConversion.convertAll(); PermissionConversion.convertAll();
} }
} }

View File

@ -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.Role;
import com.arsdigita.portation.modules.core.security.RoleMembership; import com.arsdigita.portation.modules.core.security.RoleMembership;
import com.arsdigita.portation.modules.core.security.User; 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.Task;
import com.arsdigita.portation.modules.core.workflow.TaskAssignment; 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.Workflow;
import com.arsdigita.portation.modules.core.workflow.WorkflowTemplate;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -58,8 +59,9 @@ public class NgCollection {
public static Map<Long, RoleMembership> roleMemberships = new HashMap<>(); public static Map<Long, RoleMembership> roleMemberships = new HashMap<>();
public static Map<Long, Workflow> workflows = new HashMap<>(); public static Map<Long, Workflow> workflows = new HashMap<>();
public static Map<Long, WorkflowTemplate> workflowTemplates = new HashMap<>();
public static Map<Long, Task> tasks = new HashMap<>(); public static Map<Long, Task> tasks = new HashMap<>();
public static Map<Long, UserTask> userTasks = new HashMap<>(); public static Map<Long, AssignableTask> assignableTasks = new HashMap<>();
public static Map<Long, TaskAssignment> taskAssignments = new HashMap<>(); public static Map<Long, TaskAssignment> taskAssignments = new HashMap<>();
public static Map<Long, Permission> permissions = new HashMap<>(); public static Map<Long, Permission> permissions = new HashMap<>();

View File

@ -100,18 +100,19 @@ public class PermissionConversion {
} }
/** /**
* Method recreating the association to class {@link Role} representing the * Method for recreating the association to class {@link Role}, which
* {@code grantee} of a Permission. Because the {@code grantee} in the * represents the {@code grantee} of a Permission. Because the {@code
* trunk-{@link com.arsdigita.kernel.permissions.Permission} is instance * grantee} in the
* of the trunk-{@link Party}-class, there need to be separated two * trunk-{@link com.arsdigita.kernel.permissions.Permission} is an instance
* of the trunk-{@link Party}-class, there have to be two separate
* cases: * cases:
* a) were the {@code grantee} of the trunk-system is of class * a) were the {@code grantee} of the trunk-system is of class
* {@link com.arsdigita.kernel.Group} therefore listing {@code * {@link com.arsdigita.kernel.Group} and therefore listing {@code
* Roles}, represented by this {@code Group}, which represent * Roles} represented by this {@code Group}, which represent
* the {@code grantee} of ng-{@link Permission}s. * the {@code grantee} of ng-{@link Permission}s.
* b) were the {@code grantee} of the trunk-system is of class * b) were the {@code grantee} of the trunk-system is of class
* {@link com.arsdigita.kernel.User} therefore having no {@code * {@link com.arsdigita.kernel.User} and therefore having no {@code
* Role}-representation, which has specifically to be created. * Role}-representation yet, which has specifically to be created.
* *
* @param trunkPermissions List of all * @param trunkPermissions List of all
* {@link com.arsdigita.kernel.permissions.Permission}s * {@link com.arsdigita.kernel.permissions.Permission}s

View File

@ -24,8 +24,9 @@ import com.arsdigita.kernel.RoleCollection;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.security.Role; import com.arsdigita.portation.modules.core.security.Role;
import com.arsdigita.portation.modules.core.security.User; 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.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.portation.modules.core.workflow.Workflow;
import com.arsdigita.workflow.simple.Task; import com.arsdigita.workflow.simple.Task;
@ -35,91 +36,106 @@ import java.util.List;
/** /**
* Class for converting all * Class for converting all
* trunk-{@link com.arsdigita.workflow.simple.UserTask}s into * 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. * classes into the new ng-system.
* *
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 29.6.16 * @version created on 29.6.16
*/ */
public class UserTaskConversion { public class AssignableTaskConversion {
/** /**
* Retrieves all trunk-{@link com.arsdigita.workflow.simple.UserTask}s from * Retrieves all trunk-{@link com.arsdigita.workflow.simple.UserTask}s from
* the persistent storage and collects them in a list. Then calls for * the persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link UserTask}s focusing on keeping all the * creating the equivalent ng-{@link AssignableTask}s focusing on keeping all the
* associations in tact. The ring dependencies of class {@code Task} have * associations in tact. The ring dependencies of class {@code Task} have
* to be recreated once all ng-{@link UserTask}s have been created. * to be recreated once all ng-{@link AssignableTask}s have been created.
*/ */
public static void convertAll() { public static void convertAll() {
List<com.arsdigita.workflow.simple.UserTask> trunkUserTasks = com List<com.arsdigita.workflow.simple.UserTask> trunkUserTasks = com
.arsdigita.workflow.simple.UserTask.getAllObjectUserTasks(); .arsdigita.workflow.simple.UserTask.getAllObjectUserTasks();
createUserTasksAndSetAssociations(trunkUserTasks); createAssignableTasksAndSetAssociations(trunkUserTasks);
setTaskRingDependencies(trunkUserTasks); setTaskRingDependencies(trunkUserTasks);
} }
/** /**
* Creates the equivalent ng-class of the {@code UserTask} and restores * Creates the equivalent ng-class of the {@code AssignableTask} and restores
* the associations to other classes. * the associations to other classes.
* *
* @param trunkUserTasks List of all * @param trunkUserTasks List of all
* {@link com.arsdigita.workflow.simple.UserTask}s * {@link com.arsdigita.workflow.simple.UserTask}s
* from this old trunk-system. * from this old trunk-system.
*/ */
private static void createUserTasksAndSetAssociations(List<com.arsdigita private static void createAssignableTasksAndSetAssociations(List<com.arsdigita
.workflow.simple.UserTask> trunkUserTasks) { .workflow.simple.UserTask> trunkUserTasks) {
for (com.arsdigita.workflow.simple.UserTask trunkUserTask : for (com.arsdigita.workflow.simple.UserTask trunkUserTask :
trunkUserTasks) { trunkUserTasks) {
// create userTask // create assignableTask
UserTask userTask = new UserTask(trunkUserTask); AssignableTask assignableTask = new AssignableTask(trunkUserTask);
// set workflow and opposed associations // set workflow and opposed associations
if (trunkUserTask.getWorkflow() != null) { if (trunkUserTask.getWorkflow() != null) {
Workflow workflow = NgCollection.workflows.get( Workflow workflow = NgCollection.workflows.get(
trunkUserTask.getWorkflow().getID().longValue()); trunkUserTask.getWorkflow().getID().longValue());
if (workflow != null) { if (workflow != null) {
userTask.setWorkflow(workflow); assignableTask.setWorkflow(workflow);
workflow.addTask(userTask); workflow.addTask(assignableTask);
} }
} }
// set taskComments
Iterator commentsIt = trunkUserTask.getComments();
while (commentsIt.hasNext()) {
com.arsdigita.workflow.simple.TaskComment trunkTaskComment = (com
.arsdigita.workflow.simple.TaskComment) commentsIt.next();
TaskComment taskComment = new TaskComment(trunkTaskComment);
User author = NgCollection.users.get(
trunkTaskComment.getUser().getID().longValue());
taskComment.setAuthor(author);
assignableTask.addComment(taskComment);
}
// set lockingUser and notificationSender // set lockingUser and notificationSender
if (trunkUserTask.getLockedUser() != null) { if (trunkUserTask.getLockedUser() != null) {
User lockingUser = NgCollection.users.get(trunkUserTask User lockingUser = NgCollection.users.get(trunkUserTask
.getLockedUser() .getLockedUser()
.getID().longValue()); .getID().longValue());
if (lockingUser != null) if (lockingUser != null)
userTask.setLockingUser(lockingUser); assignableTask.setLockingUser(lockingUser);
} }
if (trunkUserTask.getNotificationSender() != null) { if (trunkUserTask.getNotificationSender() != null) {
User notificationSender = NgCollection.users.get(trunkUserTask User notificationSender = NgCollection.users.get(trunkUserTask
.getNotificationSender().getID().longValue()); .getNotificationSender().getID().longValue());
if (notificationSender != null) if (notificationSender != null)
userTask.setNotificationSender(notificationSender); assignableTask.setNotificationSender(notificationSender);
} }
// taskAssignments // taskAssignments
GroupCollection groupCollection = trunkUserTask GroupCollection groupCollection = trunkUserTask
.getAssignedGroupCollection(); .getAssignedGroupCollection();
createTaskAssignments(userTask, groupCollection); createTaskAssignments(assignableTask, groupCollection);
} }
} }
/** /**
* Method for creating {@link TaskAssignment}s between {@link UserTask}s * Method for creating {@link TaskAssignment}s between {@link AssignableTask}s
* and {@link Role}s which is an association-class and has not been * and {@link Role}s which is an association-class and has not been
* existent in this old system. The {@link Role}s are represented by the * existent in this old system. The {@link Role}s are represented by the
* given groups. * given groups.
* *
* @param userTask The {@link UserTask} * @param assignableTask The {@link AssignableTask}
* @param groupCollection A collection of the * @param groupCollection A collection of the
* {@link com.arsdigita.kernel.Group}s representing * {@link com.arsdigita.kernel.Group}s representing
* {@link com.arsdigita.kernel.Role}s belonging to * {@link com.arsdigita.kernel.Role}s belonging to
* the userTask * the assignableTask
*/ */
private static void createTaskAssignments(UserTask userTask, private static void createTaskAssignments(AssignableTask assignableTask,
GroupCollection groupCollection) { GroupCollection groupCollection) {
while (groupCollection.next()) { while (groupCollection.next()) {
RoleCollection roleCollection = groupCollection.getGroup().getRoles(); RoleCollection roleCollection = groupCollection.getGroup().getRoles();
@ -127,13 +143,13 @@ public class UserTaskConversion {
Role role = NgCollection.roles.get(roleCollection.getRole() Role role = NgCollection.roles.get(roleCollection.getRole()
.getID().longValue()); .getID().longValue());
if (userTask != null && role != null) { if (assignableTask != null && role != null) {
// create taskAssignments // create taskAssignments
TaskAssignment taskAssignment = new TaskAssignment TaskAssignment taskAssignment = new TaskAssignment
(userTask, role); (assignableTask, role);
// set opposed associations // set opposed associations
userTask.addAssignment(taskAssignment); assignableTask.addAssignment(taskAssignment);
role.addAssignedTask(taskAssignment); role.addAssignedTask(taskAssignment);
} }
} }
@ -157,19 +173,19 @@ public class UserTaskConversion {
for (com.arsdigita.workflow.simple.UserTask trunkUserTask : for (com.arsdigita.workflow.simple.UserTask trunkUserTask :
trunkUserTasks) { trunkUserTasks) {
UserTask userTask = NgCollection.userTasks.get(trunkUserTask.getID() AssignableTask assignableTask = NgCollection.assignableTasks.get(trunkUserTask.getID()
.longValue()); .longValue());
Iterator it = trunkUserTask.getDependencies(); Iterator it = trunkUserTask.getDependencies();
while (it.hasNext()) { while (it.hasNext()) {
UserTask dependency = NgCollection.userTasks.get(((Task) it AssignableTask dependency = NgCollection.assignableTasks.get(((Task) it
.next()) .next())
.getID().longValue()); .getID().longValue());
if (userTask != null && dependency != null) { if (assignableTask != null && dependency != null) {
// set dependencies and opposed // set dependencies and opposed
userTask.addDependsOn(dependency); assignableTask.addDependsOn(dependency);
dependency.addDependentTask(userTask); dependency.addDependentTask(assignableTask);
} }
} }
} }

View File

@ -18,12 +18,16 @@
*/ */
package com.arsdigita.portation.conversion.core.workflow; package com.arsdigita.portation.conversion.core.workflow;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.workflow.Workflow; import com.arsdigita.portation.modules.core.workflow.Workflow;
import com.arsdigita.portation.modules.core.workflow.WorkflowTemplate;
import java.util.List; import java.util.List;
/** /**
* lass for converting all * Class for converting all
* trunk-{@link com.arsdigita.workflow.simple.Workflow}s into * trunk-{@link com.arsdigita.workflow.simple.Workflow}s into
* ng-{@link Workflow}s as preparation for a successful export of all trunk * ng-{@link Workflow}s as preparation for a successful export of all trunk
* classes into the new ng-system. * classes into the new ng-system.
@ -42,7 +46,34 @@ public class WorkflowConversion {
List<com.arsdigita.workflow.simple.Workflow> trunkWorkflows = List<com.arsdigita.workflow.simple.Workflow> trunkWorkflows =
com.arsdigita.workflow.simple.Workflow.getAllObjectWorkflows(); com.arsdigita.workflow.simple.Workflow.getAllObjectWorkflows();
createWorkflowAndSetAssociations(trunkWorkflows);
}
private static void createWorkflowAndSetAssociations(
List<com.arsdigita.workflow.simple.Workflow> trunkWorkflows) {
for (com.arsdigita.workflow.simple.Workflow
trunkWorkflow : trunkWorkflows) {
// create workflows // create workflows
trunkWorkflows.forEach(Workflow::new); Workflow workflow = new Workflow(trunkWorkflow, false);
// set template association
com.arsdigita.workflow.simple.WorkflowTemplate
trunkWorkflowTemplate = trunkWorkflow.getWorkflowTemplate();
if (trunkWorkflowTemplate != null) {
WorkflowTemplate workflowTemplate = NgCollection
.workflowTemplates.get(trunkWorkflowTemplate.getID()
.longValue());
workflow.setTemplate(workflowTemplate);
}
// set object association
ACSObject trunkObject = trunkWorkflow.getObject();
if (trunkObject != null) {
CcmObject object = NgCollection.ccmObjects.get(trunkObject
.getID().longValue());
workflow.setObject(object);
}
}
} }
} }

View File

@ -0,0 +1,49 @@
/*
* 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.conversion.core.workflow;
import com.arsdigita.portation.modules.core.workflow.WorkflowTemplate;
import java.util.List;
/**
* Class for converting all
* trunk-{@link com.arsdigita.workflow.simple.WorkflowTemplate}s into
* ng-{@link WorkflowTemplate}s as preparation for a successful export of all
* trunk classes into the new ng-system.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @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<com.arsdigita.workflow.simple.WorkflowTemplate>
trunkWorkflowTemplates = com.arsdigita.workflow.simple
.WorkflowTemplate.getAllObjectWorkflowTemplates();
trunkWorkflowTemplates.forEach(WorkflowTemplate::new);
}
}

View File

@ -44,7 +44,7 @@ import java.util.Locale;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class Category extends CcmObject { public class Category extends CcmObject implements Portable {
private String uniqueId; private String uniqueId;
private String name; private String name;

View File

@ -19,8 +19,6 @@
package com.arsdigita.portation.modules.core.core; package com.arsdigita.portation.modules.core.core;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.categorization.Categorization; import com.arsdigita.portation.modules.core.categorization.Categorization;
import com.arsdigita.portation.modules.core.categorization.Category; import com.arsdigita.portation.modules.core.categorization.Category;
@ -48,7 +46,7 @@ import java.util.UUID;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class CcmObject implements Portable { public class CcmObject {
private long objectId; private long objectId;
@ -73,11 +71,6 @@ public class CcmObject implements Portable {
NgCollection.ccmObjects.put(this.objectId, this); NgCollection.ccmObjects.put(this.objectId, this);
} }
@Override
public AbstractMarshaller<? extends Portable> getMarshaller() {
return new CcmObjectMarshaller();
}
public long getObjectId() { public long getObjectId() {
return objectId; return objectId;
} }

View File

@ -41,8 +41,8 @@ public class Permission implements Portable {
private CcmObject object; private CcmObject object;
@JsonBackReference @JsonBackReference
private Role grantee; private Role grantee;
private User creationUser;
private User creationUser;
private Date creationDate; private Date creationDate;
private String creationIp; private String creationIp;
@ -59,8 +59,8 @@ public class Permission implements Portable {
//this.object; //this.object;
//this.grantee; //this.grantee;
//this.creationUser
//this.creationUser
this.creationDate = trunkPermission.getCreationDate(); this.creationDate = trunkPermission.getCreationDate();
this.creationIp = trunkPermission.getCreationIP(); this.creationIp = trunkPermission.getCreationIP();
@ -79,8 +79,8 @@ public class Permission implements Portable {
this.object = ngPermission.getObject(); this.object = ngPermission.getObject();
this.grantee = ngPermission.getGrantee(); this.grantee = ngPermission.getGrantee();
this.creationUser = ngPermission.getCreationUser();
this.creationUser = ngPermission.getCreationUser();
this.creationDate = ngPermission.getCreationDate(); this.creationDate = ngPermission.getCreationDate();
this.creationIp = ngPermission.getCreationIp(); this.creationIp = ngPermission.getCreationIp();

View File

@ -32,7 +32,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class UserTask extends Task implements Portable { public class AssignableTask extends Task implements Portable {
private boolean locked; private boolean locked;
private User lockingUser; private User lockingUser;
@ -46,7 +46,7 @@ public class UserTask extends Task implements Portable {
@JsonManagedReference @JsonManagedReference
private List<TaskAssignment> assignments; private List<TaskAssignment> assignments;
public UserTask(final com.arsdigita.workflow.simple.UserTask public AssignableTask(final com.arsdigita.workflow.simple.UserTask
trunkUserTask) { trunkUserTask) {
super(trunkUserTask); super(trunkUserTask);
@ -61,12 +61,12 @@ public class UserTask extends Task implements Portable {
this.assignments = new ArrayList<>(); this.assignments = new ArrayList<>();
NgCollection.userTasks.put(this.getTaskId(), this); NgCollection.assignableTasks.put(this.getTaskId(), this);
} }
@Override @Override
public AbstractMarshaller<? extends Portable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new UserTaskMarshaller(); return new AssignableTaskMarshaller();
} }
public boolean isLocked() { public boolean isLocked() {

View File

@ -24,5 +24,5 @@ import com.arsdigita.portation.AbstractMarshaller;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class UserTaskMarshaller extends AbstractMarshaller<UserTask> { public class AssignableTaskMarshaller extends AbstractMarshaller<AssignableTask> {
} }

View File

@ -20,13 +20,14 @@ package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.l10n.LocalizedString; 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.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonManagedReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.UUID;
/** /**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -35,11 +36,13 @@ import java.util.Locale;
public class Task { public class Task {
private long taskId; private long taskId;
private String uuid;
private LocalizedString label; private LocalizedString label;
private LocalizedString description; private LocalizedString description;
private boolean active; private boolean active;
private String taskState; private TaskState taskState;
@JsonBackReference @JsonBackReference
private Workflow workflow; private Workflow workflow;
@ -49,28 +52,25 @@ public class Task {
@JsonManagedReference @JsonManagedReference
private List<Task> dependsOn; private List<Task> dependsOn;
private List<String> comments; private List<TaskComment> comments;
public Task(final com.arsdigita.workflow.simple.Task trunkTask) { public Task(final com.arsdigita.workflow.simple.Task trunkTask) {
this.taskId = trunkTask.getID().longValue(); this.taskId = trunkTask.getID().longValue();
this.uuid = UUID.randomUUID().toString();
this.label = new LocalizedString(); this.label = new LocalizedString();
this.label.addValue(Locale.ENGLISH, trunkTask.getLabel()); this.label.addValue(Locale.getDefault(), trunkTask.getLabel());
this.description = new LocalizedString(); this.description = new LocalizedString();
this.description.addValue(Locale.ENGLISH, trunkTask.getDescription()); this.description.addValue(Locale.getDefault(), trunkTask.getDescription());
this.active = trunkTask.isActive(); this.active = trunkTask.isActive();
this.taskState = trunkTask.getStateString(); this.taskState = StateMapper.mapTaskState(trunkTask.getState());
//this.workflow //this.workflow
this.dependentTasks = new ArrayList<>(); this.dependentTasks = new ArrayList<>();
this.dependsOn = new ArrayList<>(); this.dependsOn = new ArrayList<>();
this.comments = new ArrayList<>(); this.comments = new ArrayList<>();
Iterator commentsIt = trunkTask.getComments();
while (commentsIt.hasNext()) {
addComment(commentsIt.next().toString());
}
NgCollection.tasks.put(this.getTaskId(), this); NgCollection.tasks.put(this.getTaskId(), this);
} }
@ -83,6 +83,14 @@ public class Task {
this.taskId = taskId; this.taskId = taskId;
} }
public String getUuid() {
return uuid;
}
public void setUuid(final String uuid) {
this.uuid = uuid;
}
public LocalizedString getLabel() { public LocalizedString getLabel() {
return label; return label;
} }
@ -107,11 +115,11 @@ public class Task {
this.active = active; this.active = active;
} }
public String getTaskState() { public TaskState getTaskState() {
return taskState; return taskState;
} }
public void setTaskState(final String taskState) { public void setTaskState(final TaskState taskState) {
this.taskState = taskState; this.taskState = taskState;
} }
@ -151,24 +159,24 @@ public class Task {
dependsOn.add(task); dependsOn.add(task);
} }
public void removeDependsOn(final Task task) { public void removeDependsOn(final Task task) {
dependsOn.remove(task); dependsOn.remove(task);
} }
public List<TaskComment> getComments() {
public List<String> getComments() {
return comments; return comments;
} }
public void setComments(final List<String> comments) { public void setComments(final List<TaskComment> comments) {
this.comments = comments; this.comments = comments;
} }
public void addComment(final String comment) { public void addComment(final TaskComment comment) {
comments.add(comment); comments.add(comment);
} }
public void removeComment(final String comment) { public void removeComment(final TaskComment comment) {
comments.remove(comment); comments.remove(comment);
} }
} }

View File

@ -33,11 +33,11 @@ public class TaskAssignment implements Portable {
private long taskAssignmentId; private long taskAssignmentId;
@JsonBackReference @JsonBackReference
private UserTask task; private AssignableTask task;
@JsonBackReference @JsonBackReference
private Role role; private Role role;
public TaskAssignment(final UserTask task, final Role role) { public TaskAssignment(final AssignableTask task, final Role role) {
this.taskAssignmentId = NgCollection.taskAssignments.size() + 1; this.taskAssignmentId = NgCollection.taskAssignments.size() + 1;
this.task = task; this.task = task;
@ -59,11 +59,11 @@ public class TaskAssignment implements Portable {
this.taskAssignmentId = taskAssignmentId; this.taskAssignmentId = taskAssignmentId;
} }
public UserTask getTask() { public AssignableTask getTask() {
return task; return task;
} }
public void setTask(final UserTask task) { public void setTask(final AssignableTask task) {
this.task = task; this.task = task;
} }

View File

@ -0,0 +1,76 @@
/*
* 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;
import com.arsdigita.portation.modules.core.security.User;
import java.util.UUID;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @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;
}
}

View File

@ -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 <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 11/18/16
*/
public enum TaskState {
ENABLED,
DISABLED,
FINISHED,
DELETED,
NONE
}

View File

@ -21,12 +21,15 @@ package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Portable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.arsdigita.portation.modules.core.workflow.util.StateMapper;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonManagedReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.UUID;
/** /**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -35,25 +38,46 @@ import java.util.Locale;
public class Workflow implements Portable { public class Workflow implements Portable {
private long workflowId; private long workflowId;
private String uuid;
private WorkflowTemplate template;
private LocalizedString name; private LocalizedString name;
private LocalizedString description; private LocalizedString description;
//Todo: private WorkflowTemplate workflowTemplate; private WorkflowState workflowState;
private boolean active;
private TaskState tasksState;
private CcmObject object;
@JsonManagedReference @JsonManagedReference
private List<Task> tasks; private List<Task> 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.workflowId = trunkWorkFlow.getID().longValue();
this.uuid = UUID.randomUUID().toString();
//template
this.name = new LocalizedString(); this.name = new LocalizedString();
this.name.addValue(Locale.ENGLISH, trunkWorkFlow.getDisplayName()); this.name.addValue(Locale.getDefault(), trunkWorkFlow.getDisplayName());
this.description = new LocalizedString(); 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<>(); this.tasks = new ArrayList<>();
if (!template)
NgCollection.workflows.put(this.workflowId, this); NgCollection.workflows.put(this.workflowId, this);
} }
@ -70,6 +94,22 @@ public class Workflow implements Portable {
this.workflowId = workflowId; 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() { public LocalizedString getName() {
return name; return name;
} }
@ -86,6 +126,38 @@ public class Workflow implements Portable {
this.description = description; 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<Task> getTasks() { public List<Task> getTasks() {
return tasks; return tasks;
} }

View File

@ -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 <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 11/18/16
*/
public enum WorkflowState {
STARTED,
STOPPED,
DELETED,
INIT,
NONE
}

View File

@ -0,0 +1,35 @@
/*
* 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;
import com.arsdigita.portation.conversion.NgCollection;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @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);
}
}

View File

@ -16,13 +16,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
package com.arsdigita.portation.modules.core.core; package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
/** /**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 6/15/16 * @version created on 11/21/16
*/ */
public class CcmObjectMarshaller extends AbstractMarshaller<CcmObject> { public class WorkflowTemplateMarshaller extends
AbstractMarshaller<WorkflowTemplate> {
} }

View File

@ -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 <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 11/21/16
*/
public class StateMapper {
public static WorkflowState mapWorkflowState(int processState) {
switch (processState) {
case Workflow.STARTED:
return WorkflowState.STARTED;
case Workflow.STOPPED:
return WorkflowState.STOPPED;
case Workflow.DELETED:
return WorkflowState.DELETED;
case Workflow.INIT:
return WorkflowState.INIT;
case Workflow.NONE:
return WorkflowState.NONE;
default:
return WorkflowState.NONE;
}
}
public static TaskState mapTaskState(int taskState) {
switch (taskState) {
case Task.ENABLED:
return TaskState.ENABLED;
case Task.DISABLED:
return TaskState.DISABLED;
case Task.FINISHED:
return TaskState.FINISHED;
case Task.DELETED:
return TaskState.DELETED;
default:
return TaskState.NONE;
}
}
}

View File

@ -53,11 +53,11 @@ public class TaskComment extends ObservableDomainObject {
"com.arsdigita.workflow.simple.TaskComment"; "com.arsdigita.workflow.simple.TaskComment";
private static final String COMMENT_ID = "id";
private static final String COMMENT = "taskComment"; private static final String COMMENT = "taskComment";
private static final String DATE = "commentDate"; private static final String DATE = "commentDate";
private static final String USER_ID = "partyID"; private static final String USER_ID = "partyID";
private static final String TASK = "task"; private static final String TASK = "task";
private static final String COMMENT_ID = "id";
/** /**
@ -199,6 +199,15 @@ public class TaskComment extends ObservableDomainObject {
return BASE_DATA_OBJECT_TYPE; return BASE_DATA_OBJECT_TYPE;
} }
/**
* Retrieves the id of this comment.
*
* @return This comments id.
*/
public BigDecimal getCommentID() {
return (BigDecimal) get(COMMENT_ID);
}
/** /**
* Retrieves the comment string. * Retrieves the comment string.
* @return the comment string. * @return the comment string.

View File

@ -1015,7 +1015,7 @@ public class UserTask extends Task implements Assignable {
* Retrieves all objects of this type stored in the database. Very * Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment. * necessary for exporting all entities of the current work environment.
* *
* @return List of all userTasks * @return List of all assignableTasks
*/ */
public static List<UserTask> getAllObjectUserTasks() { public static List<UserTask> getAllObjectUserTasks() {
List<UserTask> userTaskList = new ArrayList<>(); List<UserTask> userTaskList = new ArrayList<>();

View File

@ -343,6 +343,16 @@ public class Workflow extends Task {
return getProcessStateInt((String) get(PROCESS_STATE)); 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', * Internal method to set the state from the DB, 'stopped',
* 'started','deleted', 'init' are allowed * 'started','deleted', 'init' are allowed

View File

@ -18,16 +18,21 @@
*/ */
package com.arsdigita.workflow.simple; package com.arsdigita.workflow.simple;
import java.util.Iterator; import com.arsdigita.domain.DataObjectNotFoundException;
import java.util.Collections; import com.arsdigita.domain.DomainCollection;
import java.math.BigDecimal;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
import com.arsdigita.kernel.User;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.metadata.ObjectType; 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() { public OID getObjectOID() {
return null; 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<WorkflowTemplate> getAllObjectWorkflowTemplates() {
List<WorkflowTemplate> 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;
}
} }