[exo-jcr-commits] exo-jcr SVN: r796 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage: jdbc and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Nov 20 11:15:38 EST 2009


Author: sergiykarpenko
Date: 2009-11-20 11:15:37 -0500 (Fri, 20 Nov 2009)
New Revision: 796

Modified:
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
Log:
EXOJCR-246: JDBCCacheLoader reference support added

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java	2009-11-20 14:25:20 UTC (rev 795)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java	2009-11-20 16:15:37 UTC (rev 796)
@@ -21,11 +21,9 @@
 import org.exoplatform.services.jcr.datamodel.ItemData;
 import org.exoplatform.services.jcr.datamodel.NodeData;
 import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
 import org.exoplatform.services.jcr.datamodel.QPathEntry;
 import org.exoplatform.services.jcr.datamodel.ValueData;
 import org.exoplatform.services.jcr.impl.core.lock.LockData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
 import org.exoplatform.services.jcr.impl.dataflow.ValueDataConvertor;
 import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
 import org.exoplatform.services.log.ExoLogger;
@@ -349,13 +347,13 @@
             if (refParent != null)
             {
                refParent.removeChild(propUUID);
+               // check is there is no more references
+               if (refParent.getChildrenNames().size() == 0)
+               {
+                  //TODO remove children
+                  refsRoot.removeChild(makeNodeFqn(refNodeUUID));
+               }
             }
-            // check is there is no more references
-            if (refParent.getChildrenNames().size() == 0)
-            {
-               //TODO remove children
-               refsRoot.removeChild(makeNodeFqn(refNodeUUID));
-            }
          }
 
       }
