Changeset 1800 for MDService2


Ignore:
Timestamp:
03/17/12 21:11:31 (12 years ago)
Author:
gaba
Message:

FCS first version

Location:
MDService2/branches/MDService_simple3
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • MDService2/branches/MDService_simple3/WebContent/scripts/mdservice_searchclause.js

    r1681 r1800  
    704704                        var j = $('.focused','#searchclauselist').closest('.sc-j').attr("id");
    705705                        //alert(i+ ',' + j + sValue);
    706                         searchclauseset.searchclauses[i][j].index = e.value;
     706                        var termsetitem = $('#' + 'sc' +  i + '-' + j).find('.index-input-termset').data('item');
     707                        var termset = "";
     708                        if (termsetitem != null) termset = termsetitem.key;
     709                        searchclauseset.searchclauses[i][j].index = termset + ":" +  e.value;
    707710                       
    708711                        //handleTermsSelection(i,j,sValue);             
  • MDService2/branches/MDService_simple3/WorkspaceProfile.xml

    r1638 r1800  
    66   <WorkspaceProfiles>
    77      <WorkspaceProfile user="server">
    8                 <Repositories>
     8      <Repositories>
     9      <!--
     10      <styles>
     11      <style operation="searchRetrieve">http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     12      <style operation="scan">http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/scan2view.xsl</style>
     13      <style operation="explain">http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/explain2view.xsl</style>
     14      <style operation="default">http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/xml2view.xsl</style>
     15   </styles>
     16       -->
     17   
     18   <item>
     19      <name>arz_eng_006</name>
     20      <label>VICAV dictionary Cairo-dialect</label>
     21      <id>1</id>
     22      <type>fcs</type>
     23      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     24      <uri>http://corpus3.aac.ac.at/cs2/corpus_shell/fcs/wrapper/php/GlossaryOnSRU.php</uri>
     25   </item>
     26   <item>
     27      <name>apc_eng_002</name>
     28      <label>VICAV dictionary Damascus-dialect</label>
     29      <id>2</id>
     30      <type>fcs</type>
     31      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     32      <uri>http://corpus3.aac.ac.at/cs2/corpus_shell/fcs/wrapper/php/GlossaryOnSRU.php</uri>
     33   </item>
     34   <item>
     35      <name>deu_wikt_002</name>
     36      <label>Wiktionary</label>
     37      <id>3</id>
     38      <type>fcs</type>
     39      <!-- <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/wiktionary.xsl</style> -->
     40      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     41      <uri>http://corpus3.aac.ac.at/cs2/corpus_shell/fcs/wrapper/php/WiktionaryOnSRU.php</uri>
     42   </item>
     43   <item>
     44      <name>clarin.at:icltt:ddc</name>
     45      <label>DDC on Corpus3</label>
     46      <id>4</id>
     47      <type>fcs.resource</type>
     48      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     49      <uri>http://corpus3.aac.ac.at/ddconsru</uri>
     50   </item>
     51<!--
     52   <item>
     53      <name>sru-corpus-ddcon</name>
     54      <label></label>
     55      <id>4</id>
     56      <type>fcs</type>
     57      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/ddckwic.xsl</style>
     58      <uri>http://corpus3.aac.ac.at/ddconsru</uri>
     59   </item>
     60-->
     61   <!--<item>
     62      <name>sru-cqlservlet</name>
     63      <label></label><id>5</id>
     64      <type>sru</type>
     65      <style>http://clarin.aac.ac.at/exist7/rest/db/content_repository/scripts/http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/mdset2view.xsl</style>
     66      <uri>http://cqlservlet.mpi.nl/</uri>
     67   </item> -->
     68   <item>
     69      <name>sru-gutenberg</name>
     70      <label>Gutenberg Metadata</label>
     71      <id>6</id>
     72      <type>sru</type>
     73      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     74      <uri>http://opencontent.indexdata.com/gutenberg</uri>
     75   </item>
     76   <item>
     77      <name>vicav-profile</name>
     78      <label>VICAV Profile</label>
     79      <id>7</id>
     80      <type>fcs</type>
     81      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/profile.xsl</style>
     82      <uri>http://corpus3.aac.ac.at/cs2/corpus_shell/fcs/wrapper/php/ProfileOnSRU.php</uri>
     83   </item>
     84<item>
     85      <name>vicav-bib</name>
     86      <label>VICAV Bibliography</label>
     87      <id>8</id>
     88      <type>fcs</type>
     89      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/bibliography.xsl</style>
     90      <uri>http://corpus3.aac.ac.at/cs2/corpus_shell/fcs/wrapper/php/BibliographyOnSRU.php</uri>
     91   </item>
     92<item>
     93      <name>vicav-text</name>
     94      <label>VICAV Sampletexte</label>
     95      <id>9</id>
     96      <type>fcs</type>
     97      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/profilesampletext.xsl</style>
     98      <uri>http://corpus3.aac.ac.at/cs2/corpus_shell/fcs/wrapper/php/SampleTextOnSRU.php</uri>
     99   </item>
     100<item>
     101      <name>ids-goethe</name>
     102      <label>IDS Goethe</label>
     103      <id>10</id>
     104      <type>fcs</type>
     105      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     106      <uri>http://clarin.ids-mannheim.de/cosmassru</uri>
     107   </item>
     108<item>
     109      <name>arz_eng_006_newStyle</name>
     110      <label>VICAV dictionary Cairo-dialect newStyle</label>
     111      <id>11</id>
     112      <type>fcs</type>
     113      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     114      <uri>http://corpus3.aac.ac.at/cs2/corpus_shell/fcs/wrapper/php/GlossaryOnSRU.php</uri>
     115   </item>
     116   <item>
     117      <name>clarin.at:icltt:cr</name>
     118      <label>ICLTT Content Repository</label>
     119      <id>12</id>
     120      <type>fcs.resource</type>
     121      <style>http://corpus3.aac.ac.at/cs2/corpus_shell/xsl/result2view_v1.xsl</style>
     122      <uri>http://clarin.aac.ac.at/exist8/rest/db/cr/cr.xql</uri>
     123   </item>
     124
    9125                   <item>
    10126               <name>clarin.at-mirror</name>   
    11                <id>2</id>
     127               <id>52</id>
    12128               <type>md</type>
    13129               <uri>http://clarin.aac.ac.at/exist/rest/db/clarin/cmd-model.xql/</uri>
     
    15131                   <item>
    16132               <name>gu.se-main</name>   
    17                <id>1</id>
     133               <id>51</id>
    18134               <type>md</type>
    19135               <uri>http://demo.spraakdata.gu.se/clarin/cmd/model/stats/</uri>
     
    22138            <item>
    23139               <name>sru-corpus-ddcon</name>   
    24                <id>3</id>
     140               <id>53</id>
    25141               <type>sru</type>
    26142               <uri>http://corpus3.aac.ac.at/ddconsru</uri>
     
    28144            <item>
    29145               <name>sru-cqlservlet</name>   
    30                <id>4</id>
     146               <id>54</id>
    31147               <type>sru</type>
    32148               <uri>http://cqlservlet.mpi.nl/</uri>
     
    34150            <item>
    35151               <name>sru-gutenberg</name>   
    36                <id>5</id>
     152               <id>55</id>
    37153               <type>sru</type>
    38154               <uri>http://opencontent.indexdata.com/gutenberg</uri>
     
    40156            <item>
    41157               <name>pazpar</name>   
    42                <id>6</id>
     158               <id>56</id>
    43159               <type>pazpar</type>
    44160               <uri>http://clarin.aac.ac.at/pazpar2/search.pz2/</uri>
    45161            </item>
    46162            <item>
    47                <name>clarin.at-cr</name>   
    48                <id>8</id>
     163               <name>clarin.at-cr-sru</name>   
     164               <id>58</id>
    49165               <type>sru</type>
    50166               <uri>http://clarin.aac.ac.at/exist7/rest/db/content_repository/scripts/cr.xql/</uri>
    51167            </item>
    52                 </Repositories>
     168            <item>
     169               <name>clarin.at-cr</name>   
     170               <id>59</id>
     171               <type>fcs</type>
     172               <uri>http://clarin.aac.ac.at/cr/</uri>
     173            </item>
     174      </Repositories>
     175
    53176                <Termsets>
    54177            <item>
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java

    r1663 r1800  
    5858        private InputStream sourceStream;
    5959       
    60         private Map<String,String[]> params;
     60        protected Map<String,String[]> params;
    6161       
    6262        private ProxyInterface target_proxy;
     
    208208                //configure
    209209                Utils.loadConfig("mdservice", "mdservice.properties", this.getClass().getClassLoader());
    210 
     210                params = new HashMap<String, String[]>();
    211211        }
    212212        /**
     
    337337        @SuppressWarnings("unchecked")
    338338        protected void loadParams() {           
    339                 params = new HashMap(getServletRequest().getParameterMap());   
    340 
    341                 //setDefaultParams();
    342 
     339                       
     340                if (getServletRequest() != null){
     341                        params.putAll(getServletRequest().getParameterMap());
     342                }
     343                setDefaultParams();
     344
     345
     346        }
     347       
     348        protected void setDefaultParams(){
    343349                // set defaults
    344350                if ( params.get("version") == null){
     
    373379                if ( params.get("x-cmd-repository") == null){
    374380                        if (params.get("repository") == null){
    375                                 addParam("repository",WorkspaceProfile.getRepositoryByIndex(0));
     381                                if (params.get("x-context") == null){
     382                                        addParam("repository",WorkspaceProfile.getRepositoryByIndex(0));
     383                                } else {
     384                                        // search in fcs-mapping
     385                                        addParam("repository",WorkspaceProfile.getFCSMapping(params.get("x-context")[0]));
     386                                        //addParam("repository",params.get("x-context")[0]);
     387                                }
    376388                        }
    377389                } else {
     
    410422
    411423                addParam("fullformat",getFullFormat());
    412         }
    413        
    414         protected void setDefaultParams(){
    415                 //q=query       
    416                
    417        
    418                 if (getQ() != null) {
    419                         addParam("q",getQ());
    420                         addParam("query",getQ());
    421                 } else {
    422                         addParam("q",this.getParam("query"));
    423                 }
    424                
    425                 if (this.format != null) {
    426                         addParam("format",this.format);
    427                 }
    428        
    429                 if (getParams().get("repository") == null){
    430                         addParam("repository",WorkspaceProfile.getRepositoryByIndex(0));
    431                 }
    432424        }
    433425        /**
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/RepoAction.java

    r1630 r1800  
    1010import eu.clarin.cmdi.mdservice.model.Query;
    1111import eu.clarin.cmdi.mdservice.model.WorkspaceProfile;
     12import eu.clarin.cmdi.mdservice.proxy.FCSProxy;
    1213import eu.clarin.cmdi.mdservice.proxy.MDRepoProxy;
    1314import eu.clarin.cmdi.mdservice.proxy.Pz2Proxy;
     
    143144                                setTargetProxy(new SRUProxy(new Query(Query.SRURECORDSET, this.getParams())));
    144145                                return;
     146                            case FCS:
     147                                setTargetProxy(new FCSProxy(new Query(Query.FCSRECORDSET, this.getParams())));
     148                                return;
    145149                            case MD:
    146150                                setTargetProxy(new MDRepoProxy(new Query(getActionkey(), this.getParams())));
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/SRUAction.java

    r1628 r1800  
    8989        }
    9090       
    91          private final static HashMap<String,Integer> operation_code = new HashMap<String,Integer>();
     91         protected final static HashMap<String,Integer> operation_code = new HashMap<String,Integer>();
    9292         static
    9393         {       
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/Query.java

    r1663 r1800  
    4444        public static String SRUEXTERN = "sruextern";
    4545        public static String SRURECORDSET = "srurecordset";
     46        public static String FCSRECORDSET = "fcsrecordset";
    4647       
    4748        public static String PARSED = "parsed";
     
    443444                        }
    444445                       
    445                 } else if (type.equals(RECORD)) {
     446                } else if (type.equals(FCSRECORDSET)) {
     447                        targetRequest = "?";
     448                                               
     449                       
     450                        if (!getParam("operation").equals("")) {
     451                                targetRequest = targetRequest +  "operation=" + getParam("operation");
     452                        }
     453                        if (!getParam("scanClause").equals("")) {
     454                                targetRequest = targetRequest +  "&scanClause=" + getParam("scanClause");
     455                        }
     456                        if (!getParam("query").equals("")) {
     457                                targetRequest = targetRequest +  "&query=" + getParam("query");
     458                        }
     459                        if (!getParam("x-context").equals("")) {
     460                                targetRequest = targetRequest +  "&x-context=" + getParam("x-context");
     461                        }
     462                       
     463                }else if (type.equals(RECORD)) {
    446464                        //  2010-07-11 this is just a hack, because url-encoding the handle acted strange
    447465                        //String corrid = getQueryString().replace('_', '/');
     
    451469                        log.debug("Query.toURLParam.corrid=" + corrid);
    452470                        targetRequest = "//MdSelfLink[ft:query(.,'" + corrid + "')]";                   
    453                 } else if (type.equals(SRURECORDSET)) {
     471                } else if (type.equals(SRURECORDSET) || type.equals(FCSRECORDSET)) {
    454472                        targetRequest = "?query="+ getParam("query") + "&operation=" + getParam("operation");   
    455473                       
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/WorkspaceProfile.java

    r1663 r1800  
    66import java.io.IOException;
    77import java.io.InputStream;
     8import java.net.URL;
     9import java.util.HashMap;
    810
    911import javax.xml.transform.TransformerException;
     
    1315import eu.clarin.cmdi.mdservice.internal.MDTransformer;
    1416import eu.clarin.cmdi.mdservice.internal.Utils;
     17import eu.clarin.cmdi.mdservice.action.FCSAction;
    1518import eu.clarin.cmdi.mdservice.action.WorkspaceAction;
    1619import eu.clarin.cmdi.mdservice.internal.NoStylesheetException;
     
    2730        public static enum RepositoryType
    2831        {
    29                 MD, SRU, PAZPAR, NOVALUE;
     32                MD, SRU, PAZPAR, FCS, FCSRESOURCE, NOVALUE;
    3033
    3134            public static RepositoryType toRepositoryType(String str)
    3235            {
    3336                try {
    34                     return valueOf(str.toUpperCase());
     37                    return valueOf(str.replace(".", "").toUpperCase());
    3538                }
    3639                catch (Exception ex) {
     
    5760        private static JSONObject options = null;
    5861       
     62        /////
     63        private static HashMap<String,String> fcs_mapping = null;
     64       
    5965        public static JSONArray getRepositories(){
    6066                if (repositories == null){
    6167                        try {
    6268                                WorkspaceProfile.setRepositories(WorkspaceProfile.createRepositories());
     69                                WorkspaceProfile.createFCSRepositories();
    6370                        } catch (IOException e) {
    6471                                // TODO Auto-generated catch block
     
    139146        }
    140147       
     148        // FCS
     149        public static String getFCSMapping(String context){
     150                if (fcs_mapping == null){
     151                        WorkspaceProfile.createFCSRepositories();
     152                }
     153                return fcs_mapping.get(context);
     154        }
     155       
     156        public static void createFCSRepositories(){
     157       
     158        // static repositories
     159        net.sf.json.JSONArray json = WorkspaceProfile.getRepositories();
     160        for(int i=0;i<json.size();i++){
     161                        if (json.getJSONObject(i).getString("type").equals("fcs.resource")){
     162                                if (!json.getJSONObject(i).containsKey("fcsresource")){
     163                                        if (createFCSRepository(json.getJSONObject(i))){
     164                                        }
     165                                }
     166                        }
     167                }
     168        }
     169
     170        public static void addToFCSMapping(JSONObject jsonendpoint, JSONObject json){
     171                String endpoint;
     172                JSONObject extradata, extratermsobject;
     173                net.sf.json.JSONArray extraterms;
     174       
     175        if (fcs_mapping == null){
     176                fcs_mapping  = new HashMap<String,String>();
     177        }
     178        net.sf.json.JSONArray jsonterms = json.getJSONObject("sru:scanResponse").getJSONArray("sru:terms");
     179        for(int i=0;i<jsonterms.size();i++){
     180                endpoint = jsonterms.getJSONObject(i).getString("sru:value");
     181                if (jsonterms.getJSONObject(i).containsKey("sru:extraTermData")){
     182                        extradata = jsonterms.getJSONObject(i).getJSONObject("sru:extraTermData");
     183                        if (extradata.get("sru:terms").getClass().getName().equals("net.sf.json.JSONArray")){
     184                                extraterms = extradata.getJSONArray("sru:terms");
     185                                for(int j=0;j<extraterms.size();j++){
     186                                        fcs_mapping.put(extraterms.getJSONObject(j).getString("sru:value"), endpoint);
     187                                }
     188                        } else {
     189                                extratermsobject = extradata.getJSONObject("sru:terms");
     190                                fcs_mapping.put(extratermsobject.getJSONObject("sru:term").getString("sru:value"), endpoint);
     191                        }
     192                }
     193        }
     194        //["sru:extratermdata"]["sru:terms"]
     195        }
     196
     197        public static boolean createFCSRepository(JSONObject jsonitem){
     198               
     199                //create FCSAction to scan repository data
     200                FCSAction fcsa = new FCSAction();
     201                fcsa.setActionkey("fcs");
     202                fcsa.setParam("operation", "scan");
     203                fcsa.setParam("scanClause", "fcs.resource");
     204                fcsa.setParam("repository", jsonitem.getString("name"));
     205                try {
     206                        fcsa.execute();
     207                        InputStream in  = fcsa.getResultStream();
     208                       
     209                        // convert to json
     210                        MDTransformer transformer = new MDTransformer();
     211                        transformer.configure(Utils.getAppConfig("mdservice"), WorkspaceProfile.class.getClassLoader());
     212                       
     213                        transformer.setSrcFile(new URL(jsonitem.getString("uri")));
     214                        transformer.setParams(MDTransformer.createParamsMap("xml2json"));
     215                        InputStream jsonstream = transformer.transformXML(in);
     216                       
     217                        JSONObject json = JSONObject.fromObject(Utils.streamToString(jsonstream));
     218                        jsonitem.put("fcsresource", json);
     219                        addToFCSMapping(jsonitem, json);
     220                       
     221                } catch (Exception e) {
     222                        // TODO Auto-generated catch block
     223                        e.printStackTrace();
     224                }
     225               
     226               
     227                return true;
     228        }
     229       
     230        // FCS END
     231       
    141232        public static Boolean repositoryExists(String repository_name){
    142233               
     
    167258        String repository_path = null;
    168259       
    169        
    170        
    171260        // static repositories
    172261        net.sf.json.JSONArray json = WorkspaceProfile.getRepositories();
     
    205294}
    206295
     296       
    207297        public static String getRepositoryProperty(String repo_id, String propname){
    208298                String typestr = "";
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/MDRepoProxy.java

    r1629 r1800  
    142142                */
    143143                // TODO ?????
    144                  if (getSourceAction().getActionkey().equals("sru")){
     144                 if (getSourceAction().getActionkey().equals("sru") || getSourceAction().getActionkey().equals("fcs")){
    145145                         getQuery().setType(hash_sruoperations.get(getParam("operation")));
    146146                         getSourceAction().setActionkey(hash_sruoperations.get(getParam("operation")));
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/SRUProxy.java

    r1654 r1800  
    4242                        getSourceAction().getDiagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "version");
    4343                }
    44                 if (getParam("query").equals("")) {
     44                if (getParam("query").equals("") && getParam("operation").equals("searchRetrieve")) {
    4545                        getSourceAction().getDiagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "query");
     46                }
     47                if (getParam("scanClause").equals("") && getParam("operation").equals("scan")) {
     48                        getSourceAction().getDiagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "scan");
    4649                }
    4750
     
    6770                                throw new CQLParseException("SRUP.query.PARSEERROR:" + getQuery().getMsg());
    6871                        } else {
    69                        
     72               
    7073                                URL targetURL = null;
    7174                                URL tmp = getBaseURL();
    72                                 targetURL =new URL( tmp.toString() + getQuery().toURLParam());
     75                                targetURL =new URL( tmp.toExternalForm() + getQuery().toURLParam());
    7376                       
    7477                                log.debug("SRUPA.targetURL:" + targetURL);
  • MDService2/branches/MDService_simple3/src/mdservice.properties

    r1787 r1800  
    99//cache.path = /srv/tomcat6/webapps/MDService2_cache/
    1010//workspaceprofile.path = /srv/tomcat6/webapps/MDService2_profiles/
    11 cache.path = C:/apps/apache-tomcat/webapps/MDService2_cache/
    12 workspaceprofile.path = C:/apps/apache-tomcat/webapps/MDService2_profiles/
    13 //cache.path = C:/apache-tomcat-6.0.26/webapps/MDService2_cache/
    14 //workspaceprofile.path = C:/apache-tomcat-6.0.26/webapps/MDService2_profiles/
     11//cache.path = C:/apps/apache-tomcat/webapps/MDService2_cache/
     12//workspaceprofile.path = C:/apps/apache-tomcat/webapps/MDService2_profiles/
     13cache.path = C:/apache-tomcat-6.0.26/webapps/MDService2_cache/
     14workspaceprofile.path = C:/apache-tomcat-6.0.26/webapps/MDService2_profiles/
    1515workspace.file = WorkspaceProfile.xml
    1616
  • MDService2/branches/MDService_simple3/src/struts.xml

    r1638 r1800  
    132132                        </result>
    133133                </action>
     134       
     135                <action name="fcs" class="eu.clarin.cmdi.mdservice.action.FCSAction" method="execute">
     136                        <param name="actionkey">fcs</param>
     137                        <result name="success" type="stream">                         
     138                                <param name="contentType">text/xml</param>
     139                                <param name="inputName">resultStream</param>                           
     140                        </result>
     141                        <result name="error" type="stream">                           
     142                                <param name="contentType">text/xml</param>
     143                                <param name="inputName">${getDiagnosticStreamName()}</param>                           
     144                        </result>
     145                </action>
    134146               
    135147                <action name="pazpar2/" class="eu.clarin.cmdi.mdservice.action.Pz2Action" method="execute">
Note: See TracChangeset for help on using the changeset viewer.