From portal-commits at lists.jboss.org Thu Dec 27 08:25:11 2007 Content-Type: multipart/mixed; boundary="===============5642696341847098672==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r9390 - in branches/presentation/presentation/src/main/org/jboss/portal/presentation: test/model and 1 other directory. Date: Thu, 27 Dec 2007 08:25:10 -0500 Message-ID: --===============5642696341847098672== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2007-12-27 08:25:10 -0500 (Thu, 27 Dec 2007) New Revision: 9390 Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentatio= n/impl/model/container/UIObjectContainer.java branches/presentation/presentation/src/main/org/jboss/portal/presentatio= n/test/model/ModelTestCase.java Log: more implementation of refresh operation Modified: branches/presentation/presentation/src/main/org/jboss/portal/pres= entation/impl/model/container/UIObjectContainer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/presentation/presentation/src/main/org/jboss/portal/presentati= on/impl/model/container/UIObjectContainer.java 2007-12-27 12:09:04 UTC (rev= 9389) +++ branches/presentation/presentation/src/main/org/jboss/portal/presentati= on/impl/model/container/UIObjectContainer.java 2007-12-27 13:25:10 UTC (rev= 9390) @@ -31,6 +31,7 @@ import org.jboss.portal.presentation.model.state.structural.StructuralStat= eContext; import org.jboss.portal.presentation.model.state.NoSuchStateException; import org.jboss.portal.presentation.model.state.StateException; +import org.jboss.portal.common.NotYetImplemented; = import java.util.ArrayList; import java.util.HashMap; @@ -38,8 +39,6 @@ import java.util.Map; import java.util.AbstractList; import java.util.Iterator; -import java.util.Set; -import java.util.HashSet; = /** * @author Sohil Shah @@ -419,50 +418,91 @@ // Update the structural state if (!context.structuralObject.compareTo(refresh.getObjec= t())) { - context.structuralObject =3D refresh.getObject(); - } + boolean loaded =3D context.children.relateds !=3D nul= l; = - // - boolean loaded =3D context.children.relateds !=3D null; + // + if (loaded) + { + boolean refreshChildren =3D scope.enterChildren(ob= ject, loaded); = - // - if (loaded) - { - boolean refreshChildren =3D scope.enterChildren(objec= t, loaded); + // The new list of children + List children =3D new ArrayList= (); = - // Removals - for (String removedId : refresh.getRemovedChildren()) - { - } + // Take care of the added children + for (StructuralObject addedSO : refresh.getAddedCh= ildren()) + { + UIContainerObject added =3D get(addedSO); = + // + if (added !=3D null) + { + UIObjectContext addedContext =3D added.getCo= ntext(); = - // Compute set of added ids -// Set addedIds =3D new HashSet(); -// for (StructuralObject addedSO : refresh.getAddedChi= ldren()) -// { -// addedIds.add(addedSO.getId()); -// } + // Set the parent as stale if needed + if (addedContext.parent.loaded) + { + UIObjectContext addedParentContext =3D ad= dedContext.parent.related.getContext(); = - List children =3D new ArrayList(); + // Mark the parent as stale + addedParentContext.status =3D UIObject.St= atus.STALE; = - // - for (StructuralObject addedSO : refresh.getAddedChild= ren()) - { - } + // + addedParentContext.parent.related =3D get= (context.structuralObject.getId()); + } + } + else + { + added =3D create(addedSO); = - // - for (String validId : refresh.getValidChildren()) - { - } + // + put(added); + } = + // + children.add(added); + } = - // - for (StructuralObject staleSO : refresh.getStaleChild= ren().values()) - { + // + for (String validId : refresh.getValidChildren()) + { + UIContainerObject valid =3D get(validId); + + // It must be here... + children.add(valid); + } + + + // + for (StructuralObject staleSO : refresh.getStaleCh= ildren().values()) + { + UIContainerObject stale =3D get(staleSO); + + // Mark as stale + stale.getContext().status =3D UIObject.Status.S= TALE; + + // + children.add(stale); + } + + // Removals + for (String removedId : refresh.getRemovedChildren= ()) + { + UIContainerObject removed =3D get(removedId); + + // + if (removed !=3D null) + { + // We should try to now if it is somehow ref= erenced by someone that is not us + // i.e it has been already be moved somewher= e else + throw new NotYetImplemented(); + } + } + + // Update state + context.structuralObject =3D refresh.getObject(); + context.status =3D UIObject.Status.VALID; + context.children.relateds =3D children; } - - // Update to valid - context.status =3D UIObject.Status.VALID; } } catch (NoSuchStateException e) Modified: branches/presentation/presentation/src/main/org/jboss/portal/pres= entation/test/model/ModelTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/presentation/presentation/src/main/org/jboss/portal/presentati= on/test/model/ModelTestCase.java 2007-12-27 12:09:04 UTC (rev 9389) +++ branches/presentation/presentation/src/main/org/jboss/portal/presentati= on/test/model/ModelTestCase.java 2007-12-27 13:25:10 UTC (rev 9390) @@ -647,7 +647,38 @@ assertSame(context.getObject(daaId), daa); } = + public void testRefreshAfterConcurrentMove() throws Exception + { + MockObject mockRoot =3D model.getRoot(); = + MockObject mockFoo =3D mockRoot.addChild("foo", MockObject.Type.PORT= AL); + MockObject mockBar =3D mockRoot.addChild("bar", MockObject.Type.PORT= AL); + + MockObject mockFooJuu =3D mockFoo.addChild("juu", MockObject.Type.PA= GE); + MockObject mockFooDaa =3D mockFoo.addChild("daa", MockObject.Type.PA= GE); + + MockObject mockBarDaa =3D mockBar.addChild("daa", MockObject.Type.PA= GE); + + // Load fully the context 1 + UIContext context1 =3D createContext(); + loadDescendants(context1); + + // Concurrent move + UIContext context2 =3D createContext(); + context2.getChild("foo").getChild("juu").move(context2.getChild("bar= ")); + + // + context1.getChild("bar").refresh(); + } + + private void loadDescendants(UIObject object) + { + for (UIObject child : object.getChildren()) + { + loadDescendants(child); + } + } + public void testMove() throws Exception { MockObject mockRoot =3D model.getRoot(); --===============5642696341847098672==--