Changeset 1650


Ignore:
Timestamp:
12/09/11 20:39:49 (12 years ago)
Author:
vronk
Message:

correcting config-usage
+ started implementing of listTerms

Location:
SMC/trunk/SMC/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • SMC/trunk/SMC/src/eu/clarin/cmdi/smc/SMC.java

    r1648 r1650  
    3232 */
    3333public class SMC {
     34        private static String appname="smc";
    3435       
    3536        public SMC () {
     
    4950                       
    5051                SMC smc = new SMC();
    51                 smc.init();             
     52
     53                //smc.init();           
    5254               
    5355                InputStream is = smc.listTermsets("");
     
    5961
    6062        public void configure(){
    61                 Utils.loadConfig("smc", "smc.properties", this.getClass().getClassLoader());
     63                Utils.loadConfig(appname, "smc.properties", this.getClass().getClassLoader());
    6264        }
    6365        public void configure(String configPath) {
    6466                try {
    65                         Utils.loadConfig("smc", configPath, this.getClass().getClassLoader());
     67                        Utils.loadConfig(appname, configPath, this.getClass().getClassLoader());
    6668                       
    6769                        //config = new PropertiesConfiguration("smc.properties");
     
    7678 */
    7779        public void init () {
    78 
     80               
    7981                InputStream is =null;
    8082                is = Utils.load2Stream(Utils.getConfig("termsets.config.file"),this.getClass().getClassLoader());
     
    8385               
    8486                MDTransformer transformer = new MDTransformer();
    85                 //transformer.configure(config, this.getClass().getClassLoader());
     87                transformer.configure(Utils.getAppConfig(appname), this.getClass().getClassLoader());
     88               
    8689                // set URL as srcFile (for MDTransformer to pass to xsl-scripts)
    8790                // TODO: WHY??
     
    9093
    9194                // this is necessary for the transformer (in MDUTILS-library) to search for the resources (config and xsls) in the correct context)
    92                 transformer.configure(Utils.getConfig(), this.getClass().getClassLoader());
     95                //transformer.configure(Utils.getConfig(), this.getClass().getClassLoader());
    9396               
    9497                transformer.setParams(getParams());             
     
    103106                        //String output_path = config.getString("cache.dir") +  getParam("data_key") + ".xml" ;
    104107                        File f = Utils.write2File(output_path, resultStream);
    105                         log.debug("result stored in: " + f.getAbsolutePath());
     108                        log.debug("SMC.init(): result stored in: " + f.getAbsolutePath());
    106109
    107110                } catch (IOException e1) {
     
    195198         * @return stream with XML listing the available termsets
    196199         */
    197         public InputStream listTermsets(String context) {
     200        public InputStream listTermsets(String context) {               
    198201                InputStream is =null;
    199202                is = Utils.load2Stream(Utils.getConfig("termsets.config.file").trim(), this.getClass().getClassLoader());
     
    207210         */     
    208211        public InputStream listTerms(String context) {
    209                 return null;
     212                 
     213                InputStream is =null;
     214                is = Utils.load2Stream(Utils.getConfig("termsets.config.file"),this.getClass().getClassLoader());
     215               
     216                MDTransformer transformer = new MDTransformer();
     217                // this is necessary for the transformer (in MDUTILS-library) to search for the resources (config and xsls) in the correct context)
     218                transformer.configure(Utils.getAppConfig(appname), this.getClass().getClassLoader());
     219               
     220                // set URL as srcFile (for MDTransformer to pass to xsl-scripts)
     221                // TODO: WHY??
     222                //transformer.setSrcFile(Utils.getConfig("termsets.config.file"));
     223               
     224                addParam("set", context);
     225                 
     226                transformer.setParams(getParams());             
     227                transformer.setTranskey("op");
     228
     229                InputStream resultStream=null;
     230                try {
     231                        resultStream = transformer.transformXML(is);
     232
     233                } catch (IOException e1) {
     234                        log.debug(Utils.errorMessage(e1));
     235                } catch (InterruptedException e1) {
     236                        log.debug(Utils.errorMessage(e1));
     237                } catch (TransformerException e1) {             
     238                        log.debug(Utils.errorMessage(e1));
     239                } catch (NoStylesheetException e1) {
     240                        log.debug(Utils.errorMessage(e1));
     241                }
     242               
     243                return resultStream;
    210244        }
    211245       
     
    216250         */
    217251        public InputStream map(String term) {
    218                 return null;
     252                 
     253                InputStream is =null;
     254                is = Utils.load2Stream(Utils.getConfig("termsets.config.file"),this.getClass().getClassLoader());
     255               
     256                MDTransformer transformer = new MDTransformer();
     257                // this is necessary for the transformer (in MDUTILS-library) to search for the resources (config and xsls) in the correct context)
     258                transformer.configure(Utils.getAppConfig(appname), this.getClass().getClassLoader());
     259               
     260                // set URL as srcFile (for MDTransformer to pass to xsl-scripts)
     261                // TODO: WHY??
     262                //transformer.setSrcFile(Utils.getConfig("termsets.config.file"));
     263               
     264                addParam("term", term);
     265                 
     266                transformer.setParams(getParams());             
     267                transformer.setTranskey("op");
     268
     269                InputStream resultStream=null;
     270                try {
     271                        resultStream = transformer.transformXML(is);
     272
     273                } catch (IOException e1) {
     274                        log.debug(Utils.errorMessage(e1));
     275                } catch (InterruptedException e1) {
     276                        log.debug(Utils.errorMessage(e1));
     277                } catch (TransformerException e1) {             
     278                        log.debug(Utils.errorMessage(e1));
     279                } catch (NoStylesheetException e1) {
     280                        log.debug(Utils.errorMessage(e1));
     281                }
     282               
     283                return resultStream;
    219284        }
    220285       
  • SMC/trunk/SMC/src/scripts/smc_op.xsl

    r1607 r1650  
    1818   
    1919 <xsl:template match="/">
    20      <xsl:choose>
    21          <!-- if $term=*, list all terms -->
     20     <xsl:choose>     
     21     <!-- if $set=*, list all termsets -->
    2222         <xsl:when test="$set='*' or $set='top'">
    2323                <xsl:copy-of select="my:getData('termsets')"></xsl:copy-of>             
    24          </xsl:when>         
     24         </xsl:when>
     25             <!-- if $term=*, list all terms -->         
    2526         <xsl:when test="$term='*'">
    2627             <Termset set="{$set}" xml:lang="{$lang}">
     
    3637             </xsl:for-each>
    3738         </xsl:otherwise>
    38      </xsl:choose>
    39      
     39     </xsl:choose>     
    4040     
    4141 </xsl:template>
  • SMC/trunk/SMC/src/scripts/smc_stats.xsl

    r1600 r1650  
    2727-->
    2828 
    29 <xsl:import href="cmd_commons.xsl"/>
     29<!--<xsl:import href="cmd_commons.xsl"/>-->
    3030   
    3131<xsl:output method="xml" indent="yes" />
  • SMC/trunk/SMC/src/smc.properties

    r1620 r1650  
    11termsets.config.file = smc_config.xml
    2 #cache.dir = C:/Users/m/3lingua/clarin/CMDI/SMC/cache/
    3 cache.dir = C:/apache-tomcat-6.0.26/webapps/SMC_cache/
     2cache.dir = C:/Users/m/3lingua/clarin/CMDI/SMC/cache/
     3#cache.dir = C:/apache-tomcat-6.0.26/webapps/SMC_cache/
    44
    55scripts.path = scripts/
    66xsl.init = smc_init.xsl
     7xsl.map = smc_op.xsl
Note: See TracChangeset for help on using the changeset viewer.