[exo-jcr-commits] exo-jcr SVN: r4332 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: dataflow/session and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Apr 29 05:05:52 EDT 2011


Author: tolusha
Date: 2011-04-29 05:05:52 -0400 (Fri, 29 Apr 2011)
New Revision: 4332

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
Log:
EXOJCR-1234: make code more readable

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java	2011-04-29 08:25:13 UTC (rev 4331)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java	2011-04-29 09:05:52 UTC (rev 4332)
@@ -968,14 +968,7 @@
       int lastOrderNumber = changesLog.getLastChildOrderNumber(parent.getIdentifier());
       int lastPersistedNodeOrderNumber = transactionableManager.getLastOrderNumber(parent);
 
-      if (lastPersistedNodeOrderNumber < lastOrderNumber)
-      {
-         return lastOrderNumber;
-      }
-      else
-      {
-         return lastPersistedNodeOrderNumber;
-      }
+      return Math.max(lastPersistedNodeOrderNumber, lastOrderNumber);
    }
 
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java	2011-04-29 08:25:13 UTC (rev 4331)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java	2011-04-29 09:05:52 UTC (rev 4332)
@@ -62,10 +62,23 @@
       new HashMap<String, Map<String, ItemState>>();
 
    /**
-    * Stores persisted child nodes count.  
+    * Stores info for persisted child nodes by parent identifier. 
+    * <br>Index in array points to: 
+    * <br>0 - child nodes count. 
+    * <br>1 - last child order number 
     */
-   protected Map<String, int[]> childNodesCount = new HashMap<String, int[]>();
+   protected Map<String, int[]> childNodesInfo = new HashMap<String, int[]>();
 
+   /** 
+    * Index in <code>childNodesInfo<code> value array to store child nodes count. 
+   */
+   protected final int CHILD_NODES_COUNT_INDEX = 0;
+
+   /** 
+    * Index in <code>childNodesInfo<code> value array to store last child order number. 
+    */
+   protected final int CHILD_NODES_LAST_ORDER_NUMBER_INDEX = 1;
+
    /**
     * Create empty ChangesLog.
     * 
@@ -129,7 +142,7 @@
       index.clear();
       lastChildNodeStates.clear();
       lastChildPropertyStates.clear();
-      childNodesCount.clear();
+      childNodesInfo.clear();
    }
 
    /**
@@ -153,21 +166,21 @@
             index.remove(item.getData().getQPath());
             index.remove(new ParentIDQPathBasedKey(item));
             index.remove(new IDStateBasedKey(item.getData().getIdentifier(), item.getState()));
-            childNodesCount.remove(item.getData().getIdentifier());
+            childNodesInfo.remove(item.getData().getIdentifier());
             lastChildNodeStates.remove(item.getData().getIdentifier());
             lastChildPropertyStates.remove(item.getData().getIdentifier());
 
             if (item.isNode() && item.isPersisted())
             {
-               int childCount[] = childNodesCount.get(item.getData().getParentIdentifier());
-               if (childCount != null)
+               int childInfo[] = childNodesInfo.get(item.getData().getParentIdentifier());
+               if (childInfo != null)
                {
                   if (item.isDeleted())
-                     ++childCount[0];
+                     ++childInfo[CHILD_NODES_COUNT_INDEX];
                   else if (item.isAdded())
-                     --childCount[0];
+                     --childInfo[CHILD_NODES_COUNT_INDEX];
 
-                  childNodesCount.put(item.getData().getParentIdentifier(), childCount);
+                  childNodesInfo.put(item.getData().getParentIdentifier(), childInfo);
                }
             }
 
@@ -412,15 +425,15 @@
 
    public int getChildNodesCount(String rootIdentifier)
    {
-      int[] childCount = childNodesCount.get(rootIdentifier);
-      return childCount == null ? 0 : childCount[0];
+      int[] childInfo = childNodesInfo.get(rootIdentifier);
+      return childInfo == null ? 0 : childInfo[CHILD_NODES_COUNT_INDEX];
    }
 
    public int getLastChildOrderNumber(String rootIdentifier)
    {
 
-      int[] childInfo = childNodesCount.get(rootIdentifier);
-      return childInfo == null ? -1 : childInfo[1];
+      int[] childInfo = childNodesInfo.get(rootIdentifier);
+      return childInfo == null ? -1 : childInfo[CHILD_NODES_LAST_ORDER_NUMBER_INDEX];
    }
 
    /**
@@ -671,20 +684,20 @@
 
       if (item.isNode() && item.isPersisted())
       {
-         int[] childCount = childNodesCount.get(item.getData().getParentIdentifier());
-         if (childCount == null)
-            childCount = new int[2];
+         int[] childInfo = childNodesInfo.get(item.getData().getParentIdentifier());
+         if (childInfo == null)
+            childInfo = new int[2];
 
          if (item.isDeleted())
          {
-            --childCount[0];
+            --childInfo[CHILD_NODES_COUNT_INDEX];
          }
          else if (item.isAdded())
          {
-            ++childCount[0];
-            childCount[1] = ((NodeData)item.getData()).getOrderNumber();
+            ++childInfo[CHILD_NODES_COUNT_INDEX];
+            childInfo[CHILD_NODES_LAST_ORDER_NUMBER_INDEX] = ((NodeData)item.getData()).getOrderNumber();
          }
-         childNodesCount.put(item.getData().getParentIdentifier(), childCount);
+         childNodesInfo.put(item.getData().getParentIdentifier(), childInfo);
       }
    }
 

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java	2011-04-29 08:25:13 UTC (rev 4331)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java	2011-04-29 09:05:52 UTC (rev 4332)
@@ -133,14 +133,8 @@
          }
 
          int lastOrderNumber = storageDataManager.getLastOrderNumber(parent);
-         if (lastOrderNumber > txLastOrderNumber)
-         {
-            return lastOrderNumber;
-         }
-         else
-         {
-            return txLastOrderNumber;
-         }
+
+         return Math.max(lastOrderNumber, txLastOrderNumber);
       }
       else
       {

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java	2011-04-29 08:25:13 UTC (rev 4331)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java	2011-04-29 09:05:52 UTC (rev 4332)
@@ -235,7 +235,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#add(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public void add(NodeData data) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
       IllegalStateException
@@ -253,7 +253,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#add(org.exoplatform.services.jcr.datamodel.PropertyData)
+    * {@inheritDoc}
     */
    public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -271,7 +271,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#close()
