- 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();
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;
@ -226,8 +232,9 @@ public class ExportCliTool extends Program {
" \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 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 permissions \t\t all permissions of the system\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.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() {

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.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();
}
}

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.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<Long, RoleMembership> roleMemberships = 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, UserTask> userTasks = new HashMap<>();
public static Map<Long, AssignableTask> assignableTasks = new HashMap<>();
public static Map<Long, TaskAssignment> taskAssignments = 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
* {@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

View File

@ -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 <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 29.6.16
*/
public class UserTaskConversion {
public class AssignableTaskConversion {
/**
* Retrieves all trunk-{@link com.arsdigita.workflow.simple.UserTask}s from
* 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
* 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() {
List<com.arsdigita.workflow.simple.UserTask> trunkUserTasks = com
.arsdigita.workflow.simple.UserTask.getAllObjectUserTasks();
createUserTasksAndSetAssociations(trunkUserTasks);
createAssignableTasksAndSetAssociations(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.
*
* @param trunkUserTasks List of all
* {@link com.arsdigita.workflow.simple.UserTask}s
* from this old trunk-system.
*/
private static void createUserTasksAndSetAssociations(List<com.arsdigita
private static void createAssignableTasksAndSetAssociations(List<com.arsdigita
.workflow.simple.UserTask> trunkUserTasks) {
for (com.arsdigita.workflow.simple.UserTask trunkUserTask :
trunkUserTasks) {
// create userTask
UserTask userTask = new UserTask(trunkUserTask);
// create assignableTask
AssignableTask assignableTask = new AssignableTask(trunkUserTask);
// set workflow and opposed associations
if (trunkUserTask.getWorkflow() != null) {
Workflow workflow = NgCollection.workflows.get(
trunkUserTask.getWorkflow().getID().longValue());
if (workflow != null) {
userTask.setWorkflow(workflow);
workflow.addTask(userTask);
assignableTask.setWorkflow(workflow);
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
if (trunkUserTask.getLockedUser() != null) {
User lockingUser = NgCollection.users.get(trunkUserTask
.getLockedUser()
.getID().longValue());
if (lockingUser != null)
userTask.setLockingUser(lockingUser);
assignableTask.setLockingUser(lockingUser);
}
if (trunkUserTask.getNotificationSender() != null) {
User notificationSender = NgCollection.users.get(trunkUserTask
.getNotificationSender().getID().longValue());
if (notificationSender != null)
userTask.setNotificationSender(notificationSender);
assignableTask.setNotificationSender(notificationSender);
}
// taskAssignments
GroupCollection groupCollection = trunkUserTask
.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
* existent in this old system. The {@link Role}s are represented by the
* given groups.
*
* @param userTask The {@link UserTask}
* @param assignableTask The {@link AssignableTask}
* @param groupCollection A collection of the
* {@link com.arsdigita.kernel.Group}s representing
* {@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) {
while (groupCollection.next()) {
RoleCollection roleCollection = groupCollection.getGroup().getRoles();
@ -127,13 +143,13 @@ public class UserTaskConversion {
Role role = NgCollection.roles.get(roleCollection.getRole()
.getID().longValue());
if (userTask != null && role != null) {
if (assignableTask != null && role != null) {
// create taskAssignments
TaskAssignment taskAssignment = new TaskAssignment
(userTask, role);
(assignableTask, role);
// set opposed associations
userTask.addAssignment(taskAssignment);
assignableTask.addAssignment(taskAssignment);
role.addAssignedTask(taskAssignment);
}
}
@ -157,19 +173,19 @@ public class UserTaskConversion {
for (com.arsdigita.workflow.simple.UserTask trunkUserTask :
trunkUserTasks) {
UserTask userTask = NgCollection.userTasks.get(trunkUserTask.getID()
AssignableTask assignableTask = NgCollection.assignableTasks.get(trunkUserTask.getID()
.longValue());
Iterator it = trunkUserTask.getDependencies();
while (it.hasNext()) {
UserTask dependency = NgCollection.userTasks.get(((Task) it
AssignableTask dependency = NgCollection.assignableTasks.get(((Task) it
.next())
.getID().longValue());
if (userTask != null && dependency != null) {
if (assignableTask != null && dependency != null) {
// set dependencies and opposed
userTask.addDependsOn(dependency);
dependency.addDependentTask(userTask);
assignableTask.addDependsOn(dependency);
dependency.addDependentTask(assignableTask);
}
}
}

View File

@ -18,12 +18,16 @@
*/
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.WorkflowTemplate;
import java.util.List;
/**
* lass for converting all
* Class for converting all
* trunk-{@link com.arsdigita.workflow.simple.Workflow}s into
* ng-{@link Workflow}s as preparation for a successful export of all trunk
* classes into the new ng-system.
@ -42,7 +46,34 @@ public class WorkflowConversion {
List<com.arsdigita.workflow.simple.Workflow> trunkWorkflows =
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
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>
* @version created on 6/15/16
*/
public class Category extends CcmObject {
public class Category extends CcmObject implements Portable {
private String uniqueId;
private String name;

View File

@ -19,8 +19,6 @@
package com.arsdigita.portation.modules.core.core;
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.modules.core.categorization.Categorization;
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>
* @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<? extends Portable> getMarshaller() {
return new CcmObjectMarshaller();
}
public long getObjectId() {
return objectId;
}

View File

@ -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();

View File

@ -32,7 +32,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class UserTask extends Task implements Portable {
public class AssignableTask extends Task implements Portable {
private boolean locked;
private User lockingUser;
@ -46,7 +46,7 @@ public class UserTask extends Task implements Portable {
@JsonManagedReference
private List<TaskAssignment> assignments;
public UserTask(final com.arsdigita.workflow.simple.UserTask
public AssignableTask(final com.arsdigita.workflow.simple.UserTask
trunkUserTask) {
super(trunkUserTask);
@ -61,12 +61,12 @@ public class UserTask extends Task implements Portable {
this.assignments = new ArrayList<>();
NgCollection.userTasks.put(this.getTaskId(), this);
NgCollection.assignableTasks.put(this.getTaskId(), this);
}
@Override
public AbstractMarshaller<? extends Portable> getMarshaller() {
return new UserTaskMarshaller();
return new AssignableTaskMarshaller();
}
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>
* @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.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 <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -35,11 +36,13 @@ import java.util.Locale;
public class Task {
private long taskId;
private String uuid;
private LocalizedString label;
private LocalizedString description;
private boolean active;
private String taskState;
private TaskState taskState;
@JsonBackReference
private Workflow workflow;
@ -49,28 +52,25 @@ public class Task {
@JsonManagedReference
private List<Task> dependsOn;
private List<String> comments;
private List<TaskComment> comments;
public Task(final com.arsdigita.workflow.simple.Task trunkTask) {
this.taskId = trunkTask.getID().longValue();
this.uuid = UUID.randomUUID().toString();
this.label = new LocalizedString();
this.label.addValue(Locale.ENGLISH, trunkTask.getLabel());
this.label.addValue(Locale.getDefault(), trunkTask.getLabel());
this.description = new LocalizedString();
this.description.addValue(Locale.ENGLISH, trunkTask.getDescription());
this.description.addValue(Locale.getDefault(), trunkTask.getDescription());
this.active = trunkTask.isActive();
this.taskState = trunkTask.getStateString();
this.taskState = StateMapper.mapTaskState(trunkTask.getState());
//this.workflow
this.dependentTasks = new ArrayList<>();
this.dependsOn = new ArrayList<>();
this.comments = new ArrayList<>();
Iterator commentsIt = trunkTask.getComments();
while (commentsIt.hasNext()) {
addComment(commentsIt.next().toString());
}
NgCollection.tasks.put(this.getTaskId(), this);
}
@ -83,6 +83,14 @@ public class Task {
this.taskId = taskId;
}
public String getUuid() {
return uuid;
}
public void setUuid(final String uuid) {
this.uuid = uuid;
}
public LocalizedString getLabel() {
return label;
}
@ -107,11 +115,11 @@ public class Task {
this.active = active;
}
public String getTaskState() {
public TaskState getTaskState() {
return taskState;
}
public void setTaskState(final String taskState) {
public void setTaskState(final TaskState taskState) {
this.taskState = taskState;
}
@ -151,24 +159,24 @@ public class Task {
dependsOn.add(task);
}
public void removeDependsOn(final Task task) {
dependsOn.remove(task);
}
public List<String> getComments() {
public List<TaskComment> getComments() {
return comments;
}
public void setComments(final List<String> comments) {
public void setComments(final List<TaskComment> comments) {
this.comments = comments;
}
public void addComment(final String comment) {
public void addComment(final TaskComment comment) {
comments.add(comment);
}
public void removeComment(final String comment) {
public void removeComment(final TaskComment comment) {
comments.remove(comment);
}
}

View File

@ -33,11 +33,11 @@ public class TaskAssignment implements Portable {
private long taskAssignmentId;
@JsonBackReference
private UserTask task;
private AssignableTask task;
@JsonBackReference
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.task = task;
@ -59,11 +59,11 @@ public class TaskAssignment implements Portable {
this.taskAssignmentId = taskAssignmentId;
}
public UserTask getTask() {
public AssignableTask getTask() {
return task;
}
public void setTask(final UserTask task) {
public void setTask(final AssignableTask 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.Portable;
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.workflow.util.StateMapper;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -35,25 +38,46 @@ 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<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.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<>();
if (!template)
NgCollection.workflows.put(this.workflowId, this);
}
@ -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<Task> getTasks() {
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,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @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";
private static final String COMMENT_ID = "id";
private static final String COMMENT = "taskComment";
private static final String DATE = "commentDate";
private static final String USER_ID = "partyID";
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;
}
/**
* Retrieves the id of this comment.
*
* @return This comments id.
*/
public BigDecimal getCommentID() {
return (BigDecimal) get(COMMENT_ID);
}
/**
* Retrieves 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
* 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() {
List<UserTask> userTaskList = new ArrayList<>();

View File

@ -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

View File

@ -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<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;
}
}