Author: ogrisel
Date: Thu May 12 15:06:05 2011
New Revision: 1102336

URL: http://svn.apache.org/viewvc?rev=1102336&view=rev
Log:
cleanup imports + format

Modified:
    
incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java
    
incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/ReferencedSiteEntityTaggingEnhancementEngine.java

Modified: 
incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java?rev=1102336&r1=1102335&r2=1102336&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java
 (original)
+++ 
incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java
 Thu May 12 15:06:05 2011
@@ -16,6 +16,14 @@
  */
 package org.apache.stanbol.enhancer.engines.entitytagging.impl;
 
+import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.DC_RELATION;
+import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_CONFIDENCE;
+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_ENTITY_TYPE;
+import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDFS_LABEL;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDF_TYPE;
+
 import java.util.Collection;
 import java.util.Iterator;
 
@@ -34,88 +42,92 @@ import org.apache.stanbol.entityhub.serv
 import org.apache.stanbol.entityhub.servicesapi.model.Text;
 import org.apache.stanbol.entityhub.servicesapi.model.rdf.RdfResourceEnum;
 
-
-import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.*;
-
 /**
- * Utility taken form the engine.autotagging bundle and adapted from
- * using TagInfo to {@link Sign}.
- *
+ * Utility taken form the engine.autotagging bundle and adapted from using 
TagInfo to {@link Sign}.
+ * 
  * @author Rupert Westenthaler
  * @author ogrisel (original utility)
  */
 public class EnhancementRDFUtils {
 
     /**
-     * @param literalFactory the LiteralFactory to use
-     * @param graph the MGraph to use
-     * @param contentItemId the contentItemId the enhancement is extracted from
-     * @param relatedEnhancements enhancements this textAnnotation is related 
to
-     * @param entity the related entity
+     * @param literalFactory
+     *            the LiteralFactory to use
+     * @param graph
+     *            the MGraph to use
+     * @param contentItemId
+     *            the contentItemId the enhancement is extracted from
+     * @param relatedEnhancements
+     *            enhancements this textAnnotation is related to
+     * @param entity
+     *            the related entity
      */
-    public static UriRef writeEntityAnnotation(EnhancementEngine engine, 
LiteralFactory literalFactory,
-            MGraph graph, UriRef contentItemId, Collection<NonLiteral> 
relatedEnhancements, Sign entity) {
-        //1. check if the returned Entity does has a label -> if not return 
null
-        //add labels (set only a single label. Use "en" if available!
+    public static UriRef writeEntityAnnotation(EnhancementEngine engine,
+                                               LiteralFactory literalFactory,
+                                               MGraph graph,
+                                               UriRef contentItemId,
+                                               Collection<NonLiteral> 
relatedEnhancements,
+                                               Sign entity) {
+        // 1. check if the returned Entity does has a label -> if not return 
null
+        // add labels (set only a single label. Use "en" if available!
         Text label = null;
         Iterator<Text> labels = 
entity.getRepresentation().getText(RDFS_LABEL.getUnicodeString());
         while (labels.hasNext()) {
-            Text actLabel  = labels.next();
-            if(label == null){
+            Text actLabel = labels.next();
+            if (label == null) {
                 label = actLabel;
             } else {
-                if("en".equals(actLabel.getLanguage())){
+                if ("en".equals(actLabel.getLanguage())) {
                     label = actLabel;
                 }
             }
         }
-        if (label == null){
+        if (label == null) {
             return null;
         }
         Literal literal;
-        if (label.getLanguage() == null){
+        if (label.getLanguage() == null) {
             literal = new PlainLiteralImpl(label.getText());
         } else {
             literal = new PlainLiteralImpl(label.getText(), new 
Language(label.getLanguage()));
         }
-        //Now create the entityAnnotation
-        UriRef entityAnnotation = 
EnhancementEngineHelper.createEntityEnhancement(
-                graph, engine, contentItemId);
+        // Now create the entityAnnotation
+        UriRef entityAnnotation = 
EnhancementEngineHelper.createEntityEnhancement(graph, engine,
+            contentItemId);
         // first relate this entity annotation to the text annotation(s)
-        for (NonLiteral enhancement: relatedEnhancements){
+        for (NonLiteral enhancement : relatedEnhancements) {
             graph.add(new TripleImpl(entityAnnotation, DC_RELATION, 
enhancement));
         }
         UriRef entityUri = new UriRef(entity.getId());
         // add the link to the referred entity
         graph.add(new TripleImpl(entityAnnotation, ENHANCER_ENTITY_REFERENCE, 
entityUri));
-        //add the label parsed above
+        // add the label parsed above
         graph.add(new TripleImpl(entityAnnotation, ENHANCER_ENTITY_LABEL, 
literal));
-        //TODO: add real confidence values!
+        // TODO: add real confidence values!
         // -> in case of SolrYards this will be a Lucene score and not within 
the range [0..1]
         // -> in case of SPARQL there will be no score information at all.
         Object score = 
entity.getRepresentation().getFirst(RdfResourceEnum.resultScore.getUri());
-        Double scoreValue = new Double(-1); //use -1 if no score is available!
-        if (score != null){
+        Double scoreValue = new Double(-1); // use -1 if no score is available!
+        if (score != null) {
             try {
                 scoreValue = Double.valueOf(score.toString());
             } catch (NumberFormatException e) {
-                //ignore
+                // ignore
             }
         }
-        graph.add(new TripleImpl(entityAnnotation,
-                ENHANCER_CONFIDENCE,
-                literalFactory.createTypedLiteral(scoreValue)));
+        graph.add(new TripleImpl(entityAnnotation, ENHANCER_CONFIDENCE, 
literalFactory
+                .createTypedLiteral(scoreValue)));
 
         Iterator<Reference> types = 
entity.getRepresentation().getReferences(RDF_TYPE.getUnicodeString());
         while (types.hasNext()) {
-            graph.add(new TripleImpl(entityAnnotation,
-                    ENHANCER_ENTITY_TYPE, new 
UriRef(types.next().getReference())));
+            graph.add(new TripleImpl(entityAnnotation, ENHANCER_ENTITY_TYPE, 
new UriRef(types.next()
+                    .getReference())));
         }
-        //TODO: for now add the information about this entity to the graph
+        // TODO: for now add the information about this entity to the graph
         // -> this might be replaced by some additional engine at the end
-//        RdfValueFactory rdfValueFactory = RdfValueFactory.getInstance();
-//        RdfRepresentation representation = 
rdfValueFactory.toRdfRepresentation(entity.getRepresentation());
-//        graph.addAll(representation.getRdfGraph());
+        // RdfValueFactory rdfValueFactory = RdfValueFactory.getInstance();
+        // RdfRepresentation representation = 
rdfValueFactory.toRdfRepresentation(entity.getRepresentation());
+        // graph.addAll(representation.getRdfGraph());
         return entityAnnotation;
     }
 

Modified: 
incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/ReferencedSiteEntityTaggingEnhancementEngine.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/ReferencedSiteEntityTaggingEnhancementEngine.java?rev=1102336&r1=1102335&r2=1102336&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/ReferencedSiteEntityTaggingEnhancementEngine.java
 (original)
+++ 
incubator/stanbol/trunk/enhancer/engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/ReferencedSiteEntityTaggingEnhancementEngine.java
 Thu May 12 15:06:05 2011
@@ -16,6 +16,11 @@
  */
 package org.apache.stanbol.enhancer.engines.entitytagging.impl;
 
+import static 
org.apache.stanbol.enhancer.servicesapi.rdf.OntologicalClasses.DBPEDIA_ORGANISATION;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.DC_TYPE;
+import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_SELECTED_TEXT;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDF_TYPE;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Dictionary;
@@ -40,7 +45,6 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ReferenceStrategy;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.stanbol.commons.stanboltools.offline.OfflineMode;
-import org.apache.stanbol.commons.stanboltools.offline.OnlineMode;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.EngineException;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
@@ -56,8 +60,6 @@ import org.apache.stanbol.entityhub.serv
 import org.apache.stanbol.entityhub.servicesapi.query.QueryResultList;
 import org.apache.stanbol.entityhub.servicesapi.query.ReferenceConstraint;
 import org.apache.stanbol.entityhub.servicesapi.query.TextConstraint;
-import org.apache.stanbol.entityhub.servicesapi.site.EntityDereferencer;
-import org.apache.stanbol.entityhub.servicesapi.site.EntitySearcher;
 import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSite;
 import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteException;
 import org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteManager;
@@ -66,58 +68,53 @@ import org.osgi.service.component.Compon
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
-import static 
org.apache.stanbol.enhancer.servicesapi.rdf.OntologicalClasses.DBPEDIA_ORGANISATION;
-import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.DC_TYPE;
-import static 
org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_SELECTED_TEXT;
-import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDF_TYPE;
-
 /**
- * Engine that uses a {@link ReferencedSite} to search for entities for
- * existing TextAnnotations of an Content Item.
- *
+ * Engine that uses a {@link ReferencedSite} to search for entities for 
existing TextAnnotations of an Content
+ * Item.
+ * 
  * @author ogrisel, rwesten
  */
-@Component(configurationFactory = true,
-        policy = ConfigurationPolicy.REQUIRE, //the baseUri is required!
-        specVersion = "1.1",
-        metatype = true,
-        immediate = true)
+@Component(configurationFactory = true, policy = ConfigurationPolicy.REQUIRE, 
// the baseUri is required!
+specVersion = "1.1", metatype = true, immediate = true)
 @Service
-public class ReferencedSiteEntityTaggingEnhancementEngine implements 
EnhancementEngine,
-        ServiceProperties {
+public class ReferencedSiteEntityTaggingEnhancementEngine implements 
EnhancementEngine, ServiceProperties {
 
     private final Logger log = LoggerFactory.getLogger(getClass());
-    
-    @Property(value="dbpedia")
+
+    @Property(value = "dbpedia")
     public static final String REFERENCED_SITE_ID = 
"org.apache.stanbol.enhancer.engines.entitytagging.referencedSiteId";
-    @Property(boolValue=true)
+
+    @Property(boolValue = true)
     public static final String PERSON_STATE = 
"org.apache.stanbol.enhancer.engines.entitytagging.personState";
-    @Property(value="dbp-ont:Person")
+
+    @Property(value = "dbp-ont:Person")
     public static final String PERSON_TYPE = 
"org.apache.stanbol.enhancer.engines.entitytagging.personType";
-    @Property(boolValue=true)
+
+    @Property(boolValue = true)
     public static final String ORG_STATE = 
"org.apache.stanbol.enhancer.engines.entitytagging.organisationState";
-    @Property(value="dbp-ont:Organisation")
+
+    @Property(value = "dbp-ont:Organisation")
     public static final String ORG_TYPE = 
"org.apache.stanbol.enhancer.engines.entitytagging.organisationType";
-    @Property(boolValue=true)
+
+    @Property(boolValue = true)
     public static final String PLACE_STATE = 
"org.apache.stanbol.enhancer.engines.entitytagging.placeState";
-    @Property(value="dbp-ont:Place")
+
+    @Property(value = "dbp-ont:Place")
     public static final String PLACE_TYPE = 
"org.apache.stanbol.enhancer.engines.entitytagging.placeType";
-    @Property(value="rdfs:label")
+
+    @Property(value = "rdfs:label")
     public static final String NAME_FIELD = 
"org.apache.stanbol.enhancer.engines.entitytagging.nameField";
 
     /**
-     * Service of the RICK that manages all the active referenced Site.
-     * This Service is used to lookup the configured Referenced Site when we
-     * need to enhance a content item.
+     * Service of the RICK that manages all the active referenced Site. This 
Service is used to lookup the
+     * configured Referenced Site when we need to enhance a content item.
      */
     @Reference
     protected ReferencedSiteManager siteManager;
     /**
-     * This is the configured name of the referenced Site used to find 
entities.
-     * The {@link ReferencedSiteManager} service of the RICK is used to
-     * get the actual {@link ReferencedSite} instance for each request to this
-     * Engine.
+     * This is the configured name of the referenced Site used to find 
entities. The
+     * {@link ReferencedSiteManager} service of the RICK is used to get the 
actual {@link ReferencedSite}
+     * instance for each request to this Engine.
      */
     protected String referencedSiteID;
     /**
@@ -126,37 +123,35 @@ public class ReferencedSiteEntityTagging
      */
     public static final Integer defaultOrder = ORDERING_EXTRACTION_ENHANCEMENT;
     /**
-     * State if text annotations of type {@link 
OntologicalClasses#DBPEDIA_PERSON}
-     * are enhanced by this engine
+     * State if text annotations of type {@link 
OntologicalClasses#DBPEDIA_PERSON} are enhanced by this engine
      */
     protected boolean personState;
 
     /**
-     * State if text annotations of type {@link 
OntologicalClasses#DBPEDIA_ORGANISATION}
-     * are enhanced by this engine
+     * State if text annotations of type {@link 
OntologicalClasses#DBPEDIA_ORGANISATION} are enhanced by this
+     * engine
      */
     protected boolean orgState;
 
     /**
-     * State if text annotations of type {@link 
OntologicalClasses#DBPEDIA_PLACE}
-     * are enhanced by this engine
+     * State if text annotations of type {@link 
OntologicalClasses#DBPEDIA_PLACE} are enhanced by this engine
      */
     protected boolean placeState;
     /**
-     * The rdf:type constraint used to search for persons or <code>null</code>
-     * if no type constraint should be used
+     * The rdf:type constraint used to search for persons or <code>null</code> 
if no type constraint should be
+     * used
      */
     protected String personType;
 
     /**
-     * The rdf:type constraint used to search for organisations or 
<code>null</code>
-     * if no type constraint should be used
+     * The rdf:type constraint used to search for organisations or 
<code>null</code> if no type constraint
+     * should be used
      */
     protected String orgType;
 
     /**
-     * The rdf:type constraint used to search for places or <code>null</code>
-     * if no type constraint should be used
+     * The rdf:type constraint used to search for places or <code>null</code> 
if no type constraint should be
+     * used
      */
     protected String placeType;
     /**
@@ -168,47 +163,47 @@ public class ReferencedSiteEntityTagging
      */
     public Integer numSuggestions = 3;
     /**
-     * The {@link OfflineMode} is used by Stanbol to indicate that no external
-     * service should be referenced. For this engine that means it is necessary
-     * to check if the used {@link ReferencedSite} can operate offline or not.
+     * The {@link OfflineMode} is used by Stanbol to indicate that no external 
service should be referenced.
+     * For this engine that means it is necessary to check if the used {@link 
ReferencedSite} can operate
+     * offline or not.
+     * 
      * @see #enableOfflineMode(OfflineMode)
      * @see #disableOfflineMode(OfflineMode)
      */
-    @Reference(
-        cardinality=ReferenceCardinality.OPTIONAL_UNARY,
-        policy=ReferencePolicy.DYNAMIC,
-        bind="enableOfflineMode",
-        unbind="disableOfflineMode",
-        strategy=ReferenceStrategy.EVENT)
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = 
ReferencePolicy.DYNAMIC, bind = "enableOfflineMode", unbind = 
"disableOfflineMode", strategy = ReferenceStrategy.EVENT)
     private OfflineMode offlineMode;
+
     /**
-     * Called by the ConfigurationAdmin to bind the {@link #offlineMode} if the
-     * service becomes available
-     * @param mode 
+     * Called by the ConfigurationAdmin to bind the {@link #offlineMode} if 
the service becomes available
+     * 
+     * @param mode
      */
-    protected final void enableOfflineMode(OfflineMode mode){
+    protected final void enableOfflineMode(OfflineMode mode) {
         this.offlineMode = mode;
     }
+
     /**
-     * Called by the ConfigurationAdmin to unbind the {@link #offlineMode} if 
the
-     * service becomes unavailable
+     * Called by the ConfigurationAdmin to unbind the {@link #offlineMode} if 
the service becomes unavailable
+     * 
      * @param mode
      */
-    protected final void disableOfflineMode(OfflineMode mode){
+    protected final void disableOfflineMode(OfflineMode mode) {
         this.offlineMode = null;
     }
+
     /**
      * Returns <code>true</code> only if Stanbol operates in {@link 
OfflineMode}.
+     * 
      * @return the offline state
      */
-    protected final boolean isOfflineMode(){
+    protected final boolean isOfflineMode() {
         return offlineMode != null;
     }
-    
+
     @SuppressWarnings("unchecked")
     @Activate
     protected void activate(ComponentContext context) throws 
ConfigurationException {
-        Dictionary<String, Object> config = context.getProperties();
+        Dictionary<String,Object> config = context.getProperties();
         Object referencedSiteID = config.get(REFERENCED_SITE_ID);
         if (referencedSiteID == null) {
             throw new ConfigurationException(REFERENCED_SITE_ID,
@@ -216,7 +211,7 @@ public class ReferencedSiteEntityTagging
         }
 
         this.referencedSiteID = referencedSiteID.toString();
-        if (this.referencedSiteID.isEmpty()){
+        if (this.referencedSiteID.isEmpty()) {
             throw new ConfigurationException(REFERENCED_SITE_ID,
                     "The ID of the Referenced Site is a required Parameter and 
MUST NOT be an empty String!");
         }
@@ -227,13 +222,17 @@ public class ReferencedSiteEntityTagging
         state = config.get(PLACE_STATE);
         placeState = state == null ? true : 
Boolean.parseBoolean(state.toString());
         Object type = config.get(PERSON_TYPE);
-        personType = type == null || type.toString().isEmpty() ? null : 
NamespaceEnum.getFullName(type.toString());
+        personType = type == null || type.toString().isEmpty() ? null : 
NamespaceEnum.getFullName(type
+                .toString());
         type = config.get(ORG_TYPE);
-        orgType = type == null || type.toString().isEmpty() ? null : 
NamespaceEnum.getFullName(type.toString());
+        orgType = type == null || type.toString().isEmpty() ? null : 
NamespaceEnum.getFullName(type
+                .toString());
         type = config.get(PLACE_TYPE);
-        placeType = type == null || type.toString().isEmpty() ? null : 
NamespaceEnum.getFullName(type.toString());
+        placeType = type == null || type.toString().isEmpty() ? null : 
NamespaceEnum.getFullName(type
+                .toString());
         Object nameField = config.get(NAME_FIELD);
-        this.nameField = nameField == null || nameField.toString().isEmpty() ? 
NamespaceEnum.rdfs+"label" : NamespaceEnum.getFullName(nameField.toString());
+        this.nameField = nameField == null || nameField.toString().isEmpty() ? 
NamespaceEnum.rdfs + "label"
+                : NamespaceEnum.getFullName(nameField.toString());
     }
 
     @Deactivate
@@ -247,18 +246,19 @@ public class ReferencedSiteEntityTagging
 
     public void computeEnhancements(ContentItem ci) throws EngineException {
         ReferencedSite site = siteManager.getReferencedSite(referencedSiteID);
-        if(site == null){
-            String msg = String.format("Unable to enhance %s because 
Referenced Site %s is currently not active!",
-                    ci.getId(), referencedSiteID);
+        if (site == null) {
+            String msg = String.format(
+                "Unable to enhance %s because Referenced Site %s is currently 
not active!", ci.getId(),
+                referencedSiteID);
             log.warn(msg);
-            //TODO: throwing Exceptions is currently deactivated. We need a 
more clear
-            //policy what do to in such situations
-            //throw new EngineException(msg);
+            // TODO: throwing Exceptions is currently deactivated. We need a 
more clear
+            // policy what do to in such situations
+            // throw new EngineException(msg);
             return;
         }
-        if(isOfflineMode() && !site.supportsLocalMode()){
+        if (isOfflineMode() && !site.supportsLocalMode()) {
             log.warn("Unable to enhance ci {} because OfflineMode is not 
supported by ReferencedSite {}.",
-                ci.getId(),site.getId());
+                ci.getId(), site.getId());
             return;
         }
         UriRef contentItemId = new UriRef(ci.getId());
@@ -267,9 +267,9 @@ public class ReferencedSiteEntityTagging
         LiteralFactory literalFactory = LiteralFactory.getInstance();
 
         // Retrieve the existing text annotations
-        Map<UriRef, List<UriRef>> textAnnotations = new HashMap<UriRef, 
List<UriRef>>();
-        for (Iterator<Triple> it = graph.filter(null, RDF_TYPE,
-                TechnicalClasses.ENHANCER_TEXTANNOTATION); it.hasNext();) {
+        Map<UriRef,List<UriRef>> textAnnotations = new 
HashMap<UriRef,List<UriRef>>();
+        for (Iterator<Triple> it = graph.filter(null, RDF_TYPE, 
TechnicalClasses.ENHANCER_TEXTANNOTATION); it
+                .hasNext();) {
             UriRef uri = (UriRef) it.next().getSubject();
             if (graph.filter(uri, Properties.DC_RELATION, null).hasNext()) {
                 // this is not the most specific occurrence of this name: skip
@@ -277,80 +277,78 @@ public class ReferencedSiteEntityTagging
             }
             // This is a first occurrence, collect any subsumed annotations
             List<UriRef> subsumed = new ArrayList<UriRef>();
-            for (Iterator<Triple> it2 = graph.filter(null,
-                    Properties.DC_RELATION, uri); it2.hasNext();) {
+            for (Iterator<Triple> it2 = graph.filter(null, 
Properties.DC_RELATION, uri); it2.hasNext();) {
                 subsumed.add((UriRef) it2.next().getSubject());
             }
             textAnnotations.put(uri, subsumed);
         }
 
-        for (Map.Entry<UriRef, List<UriRef>> entry : 
textAnnotations.entrySet()) {
+        for (Map.Entry<UriRef,List<UriRef>> entry : 
textAnnotations.entrySet()) {
             try {
-                computeEntityRecommentations(site, literalFactory, graph,
-                        contentItemId, entry.getKey(), entry.getValue());
+                computeEntityRecommentations(site, literalFactory, graph, 
contentItemId, entry.getKey(),
+                    entry.getValue());
             } catch (ReferencedSiteException e) {
                 throw new EngineException(this, ci, e);
             }
         }
     }
 
-    protected final Iterable<Sign> computeEntityRecommentations(
-            ReferencedSite site, LiteralFactory literalFactory, MGraph graph,
-            UriRef contentItemId, UriRef textAnnotation,
-            List<UriRef> subsumedAnnotations) throws ReferencedSiteException {
+    protected final Iterable<Sign> computeEntityRecommentations(ReferencedSite 
site,
+                                                                LiteralFactory 
literalFactory,
+                                                                MGraph graph,
+                                                                UriRef 
contentItemId,
+                                                                UriRef 
textAnnotation,
+                                                                List<UriRef> 
subsumedAnnotations) throws ReferencedSiteException {
         // First get the required properties for the parsed textAnnotation
         // ... and check the values
-        String name = EnhancementEngineHelper.getString(graph, textAnnotation,
-                ENHANCER_SELECTED_TEXT);
+        String name = EnhancementEngineHelper.getString(graph, textAnnotation, 
ENHANCER_SELECTED_TEXT);
         if (name == null) {
-            log.warn("Unable to process TextAnnotation " + textAnnotation
-                    + " because property" + ENHANCER_SELECTED_TEXT
-                    + " is not present");
+            log.warn("Unable to process TextAnnotation " + textAnnotation + " 
because property"
+                     + ENHANCER_SELECTED_TEXT + " is not present");
             return Collections.emptyList();
         }
 
-        UriRef type = EnhancementEngineHelper.getReference(graph,
-                textAnnotation, DC_TYPE);
+        UriRef type = EnhancementEngineHelper.getReference(graph, 
textAnnotation, DC_TYPE);
         if (type == null) {
-            log.warn("Unable to process TextAnnotation " + textAnnotation
-                    + " because property" + DC_TYPE + " is not present");
+            log.warn("Unable to process TextAnnotation " + textAnnotation + " 
because property" + DC_TYPE
+                     + " is not present");
             return Collections.emptyList();
         }
-        //remove punctations form the search string
+        // remove punctations form the search string
         name = cleanupKeywords(name);
 
         log.debug("Process TextAnnotation " + name + " type=" + type);
         FieldQuery query = site.getQueryFactory().createFieldQuery();
-        //replace spaces with plus to create an AND search for all words in 
the name!
-        query.setConstraint(nameField, new 
TextConstraint(name));//name.replace(' ', '+')));
-        if (OntologicalClasses.DBPEDIA_PERSON.equals(type)){
-            if (personState){
-                if (personType!=null){
+        // replace spaces with plus to create an AND search for all words in 
the name!
+        query.setConstraint(nameField, new TextConstraint(name));// 
name.replace(' ', '+')));
+        if (OntologicalClasses.DBPEDIA_PERSON.equals(type)) {
+            if (personState) {
+                if (personType != null) {
                     query.setConstraint(RDF_TYPE.getUnicodeString(), new 
ReferenceConstraint(personType));
                 } // else no type constraint
-            } else { //ignore people
+            } else { // ignore people
                 return Collections.emptyList();
             }
-        } else if (DBPEDIA_ORGANISATION.equals(type)){
-            if (orgState){
-                if (orgType!=null){
+        } else if (DBPEDIA_ORGANISATION.equals(type)) {
+            if (orgState) {
+                if (orgType != null) {
                     query.setConstraint(RDF_TYPE.getUnicodeString(), new 
ReferenceConstraint(orgType));
                 } // else no type constraint
-            } else { //ignore people
+            } else { // ignore people
                 return Collections.emptyList();
             }
-        } else if(OntologicalClasses.DBPEDIA_PLACE.equals(type)){
-            if (this.placeState){
-                if (this.placeType!=null){
+        } else if (OntologicalClasses.DBPEDIA_PLACE.equals(type)) {
+            if (this.placeState) {
+                if (this.placeType != null) {
                     query.setConstraint(RDF_TYPE.getUnicodeString(), new 
ReferenceConstraint(placeType));
                 } // else no type constraint
-            } else { //ignore people
+            } else { // ignore people
                 return Collections.emptyList();
             }
         }
         query.setLimit(this.numSuggestions);
         QueryResultList<Sign> results = site.findSigns(query);
-        log.debug("{} results returned by query {}",  results.size(), query);
+        log.debug("{} results returned by query {}", results.size(), query);
 
         List<NonLiteral> annotationsToRelate = new ArrayList<NonLiteral>();
         annotationsToRelate.add(textAnnotation);
@@ -358,30 +356,30 @@ public class ReferencedSiteEntityTagging
 
         for (Sign guess : results) {
             log.debug("Adding {} to ContentItem {}", guess, contentItemId);
-            EnhancementRDFUtils.writeEntityAnnotation(this, literalFactory,
-                    graph, contentItemId, annotationsToRelate, guess);
+            EnhancementRDFUtils.writeEntityAnnotation(this, literalFactory, 
graph, contentItemId,
+                annotationsToRelate, guess);
         }
         return results;
     }
 
     public int canEnhance(ContentItem ci) {
         /*
-         * This engine consumes existing enhancements because of that it can
-         * enhance any type of ci! TODO: It would also be possible to check 
here
-         * if there is an TextAnnotation and use that as result!
+         * This engine consumes existing enhancements because of that it can 
enhance any type of ci! TODO: It
+         * would also be possible to check here if there is an TextAnnotation 
and use that as result!
          */
         return ENHANCE_SYNCHRONOUS;
     }
 
     @Override
-    public Map<String, Object> getServiceProperties() {
-        return Collections.unmodifiableMap(Collections.singletonMap(
-                ENHANCEMENT_ENGINE_ORDERING,
-                (Object) defaultOrder));
+    public Map<String,Object> getServiceProperties() {
+        return 
Collections.unmodifiableMap(Collections.singletonMap(ENHANCEMENT_ENGINE_ORDERING,
+            (Object) defaultOrder));
     }
+
     /**
-     * Removes punctuations form a parsed string 
-     * @param keywords 
+     * Removes punctuations form a parsed string
+     * 
+     * @param keywords
      * @return
      */
     private static String cleanupKeywords(String keywords) {


Reply via email to