Changeset 1650
- Timestamp:
- 12/09/11 20:39:49 (12 years ago)
- Location:
- SMC/trunk/SMC/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
SMC/trunk/SMC/src/eu/clarin/cmdi/smc/SMC.java
r1648 r1650 32 32 */ 33 33 public class SMC { 34 private static String appname="smc"; 34 35 35 36 public SMC () { … … 49 50 50 51 SMC smc = new SMC(); 51 smc.init(); 52 53 //smc.init(); 52 54 53 55 InputStream is = smc.listTermsets(""); … … 59 61 60 62 public void configure(){ 61 Utils.loadConfig( "smc", "smc.properties", this.getClass().getClassLoader());63 Utils.loadConfig(appname, "smc.properties", this.getClass().getClassLoader()); 62 64 } 63 65 public void configure(String configPath) { 64 66 try { 65 Utils.loadConfig( "smc", configPath, this.getClass().getClassLoader());67 Utils.loadConfig(appname, configPath, this.getClass().getClassLoader()); 66 68 67 69 //config = new PropertiesConfiguration("smc.properties"); … … 76 78 */ 77 79 public void init () { 78 80 79 81 InputStream is =null; 80 82 is = Utils.load2Stream(Utils.getConfig("termsets.config.file"),this.getClass().getClassLoader()); … … 83 85 84 86 MDTransformer transformer = new MDTransformer(); 85 //transformer.configure(config, this.getClass().getClassLoader()); 87 transformer.configure(Utils.getAppConfig(appname), this.getClass().getClassLoader()); 88 86 89 // set URL as srcFile (for MDTransformer to pass to xsl-scripts) 87 90 // TODO: WHY?? … … 90 93 91 94 // 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()); 93 96 94 97 transformer.setParams(getParams()); … … 103 106 //String output_path = config.getString("cache.dir") + getParam("data_key") + ".xml" ; 104 107 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()); 106 109 107 110 } catch (IOException e1) { … … 195 198 * @return stream with XML listing the available termsets 196 199 */ 197 public InputStream listTermsets(String context) { 200 public InputStream listTermsets(String context) { 198 201 InputStream is =null; 199 202 is = Utils.load2Stream(Utils.getConfig("termsets.config.file").trim(), this.getClass().getClassLoader()); … … 207 210 */ 208 211 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; 210 244 } 211 245 … … 216 250 */ 217 251 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; 219 284 } 220 285 -
SMC/trunk/SMC/src/scripts/smc_op.xsl
r1607 r1650 18 18 19 19 <xsl:template match="/"> 20 <xsl:choose> 21 <!-- if $term=*, list all terms -->20 <xsl:choose> 21 <!-- if $set=*, list all termsets --> 22 22 <xsl:when test="$set='*' or $set='top'"> 23 23 <xsl:copy-of select="my:getData('termsets')"></xsl:copy-of> 24 </xsl:when> 24 </xsl:when> 25 <!-- if $term=*, list all terms --> 25 26 <xsl:when test="$term='*'"> 26 27 <Termset set="{$set}" xml:lang="{$lang}"> … … 36 37 </xsl:for-each> 37 38 </xsl:otherwise> 38 </xsl:choose> 39 39 </xsl:choose> 40 40 41 41 </xsl:template> -
SMC/trunk/SMC/src/scripts/smc_stats.xsl
r1600 r1650 27 27 --> 28 28 29 < xsl:import href="cmd_commons.xsl"/>29 <!--<xsl:import href="cmd_commons.xsl"/>--> 30 30 31 31 <xsl:output method="xml" indent="yes" /> -
SMC/trunk/SMC/src/smc.properties
r1620 r1650 1 1 termsets.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/2 cache.dir = C:/Users/m/3lingua/clarin/CMDI/SMC/cache/ 3 #cache.dir = C:/apache-tomcat-6.0.26/webapps/SMC_cache/ 4 4 5 5 scripts.path = scripts/ 6 6 xsl.init = smc_init.xsl 7 xsl.map = smc_op.xsl
Note: See TracChangeset
for help on using the changeset viewer.