Strabon

changeset 573:9acbd30218e1

merge with 572:e53c5ec92c0a (stella)
author Babis Nikolaou <charnik@di.uoa.gr>
date Mon Oct 01 19:30:22 2012 +0300 (2012-10-01)
parents 9723ad99e922 e53c5ec92c0a
children 66fbe30eb2e9
files
line diff
     1.1 --- a/endpoint/WebContent/WEB-INF/web.xml	Mon Oct 01 19:27:32 2012 +0300
     1.2 +++ b/endpoint/WebContent/WEB-INF/web.xml	Mon Oct 01 19:30:22 2012 +0300
     1.3 @@ -81,6 +81,17 @@
     1.4  	</servlet-mapping>
     1.5  	
     1.6  	<servlet>
     1.7 +		<display-name>Browse</display-name>
     1.8 +		<servlet-name>Browse</servlet-name>
     1.9 +		<servlet-class>eu.earthobservatory.org.StrabonEndpoint.BrowseBean</servlet-class>
    1.10 +		<load-on-startup>1</load-on-startup>
    1.11 +	</servlet>
    1.12 +	<servlet-mapping>
    1.13 +		<servlet-name>Browse</servlet-name>
    1.14 +		<url-pattern>/Browse</url-pattern>
    1.15 +	</servlet-mapping>
    1.16 +	
    1.17 +	<servlet>
    1.18  		<servlet-name>query.jsp</servlet-name>
    1.19  		<jsp-file>/query.jsp</jsp-file>
    1.20  	</servlet>
    1.21 @@ -100,6 +111,11 @@
    1.22  		<jsp-file>/connection.jsp</jsp-file>
    1.23  	</servlet>
    1.24  	
    1.25 +	<servlet>
    1.26 +		<servlet-name>browse.jsp</servlet-name>
    1.27 +		<jsp-file>/browse.jsp</jsp-file>
    1.28 +	</servlet>
    1.29 +	
    1.30     	<mime-mapping>
    1.31         	<extension>kml</extension>
    1.32         	<mime-type>application/vnd.google-earth.kml+xml</mime-type>
     2.1 --- a/endpoint/WebContent/style.css	Mon Oct 01 19:27:32 2012 +0300
     2.2 +++ b/endpoint/WebContent/style.css	Mon Oct 01 19:30:22 2012 +0300
     2.3 @@ -41,6 +41,12 @@
     2.4  	background:#E6A685;
     2.5  }
     2.6  
     2.7 +h1 
     2.8 +{ 
     2.9 +	display: inline; 
    2.10 +	text-align: left; 
    2.11 +}
    2.12 +
    2.13  /* ID Styles */
    2.14  
    2.15  #border
    2.16 @@ -55,14 +61,25 @@
    2.17  	border-radius:5px;
    2.18  	padding:5px;
    2.19  	font-size:13px;
    2.20 -
    2.21  }
    2.22  
    2.23 -
    2.24  #output
    2.25  {
    2.26  	border: 1px dashed #bbbbbb;
    2.27  }
    2.28 +#response
    2.29 +{
    2.30 +	margin-top: 20px;
    2.31 +	
    2.32 +}
    2.33 +
    2.34 +#response td{
    2.35 +	width: 33.33%;
    2.36 +}
    2.37 +
    2.38 +#response table{
    2.39 +	width: 100%;
    2.40 +}
    2.41  
    2.42  input[type=submit]
    2.43  {
    2.44 @@ -112,13 +129,29 @@
    2.45  	border-radius:5px;
    2.46  	}
    2.47  	
    2.48 -.logo 	{
    2.49 -	font:24px Arial, Helvetica, sans-serif;
    2.50 +#uri a {			
    2.51 +	text-decoration: none;	
    2.52 +	}	
    2.53 +	
    2.54 +#logo
    2.55 +{
    2.56 +	font:20px Arial, Helvetica, sans-serif;
    2.57  	color: #333333;
    2.58  	letter-spacing:.2em;
    2.59  	line-height:30px;
    2.60 +}
    2.61 +	
    2.62 +#logo a	{
    2.63 +	padding-left: 10px;
    2.64 +	padding-top: 20px;
    2.65 +	text-decoration: none;
    2.66  	}
    2.67  
    2.68 +#logo a:hover
    2.69 +{
    2.70 +	color:  #333333;
    2.71 +}
    2.72 +
    2.73  #tagline 	{	
    2.74  	font:11px Arial, Helvetica, sans-serif;
    2.75  	color: #993300;
    2.76 @@ -168,4 +201,4 @@
    2.77  	letter-spacing:.1em;
    2.78  	text-decoration: none;
    2.79  	}
    2.80 -	
    2.81 +	
    2.82 \ No newline at end of file
     3.1 --- a/endpoint/WebContent/teleios-header.html	Mon Oct 01 19:27:32 2012 +0300
     3.2 +++ b/endpoint/WebContent/teleios-header.html	Mon Oct 01 19:30:22 2012 +0300
     3.3 @@ -8,9 +8,9 @@
     3.4          <table width="100%" border=0>
     3.5           <tr>
     3.6              <td width="1"><img src="images/nav2_bg.gif" width="1" height="60"></td>
     3.7 -            <td valign="top" width="80px"><img border="0" src="images/teleios_logo.png" /></td>
     3.8 +            <td valign="top" width="50px"><a href="query.jsp"><img border="0" src="images/teleios_	logo.png" /></a></td>
     3.9              <td valign="top" align="left">
    3.10 -            <span class="logo">&nbsp;stSPARQL Endpoint</span><br><span class="style4"></span></td>
    3.11 +            <span id="logo"><a href="query.jsp">&nbsp;stSPARQL Endpoint</a></span><br><span class="style4"></span></td>
    3.12            </tr>
    3.13          </table>
    3.14        </TD>
     4.1 --- a/endpoint/pom.xml	Mon Oct 01 19:27:32 2012 +0300
     4.2 +++ b/endpoint/pom.xml	Mon Oct 01 19:30:22 2012 +0300
     4.3 @@ -188,6 +188,8 @@
     4.4  								<include>query.jsp</include>
     4.5  								<include>describe.jsp</include>
     4.6  								<include>connection.jsp</include>
     4.7 +								<include>connection.jsp</include>
     4.8 +								<include>browse.jsp</include>
     4.9  								<include>teleios-header.html</include>
    4.10  							</includes>
    4.11  						</resource>
     5.1 --- a/resultio/src/main/java/org/openrdf/query/resultio/sparqlhtml/stSPARQLResultsHTMLWriter.java	Mon Oct 01 19:27:32 2012 +0300
     5.2 +++ b/resultio/src/main/java/org/openrdf/query/resultio/sparqlhtml/stSPARQLResultsHTMLWriter.java	Mon Oct 01 19:30:22 2012 +0300
     5.3 @@ -11,6 +11,7 @@
     5.4  
     5.5  import java.io.IOException;
     5.6  import java.io.OutputStream;
     5.7 +import java.net.URLEncoder;
     5.8  import java.util.List;
     5.9  
    5.10  import org.openrdf.model.BNode;
    5.11 @@ -21,6 +22,8 @@
    5.12  import org.openrdf.query.resultio.TupleQueryResultWriter;
    5.13  import org.openrdf.query.resultio.stSPARQLQueryResultFormat;
    5.14  import org.openrdf.query.resultio.sparqlxml.stSPARQLXMLWriter;
    5.15 +import org.openrdf.model.Value;
    5.16 +import org.openrdf.model.URI;
    5.17  
    5.18  /**
    5.19   * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    5.20 @@ -32,7 +35,11 @@
    5.21  	public static final String TABLE_ROW_TAG		= "TR";
    5.22  	public static final String TABLE_HEADER_TAG 	= "TH";
    5.23  	public static final String TABLE_DATA_TAG		= "TD";
    5.24 +	public static final String LINK				    = "A";
    5.25 +	public static final String LINK_REF				= "HREF";
    5.26  	public static final String STYLE				= "class";
    5.27 +	public static final String ID					= "id";
    5.28 +	public static final String LINK_ID				= "uri";
    5.29  	public static final String TABLE_HEADER_CLASS	= "query_results_header";
    5.30  	public static final String TABLE_DATA_CLASS		= "query_results_data";
    5.31  	public static final String TABLE_CLASS			= "query_results_table";
    5.32 @@ -62,20 +69,16 @@
    5.33  		
    5.34  		try {
    5.35  			// keep the order of binding names
    5.36 -			this.bindingNames = bindingNames;
    5.37 -			
    5.38 +			this.bindingNames = bindingNames;			
    5.39  			// set style for table
    5.40 -			xmlWriter.setAttribute(STYLE, TABLE_CLASS);
    5.41 -			
    5.42 +			xmlWriter.setAttribute(STYLE, TABLE_CLASS);					
    5.43  			// write start of table
    5.44 -			xmlWriter.startTag(TABLE);
    5.45 -			
    5.46 +			xmlWriter.startTag(TABLE);			
    5.47  			// write Table header containing the bindings
    5.48  			xmlWriter.startTag(TABLE_ROW_TAG);
    5.49  			for (String bindingName: bindingNames) {
    5.50  				// set style for header
    5.51  				xmlWriter.setAttribute(STYLE, TABLE_HEADER_CLASS);
    5.52 -				
    5.53  				xmlWriter.textElement(TABLE_HEADER_TAG, bindingName);
    5.54  			}
    5.55  			
    5.56 @@ -105,20 +108,49 @@
    5.57  	public void handleSolution(BindingSet bindingSet) throws TupleQueryResultHandlerException {
    5.58  		try {
    5.59  			StringBuilder value = new StringBuilder();
    5.60 +			Value boundValue = null;
    5.61  			
    5.62  			xmlWriter.startTag(TABLE_ROW_TAG);
    5.63  			for (String bindingName : bindingNames) {
    5.64  				Binding binding = bindingSet.getBinding(bindingName);
    5.65  				if(binding != null)
    5.66  				{	
    5.67 -					value.append(binding.getValue().stringValue());
    5.68 -				
    5.69 -					if (binding.getValue() instanceof BNode) {
    5.70 +					boundValue = binding.getValue();
    5.71 +					value.append(boundValue.stringValue());
    5.72 +														
    5.73 +					if(boundValue instanceof BNode) {
    5.74  						value.insert(0, "_:");
    5.75  					}
    5.76 -				}	
    5.77 -				xmlWriter.setAttribute(STYLE, TABLE_DATA_CLASS);
    5.78 -				xmlWriter.textElement(TABLE_DATA_TAG, value.toString());
    5.79 +					
    5.80 +					xmlWriter.setAttribute(STYLE, TABLE_DATA_CLASS);
    5.81 +					xmlWriter.setAttribute(ID, LINK_ID);
    5.82 +					xmlWriter.startTag(TABLE_DATA_TAG);
    5.83 +					// If the value is a uri, make it link
    5.84 +					if(boundValue instanceof URI)
    5.85 +					{
    5.86 +						// select all the triples that contain the boundValue  
    5.87 +						String query= "select * " +
    5.88 +								"where " +
    5.89 +								"{ " +
    5.90 +								  "?subject ?predicate ?object . "+
    5.91 +								  "FILTER((?subject = <"+ boundValue.toString()+ ">) || "+
    5.92 +								         "(?predicate = <"+ boundValue.toString()+ ">)  || "+
    5.93 +								         "(?object = <"+ boundValue.toString()+ ">)) " +  
    5.94 +								"}";
    5.95 +						
    5.96 +						String href = "Browse?view=HTML&query="+URLEncoder.encode(query, "UTF-8")+"&format=HTML&resource="+boundValue.toString();						
    5.97 +						xmlWriter.setAttribute(LINK_REF, href);
    5.98 +						xmlWriter.startTag(LINK);							
    5.99 +						xmlWriter.text(boundValue.toString());					
   5.100 +						xmlWriter.endTag(LINK);		
   5.101 +					}
   5.102 +					else
   5.103 +					{						
   5.104 +						xmlWriter.text(boundValue.toString());
   5.105 +					}																					
   5.106 +					xmlWriter.endTag(TABLE_DATA_TAG);							
   5.107 +					value.setLength(0);					 
   5.108 +				}					
   5.109  				
   5.110  				value.setLength(0);
   5.111  			}
   5.112 @@ -134,4 +166,4 @@
   5.113  		return stSPARQLQueryResultFormat.HTML;
   5.114  	}
   5.115  
   5.116 -}
   5.117 +}
   5.118 \ No newline at end of file