Author: suat
Date: Mon Mar 25 14:00:37 2013
New Revision: 1460665

URL: http://svn.apache.org/r1460665
Log:
Fix for STANBOL-995:
-The name of the contentitem.ftl template has been changed to 
contenthubcontentitem.ftl to avoid the conflict between this one and the one in 
the Enhancer.
-ContentItemResource has been taken from the Enhancer. Contenthub has its own 
copy of this class not to depend on Enhancer Jersey module.

Added:
    
stanbol/trunk/contenthub/web/src/main/resources/templates/imports/contenthubcontentitem.ftl
      - copied unchanged from r1460534, 
stanbol/trunk/contenthub/web/src/main/resources/templates/imports/contentitem.ftl
    
stanbol/trunk/contenthub/web/src/main/resources/templates/imports/entities.ftl
Removed:
    
stanbol/trunk/contenthub/web/src/main/resources/templates/imports/contentitem.ftl
Modified:
    
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContentItemResource.java
    
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
    
stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/ContentItemResource/index.ftl

Modified: 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContentItemResource.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContentItemResource.java?rev=1460665&r1=1460664&r2=1460665&view=diff
==============================================================================
--- 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContentItemResource.java
 (original)
+++ 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/ContentItemResource.java
 Mon Mar 25 14:00:37 2013
@@ -28,8 +28,10 @@ import static org.apache.stanbol.enhance
 import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.DC_RELATION;
 import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.DC_TYPE;
 import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_CONFIDENCE;
+import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_END;
 import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_ENTITY_LABEL;
 import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_ENTITY_REFERENCE;
+import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_START;
 import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.GEO_LAT;
 import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.GEO_LONG;
 import static 
org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_ENTITYANNOTATION;
@@ -37,8 +39,12 @@ import static org.apache.stanbol.enhance
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -70,24 +76,33 @@ import org.apache.clerezza.rdf.core.Reso
 import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.TcManager;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
 import org.apache.clerezza.rdf.core.sparql.ParseException;
 import org.apache.clerezza.rdf.ontologies.RDF;
+import org.apache.commons.lang.StringUtils;
 import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
 import org.apache.stanbol.commons.viewable.Viewable;
 import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
 import org.apache.stanbol.enhancer.servicesapi.Blob;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementException;
+import org.apache.stanbol.enhancer.servicesapi.NoSuchPartException;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
 import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
