Ignore:
Timestamp:
10/04/10 11:31:33 (14 years ago)
Author:
gaba
Message:

simple-querystring handling, collections treeview correction

Location:
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Cache.java

    r713 r745  
    128128                        e.setAttribute("collection", "");
    129129                }
    130 
    131130                if (key_array.length > 3){
    132                         e.setAttribute("startRecord", key_array[3]);
     131                        e.setAttribute("squery", key_array[3]);
     132                }else{
     133                        e.setAttribute("squery", "");
     134                }
     135                if (key_array.length > 4){
     136                        e.setAttribute("startRecord", key_array[4]);
    133137                }else{
    134138                        e.setAttribute("startRecord", "");
    135139                }
    136                 if (key_array.length > 4){
    137                         e.setAttribute("maximumRecords", key_array[4]);
     140                if (key_array.length > 5){
     141                        e.setAttribute("maximumRecords", key_array[5]);
    138142                }else{
    139143                        e.setAttribute("maximumRecords", "");
     
    186190                Query query;
    187191               
    188                 query = new Query(str,"recordset","");
     192                if (str == null) return "";
     193                if (str.trim().length() == 0) return "";
     194               
     195                query = new Query("", str,"recordset","");
    189196                if (query.isStatus(Query.PARSEERROR)) {
    190197                        Admin.notifyUser("Cache.transformQuery.PARSEERROR:" + query.getMsg());
     
    207214               
    208215                String[] key_array = key_info.split("//-");
    209                 String query_str;
    210                
    211                 Admin.notifyUser("formPATH:" + key_info);
    212                
     216                String query_str;               
    213217               
    214218                if(key_array.length > 1){
    215219                        //Admin.notifyUser("formPATH- querystring:" + key_array[1]);
    216220                        if (key_array[0].equals("recordset")){
    217                                 query_str = transformQuery(key_array[1]);       
     221                                query_str = this.transformQuery(key_array[1]); 
    218222                                Admin.notifyUser("formPATH- querystring-transformed:" + query_str);
    219223                        }
     
    233237                }
    234238                if (key_array.length > 3){
    235                         xpath_expr = xpath_expr + "and @startRecord='"+key_array[3]+"'";
     239                        xpath_expr = xpath_expr + "and @squery='"+key_array[3]+"'";
     240                }else{
     241                        xpath_expr = xpath_expr + " and @squery=''";
     242                }
     243                if (key_array.length > 4){
     244                        xpath_expr = xpath_expr + "and @startRecord='"+key_array[4]+"'";
    236245                }else{
    237246                        xpath_expr = xpath_expr + " and @startRecord=''";
    238247                }
    239                 if (key_array.length > 4){
    240                         xpath_expr = xpath_expr + "and @maximumRecords='"+key_array[4]+"']";
     248                if (key_array.length > 5){
     249                        xpath_expr = xpath_expr + "and @maximumRecords='"+key_array[5]+"']";
    241250                }else{
    242251                        xpath_expr = xpath_expr + " and @maximumRecords='']";
     
    259268                        path = cachepath + PREFIX + key_array[0] + "_"+id + ".xml";
    260269                }  else if (list.getLength() > 1){
    261                         //Admin.notifyUser("formPath:!!!:multiple paths:"+key_info);
     270                        Admin.notifyUser("formPath ERROR:!!!:multiple paths:"+key_info);
    262271                       
    263272                }
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java

    r713 r745  
    3030        private String actionkey;
    3131        private String q;
     32        private String squery;
    3233        private String cache = Cache.USE;
    3334        private String collection;
     
    4950        }
    5051
     52        public String getSquery() {
     53                return squery;
     54        }
     55
     56        public void setSquery(String squery) {
     57                this.squery = squery;
     58        }
     59       
    5160        public String getCache() {
    5261                return cache;
     
    119128        }
    120129       
     130
    121131        public String getFullFormat() {         
    122132                return actionkey + "2" + format;
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDRepoProxyAction.java

    r713 r745  
    5252                        if (getQ()!=null) {
    5353                                key += getQ() + "//-" ;
     54                        } else {
     55                                key +="//-" ;
    5456                        }
    5557                        if (getCollection()!=null) {
    5658                                key += getCollection() + "//-";
     59                        } else {
     60                                key +="//-" ;
     61                        }
     62                        if (getSquery()!=null) {
     63                                key += getSquery() + "//-" ;
     64                        } else {
     65                                key +="//-" ;
    5766                        }
    5867                        if (getStartRecord()!=null) {
     
    7382        // URL targetURL =new URL( base_url, compname + ".xml");
    7483               
    75                 Admin.notifyUser("MDRPA.getQ:" + getQ());
     84                Admin.notifyUser("MDRPA.getQ:" + getSquery() + " and (" +  getQ() + ")");
    7685                Admin.notifyUser("MDRPA.getActionkey:" + getActionkey());
    7786                Admin.notifyUser("MDRPA.getMaxdepth:" + getMaxdepth());
    7887               
    79                 Query query = new Query(getQ(),getActionkey());
     88                Query query = new Query(getSquery(), getQ(),getActionkey());
    8089                if (query.isStatus(Query.PARSEERROR)) {
    8190                        Admin.notifyUser("MDRPA.query.PARSEERROR:" + query.getMsg());
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDTransformer.java

    r706 r745  
    209209                }
    210210                //
    211                
    212211                StreamSource src =new StreamSource();                   
    213212                src.setInputStream(in);
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/model/Query.java

    r706 r745  
    2929        public static String COLLECTIONS = "collections";
    3030        public static String COLUMNS = "columns";
    31         public static String startRecord = null;
    32         public static String maximumRecords = null;
    3331        public static String MODEL = "model";
    3432        public static String RECORDSET = "recordset";
     
    4745        private URL targetRequest;
    4846        private String syntax = "cql";  /* cql, cmdIndex, xpath */
     47        private String squery_string;
    4948        private String query_string;
    5049        private CQLNode query_cql;
     
    5554        private String collection="olac";
    5655        private String columns="Id,name";
     56        private String startRecord = null;
     57        private String maximumRecords = null;
     58        private String squery = null;
    5759        private int maxdepth=1;
    5860       
     
    6365
    6466       
    65         public Query(String queryString) {             
    66                 this(queryString, MODEL);
     67        public Query(String squeryString, String queryString) {         
     68                this(squeryString, queryString, MODEL);
    6769        }
    6870
     
    7476         */
    7577
    76         public Query(String queryString, String type, String collection, String columns) {
     78        public Query(String squeryString,String queryString, String type, String collection, String columns) {
    7779                this.type =type;
    78                 setQueryString(queryString);
     80                setQueryString(squeryString, queryString);
    7981                setCollection(collection);
    8082                setColumns(columns);
     
    8890         */
    8991
    90         public Query(String queryString, String type, String collection) {
     92        public Query(String squeryString, String queryString, String type, String collection) {
    9193                this.type =type;
    92                 setQueryString(queryString);
     94                setQueryString(squeryString, queryString);
    9395                setCollection(collection);
    9496        }
     
    101103         */
    102104
    103         public Query(String queryString, String type) {
    104        
     105        public Query(String squeryString, String queryString, String type) {
    105106                this.type =type;
    106                 setQueryString(queryString);
     107                setQueryString(squeryString, queryString);
    107108        }
    108109
     
    132133        }
    133134
    134         public void setQueryString(String queryString) {
    135                 query_string = queryString;
    136                 if (type.equals(RECORDSET)) {
    137                        
    138                        
     135        public void setQueryString(String squeryString, String queryString) {
     136                if (squeryString.trim().length() == 0){
     137                        squeryString = null;
     138                }
     139                if (queryString.trim().length() == 0){
     140                        queryString = null;
     141                }
     142                String squery = createsqueryString(squeryString);
     143                if (squery != null && queryString != null){
     144                        query_string = "(" + squery + " ) and (" + queryString + ")";
     145                } else if (squery != null) {
     146                        query_string = squery;
     147                } else {
     148                        query_string = queryString;
     149                }
     150                Admin.notifyUser("QUERY.QUERYSTRING:" + query_string);
     151                if (type.equals(RECORDSET)) {   
    139152                        parse();
    140153                        //preprocess();
     
    163176        }
    164177
     178        public String getSQuery() {
     179                return this.squery;
     180        }
     181       
     182        public void setSQuery(String squery) {
     183                if (squery!=null) {
     184                        this.squery = squery;
     185                }
     186        }
     187       
    165188        public String getStartRecord() {
    166189                return startRecord;
     
    209232        }
    210233
     234        // apply rules form squery
     235        public String createsqueryString (String _squery){
     236                String sq = null;
     237               
     238                if (_squery !=null){
     239                        sq = "* any " + _squery;
     240                }
     241
     242                return sq;
     243        }
    211244        public String getSimpleQueryString() {
    212245                String[] arr_and = query_string.split(" and ");
     
    236269                                simple_form = simple_form + rel + arr_or[j];
    237270                        }
    238                         Admin.notifyUser(simple_form);
     271                        //Admin.notifyUser(simple_form);
    239272                        if (arr_or.length > 1){
    240273                                simple_form = "(" + simple_form + ") ";
Note: See TracChangeset for help on using the changeset viewer.