adds converter for ng-class UserTask

git-svn-id: https://svn.libreccm.org/ccm/trunk@4189 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2016-07-04 21:28:49 +00:00
parent e7f6f22e26
commit 35a47857e0
10 changed files with 161 additions and 85 deletions

View File

@ -26,6 +26,7 @@ import com.arsdigita.portation.modules.core.security.GroupMembership;
import com.arsdigita.portation.modules.core.security.Party; import com.arsdigita.portation.modules.core.security.Party;
import com.arsdigita.portation.modules.core.security.User; import com.arsdigita.portation.modules.core.security.User;
import com.arsdigita.portation.modules.core.workflow.Task; import com.arsdigita.portation.modules.core.workflow.Task;
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 java.util.HashMap; import java.util.HashMap;
@ -38,14 +39,17 @@ import java.util.Map;
public class NgCollection { public class NgCollection {
public static Map<Long, CcmObject> ccmObjects = new HashMap<>(); public static Map<Long, CcmObject> ccmObjects = new HashMap<>();
public static Map<Long, Workflow> workflows = new HashMap<>();
public static Map<Long, Task> tasks = new HashMap<>();
public static Map<Long, Category> categories = new HashMap<>(); public static Map<Long, Category> categories = new HashMap<>();
public static Map<Long, Categorization> categorizations = new HashMap<>(); public static Map<Long, Categorization> categorizations = new HashMap<>();
public static Map<Long, Party> parties = new HashMap<>(); public static Map<Long, Party> parties = new HashMap<>();
public static Map<Long, User> users = new HashMap<>(); public static Map<Long, User> users = new HashMap<>();
public static Map<Long, Group> groups = new HashMap<>(); public static Map<Long, Group> groups = new HashMap<>();
public static Map<Long, GroupMembership> groupMemberships = new HashMap<>(); public static Map<Long, GroupMembership> groupMemberships = new HashMap<>();
public static Map<Long, Workflow> workflows = new HashMap<>();
public static Map<Long, Task> tasks = new HashMap<>();
public static Map<Long, UserTask> userTasks = new HashMap<>();
private NgCollection() {} private NgCollection() {}
} }

View File

