Changeset 795
- Timestamp:
- 10/16/10 20:09:34 (14 years ago)
- Location:
- MDService2/trunk/MDService2
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/trunk/MDService2/WebContent/scripts/mdservice2_ui.js
r794 r795 29 29 30 30 isocat: { 31 base_uri: "/MDService2/ isocatprofile/",31 base_uri: "/MDService2/datcats/", 32 32 current:5 33 33 } … … 52 52 ////////////// 53 53 54 loadWelcomeMessage(); 54 55 loadWorkspaceProfiles(); 55 56 loadCollections(); … … 384 385 } 385 386 //////////////////////////////////////////////// 387 function loadWelcomeMessage(){ 388 $('#detail').load("/MDService2/static/welcome.xml"); //profile.collections.base_uri, 389 } 390 386 391 function loadWorkspaceProfiles(){ 387 392 //empty json -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/CompRegistryProxyAction.java
r789 r795 92 92 Admin.notifyUser("CCCRPA." + getFullFormat()); 93 93 MDTransformer.getMDTransformer().setSrcFile(getTargetRequest()); 94 _sourceStream = MDTransformer.getMDTransformer().transformXML(__sourceStream, getFullFormat(),null,null,null,null );94 _sourceStream = MDTransformer.getMDTransformer().transformXML(__sourceStream, getFullFormat(),null,null,null,null,null); 95 95 Admin.notifyUser("CRPA.- elements"); 96 96 setActionkey("elements"); -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/DCRProxyAction.java
r789 r795 42 42 private static final long serialVersionUID = 1L; 43 43 44 private final static HashMap<String,Object> dcrs = new HashMap<String,Object>();45 46 44 47 45 public String getDcrid() { … … 53 51 } 54 52 55 public HashMap<String, Object> getDCRs() {56 if (dcrs.size()==0) {57 initDCRs();58 }59 return dcrs;60 }61 62 53 public Termset getDCR() { 63 54 String dcr_id=""; … … 66 57 if (getDcrid()!=null && !getDcrid().equals("")) dcr_id = getDcrid(); 67 58 68 Termset res = (Termset) getDCRs().get(dcr_id);59 Termset res = (Termset) Termset.getTermset(dcr_id); 69 60 if (res==null) Admin.notifyUser("getDCR(): no termset found for:" + dcr_id); 70 61 //else … … 109 100 110 101 public String getBaseURI() { 111 return getDCRAttr("url"); 112 102 return getDCRAttr("url"); 113 103 } 114 104 … … 163 153 resultStream = urlConnection.getInputStream(); 164 154 } 165 return resultStream; 166 155 return resultStream; 167 156 168 157 } 169 170 171 public void initDCRs() {172 if (dcrs.size() > 0) {173 }174 175 Document dcrs_setup = Admin.getXMLDocument(Admin.getConfig().getProperty("datcats.file"));176 177 // Admin.loadFile(Admin.getConfig().getProperty("service.list.file"));178 Admin.notifyUser("initDCRs().loaded:" + dcrs_setup.getDocumentURI());179 Admin.notifyUser("firstchild:" + dcrs_setup.getFirstChild());180 //.getDocumentElement().getLocalName()181 //Document chains_doc = Admin.getXMLDocument(Admin.getConfig().getProperty("chains.file"));182 183 //Admin.notifyUser("formPath:xpath:"+xpath_expr);184 //creating an XPathFactory:185 XPathFactory factory = XPathFactory.newInstance();186 //using this factory to create an XPath object:187 XPath xpath = factory.newXPath();188 //XPath object created compiles the XPath expression:189 XPathExpression expr;190 try {191 expr = xpath.compile("//Termset");192 //expression is evaluated with respect to a certain context node which is doc.193 Object result = expr.evaluate(dcrs_setup, XPathConstants.NODESET);194 NodeList list = (NodeList) result;195 196 // <Termset type="dcr" id="isocat" label="isoCAT" url="http://www.isocat.org/rest/" format="dcif" />197 for (int i = 0; i<list.getLength();i++) {198 //String value = list.item(i).getTextContent();199 Node n = list.item(i);200 Termset ts = new Termset(n);201 202 Admin.notifyUser("reading in dcr:" + ts.getAttr("id"));203 dcrs.put(ts.getAttr("id"), ts );204 }205 } catch (XPathExpressionException e) {206 // TODO Auto-generated catch block207 e.printStackTrace();208 }209 210 }211 212 158 213 159 } -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
r789 r795 211 211 } 212 212 213 public String getBaseURI() throws MalformedURLException{213 public String getBaseURI() { 214 214 String uri =Admin.getConfig().getProperty(getProxyKey() + ".uri"); 215 215 return uri; … … 281 281 MDTransformer.getMDTransformer().setSrcFile(getTargetRequest()); 282 282 // getColumns 283 resultStream = MDTransformer.getMDTransformer().transformXML(sourceStream, getFullFormat(), getColumns(), getStartRecord(), getMaximumRecords(),getLang() );283 resultStream = MDTransformer.getMDTransformer().transformXML(sourceStream, getFullFormat(), getColumns(), getStartRecord(), getMaximumRecords(),getLang(),getQ()); 284 284 } 285 285 -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/MDTransformer.java
r789 r795 165 165 * @throws IOException 166 166 */ 167 public void transformXML (InputStream in, String transkey, String cols, String startRecord, String maximumRecords, String lang, OutputStream out ) throws TransformerException, IOException {167 public void transformXML (InputStream in, String transkey, String cols, String startRecord, String maximumRecords, String lang, String q, OutputStream out ) throws TransformerException, IOException { 168 168 169 169 // Create a transform factory instance. … … 177 177 getXSLStreamSource(transkey)); 178 178 179 transformer.setParameter("q", q); 179 180 transformer.setParameter("lang", lang); 180 181 transformer.setParameter("format", transkey); … … 204 205 } 205 206 Admin.notifyUser("root_uri:" + root_uri ); 206 Admin.notifyUser("xsrcfile:" + root_uri);207 Admin.notifyUser("xsrcfile:" + xsrcfile ); 207 208 transformer.setParameter("root_uri", root_uri ); 208 209 transformer.setParameter("src_file", xsrcfile); … … 226 227 * @throws TransformerException 227 228 */ 228 public InputStream transformXML ( InputStream xmlStream, String transkey, String cols, String startRecord, String maximumRecords, String lang ) throws IOException, InterruptedException, TransformerException {229 public InputStream transformXML ( InputStream xmlStream, String transkey, String cols, String startRecord, String maximumRecords, String lang, String q) throws IOException, InterruptedException, TransformerException { 229 230 230 231 ByteArrayOutputStream out = new ByteArrayOutputStream(); 231 transformXML(xmlStream, transkey, cols, startRecord, maximumRecords, lang, out);232 transformXML(xmlStream, transkey, cols, startRecord, maximumRecords, lang, q, out); 232 233 InputStream transformedStream = new ByteArrayInputStream(out.toByteArray()); 233 234 //Admin.notifyUser("transformedStream:" + transformedStream.toString()); … … 247 248 248 249 ByteArrayOutputStream out = new ByteArrayOutputStream(); 249 transformXML(xmlStream, transkey, "", "", "","", out);250 transformXML(xmlStream, transkey, "", "", "","","", out); 250 251 InputStream transformedStream = new ByteArrayInputStream(out.toByteArray()); 251 252 //Admin.notifyUser("transformedStream:" + transformedStream.toString()); -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/TermsProxyAction.java
r772 r795 15 15 16 16 import eu.clarin.cmdi.mdservice.model.Query; 17 import eu.clarin.cmdi.mdservice.model.Termset; 17 18 18 19 /** … … 28 29 private static final long serialVersionUID = 1L; 29 30 31 public static String ALL = "all"; 32 30 33 private String proxy_key = "terms"; 31 34 … … 66 69 return key; 67 70 } 68 /** 71 72 public Termset getTermset() { 73 String ts_id=""; 74 if (getQ()!=null && !getQ().equals("")) ts_id = getQ(); 75 76 Termset res = (Termset) Termset.getTermset(ts_id); 77 78 return res; 79 } 80 81 public String getTSAttr(String key) { 82 Termset ts = getTermset(); 83 String val=""; 84 if (ts!=null) val= ts.getAttr(key); 85 return val; 86 } 87 88 89 public URL getBaseURL() throws MalformedURLException { 90 91 if (base_url == null) { 92 base_url = new URL(getBaseURI()); 93 } 94 95 return base_url; 96 } 97 98 /** 69 99 * uses base_url + url_pattern (parametrized by actionkey) to form a url 70 * @return the URL to the component-file100 * @return the URL to the terms 71 101 * @throws Exception 72 102 */ 73 103 public URL getTargetRequest() throws IOException { 74 104 // URL targetURL =new URL( base_url, compname + ".xml"); 75 76 Admin.notifyUser("TPA.getQ:" + getQ() ); 77 Admin.notifyUser("TPA.getActionkey:" + getActionkey()); 78 Admin.notifyUser("TPA.getMaxdepth:" + getMaxdepth()); 105 79 106 80 107 URL targetURL = null; 108 //targetURL = new URL(getBaseURI() + getQ()); 109 Admin.notifyUser("TPA.q: " + getQ()); 81 110 targetURL = new URL(getBaseURI() + getQ()); 82 Admin.notifyUser("TPA.targetURL:" + targetURL);83 111 // TPA.targetURL:http://localhost:8080/MDService2/model/matrix/?q=all 84 112 return targetURL; … … 86 114 } 87 115 116 public InputStream getSourceStream() throws IOException{ 117 String type = getTSAttr("type"); 118 if (type.equals("dcr") | type.equals("rr")) { 119 // if dcr|rr call model/matrix/all: http://localhost:8080/MDService2/model/matrix/?q=all 120 // + run through terms2extract transform (parametrized with getQ()-param!!), to serve the subset = appropriate Termset 121 URL matrix_all_URL = new URL(getBaseURI() + ALL); 122 InputStream stream_matrix_all = matrix_all_URL.openStream(); 123 InputStream resultStream=null; 124 try { 125 resultStream = MDTransformer.getMDTransformer().transformXML(stream_matrix_all, "terms2extract", getColumns(), getStartRecord(), getMaximumRecords(),getLang(),getQ()); 126 } catch (InterruptedException e) { 127 Admin.notifyUser("TPA.getSourceStream(): "+ e.getMessage()); 128 } catch (TransformerException e) { 129 Admin.notifyUser("TPA.getSourceStream(): "+ e.getMessage()); 130 } 131 return resultStream; 132 133 } else { 134 return getTargetRequest().openStream(); 135 } 136 } 137 88 138 } -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/model/Termset.java
r768 r795 3 3 import java.util.HashMap; 4 4 5 import javax.xml.xpath.XPath; 6 import javax.xml.xpath.XPathConstants; 7 import javax.xml.xpath.XPathExpression; 8 import javax.xml.xpath.XPathExpressionException; 9 import javax.xml.xpath.XPathFactory; 10 11 import org.w3c.dom.Document; 5 12 import org.w3c.dom.Node; 13 import org.w3c.dom.NodeList; 14 15 import eu.clarin.cmdi.mdservice.action.Admin; 6 16 7 17 public class Termset { 8 18 19 private final static HashMap<String,Object> termsets = new HashMap<String,Object>(); 20 9 21 private final HashMap<String,String> attrs = new HashMap<String,String>(); 10 22 11 public Termset () { 12 23 public Termset () { 13 24 } 14 25 … … 16 27 this.setAttrs(n); 17 28 } 18 29 19 30 public void setAttrs(Node n) { 20 31 … … 29 40 return attrs.get(key); 30 41 } 42 43 public static HashMap<String, Object> getTermsets() { 44 if (termsets.size() == 0) { 45 initTermsets(); 46 } 47 return termsets; 48 } 49 50 public static Termset getTermset(String ts_id) { 51 52 Termset res = (Termset) getTermsets().get(ts_id); 53 if (res==null) Admin.notifyUser("getTermset(): no termset found for:" + ts_id); 54 //else 55 //Admin.notifyUser("getDCR():" + res.getAttr("id") + ":" + res.getAttr("url") ); 56 return res; 57 } 58 59 public static String getTermsetAttr(String ts_id, String key) { 60 Termset ts = getTermset(ts_id); 61 String val=""; 62 if (ts!=null) val= ts.getAttr(key); 63 return val; 64 } 65 66 public static void initTermsets() { 67 Document dcrs_setup = Admin.getXMLDocument(Admin.getConfig().getProperty("terms.file")); 68 69 // Admin.loadFile(Admin.getConfig().getProperty("service.list.file")); 70 Admin.notifyUser("initTermsets().loaded."); 71 //.getDocumentElement().getLocalName() 72 //Document chains_doc = Admin.getXMLDocument(Admin.getConfig().getProperty("chains.file")); 73 74 //Admin.notifyUser("formPath:xpath:"+xpath_expr); 75 //creating an XPathFactory: 76 XPathFactory factory = XPathFactory.newInstance(); 77 //using this factory to create an XPath object: 78 XPath xpath = factory.newXPath(); 79 //XPath object created compiles the XPath expression: 80 XPathExpression expr; 81 try { 82 expr = xpath.compile("//Termset"); 83 //expression is evaluated with respect to a certain context node which is doc. 84 Object result = expr.evaluate(dcrs_setup, XPathConstants.NODESET); 85 NodeList list = (NodeList) result; 86 87 // <Termset type="dcr" id="isocat" label="isoCAT" url="http://www.isocat.org/rest/" format="dcif" /> 88 for (int i = 0; i<list.getLength();i++) { 89 //String value = list.item(i).getTextContent(); 90 Node n = list.item(i); 91 Termset ts = new Termset(n); 92 93 Admin.notifyUser("reading in Termset: " + ts.getAttr("id")); 94 termsets.put(ts.getAttr("id"), ts ); 95 } 96 } catch (XPathExpressionException e) { 97 // TODO Auto-generated catch block 98 e.printStackTrace(); 99 } 100 101 } 102 31 103 32 104 } -
MDService2/trunk/MDService2/src/mdservice.properties
r794 r795 3 3 mdrepository.uri = http://clarin.aac.ac.at/exist/rest/db/clarin/cmd-model.xql/ 4 4 terms.uri = http://localhost:8080/MDService2/model/matrix/?q= 5 datcats.file=terms_setup.xml 5 terms.dcr.uri = http://localhost:8080/MDService2/terms/extract/?q= 6 terms.file=terms_setup.xml 6 7 7 8 //dcregistry.uri = http://www.isocat.org/rest/ … … 30 31 xsl.model2htmllist = model2view.xsl 31 32 xsl.model2htmlselect = model2view.xsl 33 xsl.terms2extract = terms_extract.xsl 32 34 xsl.terms2htmlselect = terms2view.xsl 33 35 xsl.terms2htmllist = terms2view.xsl 36 xsl.terms2flat = terms2view.xsl 34 37 xsl.terms2autocomplete = terms2view.xsl 35 38 xsl.terms2htmlpage = terms2view.xsl -
MDService2/trunk/MDService2/src/xsl/terms2view.xsl
r794 r795 54 54 <xsl:when test="$format='terms2htmllist'" > 55 55 <xsl:call-template name="list"/> 56 </xsl:when> 57 <xsl:when test="$format='terms2flat'" > 58 <xsl:call-template name="terms-flat"/> 56 59 </xsl:when> 57 60 <xsl:when test="$format='terms2autocomplete'" > … … 202 205 203 206 <xsl:variable name="count" select="Term/@count" /> 204 <option value="{@ name}" ><xsl:value-of select="@name" /> |<xsl:value-of select="$count" />|</option>207 <option value="{@id}" ><xsl:value-of select="@name" /> |<xsl:value-of select="$count" />|</option> 205 208 </xsl:template> 206 209
Note: See TracChangeset
for help on using the changeset viewer.