+import org.apache.stanbol.enhancer.servicesapi.helper.ExecutionMetadataHelper;
+import org.apache.stanbol.enhancer.servicesapi.helper.execution.ChainExecution;
+import org.apache.stanbol.enhancer.servicesapi.helper.execution.Execution;
+import org.apache.stanbol.enhancer.servicesapi.rdf.ExecutionMetadata;
 import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ContentItemResource extends BaseStanbolResource {
 
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     // TODO make this configurable trough a property
     public static final UriRef SUMMARY = new 
UriRef("http://www.w3.org/2000/01/rdf-schema#comment";);
 
@@ -109,32 +124,41 @@ public class ContentItemResource extends
 
     protected URI metadataHref;
 
-    protected final TcManager tcManager;
-
     protected final Serializer serializer;
 
     protected String serializationFormat = SupportedFormat.RDF_XML;
+    /**
+     * Used to format dates on the UI
+     */
+    protected DateFormat format = new SimpleDateFormat("HH-mm-ss.SSS");
 
     /**
      * Map holding the extraction mapped by {@link Properties#DC_TYPE} and the
      * {@link Properties#ENHANCER_SELECTED_TEXT}. This map is initialised by 
{@link #initOccurrences()}.
      */
-    protected Map<UriRef,Map<String,EntityExtractionSummary>> 
extractionsByTypeMap = new 
HashMap<UriRef,Map<String,EntityExtractionSummary>>();
+    protected Map<UriRef,Map<EntityExtractionSummary,EntityExtractionSummary>> 
extractionsByTypeMap = new 
HashMap<UriRef,Map<EntityExtractionSummary,EntityExtractionSummary>>();
+
+    private MGraph executionMetadata;
+
+    private ChainExecution chainExecution;
+
+    private 
ArrayList<org.apache.stanbol.enhancer.servicesapi.helper.execution.Execution> 
engineExecutions;
+
+    private EnhancementException enhancementException;
 
     public ContentItemResource(String localId,
                                ContentItem ci,
                                UriInfo uriInfo,
                                String storePath,
-                               TcManager tcManager,
                                Serializer serializer,
-                               ServletContext servletContext) throws 
IOException {
+                               ServletContext servletContext,
+                               EnhancementException enhancementException) 
throws IOException {
         this.contentItem = ci;
         this.localId = localId;
         this.uriInfo = uriInfo;
-        this.tcManager = tcManager;
         this.serializer = serializer;
         this.servletContext = servletContext;
-
+        this.enhancementException = enhancementException;
         if (localId != null) {
             URI rawURI = 
uriInfo.getBaseUriBuilder().path(storePath).path("raw").path(localId).build();
             Entry<UriRef,Blob> plainTextContentPart = 
ContentItemHelper.getBlob(contentItem,
@@ -154,13 +178,43 @@ public class ContentItemResource extends
         defaultThumbnails.put(DBPEDIA_PLACE, getStaticRootUrl() + 
"/home/images/compass_48.png");
         defaultThumbnails.put(SKOS_CONCEPT, getStaticRootUrl() + 
"/home/images/black_gear_48.png");
         defaultThumbnails.put(null, getStaticRootUrl() + 
"/home/images/unknown_48.png");
-        initOccurrences();
+        long start = System.currentTimeMillis();
+        if (enhancementException == null) {
+            initOccurrences();
+        }
+        // init ExecutionMetadata
+        try {
+            executionMetadata = ci.getPart(ExecutionMetadata.CHAIN_EXECUTION, 
MGraph.class);
+        } catch (NoSuchPartException e) {
+            executionMetadata = null;
+        }
+        if (executionMetadata != null) {
+            NonLiteral ce = 
ExecutionMetadataHelper.getChainExecution(executionMetadata, ci.getUri());
+            if (ce != null) {
+                chainExecution = new ChainExecution(executionMetadata, ce);
+                engineExecutions = new ArrayList<Execution>();
+                for (NonLiteral ex : 
ExecutionMetadataHelper.getExecutions(executionMetadata, ce)) {
+                    engineExecutions.add(new Execution(chainExecution, 
executionMetadata, ex));
+                }
+                Collections.sort(engineExecutions);
+            } else {
+                chainExecution = null;
+                engineExecutions = null;
+            }
+        }
+        log.info(" ... {}ms fro parsing Enhancement Reuslts", 
System.currentTimeMillis() - start);
     }
 
     public String getRdfMetadata(String mediatype) throws 
UnsupportedEncodingException {
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        serializer.serialize(out, contentItem.getMetadata(), mediatype);
-        return out.toString("utf-8");
+        if (enhancementException == null) {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            serializer.serialize(out, contentItem.getMetadata(), mediatype);
+            return out.toString("utf-8");
+        } else {// in case of an exception print the stacktrace
+            StringWriter writer = new StringWriter();
+            enhancementException.printStackTrace(new PrintWriter(writer));
+            return writer.toString();
+        }
     }
 
     public String getRdfMetadata() throws UnsupportedEncodingException {
@@ -195,7 +249,7 @@ public class ContentItemResource extends
      * Checks if there are Occurrences
      */
     public boolean hasOccurrences() {
-        for (Map<String,EntityExtractionSummary> occ : 
extractionsByTypeMap.values()) {
+        for (Map<EntityExtractionSummary,EntityExtractionSummary> occ : 
extractionsByTypeMap.values()) {
             if (!occ.isEmpty()) {
                 return true;
             }
@@ -216,8 +270,20 @@ public class ContentItemResource extends
         return types;
     }
 
+    public String extractLabel(UriRef uri) {
+        String fullUri = uri.getUnicodeString();
+        int index = Math.max(fullUri.lastIndexOf('#'), 
fullUri.lastIndexOf('/'));
+        index = Math.max(index, fullUri.lastIndexOf(':'));
+        // do not convert if the parsed uri does not contain a local name
+        if (index > 0 && index + 1 < fullUri.length()) {
+            return StringUtils.capitalize(fullUri.substring(index + 
1).replaceAll("[\\-_]", " "));
+        } else {
+            return uri.getUnicodeString();
+        }
+    }
+
     public Collection<EntityExtractionSummary> getOccurrences(UriRef type) {
-        Map<String,EntityExtractionSummary> typeMap = 
extractionsByTypeMap.get(type);
+        Map<EntityExtractionSummary,EntityExtractionSummary> typeMap = 
extractionsByTypeMap.get(type);
         Collection<EntityExtractionSummary> typeOccurrences;
         if (typeMap != null) {
             typeOccurrences = typeMap.values();
@@ -285,31 +351,34 @@ public class ContentItemResource extends
         Iterator<Triple> textAnnotations = graph.filter(null, RDF.type, 
ENHANCER_TEXTANNOTATION);
         while (textAnnotations.hasNext()) {
             NonLiteral textAnnotation = textAnnotations.next().getSubject();
-            if (graph.filter(textAnnotation, DC_RELATION, null).hasNext()) {
-                // this is not the most specific occurrence of this name: skip
-                continue;
-            }
+            // if (graph.filter(textAnnotation, DC_RELATION, null).hasNext()) {
+            // // this is not the most specific occurrence of this name: skip
+            // continue;
+            // }
             String text = getString(graph, textAnnotation, 
Properties.ENHANCER_SELECTED_TEXT);
             if (text == null) {
                 // ignore text annotations without text
                 continue;
             }
+            Integer start = EnhancementEngineHelper.get(graph, textAnnotation, 
ENHANCER_START, Integer.class,
+                lf);
+            Integer end = EnhancementEngineHelper.get(graph, textAnnotation, 
ENHANCER_END, Integer.class, lf);
+            Double confidence = EnhancementEngineHelper.get(graph, 
textAnnotation, ENHANCER_CONFIDENCE,
+                Double.class, lf);
             Iterator<UriRef> types = getReferences(graph, textAnnotation, 
DC_TYPE);
             if (!types.hasNext()) { // create an iterator over null in case no 
types are present
                 types = Collections.singleton((UriRef) null).iterator();
             }
             while (types.hasNext()) {
                 UriRef type = types.next();
-                Map<String,EntityExtractionSummary> occurrenceMap = 
extractionsByTypeMap.get(type);
+                Map<EntityExtractionSummary,EntityExtractionSummary> 
occurrenceMap = extractionsByTypeMap
+                        .get(type);
                 if (occurrenceMap == null) {
-                    occurrenceMap = new 
TreeMap<String,EntityExtractionSummary>(String.CASE_INSENSITIVE_ORDER);
+                    occurrenceMap = new 
TreeMap<EntityExtractionSummary,EntityExtractionSummary>();
                     extractionsByTypeMap.put(type, occurrenceMap);
                 }
-                EntityExtractionSummary entity = occurrenceMap.get(text);
-                if (entity == null) {
-                    entity = new EntityExtractionSummary(text, type, 
defaultThumbnails);
-                    occurrenceMap.put(text, entity);
-                }
+                EntityExtractionSummary entity = new 
EntityExtractionSummary(text, type, start, end,
+                        confidence, defaultThumbnails);
                 Collection<NonLiteral> suggestions = 
suggestionMap.get(textAnnotation);
                 if (suggestions != null) {
                     for (NonLiteral entityAnnotation : suggestions) {
@@ -319,7 +388,167 @@ public class ContentItemResource extends
                             graph);
                     }
                 }
+                EntityExtractionSummary existingSummary = 
occurrenceMap.get(entity);
+                if (existingSummary == null) {// new extraction summary
+                    occurrenceMap.put(entity, entity);
+                } else {
+                    // extraction summary with this text and suggestions 
already
+                    // present ... only add a mention to the existing
+                    existingSummary.addMention(new Mention(text, start, end, 
confidence));
+                }
+            }
+        }
+    }
+
+    /**
+     * Mentions of {@link EntityExtractionSummary EntityExtractionSummaries}.
+     * 
+     * @author Rupert Westenthaler
+     * 
+     */
+    public static class Mention implements Comparable<Mention> {
+        private String name;
+        private Integer start;
+        private Integer end;
+        private Double conf;
+
+        Mention(String name, Integer start, Integer end, Double confidence) {
+            if (name == null) {
+                throw new IllegalStateException("The name for a Mention MUST 
NOT be NULL!");
+            }
+            this.name = name;
+            this.start = start;
+            this.end = end;
+            this.conf = confidence;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public Integer getStart() {
+            return start;
+        }
+
+        public Integer getEnd() {
+            return end;
+        }
+
+        public Double getConfidence() {
+            return conf;
+        }
+
+        public boolean hasOccurrence() {
+            return start != null && end != null;
+        }
+
+        public boolean hasConfidence() {
+            return conf != null;
+        }
+
+        @Override
+        public int hashCode() {
+            return name.hashCode() + (start != null ? start.hashCode() : 0)
+                   + (end != null ? end.hashCode() : 0);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof Mention) {
+                Mention o = (Mention) obj;
+                if (o.name.equals(name)) {
+                    if ((o.start != null && o.start.equals(start)) || (o.start 
== null && start == null)) {
+                        if (o.end != null && o.end.equals(end)) {
+                            return true;
+                        } else {
+                            return o.end == null && end == null;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public int compareTo(Mention o) {
+            int c = String.CASE_INSENSITIVE_ORDER.compare(o.name, this.name);
+            if (c == 0) {
+                if (start != null && o.start != null) {
+                    c = start.compareTo(o.start);
+                } else if (o.start != null) {
+                    c = 1;
+                } else if (start != null) {
+                    c = -1;
+                }
+                if (c == 0) {
+                    if (o.end != null && end != null) {
+                        c = end.compareTo(o.end);
+                    } else if (o.end != null) {
+                        c = -1;
+                    } else if (end != null) {
+                        c = 1;
+                    }
+                }
             }
+            return c;
+        }
+    }
+
+    public ChainExecution getChainExecution() {
+        return chainExecution;
+    }
+
+    public Collection<Execution> getEngineExecutions() {
+        return engineExecutions;
+    }
+
+    public String getExecutionOffsetText(Execution ex) {
+        if (ex.getChain() == null || ex.getChain().getStarted() == null || 
ex.getStarted() == null) {
+            return null;
+        } else {
+            return String.format("%6dms", ex.getStarted().getTime() - 
ex.getChain().getStarted().getTime());
+        }
+    }
+
+    public String getExecutionDurationText(Execution ex) {
+        if (ex.getDuration() == null) {
+            return "[duration not available]";
+        } else if (ex.getDuration() < 1025) {
+            return ex.getDuration() + "ms";
+        } else {
+            return String.format("%.2fsec", (ex.getDuration().floatValue() / 
1000));
+        }
+    }
+
+    public String getExecutionStartTime(Execution ex) {
+        if (ex.getStarted() != null) {
+            return format.format(ex.getStarted());
+        } else {
+            return "unknown";
+        }
+    }
+
+    public String getExecutionCompletionTime(Execution ex) {
+        if (ex.getCompleted() != null) {
+            return format.format(ex.getCompleted());
+        } else {
+            return "unknown";
+        }
+    }
+
+    public String getExecutionStatusText(Execution ex) {
+        if (ExecutionMetadata.STATUS_COMPLETED.equals(ex.getStatus())) {
+            return "completed";
+        } else if (ExecutionMetadata.STATUS_FAILED.equals(ex.getStatus())) {
+            return "failed";
+        } else if 
(ExecutionMetadata.STATUS_IN_PROGRESS.equals(ex.getStatus())) {
+            return "in-progress";
+        } else if (ExecutionMetadata.STATUS_SCHEDULED.equals(ex.getStatus())) {
+            return "scheduled";
+        } else if (ExecutionMetadata.STATUS_SKIPPED.equals(ex.getStatus())) {
+            return "skipped";
+        } else {
+            return "unknown";
         }
     }
 
@@ -330,27 +559,50 @@ public class ContentItemResource extends
         protected final UriRef type;
 
         protected List<EntitySuggestion> suggestions = new 
ArrayList<EntitySuggestion>();
+        protected Set<UriRef> suggestionSet = new HashSet<UriRef>();
 
-        protected List<String> mentions = new ArrayList<String>();
+        protected List<Mention> mentions = new ArrayList<Mention>();
 
         public final Map<UriRef,String> defaultThumbnails;
 
-        public EntityExtractionSummary(String name, UriRef type, 
Map<UriRef,String> defaultThumbnails) {
+        private Integer start;
+
+        private Integer end;
+
+        private Double confidence;
+
+        public EntityExtractionSummary(String name,
+                                       UriRef type,
+                                       Integer start,
+                                       Integer end,
+                                       Double confidence,
+                                       Map<UriRef,String> defaultThumbnails) {
             this.name = name;
             this.type = type;
-            mentions.add(name);
+            mentions.add(new Mention(name, start, end, confidence));
             this.defaultThumbnails = defaultThumbnails;
+            this.start = start;
+            this.end = end;
+            this.confidence = confidence;
         }
 
         public void addSuggestion(UriRef uri, String label, Double confidence, 
TripleCollection properties) {
             EntitySuggestion suggestion = new EntitySuggestion(uri, type, 
label, confidence, properties,
                     defaultThumbnails);
+            suggestionSet.add(uri);
             if (!suggestions.contains(suggestion)) {
                 suggestions.add(suggestion);
                 Collections.sort(suggestions);
             }
         }
 
+        public void addMention(Mention mention) {
+            if (!mentions.contains(mention)) {
+                mentions.add(mention);
+                Collections.sort(mentions);
+            }
+        }
+
         public String getName() {
             EntitySuggestion bestGuess = getBestGuess();
             if (bestGuess != null) {
@@ -359,6 +611,10 @@ public class ContentItemResource extends
             return name;
         }
 
+        public String getSelected() {
+            return name;
+        }
+
         public String getUri() {
             EntitySuggestion bestGuess = getBestGuess();
             if (bestGuess != null) {
@@ -367,6 +623,14 @@ public class ContentItemResource extends
             return null;
         }
 
+        public Double getConfidence() {
+            EntitySuggestion bestGuess = getBestGuess();
+            if (bestGuess != null) {
+                return bestGuess.getConfidence();
+            }
+            return confidence;
+        }
+
         public String getSummary() {
             if (suggestions.isEmpty()) {
                 return "";
@@ -374,6 +638,18 @@ public class ContentItemResource extends
             return suggestions.get(0).getSummary();
         }
 
+        public Integer getStart() {
+            return start;
+        }
+
+        public Integer getEnd() {
+            return end;
+        }
+
+        public boolean hasOccurrence() {
+            return start != null && end != null;
+        }
+
         public String getThumbnailSrc() {
             if (suggestions.isEmpty()) {
                 return getMissingThumbnailSrc();
@@ -400,13 +676,36 @@ public class ContentItemResource extends
             return suggestions;
         }
 
-        public List<String> getMentions() {
+        public List<Mention> getMentions() {
             return mentions;
         }
 
         @Override
         public int compareTo(EntityExtractionSummary o) {
-            return getName().compareTo(o.getName());
+            int c = String.CASE_INSENSITIVE_ORDER.compare(getName(), 
o.getName());
+            if (c == 0) {
+                if (suggestionSet.equals(o.suggestionSet)) {
+                    return 0; // assume as equals if name and suggestionSet is 
the same
+                } else { // sort by mention
+                    if (start != null && o.start != null) {
+                        c = start.compareTo(o.start);
+                    } else if (o.start != null) {
+                        c = 1;
+                    } else if (start != null) {
+                        c = -1;
+                    }
+                    if (c == 0) {
+                        if (o.end != null && end != null) {
+                            c = end.compareTo(o.end);
+                        } else if (o.end != null) {
+                            c = -1;
+                        } else if (end != null) {
+                            c = 1;
+                        }
+                    }
+                }
+            }
+            return c;
         }
 
         @Override
@@ -417,10 +716,14 @@ public class ContentItemResource extends
             if (o == null || getClass() != o.getClass()) {
                 return false;
             }
-
             EntityExtractionSummary that = (EntityExtractionSummary) o;
-
-            return !(name != null ? !name.equals(that.name) : that.name != 
null);
+            // if name and suggestions are the same ... consider as equals
+            if (getName().equalsIgnoreCase(getName())) {
+                return suggestionSet.equals(that.suggestionSet);
+            } else {
+                return false;
+            }
+            // return !(name != null ? !name.equals(that.name) : that.name != 
null);
         }
 
         @Override
@@ -582,4 +885,5 @@ public class ContentItemResource extends
         addCORSOrigin(servletContext, rb, headers);
         return rb.build();
     }
+
 }

Modified: 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java?rev=1460665&r1=1460664&r2=1460665&view=diff
==============================================================================
--- 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
 (original)
+++ 
stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
 Mon Mar 25 14:00:37 2013
@@ -72,7 +72,6 @@ import javax.ws.rs.core.Response.Respons
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.UriInfo;
 
-import org.apache.clerezza.rdf.core.access.TcManager;
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
 import org.apache.clerezza.rdf.core.sparql.ParseException;
@@ -116,8 +115,6 @@ public class StoreResource extends BaseS
 
     private static final Logger log = 
LoggerFactory.getLogger(StoreResource.class);
 
-    private TcManager tcManager;
-
     private SolrStore solrStore;
 
     private SolrSearch solrSearch;
@@ -150,7 +147,6 @@ public class StoreResource extends BaseS
         this.indexName = indexName;
         this.solrStore = ContextHelper.getServiceFromContext(SolrStore.class, 
context);
         this.solrSearch = 
ContextHelper.getServiceFromContext(SolrSearch.class, context);
-        this.tcManager = ContextHelper.getServiceFromContext(TcManager.class, 
context);
         this.serializer = 
ContextHelper.getServiceFromContext(Serializer.class, context);
         this.uriInfo = uriInfo;
 
@@ -166,10 +162,6 @@ public class StoreResource extends BaseS
             log.error("Missing SolrSearch service");
             throw new IllegalStateException("Missing SolrSearch service");
         }
-        if (this.tcManager == null) {
-            log.error("Missing TcManager service");
-            throw new IllegalStateException("Missing TcManager service");
-        }
     }
 
     @OPTIONS
@@ -718,7 +710,7 @@ public class StoreResource extends BaseS
             throw new WebApplicationException(404);
         }
         return new ContentItemResource(uri, ci, uriInfo, "/contenthub/" + 
indexName + "/store/download",
-                tcManager, serializer, servletContext);
+                serializer, servletContext, null);
     }
 
     // Helper methods for HTML view

Modified: 
stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/ContentItemResource/index.ftl
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/ContentItemResource/index.ftl?rev=1460665&r1=1460664&r2=1460665&view=diff
==============================================================================
--- 
stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/ContentItemResource/index.ftl
 (original)
+++ 
stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/ContentItemResource/index.ftl
 Mon Mar 25 14:00:37 2013
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 <#import "/imports/common.ftl" as common>
-<#import "/imports/contentitem.ftl" as contentitem>
+<#import "/imports/contenthubcontentitem.ftl" as contentitem>
 <#escape x as x?html>
 <@common.page title="Content Item: ${it.localId} (${it.contentItem.mimeType})" 
hasrestapi=false> 
 

Added: 
stanbol/trunk/contenthub/web/src/main/resources/templates/imports/entities.ftl
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/resources/templates/imports/entities.ftl?rev=1460665&view=auto
==============================================================================
--- 
stanbol/trunk/contenthub/web/src/main/resources/templates/imports/entities.ftl 
(added)
+++ 
stanbol/trunk/contenthub/web/src/main/resources/templates/imports/entities.ftl 
Mon Mar 25 14:00:37 2013
@@ -0,0 +1,79 @@
+<#--
+  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.
+-->
+<#macro listing entities>
+<#list entities as entity>
+<p>
+<table class="collapsed">
+<thead>
+<tr>
+  <th class="thumb">
+    <img src="${entity.thumbnailSrc}"
+      onerror="$(this).attr('src', '${entity.missingThumbnailSrc}');"
+      alt="${entity.name}" />
+  </th>
+  <th class="name">
+    <#if entity.uri?exists>
+    <a href="${entity.uri}" title="${entity.summary}">${entity.name}</a>
+    <#else>
+    ${entity.name}
+    </#if>
+    <br><span class="metadata">
+    <#if entity.name != entity.selected>for:'${entity.selected}',</#if>
+    <#if entity.mentions?size &gt; 1>${entity.mentions?size} mentions
+    <#else>
+      <#if 
entity.hasOccurrence()>pos:[${entity.start},${entity.end}]</#if></#if>
+      ,conf:<#if 
entity.confidence??>${entity.confidence?string("0.##")}<#else>unknown</#if>
+    </span>
+  </th>
+</tr>
+</thead>
+<tbody>
+<#if entity.suggestions?size != 0>
+<tr class="subheader">
+  <td colspan="2">Referenced entities</td>
+</tr>
+</#if>
+<#list entity.suggestions as suggestion>
+<tr>
+  <td class="thumb"><img src="${suggestion.thumbnailSrc}"
+    onerror="$(this).attr('src', '${suggestion.missingThumbnailSrc}');" 
alt="${suggestion.label}" /></td>
+  <td><a href="${suggestion.uri}" title="${suggestion.summary}" 
class="external">
+       ${suggestion.label}</a><br>
+       <span 
class="metadata">conf:${suggestion.confidence?string("0.##")}</span></td>
+</tr>
+</#list>
+<#if entity.mentions?size != 0>
+<tr class="subheader">
+  <td colspan="2">Mentions</td>
+</tr>
+</#if>
+<#list entity.mentions as mention>
+<tr>
+  <td></td>
+  <td>${mention.name}<br><span class="metadata">
+  <#if mention.hasOccurrence()>
+    pos:[${mention.start},${mention.end}]
+   </#if>
+   <#if mention.hasConfidence()>
+    , conf: ${mention.confidence}</#if></span></td>
+</tr>
+</#list>
+</tbody>
+</table>
+</p>
+</#list>
+</#macro>
\ No newline at end of file


Reply via email to