@ -37,6 +37,7 @@ public class CategoryConversion {
List<com.arsdigita.categorization.Category> trunkCategories = com List<com.arsdigita.categorization.Category> trunkCategories = com
.arsdigita.categorization.Category.getAllObjectCategories(); .arsdigita.categorization.Category.getAllObjectCategories();
// create categories
trunkCategories.forEach(Category::new); trunkCategories.forEach(Category::new);
setAssociations(trunkCategories); setAssociations(trunkCategories);
@ -73,6 +74,7 @@ public class CategoryConversion {
private static void setParentCategory(Category category, Category private static void setParentCategory(Category category, Category
parentCategory) { parentCategory) {
if (category != null && parentCategory != null) { if (category != null && parentCategory != null) {
// set parent and opposed association
category.setParentCategory(parentCategory); category.setParentCategory(parentCategory);
parentCategory.addSubCategory(category); parentCategory.addSubCategory(category);
} }
@ -81,15 +83,16 @@ public class CategoryConversion {
private static void createCategorizations(Category category, private static void createCategorizations(Category category,
CategorizedCollection CategorizedCollection
categorizedObjects) { categorizedObjects) {
CcmObject categorizedObject; Categorization categorization;
while (categorizedObjects.next()) { while (categorizedObjects.next()) {
CcmObject categorizedObject = NgCollection.ccmObjects.get(( categorizedObject = NgCollection.ccmObjects.get(((ACSObject)
(ACSObject) categorizedObjects.getDomainObject()) categorizedObjects.getDomainObject()).getID().longValue());
.getID().longValue());
// create categorizations // create categorizations
Categorization categorization = new Categorization(category, categorization = new Categorization(category,
categorizedObject); categorizedObject);
// set adverse associations // set opposed associations
category.addObject(categorization); category.addObject(categorization);
categorizedObject.addCategory(categorization); categorizedObject.addCategory(categorization);
} }

View File

@ -36,6 +36,7 @@ public class GroupConversion {
List<com.arsdigita.kernel.Group> trunkGroups = com.arsdigita.kernel List<com.arsdigita.kernel.Group> trunkGroups = com.arsdigita.kernel
.Group.getAllObjectGroups(); .Group.getAllObjectGroups();
// create groups
trunkGroups.forEach(Group::new); trunkGroups.forEach(Group::new);
setAssociations(trunkGroups); setAssociations(trunkGroups);

View File

@ -32,6 +32,7 @@ public class UserConversion {
List<com.arsdigita.kernel.User> trunkUsers = com.arsdigita.kernel List<com.arsdigita.kernel.User> trunkUsers = com.arsdigita.kernel
.User.getAllObjectUsers(); .User.getAllObjectUsers();
// create users
trunkUsers.forEach(User::new); trunkUsers.forEach(User::new);
} }
} }

View File

@ -1,53 +0,0 @@
/*
* 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.conversion.NgCollection;
import com.arsdigita.portation.modules.core.workflow.Task;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created the 6/29/16
*/
public class TaskConversion {
public static void convertAll() {
List<com.arsdigita.workflow.simple.Task> trunkTasks =
com.arsdigita.workflow.simple.Task.getAllObjectTasks();
Task task;
Workflow workflow;
for (com.arsdigita.workflow.simple.Task trunkTask : trunkTasks) {
task = new Task(trunkTask);
workflow = NgCollection.workflows.get(
trunkTask.getWorkflow().getID().longValue());
// set associations
if (workflow != null) {
task.setWorkflow(workflow);
workflow.addTask(task);
}
}
}
}

View File

@ -0,0 +1,97 @@
/*
* 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.conversion.NgCollection;
import com.arsdigita.portation.modules.core.security.User;
import com.arsdigita.portation.modules.core.workflow.UserTask;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import com.arsdigita.workflow.simple.Task;
import java.util.Iterator;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created the 6/29/16
*/
public class UserTaskConversion {
public static void convertAll() {
List<com.arsdigita.workflow.simple.UserTask> trunkUserTasks = com
.arsdigita.workflow.simple.UserTask.getAllObjectUserTasks();
createUserTaskSetAssociations(trunkUserTasks);
setTaskDependencies(trunkUserTasks);
}
private static void createUserTaskSetAssociations(List<com.arsdigita
.workflow.simple.UserTask> trunkUserTasks) {
UserTask userTask; Workflow workflow;
User lockingUser, notificationSender;
for (com.arsdigita.workflow.simple.UserTask trunkUserTask :
trunkUserTasks) {
// create userTask
userTask = new UserTask(trunkUserTask);
// set workflow and opposed associations
workflow = NgCollection.workflows.get(
trunkUserTask.getWorkflow().getID().longValue());
if (workflow != null) {
userTask.setWorkflow(workflow);
workflow.addTask(userTask);
}
// set lockingUser and notificationSender
lockingUser = NgCollection.users.get(trunkUserTask.getLockedUser()
.getID().longValue());
notificationSender = NgCollection.users.get(trunkUserTask
.getNotificationSender().getID().longValue());
if (lockingUser != null)
userTask.setLockingUser(lockingUser);
if (notificationSender != null)
userTask.setNotificationSender(notificationSender);
}
}
private static void setTaskDependencies(List<com.arsdigita.workflow
.simple.UserTask> trunkUserTasks) {
UserTask userTask, dependency;
for (com.arsdigita.workflow.simple.UserTask trunkUserTask :
trunkUserTasks) {
userTask = NgCollection.userTasks.get(trunkUserTask.getID()
.longValue());
Iterator it = trunkUserTask.getDependencies();
while (it.hasNext()) {
dependency = NgCollection.userTasks.get(((Task) it.next())
.getID().longValue());
// set dependencies and opposed
userTask.addDependsOn(dependency);
dependency.addDependentTask(userTask);
}
}
}
}

View File

@ -32,6 +32,7 @@ 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();
// create workflows
trunkWorkflows.forEach(Workflow::new); trunkWorkflows.forEach(Workflow::new);
} }
} }

View File

@ -20,8 +20,10 @@ package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Identifiable;
import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.security.User; import com.arsdigita.portation.modules.core.security.User;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -33,16 +35,31 @@ public class UserTask extends Task {
private boolean locked; private boolean locked;
private User lockingUser; private User lockingUser;
private Date startDate; private Date startDate;
private Date dueDate; private Date dueDate;
private long durationMinutes; private long durationMinutes;
private User notificationSender; private User notificationSender;
private List<TaskAssignment> assignments; private List<TaskAssignment> assignments;
public UserTask(final com.arsdigita.workflow.simple.UserTask public UserTask(final com.arsdigita.workflow.simple.UserTask
trunkUserTask) { trunkUserTask) {
super(trunkUserTask); super(trunkUserTask);
this.locked = trunkUserTask.isLocked();
//this.lockingUser
this.startDate = trunkUserTask.getStartDate();
this.dueDate = trunkUserTask.getDueDate();
this.durationMinutes = trunkUserTask.getDuration().getDuration();
//this.notificationSender
this.assignments = new ArrayList<>();
NgCollection.userTasks.put(this.getTaskId(), this);
} }
@Override @Override

View File

@ -1189,27 +1189,4 @@ public class Task extends AuditedACSObject implements Cloneable {
protected void finishEvt() { protected void finishEvt() {
}; };
/**
* 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 tasks
*/
public static List<Task> getAllObjectTasks() {
List<Task> taskList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
Task.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
Task task = (Task) collection.getDomainObject();
if (task != null) {
taskList.add(task);
}
}
collection.close();
return taskList;
}
} }

View File

@ -19,6 +19,7 @@
package com.arsdigita.workflow.simple; package com.arsdigita.workflow.simple;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.Group; import com.arsdigita.kernel.Group;
import com.arsdigita.kernel.GroupCollection; import com.arsdigita.kernel.GroupCollection;
@ -32,17 +33,20 @@ import com.arsdigita.notification.Notification;
import com.arsdigita.persistence.DataAssociation; import com.arsdigita.persistence.DataAssociation;
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.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Logger;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
/** /**
* User task that is associated with an interface for performing some manual * User task that is associated with an interface for performing some manual
@ -1006,4 +1010,28 @@ public class UserTask extends Task implements Assignable {
protected boolean sendAlerts(String operation) { protected boolean sendAlerts(String operation) {
return s_conf.isAlertsEnabled(); return s_conf.isAlertsEnabled();
} }
/**
* 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
*/
public static List<UserTask> getAllObjectUserTasks() {
List<UserTask> userTaskList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
UserTask.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
UserTask userTask = (UserTask) collection.getDomainObject();
if (userTask != null) {
userTaskList.add(userTask);
}
}
collection.close();
return userTaskList;
}
} }