You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/12/09 16:02:10 UTC
svn commit: r1212465 [1/2] - in /incubator/stanbol/trunk:
entityhub/bundlelist/src/main/bundles/
entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/
entityhub/jersey/
entityhub/jersey/src/main/java/org/apache/stanbol/entityh...
Author: rwesten
Date: Fri Dec 9 15:02:09 2011
New Revision: 1212465
URL: http://svn.apache.org/viewvc?rev=1212465&view=rev
Log:
Implementation of STANBOL-411:
* add LDPath support for
* entityhub/ldpath
* entityhub/sites/ldpath
* entityhub/site/{site-id}/ldpath
* RESTful service documentation
* Test that allows to execute the RESTful service included in the Docu
* Integration tests
Improvements for org.apache.stanbol.entityhub.ldpath (STANBOL-408)
* Added LDPath Transformer that allows to use existing ValueConverter implementation for the Entityhub
* Added EntityhubLDPath extends LDPath
* initialises LDPath with a configuration as typically used within the Entityhub.
* allows to use Representation as results of LDPath program executions.
Both this feature will be important when replaceing the current mapping language with LDPath
* Added a public Constructor to the RdfValueFactory that takes an MGraph. This allows to store the results for LDPath executions directly within an Clerezza Graph without the need to store results in an intermediate data structure.
* Added unit tests for this new features
others:
* The SolrYard now waits up to 5sec for the used SolrIndex to become available.
Added:
incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java (with props)
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/imports/ldpathdocumentation.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_ldpath.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/ldpath.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_ldpath.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/ldpath.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource/inc_ldpath.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource/ldpath.ftl
incubator/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPath.java (with props)
incubator/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/LDPathUtils.java (with props)
incubator/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/transformer/
incubator/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/transformer/ValueConverterTransformerAdapter.java (with props)
incubator/stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPathTest.java (with props)
incubator/stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/impl/LDPathTestBase.java (with props)
incubator/stanbol/trunk/entityhub/yard/solr/src/main/resources/solr/conf/
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/ldpath/
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/ldpath/DbpediaLDPathTest.java (with props)
Removed:
incubator/stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/impl/LdPathTest.java
Modified:
incubator/stanbol/trunk/entityhub/bundlelist/src/main/bundles/list.xml
incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/ValueConverterFactory.java
incubator/stanbol/trunk/entityhub/jersey/pom.xml
incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource.java
incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java
incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/entity.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_entity.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_find.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_lookup.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_entity.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_symbol.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_query.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/index.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_entity.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_find.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_metadata.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_query.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/index.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/site_common.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource/inc_entity.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource/inc_find.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource/inc_query.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource/inc_referenced.ftl
incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource/index.ftl
incubator/stanbol/trunk/entityhub/ldpath/pom.xml
incubator/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/backend/SiteBackend.java
incubator/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/backend/SiteManagerBackend.java
incubator/stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/backend/BackendTest.java
incubator/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java
incubator/stanbol/trunk/entityhub/yard/solr/src/main/java/org/apache/stanbol/entityhub/yard/solr/impl/SolrYard.java
incubator/stanbol/trunk/parent/pom.xml
Modified: incubator/stanbol/trunk/entityhub/bundlelist/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/bundlelist/src/main/bundles/list.xml?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/bundlelist/src/main/bundles/list.xml (original)
+++ incubator/stanbol/trunk/entityhub/bundlelist/src/main/bundles/list.xml Fri Dec 9 15:02:09 2011
@@ -54,6 +54,17 @@
<artifactId>org.apache.stanbol.entityhub.core</artifactId>
<version>0.9.0-incubating-SNAPSHOT</version>
</bundle>
+ <bundle>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.entityhub.ldpath</artifactId>
+ <version>0.9.0-incubating-SNAPSHOT</version>
+ </bundle>
+ <bundle> <!-- LDPath requires jdom for xPath -->
+ <groupId>org.jdom</groupId>
+ <artifactId>com.springsource.org.jdom</artifactId>
+ <version>1.1.0</version>
+ </bundle>
+
</startLevel>
<!-- Web Fragment -->
Modified: incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/ValueConverterFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/ValueConverterFactory.java?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/ValueConverterFactory.java (original)
+++ incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/ValueConverterFactory.java Fri Dec 9 15:02:09 2011
@@ -176,7 +176,7 @@ public class ValueConverterFactory {
*
* @param <T> the type of created objects
*/
- public interface ValueConverter<T> {
+ public static interface ValueConverter<T> {
/**
* The URI of the dataType created by this converter
@@ -196,7 +196,7 @@ public class ValueConverterFactory {
*/
T convert(Object value,ValueFactory valueFactory);
}
- public class BooleanConverter implements ValueConverter<Boolean>{
+ public static class BooleanConverter implements ValueConverter<Boolean>{
@Override
public Boolean convert(Object value, ValueFactory valueFactory) {
@@ -218,7 +218,7 @@ public class ValueConverterFactory {
public String getDataType() {return DataTypeEnum.Boolean.getUri();}
}
- public class ByteConverter implements ValueConverter<Byte>{
+ public static class ByteConverter implements ValueConverter<Byte>{
@Override
public Byte convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -247,7 +247,7 @@ public class ValueConverterFactory {
public String getDataType() {return DataTypeEnum.Byte.getUri();}
}
- public class ShortConverter implements ValueConverter<Short>{
+ public static class ShortConverter implements ValueConverter<Short>{
@Override
public Short convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -277,7 +277,7 @@ public class ValueConverterFactory {
public String getDataType() {return DataTypeEnum.Short.getUri();}
}
- public class IntConverter implements ValueConverter<Integer>{
+ public static class IntConverter implements ValueConverter<Integer>{
@Override
public Integer convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -307,7 +307,7 @@ public class ValueConverterFactory {
public String getDataType() {return DataTypeEnum.Int.getUri();}
}
- public class LongConverter implements ValueConverter<Long>{
+ public static class LongConverter implements ValueConverter<Long>{
@Override
public Long convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -331,7 +331,7 @@ public class ValueConverterFactory {
@Override
public String getDataType() {return DataTypeEnum.Long.getUri();}
}
- public class FloatConverter implements ValueConverter<Float>{
+ public static class FloatConverter implements ValueConverter<Float>{
@Override
public Float convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -348,7 +348,7 @@ public class ValueConverterFactory {
@Override
public String getDataType() {return DataTypeEnum.Float.getUri();}
}
- public class DoubleConverter implements ValueConverter<Double>{
+ public static class DoubleConverter implements ValueConverter<Double>{
@Override
public Double convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -365,7 +365,7 @@ public class ValueConverterFactory {
@Override
public String getDataType() {return DataTypeEnum.Double.getUri();}
}
- public class IntegerConverter implements ValueConverter<BigInteger>{
+ public static class IntegerConverter implements ValueConverter<BigInteger>{
@Override
public BigInteger convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -383,7 +383,7 @@ public class ValueConverterFactory {
@Override
public String getDataType() {return DataTypeEnum.Integer.getUri();}
}
- public class DecimalConverter implements ValueConverter<BigDecimal>{
+ public static class DecimalConverter implements ValueConverter<BigDecimal>{
@Override
public BigDecimal convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -400,7 +400,7 @@ public class ValueConverterFactory {
@Override
public String getDataType() {return DataTypeEnum.Decimal.getUri();}
}
- public class AnyUriConverter implements ValueConverter<Reference>{
+ public static class AnyUriConverter implements ValueConverter<Reference>{
@Override
public Reference convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -420,12 +420,12 @@ public class ValueConverterFactory {
@Override
public String getDataType() {return DataTypeEnum.AnyUri.getUri();}
}
- public class ReferenceConverter extends AnyUriConverter {
+ public static class ReferenceConverter extends AnyUriConverter {
//same as AnyUri just parse Reference as DataType
@Override
public String getDataType() {return DataTypeEnum.Reference.getUri();}
}
- public class DateTimeConverter implements ValueConverter<Date>{
+ public static class DateTimeConverter implements ValueConverter<Date>{
private final DataTypeEnum dataType;
public DateTimeConverter(){
this.dataType = DataTypeEnum.DateTime;
@@ -456,17 +456,17 @@ public class ValueConverterFactory {
@Override
public String getDataType() {return dataType.getUri();}
}
- public class DateConverter extends DateTimeConverter {
+ public static class DateConverter extends DateTimeConverter {
public DateConverter(){
super(DataTypeEnum.Date);
}
}
- public class TimeConverter extends DateTimeConverter {
+ public static class TimeConverter extends DateTimeConverter {
public TimeConverter(){
super(DataTypeEnum.Time);
}
}
- public class TextConverter implements ValueConverter<Text> {
+ public static class TextConverter implements ValueConverter<Text> {
@Override
public Text convert(Object value, ValueFactory valueFactory) {
if (value == null) {
@@ -481,13 +481,13 @@ public class ValueConverterFactory {
@Override
public String getDataType() { return DataTypeEnum.Text.getUri(); }
}
- public class StringConverter implements ValueConverter<String> {
+ public static class StringConverter implements ValueConverter<String> {
@Override
public String convert(Object value, ValueFactory valueFactory) { return value.toString(); }
@Override
public String getDataType() { return DataTypeEnum.String.getUri(); }
}
- public class DurationConverter implements ValueConverter<Duration> {
+ public static class DurationConverter implements ValueConverter<Duration> {
private boolean nullAsZeroLengthDuration;
/**
* Creates a converter for durations
Modified: incubator/stanbol/trunk/entityhub/jersey/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/pom.xml?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/pom.xml (original)
+++ incubator/stanbol/trunk/entityhub/jersey/pom.xml Fri Dec 9 15:02:09 2011
@@ -90,6 +90,10 @@
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.entityhub.query.clerezza</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.entityhub.ldpath</artifactId>
+ </dependency>
<dependency>
<groupId>commons-io</groupId>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource.java?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource.java Fri Dec 9 15:02:09 2011
@@ -36,6 +36,7 @@ import static org.apache.clerezza.rdf.co
import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.X_TURTLE;
import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
+import static org.apache.stanbol.entityhub.jersey.utils.LDPathHelper.handleLDPathRequest;
import java.io.File;
import java.util.ArrayList;
@@ -72,6 +73,8 @@ import org.apache.stanbol.commons.web.ba
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
import org.apache.stanbol.entityhub.core.query.QueryResultListImpl;
import org.apache.stanbol.entityhub.jersey.utils.JerseyUtils;
+import org.apache.stanbol.entityhub.ldpath.backend.SiteBackend;
+import org.apache.stanbol.entityhub.ldpath.backend.YardBackend;
import org.apache.stanbol.entityhub.servicesapi.Entityhub;
import org.apache.stanbol.entityhub.servicesapi.EntityhubException;
import org.apache.stanbol.entityhub.servicesapi.model.Entity;
@@ -114,11 +117,9 @@ public class EntityhubRootResource exten
private static final Collection<? extends String> DEFAULT_FIND_SELECTED_FIELDS = Arrays.asList(
RdfResourceEnum.label.getUri(), RdfResourceEnum.description.getUri());
- private ServletContext context;
// bind the job manager by looking it up from the servlet request context
- public EntityhubRootResource(@Context ServletContext context) {
+ public EntityhubRootResource() {
super();
- this.context = context;
}
@OPTIONS
public Response handleCorsPreflight(@Context HttpHeaders headers){
@@ -156,7 +157,7 @@ public class EntityhubRootResource exten
// TODO: how to parse an error message
throw new WebApplicationException(BAD_REQUEST);
}
- Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, context);
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
Entity entity;
try {
entity = entityhub.getEntity(symbolId);
@@ -197,7 +198,7 @@ public class EntityhubRootResource exten
// TODO: how to parse an error message
throw new WebApplicationException(BAD_REQUEST);
}
- Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, context);
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
Entity entity;
try {
entity = entityhub.lookupLocalEntity(reference, create);
@@ -261,12 +262,12 @@ public class EntityhubRootResource exten
MediaType accepted = JerseyUtils.getAcceptableMediaType(headers,
JerseyUtils.ENTITY_SUPPORTED_MEDIA_TYPES,
MediaType.APPLICATION_JSON_TYPE);
- Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, context);
if(id == null || id.isEmpty()){
return Response.status(Status.BAD_REQUEST).entity("The Request does" +
"not provide the id of the Entity to delete (parameter 'id').")
.header(HttpHeaders.ACCEPT, accepted).build();
}
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
Entity entity;
try {
entity = entityhub.delete(id);
@@ -303,10 +304,10 @@ public class EntityhubRootResource exten
boolean create,
boolean update,
HttpHeaders headers){
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
MediaType accepted = JerseyUtils.getAcceptableMediaType(headers,
JerseyUtils.ENTITY_SUPPORTED_MEDIA_TYPES,
MediaType.APPLICATION_JSON_TYPE);
- Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, context);
if(entityhub == null){
return Response.status(Status.INTERNAL_SERVER_ERROR).
entity("The Entityhub is currently unavailable.")
@@ -540,7 +541,7 @@ public class EntityhubRootResource exten
* @return the response (results of error)
*/
private Response executeQuery(FieldQuery query, HttpHeaders headers, MediaType acceptedMediaType) throws WebApplicationException {
- Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, context);
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
try {
ResponseBuilder rb = Response.ok(entityhub.find(query));
rb.header(HttpHeaders.CONTENT_TYPE, acceptedMediaType+"; charset=utf-8");
@@ -588,7 +589,7 @@ public class EntityhubRootResource exten
HttpHeaders.ACCEPT, acceptedMediaType).build();
}
}
- Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, context);
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
Entity mapping;
try {
mapping = entityhub.getMappingById(reference);
@@ -640,7 +641,7 @@ public class EntityhubRootResource exten
}
}
- Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, context);
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
Entity mapping;
try {
mapping = entityhub.getMappingBySource(entity);
@@ -691,7 +692,7 @@ public class EntityhubRootResource exten
.header(HttpHeaders.ACCEPT, acceptedMediaType).build();
}
}
- Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, context);
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
Collection<Entity> mappings;
try {
mappings = entityhub.getMappingsByTarget(symbol);
@@ -712,4 +713,33 @@ public class EntityhubRootResource exten
return rb.build();
}
}
+ /*
+ * LDPath support
+ */
+ @OPTIONS
+ @Path("/ldpath")
+ public Response handleCorsPreflightLDPath(@Context HttpHeaders headers){
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers,OPTIONS,GET,POST);
+ return res.build();
+ }
+ @GET
+ @Path("/ldpath")
+ public Response handleLDPathGet(
+ @QueryParam(value = "context")Set<String> contexts,
+ @QueryParam(value = "ldpath")String ldpath,
+ @Context HttpHeaders headers){
+ return handleLDPathPost(contexts, ldpath, headers);
+ }
+ @POST
+ @Path("/ldpath")
+ public Response handleLDPathPost(
+ @FormParam(value = "context")Set<String> contexts,
+ @FormParam(value = "ldpath")String ldpath,
+ @Context HttpHeaders headers){
+ Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
+ return handleLDPathRequest(this,new YardBackend(entityhub.getYard()),
+ ldpath, contexts, headers, servletContext);
+ }
+
}
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource.java Fri Dec 9 15:02:09 2011
@@ -18,6 +18,7 @@ package org.apache.stanbol.entityhub.jer
import static javax.ws.rs.HttpMethod.GET;
import static javax.ws.rs.HttpMethod.OPTIONS;
+import static javax.ws.rs.HttpMethod.POST;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.MediaType.TEXT_HTML;
@@ -33,6 +34,7 @@ import static org.apache.stanbol.entityh
import static org.apache.stanbol.entityhub.jersey.utils.JerseyUtils.REPRESENTATION_SUPPORTED_MEDIA_TYPES;
import static org.apache.stanbol.entityhub.jersey.utils.JerseyUtils.createFieldQueryForFindRequest;
import static org.apache.stanbol.entityhub.jersey.utils.JerseyUtils.getAcceptableMediaType;
+import static org.apache.stanbol.entityhub.jersey.utils.LDPathHelper.handleLDPathRequest;
import java.io.File;
import java.util.Arrays;
@@ -46,7 +48,6 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
-import javax.ws.rs.HttpMethod;
import javax.ws.rs.OPTIONS;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -68,6 +69,7 @@ import org.apache.stanbol.commons.web.ba
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
import org.apache.stanbol.entityhub.jersey.parsers.FieldQueryReader;
import org.apache.stanbol.entityhub.jersey.utils.JerseyUtils;
+import org.apache.stanbol.entityhub.ldpath.backend.SiteBackend;
import org.apache.stanbol.entityhub.model.clerezza.RdfRepresentation;
import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory;
import org.apache.stanbol.entityhub.servicesapi.defaults.NamespaceEnum;
@@ -129,12 +131,12 @@ public class ReferencedSiteRootResource
private ReferencedSite site;
- public ReferencedSiteRootResource(@Context ServletContext context,
- @PathParam(value = "site") String siteId) {
+ public ReferencedSiteRootResource(@PathParam(value = "site") String siteId,
+ @Context ServletContext servletContext) {
super();
log.info("<init> with site {}", siteId);
ReferencedSiteManager referencedSiteManager = ContextHelper.getServiceFromContext(
- ReferencedSiteManager.class, context);
+ ReferencedSiteManager.class, servletContext);
if (siteId == null || siteId.isEmpty()) {
log.error("Missing path parameter site={}", siteId);
throw new WebApplicationException(Response.Status.NOT_FOUND);
@@ -400,6 +402,37 @@ public class ReferencedSiteRootResource
}
}
+ /*
+ * LDPath support
+ */
+ @OPTIONS
+ @Path("/ldpath")
+ public Response handleCorsPreflightLDPath(@Context HttpHeaders headers){
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers,OPTIONS,GET,POST);
+ return res.build();
+ }
+ @GET
+ @Path("/ldpath")
+ public Response handleLDPathGet(
+ @QueryParam(value = "context")Set<String> contexts,
+ @QueryParam(value = "ldpath")String ldpath,
+ @Context HttpHeaders headers){
+ return handleLDPathPost(contexts, ldpath, headers);
+ }
+ @POST
+ @Path("/ldpath")
+ public Response handleLDPathPost(
+ @FormParam(value = "context")Set<String> contexts,
+ @FormParam(value = "ldpath")String ldpath,
+ @Context HttpHeaders headers){
+ return handleLDPathRequest(this,new SiteBackend(site),
+ ldpath, contexts, headers, servletContext);
+ }
+
+ /*
+ * Referenced Site Metadata
+ */
/**
* Transforms a site to a Representation that can be serialised
* @param context
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java Fri Dec 9 15:02:09 2011
@@ -18,6 +18,7 @@ package org.apache.stanbol.entityhub.jer
import static javax.ws.rs.HttpMethod.GET;
import static javax.ws.rs.HttpMethod.OPTIONS;
+import static javax.ws.rs.HttpMethod.POST;
import static javax.ws.rs.core.MediaType.TEXT_HTML;
import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.N3;
import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.N_TRIPLE;
@@ -27,6 +28,7 @@ import static org.apache.clerezza.rdf.co
import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.X_TURTLE;
import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
+import static org.apache.stanbol.entityhub.jersey.utils.LDPathHelper.handleLDPathRequest;
import java.util.Arrays;
import java.util.Collection;
@@ -56,6 +58,7 @@ import org.apache.clerezza.rdf.ontologie
import org.apache.stanbol.commons.web.base.ContextHelper;
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
import org.apache.stanbol.entityhub.jersey.utils.JerseyUtils;
+import org.apache.stanbol.entityhub.ldpath.backend.SiteManagerBackend;
import org.apache.stanbol.entityhub.servicesapi.model.Entity;
import org.apache.stanbol.entityhub.servicesapi.query.FieldQuery;
import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteManager;
@@ -89,11 +92,9 @@ public class SiteManagerRootResource ext
*/
private static final int DEFAULT_FIND_RESULT_LIMIT = 5;
- private ServletContext context;
-
- public SiteManagerRootResource(@Context ServletContext context) {
+
+ public SiteManagerRootResource() {
super();
- this.context = context;
}
@OPTIONS
@@ -156,9 +157,9 @@ public class SiteManagerRootResource ext
addCORSOrigin(servletContext, rb, headers);
return rb.build();
} else {
- JSONArray referencedSites = new JSONArray();
ReferencedSiteManager referencedSiteManager = ContextHelper.getServiceFromContext(
- ReferencedSiteManager.class, context);
+ ReferencedSiteManager.class, servletContext);
+ JSONArray referencedSites = new JSONArray();
for (String site : referencedSiteManager.getReferencedSiteIds()) {
referencedSites.put(String.format("%sentityhub/site/%s/", uriInfo.getBaseUri(), site));
}
@@ -208,14 +209,8 @@ public class SiteManagerRootResource ext
}
}
ReferencedSiteManager referencedSiteManager = ContextHelper.getServiceFromContext(
- ReferencedSiteManager.class, context);
- Entity sign;
- // try {
- sign = referencedSiteManager.getEntity(id);
- // } catch (IOException e) {
- // log.error("IOException while accessing ReferencedSiteManager",e);
- // throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
- // }
+ ReferencedSiteManager.class, servletContext);
+ Entity sign = referencedSiteManager.getEntity(id);
if (sign != null) {
ResponseBuilder rb = Response.ok(sign);
rb.header(HttpHeaders.CONTENT_TYPE, acceptedMediaType+"; charset=utf-8");
@@ -286,7 +281,7 @@ public class SiteManagerRootResource ext
}
}
ReferencedSiteManager referencedSiteManager = ContextHelper.getServiceFromContext(
- ReferencedSiteManager.class, context);
+ ReferencedSiteManager.class, servletContext);
FieldQuery query = JerseyUtils.createFieldQueryForFindRequest(name, field, language,
limit == null || limit < 1 ? DEFAULT_FIND_RESULT_LIMIT : limit, offset);
ResponseBuilder rb = Response.ok(referencedSiteManager.find(query));
@@ -320,8 +315,6 @@ public class SiteManagerRootResource ext
@Consumes( {MediaType.APPLICATION_JSON})
public Response queryEntities(FieldQuery query,
@Context HttpHeaders headers) {
- ReferencedSiteManager referencedSiteManager = ContextHelper.getServiceFromContext(
- ReferencedSiteManager.class, context);
Collection<String> supported = new HashSet<String>(JerseyUtils.QUERY_RESULT_SUPPORTED_MEDIA_TYPES);
supported.add(TEXT_HTML);
final MediaType acceptedMediaType = JerseyUtils.getAcceptableMediaType(
@@ -337,11 +330,42 @@ public class SiteManagerRootResource ext
.header(HttpHeaders.ACCEPT, acceptedMediaType).build();
}
} else {
- ResponseBuilder rb = Response.ok(referencedSiteManager.find(query));
+ ReferencedSiteManager referencedSiteManager = ContextHelper.getServiceFromContext(
+ ReferencedSiteManager.class, servletContext);
+ ResponseBuilder rb = Response.ok(referencedSiteManager.find(query));
rb.header(HttpHeaders.CONTENT_TYPE, acceptedMediaType+"; charset=utf-8");
addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
}
-
+ /*
+ * LDPath support
+ */
+ @OPTIONS
+ @Path("/ldpath")
+ public Response handleCorsPreflightLDPath(@Context HttpHeaders headers){
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers,OPTIONS,GET,POST);
+ return res.build();
+ }
+ @GET
+ @Path("/ldpath")
+ public Response handleLDPathGet(
+ @QueryParam(value = "context")Set<String> contexts,
+ @QueryParam(value = "ldpath")String ldpath,
+ @Context HttpHeaders headers){
+ return handleLDPathPost(contexts, ldpath, headers);
+ }
+ @POST
+ @Path("/ldpath")
+ public Response handleLDPathPost(
+ @FormParam(value = "context")Set<String> contexts,
+ @FormParam(value = "ldpath")String ldpath,
+ @Context HttpHeaders headers){
+ ReferencedSiteManager referencedSiteManager = ContextHelper.getServiceFromContext(
+ ReferencedSiteManager.class, servletContext);
+ return handleLDPathRequest(this,new SiteManagerBackend(referencedSiteManager),
+ ldpath, contexts, headers, servletContext);
+ }
+
}
Added: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java?rev=1212465&view=auto
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java (added)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java Fri Dec 9 15:02:09 2011
@@ -0,0 +1,155 @@
+package org.apache.stanbol.entityhub.jersey.utils;
+
+import static javax.ws.rs.core.MediaType.TEXT_HTML;
+import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
+import static org.apache.stanbol.entityhub.ldpath.LDPathUtils.getReader;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
+import org.apache.stanbol.entityhub.jersey.resource.EntityhubRootResource;
+import org.apache.stanbol.entityhub.jersey.resource.ReferencedSiteRootResource;
+import org.apache.stanbol.entityhub.jersey.resource.SiteManagerRootResource;
+import org.apache.stanbol.entityhub.ldpath.EntityhubLDPath;
+import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.jersey.api.view.Viewable;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.exception.LDPathParseException;
+import at.newmedialab.ldpath.model.programs.Program;
+
+public class LDPathHelper {
+ private static final Logger log = LoggerFactory.getLogger(LDPathHelper.class);
+ /**
+ * Executes the LDPath program on the contexts stored in the backend and
+ * returns the result as an RDF graph
+ * @param contexts the contexts to execute the program on
+ * @param ldpath the LDPath program to execute
+ * @param backend the {@link RDFBackend} to use
+ * @return The results stored within an RDF graph
+ * @throws LDPathParseException if the parsed LDPath program is invalid
+ */
+ private static MGraph executeLDPath(RDFBackend<Object> backend,
+ String ldpath,
+ Set<String> contexts ) throws LDPathParseException {
+ MGraph data = new SimpleMGraph();
+ RdfValueFactory vf = new RdfValueFactory(data);
+ EntityhubLDPath ldPath = new EntityhubLDPath(backend,vf);
+ Program<Object> program = ldPath.parseProgram(getReader(ldpath));
+ if(log.isDebugEnabled()){
+ log.debug("Execute on Context(s) '{}' LDPath program: \n{}",
+ contexts,program.getPathExpression(backend));
+ }
+ /*
+ * NOTE: We do not need to process the Representations returned by
+ * EntityhubLDPath#exdecute, because the RdfValueFactory used uses
+ * the local variable "MGraph data" to backup all created
+ * RdfRepresentation. Because of this all converted data will be
+ * automatically added the MGraph. The only thing we need to do is to
+ * wrap the MGraph in the response.
+ */
+ for(String context : contexts){
+ ldPath.execute(vf.createReference(context), program);
+ }
+ return data;
+ }
+ /**
+ * Utility that gets the messages of the parsing error. The message about the
+ * problem is contained in some parent Exception. Therefore this follows
+ * {@link Exception#getCause()}s. The toString method of the returned map
+ * will print the "exception: message" in the correct order.
+ * @param e the exception
+ * @return the info useful to replay in BAD_REQUEST responses
+ */
+ private static Map<String,String> getLDPathParseExceptionMessage(LDPathParseException e) {
+ Map<String,String> messages = new LinkedHashMap<String,String>();
+ Throwable t = e;
+ do { // the real parsing error is in some cause ...
+ messages.put(t.getClass().getSimpleName(),t.getMessage()); // ... so collect all messages
+ t = t.getCause();
+ } while (t != null);
+ return messages;
+ }
+ /**
+ * Processes LDPath requests as supported by the {@link SiteManagerRootResource},
+ * {@link ReferencedSiteRootResource}, {@link EntityhubRootResource}.
+ * @param resource The resource used as context when sending RESTful Service API
+ * {@link Viewable} as response entity.
+ * @param backend The {@link RDFBackend} implementation
+ * @param ldpath the parsed LDPath program
+ * @param contexts the Entities to execute the LDPath program
+ * @param headers the parsed HTTP headers (used to determine the accepted
+ * content type for the response
+ * @param servletContext The Servlet context needed for CORS support
+ * @return the Response {@link Status#BAD_REQUEST} or {@link Status#OK}.
+ */
+ public static Response handleLDPathRequest(BaseStanbolResource resource,
+ RDFBackend<Object> backend,
+ String ldpath,
+ Set<String> contexts,
+ HttpHeaders headers,
+ ServletContext servletContext) {
+ Collection<String> supported = new HashSet<String>(JerseyUtils.ENTITY_SUPPORTED_MEDIA_TYPES);
+ supported.add(TEXT_HTML);
+ final MediaType acceptedMediaType = JerseyUtils.getAcceptableMediaType(headers,
+ supported, MediaType.APPLICATION_JSON_TYPE);
+ boolean printDocu = false;
+ //remove null and "" element
+ contexts.remove(null);
+ contexts.remove("");
+ if(contexts == null || contexts.isEmpty()){
+ if(MediaType.TEXT_HTML_TYPE.isCompatible(acceptedMediaType)){
+ printDocu = true;
+ } else {
+ return Response.status(Status.BAD_REQUEST)
+ .entity("No context was provided by the Request. Missing parameter context.\n")
+ .header(HttpHeaders.ACCEPT, acceptedMediaType).build();
+ }
+ }
+ if(!printDocu & (ldpath == null || ldpath.isEmpty())){
+ if(MediaType.TEXT_HTML_TYPE.isCompatible(acceptedMediaType)){
+ printDocu = true;
+ } else {
+ return Response.status(Status.BAD_REQUEST)
+ .entity("No ldpath program was provided by the Request. Missing or empty parameter ldpath.\n")
+ .header(HttpHeaders.ACCEPT, acceptedMediaType).build();
+ }
+ }
+ if(printDocu){ //a missing parameter and the content type is compatible to HTML
+ ResponseBuilder rb = Response.ok(new Viewable("ldpath", resource));
+ rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8");
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ }
+ MGraph data;
+ try {
+ data = executeLDPath(backend, ldpath, contexts);
+ } catch (LDPathParseException e) {
+ log.warn("Unable to parse LDPath program:\n"+ldpath,e);
+ return Response.status(Status.BAD_REQUEST)
+ .entity(("Unable to parse LDPath program (Messages: "+
+ getLDPathParseExceptionMessage(e)+")!\n"))
+ .header(HttpHeaders.ACCEPT, acceptedMediaType).build();
+ }
+ ResponseBuilder rb = Response.ok(data);
+ rb.header(HttpHeaders.CONTENT_TYPE, acceptedMediaType+"; charset=utf-8");
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ }
+}
Propchange: incubator/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/imports/ldpathdocumentation.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/imports/ldpathdocumentation.ftl?rev=1212465&view=auto
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/imports/ldpathdocumentation.ftl (added)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/imports/ldpathdocumentation.ftl Fri Dec 9 15:02:09 2011
@@ -0,0 +1,125 @@
+<#--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<h3>LD Path Language:</h3>
+
+<p><strong>NOTE:</strong> This only provides a short overview. A much more
+complete <a href="http://code.google.com/p/ldpath/wiki/PathLanguage">
+documentation</a> is also available on the
+<a href="http://code.google.com/p/ldpath/">LDPath project</a> home.</p>
+
+<h3>Namespace Definitions</h3>
+
+<p>Define shortcut names for URI prefixes, like in SPARQL or N3.</p>
+
+<pre><code>@prefix PREFIX : <URI>
+</code></pre>
+
+<p>where PREFIX is a shortcut name for the uri URI.</p>
+
+<p><em>Example:</em></p>
+
+<pre><code>@prefix foaf : <http://xmlns.com/foaf/0.1/>;
+</code></pre>
+
+<h3>Field Definitions</h3>
+
+<p>Define fields in the search index to map to path definitions.</p>
+
+<pre><code>FIELDNAME = PATH :: FIELDTYPE FIELDCONF
+</code></pre>
+
+<p>where PATH is an RDF path and FIELDTYPE is one of the available field types.
+FIELDCONF is an optional field configuration.</p>
+
+<p><em>Example:</em></p>
+
+<pre><code>title = foaf:name :: xsd:string ;
+</code></pre>
+
+<h3>Path Selectors</h3>
+
+<p>The path language supports a number of path selectors that start at the current
+"context node" and return a collection of nodes when applied. The following is
+a short overview over the different selectors, detailed documentation follows
+below:</p>
+
+<ul>
+<li><p>Property Selections (URI or prefix:local): select the values of a property</p>
+
+<pre><code>title = foaf:name :: xsd:string ;
+title = <http://xmlns.com/foaf/0.1/name> :: xsd:string;
+</code></pre></li>
+<li><p>Reverse Property Selections (^URI or ^prefix:local)</p>
+
+<pre><code>childs = ^skos:parent :: xsd:string ;
+</code></pre></li>
+<li><p>Wildcard Selections (*): select the values of all properties</p>
+
+<pre><code>all = * :: xsd:string ;
+</code></pre></li>
+<li><p>Self Selector (.): select the current context node</p></li>
+<li><p>Path Traversal (/): follow a path of selectors recursively</p>
+
+<pre><code>friend = foaf:knows/foaf:name :: xsd:string;
+</code></pre></li>
+<li><p>Unions (|): join the results of two selections in one collection</p>
+
+<pre><code>friend = foaf:knows/foaf:name | foaf:knows/rdfs:label :: xsd:string;
+</code></pre></li>
+<li><p>Intersections (&): build the intersection of the results of two selections</p>
+
+<pre><code>topic_interests = foaf:interest & foaf:topic</em>interest :: xsd:anyURI;
+</code></pre></li>
+<li><p>Recursive Selections ((PATH)+)</p>
+<li><p>Tests ([...]): filter the collection based on test criteria</p>
+
+<ul><li>Path Existence Test (PATH): only resources where a subpath yields some value</li>
+<li><p>Language Test (@language): only literals of a certain language</p>
+
+<pre><code>title = rdfs:label[@de] | rdfs:label[@none] :: xsd:string ;
+</code></pre></li>
+<li><p>Type Test (^^xsd:type): only literals of a certain type</p>
+
+<pre><code>decimals = *[^^xsd:decimal] :: xsd:decimal
+</code></pre></li>
+<li><p>Path Value Test (is): only resources with a subpath yielding a given value</p>
+
+<pre><code>food = foaf:interest[rdf:type is ex:Food] :: xsd:anyURI;
+</code></pre></li>
+<li><p>Test Conjunction and Disjunction</p>
+
+<pre><code>foodstuff = foaf:interest[rdf:type is ex:Food | rdf:type is ex:Drink] :: xsd:anyURI ;
+fluidfood = foaf:interest[rdf:type is ex:Food & rdf:type is ex:Drink] :: xsd:anyURI ;
+</code></pre></li>
+<li><p>Combinations of Tests</p>
+
+<pre><code>foodstuff = foaf:interest[rdf:type is ex:Food]/rdfs:label[@es] :: xsd:string ;
+</code></pre></li>
+</ul>
+<li><p>Functions (f(...)): apply a function on the values of the selections passed as argument</p>
+
+<pre><code>friends = foaf:knows/fn:concat(foaf:given," ",foaf:surname) :: xsd:string ;
+friends = foaf:knows/(fn:concat(foaf:given," ",foaf:surname) | foaf:name) :: xsd:string ;
+label = fn:first(skos:prefLabel[@de], skos:prefLabel) :: xsd:string ;
+content = fn:removeTags(ex:hasHtmlContent) :: xsd:string ;
+title = fn:xpath("//head/title/text()", ex:hasHtmlContent) :: xsd:string ;
+
+//'fn:content' retrieve the human-readable content (e.g. in HTML) t
+// hat is associated with a resource,
+content = fn:content(foaf:homepage) :: xsd:string ;</p></li></ul></li>
+</code></pre></li>
+</ul>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/entity.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/entity.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/entity.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/entity.ftl Fri Dec 9 15:02:09 2011
@@ -18,20 +18,9 @@
<#escape x as x?html>
<@common.page title="Entityhub Entity" hasrestapi=true>
-<div class="panel" id="webview">
- <p>
- This is the page to get/create/update/delete Entities Managed by the entity
- hub.
- </p>
- <p>TODO:</p>
-</div>
+<h3>Service Endpoint <a href="${it.publicBaseUri}entityhub/entity">/entityhub/entity</a></h3>
-<div class="panel" id="restapi" style="display: none;">
- <h3>Service Endpoint <a href="${it.publicBaseUri}entityhub/entity">/entityhub/entity</a></h3>
-
- <#include "inc_entity.ftl">
-
-</div>
+<#include "inc_entity.ftl">
</...@common.page>
</#escape>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_entity.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_entity.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_entity.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_entity.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource entityhub/entity</h4>
+<h3>Subresource entityhub/entity</h3>
<p>Service to get/create/update and delete Entities managed by the Entityhub.
<h4> GET entityhub/entity</h4>
<table>
@@ -38,10 +38,10 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl "${it.publicBaseUri}entityhub/entity?id=</pre>
-<h5>Test</h5>
+<h4>Test</h4>
<form id="getEntityForUriForm">
<p>Get entity for URI
@@ -98,7 +98,7 @@ function getEntityForUri() {
</tr>
</tbody>
</table>
-<h5>Examples:</h5>
+<h4>Examples:</h4>
<p> The following request would create all Entities defines within {file.rdf} in
the entityhub. If any of such Entities already exists within the Entityhub the
request would fail with BAD REQUEST</p>
@@ -138,7 +138,7 @@ all triples with a subject other that {i
</tr>
</tbody>
</table>
-<h5>Examples:</h5>
+<h4>Examples:</h4>
<p> The following request would update/create all Entities defines within {file.rdf} in
the entityhub. Non existent Entities will be created and already existing one will be
updated (replaced with the submitted version).</p>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_find.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_find.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_find.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_find.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /entity/find?name={name}</h4>
+<h3>Subresource /entity/find?name={name}</h3>
<table>
<tbody>
@@ -50,13 +50,13 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<p>The following query would search for Entities with a 'rdfs:label' that starts
with 'Pari'.</p>
<pre>curl -X POST -d "name=Pari*&field=http://www.w3.org/2000/01/rdf-schema#label" ${it.publicBaseUri}entityhub/sites/find</pre>
-<h5>Test</h5>
+<h4>Test</h4>
<p>Find symbol by searching for 'Paris' for the language 'de'.<br>
<a href="#" onclick="findSymbol(); return false;">Go and find symbol</a>
Added: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_ldpath.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_ldpath.ftl?rev=1212465&view=auto
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_ldpath.ftl (added)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_ldpath.ftl Fri Dec 9 15:02:09 2011
@@ -0,0 +1,101 @@
+<#--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<h3> Subresource /ldpath (/ldpath?ldpath={ldpath}&context={context})</h3>
+<table>
+<tbody>
+ <tr>
+ <th>Description</th>
+ <td>This service can be used to execute an LDPath program on one or more
+ Entities (contexts). Both a POST and a GET version are available.</td>
+ </tr>
+ <tr>
+ <th>Request</th>
+ <td><ul>
+ <li>GET /entityhub/ldpath?ldpath=ldpath&context={context1}[&context={contextn}]</li>
+ <li>POST -d "ldpath=ldpath&context={context1}[&context={contextn}]" /entityhub/ldpath</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <th>Parameter</th>
+ <td><ul><li>ldpath: The LDPath program to execute.</li>
+ <li>context: The id of the entity used as context for the execution
+ of the LDPath program. This parameter can occur multiple times</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <th>Produces:</th>
+ <td>Produces an RDF Graph with the parsed context(s) as subject the
+ field selected by the LDPath program as properties and the selected
+ values as object. All RDF serialisations are supported however
+ JSON-LD seams to be a natural fit for the data created by LDPath.
+ JSON-LD is also the default encoding.</td>
+ </tr>
+</tbody>
+</table>
+
+<h4>Example</h4>
+<p>The following LDPath statement will be executed on the defined contexts</p>
+
+<pre>curl -X POST -d "context=http://dbpedia.org/resource/Paris&ldpath=name%20%3D%20rdfs%3Alabel%5B%40en%5D%3B" ${it.publicBaseUri}entityhub/ldpath</pre>
+
+<p> NOTE: the LDPath MUST BE URLEncoded. The decoded string of the above example is
+"name = rdfs:label[@en];" and would select the english label of Paris in the field "name".</p>
+
+<h4>Test</h4>
+
+<p>Execute the LDPath on the Context:<br>
+<form name="ldpathExample" id="ldpathExample">
+ <input type="text" size="150" name="context">
+ <textarea class="input" name="ldpath" rows="10">@prefix dct : <http://purl.org/dc/terms/subject/> ;
+@prefix geo : <http://www.w3.org/2003/01/geo/wgs84_pos#> ;
+name = rdfs:label[@en] :: xsd:string;
+labels = rdfs:label :: xsd:string;
+comment = rdfs:comment[@en] :: xsd:string;
+categories = dct:subject :: xsd:anyURI;
+homepage = foaf:homepage :: xsd:anyURI;
+location = fn:concat("[",geo:lat,",",geo:lon,"]") :: xsd:string;</textarea>
+ <input type="submit" value="Execute" onclick="executeLDPath(); return false;" /></p>
+</form>
+</p>
+
+<script language="javascript">
+function executeLDPath() {
+ $("#ldpathExampleResult").hide();
+ $("#ldpathExampleResultText").text("... waiting for results ...");
+ $("#ldpathExampleResult").show();
+ $.ajax({
+ type: 'POST',
+ url: "${it.publicBaseUri}entityhub/ldpath" ,
+ data: $("#ldpathExample").serialize(),
+ dataType: "text",
+ cache: false,
+ success: function(data) {
+ $("#ldpathExampleResultText").text(data);
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ $("#ldpathExampleResultText").text(jqXHR.statusText + " - " + jqXHR.responseText);
+ }
+ });
+}
+</script>
+
+<div id="ldpathExampleResult" style="display: none">
+<p><a href="#" onclick="$('#findSymbolResult').hide(); return false;">Hide results</a>
+<pre id="ldpathExampleResultText">... waiting for results ...</pre>
+</div>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_lookup.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_lookup.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_lookup.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_lookup.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /lookup?id={uri}&create={create}</h4>
+<h3>Subresource /lookup?id={uri}&create={create}</h3>
<table>
<tbody>
@@ -58,11 +58,11 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl "${it.publicBaseUri}entityhub/lookup/?id=http://dbpedia.org/resource/Paris&create=false"</pre>
-<h5>Test</h5>
+<h4>Test</h4>
<ul>
<li><a href="#" onclick="lookupEntity('http://dbpedia.org/resource/Paris',false); return false;">Lookup symbol for
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /mapping?id={URI}</h4>
+<h3>Subresource /mapping?id={URI}</h3>
<table>
<tbody>
@@ -38,10 +38,10 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl "${it.publicBaseUri}entityhub/mapping?id=</pre>
-<h5>Test</h5>
+<h4>Test</h4>
<form id="getMappingForUriForm">
<p>Get mapping for URI
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_entity.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_entity.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_entity.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_entity.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /mapping/entity</h4>
+<h3>Subresource /mapping/entity</h3>
<table>
<tbody>
@@ -40,11 +40,11 @@
</tbody>
</table>
-<h5>Example</h5>
+<h3>Example</h3>
<pre>curl ${it.publicBaseUri}entityhub/mapping/entity?id=http://dbpedia.org/resource/Paris</pre>
-<h5>Test</h5>
+<h4>Test</h4>
<form id="getMappingForEntityForm">
<p>Get mapping for entity
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_symbol.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_symbol.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_symbol.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_mapping_symbol.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /mapping/symbol</h4>
+<h3>Subresource /mapping/symbol</h3>
<table>
<tbody>
@@ -43,11 +43,11 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl ${it.publicBaseUri}entityhub/mapping/symbol?id=urn:org.apache.stanbol:entityhub:symbol.1265dfa5-f39a-a033-4d0a-0dc0bfb53fb7</pre>
-<h5>Test</h5>
+<h4>Test</h4>
<form id="getMappingForSymbolForm">
<p>Get mapping for symbol
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_query.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_query.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_query.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/inc_query.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /query</h4>
+<h3>Subresource /query</h3>
<table>
<tbody>
@@ -39,7 +39,7 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl -X POST -H "Content-Type:application/json" --data "@fieldQuery.json" ${it.publicBaseUri}entityhub/query</pre>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/index.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/index.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/index.ftl Fri Dec 9 15:02:09 2011
@@ -18,12 +18,12 @@
<#escape x as x?html>
<@common.page title="Entityhub" hasrestapi=true>
-<div class="panel" id="webview">
+<!-- <div class="panel" id="webview">
<p>This is the start page of the entity hub.</p>
-</div>
+</div> -->
-<div class="panel" id="restapi" style="display: none;">
+<!-- div class="panel" id="restapi" style="display: none;" -->
<h3>Service Endpoints</h3>
<p>The Entityhub provide two main service. First it allows to manage a network
@@ -76,6 +76,9 @@
<a href="${it.publicBaseUri}entityhub/sites">Referenced Sites</a> and
the import of found Entities to the Entityhub.
</li>
+ <li>LDPath @<a href="${it.publicBaseUri}entityhub/ldpath">/entityhub/ldpath</a>:
+ Allows to execute LDPath programs on locally managed Entities.
+ </li>
</ul>
<hr>
<#include "inc_entity.ftl">
@@ -85,7 +88,9 @@
<#include "inc_find.ftl">
<hr>
<#include "inc_query.ftl">
-</div>
+ <hr>
+ <#include "inc_ldpath.ftl">
+<!-- /div -->
</...@common.page>
</#escape>
Added: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/ldpath.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/ldpath.ftl?rev=1212465&view=auto
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/ldpath.ftl (added)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/EntityhubRootResource/ldpath.ftl Fri Dec 9 15:02:09 2011
@@ -0,0 +1,26 @@
+<#--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<#import "/imports/common.ftl" as common>
+<#escape x as x?html>
+<@common.page title="Entityhub LDPath" hasrestapi=false>
+
+<#include "inc_ldpath.ftl">
+<hr>
+<#include "/imports/ldpathdocumentation.ftl">
+
+</...@common.page>
+</#escape>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_entity.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_entity.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_entity.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_entity.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /entity?id={URI}</h4>
+<h3>Subresource /entity?id={URI}</h3>
<table>
<tbody>
@@ -41,21 +41,25 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl "${it.publicBaseUri}entityhub/site/dbpedia/entity?id=http://dbpedia.org/resource/Paris"</pre>
-<!-- TODO: Adapt this to work with referenced sites
-<h5>Test</h5>
+<h4>Test</h4>
<a href="#" onclick="searchEntityParis(); return false;">Search for entity 'Paris' in DBPedia</a>.
<script language="javascript">
function searchEntityParis() {
+ var relpath = "/entity";
+ var base = window.location.href.replace(/\/$/, "");
+ if(base.lastIndexOf(relpath) != (base.length-relpath.length)){
+ base = base+relpath;
+ }
$("#searchEntityParisResult").show();
$.ajax({
type: "GET",
- url: "${it.publicBaseUri}entityhub/sites/entity",
+ url: base,
data: "id=http://dbpedia.org/resource/Paris",
dataType: "text",
cache: false,
@@ -72,4 +76,4 @@ function searchEntityParis() {
<div id="searchEntityParisResult" style="display: none">
<p><a href="#" onclick="$('#searchEntityParisResult').hide(); return false;">Hide results</a>
<pre id="searchEntityParisResultText">... waiting for results ...</pre>
-</div> -->
+</div>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_find.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_find.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_find.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_find.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /find?name={name}</h4>
+<h3>Subresource /find?name={name}</h3>
<table>
<tbody>
@@ -51,11 +51,11 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl -X POST -d "name=Bishofsh*&limit=10&offset=0" ${it.publicBaseUri}entityhub/site/dbpedia/find</pre>
-<h5>Test</h5>
+<h4>Test</h4>
<form>
<p>Start test search for
@@ -65,12 +65,17 @@
<script language="javascript">
function startTestSearch() {
+ var relpath = "/find";
+ var base = window.location.href.replace(/\/$/, "");
+ if(base.lastIndexOf(relpath) != (base.length-relpath.length)){
+ base = base+relpath;
+ }
$("#testSearchResultText").text("... waiting for results ...");
$("#testSearchResult").show();
var data = "name=" + $("#testSearchValue").val() + "&limit=10&offset=0";
$.ajax({
type: "POST",
- url: window.location.href.replace(/\/$/, "") + "/find", //normalise trailing '/'
+ url: base,
data: data,
dataType: "text",
cache: false,
Added: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_ldpath.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_ldpath.ftl?rev=1212465&view=auto
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_ldpath.ftl (added)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_ldpath.ftl Fri Dec 9 15:02:09 2011
@@ -0,0 +1,107 @@
+<#--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<h3>Subresource LDPath (/ldpath?ldpath={ldpath}&context={context})</h3>
+<table>
+<tbody>
+ <tr>
+ <th>Description</th>
+ <td>This service can be used to execute an LDPath program on one or more
+ Entities (contexts). Both a POST and a GET version are available.</td>
+ </tr>
+ <tr>
+ <th>Request</th>
+ <td><ul>
+ <li>GET /entityhub/ldpath?ldpath=ldpath&context={context1}[&context={contextn}]</li>
+ <li>POST -d "ldpath=ldpath&context={context1}[&context={contextn}]" /entityhub/ldpath</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <th>Parameter</th>
+ <td><ul><li>ldpath: The LDPath program to execute.</li>
+ <li>context: The id of the entity used as context for the execution
+ of the LDPath program. This parameter can occur multiple times</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <th>Produces:</th>
+ <td>Produces an RDF Graph with the parsed context(s) as subject the
+ field selected by the LDPath program as properties and the selected
+ values as object. All RDF serialisations are supported however
+ JSON-LD seams to be a natural fit for the data created by LDPath.
+ JSON-LD is also the default encoding.</td>
+ </tr>
+</tbody>
+</table>
+
+<h4>Example</h4>
+<p>The following LDPath statement will be executed on the defined contexts</p>
+
+<pre>curl -X POST -d "context=http://dbpedia.org/resource/Paris&ldpath=name%20%3D%20rdfs%3Alabel%5B%40en%5D%3B" ${it.publicBaseUri}entityhub/site/dbpedia/ldpath</pre>
+
+<p> NOTE: the LDPath MUST BE URLEncoded. The decoded string of the above example is
+"name = rdfs:label[@en];" and would select the english label of Paris in the field "name".</p>
+
+<h4>Test</h4>
+
+<p>Execute the LDPath on the Context:<br>
+<form name="ldpathExample" id="ldpathExample">
+ <input type="text" size="150" name="context" value="http://dbpedia.org/resource/Paris">
+ <textarea class="input" name="ldpath" rows="10">@prefix dct : <http://purl.org/dc/terms/subject/> ;
+@prefix geo : <http://www.w3.org/2003/01/geo/wgs84_pos#> ;
+name = rdfs:label[@en] :: xsd:string;
+labels = rdfs:label :: xsd:string;
+comment = rdfs:comment[@en] :: xsd:string;
+categories = dct:subject :: xsd:anyURI;
+homepage = foaf:homepage :: xsd:anyURI;
+location = fn:concat("[",geo:lat,",",geo:lon,"]") :: xsd:string;</textarea>
+ <input type="submit" value="Execute" onclick="executeLDPath(); return false;" /></p>
+</form>
+</p>
+
+<script language="javascript">
+function executeLDPath() {
+ var relpath = "/ldpath";
+ var base = window.location.href.replace(/\/$/, "");
+ if(base.lastIndexOf(relpath) != (base.length-relpath.length)){
+ base = base+relpath;
+ }
+ $("#ldpathExampleResult").hide();
+ $("#ldpathExampleResultText").text("... waiting for results ...");
+ $("#ldpathExampleResult").show();
+ $.ajax({
+ type: 'POST',
+ url: base ,
+ data: $("#ldpathExample").serialize(),
+ dataType: "text",
+ cache: false,
+ success: function(data) {
+ $("#ldpathExampleResultText").text(data);
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ $("#ldpathExampleResultText").text(jqXHR.statusText + " - " + jqXHR.responseText);
+ }
+ });
+}
+</script>
+
+<div id="ldpathExampleResult" style="display: none">
+<p><a href="#" onclick="$('#findSymbolResult').hide(); return false;">Hide results</a>
+<pre id="ldpathExampleResultText">... waiting for results ...</pre>
+</div>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_metadata.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_metadata.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_metadata.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_metadata.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Referenced Site Metadata </h4>
+<h3>Referenced Site Metadata </h3>
<table>
<tbody>
@@ -49,10 +49,10 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl -H "Accept: application/rdf+xml" "${it.publicBaseUri}entityhub/site/dbpedia"</pre>
-<h5>Test</h5>
+<h4>Test</h4>
<p>You can the metadata of this referenced site by
<a href="#" onclick="getSiteMetadata(); return false;">clicking here</a>.</p>
@@ -65,7 +65,7 @@ function getSiteMetadata() {
req.setRequestHeader("Accept", "application/rdf+xml");
},
type: "GET",
- url: window.location.href,
+ url: window.location.href.replace(/\/$/, ""),
cache: false,
data: "",
dataType: "text",
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_query.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_query.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_query.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/inc_query.ftl Fri Dec 9 15:02:09 2011
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<h4>Subresource /query</h4>
+<h3>Subresource /query</h3>
<table>
<tbody>
@@ -39,7 +39,7 @@
</tbody>
</table>
-<h5>Example</h5>
+<h4>Example</h4>
<pre>curl -X POST -H "Content-Type:application/json" --data "@fieldQuery.json" ${it.publicBaseUri}entityhub/site/dbpedia/query</pre>
Modified: incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/index.ftl?rev=1212465&r1=1212464&r2=1212465&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/index.ftl (original)
+++ incubator/stanbol/trunk/entityhub/jersey/src/main/resources/org/apache/stanbol/entityhub/jersey/templates/org/apache/stanbol/entityhub/jersey/resource/ReferencedSiteRootResource/index.ftl Fri Dec 9 15:02:09 2011
@@ -23,6 +23,7 @@
<li><a href="entity">/entityhub/site/{siteId}/entity</a></li>
<li><a href="find">/entityhub/site/{siteId}/find</a></li>
<li><a href="query">/entityhub/site/{siteId}/query</a></li>
+ <li><a href="ldpath">/entityhub/site/{siteId}/ldpath</a></li>
</ul>
<hr>
<#include "inc_metadata.ftl">
@@ -32,6 +33,8 @@
<#include "inc_find.ftl">
<hr>
<#include "inc_query.ftl">
+<hr>
+<#include "inc_ldpath.ftl">
</...@common.page>
</#escape>