@@ -673,88 +671,88 @@
    {
       //TODO we expecting that on session.move() there will be only one rename() method call
 
-//      startBatch();
-//
-//      String nodeId = data.getIdentifier();
-//
-//      //1. Update renamed node and also get old nodeData
-//      Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
-//      if (node == null)
-//      {
-//         throw new InvalidItemStateException("Renamed node is not exist" + data.getQPath().getAsString());
-//      }
-//
-//      NodeData prevData = (NodeData)node.put(ITEM_DATA, data);
-//      if (prevData == null)
-//      {
-//         throw new RepositoryException("FATAL NodeData is empty " + data.getQPath().getAsString());
-//      }
-//
-//      // 2. remove renamed node from child list of previous parent node
-//      // check if parent is cached
-//      Node<Serializable, Object> prevParent = nodesRoot.getChild(makeNodeFqn(prevData.getParentIdentifier()));
-//      if (prevParent == null)
-//      {
-//         throw new InvalidItemStateException("Node's previous parent doesn't exist "
-//            + prevData.getQPath().getAsString() + ". Node " + data.getQPath().getAsString());
-//      }
-//
-//      // remove node form old parent child list
-//      if (!prevParent
-//         .removeChild(makeChildNodeFqn(prevData.getQPath().getEntries()[prevData.getQPath().getEntries().length - 1])))
-//      {
-//         throw new RepositoryException("FATAL Node doesn't listed in children nodes of previous parent "
-//            + prevData.getQPath().getAsString() + ". Node " + data.getQPath().getAsString());
-//      }
-//
-//      // 3. add node to child list of new parent node
-//      // check if parent is cached
-//      Node<Serializable, Object> newParent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
-//      if (newParent == null)
-//      {
-//         throw new InvalidItemStateException("Node's new parent doesn't exist " + data.getParentIdentifier()
-//            + ". Node " + data.getQPath().getAsString());
-//      }
-//
-//      // add child to Parent 
-//      Node<Serializable, Object> childNode =
-//         newParent.addChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length - 1]));
-//
-//      // set child id attr 
-//      childNode.put(ITEM_ID, data.getIdentifier());
-//
-//      // 4. update all child nodes
-//      for (Node<Serializable, Object> child : node.getChildren())
-//      {
-//         String childNodeId = (String)child.get(ITEM_ID);
-//         if (childNodeId == null)
-//         {
-//            throw new RepositoryException("FATAL Child Node Id key is null. Parent " + data.getQPath().getAsString());
-//         }
-//
-//         // TODO NodeData or PropertyData? As ItemData check then and cast.
-//         Node<Serializable, Object> childnode = nodesRoot.getChild(makeNodeFqn(childNodeId)); //cache.evict(fqn)
-//         if (childnode == null)
-//         {
-//            throw new RepositoryException("FATAL Node record not found(" + childNodeId + "), but listed in childs of "
-//               + data.getQPath().getAsString());
-//         }
-//         NodeData nodeData = (NodeData)childnode.get(ITEM_DATA);
-//         if (nodeData == null)
-//         {
-//            // TODO should not occurs by contract
-//            throw new RepositoryException("Child node data is null. Parent " + data.getQPath().getAsString());
-//         }
-//
-//         //repack child NodeData with new QPath
-//         //TODO check it
-//         QPath newPath = QPath.makeChildPath(data.getQPath(), nodeData.getQPath().getName());
-//         TransientNodeData newNodeData =
-//            new TransientNodeData(newPath, nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
-//               .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
-//               .getParentIdentifier(), nodeData.getACL());
-//         childnode.put(ITEM_DATA, newNodeData);
-//      }
+      //      startBatch();
+      //
+      //      String nodeId = data.getIdentifier();
+      //
+      //      //1. Update renamed node and also get old nodeData
+      //      Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
+      //      if (node == null)
+      //      {
+      //         throw new InvalidItemStateException("Renamed node is not exist" + data.getQPath().getAsString());
+      //      }
+      //
+      //      NodeData prevData = (NodeData)node.put(ITEM_DATA, data);
+      //      if (prevData == null)
+      //      {
+      //         throw new RepositoryException("FATAL NodeData is empty " + data.getQPath().getAsString());
+      //      }
+      //
+      //      // 2. remove renamed node from child list of previous parent node
+      //      // check if parent is cached
+      //      Node<Serializable, Object> prevParent = nodesRoot.getChild(makeNodeFqn(prevData.getParentIdentifier()));
+      //      if (prevParent == null)
+      //      {
+      //         throw new InvalidItemStateException("Node's previous parent doesn't exist "
+      //            + prevData.getQPath().getAsString() + ". Node " + data.getQPath().getAsString());
+      //      }
+      //
+      //      // remove node form old parent child list
+      //      if (!prevParent
+      //         .removeChild(makeChildNodeFqn(prevData.getQPath().getEntries()[prevData.getQPath().getEntries().length - 1])))
+      //      {
+      //         throw new RepositoryException("FATAL Node doesn't listed in children nodes of previous parent "
+      //            + prevData.getQPath().getAsString() + ". Node " + data.getQPath().getAsString());
+      //      }
+      //
+      //      // 3. add node to child list of new parent node
+      //      // check if parent is cached
+      //      Node<Serializable, Object> newParent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
+      //      if (newParent == null)
+      //      {
+      //         throw new InvalidItemStateException("Node's new parent doesn't exist " + data.getParentIdentifier()
+      //            + ". Node " + data.getQPath().getAsString());
+      //      }
+      //
+      //      // add child to Parent 
+      //      Node<Serializable, Object> childNode =
+      //         newParent.addChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length - 1]));
+      //
+      //      // set child id attr 
+      //      childNode.put(ITEM_ID, data.getIdentifier());
+      //
+      //      // 4. update all child nodes
+      //      for (Node<Serializable, Object> child : node.getChildren())
+      //      {
+      //         String childNodeId = (String)child.get(ITEM_ID);
+      //         if (childNodeId == null)
+      //         {
+      //            throw new RepositoryException("FATAL Child Node Id key is null. Parent " + data.getQPath().getAsString());
+      //         }
+      //
+      //         // TODO NodeData or PropertyData? As ItemData check then and cast.
+      //         Node<Serializable, Object> childnode = nodesRoot.getChild(makeNodeFqn(childNodeId)); //cache.evict(fqn)
+      //         if (childnode == null)
+      //         {
+      //            throw new RepositoryException("FATAL Node record not found(" + childNodeId + "), but listed in childs of "
+      //               + data.getQPath().getAsString());
+      //         }
+      //         NodeData nodeData = (NodeData)childnode.get(ITEM_DATA);
+      //         if (nodeData == null)
+      //         {
+      //            // TODO should not occurs by contract
+      //            throw new RepositoryException("Child node data is null. Parent " + data.getQPath().getAsString());
+      //         }
+      //
+      //         //repack child NodeData with new QPath
+      //         //TODO check it
+      //         QPath newPath = QPath.makeChildPath(data.getQPath(), nodeData.getQPath().getName());
+      //         TransientNodeData newNodeData =
+      //            new TransientNodeData(newPath, nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
+      //               .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
+      //               .getParentIdentifier(), nodeData.getACL());
+      //         childnode.put(ITEM_DATA, newNodeData);
+      //      }
    }
 
    /**

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java	2009-11-20 14:25:20 UTC (rev 795)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java	2009-11-20 16:15:37 UTC (rev 796)
@@ -19,7 +19,6 @@
 package org.exoplatform.services.jcr.impl.storage.jbosscache;
 
 import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
 import org.exoplatform.services.jcr.datamodel.ItemData;
 import org.exoplatform.services.jcr.datamodel.NodeData;
 import org.exoplatform.services.jcr.datamodel.PropertyData;
@@ -108,6 +107,11 @@
          {
             case PUT_DATA :
                //LOG.warn("PUT_DATA modification");
+               // Process references
+               //               if (m.getFqn().get(0).equals(JBossCacheStorage.REFS))
+               //               {
+               //                  addReferences((JDBCStorageConnection)conn, m);
+               //               }
                break;
             case PUT_DATA_ERASE :
                LOG.warn("PUT_DATA_ERASE modification");
@@ -134,7 +138,14 @@
                break;
             case REMOVE_NODE :
 
+               //               if (m.getFqn().get(0).equals(JBossCacheStorage.REFS))
+               //               {
+               //                  removeReference((JDBCStorageConnection)conn, m);
+               //               }
+               //               else
+               //               {
                doRemove(m, (JDBCStorageConnection)conn);
+               //               }
 
                break;
             case MOVE :
@@ -362,14 +373,53 @@
                   LOG.warn("Unexpected Fqn asked " + name);
                }
             }
+            else if (name.get(0).equals(JBossCacheStorage.REFS))
+            {
+               // get reference
+               if (name.size() == 3)
+               {
+
+                  // do we have such property reference
+                  String nodeID = String.valueOf(name.get(1));
+                  String propID = String.valueOf(name.get(2));
+
+                  if (conn.hasReference(nodeID, propID))
+                  {
+                     attrs = new LinkedHashMap<Object, Object>();
+                  }
+                  else
+                  {
+                     attrs = null;
+                  }
+               }
+               else if (name.size() == 2)
+               {
+                  // do we have node with any reference
+                  String nodeID = name.getLastElementAsString();
+                  if (conn.getReferenceIdentifiers(nodeID).size() > 0)
+                  {
+                     attrs = new LinkedHashMap<Object, Object>();
+                  }
+                  else
+                  {
+                     attrs = null;
+                  }
+               }
+               else
+               {
+                  attrs = null;
+               }
+
+            }
             else
             {
                attrs = null;
                LOG.warn("Unexpected Fqn asked " + name);
             }
          }
-         else if (name.equals(Fqn.ROOT) || name.equals(JBossCacheStorage.PROPS) || name.equals(JBossCacheStorage.NODES)
-            || name.equals(JBossCacheStorage.LOCKS))
+         else if (name.get(0).equals(Fqn.ROOT) || name.get(0).equals(JBossCacheStorage.PROPS)
+            || name.get(0).equals(JBossCacheStorage.NODES) || name.get(0).equals(JBossCacheStorage.LOCKS)
+            || name.get(0).equals(JBossCacheStorage.REFS))
          {
             // roots, like NODES, PROPS etc               
             attrs = new LinkedHashMap<Object, Object>();
@@ -464,14 +514,37 @@
                   LOG.warn("Unexpected Fqn asked " + name);
                }
             }
+            else if (name.get(0).equals(JBossCacheStorage.REFS))
+            {
+               // /$REFS/<NODE_ID>
+               if (name.size() == 2)
+               {
+                  String nodeId = name.getLastElementAsString();
+                  exists = conn.getReferenceIdentifiers(nodeId).size() > 0;
+               }
+               // /$REFS/<NODE_ID>/<REF_PROP_ID>
+               else if (name.size() == 3)
+               {
+                  String refPropertyId = name.getLastElementAsString();
+                  String nodeId = (String)name.get(1);
+
+                  exists = conn.hasReference(nodeId, refPropertyId);
+               }
+               else
+               {
+                  exists = false;
+                  LOG.warn("Unexpected Fqn asked " + name);
+               }
+            }
             else
             {
                exists = false;
                LOG.warn("Unexpected Fqn asked " + name);
             }
          }
-         else if (name.equals(Fqn.ROOT) || name.equals(JBossCacheStorage.PROPS) || name.equals(JBossCacheStorage.NODES)
-            || name.equals(JBossCacheStorage.LOCKS))
+         else if (name.get(0).equals(Fqn.ROOT) || name.get(0).equals(JBossCacheStorage.PROPS)
+            || name.get(0).equals(JBossCacheStorage.NODES) || name.get(0).equals(JBossCacheStorage.LOCKS)
+            || name.get(0).equals(JBossCacheStorage.REFS))
          {
             // roots, like NODES, PROPS etc               
             exists = true;
@@ -504,32 +577,53 @@
          if (name.size() == 2)
          {
             String nodeId = (String)name.get(1);
-            return conn.getChildNodeNames(nodeId);
+            if (name.get(0).equals(JBossCacheStorage.NODES))
+            {
+               return conn.getChildNodeNames(nodeId);
+            }
+            else if (name.get(0).equals(JBossCacheStorage.REFS))
+            {
+               List<String> references = conn.getReferenceIdentifiers(nodeId);
+               Set<String> result = new LinkedHashSet<String>();
+               result.addAll(references);
+               return result;
+            }
+            else
+            {
+               // TODO this a property on any unexpected part of cache throw Exception
+               return null;
+            }
          }
-         else if (name.equals(JBossCacheStorage.NODES))
+         else if (name.get(0).equals(JBossCacheStorage.NODES))
          {
             // TODO should never be called
             LOG.warn("conn.getAllNodeIdentifiers()");
             return conn.getAllNodeIdentifiers();
 
          }
-         else if (name.equals(JBossCacheStorage.PROPS))
+         else if (name.get(0).equals(JBossCacheStorage.PROPS))
          {
             // TODO should never be called
             LOG.warn("conn.getAllPropertyIdentifiers()");
             return conn.getAllPropertyIdentifiers();
          }
-         else if (name.equals(JBossCacheStorage.LOCKS))
+         else if (name.get(0).equals(JBossCacheStorage.LOCKS))
          {
             // TODO return all Locks in workspace
             return new LinkedHashSet<String>();
          }
-         else if (name.equals(Fqn.ROOT))
+         else if (name.get(0).equals(JBossCacheStorage.REFS))
          {
+            // TODO return all referenced nodes in workspace
+            return new LinkedHashSet<String>();
+         }
+         else if (name.get(0).equals(Fqn.ROOT))
+         {
             Set<String> childs = new LinkedHashSet<String>();
             childs.add(JBossCacheStorage.NODES);
             childs.add(JBossCacheStorage.PROPS);
             childs.add(JBossCacheStorage.LOCKS);
+            childs.add(JBossCacheStorage.REFS);
             return childs;
          }
          else
@@ -541,6 +635,7 @@
       {
          conn.close();
       }
+      //      return null;
    }
 
    /**

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java	2009-11-20 14:25:20 UTC (rev 795)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java	2009-11-20 16:15:37 UTC (rev 796)
@@ -126,7 +126,7 @@
     * FIND_NODES_BY_PARENTID.
     */
    protected String FIND_NODES_BY_PARENTID;
