From e7f6f22e266ffa914f366b2675943be0e7a50eb8 Mon Sep 17 00:00:00 2001 From: tosmers Date: Mon, 4 Jul 2016 16:22:14 +0000 Subject: [PATCH] adds converter for the ng-classes Workflow, Task, Category, User and Group; as well as multiple other modifications in package conversion git-svn-id: https://svn.libreccm.org/ccm/trunk@4188 8810af33-2d31-482b-a856-94f89814c4df --- .../arsdigita/categorization/Category.java | 31 +++++++- ccm-core/src/com/arsdigita/kernel/Group.java | 28 ++++++++ ccm-core/src/com/arsdigita/kernel/User.java | 27 +++++++ .../portation/conversion/NgCollection.java | 11 ++- .../categorization/CategoryConversion.java | 65 +++++++++++++---- .../core/security/GroupConversion.java | 72 +++++++++++++++++++ .../UserConversion.java} | 17 ++++- .../core/workflow/TaskConversion.java | 25 ++----- .../core/workflow/WorkflowConversion.java | 2 +- .../core/categorization/Categorization.java | 12 ++-- .../modules/core/core/CcmObject.java | 7 +- .../modules/core/core/EmailAddress.java | 11 +-- .../modules/core/security/Group.java | 17 ++++- .../core/security/GroupMembership.java | 13 ++-- .../modules/core/security/Party.java | 23 ++++-- .../modules/core/security/Permission.java | 14 ++-- .../portation/modules/core/security/Role.java | 38 ++++++++-- .../modules/core/security/RoleMembership.java | 6 +- .../portation/modules/core/security/User.java | 61 +++++++++++++--- .../modules/core/workflow/TaskAssignment.java | 6 +- .../modules/core/workflow/UserTask.java | 22 ++++-- .../modules/core/workflow/Workflow.java | 4 ++ .../com/arsdigita/workflow/simple/Task.java | 29 +++++++- .../arsdigita/workflow/simple/Workflow.java | 8 ++- 24 files changed, 448 insertions(+), 101 deletions(-) create mode 100644 ccm-core/src/com/arsdigita/portation/conversion/core/security/GroupConversion.java rename ccm-core/src/com/arsdigita/portation/conversion/core/{categorization/CategorizationConversion.java => security/UserConversion.java} (68%) diff --git a/ccm-core/src/com/arsdigita/categorization/Category.java b/ccm-core/src/com/arsdigita/categorization/Category.java index 151c07524..b7cfa8d22 100755 --- a/ccm-core/src/com/arsdigita/categorization/Category.java +++ b/ccm-core/src/com/arsdigita/categorization/Category.java @@ -20,6 +20,7 @@ package com.arsdigita.categorization; import com.arsdigita.db.Sequences; import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.domain.DomainCollection; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainServiceInterfaceExposer; import com.arsdigita.globalization.GlobalizationHelper; @@ -36,22 +37,22 @@ import com.arsdigita.persistence.DataOperation; import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.DataQueryDataCollectionAdapter; import com.arsdigita.persistence.OID; +import com.arsdigita.persistence.Session; import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.metadata.ObjectType; import com.arsdigita.util.Assert; import com.arsdigita.util.HierarchyDenormalization; import com.arsdigita.util.StringUtils; import com.arsdigita.util.UncheckedWrapperException; +import org.apache.log4j.Logger; import java.math.BigDecimal; import java.sql.SQLException; -import java.util.Collection; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.StringTokenizer; -import org.apache.log4j.Logger; - /** * *

