Project

General

Profile

« Previous | Next » 

Revision 1350

Added by Jing Tao almost 22 years ago

add some methods and attributes to determine percentage search.

View differences:

src/edu/ucsb/nceas/metacat/QuerySpecification.java
80 80
  private String accNumberSeparator = null;
81 81
  private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
82 82
  
83
  private int countPercentageSearchItem = 0;
84
  private boolean percentageSearch = false;
85
  
83 86
  private String userName = null;
84 87
  private static final String PUBLIC = "public";
85 88
  private String [] group = null;
......
154 157
  {
155 158
    this.group = myGroup;
156 159
  }
157
  
160
  /**
161
   * Method to indicate this query is a percentage search
162
   */
163
  public boolean isPercentageSearch()
164
  {
165
    return percentageSearch;
166
  }
158 167
  /*
159 168
   * Method to get owner query. If it is owner it has all permission
160 169
   */
......
580 589
   * create a SQL serialization of the query that this instance represents
581 590
   */
582 591
  public String printSQL(boolean useXMLIndex) {
592
    
593
   
583 594
    StringBuffer self = new StringBuffer();
584 595

  
585 596
    self.append("SELECT docid,docname,doctype,");
......
647 658
      }
648 659
      self.append(") ");
649 660
    }
650
    //System.out.println(self.toString());
661
    
662
    // if there is only one percentage search item, this query is a percentage
663
    // search query
664
    if (countPercentageSearchItem ==1)
665
    {
666
      
667
      percentageSearch =true;
668
    }
669
    
651 670
    return self.toString();
652 671
  }
653 672
  
......
687 706
    self.append(")");
688 707
    self.append(" AND xml_nodes.nodetype = 'TEXT'");
689 708

  
690
    //System.out.println(self.toString());
709
   
691 710
    return self.toString();
692 711
  }
693 712
  
......
899 918
    private String searchmode = null;
900 919
    private String value = null;
901 920
    private String pathexpr = null;
921
    private boolean percentageSymbol = false;
922
   
902 923

  
903 924
    /**
904 925
     * Construct a new instance of a query term for a free text search
......
988 1009
        else
989 1010
        {
990 1011
          searchexpr = nodedataterm + " LIKE '" + casevalue + "' ";
1012
          // find percentage symbol
1013
          percentageSymbol = true;
991 1014
        }
992 1015
      } else if (searchmode.equals("equals")) {
993 1016
        //searchvalue = casevalue;
......
1060 1083
          self.append(useNestedStatements(pathexpr));
1061 1084
        }
1062 1085
      }
1086
      else
1087
      {
1088
        //if pathexpr is null and search value is %, is a percentageSearchItem
1089
        // the count number will be increase one
1090
        countPercentageSearchItem++;
1091
        
1092
       }
1063 1093

  
1064 1094
      return self.toString();
1065 1095
    }
......
1127 1157

  
1128 1158
      do {
1129 1159
        inx = path.lastIndexOf("/");
1130
//System.out.println(path.substring(inx+1));
1160

  
1131 1161
        nodes.addElement(path.substring(inx+1));
1132 1162
        path = path.substring(0, Math.abs(inx));
1133 1163
      } while ( inx > 0 );
......
1150 1180
      }
1151 1181

  
1152 1182

  
1153
//System.out.println(nestedStmts.toString());
1183

  
1154 1184
      return nestedStmts.toString();
1155 1185
    }
1156 1186

  

Also available in: Unified diff