[FEATURE]

- bugfixes for object conversion from trunk to ng

git-svn-id: https://svn.libreccm.org/ccm/trunk@4309 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2016-09-19 16:52:45 +00:00
parent 89a47f4a8f
commit 33af4f199a
7 changed files with 64 additions and 28 deletions

View File

@ -23,6 +23,7 @@ import com.arsdigita.domain.DomainObjectInstantiator;
import com.arsdigita.domain.ReflectionInstantiator; import com.arsdigita.domain.ReflectionInstantiator;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.domain.DomainObject ; import com.arsdigita.domain.DomainObject ;
import com.arsdigita.persistence.metadata.ObjectType;
/** /**
* Defines the instantiator that should be * Defines the instantiator that should be
@ -123,7 +124,8 @@ public class ACSObjectInstantiator extends DomainObjectInstantiator {
* @see com.arsdigita.domain.DomainObjectFactory * @see com.arsdigita.domain.DomainObjectFactory
*/ */
public DomainObjectInstantiator resolveInstantiator(DataObject dataObject) { public DomainObjectInstantiator resolveInstantiator(DataObject dataObject) {
String type = (String) dataObject.get(ACSObject.OBJECT_TYPE); //String type = (String) dataObject.get(ACSObject.OBJECT_TYPE);
ObjectType type = dataObject.getObjectType();
dataObject.specialize(type); dataObject.specialize(type);
DomainObjectInstantiator instantiator = DomainObjectInstantiator instantiator =

View File

@ -517,6 +517,7 @@ public class Role extends DomainObject {
while (collection.next()) { while (collection.next()) {
Role role = (Role) collection.getDomainObject(); Role role = (Role) collection.getDomainObject();
if (role != null) { if (role != null) {
roleList.add(role); roleList.add(role);
} }

View File

@ -330,7 +330,7 @@ public class Permission extends DomainObject {
final Session session = SessionManager.getSession(); final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve( DomainCollection collection = new DomainCollection(session.retrieve(
Group.BASE_DATA_OBJECT_TYPE)); Permission.BASE_DATA_OBJECT_TYPE));
while (collection.next()) { while (collection.next()) {
Permission permission = (Permission) collection.getDomainObject(); Permission permission = (Permission) collection.getDomainObject();

View File

@ -76,23 +76,29 @@ public class UserTaskConversion {
UserTask userTask = new UserTask(trunkUserTask); UserTask userTask = new UserTask(trunkUserTask);
// set workflow and opposed associations // set workflow and opposed associations
Workflow workflow = NgCollection.workflows.get( if (trunkUserTask.getWorkflow() != null) {
trunkUserTask.getWorkflow().getID().longValue()); Workflow workflow = NgCollection.workflows.get(
if (workflow != null) { trunkUserTask.getWorkflow().getID().longValue());
userTask.setWorkflow(workflow); if (workflow != null) {
workflow.addTask(userTask); userTask.setWorkflow(workflow);
workflow.addTask(userTask);
}
} }
// set lockingUser and notificationSender // set lockingUser and notificationSender
User lockingUser = NgCollection.users.get(trunkUserTask if (trunkUserTask.getLockedUser() != null) {
.getLockedUser() User lockingUser = NgCollection.users.get(trunkUserTask
.getID().longValue()); .getLockedUser()
User notificationSender = NgCollection.users.get(trunkUserTask .getID().longValue());
.getNotificationSender().getID().longValue()); if (lockingUser != null)
if (lockingUser != null) userTask.setLockingUser(lockingUser);
userTask.setLockingUser(lockingUser); }
if (notificationSender != null) if (trunkUserTask.getNotificationSender() != null) {
userTask.setNotificationSender(notificationSender); User notificationSender = NgCollection.users.get(trunkUserTask
.getNotificationSender().getID().longValue());
if (notificationSender != null)
userTask.setNotificationSender(notificationSender);
}
// taskAssignments // taskAssignments
GroupCollection groupCollection = trunkUserTask GroupCollection groupCollection = trunkUserTask

View File

@ -71,23 +71,42 @@ public class Category extends CcmObject {
this.uniqueId = trunkCategory.getID().toString(); this.uniqueId = trunkCategory.getID().toString();
this.name = trunkCategory.getName(); 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 = CategoryLocalizationCollection categoryLocalizationCollection =
trunkCategory.getCategoryLocalizationCollection(); trunkCategory.getCategoryLocalizationCollection();
if (categoryLocalizationCollection != null && if (categoryLocalizationCollection != null &&
categoryLocalizationCollection.next()) { categoryLocalizationCollection.next()) {
CategoryLocalization categoryLocalization = CategoryLocalization categoryLocalization =
categoryLocalizationCollection.getCategoryLocalization(); categoryLocalizationCollection.getCategoryLocalization();
if (categoryLocalization != null) { if (categoryLocalization != null) {
String strLocale = categoryLocalization.getLocale(); Locale locale = new Locale(categoryLocalization.getLocale());
String name = categoryLocalization.getName(); this.title = new LocalizedString();
String description = categoryLocalization.getDescription(); this.title.addValue(locale, categoryLocalization.getName());
if (strLocale != null) { this.description = new LocalizedString();
Locale locale = new Locale(strLocale); this.description.addValue(locale, categoryLocalization.getDescription());
if (name != null)
this.title.addValue(locale, name);
if (description != null)
this.description.addValue(locale, description);
}
} }
} }
@ -108,6 +127,9 @@ public class Category extends CcmObject {
? defaultParent.getNumberOfChildCategories() + 1 ? defaultParent.getNumberOfChildCategories() + 1
: 0; : 0;
// to avoid infinite recursion
this.subCategoriesId = new ArrayList<>();
NgCollection.categories.put(this.getObjectId(), this); NgCollection.categories.put(this.getObjectId(), this);
} }

View File

@ -49,8 +49,11 @@ public class Task implements Identifiable {
public Task(final com.arsdigita.workflow.simple.Task trunkTask) { public Task(final com.arsdigita.workflow.simple.Task trunkTask) {
this.taskId = trunkTask.getID().longValue(); this.taskId = trunkTask.getID().longValue();
label.addValue(Locale.ENGLISH, trunkTask.getLabel());
description.addValue(Locale.ENGLISH, trunkTask.getDescription()); this.label = new LocalizedString();
this.label.addValue(Locale.ENGLISH, trunkTask.getLabel());
this.description = new LocalizedString();
this.description.addValue(Locale.ENGLISH, trunkTask.getDescription());
this.active = trunkTask.isActive(); this.active = trunkTask.isActive();
this.taskState = trunkTask.getStateString(); this.taskState = trunkTask.getStateString();

View File

@ -43,7 +43,9 @@ public class Workflow implements Identifiable {
public Workflow(final com.arsdigita.workflow.simple.Workflow trunkWorkFlow) { public Workflow(final com.arsdigita.workflow.simple.Workflow trunkWorkFlow) {
this.workflowId = trunkWorkFlow.getID().longValue(); this.workflowId = trunkWorkFlow.getID().longValue();
this.name = new LocalizedString();
this.name.addValue(Locale.ENGLISH, trunkWorkFlow.getDisplayName()); this.name.addValue(Locale.ENGLISH, trunkWorkFlow.getDisplayName());
this.description = new LocalizedString();
this.description.addValue(Locale.ENGLISH, trunkWorkFlow.getDescription()); this.description.addValue(Locale.ENGLISH, trunkWorkFlow.getDescription());
this.tasks = new ArrayList<>(); this.tasks = new ArrayList<>();