+    * {@inheritDoc}
     */
    public void close() throws IllegalStateException, RepositoryException
    {
@@ -288,7 +288,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#commit()
+    * {@inheritDoc}
     */
    public void commit() throws IllegalStateException, RepositoryException
    {
@@ -305,7 +305,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#delete(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -323,7 +323,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#delete(org.exoplatform.services.jcr.datamodel.PropertyData)
+    * {@inheritDoc}
     */
    public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -341,7 +341,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildNodesCount(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public int getLastOrderNumber(NodeData parent) throws RepositoryException
    {
@@ -356,9 +356,9 @@
          s.end();
       }
    }
-   
+
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildNodesCount(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public int getChildNodesCount(NodeData parent) throws RepositoryException
    {
@@ -375,7 +375,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildNodesData(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
    {
@@ -392,7 +392,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getChildPropertiesData(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
    {
@@ -435,7 +435,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getItemData(java.lang.String)
+    * {@inheritDoc}
     */
    public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
    {
@@ -452,7 +452,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getReferencesData(java.lang.String)
+    * {@inheritDoc}
     */
    public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
       IllegalStateException, UnsupportedOperationException
@@ -470,7 +470,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#isOpened()
+    * {@inheritDoc}
     */
    public boolean isOpened()
    {
@@ -487,7 +487,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#listChildPropertiesData(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
    {
@@ -504,7 +504,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#rename(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -522,7 +522,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#rollback()
+    * {@inheritDoc}
     */
    public void rollback() throws IllegalStateException, RepositoryException
    {
@@ -539,7 +539,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#update(org.exoplatform.services.jcr.datamodel.NodeData)
+    * {@inheritDoc}
     */
    public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException
@@ -557,7 +557,7 @@
    }
 
    /**
-    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#update(org.exoplatform.services.jcr.datamodel.PropertyData)
+    * {@inheritDoc}
     */
    public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
       InvalidItemStateException, IllegalStateException



More information about the exo-jcr-commits mailing list