Author: julien(a)jboss.com
Date: 2007-12-27 17:00:40 -0500 (Thu, 27 Dec 2007)
New Revision: 9398
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/AssociationContext.java
Log:
abstrac the owner from the one2many and many2one associations
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/AssociationContext.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/AssociationContext.java 2007-12-27
21:51:58 UTC (rev 9397)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/AssociationContext.java 2007-12-27
22:00:40 UTC (rev 9398)
@@ -49,6 +49,10 @@
{
return
owner.container.structuralStateContext.loadParent(owner.structuralObject);
}
+ protected ObjectContext getOwner()
+ {
+ return owner;
+ }
};
/** . */
@@ -58,9 +62,13 @@
{
return
owner.container.structuralStateContext.loadChildren(owner.structuralObject);
}
+ protected ObjectContext getOwner()
+ {
+ return owner;
+ }
};
- abstract class ManyToOne
+ static abstract class ManyToOne
{
/** . */
@@ -88,6 +96,14 @@
{
throw new IllegalStateException("Cannot set parent of non loaded
association");
}
+
+ // Update the related side
+ if (related != null)
+ {
+
+ }
+
+ //
if (newParent != null)
{
related = newParent;
@@ -126,6 +142,8 @@
*/
protected abstract StructuralObject doLoad() throws StateException;
+ protected abstract ObjectContext getOwner();
+
/**
* Attempt for loading the related side. If a failure occurs during while loading
the related side
* the load operation is aborted and the status of the association owner is updated
accordingly. If the loading
@@ -133,6 +151,9 @@
*/
private void load()
{
+ ObjectContext owner = getOwner();
+
+ //
try
{
StructuralObject relatedSO = doLoad();
@@ -179,6 +200,9 @@
UIContainerObject getRelated()
{
+ ObjectContext owner = getOwner();
+
+ //
owner.checkAccess();
//
@@ -195,7 +219,7 @@
}
}
- abstract class OneToMany
+ static abstract class OneToMany
{
/** . */
@@ -284,8 +308,13 @@
*/
protected abstract List<StructuralObject> doLoad() throws StateException;
+ protected abstract ObjectContext getOwner();
+
private void load()
{
+ ObjectContext owner = getOwner();
+
+ //
try
{
ArrayList<UIContainerObject> relateds = new
ArrayList<UIContainerObject>();
@@ -332,6 +361,9 @@
{
public UIContainerObject get(int i)
{
+ ObjectContext owner = getOwner();
+
+ //
owner.checkAccess();
// Load the entire relationship
@@ -349,6 +381,9 @@
public int size()
{
+ ObjectContext owner = getOwner();
+
+ //
owner.checkAccess();
//
@@ -366,7 +401,7 @@
public String toString()
{
- return "ProxyList[" + owner + "]";
+ return "ProxyList[" + getOwner() + "]";
}
}
}
Show replies by date