Author: sergiykarpenko
Date: 2010-08-03 11:08:05 -0400 (Tue, 03 Aug 2010)
New Revision: 2868
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/child-node-constraint.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/exaxt-path-constraint.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-all-descendant-nodes.xml
Modified:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/jcr-query-usecases.xml
Log:
EXOJCR-869: jcr-query-usecases ported
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/child-node-constraint.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/child-node-constraint.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/child-node-constraint.xml 2010-08-03
15:08:05 UTC (rev 2868)
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.ChildNodeConstraint">
+ <title>Child Node Constraint</title>
+
+ <para>Find all nodes with the primary type 'nt:folder' that are children
of
+ node by path "/root1/root2". Only find children, do not find further
+ descendants.</para>
+
+ <section>
+ <title>Repository Structure</title>
+
+ <para>The repository is filled by "nt:folder" nodes. The nodes are
placed
+ in a multilayer tree.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder1 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder2 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder3 (nt:folder) // This node we want to
+ find</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder4 (nt:folder) // This node is not child
+ but a descendant of '/folder1/folder2/'.</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+
+ <listitem>
+ <para>folder5 (nt:folder) // This node we want to
+ find</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query Execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <para>The use of "%" in the LIKE statement includes any string,
therefore
+ there is a second LIKE statement that excludes that the string contains
+ "/". This way child nodes are included but descendant nodes are
+ excluded.</para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM nt:folder WHERE jcr:path LIKE
'/folder1/folder2/%' AND NOT jcr:path LIKE '/folder1/folder2/%/%'";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement =
"/jcr:root/folder1[1]/folder2[1]/element(*,nt:folder)";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetching the Result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>The NodeIterator will return "folder3" and
"folder5".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>The table content is: <table>
+ <title>Table content</title>
+
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>/folder1/folder2/folder3</entry>
+
+ <entry>1707</entry>
+ </row>
+
+ <row>
+ <entry>/folder1/folder2/folder5</entry>
+
+ <entry>1707</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/exaxt-path-constraint.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/exaxt-path-constraint.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/exaxt-path-constraint.xml 2010-08-03
15:08:05 UTC (rev 2868)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.ExactPathConstraint">
+ <title>Exact Path Constraint</title>
+
+ <para>Find a node with the primary type 'nt:file' that is located on the
+ exact path "/folder1/folder2/document1".</para>
+
+ <section>
+ <title>Repository Structure</title>
+
+ <para>Repository filled by different nodes. There are several folders
+ which contain other folders and files.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder1 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder2 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (nt:file) // This document we want to
+ find</para>
+ </listitem>
+
+ <listitem>
+ <para>folder3 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (nt:file)</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query Execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// we want find 'document1'
+String sqlStatement = "SELECT * FROM nt:file WHERE jcr:path =
'/folder1/folder2/document1'";
+// create query
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// we want to find 'document1'
+String xpathStatement =
"/jcr:root/folder1[1]/folder2[1]/element(document1,nt:file)[1]";
+// create query
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para>Remark: The indexes [1] are used in order to get the same result as
+ the SQL statement. SQL by default only returns the first node, whereas
+ XPath fetches by default all nodes.</para>
+ </section>
+
+ <section>
+ <title>Fetching the Result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return expected "document1".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is: <table>
+ <title>Table content</title>
+
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>/folder1/folder2/document1</entry>
+
+ <entry>1030</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-all-descendant-nodes.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-all-descendant-nodes.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-all-descendant-nodes.xml 2010-08-03
15:08:05 UTC (rev 2868)
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.FindAllDescendantNodes">
+ <title>Find All Descendant Nodes</title>
+
+ <para>Find all nodes with the primary type 'nt:folder' that are
descendants
+ of the node "/folder1/folder2".</para>
+
+ <section>
+ <title>Repository Structure</title>
+
+ <para>The repository contains "nt:folder" nodes. The nodes are placed
in a
+ multilayer tree.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder1 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder2 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder3 (nt:folder) // This node we want to
+ find</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder4 (nt:folder) // This node we want to
+ find</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+
+ <listitem>
+ <para>folder5 (nt:folder) // This node we want to
+ find</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query Execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM nt:folder WHERE jcr:path LIKE
'/folder1/folder2/%'";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement =
"/jcr:root/folder1[1]/folder2[1]//element(*,nt:folder)";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetching the Result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>The NodeIterator will return "folder3", "folder4" and
"folder5"
+ nodes.</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is: <table>
+ <title>Table content</title>
+
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>jcr:path</entry>
+
+ <entry> jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>/folder1/folder2/folder3</entry>
+
+ <entry>1000</entry>
+ </row>
+
+ <row>
+ <entry>/folder1/folder2/folder3/folder4</entry>
+
+ <entry>1000</entry>
+ </row>
+
+ <row>
+ <entry>/folder1/folder2/folder5</entry>
+
+ <entry>1000</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Modified:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/jcr-query-usecases.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/jcr-query-usecases.xml 2010-08-03
14:40:37 UTC (rev 2867)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/jcr-query-usecases.xml 2010-08-03
15:08:05 UTC (rev 2868)
@@ -182,18 +182,18 @@
<itemizedlist>
<listitem>
- <para><ulink url="JCR.Exact Path Constraint">JCR.Exact
Path
- Constraint</ulink></para>
+ <para><link linkend="JCR.ExactPathConstraint">Exact Path
+ Constraint</link></para>
</listitem>
<listitem>
- <para><ulink url="JCR.Child Node Constraint">JCR.Child
Node
- Constraint</ulink></para>
+ <para><link linkend="JCR.ChildNodeConstraint">Child Node
+ Constraint</link></para>
</listitem>
<listitem>
- <para><ulink url="JCR.Find All Descendant Nodes">JCR.Find
All
- Descendant Nodes</ulink></para>
+ <para><link linkend="JCR.FindAllDescendantNodes">Find All
Descendant
+ Nodes</link></para>
</listitem>
</itemizedlist>
</section>
@@ -203,40 +203,36 @@
<itemizedlist>
<listitem>
- <para><ulink url="JCR.Order by Property">JCR.Order by
- Property</ulink></para>
+ <para><link linkend="???">JCR.Order by
Property</link></para>
</listitem>
<listitem>
- <para><ulink url="JCR.Order by Descendant Node
Property">JCR.Order
- by Descendant Node Property</ulink></para>
+ <para><link linkend="???">JCR.Order by Descendant Node
+ Property</link></para>
</listitem>
<listitem>
- <para><ulink url="JCR.Order by Score">JCR.Order by
- Score</ulink></para>
+ <para><link linkend="???">JCR.Order by
Score</link></para>
</listitem>
<listitem>
- <para><ulink url="JCR.Order by Path or Name">JCR.Order by
Path or
- Name</ulink></para>
+ <para><link linkend="???">JCR.Order by Path or
Name</link></para>
</listitem>
</itemizedlist>
</section>
<section>
- <title><ulink url="Fulltext Search">Fulltext
Search</ulink></title>
+ <title><link linkend="???">Fulltext
Search</link></title>
<itemizedlist>
<listitem>
- <para><ulink url="JCR.Fulltext Search by
Property">JCR.Fulltext
- Search by Property</ulink></para>
+ <para><link linkend="???">JCR.Fulltext Search by
+ Property</link></para>
</listitem>
<listitem>
- <para><ulink
- url="JCR.Fulltext Search by All Properties">JCR.Fulltext Search
by
- All Properties</ulink></para>
+ <para><link linkend="???">JCR.Fulltext Search by All
+ Properties</link></para>
</listitem>
<listitem>
Show replies by date