-   
+
    /**
     * FIND_NODES_NAME_BY_PARENTID.
     */
@@ -136,32 +136,32 @@
     * FIND_PROPERTIES_BY_PARENTID.
     */
    protected String FIND_PROPERTIES_BY_PARENTID;
-   
+
    /**
     * FIND_PROPERTIES_IDNAME_BY_PARENTID.
     */
    protected String FIND_PROPERTIES_IDNAME_BY_PARENTID;
-   
+
    /**
     * FIND_ITEM_IDENTIFIER.
     */
    protected String FIND_NODE_IDENTIFIER;
-   
+
    /**
     * FIND_PROPERTY_IDENTIFIER.
     */
    protected String FIND_PROPERTY_IDENTIFIER;
-   
+
    /**
     * FIND_ITEM_NAME.
     */
    protected String FIND_ITEM_NAME;
-   
+
    /**
     * FIND_ALL_NODES.
     */
    protected String FIND_ALL_NODES;
-   
+
    /**
     * FIND_ALL_PROPERTIES.
     */
@@ -217,6 +217,11 @@
     */
    protected String DELETE_REF;
 
+   /**
+    * FIND_REFERENCE
+    */
+   protected String FIND_REFERENCE;
+
    // ======================== ITEMS table ======================== 
    /**
     * COLUMN_ID.

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java	2009-11-20 14:25:20 UTC (rev 795)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java	2009-11-20 16:15:37 UTC (rev 796)
@@ -700,6 +700,39 @@
       }
    }
 
+   public List<String> getReferenceIdentifiers(String nodeIdentifier) throws RepositoryException, IllegalStateException
+   {
+      checkIfOpened();
+      try
+      {
+         ResultSet refProps = findReferences(nodeIdentifier);
+         List<String> references = new ArrayList<String>();
+         while (refProps.next())
+         {
+            references.add(getIdentifier(refProps.getString(COLUMN_ID)));
+         }
+         return references;
+      }
+      catch (SQLException e)
+      {
+         throw new RepositoryException(e);
+      }
+   }
+
+   public boolean hasReference(String nodeIdentifier, String refPropertyIdentifier) throws RepositoryException,
+      IllegalStateException
+   {
+      checkIfOpened();
+      try
+      {
+         return hasReferenceRecord(nodeIdentifier, refPropertyIdentifier);
+      }
+      catch (SQLException e)
+      {
+         throw new RepositoryException(e);
+      }
+   }
+
    /**
     * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLockData(java.lang.String)
     */
