jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r774397 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java
Date Wed, 13 May 2009 15:22:52 GMT
Author: stefan
Date: Wed May 13 15:22:50 2009
New Revision: 774397

URL: http://svn.apache.org/viewvc?rev=774397&view=rev
Log:
JCR-1591: JSR 283: NodeType Management (WIP...)
JCR-2091: Searchability settings in PropertyDefinition (WIP...)

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java?rev=774397&r1=774396&r2=774397&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
Wed May 13 15:22:50 2009
@@ -45,6 +45,7 @@
 import javax.jcr.ValueFormatException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
+import javax.jcr.query.qom.QueryObjectModelConstants;
 import javax.jcr.version.OnParentVersionAction;
 import java.io.Reader;
 import java.util.ArrayList;
@@ -231,6 +232,8 @@
             NodeTypeDef ntd = new NodeTypeDef();
             ntd.setOrderableChildNodes(false);
             ntd.setMixin(false);
+            ntd.setAbstract(false);
+            ntd.setQueryable(true);
             ntd.setPrimaryItemName(null);
             doNodeTypeName(ntd);
             doSuperTypes(ntd);
@@ -333,7 +336,7 @@
                 ntd.setAbstract(true);
             } else if (currentTokenEquals(Lexer.NOQUERY)) {
                 nextToken();
-                // ntd.setNoQuery(true);
+                ntd.setQueryable(false);
             } else if (currentTokenEquals(Lexer.PRIMARYITEM)) {
                 nextToken();
                 ntd.setPrimaryItemName(toQName(currentToken));
@@ -367,6 +370,18 @@
                 pdi.setRequiredType(PropertyType.STRING);
                 pdi.setValueConstraints(null);
 
+                pdi.setFullTextSearchable(true);
+                pdi.setQueryOrderable(true);
+                pdi.setAvailableQueryOperators(new String[]{
+                        QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
+                        QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN,
+                        QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO,
+                        QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN,
+                        QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO,
+                        QueryObjectModelConstants.JCR_OPERATOR_LIKE,
+                        QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO
+                });
+
                 nextToken();
                 doPropertyDefinition(pdi, ntd);
                 propertyDefinitions.add(pdi);
@@ -448,6 +463,12 @@
             pdi.setRequiredType(PropertyType.PATH);
         } else if (currentTokenEquals(Lexer.REFERENCE)) {
             pdi.setRequiredType(PropertyType.REFERENCE);
+        } else if (currentTokenEquals(Lexer.WEAKREFERENCE)) {
+            pdi.setRequiredType(PropertyType.WEAKREFERENCE);
+        } else if (currentTokenEquals(Lexer.URI)) {
+            pdi.setRequiredType(PropertyType.URI);
+        } else if (currentTokenEquals(Lexer.DECIMAL)) {
+            pdi.setRequiredType(PropertyType.DECIMAL);
         } else if (currentTokenEquals(Lexer.UNDEFINED)) {
             pdi.setRequiredType(PropertyType.UNDEFINED);
         } else {
@@ -500,12 +521,60 @@
                 pdi.setOnParentVersion(OnParentVersionAction.IGNORE);
             } else if (currentTokenEquals(Lexer.ABORT)) {
                 pdi.setOnParentVersion(OnParentVersionAction.ABORT);
+            } else if (currentTokenEquals(Lexer.NOFULLTEXT)) {
+                pdi.setFullTextSearchable(false);
+            } else if (currentTokenEquals(Lexer.NOQUERYORDER)) {
+                pdi.setQueryOrderable(false);
+            } else if (currentTokenEquals(Lexer.QUERYOPS)) {
+                doPropertyQueryOperators(pdi);
             }
             nextToken();
         }
     }
 
     /**
+     * processes the property value constraints
+     *
+     * @param pdi
+     * @throws ParseException
+     */
+    private void doPropertyQueryOperators(PropDefImpl pdi) throws ParseException {
+        if (!currentTokenEquals(Lexer.QUERYOPS)) {
+            return;
+        }
+        nextToken();
+        if (!currentTokenEquals(Lexer.SINGLE_QUOTE)) {
+            lexer.fail("Missing \' delimiter for beginning of query operators list");
+        }
+        List queryOps = new ArrayList();
+        do {
+            nextToken();
+            if (currentTokenEquals(Lexer.QUEROPS_EQUAL)) {
+                queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO);
+            } else if (currentTokenEquals(Lexer.QUEROPS_NOTEQUAL)) {
+                queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO);
+            } else if (currentTokenEquals(Lexer.QUEROPS_LESSTHAN)) {
+                queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN);
+            } else if (currentTokenEquals(Lexer.QUEROPS_LESSTHANOREQUAL)) {
+                queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO);
+            } else if (currentTokenEquals(Lexer.QUEROPS_GREATERTHAN)) {
+                queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN);
+            } else if (currentTokenEquals(Lexer.QUEROPS_GREATERTHANOREQUAL)) {
+                queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO);
+            } else if (currentTokenEquals(Lexer.QUEROPS_LIKE)) {
+                queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LIKE);
+            } else if (currentTokenEquals(Lexer.SINGLE_QUOTE)) {
+                nextToken();
+                break;
+            } else {
+                lexer.fail("'" + currentToken + "' is not a valid query operator");
+            }
+            nextToken();
+        } while (currentTokenEquals(Lexer.LIST_DELIMITER));
+        pdi.setAvailableQueryOperators((String[]) queryOps.toArray(new String[queryOps.size()]));
+    }
+
+    /**
      * processes the property default values
      *
      * @param pdi

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java?rev=774397&r1=774396&r2=774397&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java
Wed May 13 15:22:50 2009
@@ -16,9 +16,12 @@
  */
 package org.apache.jackrabbit.spi.commons.nodetype.compact;
 
