Project

General

Profile

« Previous | Next » 

Revision 3769

Added by Jing Tao almost 17 years ago

Fixed bug that kepler skin wouldn't return actor name in query. The reason is there was no separate vector to store returnfield with "]". So those fields with or without "]" are handled
together (which shouldn't). When seperate those return fields, the bug was fixed.

View differences:

src/edu/ucsb/nceas/metacat/QuerySpecification.java
78 78

  
79 79
    /** List of fields to be returned in result set */
80 80
    private Vector returnFieldList;
81
    
82
    /** List of fields with "[" and "]" in result set. This is a subset of returnFieldList.
83
     *   If some of return fields have [,  those fields will be stored this vector (we have different query for those return fields */
84
    private Vector returnFieldListWithPredicates;
81 85

  
82 86
    /** List of users owning documents to be searched */
83 87
    private Vector ownerList;
......
152 156
        elementStack = new Stack();
153 157
        queryStack = new Stack();
154 158
        returnFieldList = new Vector();
159
        returnFieldListWithPredicates = new Vector();
155 160
        ownerList = new Vector();
156 161
        this.parserName = parserName;
157 162
        this.accNumberSeparator = accNumberSeparator;
......
201 206
        elementStack = new Stack();
202 207
        queryStack = new Stack();
203 208
        returnFieldList = new Vector();
209
        returnFieldListWithPredicates = new Vector();
204 210
        ownerList = new Vector();
205 211
        this.accNumberSeparator = accNumberSeparator;
206 212
    }
......
724 730
        }
725 731

  
726 732
        if (hasPredicate)
733
        {
727 734
            containsPredicates = true;
735
            returnFieldListWithPredicates.add(inputString);
736
        }
728 737

  
729 738
        containsExtendedSQL = true;
730 739

  
731 740
     
732
            // no attribute value will be returned
733
            logMetacat.info("QuerySpecification.handleReturnField(): " );
734
            logMetacat.info("  there are no attributes in the XPATH statement" );
735
            returnFieldList.add(inputString);
741
        // no attribute value will be returned
742
        logMetacat.info("QuerySpecification.handleReturnField(): " );
743
        logMetacat.info("  there are no attributes in the XPATH statement" );
744
        returnFieldList.add(inputString);
736 745
       
737 746

  
738 747
       
......
860 869
        else
861 870
        {
862 871
            StringBuffer self = new StringBuffer();
863

  
864 872
            boolean firstfield = true;
873
            // first part comes from fields without  predicates 
874
            String queryFromWithoutPrecidates = printExtendedSQL(doclist);
875
             if (queryFromWithoutPrecidates != null)
876
             {
877
            	 // it has return fields without predicate
878
            	 self.append(queryFromWithoutPrecidates);
879
            	 firstfield = false;
880
             }
865 881
            //put the returnfields into the query
866 882
            //the for loop allows for multiple fields
867
            for (int i = 0; i < returnFieldList.size(); i++)
883
            for (int i = 0; i <   returnFieldListWithPredicates.size(); i++)
868 884
            {
869 885
                if (firstfield)
870 886
                {
......
874 890
                {
875 891
                    self.append(" UNION ");
876 892
                }
877
                String path  = (String) returnFieldList.elementAt(i);
893
                String path  = (String)  returnFieldListWithPredicates.elementAt(i);
878 894
                self.append("select xml_nodes.docid, ");
879 895
                self.append("'"+ path.replaceAll("'", "''") + "' as path, ");
880 896
                self.append("xml_nodes.nodedata, ");
......
922 938

  
923 939
        for (int i = 0; i < returnFieldList.size(); i++) {
924 940
        	String path = (String)returnFieldList.elementAt(i);
941
        	// Since return fileds having preicates will be handle in another path,
942
        	// we should skip it.
943
        	if (returnFieldListWithPredicates.contains(path))
944
        	{
945
        		continue;
946
        	}
925 947
        	if (path != null && path.indexOf(ATTRIBUTESYMBOL) != -1)
926 948
        	{
927 949
        		attributeVector.add(path);

Also available in: Unified diff