You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by sf...@apache.org on 2011/03/06 10:18:15 UTC
svn commit: r1078434 [2/2] - in /incubator/stanbol/trunk/enhancer:
autotagging/src/main/java/org/apache/stanbol/autotagging/ engines/
engines/geonames/src/main/java/org/apache/stanbol/enhancer/engines/geonames/impl/
engines/geonames/src/test/java/org/a...
Modified: incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java?rev=1078434&r1=1078433&r2=1078434&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/opencalais/src/main/java/org/apache/stanbol/enhancer/engines/opencalais/impl/OpenCalaisEngine.java Sun Mar 6 09:18:14 2011
@@ -69,6 +69,7 @@ import org.osgi.service.component.Compon
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.stanbol.enhancer.servicesapi.ServiceProperties.ENHANCEMENT_ENGINE_ORDERING;
import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.*;
@@ -146,7 +147,7 @@ public class OpenCalaisEngine implements
public Map<String, Object> getServiceProperties() {
// TODO Auto-generated method stub
return Collections.unmodifiableMap(Collections.singletonMap(
- ServiceProperties.ENHANCEMENT_ENGINE_ORDERING,
+ ENHANCEMENT_ENGINE_ORDERING,
(Object) defaultOrder));
}
@@ -237,7 +238,7 @@ public class OpenCalaisEngine implements
}
/**
- * This retrieves the annotations from OpenCalais as RDF/XML. From that an MGraph is created.
+ * Retrieves the annotations from OpenCalais as RDF/XML. From that an MGraph is created.
*
* @param text the text to send to OpenCalais
*
@@ -288,7 +289,7 @@ public class OpenCalaisEngine implements
}
/**
- * This parses an InputStream of RDF data and produces an MGraph from them
+ * Parses an InputStream of RDF data and produces an MGraph from them
*
* @param in The InputStream of RDF data
* @param format the format of the RDF data
@@ -309,7 +310,7 @@ public class OpenCalaisEngine implements
}
/**
- * This extracts the relevant entity information from the Calais RDF data.
+ * Extracts the relevant entity information from the Calais RDF data.
* The entities and the relted information is extracted by a Sparql query.
*
* @param model the MGraph representing the Calais data
@@ -377,7 +378,7 @@ public class OpenCalaisEngine implements
/**
- * This sends a POST request to the given url.
+ * Sends a POST request to the given url.
*
* @param targetUrl a <code>String</code> with the target url
* @param params a <code>Map<String,String></code> object containing the url parameters;
Modified: incubator/stanbol/trunk/enhancer/engines/zemanta/src/main/java/org/apache/stanbol/enhancer/engines/zemanta/impl/ZemantaEnhancementEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/zemanta/src/main/java/org/apache/stanbol/enhancer/engines/zemanta/impl/ZemantaEnhancementEngine.java?rev=1078434&r1=1078433&r2=1078434&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/zemanta/src/main/java/org/apache/stanbol/enhancer/engines/zemanta/impl/ZemantaEnhancementEngine.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/zemanta/src/main/java/org/apache/stanbol/enhancer/engines/zemanta/impl/ZemantaEnhancementEngine.java Sun Mar 6 09:18:14 2011
@@ -54,6 +54,10 @@ import org.osgi.service.component.Compon
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.*;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_CATEGORY;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_TEXTANNOTATION;
+
/**
* Apache Stanbol Enhancer Zemanta enhancement engine.
@@ -75,22 +79,23 @@ import org.slf4j.LoggerFactory;
@Service
public class ZemantaEnhancementEngine implements EnhancementEngine {
- protected static final String TEXT_PLAIN_MIMETYPE = "text/plain";
- protected static final String TEXT_HTML_MIMETYPE = "text/html";
-
- private static final Logger log = LoggerFactory.getLogger(ZemantaEnhancementEngine.class);
-
- protected BundleContext bundleContext;
-
@Property
public static final String API_KEY_PROPERTY = "org.apache.stanbol.enhancer.engines.zemanta.key";
public static final String DMOZ_BASE_URL = "http://www.dmoz.org/";
public static final String ZEMANTA_DMOZ_PREFIX = "Top/";
+
+ protected static final String TEXT_PLAIN_MIMETYPE = "text/plain";
+ protected static final String TEXT_HTML_MIMETYPE = "text/html";
+
+ private static final Logger log = LoggerFactory.getLogger(ZemantaEnhancementEngine.class);
+
private static String key;
public LiteralFactory literalFactory;
+ protected BundleContext bundleContext;
+
@Activate
@SuppressWarnings("unchecked")
protected void activate(ComponentContext ce) throws IOException {
@@ -151,11 +156,10 @@ public class ZemantaEnhancementEngine im
//annotation structure
processRecognition(results, graph, text, ciId);
processCategories(results, graph, ciId);
-
}
protected void processCategories(MGraph results, MGraph enhancements, UriRef ciId) {
- Iterator<Triple> categories = results.filter(null, Properties.RDF_TYPE, ZemantaOntologyEnum.Category.getUri());
+ Iterator<Triple> categories = results.filter(null, RDF_TYPE, ZemantaOntologyEnum.Category.getUri());
while (categories.hasNext()) {
NonLiteral category = categories.next().getSubject();
log.info("process category " + category);
@@ -172,21 +176,23 @@ public class ZemantaEnhancementEngine im
//now write the Stanbol Enhancer entity enhancement
UriRef categoryEnhancement = EnhancementEngineHelper.createEntityEnhancement(enhancements, this, ciId);
//write the title
- enhancements.add(new TripleImpl(categoryEnhancement, Properties.ENHANCER_ENTITY_LABEL, literalFactory.createTypedLiteral(categoryTitle)));
+ enhancements.add(new TripleImpl(categoryEnhancement, ENHANCER_ENTITY_LABEL, literalFactory.createTypedLiteral(categoryTitle)));
//write the reference
if (categoryTitle.startsWith(ZEMANTA_DMOZ_PREFIX)) {
- enhancements.add(new TripleImpl(categoryEnhancement, Properties.ENHANCER_ENTITY_REFERENCE, new UriRef(DMOZ_BASE_URL + categoryTitle.substring(ZEMANTA_DMOZ_PREFIX.length()))));
+ enhancements.add(
+ new TripleImpl(categoryEnhancement, ENHANCER_ENTITY_REFERENCE, new UriRef(DMOZ_BASE_URL + categoryTitle.substring(ZEMANTA_DMOZ_PREFIX.length()))));
}
//write the confidence
if (confidence != null) {
- enhancements.add(new TripleImpl(categoryEnhancement, Properties.ENHANCER_CONFIDENCE, literalFactory.createTypedLiteral(confidence)));
+ enhancements.add(
+ new TripleImpl(categoryEnhancement, ENHANCER_CONFIDENCE, literalFactory.createTypedLiteral(confidence)));
}
//we need to write the entity type and the dc:type
// see http://wiki.iks-project.eu/index.php/ZemantaEnhancementEngine#Mapping_of_Categories
// for more Information
- enhancements.add(new TripleImpl(categoryEnhancement, Properties.DC_TYPE, TechnicalClasses.ENHANCER_CATEGORY));
+ enhancements.add(new TripleImpl(categoryEnhancement, DC_TYPE, ENHANCER_CATEGORY));
//Use the Zemanta Category as type for the referred Entity
- enhancements.add(new TripleImpl(categoryEnhancement, Properties.ENHANCER_ENTITY_TYPE, ZemantaOntologyEnum.Category.getUri()));
+ enhancements.add(new TripleImpl(categoryEnhancement, ENHANCER_ENTITY_TYPE, ZemantaOntologyEnum.Category.getUri()));
} else {
log.warn("Unable to process category " + category + " because no title is present");
}
@@ -209,7 +215,7 @@ public class ZemantaEnhancementEngine im
* @param text the content of the content item as string
*/
protected void processRecognition(MGraph results, MGraph enhancements, String text, UriRef ciId) {
- Iterator<Triple> recognitions = results.filter(null, Properties.RDF_TYPE, ZemantaOntologyEnum.Recognition.getUri());
+ Iterator<Triple> recognitions = results.filter(null, RDF_TYPE, ZemantaOntologyEnum.Recognition.getUri());
while (recognitions.hasNext()) {
NonLiteral recognition = recognitions.next().getSubject();
log.info("process recognition " + recognition);
@@ -265,15 +271,19 @@ public class ZemantaEnhancementEngine im
//create the entityEnhancement
UriRef entityEnhancement = EnhancementEngineHelper.createEntityEnhancement(enhancements, this, ciId);
if (confidence != null) {
- enhancements.add(new TripleImpl(entityEnhancement, Properties.ENHANCER_CONFIDENCE, literalFactory.createTypedLiteral(confidence)));
+ enhancements.add(
+ new TripleImpl(entityEnhancement, ENHANCER_CONFIDENCE, literalFactory.createTypedLiteral(confidence)));
}
for (NonLiteral relatedTextAnnotation : textAnnotations) {
- enhancements.add(new TripleImpl(entityEnhancement, Properties.DC_RELATION, relatedTextAnnotation));
+ enhancements.add(
+ new TripleImpl(entityEnhancement, DC_RELATION, relatedTextAnnotation));
}
for (UriRef entity : sameAsSet) {
- enhancements.add(new TripleImpl(entityEnhancement, Properties.ENHANCER_ENTITY_REFERENCE, entity));
+ enhancements.add(
+ new TripleImpl(entityEnhancement, ENHANCER_ENTITY_REFERENCE, entity));
}
- enhancements.add(new TripleImpl(entityEnhancement, Properties.ENHANCER_ENTITY_LABEL, literalFactory.createTypedLiteral(title)));
+ enhancements.add(
+ new TripleImpl(entityEnhancement, ENHANCER_ENTITY_LABEL, literalFactory.createTypedLiteral(title)));
}
}
@@ -308,7 +318,8 @@ public class ZemantaEnhancementEngine im
/**
* This Methods searches/creates text annotations for anchor points of Zemanta
- * extractions.<br>
+ * extractions.
+ * <p>
* First this method searches for text annotations that do use the anchor as
* selected text. Second it searches for occurrences of the anchor within the
* content of the content and checks if there is an text annotation for that
@@ -339,13 +350,17 @@ public class ZemantaEnhancementEngine im
UriRef textAnnotation = EnhancementEngineHelper.createTextEnhancement(enhancements, this, ciId);
textAnnotations.add(textAnnotation);
//write the selection
- enhancements.add(new TripleImpl(textAnnotation, Properties.ENHANCER_START, literalFactory.createTypedLiteral(current)));
- enhancements.add(new TripleImpl(textAnnotation, Properties.ENHANCER_END, literalFactory.createTypedLiteral(current + anchorLength)));
- enhancements.add(new TripleImpl(textAnnotation, Properties.ENHANCER_SELECTED_TEXT, anchorLiteral));
+ enhancements.add(
+ new TripleImpl(textAnnotation, ENHANCER_START, literalFactory.createTypedLiteral(current)));
+ enhancements.add(
+ new TripleImpl(textAnnotation, ENHANCER_END, literalFactory.createTypedLiteral(current + anchorLength)));
+ enhancements.add(
+ new TripleImpl(textAnnotation, ENHANCER_SELECTED_TEXT, anchorLiteral));
//TODO: Currently I use the confidence of the extraction, but I think this is more
// related to the annotated Entity rather to the selected text.
if (confidence != null) {
- enhancements.add(new TripleImpl(textAnnotation, Properties.ENHANCER_CONFIDENCE, literalFactory.createTypedLiteral(confidence)));
+ enhancements.add(
+ new TripleImpl(textAnnotation, ENHANCER_CONFIDENCE, literalFactory.createTypedLiteral(confidence)));
}
//TODO: No idea about the type of the Annotation, because we do not have an type of the entity!
// One would need to get the types from the referred Source
@@ -366,13 +381,13 @@ public class ZemantaEnhancementEngine im
* text annotations as an value.
*/
private Map<Integer, Collection<NonLiteral>> searchExistingTextAnnotations(MGraph enhancements, Literal anchorLiteral) {
- Iterator<Triple> textAnnotationsIterator = enhancements.filter(null, Properties.ENHANCER_SELECTED_TEXT, anchorLiteral);
+ Iterator<Triple> textAnnotationsIterator = enhancements.filter(null, ENHANCER_SELECTED_TEXT, anchorLiteral);
Map<Integer, Collection<NonLiteral>> existingTextAnnotationsMap = new HashMap<Integer, Collection<NonLiteral>>();
while (textAnnotationsIterator.hasNext()) {
NonLiteral subject = textAnnotationsIterator.next().getSubject();
//test rdfType
- if (enhancements.contains(new TripleImpl(subject, Properties.RDF_TYPE, TechnicalClasses.ENHANCER_TEXTANNOTATION))) {
- Integer start = EnhancementEngineHelper.get(enhancements, subject, Properties.ENHANCER_START, Integer.class, literalFactory);
+ if (enhancements.contains(new TripleImpl(subject, RDF_TYPE, ENHANCER_TEXTANNOTATION))) {
+ Integer start = EnhancementEngineHelper.get(enhancements, subject, ENHANCER_START, Integer.class, literalFactory);
if (start != null) {
Collection<NonLiteral> textAnnotationList = existingTextAnnotationsMap.get(start);
if (textAnnotationList == null) {
Modified: incubator/stanbol/trunk/enhancer/engines/zemanta/src/test/java/org/apache/stanbol/enhancer/engines/zemanta/impl/ZemantaEnhancementEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/zemanta/src/test/java/org/apache/stanbol/enhancer/engines/zemanta/impl/ZemantaEnhancementEngineTest.java?rev=1078434&r1=1078433&r2=1078434&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/zemanta/src/test/java/org/apache/stanbol/enhancer/engines/zemanta/impl/ZemantaEnhancementEngineTest.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/zemanta/src/test/java/org/apache/stanbol/enhancer/engines/zemanta/impl/ZemantaEnhancementEngineTest.java Sun Mar 6 09:18:14 2011
@@ -16,6 +16,12 @@
*/
package org.apache.stanbol.enhancer.engines.zemanta.impl;
+import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.TURTLE;
+import static org.apache.stanbol.enhancer.engines.zemanta.impl.ZemantaEnhancementEngine.API_KEY_PROPERTY;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.*;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_CATEGORY;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_ENTITYANNOTATION;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_TEXTANNOTATION;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -49,15 +55,6 @@ import org.slf4j.LoggerFactory;
public class ZemantaEnhancementEngineTest {
- private static final Logger log = LoggerFactory.getLogger(ZemantaEnhancementEngineTest.class);
-
- /**
- * This key was generated to support testing only. Please do only use it
- * for testing. For real usages of the engine you need to create your own
- * key!
- */
- private static final String ZEMANTA_TEST_APPLICATION_KEY = "2qsvcvkut8rhnqbhm35znn76";
-
/**
* found on this Blog {@linkplain http://bcbio.wordpress.com/2009/01/04/extracting-keywords-from-biological-text-using-zemanta/}
*/
@@ -75,10 +72,20 @@ public class ZemantaEnhancementEngineTes
static ZemantaEnhancementEngine zemantaEngine = new ZemantaEnhancementEngine();
+
+ private static final Logger log = LoggerFactory.getLogger(ZemantaEnhancementEngineTest.class);
+
+ /**
+ * This key was generated to support testing only. Please do only use it
+ * for testing. For real usages of the engine you need to create your own
+ * key!
+ */
+ private static final String ZEMANTA_TEST_APPLICATION_KEY = "2qsvcvkut8rhnqbhm35znn76";
+
@BeforeClass
public static void setUpServices() throws IOException {
Dictionary<String, Object> properties = new Hashtable<String, Object>();
- properties.put(ZemantaEnhancementEngine.API_KEY_PROPERTY, ZEMANTA_TEST_APPLICATION_KEY);
+ properties.put(API_KEY_PROPERTY, ZEMANTA_TEST_APPLICATION_KEY);
MockComponentContext context = new MockComponentContext(properties);
zemantaEngine.activate(context);
}
@@ -87,11 +94,13 @@ public class ZemantaEnhancementEngineTes
public static void shutdownServices() {
zemantaEngine.deactivate(null);
}
+
public static ContentItem wrapAsContentItem(final String text) {
return new ContentItem() {
SimpleMGraph metadata = new SimpleMGraph();
- String id = "urn:org.apache.stanbol.enhancer:test:engines.zemanta:content-item-"+EnhancementEngineHelper.randomUUID().toString();
+ String id = "urn:org.apache.stanbol.enhancer:test:engines.zemanta:content-item-"
+ + EnhancementEngineHelper.randomUUID().toString();
public InputStream getStream() {
return new ByteArrayInputStream(text.getBytes());
@@ -110,30 +119,28 @@ public class ZemantaEnhancementEngineTes
}
};
}
+
@Test
- public void tesetBioText() throws Exception{
+ public void tesetBioText() throws Exception {
ContentItem ci = wrapAsContentItem(BIO_DOMAIN_TEXT);
zemantaEngine.computeEnhancements(ci);
JenaSerializerProvider serializer = new JenaSerializerProvider();
- serializer.serialize(System.out, ci.getMetadata(), SupportedFormat.TURTLE);
+ serializer.serialize(System.out, ci.getMetadata(), TURTLE);
int textAnnoNum = checkAllTextAnnotations(ci.getMetadata(), BIO_DOMAIN_TEXT);
log.info(textAnnoNum + " TextAnnotations found ...");
int entityAnnoNum = checkAllEntityAnnotations(ci.getMetadata());
log.info(textAnnoNum + " EntityAnnotations found ...");
}
+
/*
* -----------------------------------------------------------------------
* Helper Methods to check Text and EntityAnnotations
* -----------------------------------------------------------------------
*/
- /**
- * @param g
- * @return
- */
private int checkAllEntityAnnotations(MGraph g) {
Iterator<Triple> entityAnnotationIterator = g.filter(null,
- Properties.RDF_TYPE, TechnicalClasses.ENHANCER_ENTITYANNOTATION);
+ RDF_TYPE, ENHANCER_ENTITYANNOTATION);
int entityAnnotationCount = 0;
while (entityAnnotationIterator.hasNext()) {
UriRef entityAnnotation = (UriRef) entityAnnotationIterator.next().getSubject();
@@ -143,19 +150,17 @@ public class ZemantaEnhancementEngineTes
}
return entityAnnotationCount;
}
+
/**
- * Checks if an entity annotation is valid
- *
- * @param g
- * @param textAnnotation
+ * Checks if an entity annotation is valid.
*/
private void checkEntityAnnotation(MGraph g, UriRef entityAnnotation) {
Iterator<Triple> relationIterator = g.filter(
- entityAnnotation, Properties.DC_RELATION, null);
+ entityAnnotation, DC_RELATION, null);
Iterator<Triple> requiresIterator = g.filter(
- entityAnnotation, Properties.DC_REQUIRES, null);
+ entityAnnotation, DC_REQUIRES, null);
Iterator<Triple> dcTypeCategory = g.filter(
- entityAnnotation, Properties.DC_TYPE, TechnicalClasses.ENHANCER_CATEGORY);
+ entityAnnotation, DC_TYPE, ENHANCER_CATEGORY);
// check if the relation or an requires annotation set
// also include the DC_TYPE ENHANCER_CATEGORY, because such entityEnhancements
// do not need to have any values for DC_RELATION nor DC_REQUIRES
@@ -163,13 +168,13 @@ public class ZemantaEnhancementEngineTes
while (relationIterator.hasNext()) {
// test if the referred annotations are text annotations
UriRef referredTextAnnotation = (UriRef) relationIterator.next().getObject();
- assertTrue(g.filter(referredTextAnnotation, Properties.RDF_TYPE,
- TechnicalClasses.ENHANCER_TEXTANNOTATION).hasNext());
+ assertTrue(g.filter(referredTextAnnotation, RDF_TYPE,
+ ENHANCER_TEXTANNOTATION).hasNext());
}
// test if an entity is referred
Iterator<Triple> entityReferenceIterator = g.filter(entityAnnotation,
- Properties.ENHANCER_ENTITY_REFERENCE, null);
+ ENHANCER_ENTITY_REFERENCE, null);
assertTrue(entityReferenceIterator.hasNext());
// test if the reference is an URI
assertTrue(entityReferenceIterator.next().getObject() instanceof UriRef);
@@ -180,16 +185,13 @@ public class ZemantaEnhancementEngineTes
// finally test if the entity label is set
Iterator<Triple> entityLabelIterator = g.filter(entityAnnotation,
- Properties.ENHANCER_ENTITY_LABEL, null);
+ ENHANCER_ENTITY_LABEL, null);
assertTrue(entityLabelIterator.hasNext());
}
- /**
- * @param g
- * @return
- */
+
private int checkAllTextAnnotations(MGraph g, String content) {
Iterator<Triple> textAnnotationIterator = g.filter(null,
- Properties.RDF_TYPE, TechnicalClasses.ENHANCER_TEXTANNOTATION);
+ RDF_TYPE, ENHANCER_TEXTANNOTATION);
// test if a textAnnotation is present
assertTrue(textAnnotationIterator.hasNext());
int textAnnotationCount = 0;
@@ -203,10 +205,7 @@ public class ZemantaEnhancementEngineTes
}
/**
- * Checks if a text annotation is valid
- *
- * @param g
- * @param textAnnotation
+ * Checks if a text annotation is valid.
*/
private void checkTextAnnotation(MGraph g, UriRef textAnnotation, String content) {
Iterator<Triple> selectedTextIterator = g.filter(textAnnotation,
@@ -231,9 +230,9 @@ public class ZemantaEnhancementEngineTes
// object = null;
//test start/end if present
Iterator<Triple> startPosIterator = g.filter(textAnnotation,
- Properties.ENHANCER_START, null);
+ ENHANCER_START, null);
Iterator<Triple> endPosIterator = g.filter(textAnnotation,
- Properties.ENHANCER_END, null);
+ ENHANCER_END, null);
//start end is optional, but if start is present, that also end needs to be set
if(startPosIterator.hasNext()){
Resource resource = startPosIterator.next().getObject();
Modified: incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java?rev=1078434&r1=1078433&r2=1078434&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java (original)
+++ incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java Sun Mar 6 09:18:14 2011
@@ -129,7 +129,7 @@ public class EnginesRootResource extends
}
/**
- * Form based OpenCalais-compatible interface
+ * Form-based OpenCalais-compatible interface
*
* TODO: should we parse the OpenCalais paramsXML and find the closest
* Stanbol Enhancer semantics too?
Modified: incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java?rev=1078434&r1=1078433&r2=1078434&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java (original)
+++ incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java Sun Mar 6 09:18:14 2011
@@ -62,31 +62,30 @@ import com.sun.jersey.core.header.FormDa
import static javax.ws.rs.core.MediaType.*;
+import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.*;
/**
* Resource to provide a CRU[D] REST API for content items and there related
* enhancements.
- *
+ * <p>
* Creation is achieved using either POST requests on the root of the store or
* as PUT requests on the expected content item URI.
- *
+ * <p>
* Retrieval is achieved using simple GET requests on the content item or
* enhancement public URIs.
- *
+ * <p>
* Update is achieved by issue a PUT request on an existing content item public
* URI.
- *
+ * <p>
* The Delete operation is not implemented yet.
*/
@Path("/store")
public class StoreRootResource extends NavigationMixin {
- private static final Logger log = LoggerFactory.getLogger(StoreRootResource.class);
-
public static final Set<String> RDF_MEDIA_TYPES = new TreeSet<String>(
- Arrays.asList(SupportedFormat.N3, SupportedFormat.N_TRIPLE,
- SupportedFormat.RDF_XML, SupportedFormat.TURTLE,
- SupportedFormat.X_TURTLE, SupportedFormat.RDF_JSON));
+ Arrays.asList(N3, N_TRIPLE, RDF_XML, TURTLE, X_TURTLE, RDF_JSON));
+
+ private static final Logger log = LoggerFactory.getLogger(StoreRootResource.class);
protected TcManager tcManager;
@@ -143,7 +142,7 @@ public class StoreRootResource extends N
public StoreRootResource(@Context ServletContext context,
@Context UriInfo uriInfo, @QueryParam(value = "offset") int offset,
- @DefaultValue("5") @QueryParam(value = "pageSize") int pageSize)
+ @QueryParam(value = "pageSize") @DefaultValue("5") int pageSize)
throws ParseException {
tcManager = (TcManager) context.getAttribute(TcManager.class.getName());
store = (Store) context.getAttribute(Store.class.getName());
Modified: incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/writers/GraphWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/writers/GraphWriter.java?rev=1078434&r1=1078433&r2=1078434&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/writers/GraphWriter.java (original)
+++ incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/writers/GraphWriter.java Sun Mar 6 09:18:14 2011
@@ -20,12 +20,12 @@ import org.apache.clerezza.rdf.core.seri
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.TEXT_PLAIN;
+import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.*;
+
@Provider
-@Produces( { TEXT_PLAIN, SupportedFormat.N3,
- SupportedFormat.N_TRIPLE, SupportedFormat.RDF_XML,
- SupportedFormat.TURTLE, SupportedFormat.X_TURTLE,
- SupportedFormat.RDF_JSON, APPLICATION_JSON })
+@Produces( { TEXT_PLAIN, N3, N_TRIPLE, RDF_XML, TURTLE, X_TURTLE,
+ RDF_JSON, APPLICATION_JSON })
public class GraphWriter implements MessageBodyWriter<TripleCollection> {
@Context
Modified: incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/writers/JsonLdSerializerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/writers/JsonLdSerializerProvider.java?rev=1078434&r1=1078433&r2=1078434&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/writers/JsonLdSerializerProvider.java (original)
+++ incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/writers/JsonLdSerializerProvider.java Sun Mar 6 09:18:14 2011
@@ -22,6 +22,8 @@ import org.apache.stanbol.jsonld.JsonLdR
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
/**
* Implements a <a href="http://json-ld.org/">JSON-LD</a> serialization of a Clerezza
@@ -39,7 +41,7 @@ import org.slf4j.LoggerFactory;
@SupportedFormat(JsonLdSerializerProvider.SUPPORTED_FORMAT)
public class JsonLdSerializerProvider implements SerializingProvider {
- public static final String SUPPORTED_FORMAT = MediaType.APPLICATION_JSON;
+ public static final String SUPPORTED_FORMAT = APPLICATION_JSON;
private static final String RDF_NS_TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type";