[exo-jcr-commits] exo-jcr SVN: r1282 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation: db and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jan 4 12:14:19 EST 2010


Author: sergiykarpenko
Date: 2010-01-04 12:14:19 -0500 (Mon, 04 Jan 2010)
New Revision: 1282

Modified:
   jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
   jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
   jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-302: getReferenceProperties added

Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java	2010-01-04 16:03:31 UTC (rev 1281)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java	2010-01-04 17:14:19 UTC (rev 1282)
@@ -34,6 +34,8 @@
 import org.exoplatform.services.jcr.impl.storage.jdbc.PrimaryTypeNotFoundException;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
 
 import java.io.File;
 import java.io.IOException;
@@ -59,6 +61,11 @@
 {
 
    /**
+    * Connection logger.
+    */
+   protected static final Log LOG = ExoLogger.getLogger("jcr.optimisation.CQJDBCStorageConnection");
+
+   /**
     * FIND_NODES_BY_PARENTID NEW.
     */
    protected String FIND_NODES_BY_PARENTID_CQ;
@@ -73,6 +80,8 @@
     */
    protected String FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ;
 
+   protected String FIND_REFERENCE_PROPERTIES;
+
    /**
     * Class needed to store node details (property also) since result set is not sorted in valid way. 
     */
@@ -209,6 +218,33 @@
       }
    }
 
+   /**
+    * {@inheritDoc}
+    */
+   public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException, IllegalStateException
+   {
+      checkIfOpened();
+      try
+      {
+         ResultSet refProps = findReferencePropertiesCQ(getInternalId(nodeIdentifier));
+         List<PropertyData> references = new ArrayList<PropertyData>();
+         while (refProps.next())
+         {
+            while (!refProps.isAfterLast())
+               references.add(loadPropertyRecord(refProps, null));
+         }
+         return references;
+      }
+      catch (SQLException e)
+      {
+         throw new RepositoryException(e);
+      }
+      catch (IOException e)
+      {
+         throw new RepositoryException(e);
+      }
+   }
+
    protected List<AccessControlEntry> readACLPermisions(String cid, Map<String, List<byte[]>> properties)
       throws SQLException, IllegalACLException
    {
@@ -460,16 +496,19 @@
          List<ValueData> data = new ArrayList<ValueData>();
          String identifier = getIdentifier(cid);
 
+         int orderNum = -1;
+
          do
          {
-            final int orderNum = resultSet.getInt(COLUMN_VORDERNUM);
+            orderNum = resultSet.getInt(COLUMN_VORDERNUM);
             final String storageId = resultSet.getString(COLUMN_VSTORAGE_DESC);
             ValueData vdata =
                resultSet.wasNull() ? readValueData(cid, orderNum, cversion, resultSet.getBinaryStream(COLUMN_VDATA))
                   : readValueData(identifier, orderNum, storageId);
             data.add(vdata);
          }
-         while (resultSet.next() && resultSet.getString(COLUMN_ID).equals(cid));
+         while (resultSet.next() && resultSet.getString(COLUMN_ID).equals(cid)
+            && (resultSet.getInt(COLUMN_VORDERNUM)) > orderNum);
 
          PersistedPropertyData pdata =
             new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion, cptype, cpmultivalued, data);
@@ -646,4 +685,6 @@
    protected abstract ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
 
    protected abstract ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
+
+   protected abstract ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException;
 }

Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java	2010-01-04 16:03:31 UTC (rev 1281)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java	2010-01-04 17:14:19 UTC (rev 1282)
@@ -67,7 +67,7 @@
 
    protected PreparedStatement findReferences;
 
-   protected PreparedStatement findReferenceProperties;
+   protected PreparedStatement findReferencePropertiesCQ;
 
    protected PreparedStatement findValuesByPropertyId;
 
@@ -187,6 +187,11 @@
          "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_MREF R, JCR_MITEM P"
             + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
 
+      FIND_REFERENCE_PROPERTIES =
+         "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
+            + " from JCR_MREF R, JCR_MITEM P, JCR_MVALUE V"
+            + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by P.ID, V.ORDER_NUM";
+
       FIND_VALUES_BY_PROPERTYID =
          "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? order by ORDER_NUM";
 
@@ -214,7 +219,7 @@
       // property may contain no values
       FIND_PROPERTIES_BY_PARENTID_CQ =
          "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
-            + " where I.I_CLASS=2 and I.PARENT_ID=? order by ID, ORDER_NUM";
+            + " where I.I_CLASS=2 and I.PARENT_ID=? order by I.ID, V.ORDER_NUM";
 
       INSERT_NODE =
          "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
@@ -632,4 +637,20 @@
       findNodeMainPropertiesByParentIdentifierCQ.setString(1, parentIdentifier);
       return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
    }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
+   {
+      if (findReferencePropertiesCQ == null)
+         findReferencePropertiesCQ = dbConnection.prepareStatement(FIND_REFERENCE_PROPERTIES);
+      else
+         findReferencePropertiesCQ.clearParameters();
+
+      findReferencePropertiesCQ.setString(1, nodeIdentifier);
+      return findReferencePropertiesCQ.executeQuery();
+   }
+
 }

Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java	2010-01-04 16:03:31 UTC (rev 1281)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java	2010-01-04 17:14:19 UTC (rev 1282)
@@ -65,6 +65,8 @@
 
    protected PreparedStatement findReferences;
 
+   protected PreparedStatement findReferencePropertiesCQ;
+
    protected PreparedStatement findValuesByPropertyId;
 
    protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
@@ -191,6 +193,11 @@
          "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_SREF R, JCR_SITEM P"
             + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
 
+      FIND_REFERENCE_PROPERTIES =
+         "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
+            + " from JCR_SREF R, JCR_SITEM P, JCR_SVALUE V"
+            + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by P.ID, V.ORDER_NUM";
+
       FIND_VALUES_BY_PROPERTYID =
          "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
 
@@ -647,4 +654,17 @@
       findNodeMainPropertiesByParentIdentifierCQ.setString(2, parentIdentifier);
       return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
    }
+
+   @Override
+   protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
+   {
+      if (findReferencePropertiesCQ == null)
+         findReferencePropertiesCQ = dbConnection.prepareStatement(FIND_REFERENCE_PROPERTIES);
+      else
+         findReferencePropertiesCQ.clearParameters();
+
+      findReferencePropertiesCQ.setString(1, nodeIdentifier);
+      findReferencePropertiesCQ.setString(2, containerName);
+      return findReferencePropertiesCQ.executeQuery();
+   }
 }



More information about the exo-jcr-commits mailing list