adds converter for trunk class role and permission
git-svn-id: https://svn.libreccm.org/ccm/trunk@4197 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
35a47857e0
commit
d8c9a0eda8
|
|
@ -20,6 +20,7 @@ package com.arsdigita.kernel;
|
|||
|
||||
import com.arsdigita.db.Sequences;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.kernel.permissions.PermissionDescriptor;
|
||||
import com.arsdigita.kernel.permissions.PermissionService;
|
||||
|
|
@ -27,9 +28,13 @@ import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
|||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.PersistenceException;
|
||||
import com.arsdigita.persistence.Session;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -497,4 +502,28 @@ public class Role extends DomainObject {
|
|||
return m_roleGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 roles
|
||||
*/
|
||||
public static List<Role> getAllObjectRoles() {
|
||||
List<Role> roleList = new ArrayList<>();
|
||||
|
||||
final Session session = SessionManager.getSession();
|
||||
DomainCollection collection = new DomainCollection(session.retrieve(
|
||||
Role.BASE_DATA_OBJECT_TYPE));
|
||||
|
||||
while (collection.next()) {
|
||||
Role role = (Role) collection.getDomainObject();
|
||||
if (role != null) {
|
||||
roleList.add(role);
|
||||
}
|
||||
}
|
||||
|
||||
collection.close();
|
||||
return roleList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@
|
|||
package com.arsdigita.kernel.permissions;
|
||||
|
||||
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.kernel.Group;
|
||||
import com.arsdigita.persistence.Session;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.web.Web;
|
||||
|
||||
import com.arsdigita.kernel.ACSObject;
|
||||
|
|
@ -36,7 +40,9 @@ import com.arsdigita.persistence.OID;
|
|||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -59,6 +65,7 @@ public class Permission extends DomainObject {
|
|||
// The names of the attributes we use when creating permission
|
||||
// objects
|
||||
static final String OBJECT_ID = "objectId";
|
||||
static final String ID = "id";
|
||||
static final String PARTY_ID = "partyId";
|
||||
static final String PRIVILEGE = "privilege";
|
||||
|
||||
|
|
@ -69,7 +76,7 @@ public class Permission extends DomainObject {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
protected String getBaseDataObjectType() {
|
||||
public String getBaseDataObjectType() {
|
||||
return BASE_DATA_OBJECT_TYPE;
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +118,19 @@ public class Permission extends DomainObject {
|
|||
super(oid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the ID property.
|
||||
*
|
||||
* This is a convenience method that is roughly equivalent
|
||||
* to getOID().get("id"). In general, it should be used
|
||||
* instead of the getOID method to get any ACSObject's ID.
|
||||
*
|
||||
* @return the value of the ID property.
|
||||
*/
|
||||
public BigDecimal getID() {
|
||||
return (BigDecimal) get(ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>OID</code> of the <code>Party</code> that is
|
||||
* the grantee of the privilege associated with this
|
||||
|
|
@ -123,7 +143,7 @@ public class Permission extends DomainObject {
|
|||
* @see com.arsdigita.kernel.permissions.PrivilegeDescriptor
|
||||
* @see com.arsdigita.persistence.OID
|
||||
*/
|
||||
OID getPartyOID() {
|
||||
public OID getPartyOID() {
|
||||
return new OID(Party.BASE_DATA_OBJECT_TYPE, get(PARTY_ID));
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +161,7 @@ public class Permission extends DomainObject {
|
|||
* @see com.arsdigita.kernel.permissions.PrivilegeDescriptor
|
||||
* @see com.arsdigita.persistence.OID
|
||||
*/
|
||||
void setPartyOID(OID partyOID) {
|
||||
public void setPartyOID(OID partyOID) {
|
||||
set(PARTY_ID, partyOID.get("id"));
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +176,7 @@ public class Permission extends DomainObject {
|
|||
* @see com.arsdigita.kernel.permissions.PrivilegeDescriptor
|
||||
* @see com.arsdigita.persistence.OID
|
||||
*/
|
||||
OID getACSObject() {
|
||||
public OID getACSObject() {
|
||||
return new OID("com.arsdigita.kernel.ACSObject", get(OBJECT_ID));
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +193,7 @@ public class Permission extends DomainObject {
|
|||
* @see com.arsdigita.kernel.permissions.PrivilegeDescriptor
|
||||
* @see com.arsdigita.persistence.OID
|
||||
*/
|
||||
void setACSObjectOID(OID acsObjectOID) {
|
||||
public void setACSObjectOID(OID acsObjectOID) {
|
||||
set(OBJECT_ID, acsObjectOID.get("id"));
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +207,7 @@ public class Permission extends DomainObject {
|
|||
* @see com.arsdigita.kernel.permissions.PrivilegeDescriptor
|
||||
* @see com.arsdigita.persistence.OID
|
||||
*/
|
||||
PrivilegeDescriptor getPrivilege() {
|
||||
public PrivilegeDescriptor getPrivilege() {
|
||||
return PrivilegeDescriptor.get((String) get(PRIVILEGE));
|
||||
}
|
||||
|
||||
|
|
@ -203,14 +223,14 @@ public class Permission extends DomainObject {
|
|||
* @see com.arsdigita.kernel.permissions.PrivilegeDescriptor
|
||||
* @see com.arsdigita.persistence.OID
|
||||
*/
|
||||
void setPrivilege(PrivilegeDescriptor privilege) {
|
||||
public void setPrivilege(PrivilegeDescriptor privilege) {
|
||||
set(PRIVILEGE, privilege.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user who created the object (may be null)
|
||||
*/
|
||||
User getCreationUser() {
|
||||
public User getCreationUser() {
|
||||
Object o = get("creationUser");
|
||||
if (o == null) {
|
||||
return null;
|
||||
|
|
@ -221,14 +241,14 @@ public class Permission extends DomainObject {
|
|||
/**
|
||||
* Get the creation date
|
||||
*/
|
||||
Date getCreationDate() {
|
||||
public Date getCreationDate() {
|
||||
return (Date) get("creationDate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the creation IP address (may be null)
|
||||
*/
|
||||
String getCreationIP() {
|
||||
public String getCreationIP() {
|
||||
return (String) get("creationIP");
|
||||
}
|
||||
|
||||
|
|
@ -298,4 +318,28 @@ public class Permission extends DomainObject {
|
|||
set("creationDate", date);
|
||||
set("creationIP", ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 permissions
|
||||
*/
|
||||
public static List<Permission> getAllObjectPermissions() {
|
||||
List<Permission> permissionList = new ArrayList<>();
|
||||
|
||||
final Session session = SessionManager.getSession();
|
||||
DomainCollection collection = new DomainCollection(session.retrieve(
|
||||
Group.BASE_DATA_OBJECT_TYPE));
|
||||
|
||||
while (collection.next()) {
|
||||
Permission permission = (Permission) collection.getDomainObject();
|
||||
if (permission != null) {
|
||||
permissionList.add(permission);
|
||||
}
|
||||
}
|
||||
|
||||
collection.close();
|
||||
return permissionList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,12 @@ 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.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.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;
|
||||
|
||||
|
|
@ -51,5 +55,13 @@ public class NgCollection {
|
|||
public static Map<Long, Task> tasks = new HashMap<>();
|
||||
public static Map<Long, UserTask> userTasks = new HashMap<>();
|
||||
|
||||
public static Map<Long, Role> roles = new HashMap<>();
|
||||
public static Map<Long, RoleMembership> roleMemberships = new HashMap<>();
|
||||
|
||||
public static Map<Long, TaskAssignment> taskAssignments = new HashMap<>();
|
||||
|
||||
public static Map<Long, Permission> permissions = new HashMap<>();
|
||||
|
||||
|
||||
private NgCollection() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,17 +51,20 @@ public class CategoryConversion {
|
|||
*/
|
||||
private static void setAssociations(
|
||||
List<com.arsdigita.categorization.Category> trunkCategories) {
|
||||
Category category, parentCategory;
|
||||
|
||||
for (com.arsdigita.categorization.Category
|
||||
trunkCategory : trunkCategories) {
|
||||
category = NgCollection.categories.get(trunkCategory.getID()
|
||||
Category category = NgCollection.categories.get(trunkCategory
|
||||
.getID()
|
||||
.longValue());
|
||||
|
||||
// set parent associations
|
||||
parentCategory = NgCollection.categories.get(trunkCategory
|
||||
Category parentCategory = NgCollection.categories.get(trunkCategory
|
||||
.getDefaultParentCategory().getID().longValue());
|
||||
setParentCategory(category, parentCategory);
|
||||
if (category != null && parentCategory != null) {
|
||||
// set parent and opposed association
|
||||
category.setParentCategory(parentCategory);
|
||||
parentCategory.addSubCategory(category);
|
||||
}
|
||||
|
||||
// create categorizations only for category typed objects
|
||||
CategorizedCollection categorizedCollection = trunkCategory
|
||||
|
|
@ -71,30 +74,22 @@ public class CategoryConversion {
|
|||
}
|
||||
}
|
||||
|
||||
private static void setParentCategory(Category category, Category
|
||||
parentCategory) {
|
||||
if (category != null && parentCategory != null) {
|
||||
// set parent and opposed association
|
||||
category.setParentCategory(parentCategory);
|
||||
parentCategory.addSubCategory(category);
|
||||
}
|
||||
}
|
||||
|
||||
private static void createCategorizations(Category category,
|
||||
CategorizedCollection
|
||||
categorizedObjects) {
|
||||
CcmObject categorizedObject; Categorization categorization;
|
||||
|
||||
while (categorizedObjects.next()) {
|
||||
categorizedObject = NgCollection.ccmObjects.get(((ACSObject)
|
||||
CcmObject categorizedObject = NgCollection.ccmObjects.get(((ACSObject)
|
||||
categorizedObjects.getDomainObject()).getID().longValue());
|
||||
// create categorizations
|
||||
categorization = new Categorization(category,
|
||||
categorizedObject);
|
||||
|
||||
// set opposed associations
|
||||
category.addObject(categorization);
|
||||
categorizedObject.addCategory(categorization);
|
||||
if (category != null && categorizedObject != null) {
|
||||
// create categorizations
|
||||
Categorization categorization = new Categorization(category,
|
||||
categorizedObject);
|
||||
|
||||
// set opposed associations
|
||||
category.addObject(categorization);
|
||||
categorizedObject.addCategory(categorization);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ 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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -33,8 +34,16 @@ import java.util.List;
|
|||
public class GroupConversion {
|
||||
|
||||
public static void convertAll() {
|
||||
List<com.arsdigita.kernel.Group> trunkGroups = com.arsdigita.kernel
|
||||
.Group.getAllObjectGroups();
|
||||
List<com.arsdigita.kernel.Group> trunkGroups,
|
||||
roleGroups = new ArrayList<>();
|
||||
trunkGroups = com.arsdigita.kernel.Group.getAllObjectGroups();
|
||||
|
||||
List<com.arsdigita.kernel.Role> trunkRoles = com.arsdigita.kernel
|
||||
.Role.getAllObjectRoles();
|
||||
trunkRoles.forEach(role -> roleGroups.add(role.getGroup()));
|
||||
|
||||
// remove subgroups representing roles
|
||||
trunkGroups.removeAll(roleGroups);
|
||||
|
||||
// create groups
|
||||
trunkGroups.forEach(Group::new);
|
||||
|
|
@ -44,10 +53,9 @@ public class GroupConversion {
|
|||
|
||||
private static void setAssociations(
|
||||
List<com.arsdigita.kernel.Group> trunkGroups) {
|
||||
Group group;
|
||||
|
||||
for (com.arsdigita.kernel.Group trunkGroup : trunkGroups) {
|
||||
group = NgCollection.groups.get(trunkGroup.getID().longValue());
|
||||
Group group = NgCollection.groups.get(trunkGroup.getID()
|
||||
.longValue());
|
||||
|
||||
// create groupMemberships
|
||||
UserCollection userCollection = trunkGroup.getMemberUsers();
|
||||
|
|
@ -61,12 +69,14 @@ public class GroupConversion {
|
|||
User member = NgCollection.users.get(userCollection.getUser()
|
||||
.getID().longValue());
|
||||
|
||||
// create groupMemeberships
|
||||
GroupMembership groupMembership = new GroupMembership(group, member);
|
||||
if (group != null && member != null) {
|
||||
// create groupMemeberships
|
||||
GroupMembership groupMembership = new GroupMembership(group, member);
|
||||
|
||||
// set adverse associations
|
||||
group.addMembership(groupMembership);
|
||||
member.addGroupMembership(groupMembership);
|
||||
// set adverse associations
|
||||
group.addMembership(groupMembership);
|
||||
member.addGroupMembership(groupMembership);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.portation.conversion.NgCollection;
|
||||
import com.arsdigita.portation.modules.core.core.CcmObject;
|
||||
import com.arsdigita.portation.modules.core.security.Permission;
|
||||
import com.arsdigita.portation.modules.core.security.Role;
|
||||
import com.arsdigita.portation.modules.core.security.User;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created the 7/14/16
|
||||
*/
|
||||
public class PermissionConversion {
|
||||
|
||||
public static void convertAll() {
|
||||
List<com.arsdigita.kernel.permissions.Permission> trunkPermissions =
|
||||
com.arsdigita.kernel.permissions.Permission
|
||||
.getAllObjectPermissions();
|
||||
|
||||
createPermissionsAndSetAssociations(trunkPermissions);
|
||||
}
|
||||
|
||||
private static void createPermissionsAndSetAssociations(List<com
|
||||
.arsdigita.kernel.permissions.Permission> trunkPermissions) {
|
||||
for (com.arsdigita.kernel.permissions.Permission trunkPermission :
|
||||
trunkPermissions) {
|
||||
|
||||
// create Permissions
|
||||
Permission permission = new Permission(trunkPermission);
|
||||
|
||||
// set object and opposed associations
|
||||
CcmObject object = NgCollection.ccmObjects.get(((BigDecimal)
|
||||
trunkPermission.getACSObject().get("id")).longValue());
|
||||
if (object != null) {
|
||||
permission.setObject(object);
|
||||
object.addPermission(permission);
|
||||
}
|
||||
|
||||
// set grantee and opposed associations
|
||||
Role role = NgCollection.roles.get(0); //Todo: fix "0"
|
||||
if (role != null) {
|
||||
permission.setGrantee(role);
|
||||
role.addPermission(permission);
|
||||
}
|
||||
|
||||
// set creationUser
|
||||
User creationUser = NgCollection.users.get(trunkPermission
|
||||
.getCreationUser().getID().longValue());
|
||||
if (creationUser != null)
|
||||
permission.setCreationUser(creationUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.PartyCollection;
|
||||
import com.arsdigita.portation.conversion.NgCollection;
|
||||
import com.arsdigita.portation.modules.core.security.Party;
|
||||
import com.arsdigita.portation.modules.core.security.Role;
|
||||
import com.arsdigita.portation.modules.core.security.RoleMembership;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created the 7/4/16
|
||||
*/
|
||||
public class RoleConversion {
|
||||
|
||||
public static void convertAll() {
|
||||
List<com.arsdigita.kernel.Role> trunkRoles = com.arsdigita.kernel
|
||||
.Role.getAllObjectRoles();
|
||||
|
||||
// create roles
|
||||
trunkRoles.forEach(Role::new);
|
||||
|
||||
// set associations
|
||||
setAssociations(trunkRoles);
|
||||
}
|
||||
|
||||
private static void setAssociations(List<com.arsdigita.kernel.Role>
|
||||
trunkRoles) {
|
||||
for (com.arsdigita.kernel.Role trunkRole : trunkRoles) {
|
||||
Role role = NgCollection.roles.get(trunkRole.getID().longValue());
|
||||
|
||||
// create roleMemberships
|
||||
PartyCollection partyCollection = trunkRole.getContainedParties();
|
||||
createRoleMemberships(role, partyCollection);
|
||||
}
|
||||
}
|
||||
|
||||
private static void createRoleMemberships(Role role, PartyCollection
|
||||
partyCollection) {
|
||||
while (partyCollection.next()) {
|
||||
Party member = NgCollection.parties.get(partyCollection.getParty()
|
||||
.getID().longValue());
|
||||
|
||||
if (role != null && member != null) {
|
||||
// create roleMemberships
|
||||
RoleMembership roleMembership = new RoleMembership(role, member);
|
||||
|
||||
// set adverse associations
|
||||
role.addMembership(roleMembership);
|
||||
member.addRoleMembership(roleMembership);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
package com.arsdigita.portation.conversion.core.workflow;
|
||||
|
||||
|
||||
import com.arsdigita.kernel.UserCollection;
|
||||
import com.arsdigita.portation.conversion.NgCollection;
|
||||
import com.arsdigita.portation.modules.core.security.User;
|
||||
import com.arsdigita.portation.modules.core.workflow.UserTask;
|
||||
|
|
@ -38,24 +39,21 @@ public class UserTaskConversion {
|
|||
List<com.arsdigita.workflow.simple.UserTask> trunkUserTasks = com
|
||||
.arsdigita.workflow.simple.UserTask.getAllObjectUserTasks();
|
||||
|
||||
createUserTaskSetAssociations(trunkUserTasks);
|
||||
createUserTasksAndSetAssociations(trunkUserTasks);
|
||||
|
||||
setTaskDependencies(trunkUserTasks);
|
||||
setTaskRingDependencies(trunkUserTasks);
|
||||
}
|
||||
|
||||
private static void createUserTaskSetAssociations(List<com.arsdigita
|
||||
private static void createUserTasksAndSetAssociations(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);
|
||||
UserTask userTask = new UserTask(trunkUserTask);
|
||||
|
||||
// set workflow and opposed associations
|
||||
workflow = NgCollection.workflows.get(
|
||||
Workflow workflow = NgCollection.workflows.get(
|
||||
trunkUserTask.getWorkflow().getID().longValue());
|
||||
if (workflow != null) {
|
||||
userTask.setWorkflow(workflow);
|
||||
|
|
@ -63,18 +61,32 @@ public class UserTaskConversion {
|
|||
}
|
||||
|
||||
// set lockingUser and notificationSender
|
||||
lockingUser = NgCollection.users.get(trunkUserTask.getLockedUser()
|
||||
User lockingUser = NgCollection.users.get(trunkUserTask
|
||||
.getLockedUser()
|
||||
.getID().longValue());
|
||||
notificationSender = NgCollection.users.get(trunkUserTask
|
||||
User notificationSender = NgCollection.users.get(trunkUserTask
|
||||
.getNotificationSender().getID().longValue());
|
||||
if (lockingUser != null)
|
||||
userTask.setLockingUser(lockingUser);
|
||||
if (notificationSender != null)
|
||||
userTask.setNotificationSender(notificationSender);
|
||||
|
||||
// create taskAssignments
|
||||
UserCollection userCollection = trunkUserTask
|
||||
.getAssignedUserCollection();
|
||||
createTaskAssignments(userTask, userCollection);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setTaskDependencies(List<com.arsdigita.workflow
|
||||
private static void createTaskAssignments(UserTask userTask,
|
||||
UserCollection userCollection) {
|
||||
while (userCollection.next()) {
|
||||
// Role role = NgCollection.users.get(userCollection.getUser().getID
|
||||
// ().longValue()).getRoleMemberships().;
|
||||
}
|
||||
}
|
||||
|
||||
private static void setTaskRingDependencies(List<com.arsdigita.workflow
|
||||
.simple.UserTask> trunkUserTasks) {
|
||||
UserTask userTask, dependency;
|
||||
|
||||
|
|
@ -87,9 +99,12 @@ public class UserTaskConversion {
|
|||
while (it.hasNext()) {
|
||||
dependency = NgCollection.userTasks.get(((Task) it.next())
|
||||
.getID().longValue());
|
||||
// set dependencies and opposed
|
||||
userTask.addDependsOn(dependency);
|
||||
dependency.addDependentTask(userTask);
|
||||
|
||||
if (userTask != null && dependency != null) {
|
||||
// set dependencies and opposed
|
||||
userTask.addDependsOn(dependency);
|
||||
dependency.addDependentTask(userTask);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ public class Categorization implements Identifiable {
|
|||
private long categoryOrder;
|
||||
private long objectOrder;
|
||||
|
||||
public Categorization(Category category, CcmObject categorizedObject) {
|
||||
public Categorization(final Category category, final CcmObject
|
||||
categorizedObject) {
|
||||
this.categorizationId = NgCollection.categorizations.size() + 1;
|
||||
|
||||
this.category = category;
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ import com.arsdigita.portation.conversion.NgCollection;
|
|||
public class GroupMembership implements Identifiable {
|
||||
|
||||
private long membershipId;
|
||||
|
||||
private Group group;
|
||||
private User member;
|
||||
|
||||
public GroupMembership(Group group, User member) {
|
||||
public GroupMembership(final Group group, final User member) {
|
||||
this.membershipId = NgCollection.groupMemberships.size() + 1;
|
||||
|
||||
this.group = group;
|
||||
this.member = member;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 com.arsdigita.portation.modules.core.core.CcmObject;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -32,14 +33,26 @@ public class Permission implements Identifiable {
|
|||
|
||||
private long permissionId;
|
||||
private String grantedPrivilege;
|
||||
|
||||
private CcmObject object;
|
||||
private Role grantee;
|
||||
private User creationUser;
|
||||
|
||||
private Date creationDate;
|
||||
private String creationIp;
|
||||
|
||||
public Permission(final com.arsdigita.kernel.permissions.Permission permission) {
|
||||
public Permission(final com.arsdigita.kernel.permissions.Permission trunkPermission) {
|
||||
this.permissionId = trunkPermission.getID().longValue();
|
||||
this.grantedPrivilege = trunkPermission.getPrivilege().getName();
|
||||
|
||||
//this.object;
|
||||
//this.grantee;
|
||||
//this.creationUser
|
||||
|
||||
this.creationDate = trunkPermission.getCreationDate();
|
||||
this.creationIp = trunkPermission.getCreationIP();
|
||||
|
||||
NgCollection.permissions.put(this.permissionId, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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 com.arsdigita.portation.modules.core.workflow.TaskAssignment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -35,12 +36,22 @@ public class Role implements Identifiable {
|
|||
|
||||
private long roleId;
|
||||
private String name;
|
||||
private Set<RoleMembership> memberships = new HashSet<>();
|
||||
private List<Permission> permissions = new ArrayList<>();
|
||||
|
||||
private Set<RoleMembership> memberships;
|
||||
|
||||
private List<Permission> permissions;
|
||||
private List<TaskAssignment> assignedTasks;
|
||||
|
||||
public Role() {
|
||||
public Role(com.arsdigita.kernel.Role trunkRole) {
|
||||
this.roleId = trunkRole.getID().longValue();
|
||||
this.name = trunkRole.getName();
|
||||
|
||||
this.memberships = new HashSet<>();
|
||||
|
||||
this.permissions = new ArrayList<>();
|
||||
this.assignedTasks = new ArrayList<>();
|
||||
|
||||
NgCollection.roles.put(this.roleId, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -72,11 +83,11 @@ public class Role implements Identifiable {
|
|||
this.memberships = memberships;
|
||||
}
|
||||
|
||||
protected void addMembership(final RoleMembership membership) {
|
||||
public void addMembership(final RoleMembership membership) {
|
||||
memberships.add(membership);
|
||||
}
|
||||
|
||||
protected void removeMembership(final RoleMembership membership) {
|
||||
public void removeMembership(final RoleMembership membership) {
|
||||
memberships.remove(membership);
|
||||
}
|
||||
|
||||
|
|
@ -88,11 +99,11 @@ public class Role implements Identifiable {
|
|||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
protected void addPermission(final Permission permission) {
|
||||
public void addPermission(final Permission permission) {
|
||||
permissions.add(permission);
|
||||
}
|
||||
|
||||
protected void removePermission(final Permission permission) {
|
||||
public void removePermission(final Permission permission) {
|
||||
permissions.remove(permission);
|
||||
}
|
||||
|
||||
|
|
@ -104,11 +115,11 @@ public class Role implements Identifiable {
|
|||
this.assignedTasks = assignedTasks;
|
||||
}
|
||||
|
||||
protected void addAssignedTask(final TaskAssignment taskAssignment) {
|
||||
public void addAssignedTask(final TaskAssignment taskAssignment) {
|
||||
assignedTasks.add(taskAssignment);
|
||||
}
|
||||
|
||||
protected void removeAssignedTask(final TaskAssignment taskAssignment) {
|
||||
public void removeAssignedTask(final TaskAssignment taskAssignment) {
|
||||
assignedTasks.remove(taskAssignment);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
|
|
@ -28,11 +29,17 @@ import com.arsdigita.portation.Identifiable;
|
|||
public class RoleMembership implements Identifiable {
|
||||
|
||||
private long membershipId;
|
||||
|
||||
private Role role;
|
||||
private Party member;
|
||||
|
||||
public RoleMembership() {
|
||||
public RoleMembership(final Role role, final Party member) {
|
||||
this.membershipId = NgCollection.roleMemberships.size() + 1;
|
||||
|
||||
this.role = role;
|
||||
this.member = member;
|
||||
|
||||
NgCollection.roleMemberships.put(this.membershipId, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package com.arsdigita.portation.modules.core.workflow;
|
|||
|
||||
import com.arsdigita.portation.AbstractMarshaller;
|
||||
import com.arsdigita.portation.Identifiable;
|
||||
import com.arsdigita.portation.conversion.NgCollection;
|
||||
import com.arsdigita.portation.modules.core.security.Role;
|
||||
|
||||
/**
|
||||
|
|
@ -29,11 +30,17 @@ import com.arsdigita.portation.modules.core.security.Role;
|
|||
public class TaskAssignment implements Identifiable {
|
||||
|
||||
private long taskAssignmentId;
|
||||
|
||||
private UserTask task;
|
||||
private Role role;
|
||||
|
||||
public TaskAssignment() {
|
||||
public TaskAssignment(final UserTask task, final Role role) {
|
||||
this.taskAssignmentId = NgCollection.taskAssignments.size() + 1;
|
||||
|
||||
this.task = task;
|
||||
this.role = role;
|
||||
|
||||
NgCollection.taskAssignments.put(this.taskAssignmentId, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue