[exo-jcr-commits] exo-jcr SVN: r1263 - 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
Thu Dec 31 14:06:32 EST 2009
Author: nfilotto
Date: 2009-12-31 14:06:31 -0500 (Thu, 31 Dec 2009)
New Revision: 1263
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: Rework of JDBC level to use complex queries
1. The methods getItemData are now done in 2 requests for the properties (as we do now) and for the nodes
2. The useless code has been removed
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 2009-12-31 09:05:39 UTC (rev 1262)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2009-12-31 19:06:31 UTC (rev 1263)
@@ -25,11 +25,9 @@
import org.exoplatform.services.jcr.datamodel.IllegalACLException;
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
-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.Constants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
@@ -44,7 +42,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -62,26 +59,21 @@
{
/**
- * FIND_ITEM_BY_NAME NEW.
- */
- protected String FIND_ITEM_BY_NAME_CQ;
-
- /**
- * FIND_NODE_BY_ID.
- */
- protected String FIND_ITEM_BY_ID_CQ;
-
- /**
* FIND_NODES_BY_PARENTID NEW.
*/
protected String FIND_NODES_BY_PARENTID_CQ;
/**
- * GET_PROPERTIES_BY_PARENT_ID
+ * FIND_PROPERTIES_BY_PARENTID NEW.
*/
protected String FIND_PROPERTIES_BY_PARENTID_CQ;
/**
+ * FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ.
+ */
+ protected String FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ;
+
+ /**
* Class needed to store node details (property also) since result set is not sorted in valid way.
*/
private static class TempNodeData
@@ -187,63 +179,16 @@
}
}
- protected Map<String, TempNodeData> loadTempNodesFromResultSet(ResultSet resultSet) throws RepositoryException,
- IOException, SQLException
- {
-
- Map<String, TempNodeData> nodesData = new LinkedHashMap<String, TempNodeData>();
- do
- {
- int itemClass = resultSet.getInt(COLUMN_CLASS);
- if (itemClass == I_CLASS_NODE)
- {
- TempNodeData data = new TempNodeData(resultSet);
- nodesData.put(data.cid, data);
- }
- else
- {
- String cpid = resultSet.getString(COLUMN_PARENTID);
- TempNodeData data = nodesData.get(cpid);
- if (data.properties == null)
- {
- data.properties = new HashMap<String, List<byte[]>>();
- }
- Map<String, List<byte[]>> properties = data.properties;
- String key = resultSet.getString(COLUMN_NAME);
- List<byte[]> values = properties.get(key);
- if (values == null)
- {
- values = new ArrayList<byte[]>();
- properties.put(key, values);
- }
- values.add(resultSet.getBytes(COLUMN_VDATA));
- }
- }
- while (resultSet.next());
-
- return nodesData;
-
- }
-
/**
* {@inheritDoc}
*/
- public int getChildNodesCount(NodeData parent) throws RepositoryException
- {
- // nothing to optimize
- return super.getChildNodesCount(parent);
- }
-
- /**
- * {@inheritDoc}
- */
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
{
checkIfOpened();
try
{
- ResultSet resultSet = getChildPropertiesByParentIdentifierCQ(getInternalId(parent.getIdentifier()));
+ ResultSet resultSet = findChildPropertiesByParentIdentifierCQ(getInternalId(parent.getIdentifier()));
List<PropertyData> children = new ArrayList<PropertyData>();
if (resultSet.next())
{
@@ -276,164 +221,12 @@
/**
* {@inheritDoc}
*/
- public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
- {
- return getItemByIdentifier(getInternalId(identifier));
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
- {
-
- if (parentData != null)
- {
- return getItemByName(parentData, getInternalId(parentData.getIdentifier()), name);
- }
-
- // it's a root node
- return getItemByName(null, null, name);
- }
-
- /**
- * {@inheritDoc}
- */
public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException, IllegalStateException
{
// can't optimize - result may return same node more than one time, so parse result set is difficult
return super.getReferencesData(nodeIdentifier);
}
- /**
- * Get Item By Identifier.
- *
- * @param cid
- * Item id (container internal)
- * @return ItemData
- * @throws RepositoryException
- * Repository error
- * @throws IllegalStateException
- * if connection is closed
- */
- protected ItemData getItemByIdentifier(String cid) throws RepositoryException, IllegalStateException
- {
- checkIfOpened();
- ResultSet resultSet = null;
- try
- {
- resultSet = findItemByIdentifierCQ(cid);
- if (resultSet.next())
- {
- int itemType = resultSet.getInt(COLUMN_CLASS);
- if (itemType == I_CLASS_NODE)
- {
- Map<String, TempNodeData> node = loadTempNodesFromResultSet(resultSet);
- return loadNodeFromTemporaryNodeData(node.get(cid), null, null);
- }
- else
- {
- return loadPropertyRecord(resultSet, null);
- }
-
- }
- return null;
- }
- catch (SQLException e)
- {
- throw new RepositoryException("getItemData() error", e);
- }
- catch (IOException e)
- {
- throw new RepositoryException("getItemData() error", e);
- }
- finally
- {
- try
- {
- if (resultSet != null)
- resultSet.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " + e.getMessage());
- }
- }
-
- }
-
- /**
- * Gets an item data from database.
- *
- * @param parentPath
- * - parent QPath
- * @param parentId
- * - parent container internal id (depends on Multi/Single DB)
- * @param name
- * - item name
- * @return - ItemData instance
- * @throws RepositoryException
- * Repository error
- * @throws IllegalStateException
- * if connection is closed
- */
- protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name) throws RepositoryException,
- IllegalStateException
- {
- checkIfOpened();
- ResultSet resultSet = null;
- try
- {
- resultSet = findItemByNameCQ(parentId, name.getAsString(), name.getIndex());
- if (resultSet.next())
- {
- // return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS), parent.getACL());
- int itemType = resultSet.getInt(COLUMN_CLASS);
- if (itemType == I_CLASS_NODE)
- {
- // Remember first node id. If node is not first in result set - it's a bug.
- String firstNodeId = resultSet.getString(COLUMN_ID);
-
- // There may be two or more nodes, so load temp NodeDatas and return first one.
- Map<String, TempNodeData> tempNodes = loadTempNodesFromResultSet(resultSet);
-
- QPath parentQPath = parent.getQPath();
- AccessControlList parentACL = parent.getACL();
-
- NodeData nodeData = loadNodeFromTemporaryNodeData(tempNodes.get(firstNodeId), parentQPath, parentACL);
- tempNodes.clear();
- return nodeData;
- }
- else
- {
- return loadPropertyRecord(resultSet, parent.getQPath());
- }
- }
-
- return null;
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- try
- {
- if (resultSet != null)
- resultSet.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " + e.getMessage());
- }
- }
- }
-
protected List<AccessControlEntry> readACLPermisions(String cid, Map<String, List<byte[]>> properties)
throws SQLException, IllegalACLException
{
@@ -463,30 +256,55 @@
throw new IllegalACLException("Property exo:owner is not found for node with id: " + getIdentifier(cid));
}
+
+ /**
+ * {@inheritDoc}
+ */
+ protected PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid, String cpid, int cindex,
+ int cversion, int cnordernumb, AccessControlList parentACL) throws RepositoryException, SQLException
+ {
+ ResultSet ptProp = findNodeMainPropertiesByParentIdentifierCQ(cid);
+ Map<String, List<byte[]>> properties = new HashMap<String, List<byte[]>>();
+ while (ptProp.next())
+ {
+ String key = ptProp.getString(COLUMN_NAME);
+ List<byte[]> values = properties.get(key);
+ if (values == null)
+ {
+ values = new ArrayList<byte[]>();
+ properties.put(key, values);
+ }
+ values.add(ptProp.getBytes(COLUMN_VDATA));
+ }
+ return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb, properties, parentACL);
+ }
+
/**
* Create NodeData from TempNodeData content.
*
* @param tempData
* @param parentPath
- * @param pACL
+ * @param parentACL
* @return
* @throws RepositoryException
* @throws SQLException
* @throws IOException
*/
protected PersistedNodeData loadNodeFromTemporaryNodeData(TempNodeData tempData, QPath parentPath,
- AccessControlList pACL) throws RepositoryException, SQLException, IOException
+ AccessControlList parentACL) throws RepositoryException, SQLException, IOException
{
+ return loadNodeRecord(parentPath, tempData.cname, tempData.cid, tempData.cpid, tempData.cindex,
+ tempData.cversion, tempData.cnordernumb, tempData.properties, parentACL);
+ }
- String cid = tempData.cid;
- String cname = tempData.cname;
- int cversion = tempData.cversion;
- String cpid = tempData.cpid;
- int cindex = tempData.cindex;
- int cnordernumb = tempData.cnordernumb;
- AccessControlList parentACL = pACL;
-
+ /**
+ * Create a new node from the given parameter
+ */
+ private PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid, String cpid, int cindex,
+ int cversion, int cnordernumb, Map<String, List<byte[]>> properties, AccessControlList parentACL)
+ throws RepositoryException, SQLException
+ {
try
{
InternalQName qname = InternalQName.parse(cname);
@@ -516,8 +334,6 @@
}
}
- Map<String, List<byte[]>> properties = tempData.properties;
-
// PRIMARY
List<byte[]> primaryType = properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
if (primaryType == null || primaryType.isEmpty())
@@ -629,7 +445,7 @@
throw new RepositoryException(e);
}
}
-
+
/**
* Load property record from result set. Result set must be ordered by property id.
* In other way there may be mistaces.
@@ -843,11 +659,9 @@
// }
// }
- protected abstract ResultSet findItemByIdentifierCQ(String identifier) throws SQLException;
-
- protected abstract ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException;
-
protected abstract ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
- protected abstract ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
+ protected abstract ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) 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 2009-12-31 09:05:39 UTC (rev 1262)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-31 19:06:31 UTC (rev 1263)
@@ -53,14 +53,10 @@
protected PreparedStatement findItemById;
- protected PreparedStatement findItemByIdCQ;
-
protected PreparedStatement findItemByPath;
protected PreparedStatement findItemByName;
- protected PreparedStatement findItemByNameCQ;
-
protected PreparedStatement findChildPropertyByPath;
protected PreparedStatement findPropertyByName;
@@ -90,7 +86,9 @@
protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement getPropertiesByParentIdCQ;
+ protected PreparedStatement findPropertiesByParentIdCQ;
+
+ protected PreparedStatement findNodeMainPropertiesByParentIdentifierCQ;
protected PreparedStatement insertNode;
@@ -178,22 +176,9 @@
FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
- FIND_ITEM_BY_ID_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.ID=?) or (I.PARENT_ID=? and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
- + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by V.ORDER_NUM"; //I.I_CLASS, I.N_ORDER_NUM,
-
FIND_ITEM_BY_NAME =
"select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
- FIND_ITEM_BY_NAME_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)"
- + ", (select ID from JCR_MITEM where PARENT_ID=? and NAME=? and I_INDEX=?) I2"
- + " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
- + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM, V.ORDER_NUM";
-
FIND_PROPERTY_BY_NAME =
"select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
+ " where I.I_CLASS=2 and I.PARENT_ID=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
@@ -217,6 +202,12 @@
+ " where (P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ " order by I.N_ORDER_NUM, PROP_NAME DESC, V.ORDER_NUM";
+ FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
+ "select I.NAME, V.DATA"
+ + " from JCR_SITEM I, JCR_SVALUE V"
+ + " where I.I_CLASS=2 and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+
+
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
@@ -404,22 +395,6 @@
/**
* {@inheritDoc}
*/
- protected ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException
- {
- if (findItemByNameCQ == null)
- findItemByNameCQ = dbConnection.prepareStatement(FIND_ITEM_BY_NAME_CQ);
- else
- findItemByNameCQ.clearParameters();
-
- findItemByNameCQ.setString(1, parentId);
- findItemByNameCQ.setString(2, name);
- findItemByNameCQ.setInt(3, index);
- return findItemByNameCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
@Override
protected ResultSet findPropertyByName(String parentId, String name) throws SQLException
{
@@ -635,27 +610,26 @@
}
@Override
- protected ResultSet findItemByIdentifierCQ(String identifier) throws SQLException
+ protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- if (findItemByIdCQ == null)
- findItemByIdCQ = dbConnection.prepareStatement(FIND_ITEM_BY_ID_CQ);
+ if (findPropertiesByParentIdCQ == null)
+ findPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
else
- findItemByIdCQ.clearParameters();
- findItemByIdCQ.setString(1, identifier);
- findItemByIdCQ.setString(2, identifier);
- return findItemByIdCQ.executeQuery();
+ findPropertiesByParentIdCQ.clearParameters();
+
+ findPropertiesByParentIdCQ.setString(1, parentIdentifier);
+ return findPropertiesByParentIdCQ.executeQuery();
}
@Override
- protected ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- if (getPropertiesByParentIdCQ == null)
- getPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
+ if (findNodeMainPropertiesByParentIdentifierCQ == null)
+ findNodeMainPropertiesByParentIdentifierCQ = dbConnection.prepareStatement(FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ);
else
- getPropertiesByParentIdCQ.clearParameters();
+ findNodeMainPropertiesByParentIdentifierCQ.clearParameters();
- getPropertiesByParentIdCQ.setString(1, parentIdentifier);
- return getPropertiesByParentIdCQ.executeQuery();
+ findNodeMainPropertiesByParentIdentifierCQ.setString(1, parentIdentifier);
+ return findNodeMainPropertiesByParentIdentifierCQ.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 2009-12-31 09:05:39 UTC (rev 1262)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-31 19:06:31 UTC (rev 1263)
@@ -51,14 +51,10 @@
protected PreparedStatement findItemById;
- protected PreparedStatement findItemByIdCQ;
-
protected PreparedStatement findItemByPath;
protected PreparedStatement findItemByName;
- protected PreparedStatement findItemByNameCQ;
-
protected PreparedStatement findChildPropertyByPath;
protected PreparedStatement findPropertyByName;
@@ -85,8 +81,10 @@
protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement getPropertiesByParentIdCQ;
+ protected PreparedStatement findPropertiesByParentIdCQ;
+ protected PreparedStatement findNodeMainPropertiesByParentIdentifierCQ;
+
protected PreparedStatement insertItem;
protected PreparedStatement insertNode;
@@ -184,19 +182,6 @@
"select * from JCR_SITEM"
+ " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
- FIND_ITEM_BY_NAME_CQ =
- "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
- + ", (select ID from JCR_SITEM where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?) I2"
- + " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
- + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM, V.ORDER_NUM";
-
- FIND_ITEM_BY_ID_CQ =
- "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where (I.ID=?) or (I.PARENT_ID=? and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
- + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by V.ORDER_NUM"; //I.I_CLASS, I.N_ORDER_NUM,
-
FIND_PROPERTY_BY_NAME =
"select V.DATA"
+ " from JCR_SITEM I, JCR_SVALUE V"
@@ -222,6 +207,11 @@
+ " where (P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ " order by I.N_ORDER_NUM, PROP_NAME DESC, V.ORDER_NUM";
+ FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
+ "select I.NAME, V.DATA"
+ + " from JCR_SITEM I, JCR_SVALUE V"
+ + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+
FIND_NODES_COUNT_BY_PARENTID =
"select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
@@ -617,34 +607,6 @@
}
@Override
- protected ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException
- {
- if (findItemByNameCQ == null)
- findItemByNameCQ = dbConnection.prepareStatement(FIND_ITEM_BY_NAME_CQ);
- else
- findItemByNameCQ.clearParameters();
-
- findItemByNameCQ.setString(1, containerName);
- findItemByNameCQ.setString(2, parentId);
- findItemByNameCQ.setString(3, name);
- findItemByNameCQ.setInt(4, index);
- return findItemByNameCQ.executeQuery();
- }
-
- @Override
- protected ResultSet findItemByIdentifierCQ(String identifier) throws SQLException
- {
-
- if (findItemByIdCQ == null)
- findItemByIdCQ = dbConnection.prepareStatement(FIND_ITEM_BY_ID_CQ);
- else
- findItemByIdCQ.clearParameters();
- findItemByIdCQ.setString(1, identifier);
- findItemByIdCQ.setString(2, identifier);
- return findItemByIdCQ.executeQuery();
- }
-
- @Override
protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
if (findNodesByParentIdCQ == null)
@@ -659,17 +621,29 @@
}
@Override
- protected ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- if (getPropertiesByParentIdCQ == null)
- getPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
+ if (findPropertiesByParentIdCQ == null)
+ findPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
else
- getPropertiesByParentIdCQ.clearParameters();
+ findPropertiesByParentIdCQ.clearParameters();
- getPropertiesByParentIdCQ.setString(1, containerName);
- getPropertiesByParentIdCQ.setString(2, parentIdentifier);
- return getPropertiesByParentIdCQ.executeQuery();
+ findPropertiesByParentIdCQ.setString(1, containerName);
+ findPropertiesByParentIdCQ.setString(2, parentIdentifier);
+ return findPropertiesByParentIdCQ.executeQuery();
}
+ @Override
+ protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ {
+ if (findNodeMainPropertiesByParentIdentifierCQ == null)
+ findNodeMainPropertiesByParentIdentifierCQ = dbConnection.prepareStatement(FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ);
+ else
+ findNodeMainPropertiesByParentIdentifierCQ.clearParameters();
+
+ findNodeMainPropertiesByParentIdentifierCQ.setString(1, containerName);
+ findNodeMainPropertiesByParentIdentifierCQ.setString(2, parentIdentifier);
+ return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
+ }
}
More information about the exo-jcr-commits
mailing list