Implements persistent storage of categories. See {@link @@ -2410,4 +2411,28 @@ public class Category extends ACSObject { return false; } + /** + * 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 categories + */ + public static List getAllObjectCategories() { + List categoryList = new ArrayList<>(); + + final Session session = SessionManager.getSession(); + DomainCollection collection = new DomainCollection(session.retrieve( + Category.BASE_DATA_OBJECT_TYPE)); + + while (collection.next()) { + Category category = (Category) collection.getDomainObject(); + if (category != null) { + categoryList.add(category); + } + } + + collection.close(); + return categoryList; + } + } diff --git a/ccm-core/src/com/arsdigita/kernel/Group.java b/ccm-core/src/com/arsdigita/kernel/Group.java index cd0de3aec..7ec19288f 100755 --- a/ccm-core/src/com/arsdigita/kernel/Group.java +++ b/ccm-core/src/com/arsdigita/kernel/Group.java @@ -21,8 +21,10 @@ package com.arsdigita.kernel; // Identity class. import java.math.BigDecimal; +import com.arsdigita.categorization.Category; import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.domain.DomainCollection; import com.arsdigita.persistence.DataAssociation; import com.arsdigita.persistence.DataAssociationCursor; import com.arsdigita.persistence.DataCollection; @@ -32,12 +34,14 @@ import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.Filter; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.PersistenceException; +import com.arsdigita.persistence.Session; import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.metadata.ObjectType; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; +import java.util.List; /** * Represents a group. @@ -811,4 +815,28 @@ public class Group extends Party { return SessionManager.getSession().retrieveDataOperation(name); } + /** + * 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 groups + */ + public static List getAllObjectGroups() { + List groupList = new ArrayList<>(); + + final Session session = SessionManager.getSession(); + DomainCollection collection = new DomainCollection(session.retrieve( + Group.BASE_DATA_OBJECT_TYPE)); + + while (collection.next()) { + Group group = (Group) collection.getDomainObject(); + if (group != null) { + groupList.add(group); + } + } + + collection.close(); + return groupList; + } + } diff --git a/ccm-core/src/com/arsdigita/kernel/User.java b/ccm-core/src/com/arsdigita/kernel/User.java index a2456e692..9a0daaae3 100755 --- a/ccm-core/src/com/arsdigita/kernel/User.java +++ b/ccm-core/src/com/arsdigita/kernel/User.java @@ -21,6 +21,7 @@ package com.arsdigita.kernel; // Identity class. import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.domain.DomainCollection; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.kernel.permissions.PermissionDescriptor; import com.arsdigita.kernel.permissions.PermissionService; @@ -29,6 +30,8 @@ import com.arsdigita.persistence.*; import com.arsdigita.persistence.metadata.ObjectType; import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; /** * Represents a user. @@ -469,4 +472,28 @@ public class User extends Party { public void setBanned(boolean b) { set(BANNED, new Boolean(b)); } + + /** + * 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 users + */ + public static List getAllObjectUsers() { + List userList = new ArrayList<>(); + + final Session session = SessionManager.getSession(); + DomainCollection collection = new DomainCollection(session.retrieve( + User.BASE_DATA_OBJECT_TYPE)); + + while (collection.next()) { + User user = (User) collection.getDomainObject(); + if (user != null) { + userList.add(user); + } + } + + collection.close(); + return userList; + } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/NgCollection.java b/ccm-core/src/com/arsdigita/portation/conversion/NgCollection.java index c1cbb50c7..c69459cd2 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/NgCollection.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/NgCollection.java @@ -20,6 +20,11 @@ package com.arsdigita.portation.conversion; import com.arsdigita.portation.modules.core.categorization.Categorization; import com.arsdigita.portation.modules.core.categorization.Category; +import com.arsdigita.portation.modules.core.core.CcmObject; +import com.arsdigita.portation.modules.core.security.Group; +import com.arsdigita.portation.modules.core.security.GroupMembership; +import com.arsdigita.portation.modules.core.security.Party; +import com.arsdigita.portation.modules.core.security.User; import com.arsdigita.portation.modules.core.workflow.Task; import com.arsdigita.portation.modules.core.workflow.Workflow; @@ -32,11 +37,15 @@ import java.util.Map; */ public class NgCollection { - //public static Map ccmObjects = new HashMap<>(); + public static Map ccmObjects = new HashMap<>(); public static Map workflows = new HashMap<>(); public static Map tasks = new HashMap<>(); public static Map categories = new HashMap<>(); public static Map categorizations = new HashMap<>(); + public static Map parties = new HashMap<>(); + public static Map users = new HashMap<>(); + public static Map groups = new HashMap<>(); + public static Map groupMemberships = new HashMap<>(); private NgCollection() {} } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/categorization/CategoryConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/categorization/CategoryConversion.java index 57e5ecd67..2a2f39238 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/categorization/CategoryConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/categorization/CategoryConversion.java @@ -18,10 +18,13 @@ */ package com.arsdigita.portation.conversion.core.categorization; +import com.arsdigita.categorization.CategorizedCollection; +import com.arsdigita.kernel.ACSObject; import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.modules.core.categorization.Categorization; import com.arsdigita.portation.modules.core.categorization.Category; +import com.arsdigita.portation.modules.core.core.CcmObject; -import java.util.ArrayList; import java.util.List; /** @@ -31,32 +34,64 @@ import java.util.List; public class CategoryConversion { public static void convertAll() { - // Todo: - List trunkCategories = new ArrayList<>(); + List trunkCategories = com + .arsdigita.categorization.Category.getAllObjectCategories(); trunkCategories.forEach(Category::new); - setParentCategory(trunkCategories); + setAssociations(trunkCategories); } - private static void setParentCategory( + /** + * Sets associations. Needs to be separate, so that all categories have + * been converted before. Otherwise it will be complex to get parent. + * + * @param trunkCategories + */ + private static void setAssociations( List trunkCategories) { - Long id, parentId; Category category, parentCategory; for (com.arsdigita.categorization.Category trunkCategory : trunkCategories) { - id = trunkCategory.getID().longValue(); - parentId = trunkCategory.getDefaultParentCategory().getID() - .longValue(); + category = NgCollection.categories.get(trunkCategory.getID() + .longValue()); - category = NgCollection.categories.get(id); - parentCategory = NgCollection.categories.get(parentId); + // set parent associations + parentCategory = NgCollection.categories.get(trunkCategory + .getDefaultParentCategory().getID().longValue()); + setParentCategory(category, parentCategory); - if (category != null && parentCategory != null) { - category.setParentCategory(parentCategory); - parentCategory.addSubCategory(category); - } + // create categorizations only for category typed objects + CategorizedCollection categorizedCollection = trunkCategory + .getObjects(com.arsdigita.categorization.Category + .BASE_DATA_OBJECT_TYPE); + createCategorizations(category, categorizedCollection); + } + } + + private static void setParentCategory(Category category, Category + parentCategory) { + if (category != null && parentCategory != null) { + category.setParentCategory(parentCategory); + parentCategory.addSubCategory(category); + } + } + + private static void createCategorizations(Category category, + CategorizedCollection + categorizedObjects) { + while (categorizedObjects.next()) { + CcmObject categorizedObject = NgCollection.ccmObjects.get(( + (ACSObject) categorizedObjects.getDomainObject()) + .getID().longValue()); + // create categorizations + Categorization categorization = new Categorization(category, + categorizedObject); + + // set adverse associations + category.addObject(categorization); + categorizedObject.addCategory(categorization); } } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/security/GroupConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/security/GroupConversion.java new file mode 100644 index 000000000..596d4bc3a --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/security/GroupConversion.java @@ -0,0 +1,72 @@ +/* + * 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.security; + +import com.arsdigita.kernel.UserCollection; +import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.modules.core.security.Group; +import com.arsdigita.portation.modules.core.security.GroupMembership; +import com.arsdigita.portation.modules.core.security.User; + +import java.util.List; + +/** + * @author Tobias Osmers - * @version created the 6/29/16 + * @version created the 7/4/16 */ -public class CategorizationConversion { +public class UserConversion { + + public static void convertAll() { + List trunkUsers = com.arsdigita.kernel + .User.getAllObjectUsers(); + + trunkUsers.forEach(User::new); + } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/TaskConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/TaskConversion.java index 4cb2df542..1b7623ca6 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/TaskConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/TaskConversion.java @@ -23,7 +23,6 @@ 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.ArrayList; import java.util.List; /** @@ -33,32 +32,22 @@ import java.util.List; public class TaskConversion { public static void convertAll() { - // Todo: - List trunkTask = new ArrayList<>(); + List trunkTasks = + com.arsdigita.workflow.simple.Task.getAllObjectTasks(); - trunkTask.forEach(Task::new); - - setWorkflow(trunkTask); - } - - private static void setWorkflow(List - trunkTasks) { - long id, workflowId; Task task; Workflow workflow; for (com.arsdigita.workflow.simple.Task trunkTask : trunkTasks) { - id = trunkTask.getID().longValue(); - workflowId = trunkTask.getWorkflow().getID().longValue(); + task = new Task(trunkTask); + workflow = NgCollection.workflows.get( + trunkTask.getWorkflow().getID().longValue()); - task = NgCollection.tasks.get(id); - workflow = NgCollection.workflows.get(workflowId); - - if (task != null && workflow != null) { + // set associations + if (workflow != null) { task.setWorkflow(workflow); workflow.addTask(task); } } - } } diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java index d94cc9f6b..bc86f8ce3 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java @@ -30,7 +30,7 @@ public class WorkflowConversion { public static void convertAll() { List trunkWorkflows = - com.arsdigita.workflow.simple.Workflow.getObjectWorkflows(); + com.arsdigita.workflow.simple.Workflow.getAllObjectWorkflows(); trunkWorkflows.forEach(Workflow::new); } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Categorization.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Categorization.java index 746d6792d..4db37f82c 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Categorization.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Categorization.java @@ -34,13 +34,14 @@ import com.arsdigita.portation.modules.core.core.CcmObject; public class Categorization implements Identifiable { private long categorizationId; + private Category category; private CcmObject categorizedObject; + private boolean index; private long categoryOrder; private long objectOrder; - public Categorization(Category category, CcmObject categorizedObject) { this.categorizationId = NgCollection.categorizations.size() + 1; @@ -52,7 +53,6 @@ public class Categorization implements Identifiable { this.objectOrder = category.getObjects().size() + 1; NgCollection.categorizations.put(this.categorizationId, this); - } @@ -81,7 +81,7 @@ public class Categorization implements Identifiable { return categorizedObject; } - public void setCategorizedObject(CcmObject categorizedObject) { + public void setCategorizedObject(final CcmObject categorizedObject) { this.categorizedObject = categorizedObject; } @@ -89,7 +89,7 @@ public class Categorization implements Identifiable { return index; } - public void setIndex(boolean index) { + public void setIndex(final boolean index) { this.index = index; } @@ -97,7 +97,7 @@ public class Categorization implements Identifiable { return categoryOrder; } - public void setCategoryOrder(long categoryOrder) { + public void setCategoryOrder(final long categoryOrder) { this.categoryOrder = categoryOrder; } @@ -105,7 +105,7 @@ public class Categorization implements Identifiable { return objectOrder; } - public void setObjectOrder(long objectOrder) { + public void setObjectOrder(final long objectOrder) { this.objectOrder = objectOrder; } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java b/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java index edcfceeb7..2a433b039 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java @@ -21,6 +21,7 @@ package com.arsdigita.portation.modules.core.core; import com.arsdigita.kernel.ACSObject; import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Identifiable; +import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.modules.core.categorization.Categorization; import com.arsdigita.portation.modules.core.categorization.Category; import com.arsdigita.portation.modules.core.security.Permission; @@ -49,20 +50,24 @@ import java.util.UUID; public class CcmObject implements Identifiable { private long objectId; + private String uuid; private String displayName; + private List permissions; private List categories; public CcmObject(final ACSObject trunkObject) { this.objectId = trunkObject.getID().longValue(); + this.uuid = UUID.randomUUID().toString(); this.displayName = trunkObject.getDisplayName(); + this.permissions = new ArrayList<>(); this.categories = new ArrayList<>(); - //NgCollection.ccmObjects.put(this.objectId, this); + NgCollection.ccmObjects.put(this.objectId, this); } @Override diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/core/EmailAddress.java b/ccm-core/src/com/arsdigita/portation/modules/core/core/EmailAddress.java index d41f61a32..2f383253d 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/core/EmailAddress.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/core/EmailAddress.java @@ -28,13 +28,16 @@ import com.arsdigita.portation.Identifiable; public class EmailAddress implements Identifiable { private String address; + private boolean bouncing; private boolean verified; - public EmailAddress(final com.arsdigita.kernel.EmailAddress trunkEmailAddress) { + this.address = trunkEmailAddress.getEmailAddress(); + this.bouncing = trunkEmailAddress.isBouncing(); + this.verified = trunkEmailAddress.isVerified(); } @Override @@ -46,7 +49,7 @@ public class EmailAddress implements Identifiable { return address; } - public void setAddress(String address) { + public void setAddress(final String address) { this.address = address; } @@ -54,7 +57,7 @@ public class EmailAddress implements Identifiable { return bouncing; } - public void setBouncing(boolean bouncing) { + public void setBouncing(final boolean bouncing) { this.bouncing = bouncing; } @@ -62,7 +65,7 @@ public class EmailAddress implements Identifiable { return verified; } - public void setVerified(boolean verified) { + public void setVerified(final boolean verified) { this.verified = verified; } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/Group.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/Group.java index b8cc7ad2b..80b21e559 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/Group.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/Group.java @@ -20,6 +20,7 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Identifiable; +import com.arsdigita.portation.conversion.NgCollection; import java.util.HashSet; import java.util.Set; @@ -30,10 +31,14 @@ import java.util.Set; */ public class Group extends Party { - private Set memberships = new HashSet<>(); + private Set memberships; public Group(final com.arsdigita.kernel.Group trunkGroup) { super(trunkGroup); + + this.memberships = new HashSet<>(); + + NgCollection.groups.put(this.getPartyId(), this); } @Override @@ -45,7 +50,15 @@ public class Group extends Party { return memberships; } - public void setMemberships(Set memberships) { + public void setMemberships(final Set memberships) { this.memberships = memberships; } + + public void addMembership(final GroupMembership member) { + memberships.add(member); + } + + public void removeMembership(final GroupMembership member) { + memberships.remove(member); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembership.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembership.java index fe906a8dc..7fc429fab 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembership.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembership.java @@ -20,6 +20,7 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Identifiable; +import com.arsdigita.portation.conversion.NgCollection; /** * @author (); + + NgCollection.users.put(this.getPartyId(), this); } @Override @@ -54,7 +80,7 @@ public class User extends Party { return givenName; } - public void setGivenName(String givenName) { + public void setGivenName(final String givenName) { this.givenName = givenName; } @@ -62,7 +88,7 @@ public class User extends Party { return familyName; } - public void setFamilyName(String familyName) { + public void setFamilyName(final String familyName) { this.familyName = familyName; } @@ -70,7 +96,7 @@ public class User extends Party { return primaryEmailAddress; } - public void setPrimaryEmailAddress(EmailAddress primaryEmailAddress) { + public void setPrimaryEmailAddress(final EmailAddress primaryEmailAddress) { this.primaryEmailAddress = primaryEmailAddress; } @@ -78,15 +104,23 @@ public class User extends Party { return emailAddresses; } - public void setEmailAddresses(List emailAddresses) { + public void setEmailAddresses(final List emailAddresses) { this.emailAddresses = emailAddresses; } + public void addEmailAddress(final EmailAddress emailAddress) { + emailAddresses.add(emailAddress); + } + + public void removeEmailAddress(final EmailAddress emailAddress) { + emailAddresses.remove(emailAddress); + } + public boolean isBanned() { return banned; } - public void setBanned(boolean banned) { + public void setBanned(final boolean banned) { this.banned = banned; } @@ -94,7 +128,7 @@ public class User extends Party { return password; } - public void setPassword(String password) { + public void setPassword(final String password) { this.password = password; } @@ -102,7 +136,7 @@ public class User extends Party { return passwordResetRequired; } - public void setPasswordResetRequired(boolean passwordResetRequired) { + public void setPasswordResetRequired(final boolean passwordResetRequired) { this.passwordResetRequired = passwordResetRequired; } @@ -110,7 +144,16 @@ public class User extends Party { return groupMemberships; } - public void setGroupMemberships(Set groupMemberships) { + public void setGroupMemberships(final Set + groupMemberships) { this.groupMemberships = groupMemberships; } + + public void addGroupMembership(final GroupMembership groupMembership) { + groupMemberships.add(groupMembership); + } + + public void removeGroupMembership(final GroupMembership groupMembership) { + groupMemberships.remove(groupMembership); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignment.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignment.java index 391128605..fdaaf416d 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignment.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignment.java @@ -45,7 +45,7 @@ public class TaskAssignment implements Identifiable { return taskAssignmentId; } - public void setTaskAssignmentId(long taskAssignmentId) { + public void setTaskAssignmentId(final long taskAssignmentId) { this.taskAssignmentId = taskAssignmentId; } @@ -53,7 +53,7 @@ public class TaskAssignment implements Identifiable { return task; } - public void setTask(UserTask task) { + public void setTask(final UserTask task) { this.task = task; } @@ -61,7 +61,7 @@ public class TaskAssignment implements Identifiable { return role; } - public void setRole(Role role) { + public void setRole(final Role role) { this.role = role; } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/UserTask.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/UserTask.java index ac40a801f..34d04246d 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/UserTask.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/UserTask.java @@ -54,7 +54,7 @@ public class UserTask extends Task { return locked; } - public void setLocked(boolean locked) { + public void setLocked(final boolean locked) { this.locked = locked; } @@ -62,7 +62,7 @@ public class UserTask extends Task { return lockingUser; } - public void setLockingUser(User lockingUser) { + public void setLockingUser(final User lockingUser) { this.lockingUser = lockingUser; } @@ -70,7 +70,7 @@ public class UserTask extends Task { return startDate; } - public void setStartDate(Date startDate) { + public void setStartDate(final Date startDate) { this.startDate = startDate; } @@ -78,7 +78,7 @@ public class UserTask extends Task { return dueDate; } - public void setDueDate(Date dueDate) { + public void setDueDate(final Date dueDate) { this.dueDate = dueDate; } @@ -86,7 +86,7 @@ public class UserTask extends Task { return durationMinutes; } - public void setDurationMinutes(long durationMinutes) { + public void setDurationMinutes(final long durationMinutes) { this.durationMinutes = durationMinutes; } @@ -94,7 +94,7 @@ public class UserTask extends Task { return notificationSender; } - public void setNotificationSender(User notificationSender) { + public void setNotificationSender(final User notificationSender) { this.notificationSender = notificationSender; } @@ -102,7 +102,15 @@ public class UserTask extends Task { return assignments; } - public void setAssignments(List assignments) { + public void setAssignments(final List assignments) { this.assignments = assignments; } + + public void addAssignment(final TaskAssignment assignment) { + assignments.add(assignment); + } + + public void removeAssignment(final TaskAssignment assignment) { + assignments.remove(assignment); + } } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Workflow.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Workflow.java index 4c1165402..354d0a137 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Workflow.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Workflow.java @@ -34,14 +34,18 @@ import java.util.Locale; public class Workflow implements Identifiable { private long workflowId; + private LocalizedString name; private LocalizedString description; + private List tasks; public Workflow(final com.arsdigita.workflow.simple.Workflow trunkWorkFlow) { this.workflowId = trunkWorkFlow.getID().longValue(); + this.name.addValue(Locale.ENGLISH, trunkWorkFlow.getDisplayName()); this.description.addValue(Locale.ENGLISH, trunkWorkFlow.getDescription()); + this.tasks = new ArrayList<>(); NgCollection.workflows.put(this.workflowId, this); diff --git a/ccm-core/src/com/arsdigita/workflow/simple/Task.java b/ccm-core/src/com/arsdigita/workflow/simple/Task.java index fb0b2ccce..6565ebd37 100755 --- a/ccm-core/src/com/arsdigita/workflow/simple/Task.java +++ b/ccm-core/src/com/arsdigita/workflow/simple/Task.java @@ -20,6 +20,7 @@ package com.arsdigita.workflow.simple; import com.arsdigita.auditing.AuditedACSObject; import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.domain.DomainCollection; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.kernel.User; import com.arsdigita.persistence.DataAssociation; @@ -27,17 +28,18 @@ import com.arsdigita.persistence.DataAssociationCursor; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.OID; +import com.arsdigita.persistence.Session; import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.metadata.ObjectType; import com.arsdigita.util.UncheckedWrapperException; +import org.apache.log4j.Logger; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; - -import org.apache.log4j.Logger; +import java.util.List; /** * This class represents the properties of a Task. @@ -1187,4 +1189,27 @@ public class Task extends AuditedACSObject implements Cloneable { 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 getAllObjectTasks() { + List 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; + } } diff --git a/ccm-core/src/com/arsdigita/workflow/simple/Workflow.java b/ccm-core/src/com/arsdigita/workflow/simple/Workflow.java index 91aa217d7..eb7cba937 100755 --- a/ccm-core/src/com/arsdigita/workflow/simple/Workflow.java +++ b/ccm-core/src/com/arsdigita/workflow/simple/Workflow.java @@ -861,7 +861,13 @@ public class Workflow extends Task { return getObjectWorkflow(o.getID()); } - public static List getObjectWorkflows() { + /** + * 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 getAllObjectWorkflows() { List workflowList = new ArrayList<>(); final Session session = SessionManager.getSession();