@@ -2317,6 +2350,9 @@
 
    protected abstract ResultSet findReferences(String nodeIdentifier) throws SQLException;
 
+   protected abstract boolean hasReferenceRecord(String nodeIdentifier, String refPropertyIdentifier)
+      throws SQLException;
+
    protected abstract int deleteItemByIdentifier(String identifier) throws SQLException;
 
    protected abstract int updateNodeByIdentifier(int version, int index, int orderNumb, String identifier)

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java	2009-11-20 14:25:20 UTC (rev 795)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java	2009-11-20 16:15:37 UTC (rev 796)
@@ -85,13 +85,13 @@
    protected PreparedStatement findPropertiesIdNameByParentId;
 
    protected PreparedStatement findNodeIdentifier;
-   
+
    protected PreparedStatement findPropertyIdentifier;
 
    protected PreparedStatement findItemName;
-   
+
    protected PreparedStatement findAllProperties;
-   
+
    protected PreparedStatement findAllNodes;
 
    protected PreparedStatement insertNode;
@@ -124,6 +124,8 @@
 
    protected PreparedStatement renameNode;
 
+   protected PreparedStatement findReference;
+
    /**
     * Multidatabase JDBC Connection constructor.
     * 
@@ -191,6 +193,8 @@
          "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 = "select P.ID from JCR_MREF R, JCR_MITEM P where R.NODE_ID=? and R.PROPERTY_ID=?";
+
       FIND_VALUES_BY_PROPERTYID =
          "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? order by ORDER_NUM";
 
@@ -201,20 +205,21 @@
       FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
 
       FIND_ALL_NODES = "select ID from JCR_MITEM where I_CLASS=1";
-      
+
       FIND_NODES_NAME_BY_PARENTID =
          "select NAME, I_INDEX from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
 
       FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
 
       FIND_PROPERTIES_IDNAME_BY_PARENTID = "select ID, NAME from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?";
-      
+
       FIND_ALL_PROPERTIES = "select ID from JCR_MITEM where I_CLASS=2";
 
       FIND_NODE_IDENTIFIER = "select ID from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=? and NAME=? and I_INDEX=?";
-      
-      FIND_PROPERTY_IDENTIFIER = "select ID from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=? and NAME=? and I_INDEX=1";
 
+      FIND_PROPERTY_IDENTIFIER =
+         "select ID from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=? and NAME=? and I_INDEX=1";
+
       FIND_ITEM_NAME = "select NAME, I_CLASS from JCR_MITEM" + " where ID=?";
 
       INSERT_NODE =
@@ -616,7 +621,7 @@
       findNodeIdentifier.setInt(3, index);
       return findNodeIdentifier.executeQuery();
    }
-   
+
    /**
     * {@inheritDoc}
     */
