Project

General

Profile

« Previous | Next » 

Revision 7495

group user_owner clause as "AND (... OR .... OR ....)" to handle multiple pathquery <owner> elements. http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5880

View differences:

src/edu/ucsb/nceas/metacat/QuerySpecification.java
779 779
        // list will be searched if the tag is present
780 780
        if (!filterDocList.isEmpty()) {
781 781
            boolean firstdoctype = true;
782
            boolean emptyString = true;
783 782

  
784
            if(!self.toString().equals("")){
785
                self.append(" AND (");
786
                emptyString = false;
783
            if (!self.toString().equals("")){
784
                self.append(" AND ");
787 785
            }
786
            self.append(" (");
788 787

  
789 788
            Enumeration en = filterDocList.elements();
790 789
            while (en.hasMoreElements()) {
791 790
                String currentDoctype = (String) en.nextElement();
792 791
                if (firstdoctype) {
793 792
                    firstdoctype = false;
794
                    self.append(" doctype = '" + currentDoctype + "'");
793
                    self.append(" doctype = ?");
795 794
                } else {
796
                    self.append(" OR doctype = '" + currentDoctype + "'");
795
                    self.append(" OR doctype = ?");
797 796
                }
797
                parameterValues.add(currentDoctype);
798

  
798 799
            }
799 800

  
800
            if(!emptyString){
801
                self.append(") ");
802
            }
801
            self.append(") ");
802
            
803 803
        }
804 804

  
805 805
        // Add SQL to filter for owners requested in the query
806 806
        // This is an implicit OR for the list of owners
807 807
        if (!ownerList.isEmpty()) {
808 808
            boolean first = true;
809
            boolean emptyString = true;
810 809

  
811
            if(!self.toString().equals("")){
812
                self.append(" AND (");
813
                emptyString = false;
810
            if (!self.toString().equals("")){
811
                self.append(" AND ");
814 812
            }
813
            self.append(" (");
814
            
815 815

  
816 816
            Enumeration en = ownerList.elements();
817 817
            while (en.hasMoreElements()) {
......
821 821
                }
822 822
                if (first) {
823 823
                    first = false;
824
                    self.append(" lower(user_owner) = '" + current + "'");
824
                    self.append(" lower(user_owner) = ?");
825 825
                } else {
826
                    self.append(" OR lower(user_owner) = '" + current + "'");
826
                    self.append(" OR lower(user_owner) = ?");
827 827
                }
828
                parameterValues.add(current);
828 829
            }
829 830

  
830
            if(!emptyString){
831
                self.append(") ");
832
            }
831
            self.append(") ");
832
            
833 833
        }
834 834

  
835 835
        // if there is only one percentage search item, this query is a

Also available in: Unified diff