knguyen     2005/05/24 20:16:17 CEST

  Modified files:        (Branch: JAHIA-4-1-BRANCH)
    src/java/org/jahia/data/containers ContainerChainedFilter.java 
  Log:
  - last fix
  
  Revision  Changes    Path
  1.1.2.2   +72 -24    
jahia/src/java/org/jahia/data/containers/ContainerChainedFilter.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/data/containers/ContainerChainedFilter.java.diff?r1=1.1.2.1&r2=1.1.2.2&f=h
  
  
  
  Index: ContainerChainedFilter.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/src/java/org/jahia/data/containers/Attic/ContainerChainedFilter.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ContainerChainedFilter.java       20 May 2005 15:20:17 -0000      1.1.2.1
  +++ ContainerChainedFilter.java       24 May 2005 18:16:17 -0000      1.1.2.2
  @@ -111,6 +111,28 @@
               filter = (ContainerFilterInterface)chain[i];
               val = filter.getSelect(ctnListID);
               if ( val != null ){
  +                if (i > 0) {
  +                    int logop = (this.logic != -1) ? this.logic :
  +                                this.logicArray[i-1];
  +                    switch (logop) {
  +                        case OR:
  +                            buff.append(" UNION ");
  +                            break;
  +                        case AND:
  +                            buff.append(" INTERSECT ");
  +                            break;
  +                        case XOR:
  +                            buff.append(" XOR "); //probably not supported 
in SQL but this SQL statement is not executed anyway, just used as ID for 
caching
  +                            break;
  +                        case ANDNOT:
  +                            buff.append(" ANDNOT "); //probably not 
supported in SQL but this SQL statement is not executed anyway, just used as ID 
for caching
  +                            break;
  +                        default:
  +                            buff.append(" DEFAULT_OPERATOR ");//probably not 
supported in SQL but this SQL statement is not executed anyway, just used as ID 
for caching
  +                            break;
  +                    }
  +                }
  +
                   buff.append(val);
               }
           }
  @@ -181,6 +203,27 @@
               filter = (ContainerFilterInterface)chain[i];
               val = filter.getSelectBySiteID(siteId,containerDefinitionName);
               if ( val != null ){
  +                if (i > 0) {
  +                    int logop = (this.logic != -1) ? this.logic :
  +                                this.logicArray[i-1];
  +                    switch (logop) {
  +                        case OR:
  +                            buff.append(" UNION ");
  +                            break;
  +                        case AND:
  +                            buff.append(" INTERSECT ");
  +                            break;
  +                        case XOR:
  +                            buff.append(" XOR "); //probably not supported 
in SQL but this SQL statement is not executed anyway, just used as ID for 
caching
  +                            break;
  +                        case ANDNOT:
  +                            buff.append(" ANDNOT ");//probably not supported 
in SQL but this SQL statement is not executed anyway, just used as ID for 
caching
  +                            break;
  +                        default:
  +                            buff.append(" DEFAULT_OPERATOR ");//probably not 
supported in SQL but this SQL statement is not executed anyway, just used as ID 
for caching
  +                            break;
  +                    }
  +                }
                   buff.append(val);
               }
           }
  @@ -241,35 +284,20 @@
        */
       private BitSet bits(int[] logic, FilterData filterData) throws 
JahiaException
       {
  -        if (logic.length != chain.length)
  +        if (logic.length < chain.length-1)
               throw new IllegalArgumentException("Invalid number of elements 
in logic array");
  -        BitSet result;
  -        int i = 0;
   
  -        /**
  -         * First AND operation takes place against a completely false
  -         * bitset and will always return zero results. Thanks to
  -         * Daniel Armbrust for pointing this out and suggesting workaround.
  -         */
  -        if (logic[0] == AND)
  -        {
  -            if ( !filterData.isSiteSearch() ) {
  -                result = (BitSet) 
chain[i].doFilter(filterData.getListId()).clone();
  -            } else {
  -                result = (BitSet) 
chain[i].doFilterBySite(filterData.getSiteId(),
  -                        
filterData.getContainerDefinitionName(),filterData.getListId()).clone();
  -            }
  -            ++i;
  -        }
  -        else
  -        {
  -            //result = new BitSet(reader.maxDoc());
  -            result = new BitSet();
  +        BitSet result = null;
  +        if ( !filterData.isSiteSearch() ) {
  +            result = (BitSet) 
chain[0].doFilter(filterData.getListId()).clone();
  +        } else {
  +            result = (BitSet) chain[0].doFilterBySite(filterData.getSiteId(),
  +                    
filterData.getContainerDefinitionName(),filterData.getListId()).clone();
           }
   
  -        for (; i < chain.length; i++)
  +        for (int i=1; i < chain.length; i++)
           {
  -            doChain(result, logic[i], chain[i], filterData);
  +            doChain(result, logic[i-1], chain[i], filterData);
           }
           return result;
       }
  @@ -323,6 +351,26 @@
           sb.append("ChainedFilter: [");
           for (int i = 0; i < chain.length; i++)
           {
  +            if (i>0) {
  +                int logop = (this.logic != -1) ? this.logic : 
this.logicArray[i-1] ;
  +                switch (logop) {
  +                    case OR:
  +                        sb.append(" OR ");
  +                        break;
  +                    case AND:
  +                        sb.append(" AND ");
  +                        break;
  +                    case XOR:
  +                        sb.append(" XOR ");
  +                        break;
  +                    case ANDNOT:
  +                        sb.append(" XOR ");
  +                        break;
  +                    default:
  +                        sb.append(" OR ");
  +                        break;
  +                }
  +            }
               sb.append(chain[i]);
               sb.append(' ');
           }
  

Reply via email to