+import javax.jcr.query.qom.QueryObjectModelConstants;
 import java.io.StreamTokenizer;
 import java.io.Reader;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
 
 /**
  * Lexer
@@ -48,6 +51,9 @@
     public static final String[] MANDATORY = new String[]{"mandatory", "man", "m"};
     public static final String[] PROTECTED = new String[]{"protected", "pro", "p"};
     public static final String[] MULTIPLE = new String[]{"multiple", "mul", "*"};
+    public static final String[] QUERYOPS = new String[]{"queryops", "qop"};
+    public static final String[] NOFULLTEXT = new String[]{"nofulltext", "nof"};
+    public static final String[] NOQUERYORDER = new String[]{"noqueryorder", "nqord"};
 
     public static final String[] COPY = new String[]{"copy", "Copy", "COPY"};
     public static final String[] VERSION = new String[]{"version", "Version", "VERSION"};
@@ -56,17 +62,33 @@
     public static final String[] IGNORE = new String[]{"ignore", "Ignore", "IGNORE"};
     public static final String[] ABORT = new String[]{"abort", "Abort", "ABORT"};
 
-    public static final String[] ATTRIBUTE = new String[]{"primary", "pri", "!",
-                                                          "autocreated", "aut", "a",
-                                                          "mandatory", "man", "m",
-                                                          "protected", "pro", "p",
-                                                          "multiple", "mul", "*",
-                                                          "copy", "Copy", "COPY",
-                                                          "version", "Version", "VERSION",
-                                                          "initialize", "Initialize", "INITIALIZE",
-                                                          "compute", "Compute", "COMPUTE",
-                                                          "ignore", "Ignore", "IGNORE",
-                                                          "abort", "Abort", "ABORT"};
+    public static final String[] ATTRIBUTE;
+    static {
+        ArrayList<String> attr = new ArrayList<String>();
+        attr.addAll(Arrays.asList(PRIMARY));
+        attr.addAll(Arrays.asList(AUTOCREATED));
+        attr.addAll(Arrays.asList(MANDATORY));
+        attr.addAll(Arrays.asList(PROTECTED));
+        attr.addAll(Arrays.asList(MULTIPLE));
+        attr.addAll(Arrays.asList(QUERYOPS));
+        attr.addAll(Arrays.asList(NOFULLTEXT));
+        attr.addAll(Arrays.asList(NOQUERYORDER));
+        attr.addAll(Arrays.asList(COPY));
+        attr.addAll(Arrays.asList(VERSION));
+        attr.addAll(Arrays.asList(INITIALIZE));
+        attr.addAll(Arrays.asList(COMPUTE));
+        attr.addAll(Arrays.asList(IGNORE));
+        attr.addAll(Arrays.asList(ABORT));
+        ATTRIBUTE = attr.toArray(new String[attr.size()]);
+    }
+
+    public static final String QUEROPS_EQUAL = "=";
+    public static final String QUEROPS_NOTEQUAL = "<>";
+    public static final String QUEROPS_LESSTHAN = "<";
+    public static final String QUEROPS_LESSTHANOREQUAL = "<=";
+    public static final String QUEROPS_GREATERTHAN = ">";
+    public static final String QUEROPS_GREATERTHANOREQUAL = ">=";
+    public static final String QUEROPS_LIKE = "LIKE";
 
     public static final String[] STRING = {"string", "String", "STRING"};
     public static final String[] BINARY = {"binary", "Binary", "BINARY"};
@@ -77,6 +99,9 @@
     public static final String[] NAME = {"name", "Name", "NAME"};
     public static final String[] PATH = {"path", "Path", "PATH"};
     public static final String[] REFERENCE = {"reference", "Reference", "REFERENCE"};
+    public static final String[] WEAKREFERENCE = {"weakreference", "WeakReference", "WEAKREFERENCE"};
+    public static final String[] URI = {"uri", "Uri", "URI"};
+    public static final String[] DECIMAL = {"decimal", "Decimal", "DECIMAL"};
 
     public static final String[] UNDEFINED = new String[]{"undefined", "Undefined", "UNDEFINED",
"*"};
 



Mime
View raw message