- bugfixes in conversion routine from trunk to ng

git-svn-id: https://svn.libreccm.org/ccm/trunk@4325 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2016-09-26 18:15:51 +00:00
parent 60ae856a4b
commit 6e6bed3468
5 changed files with 56 additions and 45 deletions

View File

@ -21,6 +21,7 @@ package com.arsdigita.kernel.permissions;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.kernel.Group;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.web.Web;
@ -329,15 +330,13 @@ public class Permission extends DomainObject {
List<Permission> permissionList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
Permission.BASE_DATA_OBJECT_TYPE));
DataCollection collection = session.retrieve(Permission
.BASE_DATA_OBJECT_TYPE);
while (collection.next()) {
Permission permission = (Permission) collection.getDomainObject();
if (permission != null) {
Permission permission = new Permission(collection.getDataObject());
permissionList.add(permission);
}
}
collection.close();
return permissionList;

View File

@ -98,7 +98,8 @@ public class CategoryConversion {
categorizedObject);
// set opposed associations
category.addObject(categorization);
//category.addObject(categorization); Todo
category.addObjectId(categorization.getCategorizationId());
categorizedObject.addCategory(categorization);
}
}
@ -135,7 +136,7 @@ public class CategoryConversion {
//category.setParentCategory(parentCategory);
//parentCategory.addSubCategory(category);
// to avoid infinite recursion
// to avoid infinite recursion Todo
category.setParentCategoryId(parentCategory.getUniqueId());
parentCategory.addSubCategoryId(category.getUniqueId());
}

View File

@ -86,12 +86,17 @@ public class PermissionConversion {
}
// set creationUser
User creationUser = NgCollection.users.get(trunkPermission
.getCreationUser().getID().longValue());
com.arsdigita.kernel.User trunkCreationUser = trunkPermission
.getCreationUser();
if (trunkCreationUser != null) {
User creationUser = NgCollection.users.get(trunkCreationUser
.getID().longValue());
if (creationUser != null)
permission.setCreationUser(creationUser);
}
}
}
/**
* Method recreating the association to class {@link Role} representing the

View File

@ -60,8 +60,9 @@ public class Category extends CcmObject {
private Category parentCategory;
private long categoryOrder;
// to avoid infinite recursion
private List<String> subCategoriesId;
// to avoid infinite recursion Todo
private List<Long> objectIds;
private List<String> subCategoryIds;
private String parentCategoryId;
@ -71,28 +72,6 @@ public class Category extends CcmObject {
this.uniqueId = trunkCategory.getID().toString();
this.name = trunkCategory.getName();
// CategoryLocalizationCollection categoryLocalizationCollection = trunkCategory.getCategoryLocalizationCollection();
//
// if (categoryLocalizationCollection != null && categoryLocalizationCollection.next()) {
//
// CategoryLocalization categoryLocalization = categoryLocalizationCollection.getCategoryLocalization();
//
// if (categoryLocalization != null) {
//
// String strLocale = categoryLocalization.getLocale();
// String name = categoryLocalization.getName();
// String description = categoryLocalization.getDescription();
//
// if (strLocale != null) {
// Locale locale = new Locale(strLocale);
// if (name != null)
// this.title.addValue(locale, name);
// if (description != null)
// this.description.addValue(locale, description);
// }
// }
// }
CategoryLocalizationCollection categoryLocalizationCollection =
trunkCategory.getCategoryLocalizationCollection();
@ -127,8 +106,12 @@ public class Category extends CcmObject {
? defaultParent.getNumberOfChildCategories() + 1
: 0;
// to avoid infinite recursion
this.subCategoriesId = new ArrayList<>();
// to avoid infinite recursion Todo
this.objectIds = new ArrayList<>();
this.subCategoryIds = new ArrayList<>();
//this.parantCategoryId
NgCollection.categories.put(this.getObjectId(), this);
}
@ -244,20 +227,37 @@ public class Category extends CcmObject {
}
public List<String> getSubCategoriesId() {
return subCategoriesId;
public List<Long> getObjectIds() {
return objectIds;
}
public void setSubCategoriesId(final List<String> subCategoriesId) {
this.subCategoriesId = subCategoriesId;
public void setObjectIds(final List<Long> objectIds) {
this.objectIds = objectIds;
}
public void addObjectId(final long object) {
this.objectIds.add(object);
}
public void removeObjectId(final long object) {
this.objectIds.remove(object);
}
public List<String> getSubCategoryIds() {
return subCategoryIds;
}
public void setSubCategoryIds(final List<String> subCategoryIds) {
this.subCategoryIds = subCategoryIds;
}
public void addSubCategoryId(final String subCategoryId) {
this.subCategoriesId.add(subCategoryId);
this.subCategoryIds.add(subCategoryId);
}
public void removeSubCategoryId(final String subCategoryId) {
this.subCategoriesId.remove(subCategoryId);
this.subCategoryIds.remove(subCategoryId);
}
public String getParentCategoryId() {

View File

@ -42,7 +42,7 @@ public class Permission implements Identifiable {
private String creationIp;
public Permission(final com.arsdigita.kernel.permissions.Permission trunkPermission) {
this.permissionId = trunkPermission.getID().longValue();
this.permissionId = NgCollection.permissions.size() + 1;
this.grantedPrivilege = trunkPermission.getPrivilege().getName();
//this.object;
@ -55,6 +55,12 @@ public class Permission implements Identifiable {
NgCollection.permissions.put(this.permissionId, this);
}
/**
* Constructor to copy a given Permission. Needed for purposes of
* creating permissions for multiple grantees from the trunk object.
*
* @param ngPermission The Permission to be copied.
*/
public Permission(final Permission ngPermission) {
this.permissionId = NgCollection.permissions.size() + 1;
this.grantedPrivilege = ngPermission.getGrantedPrivilege();