You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/11/21 16:57:10 UTC

svn commit: r719611 - in /portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java: JETSPEED-INF/ojb/registry_repository.xml org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java

Author: ate
Date: Fri Nov 21 07:57:09 2008
New Revision: 719611

URL: http://svn.apache.org/viewvc?rev=719611&view=rev
Log:
Fixing Description/DisplayName retrieval based on containing object.
This needs "discriminator" query filtering from the owner object side which I forgot to implement.
Now handled properly using a custom OJB QueryCustomizer

Added:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java   (with props)
Modified:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml?rev=719611&r1=719610&r2=719611&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml Fri Nov 21 07:57:09 2008
@@ -240,16 +240,28 @@
           auto-retrieve = "true"
       >
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
 
-    <collection-descriptor
+      <collection-descriptor
          name="displayNames"
          element-class-ref="org.apache.jetspeed.om.portlet.impl.DisplayNameImpl"
           auto-delete="true"
           auto-update = "true"
           auto-retrieve = "true"
       >
-          <inverse-foreignkey field-ref="ownerId"/>
+         <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
 
      <collection-descriptor
@@ -354,7 +366,13 @@
          auto-retrieve = "true"
          proxy="false"
       >
-          <inverse-foreignkey field-ref="ownerId"/>
+         <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
 
 
@@ -392,6 +410,12 @@
       >
 
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
 
 
@@ -416,7 +440,12 @@
          auto-retrieve = "true"
       >
          <inverse-foreignkey field-ref="ownerId"/>
-
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
 
 
@@ -574,6 +603,12 @@
           auto-retrieve = "true"
       >
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
 
       </collection-descriptor>
 
@@ -897,6 +932,12 @@
 
       >
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
 
       </collection-descriptor>
 
@@ -940,6 +981,12 @@
 
       >
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
       
    </class-descriptor>
@@ -989,6 +1036,12 @@
 
       >
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
       
    </class-descriptor>
@@ -1033,6 +1086,12 @@
 
       >
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
       
    </class-descriptor>
@@ -1084,6 +1143,12 @@
 
       >
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
       
    </class-descriptor>
@@ -1135,6 +1200,12 @@
 
       >
          <inverse-foreignkey field-ref="ownerId"/>
+         <query-customizer class="org.apache.jetspeed.util.ojb.CollectionOwnerClassDiscriminatorQueryCustomizer">
+            <attribute
+              attribute-name="discriminatorField"
+              attribute-value="owner"
+            />
+         </query-customizer>
       </collection-descriptor>
       
    </class-descriptor>

Added: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java?rev=719611&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java (added)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java Fri Nov 21 07:57:09 2008
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.util.ojb;
+
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.accesslayer.QueryCustomizerDefaultImpl;
+import org.apache.ojb.broker.metadata.CollectionDescriptor;
+import org.apache.ojb.broker.query.Query;
+import org.apache.ojb.broker.query.QueryByCriteria;
+
+/**
+ * @version $Id$
+ *
+ */
+public class CollectionOwnerClassDiscriminatorQueryCustomizer extends QueryCustomizerDefaultImpl
+{
+    private static final long serialVersionUID = -1933868940330442307L;
+    
+    private static final String DISCRIMINATOR_FIELD = "discriminatorField"; 
+
+    public Query customizeQuery(Object owner, PersistenceBroker broker, CollectionDescriptor collDescriptor, QueryByCriteria query)
+    {
+        String discriminatorField = this.getAttribute(DISCRIMINATOR_FIELD);
+        if (discriminatorField != null)
+        {
+            query.getCriteria().addEqualTo(discriminatorField, owner.getClass().getName());
+        }
+        return query;
+    }
+}

Propchange: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/util/ojb/CollectionOwnerClassDiscriminatorQueryCustomizer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org