Changeset 1467 for MDService2/trunk


Ignore:
Timestamp:
07/22/11 21:31:08 (13 years ago)
Author:
gaba
Message:

SRU queries added

Location:
MDService2/trunk/MDService2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • MDService2/trunk/MDService2/WebContent/index.jsp

    r1435 r1467  
    2828<script src="scripts/jquery/jquery-layout/jquery.layout-1.3.0.rc29.12.js" type="text/javascript"></script>
    2929<script src="scripts/mdservice_ui_settings.js" type="text/javascript"></script>
     30<script src="scripts/pz2.js" type="text/javascript"></script>
    3031<script src="scripts/mdservice_helpers.js" type="text/javascript"></script>
    3132<script src="scripts/mdservice_ui_helpers.js" type="text/javascript"></script>
     
    3334<script src="scripts/mdservice_searchclause.js" type="text/javascript"></script>
    3435<script src="scripts/mdservice_model.js" type="text/javascript"></script>
     36<script src="scripts/mdservice_pazpar.js" type="text/javascript"></script>
    3537<script src="scripts/mdservice_ui_detail.js" type="text/javascript"></script>
    3638<script src="scripts/mdservice_ui_load.js" type="text/javascript"></script>
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js

    r1435 r1467  
    107107        //this.user_json["WorkspaceProfile"]["Querysets"][id] = {"name":name, "id":0, "created":str_time , "Queries" : "null"};
    108108       
     109};
     110Workspace.prototype.getRepositoryType = function(repository){
     111        var reptype = "";
     112        $.each(workspace.server_json["WorkspaceProfile"]["Repositories"], function(i,item){
     113                if (item.name==repository){
     114                        reptype=item.type;
     115                }
     116        });
     117        return reptype;
    109118};
    110119/*
     
    306315        // repository
    307316        this.repository = 1;
     317        //this.reptype =
    308318        this.options = null;
    309319        this.time_created = null;
     
    865875};
    866876 Query.prototype.submit = function () {
    867                 var uri = link('recordset',this.format, this.query_uri());
     877               
     878                var uri;
     879               
     880                var reptype = workspace.getRepositoryType(this.repository);
     881                if (reptype=="pazpar"){
     882                        //pazpar handling this
     883                        pazparsubmit(this);
     884                        return;
     885                }
     886                if (reptype=="md" ){
     887                        uri = link('recordset',this.format, this.query_uri());
     888                } else {
     889                        if (reptype=="sru"){
     890                                uri = link('sru', this.format, this.sruquery_uri());
     891                        } else {
     892                                return;
     893                        }
     894                }
     895
     896               
    868897                var query = this;
    869                
    870898                notifyUser("submitting query:" +  uri);
    871899                this.container.find('.result').load( uri, function() {
     
    893921Query.prototype.resubmit = function () {
    894922       
    895         var uri = link('recordset',this.format, this.query_uri());
     923        var uri;// = link('recordset',this.format, this.query_uri());
     924        var reptype = workspace.getRepositoryType(this.repository);
     925        if (reptype=="pazpar"){
     926                //pazpar handling this
     927                return;
     928        }
     929        if (reptype=="md" ){
     930                uri = link('recordset',this.format, this.query_uri());
     931        } else {
     932                if (reptype=="sru"){
     933                        uri = link('sru', this.format, this.sruquery_uri());
     934                } else {
     935                        return;
     936                }
     937        }
    896938        var qid = this.listid;
    897         var q_uri = this.query_uri();
     939        //var q_uri = this.query_uri();
    898940        var query = this;
    899941       
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_load.js

    r1435 r1467  
    223223       
    224224        $select.change(function(data){
    225                 loadCollections(false);                         
    226                 loadTerms();
    227                 loadTermsAutocomplete();
    228                 $('#model_profiles').load(link('terms','htmlselect',actions.terms.current) + '?repository=' + getSelectedRepository());
     225                if (workspace.getRepositoryType(getSelectedRepository())=='md'){
     226                        loadCollections(false);                         
     227                        loadTerms();
     228                        loadTermsAutocomplete();
     229                        $('#model_profiles').load(link('terms','htmlselect',actions.terms.current) + '?repository=' + getSelectedRepository());
     230
     231                }
    229232        });
    230233       
  • MDService2/trunk/MDService2/WorkspaceProfile.xml

    r1436 r1467  
    22<Profiles>
    33   <Querycounter>
    4       <maxqid>6</maxqid>
    5       <maxbid>3</maxbid>
    6       <maxqsid>2</maxqsid>
    7       <maxbsid>2</maxbsid>
     4          <maxid>31</maxid>
    85   </Querycounter>
    96   <WorkspaceProfiles>
     
    129                   <item>
    1310               <name>clarin.at-mirror</name>   
    14                <id>1</id>
     11               <id>2</id>
     12               <type>md</type>
    1513               <uri>http://clarin.aac.ac.at/exist/rest/db/clarin/cmd-model.xql/</uri>
    1614            </item>
    17             <item>
     15                   <item>
    1816               <name>gu.se-main</name>   
    19                <id>2</id>
     17               <id>1</id>
     18               <type>md</type>
    2019               <uri>http://demo.spraakdata.gu.se/clarin/cmd/model/stats/</uri>
     20            </item>
     21            <item>
     22               <name>sru-corpus-ddcon</name>   
     23               <id>3</id>
     24               <type>sru</type>
     25               <uri>http://corpus3.aac.ac.at/ddconsru</uri>
     26            </item>
     27            <item>
     28               <name>sru-cqlservlet</name>   
     29               <id>4</id>
     30               <type>sru</type>
     31               <uri>http://cqlservlet.mpi.nl/</uri>
     32            </item>
     33            <item>
     34               <name>sru-gutenberg</name>   
     35               <id>5</id>
     36               <type>sru</type>
     37               <uri>http://opencontent.indexdata.com/gutenberg</uri>
     38            </item>
     39            <item>
     40               <name>pazpar</name>   
     41               <id>6</id>
     42               <type>pazpar</type>
     43               <uri>http://clarin.aac.ac.at/pazpar2/</uri>
    2144            </item>
    2245                </Repositories>
     
    86109                <username>a</username>
    87110      </WorkspaceProfile>
    88        
     111     
     112     
     113     
     114     
     115     
     116     
     117     
    89118      <WorkspaceProfile user="default">
    90119         <Bookmarksets>
     
    95124                     <collections>null</collections>
    96125                     <columns>null</columns>
    97                      <id>2</id>
    98                      <maximumItems>10</maximumItems>
    99                      <name>C4_transl:8?repository=clarin.at-mirror</name>
    100                      <options null="true"/>
    101                      <querystring>clarin-at%3Aaac-test-corpus%3AC4_transl%3A8?repository=clarin.at-mirror</querystring>
     126                     <id>31</id>
     127                     <maximumItems>10</maximumItems>
     128                     <name>lrt:2787?repository=clarin.at-mirror</name>
     129                     <options null="true"/>
     130                     <querystring>clarin%252Eeu%3Alrt%3A2787?repository=clarin.at-mirror</querystring>
    102131                     <searchclauses>null</searchclauses>
    103132                     <squerystring null="true"/>
    104133                     <startItem>1</startItem>
    105                      <time>2011-06-05 16:10:04</time>
    106                      <vcrid>0</vcrid>
    107                   </item>
     134                     <time>2011-06-05 23:22:33</time>
     135                     <vcrid>0</vcrid>
     136                  </item>
     137               </Bookmarks>
     138               <created>2011-06-05 23:16:57</created>
     139               <id>25</id>
     140               <name>book1</name>
     141               <vcrid>40</vcrid>
     142            </item>
     143            <item>
     144               <Bookmarks>
    108145                  <item>
    109146                     <bookmark>1</bookmark>
    110147                     <collections>null</collections>
    111148                     <columns>null</columns>
    112                      <id>3</id>
    113                      <maximumItems>10</maximumItems>
    114                      <name>theater:3?repository=clarin.at-mirror</name>
    115                      <options null="true"/>
    116                      <querystring>clarin-at%3Aaac-test-corpus%3Atheater%3A3?repository=clarin.at-mirror</querystring>
     149                     <id>28</id>
     150                     <maximumItems>10</maximumItems>
     151                     <name>C4:220?repository=clarin.at-mirror</name>
     152                     <options null="true"/>
     153                     <querystring>clarin-at%3Aaac-test-corpus%3AC4%3A220?repository=clarin.at-mirror</querystring>
    117154                     <searchclauses>null</searchclauses>
    118155                     <squerystring null="true"/>
    119156                     <startItem>1</startItem>
    120                      <time>2011-06-05 16:19:05</time>
     157                     <time>2011-06-05 23:18:28</time>
    121158                     <vcrid>0</vcrid>
    122159                  </item>
    123160               </Bookmarks>
    124                <created>2011-06-05 16:016:56</created>
    125                <id>2</id>
    126                <name>new_bookmarkset</name>
     161               <created>2011-06-05 23:17:10</created>
     162               <id>26</id>
     163               <name>book2</name>
     164               <vcrid>0</vcrid>
     165            </item>
     166            <item>
     167               <Bookmarks>null</Bookmarks>
     168               <created>2011-06-05 23:18:04</created>
     169               <id>27</id>
     170               <name>book33</name>
     171               <vcrid>0</vcrid>
    127172            </item>
    128173         </Bookmarksets>
     
    135180                     <collections>null</collections>
    136181                     <columns>null</columns>
    137                      <id>2</id>
    138                      <maximumItems>10</maximumItems>
    139                      <name>clarin-at:aac-test-corpus..| </name>
    140                      <options null="true"/>
    141                      <querystring>clarin-at%3Aaac-test-corpus%3AC4_transl%3A8?repository=clarin.at-mirror</querystring>
    142                      <searchclauses>null</searchclauses>
    143                      <squerystring null="true"/>
    144                      <startItem>1</startItem>
    145                      <time>2011-06-05 16:18:37</time>
    146                      <vcrid>30</vcrid>
    147                   </item>
    148                   <item>
    149                      <bookmark>0</bookmark>
    150                      <collections>null</collections>
    151                      <columns>
    152                         <item>title</item>
    153                         <item>publisher</item>
    154                         <item>author</item>
    155                      </columns>
    156                      <id>4</id>
    157                      <maximumItems>10</maximumItems>
    158                      <name>title contains a and  tei..| </name>
    159                      <options null="true"/>
    160                      <querystring>(title contains a)  and ( tei:imprint.date &gt; 1910) and (tei:imprint.date &lt; 1920)</querystring>
    161                      <searchclauses>null</searchclauses>
    162                      <squerystring null="true"/>
    163                      <startItem>1</startItem>
    164                      <time>2011-06-05 16:17:30</time>
    165                      <vcrid>0</vcrid>
    166                   </item>
    167                   <item>
    168                      <bookmark>0</bookmark>
    169                      <collections>null</collections>
    170                      <columns>
    171                         <item>title</item>
    172                         <item>publisher</item>
    173                         <item>author</item>
    174                      </columns>
    175                      <id>5</id>
    176                      <maximumItems>10</maximumItems>
    177                      <name>title contains a and  tei..| </name>
    178                      <options null="true"/>
    179                      <querystring>(title contains a)  and ( tei:imprint.date &gt; 1910) and (tei:imprint.date &lt; 1920)</querystring>
    180                      <searchclauses>null</searchclauses>
    181                      <squerystring null="true"/>
    182                      <startItem>1</startItem>
    183                      <time>2011-06-05 16:17:55</time>
    184                      <vcrid>0</vcrid>
    185                   </item>
    186                   <item>
    187                      <bookmark>0</bookmark>
    188                      <collections>null</collections>
    189                      <columns>
    190                         <item>title</item>
    191                         <item>publisher</item>
    192                         <item>author</item>
    193                      </columns>
    194                      <id>6</id>
    195                      <maximumItems>10</maximumItems>
    196                      <name>title contains a and  tei..| </name>
    197                      <options null="true"/>
    198                      <querystring>(title contains a)  and ( tei:imprint.date &gt; 1910) and (tei:imprint.date &lt; 1920)</querystring>
    199                      <searchclauses>null</searchclauses>
    200                      <squerystring null="true"/>
    201                      <startItem>1</startItem>
    202                      <time>2011-06-05 16:42:03</time>
     182                     <id>20</id>
     183                     <maximumItems>10</maximumItems>
     184                     <name>schule                     | </name>
     185                     <options null="true"/>
     186                     <querystring null="true"/>
     187                     <searchclauses>null</searchclauses>
     188                     <squerystring>schule</squerystring>
     189                     <startItem>1</startItem>
     190                     <time>2011-06-05 22:49:20</time>
     191                     <vcrid>0</vcrid>
     192                  </item>
     193                  <item>
     194                     <bookmark>0</bookmark>
     195                     <collections>null</collections>
     196                     <columns>null</columns>
     197                     <id>21</id>
     198                     <maximumItems>10</maximumItems>
     199                     <name>machine                    | </name>
     200                     <options null="true"/>
     201                     <querystring null="true"/>
     202                     <searchclauses>null</searchclauses>
     203                     <squerystring>machine</squerystring>
     204                     <startItem>1</startItem>
     205                     <time>2011-06-05 23:023:58</time>
    203206                     <vcrid>0</vcrid>
    204207                  </item>
    205208               </Queries>
    206                <created>2011-06-05 16:016:42</created>
    207                <id>2</id>
    208                <name>new_queryset</name>
     209               <created>2011-06-05 22:46:29</created>
     210               <id>17</id>
     211               <name>qset0</name>
     212            </item>
     213            <item>
     214               <Queries>
     215                  <item>
     216                     <bookmark>0</bookmark>
     217                     <collections>null</collections>
     218                     <columns>null</columns>
     219                     <id>22</id>
     220                     <maximumItems>10</maximumItems>
     221                     <name>mar                        | </name>
     222                     <options null="true"/>
     223                     <querystring null="true"/>
     224                     <searchclauses>null</searchclauses>
     225                     <squerystring>mar</squerystring>
     226                     <startItem>1</startItem>
     227                     <time>2011-06-05 23:023:31</time>
     228                     <vcrid>0</vcrid>
     229                  </item>
     230                  <item>
     231                     <bookmark>0</bookmark>
     232                     <collections>null</collections>
     233                     <columns>null</columns>
     234                     <id>23</id>
     235                     <maximumItems>10</maximumItems>
     236                     <name>januar                     | </name>
     237                     <options null="true"/>
     238                     <querystring null="true"/>
     239                     <searchclauses>null</searchclauses>
     240                     <squerystring>januar</squerystring>
     241                     <startItem>1</startItem>
     242                     <time>2011-06-05 23:15:59</time>
     243                     <vcrid>0</vcrid>
     244                  </item>
     245               </Queries>
     246               <created>2011-06-05 22:46:29</created>
     247               <id>18</id>
     248               <name>qset1</name>
     249            </item>
     250            <item>
     251               <Queries>
     252                  <item>
     253                     <bookmark>0</bookmark>
     254                     <collections>null</collections>
     255                     <columns>null</columns>
     256                     <id>24</id>
     257                     <maximumItems>10</maximumItems>
     258                     <name>januar                     | </name>
     259                     <options null="true"/>
     260                     <querystring null="true"/>
     261                     <searchclauses>null</searchclauses>
     262                     <squerystring>januar</squerystring>
     263                     <startItem>1</startItem>
     264                     <time>2011-06-05 23:16:33</time>
     265                     <vcrid>0</vcrid>
     266                  </item>
     267               </Queries>
     268               <created>2011-06-05 22:48:10</created>
     269               <id>19</id>
     270               <name>qset2</name>
    209271            </item>
    210272         </Querysets>
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java

    r1455 r1467  
    525525        public Boolean isSRURepository(){
    526526                //Boolean issru = false;
    527                 String srustr = "";
     527                String typestr = "";
    528528               
    529529                if (repositories == null ) {
     
    545545                for(int i=0;i<json.size();i++){
    546546                        if (json.getJSONObject(i).getString("name").equals(getRepository())){
    547                                 srustr =  json.getJSONObject(i).getString("sruextern");
    548                         }
    549                 }
    550                
    551                 return (srustr.equals("1"));
     547                                typestr =  json.getJSONObject(i).getString("type");
     548                        }
     549                }
     550               
     551                return (typestr.equals("sru"));
    552552               
    553553        }
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/SRUProxyAction.java

    r1455 r1467  
    5353
    5454
    55 public class SRUProxyAction extends ActionSupport
    56 implements ServletRequestAware
     55public class SRUProxyAction extends GenericProxyAction//ActionSupport
     56//implements ServletRequestAware
    5757{
    5858
     
    8282        private MDRepoProxyAction mdrepoproxyaction;
    8383        private TermsProxyAction termsproxyaction;
    84         private InputStream resultStream;
    85         private HttpServletRequest request;
     84        //private InputStream resultStream;
     85        //private HttpServletRequest request;
    8686       
    8787        private static int OP_SEARCHRETRIEVE = 1;
    8888        private static int OP_EXPLAIN = 2;
    8989        private static int OP_SCAN = 3;
     90       
     91        //TODO cache after analysis
     92        @Override
     93        public String getCache() {
     94                return Cache.SKIP;
     95        }
    9096       
    9197        private final static HashMap<String,String> hash_operations = new HashMap<String,String>();
     
    116122         }
    117123         
    118          @Override
     124         /*@Override
    119125                public void setServletRequest(HttpServletRequest arg0) {
    120126                        request = arg0;
     
    124130                        return request;
    125131                }
    126                
     132                */
    127133                public Diagnostics getDiagnostics(){
    128134                        return this.diagnostics;
     
    141147                        this.q = q;
    142148                }
    143          
     149         /*
    144150         public InputStream getResultStream() {
    145151             return resultStream;
     
    148154                resultStream = _resultStream;
    149155         }
    150        
     156        */
    151157
    152158        public String getVersion() {
     
    264270       
    265271        public String getDiagnosticStreamName() throws TransformerConfigurationException, UnsupportedEncodingException, ParserConfigurationException, TransformerException, TransformerFactoryConfigurationError{
    266                 resultStream = this.Diagnostics().buildXMLStream();
     272                this.setResultStream(this.Diagnostics().buildXMLStream());
    267273                return "resultStream";
    268274        }
     
    275281        public String getProxyKey() {
    276282                return "";
     283        }
     284       
     285        @Override
     286        public String getBaseURI() {           
     287                Admin.notifyUser("SRU-repositorypath:" + getRepositoryPath());
     288                String uri = getRepositoryPath();//Admin.getConfig().getProperty(getProxyKey() + ".uri");               
     289                return uri;
    277290        }
    278291       
     
    346359                                                                XMLSerializer xmlserializer = new XMLSerializer();
    347360                                                                String xml = xmlserializer.write( mdrepoproxyaction.getRepositories() ); 
    348                                                                 resultStream = new ByteArrayInputStream(xml.getBytes("UTF-8"));
     361                                                                this.setResultStream(new ByteArrayInputStream(xml.getBytes("UTF-8")));
    349362
    350363                                                        } else {
     
    359372        }
    360373       
    361         public void prepare() throws UnsupportedEncodingException{
     374        public void sru2MD() throws UnsupportedEncodingException{
    362375                // special handling of parameter setting, x-cmd-... not alowed in java
    363376                this.setX_cmd_collections(getServletRequest().getParameter("x-cmd-collections"));
     
    393406        }
    394407       
     408        public void  prepareMD() throws Exception{
     409                sru2MD();
     410                if (Diagnostics().Accepted()){
     411                        // root-explain
     412                        if (this.termsproxyaction != null) {                   
     413                                if (this.termsproxyaction.execute() == SUCCESS){
     414                                        this.setResultStream(this.termsproxyaction.getResultStream());
     415                                        //return SUCCESS;
     416                                }
     417                        } else {
     418                                //TODO diagnostic                       
     419                                if (this.mdrepoproxyaction.getTargetRequest() == null) {
     420                                        Diagnostics().Add(Diagnostic.QUERYSYNTAXERROR);
     421                                        //return ERROR;
     422                                }
     423                                if (this.mdrepoproxyaction.execute() == SUCCESS){
     424                                        this.setResultStream(this.mdrepoproxyaction.getResultStream());
     425                                        postprocess();
     426                                        //return SUCCESS;
     427                                }
     428                        }
     429                }
     430                //return ERROR;
     431        }
     432       
    395433        public static String inputStreamAsString(InputStream stream)
    396434                throws IOException {
     
    435473                        if (this.getRecordPacking().toLowerCase().equals("string")){
    436474                                try {
    437                                         resultStream = IOUtils.toInputStream(StringEscapeUtils.escapeXml(inputStreamAsString(resultStream)));
     475                                        this.setResultStream(IOUtils.toInputStream(StringEscapeUtils.escapeXml(inputStreamAsString(this.getResultStream()))));
    438476                                } catch (IOException e) {
    439477                                        // TODO Auto-generated catch block
     
    446484                // add diagnostics
    447485                if (Diagnostics().Exists()){
    448                         Document doc = newDocumentFromInputStream(resultStream);
     486                        Document doc = newDocumentFromInputStream(this.getResultStream());
    449487                        Node r_element=  doc.getElementsByTagName("searchRetrieveResponse").item(0);
    450488                        Document ddoc = Diagnostics().buildXMLDocument();
     
    456494                        StreamResult result = new StreamResult(xmlAsWriter);   
    457495                        TransformerFactory.newInstance().newTransformer().transform(source, result);
    458                         resultStream = new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8"));
    459                 }
    460         }
    461        
     496                        this.setResultStream(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")));
     497                }
     498        }
     499       
     500        @Override
     501        public URL getTargetRequest() throws IOException {
     502                String requestURI = "";
     503                URL targetURL;
     504               
     505                if (this.getBaseURI() == null){
     506                        requestURI = this.getX_cmd_repository();
     507                } else {
     508                        requestURI = this.getBaseURI();
     509                }
     510                //TODO params
     511                Set set = getServletRequest().getParameterMap().entrySet();
     512                Iterator i = set.iterator();
     513                String params = "";
     514            while(i.hasNext()){
     515                      Map.Entry me = (Map.Entry)i.next();
     516                      if (!(me.getKey().equals("x-cmd-repository") || me.getKey().equals("x-cmd-collections"))){
     517                              params = params + "&" + me.getKey() + "=" + ((String[])me.getValue())[0]; 
     518                      }
     519                }
     520            params = params.substring(1);
     521            targetURL = new URL(requestURI + "?" + params);
     522                return targetURL;
     523        }
     524       
     525        @Override
     526        public void prepare() throws Exception{
     527                this.setX_cmd_repository(getServletRequest().getParameter("x-cmd-repository"));
     528                this.setRepository(this.getX_cmd_repository());
     529                //TODO xsl usage according particular repositories ?
     530                //this.setActionkey("recordset");
     531                this.setFormat("xml");
     532               
     533                //extern SRU repository
     534                if (this.isSRURepository() || this.getBaseURI() == null){
     535                        super.prepare();
     536                }
     537                else {
     538                         prepareMD();
     539                }
     540               
     541        }
    462542        /**
    463543         * default Action method
    464544         */
     545        /*
    465546        public String execute() throws Exception {
    466547                this.setX_cmd_repository(getServletRequest().getParameter("x-cmd-repository"));
     
    514595                return ERROR;
    515596        }
    516 
     597*/
    517598
    518599}
  • MDService2/trunk/MDService2/src/struts.xml

    r1350 r1467  
    251251                </action>
    252252               
     253                <action name="sru/*/*" class="eu.clarin.cmdi.mdservice.action.SRUProxyAction" method="execute">
     254                           <param name="format">{1}</param>
     255                           <param name="q">{2}</param>
     256                           <result name="success" type="stream">                               
     257                                <param name="contentType">text/xml</param>
     258                                <param name="inputName">resultStream</param>                           
     259                            </result>
     260                            <result name="error" type="stream">                       
     261                                <param name="contentType">text/xml</param>
     262                                <param name="inputName">${getDiagnosticStreamName()}</param>                           
     263                            </result>
     264                </action>
     265               
    253266                <!-- <action name="*/*" class="eu.clarin.cmdi.mdservice.action.MDServiceAction" method="{2}">   -->
    254267                <action name="*/*" class="eu.clarin.cmdi.mdservice.action.MDRepoProxyAction" method="execute">
Note: See TracChangeset for help on using the changeset viewer.