Author: bpapez
Date: Tue Jan 15 13:25:38 2008
New Revision: 19510

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19510&repname=
=3Djahia
Log:
add abstract query model

Added:
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/AbstractJahiaTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/AndTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/ComparisonTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/ConstraintTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/FullTextSearchTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/NotTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/OrTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/OrderTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryDefinitionTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryParameterTag.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryParameterValueTag.java

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/AbstractJahiaTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/AbstractJahiaT=
ag.java&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/AbstractJahiaTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/AbstractJahiaTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2002-2006 Jahia Ltd
+ *
+ * Licensed under the JAHIA COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (J=
CDDL),
+ * Version 1.0 (the "License"), or (at your option) any later version; you=
 may
+ * not use this file except in compliance with the License. You should have
+ * received a copy of the License along with this program; if not, you may=
 obtain
+ * a copy of the License at
+ *
+ *  http://www.jahia.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jahia.taglibs;
+
+import javax.servlet.jsp.tagext.BodyTagSupport;
+
+/**
+ * This abstract Tag is the starting point for implementing any knew tags.=
 In contains common attributes that should be
+ * used in the implementation of the derived tags. For instance, the 'xhtm=
lCompliantHtml' is used to know if the tag
+ * should render XHTML compliant html or simple basic html.</br>
+ * The same is true regarding the 'resourceBundle' attribute. Instead of h=
aving to set the name of the resource bundle
+ * file for all jahia tags, it is much more convenient to set it once, at =
the beginning of the template, and then simply
+ * fetching this set values.
+ *
+ * @author Xavier Lawrence
+ */
+public class AbstractJahiaTag extends BodyTagSupport {
+    /**
+     * Name of the resourceBundle all tags derived from this class will us=
e.
+     */
+    protected String resourceBundle;
+
+    /**
+     * If set to 'true' the output generated by the tag will be XHTML comp=
liant, otherwise it will be
+     * HTML compliant
+     */
+    protected boolean xhtmlCompliantHtml;
+
+    /**
+     * The languageCode attribute keeps track of the current language
+     */
+    protected String languageCode;
+
+    /**
+     * The CSS class the surrounding div or span element will have
+     */
+    protected String cssClassName;
+
+    public String getResourceBundle() {
+        return resourceBundle;
+    }
+
+    public void setResourceBundle(String resourceBundle) {
+        this.resourceBundle =3D resourceBundle;
+    }
+
+    public boolean isXhtmlCompliantHtml() {
+        return xhtmlCompliantHtml;
+    }
+
+    public void setXhtmlCompliantHtml(boolean xhtmlCompliantHtml) {
+        this.xhtmlCompliantHtml =3D xhtmlCompliantHtml;
+    }
+
+    public String getLanguageCode() {
+        return languageCode;
+    }
+
+    public void setLanguageCode(String languageCode) {
+        this.languageCode =3D languageCode;
+    }
+
+    public String getCssClassName() {
+        return cssClassName;
+    }
+
+    public void setCssClassName(String cssClassName) {
+        this.cssClassName =3D cssClassName;
+    }
+}

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/AndTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/AndTag.j=
ava&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/AndTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/AndTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,54 @@
+package org.jahia.taglibs.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.jsp.JspException;
+
+import org.jahia.query.Constraint;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 7 nov. 2007
+ * Time: 15:33:24
+ * To change this template use File | Settings | File Templates.
+ */
+public class AndTag extends ConstraintTag  {
+
+    private Constraint andConstraint;
+    private List constraints;
+
+    public int doEndTag() throws JspException {
+        int eval =3D super.doEndTag();
+        andConstraint =3D null;
+        constraints =3D null;
+        return eval;
+    }
+
+    public Constraint getConstraint(){
+        if ( andConstraint !=3D null ){
+            return andConstraint;
+        }
+        if ( this.constraints =3D=3D null || this.constraints.isEmpty() ){
+            return null;
+        }
+        if ( this.constraints.size()=3D=3D1 ){
+            andConstraint =3D (Constraint)this.constraints.get(0);
+        } else {
+            andConstraint =3D this.getQueryFactory().and(this.constraints);
+        }
+        return andConstraint;
+    }
+
+    public void addChildConstraint(Constraint constraint){
+        if ( constraint =3D=3D null ){
+            return;
+        }
+        if ( this.constraints =3D=3D null ){
+            this.constraints =3D new ArrayList();
+        }
+        this.constraints.add(constraint);
+    }
+
+}

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/ComparisonTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/Comparis=
onTag.java&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/ComparisonTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/ComparisonTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,87 @@
+package org.jahia.taglibs.query;
+
+import org.jahia.query.*;
+
+import javax.servlet.jsp.JspException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 7 nov. 2007
+ * Time: 15:33:24
+ * To change this template use File | Settings | File Templates.
+ */
+public class ComparisonTag extends ConstraintTag  {
+
+    private Comparison comparison;
+
+    private String propertyName;
+    private int operator =3D QueryModelConstants.OPERATOR_EQUAL_TO;
+    private List value;
+    =

+    public int doEndTag() throws JspException {
+        int eval =3D super.doEndTag();
+        comparison =3D null;
+        operator =3D QueryModelConstants.OPERATOR_EQUAL_TO;
+        value =3D null;
+        return eval;
+    }
+
+    public String getPropertyName() {
+        return propertyName;
+    }
+
+    public void setPropertyName(String propertyName) {
+        this.propertyName =3D propertyName;
+    }
+
+    public int getOperator() {
+        return operator;
+    }
+
+    public void setOperator(int operator) {
+        this.operator =3D operator;
+    }
+
+    public String getValue() {
+        if ( value =3D=3D null ){
+            value =3D new ArrayList();
+            return "";
+        }
+        StringBuffer buffer =3D new StringBuffer();
+        Iterator it =3D value.iterator();
+        while (it.hasNext()){
+            buffer.append(it.next());
+            if ( it.hasNext() ){
+                buffer.append(",");
+            }
+        }
+        return buffer.toString();
+    }
+
+    public void setValue(String value) {
+        this.value =3D new ArrayList();
+        StringTokenizer tokenizer =3D new StringTokenizer(value,",");
+        while (tokenizer.hasMoreElements()){
+            this.value.add(tokenizer.nextToken().trim());
+        }
+    }
+
+    public Constraint getConstraint(){
+        if ( comparison !=3D null ){
+            return comparison;
+        }
+        if ( !QueryModelTools.isNotEmptyStringOrNull(this.getPropertyName(=
)) ){
+            return null;
+        }
+        comparison =3D this.getQueryFactory().comparison(new PropertyValue=
(this.getPropertyName().trim()),
+                this.operator,
+                new Literal(value));
+        return comparison;
+    }
+
+}
\ No newline at end of file

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/ConstraintTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/Constrai=
ntTag.java&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/ConstraintTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/ConstraintTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,64 @@
+package org.jahia.taglibs.query;
+
+import org.jahia.query.Constraint;
+import org.jahia.query.QueryModelFactory;
+import org.jahia.taglibs.AbstractJahiaTag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 7 nov. 2007
+ * Time: 15:36:14
+ * To change this template use File | Settings | File Templates.
+ */
+public abstract class ConstraintTag extends AbstractJahiaTag {
+
+    private QueryDefinitionTag queryModelDefTag =3D null;
+    private ConstraintTag compoundConstraintTag =3D null;
+    private QueryModelFactory queryFactory =3D null;
+
+    public int doStartTag() {
+        queryModelDefTag =3D (QueryDefinitionTag) findAncestorWithClass(th=
is, QueryDefinitionTag.class);
+        if (queryModelDefTag =3D=3D null || queryModelDefTag.getQueryFacto=
ry()=3D=3Dnull) {
+            return SKIP_BODY;
+        }
+        this.queryFactory =3D queryModelDefTag.getQueryFactory();
+        =

+        compoundConstraintTag =3D (ConstraintTag) findAncestorWithClass(th=
is,
+                ConstraintTag.class);
+
+        return EVAL_BODY_BUFFERED;
+    }
+
+    public int doEndTag() throws JspException {
+        if ( compoundConstraintTag =3D=3D null ){
+            queryModelDefTag.addChildConstraint(getConstraint());
+        } else {
+            compoundConstraintTag.addChildConstraint(getConstraint());
+        }
+        queryModelDefTag =3D null;
+        return EVAL_PAGE;
+    }
+
+    public QueryDefinitionTag getQueryModelDefTag() {
+        return queryModelDefTag;
+    }
+
+    public void setQueryModelDefTag(QueryDefinitionTag queryModelDefTag) {
+        this.queryModelDefTag =3D queryModelDefTag;
+    }
+
+    public QueryModelFactory getQueryFactory(){
+        return this.queryFactory;
+    }
+
+    public abstract Constraint getConstraint();
+
+    public void addChildConstraint(Constraint constraint){
+        // by default do nothing
+    }
+
+}

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/FullTextSearchTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/FullText=
SearchTag.java&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/FullTextSearchTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/FullTextSearchTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,55 @@
+package org.jahia.taglibs.query;
+
+import org.jahia.query.Constraint;
+import org.jahia.query.FullTextSearch;
+
+import javax.servlet.jsp.JspException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 7 nov. 2007
+ * Time: 15:33:24
+ * To change this template use File | Settings | File Templates.
+ */
+public class FullTextSearchTag extends ConstraintTag  {
+
+    private FullTextSearch fullTextSearch;
+
+    private String searchExpression;
+    private String propertyName;
+
+    public int doEndTag() throws JspException {
+        int eval =3D super.doEndTag();
+        fullTextSearch =3D null;
+        return eval;
+    }
+
+    public Constraint getConstraint(){
+        if ( fullTextSearch !=3D null ){
+            return fullTextSearch;
+        }
+        if ( this.searchExpression =3D=3D null || this.searchExpression.tr=
im().equals("") ){
+            return null;
+        }
+        fullTextSearch =3D this.getQueryFactory().fullTextSearch(this.prop=
ertyName,this.searchExpression);
+        return fullTextSearch;
+    }
+
+    public String getSearchExpression() {
+        return searchExpression;
+    }
+
+    public void setSearchExpression(String searchExpression) {
+        this.searchExpression =3D searchExpression;
+    }
+
+    public String getPropertyName() {
+        return propertyName;
+    }
+
+    public void setPropertyName(String propertyName) {
+        this.propertyName =3D propertyName;
+    }
+
+}
\ No newline at end of file

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/NotTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/NotTag.j=
ava&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/NotTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/NotTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,53 @@
+package org.jahia.taglibs.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.jsp.JspException;
+
+import org.jahia.query.Constraint;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 7 nov. 2007
+ * Time: 15:33:24
+ * To change this template use File | Settings | File Templates.
+ */
+public class NotTag extends ConstraintTag  {
+
+    private Constraint notConstraint;
+    private List constraints;
+
+    public int doEndTag() throws JspException {
+        int eval =3D super.doEndTag();
+        notConstraint =3D null;
+        return eval;
+    }
+
+    public Constraint getConstraint(){
+        if ( notConstraint !=3D null ){
+            return notConstraint;
+        }
+        if ( this.constraints =3D=3D null || this.constraints.isEmpty() ){
+            return null;
+        }
+        if ( this.constraints.size()=3D=3D1 ){
+            notConstraint =3D this.getQueryFactory().not((Constraint)this.=
constraints.get(0));
+        } else {
+            notConstraint =3D this.getQueryFactory().not(this.constraints);
+        }
+        return notConstraint;
+    }
+
+    public void addChildConstraint(Constraint constraint){
+        if ( constraint =3D=3D null ){
+            return;
+        }
+        if ( this.constraints =3D=3D null ){
+            this.constraints =3D new ArrayList();
+        }
+        this.constraints.add(constraint);
+    }
+
+}
\ No newline at end of file

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/OrTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/OrTag.ja=
va&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/OrTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/OrTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,54 @@
+package org.jahia.taglibs.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.jsp.JspException;
+
+import org.jahia.query.Constraint;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 7 nov. 2007
+ * Time: 15:33:24
+ * To change this template use File | Settings | File Templates.
+ */
+public class OrTag extends ConstraintTag  {
+
+    private Constraint orConstraint;
+    private List constraints;
+
+    public int doEndTag() throws JspException {
+        int eval =3D super.doEndTag();
+        orConstraint =3D null;
+        constraints =3D null;
+        return eval;
+    }
+
+    public Constraint getConstraint(){
+        if ( orConstraint !=3D null ){
+            return orConstraint;
+        }
+        if ( this.constraints =3D=3D null || this.constraints.isEmpty() ){
+            return null;
+        }
+        if ( this.constraints.size()=3D=3D1 ){
+            orConstraint =3D (Constraint)this.constraints.get(0);
+        } else {
+            orConstraint =3D this.getQueryFactory().or(this.constraints);
+        }
+        return orConstraint;
+    }
+
+    public void addChildConstraint(Constraint constraint){
+        if ( constraint =3D=3D null ){
+            return;
+        }
+        if ( this.constraints =3D=3D null ){
+            this.constraints =3D new ArrayList();
+        }
+        this.constraints.add(constraint);
+    }
+
+}
\ No newline at end of file

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/OrderTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/OrderTag=
.java&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/OrderTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/OrderTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,76 @@
+package org.jahia.taglibs.query;
+
+import org.jahia.query.Ordering;
+import org.jahia.query.PropertyValue;
+import org.jahia.query.QueryModelFactory;
+import org.jahia.query.QueryModelConstants;
+import org.jahia.taglibs.AbstractJahiaTag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.tagext.Tag;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 7 nov. 2007
+ * Time: 15:33:24
+ * To change this template use File | Settings | File Templates.
+ */
+public class OrderTag extends AbstractJahiaTag {
+
+    private QueryDefinitionTag queryModelDefTag =3D null;
+    private QueryModelFactory queryFactory =3D null;
+
+    private String propertyName;
+    private String order;
+
+    public int doStartTag() {
+
+        Tag parentTag =3D this.getParent();
+        if ( parentTag =3D=3D null || !(parentTag instanceof QueryDefiniti=
onTag) ){
+            return SKIP_BODY;
+        }
+        queryModelDefTag =3D (QueryDefinitionTag)parentTag;
+        if (queryModelDefTag =3D=3D null || queryModelDefTag.getQueryFacto=
ry()=3D=3Dnull) {
+            return SKIP_BODY;
+        }
+        this.queryFactory =3D queryModelDefTag.getQueryFactory();
+        if (this.propertyName =3D=3D null || this.propertyName.trim().equa=
ls("")){
+            return EVAL_BODY_BUFFERED;
+        }
+        Ordering ordering =3D null;
+        if ( QueryModelConstants.ORDER_DESCENDING_LITERAL.equalsIgnoreCase=
(order) ){
+             ordering =3D this.queryFactory.descending(new PropertyValue(p=
ropertyName));
+        } else {
+            ordering =3D this.queryFactory.ascending(new PropertyValue(pro=
pertyName));
+        }
+        this.queryModelDefTag.getQueryModel().addOrdering(ordering);
+        return EVAL_BODY_BUFFERED;
+    }
+
+    public int doEndTag() throws JspException {
+        queryModelDefTag =3D null;
+        queryFactory =3D null;
+        propertyName =3D null;
+        order =3D null;
+        return EVAL_PAGE;
+    }
+
+    public String getPropertyName() {
+        return propertyName;
+    }
+
+    public void setPropertyName(String propertyName) {
+        this.propertyName =3D propertyName;
+    }
+
+    public String getOrder() {
+        return order;
+    }
+
+    public void setOrder(String order) {
+        this.order =3D order;
+    }
+
+}
\ No newline at end of file

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/QueryDefinitionTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/QueryDef=
initionTag.java&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryDefinitionTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryDefinitionTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,177 @@
+package org.jahia.taglibs.query;
+
+import org.apache.log4j.Logger;
+import org.jahia.data.JahiaData;
+import org.jahia.query.*;
+import org.jahia.taglibs.AbstractJahiaTag;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Properties;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 6 nov. 2007
+ * Time: 15:42:29
+ * To change this template use File | Settings | File Templates.
+ */
+public class QueryDefinitionTag extends AbstractJahiaTag {
+
+    public static final String SET_ACTION =3D "set";
+    public static final String APPEND_ACTION =3D "append";
+    public static final String REMOVE_ACTION =3D "remove";
+
+    private static org.apache.log4j.Logger logger =3D
+        org.apache.log4j.Logger.getLogger(QueryDefinitionTag.class);
+
+    private JahiaData jData;
+
+    private QueryModelFactory queryFactory;
+    private QueryModel queryModel;
+    private String siteLevelQuery;
+    private String siteIDs;
+    private String contentDefinitionNames;
+
+    public static Logger getLogger() {
+        return logger;
+    }
+
+    public static void setLogger(Logger logger) {
+        QueryDefinitionTag.logger =3D logger;
+    }
+
+
+    public int doStartTag () {
+
+        ServletRequest request =3D pageContext.getRequest();
+        jData =3D (JahiaData) request.getAttribute("org.jahia.data.JahiaDa=
ta");
+
+        Properties queryParameters =3D new Properties();
+        if (this.getSiteIDs()!=3Dnull && !"".equals(this.getSiteIDs().trim=
())){
+            queryParameters.setProperty(QueryModelConstants.SITE_IDS_PARAM=
S,this.getSiteIDs());
+        }
+        if (this.getContentDefinitionNames()!=3Dnull
+                && !"".equals(this.getContentDefinitionNames().trim())){
+            queryParameters.setProperty(QueryModelConstants.DEFINITION_NAM=
ES_PARAMS,
+                    this.getContentDefinitionNames());
+        }
+        if (this.getSiteLevelQuery()!=3Dnull
+                && !"".equals(this.getSiteLevelQuery().trim())){
+            queryParameters.setProperty(QueryModelConstants.SITE_LEVEL_QUE=
RY_PARAMS,
+                    this.getSiteLevelQuery().trim());            =

+        }
+
+        queryFactory =3D new QueryModelFactory();
+
+        queryModel =3D queryFactory.createQuery(null,new ArrayList(),query=
Parameters);
+        if (getId() !=3D null) {
+            if (queryModel!=3D null) {
+                pageContext.setAttribute(getId(), getQueryModel(), PageCon=
text.REQUEST_SCOPE);
+            } else {
+                pageContext.removeAttribute(getId(),PageContext.REQUEST_SC=
OPE);
+            }
+        }
+
+        return EVAL_BODY_BUFFERED;
+    }
+
+    // Body is evaluated one time, so just writes it on standard output
+    public int doAfterBody () {
+
+        try {
+            bodyContent.writeOut(bodyContent.getEnclosingWriter());
+        } catch (IOException ioe) {
+            logger.error("Error:", ioe);
+        }
+        return EVAL_PAGE;
+    }
+
+    /**
+     *
+     * @return
+     * @throws JspException
+     */
+    public int doEndTag ()
+        throws JspException {
+
+        // let's reinitialize the tag variables to allow tag object reuse =
in
+        // pooling.
+        jData =3D null;
+        queryFactory =3D null;
+        queryModel =3D null;
+        siteLevelQuery =3D null;
+        siteIDs =3D null;
+        contentDefinitionNames =3D null;
+        id =3D null;        =

+        return EVAL_PAGE;
+    }
+
+    public String getSiteLevelQuery() {
+        return siteLevelQuery;
+    }
+
+    public void setSiteLevelQuery(String siteLevelQuery) {
+        this.siteLevelQuery =3D siteLevelQuery;
+    }
+
+    public String getSiteIDs() {
+        return siteIDs;
+    }
+
+    public void setSiteIDs(String siteIDs) {
+        this.siteIDs =3D siteIDs;
+    }
+
+    public String getContentDefinitionNames() {
+        return contentDefinitionNames;
+    }
+
+    public void setContentDefinitionNames(String contentDefinitionNames) {
+        this.contentDefinitionNames =3D contentDefinitionNames;
+    }
+
+    public JahiaData getJData() {
+        return jData;
+    }
+
+    public void setJData(JahiaData jData) {
+        this.jData =3D jData;
+    }
+
+    public QueryModelFactory getQueryFactory() {
+        return queryFactory;
+    }
+
+    public void setQueryFactory(QueryModelFactory queryFactory) {
+        this.queryFactory =3D queryFactory;
+    }
+
+    public QueryModel getQueryModel(){
+        return queryModel;
+    }
+
+    public void setQueryModel(QueryModel queryModel){
+        this.queryModel =3D queryModel;        =

+    }
+
+    public void addChildConstraint(Constraint constraint){
+        if (constraint =3D=3D null){
+            return;
+        }
+        if ( this.queryModel =3D=3D null ){
+            return;
+        }
+        Constraint c =3D this.queryModel.getConstraint();
+        if ( c =3D=3D null ){
+            this.queryModel.setConstraint(constraint);
+        } else {
+            c =3D new And(c,constraint);
+            this.queryModel.setConstraint(c);
+        }
+    }
+}
\ No newline at end of file

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/QueryParameterTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/QueryPar=
ameterTag.java&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryParameterTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryParameterTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,96 @@
+package org.jahia.taglibs.query;
+
+import org.jahia.query.QueryModelTools;
+import org.jahia.taglibs.AbstractJahiaTag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.tagext.Tag;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 8 nov. 2007
+ * Time: 13:08:23
+ * To change this template use File | Settings | File Templates.
+ */
+public class QueryParameterTag extends AbstractJahiaTag {
+
+
+    private QueryDefinitionTag queryModelDefTag =3D null;
+
+    private String name;
+    private String value;
+    private String operation =3D QueryDefinitionTag.SET_ACTION;
+
+    public int doStartTag() {
+        Tag parentTag =3D this.getParent();
+        if ( parentTag =3D=3D null || !(parentTag instanceof QueryDefiniti=
onTag) ){
+            return SKIP_BODY;
+        }
+        queryModelDefTag =3D (QueryDefinitionTag)parentTag;
+        if (queryModelDefTag =3D=3D null) {
+            return SKIP_BODY;
+        }
+
+        if ( name =3D=3D null || name.trim().equals("") ){
+            return SKIP_BODY;
+        }
+        if ( QueryDefinitionTag.REMOVE_ACTION.equalsIgnoreCase(operation) =
){
+            queryModelDefTag.getQueryModel().getParamaters().remove(name);
+        } else if ( value !=3D null ){
+            if (QueryDefinitionTag.SET_ACTION.equalsIgnoreCase(operation)){
+                queryModelDefTag.getQueryModel().getParamaters().setProper=
ty(name, value);
+            } else {
+                QueryModelTools.appendParameterValue(queryModelDefTag.getQ=
ueryModel().getParamaters(),
+                        name,value);
+            }
+        }
+        return EVAL_BODY_BUFFERED;
+    }
+
+    public int doEndTag() throws JspException {
+        queryModelDefTag =3D null;
+        name =3D null;
+        value =3D null;
+        operation =3D QueryDefinitionTag.SET_ACTION;
+        return EVAL_PAGE;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name =3D name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value =3D value;
+    }
+
+    public String getOperation() {
+        return operation;
+    }
+
+    public void setOperation(String operation) {
+        this.operation =3D operation;
+    }
+
+    public void setParameter(String value) {
+        if ( value !=3D null ){
+            if (QueryDefinitionTag.SET_ACTION.equalsIgnoreCase(operation)){
+                queryModelDefTag.getQueryModel().getParamaters().setProper=
ty(name, value);
+            } else {
+                QueryModelTools.appendParameterValue(queryModelDefTag.getQ=
ueryModel().getParamaters(),
+                        name,value);
+            }
+        }
+    }
+
+
+}

Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/query/QueryParameterValueTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/query/QueryPar=
ameterValueTag.java&rev=3D19510&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryParameterValueTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/query/QueryParameterValueTag.java Tue Jan 15 13:25:38 2008
@@ -0,0 +1,51 @@
+package org.jahia.taglibs.query;
+
+import org.jahia.taglibs.AbstractJahiaTag;
+
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.JspException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hollis
+ * Date: 8 nov. 2007
+ * Time: 13:08:23
+ * To change this template use File | Settings | File Templates.
+ */
+public class QueryParameterValueTag extends AbstractJahiaTag {
+
+    private QueryParameterTag queryParameterTag =3D null;
+
+    private String value;
+
+    public int doStartTag() {
+        Tag parentTag =3D this.getParent();
+        if ( parentTag =3D=3D null || !(parentTag instanceof QueryParamete=
rTag) ){
+            return SKIP_BODY;
+        }
+        queryParameterTag =3D (QueryParameterTag)parentTag;
+        if (queryParameterTag =3D=3D null) {
+            return SKIP_BODY;
+        }
+        if ( value !=3D null ){
+            queryParameterTag.setParameter(value);
+        }
+        return EVAL_BODY_BUFFERED;
+    }
+
+    public int doEndTag() throws JspException {
+        queryParameterTag =3D null;
+        value =3D null;
+        return EVAL_PAGE;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value =3D value;
+    }
+
+}
\ No newline at end of file

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to