@@ -705,4 +710,20 @@
       }
       return findAllProperties.executeQuery();
    }
+
+   @Override
+   protected boolean hasReferenceRecord(String nodeIdentifier, String refPropertyIdentifier) throws SQLException
+   {
+      // TODO make query
+      if (findReference == null)
+         findReference = dbConnection.prepareStatement(FIND_REFERENCE);
+      else
+         findReference.clearParameters();
+
+      findReference.setString(1, nodeIdentifier);
+      findReference.setString(1, refPropertyIdentifier);
+      ResultSet result = findReference.executeQuery();
+
+      return result.next();
+   }
 }

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java	2009-11-20 14:25:20 UTC (rev 795)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java	2009-11-20 16:15:37 UTC (rev 796)
@@ -82,7 +82,7 @@
    protected PreparedStatement findPropertiesIdNameByParentId;
 
    protected PreparedStatement findNodeIdentifier;
-   
+
    protected PreparedStatement findPropertyIdentifier;
 
    protected PreparedStatement findItemName;
@@ -212,7 +212,7 @@
             + " order by N_ORDER_NUM";
 
       FIND_ALL_NODES = "select ID from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=?";
-      
+
       FIND_PROPERTIES_BY_PARENTID =
          "select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
 
@@ -220,11 +220,13 @@
          "select ID, NAME from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?";
 
       FIND_ALL_PROPERTIES = "select ID from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?";
-      
-      FIND_NODE_IDENTIFIER = "select ID from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?";
-      
-      FIND_PROPERTY_IDENTIFIER = "select ID from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=1";
 
+      FIND_NODE_IDENTIFIER =
+         "select ID from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?";
+
+      FIND_PROPERTY_IDENTIFIER =
+         "select ID from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=1";
+
       FIND_ITEM_NAME = "select NAME, I_CLASS from JCR_SITEM" + " where ID=?";
 
       INSERT_NODE =
@@ -630,7 +632,7 @@
       findNodeIdentifier.setInt(4, index);
       return findNodeIdentifier.executeQuery();
    }
-   
+
    /**
     * {@inheritDoc}
     */
@@ -684,7 +686,7 @@
       findNodesNameByParentId.setString(2, parentCid);
       return findNodesNameByParentId.executeQuery();
    }
-   
+
    /**
     * {@inheritDoc}
     */
@@ -719,5 +721,12 @@
       }
       findAllProperties.setString(1, containerName);
       return findAllProperties.executeQuery();
-   }   
+   }
+
+   @Override
+   protected boolean hasReferenceRecord(String nodeId, String refPropertyId) throws SQLException
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
 }



More information about the exo-jcr-commits mailing list