The nodes for the ApplicationsTree are no longer storing instances of com.arsdigita.web.ApplicationType or com.arsdigita.web.Application to avoid problems with PDLs transaction management and threads.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2282 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-08-01 10:45:42 +00:00
parent 722a74ce2f
commit 8bbcac1977
3 changed files with 91 additions and 20 deletions

View File

@ -39,7 +39,10 @@ public class ApplicationInstanceTreeNode implements TreeNode {
/**
* The application instance represented by this {@code TreeNode}
*/
private final Application application;
//private final Application application;
private String path;
private String title;
private String appType;
/**
* Constructor
@ -47,7 +50,22 @@ public class ApplicationInstanceTreeNode implements TreeNode {
* @param application The application instance to represent by this {@code TreeNode}
*/
public ApplicationInstanceTreeNode(final Application application) {
this.application = application;
//this.application = application;
path = application.getPath();
title = application.getTitle();
appType = application.getApplicationType().getApplicationObjectType();
}
public String getPath() {
return path;
}
public String getTitle() {
return title;
}
public String getAppType() {
return appType;
}
/**
@ -57,7 +75,8 @@ public class ApplicationInstanceTreeNode implements TreeNode {
* @see TreeNode#getKey()
*/
public Object getKey() {
return application.getPath();
//return application.getPath();
return path;
}
/**
@ -67,7 +86,8 @@ public class ApplicationInstanceTreeNode implements TreeNode {
* @see TreeNode#getElement()
*/
public Object getElement() {
return application.getTitle();
//return application.getTitle();
return title;
}
}

View File

@ -51,10 +51,13 @@ public class ApplicationTreeModel implements TreeModel {
} else if (node instanceof ApplicationTypeTreeNode) {
final ApplicationTypeTreeNode typeTreeNode = (ApplicationTypeTreeNode) node;
if (typeTreeNode.getApplicationType().isSingleton()) {
//if (typeTreeNode.getApplicationType().isSingleton()) {
if (typeTreeNode.isSingleton()) {
return false;
} else {
return !retrieveApplicationInstances(typeTreeNode.getApplicationType()).isEmpty();
//return !retrieveApplicationInstances(typeTreeNode.getApplicationType()).isEmpty();
//return !retrieveApplicationInstances(typeTreeNode.getApplicationType()).isEmpty();
return !retrieveApplicationInstances(typeTreeNode.getObjecType()).isEmpty();
}
} else if (node instanceof ApplicationInstanceTreeNode) {
return false;
@ -73,10 +76,11 @@ public class ApplicationTreeModel implements TreeModel {
return new AppTypesIterator(appTypes);
} else if (node instanceof ApplicationTypeTreeNode) {
final ApplicationTypeTreeNode typeTreeNode = (ApplicationTypeTreeNode) node;
final ApplicationType appType = typeTreeNode.getApplicationType();
//final ApplicationType appType = typeTreeNode.getApplicationType();
final ApplicationCollection applications = Application.retrieveAllApplications(
appType.getApplicationObjectType());
//final ApplicationCollection applications = Application.retrieveAllApplications(
// appType.getApplicationObjectType());
final ApplicationCollection applications = Application.retrieveAllApplications(typeTreeNode.getObjecType());
applications.addOrder("title");
return new AppIterator(applications);
@ -88,13 +92,20 @@ public class ApplicationTreeModel implements TreeModel {
+ "ApplicationInstanceTreeNodes.");
}
}
private ApplicationCollection retrieveApplicationInstances(final ApplicationType applicationType) {
final ApplicationCollection applications = Application.retrieveAllApplications();
applications.addEqualsFilter("objectType", applicationType.getApplicationObjectType());
return applications;
}
private ApplicationCollection retrieveApplicationInstances(final String appObjectType) {
final ApplicationCollection applications = Application.retrieveAllApplications();
applications.addEqualsFilter("objectType", appObjectType);
return applications;
}
private class RootTreeNode implements TreeNode {

View File

@ -20,32 +20,72 @@ package com.arsdigita.ui.admin.applications.tree;
import com.arsdigita.bebop.tree.TreeNode;
import com.arsdigita.web.ApplicationType;
import java.math.BigDecimal;
/**
* Tree Node implementation for the Application Tree in the Application
* admin tab.
*
* Tree Node implementation for the Application Tree in the Application admin tab.
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class ApplicationTypeTreeNode implements TreeNode {
private final ApplicationType applicationType;
//private final ApplicationType applicationType;
private final BigDecimal appTypeId;
private final String name;
private final String title;
private final String objectType;
private final boolean singleton;
private final String description;
// Needed:
// isSingleton
// getObjectType
public ApplicationTypeTreeNode(final ApplicationType applicationType) {
this.applicationType = applicationType;
//this.applicationType = applicationType;
appTypeId = applicationType.getID();
name = applicationType.getName();
title = applicationType.getTitle();
objectType = applicationType.getApplicationObjectType();
singleton = applicationType.isSingleton();
description = applicationType.getDescription();
}
public ApplicationType getApplicationType() {
return applicationType;
//public ApplicationType getApplicationType() {
// return applicationType;
//}
public BigDecimal getAppTypeId() {
return appTypeId;
}
public String getName() {
return name;
}
public String getTitle() {
return title;
}
public String getObjecType() {
return objectType;
}
public boolean isSingleton() {
return singleton;
}
public String getDescription() {
return description;
}
public Object getKey() {
return applicationType.getApplicationObjectType();
//return applicationType.getApplicationObjectType();
return objectType;
}
public Object getElement() {
return applicationType.getTitle();
//return applicationType.getTitle();
return title;
}
}