You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by si...@apache.org on 2012/01/26 16:37:08 UTC

svn commit: r1236246 [4/7] - in /incubator/stanbol/trunk: cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/ cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/ contenthub/ contenthub/bundlelist/src/main/bundl...

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/AbstractContenthubException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/AbstractContenthubException.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/AbstractContenthubException.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/AbstractContenthubException.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,24 @@
+package org.apache.stanbol.contenthub.servicesapi;
+
+/**
+ * 
+ * @author anil.sinaci
+ *
+ */
+public abstract class AbstractContenthubException extends Exception {
+
+    private static final long serialVersionUID = -2303415622874917355L;
+
+    protected AbstractContenthubException(String msg) {
+        super(msg);
+    }
+    
+    protected AbstractContenthubException(Throwable cause) {
+        super(cause);
+    }
+    
+    protected AbstractContenthubException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+    
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,26 @@
+/**
+ * 
+ */
+package org.apache.stanbol.contenthub.servicesapi;
+
+import org.apache.stanbol.contenthub.servicesapi.enhancements.vocabulary.EnhancementGraphVocabulary;
+
+/**
+ * @author anil.sinaci
+ *
+ */
+public class Constants {
+    
+    public static final String DEFAULT_ENCODING = "UTF-8";
+    
+    public static final String ENHANCER_ENTITIY_CACHE_GRAPH_URI = "enhancerEntityCache";
+    public static final String[] RESERVED_GRAPH_URIs = {ENHANCER_ENTITIY_CACHE_GRAPH_URI,
+                                                        EnhancementGraphVocabulary.ENHANCEMENTS_GRAPH_URI};
+
+    public static boolean isGraphReserved(String graphURI) {
+        for (String uri : RESERVED_GRAPH_URIs) {
+            if (uri.equals(graphURI)) return true;
+        }
+        return false;
+    }
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/enhancements/vocabulary/EnhancementGraphVocabulary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/enhancements/vocabulary/EnhancementGraphVocabulary.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/enhancements/vocabulary/EnhancementGraphVocabulary.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/enhancements/vocabulary/EnhancementGraphVocabulary.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.apache.stanbol.contenthub.servicesapi.enhancements.vocabulary;
+
+/**
+ * All enhancements gathered from all submitted documents are hold inside a single graph, called Enhancement
+ * Graph. This class provides specific endpoints and field names about the Enhancement Graph.
+ * 
+ * @author anil.sinaci
+ * 
+ */
+public class EnhancementGraphVocabulary {
+
+    /**
+     * The URI of the global enhancement graph. All enhancements are stored in this graph.
+     */
+    public static final String ENHANCEMENTS_GRAPH_URI = "org.apache.stanbol.enhancer.standalone.store.enhancements";
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/ContenthubException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/ContenthubException.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/ContenthubException.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/ContenthubException.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,15 @@
+package org.apache.stanbol.contenthub.servicesapi.exception;
+
+/**
+ * 
+ * @author anil.sinaci
+ *
+ */
+public class ContenthubException extends Exception {
+
+    private static final long serialVersionUID = -2303415622874917355L;
+
+    public ContenthubException(String msg) {
+        super(msg);
+    }
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,35 @@
+package org.apache.stanbol.contenthub.servicesapi.ldpath;
+
+import org.apache.stanbol.contenthub.servicesapi.AbstractContenthubException;
+
+/**
+ * @author anil.sinaci
+ *
+ */
+public class LDPathException extends AbstractContenthubException {
+
+    private static final long serialVersionUID = 4755524861924506181L;
+
+    /**
+     * @param msg
+     */
+    public LDPathException(String msg) {
+        super(msg);
+    }
+    
+    /**
+     * @param cause
+     */
+    public LDPathException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * @param msg
+     * @param cause
+     */
+    public LDPathException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+    
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,30 @@
+package org.apache.stanbol.contenthub.servicesapi.ldpath;
+
+/**
+ * @author anil.sinaci
+ *
+ */
+public class LDProgram {
+
+    private String name;
+    private String ldPathProgram;
+
+    public LDProgram(String name, String ldPathProgram) {
+        this.name = name;
+        this.ldPathProgram = ldPathProgram;
+    }
+    
+    public String getName() {
+        return name;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+    public String getLdPathProgram() {
+        return ldPathProgram;
+    }
+    public void setLdPathProgram(String ldPathProgram) {
+        this.ldPathProgram = ldPathProgram;
+    }
+    
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,39 @@
+package org.apache.stanbol.contenthub.servicesapi.ldpath;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author anil.sinaci
+ * 
+ */
+public class LDProgramCollection {
+
+    private Map<String,String> nameProgramMap;
+
+    public LDProgramCollection(Map<String,String> nameProgramMap) {
+        this.nameProgramMap = nameProgramMap;
+    }
+
+    public List<LDProgram> asList() {
+        List<LDProgram> list = new ArrayList<LDProgram>();
+        for(Map.Entry<String,String> entry : nameProgramMap.entrySet()) {
+            list.add(new LDProgram(entry.getKey(), entry.getValue()));
+        }
+        return list;
+    }
+
+    public Map<String,String> asMap() {
+        return this.nameProgramMap;
+    }
+    
+    public List<String> getProgramNames() {
+        return new ArrayList<String>(nameProgramMap.keySet());
+    }
+    
+    public List<String> getPrograms() {
+        return new ArrayList<String>(nameProgramMap.values());
+    }
+
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,55 @@
+package org.apache.stanbol.contenthub.servicesapi.ldpath;
+
+import java.io.Reader;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.clerezza.rdf.core.MGraph;
+
+public interface LDProgramManager {
+
+	/**
+	 * Saves program to persistent storage with given name and initialize Solr Core with same name
+	 * @param programName name of the submitted program, also will be name of corresponding Solr Core
+	 * @param ldPathProgram	LDPath Program in the form of {@link String}
+	 * @throws LDPathException	is thrown while parsing program and creating Solr Core
+	 */
+	public void submitProgram(String programName, String ldPathProgram) throws LDPathException;
+
+	/**
+	 * Saves program to persistent storage with given name and initialize Solr Core with same name
+	 * @param programName name of the submitted program, also will be name of corresponding Solr Core
+	 * @param ldPathProgram	LDPath Program in the form of {@link java.io.Reader}
+	 * @throws LDPathException	is thrown while parsing program and creating Solr Core
+	 */
+	public void submitProgram(String programName, Reader ldPathProgram) throws LDPathException;
+	
+	/**
+	 * Checks whether a program-core pair exist with given name or not
+	 * @param programName name of the program/core 
+	 * @return {@link true} if a program with given name exists; {@link false} otherwise
+	 */
+	public boolean isManagedProgram(String programName);
+	
+	/**
+	 * Retrieves the program managed by {@link ProgramManager} with given name
+	 * @param programName name of the program that will be retrieved
+	 * @return requested program as String, if such program does not exist, returns {@link false}
+	 */
+	public String getProgramByName(String programName);
+
+	/**
+	 * Deletes both the program and the corresponding Solr Core
+	 * @param programName name of the program-core pair to be deleted
+	 */
+	public void deleteProgram(String programName);
+	
+	/**
+	 * Used to retrieve names and programs of all currently managed program-core pairs
+	 * @return All managed programs with their names as {@link LDProgramCollection}
+	 */
+	public LDProgramCollection retrieveAllPrograms();
+	
+	public Map<String,Collection<?>> executeProgram(String programName, MGraph graph) throws LDPathException;
+
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,35 @@
+package org.apache.stanbol.contenthub.servicesapi.search;
+
+import org.apache.stanbol.contenthub.servicesapi.AbstractContenthubException;
+
+/**
+ * @author anil.sinaci
+ * 
+ */
+public class SearchException extends AbstractContenthubException {
+
+    private static final long serialVersionUID = -8961306574004699946L;
+
+    /**
+     * @param msg
+     */
+    public SearchException(String msg) {
+        super(msg);
+    }
+
+    /**
+     * @param cause
+     */
+    public SearchException(Throwable cause) {
+        super(cause);
+    }
+    
+    /**
+     * @param msg
+     * @param cause
+     */
+    public SearchException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,31 @@
+/**
+ * 
+ */
+package org.apache.stanbol.contenthub.servicesapi.search.featured;
+
+import java.util.List;
+
+import org.apache.solr.common.params.SolrParams;
+import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
+
+/**
+ * @author anil.sinaci
+ * 
+ */
+public interface FeaturedSearch {
+
+    SearchResult search(String queryTerm) throws SearchException;
+    
+    SearchResult search(String queryTerm, String ontologyURI, String ldProgramName) throws SearchException;
+    
+    SearchResult search(SolrParams solrQuery) throws SearchException;
+    
+    SearchResult search(SolrParams solrQuery, String ontologyURI, String ldProgramName) throws SearchException;
+
+    List<String> getFacetNames() throws SearchException;
+    
+    List<String> getFacetNames(String ldProgramName) throws SearchException;
+    
+    List<String> tokenizeEntities(String queryTerm);
+
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,14 @@
+package org.apache.stanbol.contenthub.servicesapi.search.featured;
+
+public interface ResultantDocument {
+    
+    String getLocalId();
+
+    String getDereferencableURI();
+
+    String getMimetype();
+
+    long getEnhancementCount();
+
+    String getTitle();
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+package org.apache.stanbol.contenthub.servicesapi.search.featured;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.solr.client.solrj.response.FacetField;
+import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeyword;
+
+/**
+ * This interface defines the structure of a search result returned by
+ * {@link Search#search(String[], String, List, Map)}. All results of a search operation are encapsulated.
+ * 
+ * @author anil.sinaci
+ * 
+ */
+public interface SearchResult {
+
+    List<ResultantDocument> getResultantDocuments();
+
+    /**
+     * Returns the facets generated as a result of the search operations. Each search result has its own
+     * facets.
+     * 
+     * @return A map of <code>property:[value1,value2]</code> pairs.
+     */
+    List<FacetField> getFacets();
+
+    Map<String,Map<String,List<RelatedKeyword>>> getRelatedKeywords();
+    
+    void setDocuments(List<ResultantDocument> resultantDocuments);
+
+    void setFacets(List<FacetField> facets);
+    
+    void setRelatedKeywords(Map<String,Map<String,List<RelatedKeyword>>> relatedKeywords);
+
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,34 @@
+package org.apache.stanbol.contenthub.servicesapi.search.related;
+
+public interface RelatedKeyword {
+
+    String getKeyword();
+    
+    double getScore();
+    
+    String getSource();
+    
+    /*
+     * To enumerate the source for a related keyword 
+     */
+    public enum Source {
+        
+        UNKNOWN("Unknown"),
+        
+        WORDNET("Wordnet"),
+        
+        ONTOLOGY("Ontology");
+        
+        private final String name;
+
+        private Source(String n) {
+            this.name = n;
+        }
+
+        @Override
+        public final String toString() {
+            return this.name;
+        }        
+    }
+    
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,13 @@
+package org.apache.stanbol.contenthub.servicesapi.search.related;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
+
+public interface RelatedKeywordSearch {
+
+    Map<String,List<RelatedKeyword>> search(String keyword) throws SearchException;
+
+    Map<String,List<RelatedKeyword>> search(String keyword, String ontologyURI) throws SearchException;
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,17 @@
+package org.apache.stanbol.contenthub.servicesapi.search.related;
+
+import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
+import org.apache.stanbol.contenthub.servicesapi.search.featured.SearchResult;
+
+public interface RelatedKeywordSearchManager {
+    
+    SearchResult getRelatedKeywordsFromAllSources(String keyword) throws SearchException;
+
+    SearchResult getRelatedKeywordsFromAllSources(String keyword, String ontologyURI) throws SearchException;
+    
+    SearchResult getRelatedKeywordsFromWordnet(String keyword) throws SearchException;
+    
+    SearchResult getRelatedKeywordsFromOntology(String keyword, String ontologyURI) throws SearchException;
+    
+    SearchResult getRelatedKeywordsFromReferencedCites(String keyword) throws SearchException;
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,17 @@
+package org.apache.stanbol.contenthub.servicesapi.search.solr;
+
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
+
+public interface SolrSearch {
+
+    QueryResponse search(String queryTerm) throws SearchException;
+    
+    QueryResponse search(String queryTerm, String ldProgramName) throws SearchException;
+    
+    QueryResponse search(SolrParams solrQuery) throws SearchException;
+    
+    QueryResponse search(SolrParams solrQuery, String ldProgramName) throws SearchException;
+    
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/vocabulary/SearchVocabulary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/vocabulary/SearchVocabulary.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/vocabulary/SearchVocabulary.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/vocabulary/SearchVocabulary.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,250 @@
+/*
+ * 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.
+ */
+
+package org.apache.stanbol.contenthub.servicesapi.search.vocabulary;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+
+/**
+ * RDF Vocabulary for Apache Stanbol search component. Inspired by com.hp.hpl.jena.vocabulary.RDF class
+ * {@link SearchContext} is implemented as a Jena graph. Any information of the search context is kept as a
+ * triple inside the context graph. Accessing any information of the context (i.e. search results) is actually
+ * executing a filter on the Jena graph, which is the context itself.
+ * 
+ * @author cihancimen
+ * 
+ */
+public final class SearchVocabulary {
+
+    private static final String URI = "http://stanbol.apache.org/search/";
+
+    public static final String getUri() {
+        return URI;
+    }
+
+    private static Resource resource(String local) {
+        return ResourceFactory.createResource(URI + local);
+    }
+
+    private static Property property(String local) {
+        return ResourceFactory.createProperty(URI, local);
+    }
+
+    /**
+     * Represents a keyword directly entered in query string
+     */
+    public static final Resource QUERY_KEYWORD = resource("queryKeyword");
+
+    /**
+     * Represents a {@link Keyword} that is related to a {@link QueryKeyword}. Generally found by a
+     * {@link SearchEngine}.
+     */
+    public static final Resource KEYWORD = resource("keyword");
+
+    /**
+     * Represents an OWL Class found by a {@link SearchEngine}.
+     */
+    public static final Resource CLASS_RESOURCE = resource("classResource");
+    /**
+     * Represents an OWL Individual found by a search engine.
+     */
+    public static final Resource INDIVIDUAL_RESOURCE = resource("individualResource");
+
+    /**
+     * Represents a Document in Enhancer Store, found by a {@link SearchEngine}.
+     */
+    public static final Resource DOCUMENT_RESOURCE = resource("documentResource");
+
+    /**
+     * Represents an external entity found by a {@link SearchEngine}
+     */
+    public static final Resource EXTERNAL_RESOURCE = resource("externalResource");
+
+    /**
+     * Represents the score of a resource.
+     */
+    public static final Property SCORE = property("score");
+
+    /**
+     * Represent the weight of a resource. Weight is used to update the score of the resource.
+     */
+    public static final Property WEIGHT = property("weight");
+
+    /**
+     * Represents the original string of a {@link Keyword}.
+     */
+    public static final Property KEYWORD_STRING = property("keywordString");
+
+    /**
+     * Represents relationship between a resource and a {@link Keyword}
+     */
+    public static final Property RELATED_KEYWORD = property("relatedKeyword");
+
+    /**
+     * Represents relationship between a resource and a {@link QueryKeyword}
+     */
+    public static final Property RELATED_QUERY_KEYWORD = property("relatedQueryKeyword");
+
+    /**
+     * Represents relationship between a resource and a {@link ClassResource}.
+     */
+    public static final Property RELATED_CLASS = property("relatedClass");
+
+    /**
+     * Represents relationship between a resource and a {@link IndividualResource}.
+     */
+    public static final Property RELATED_INDIVIDUAL = property("relatedIndividual");
+
+    /**
+     * Represents the URI of a {@link ClassResource}.
+     */
+    public static final Property CLASS_URI = property("classURI");
+
+    /**
+     * Represents the URI of an {@link IndividualResource}.
+     */
+    public static final Property INDIVIDUAL_URI = property("individualURI");
+
+    /**
+     * Represents the URI of an {@link ExternalResource}.
+     */
+    public static final Property DEREFENCEABLE_URI = property("dereferenceableURI");
+
+    /**
+     * Represents the special property which is used by Lucene while creating the index. At the beginning of a
+     * search operation, user ontology is processed to add this special property to each class and individual
+     * resource by using their local names.
+     */
+    public static final Property HAS_LOCAL_NAME = property("hasLocalName");
+
+    /**
+     * Represents relationship between a resource and a {@link DocumentResource}.
+     */
+    public static final Property RELATED_DOCUMENT = property("relatedDocument");
+
+    /**
+     * Represents the text of a {@link DocumentResource}.
+     */
+    public static final Property SELECTION_TEXT = property("selectionText");
+
+    /**
+     * Represents the title of a {@link DocumentResource}.
+     */
+    public static final Property DOCUMENT_TITLE = property("documentTitle");
+
+    /**
+     * Represents relationship between an {@link ExternalResource} and the entity which is externally
+     * referenced.
+     */
+    public static final Property EXTERNAL_ENTITY = property("externalEntity");
+
+    /**
+     * Represents the path of a {@link DocumentResource}. This is the path which specifically identifies the
+     * content item inside the content reposiroy.
+     */
+    public static final Property CONTENT_REPOSITORY_ITEM = property("contentRepositoryItem");
+
+    /**
+     * Special class to manage the conversion between {@link Resource} and {@link Node}.
+     * 
+     * @author cihan
+     * 
+     */
+    // Nodes
+    public static final class Nodes {
+        private Nodes() {
+
+        }
+
+        /**
+         * @see SearchVocabulary#QUERY_KEYWORD
+         */
+        public static final Node QUERY_KEYWORD = SearchVocabulary.QUERY_KEYWORD.asNode();
+
+        /**
+         * @see SearchVocabulary#KEYWORD
+         */
+        public static final Node KEYWORD = SearchVocabulary.KEYWORD.asNode();
+
+        /**
+         * @see SearchVocabulary#CLASS_RESOURCE
+         */
+        public static final Node CLASS_RESOURCE = SearchVocabulary.CLASS_RESOURCE.asNode();
+
+        /**
+         * @see SearchVocabulary#INDIVIDUAL_RESOURCE
+         */
+        public static final Node INDIVIDUAL_RESOURCE = SearchVocabulary.INDIVIDUAL_RESOURCE.asNode();
+
+        /**
+         * @see SearchVocabulary#DOCUMENT_RESOURCE
+         */
+        public static final Node DOCUMENT_RESOURCE = SearchVocabulary.DOCUMENT_RESOURCE.asNode();
+
+        /**
+         * @see SearchVocabulary#EXTERNAL_RESOURCE
+         */
+        public static final Node EXTERNAL_RESOURCE = SearchVocabulary.EXTERNAL_RESOURCE.asNode();
+
+        /**
+         * @see SearchVocabulary#KEYWORD_STRING
+         */
+        public static final Node KEYWORD_STRING = SearchVocabulary.KEYWORD_STRING.asNode();
+
+        /**
+         * @see SearchVocabulary#RELATED_CLASS
+         */
+        public static final Node RELATED_CLASS = SearchVocabulary.RELATED_CLASS.asNode();
+
+        /**
+         * @see SearchVocabulary#RELATED_INDIVIDUAL
+         */
+        public static final Node RELATED_INDIVIDUAL = SearchVocabulary.RELATED_INDIVIDUAL.asNode();
+
+        /**
+         * @see SearchVocabulary#INDIVIDUAL_URI
+         */
+        public static final Node INDIVIDUAL_URI = SearchVocabulary.INDIVIDUAL_URI.asNode();
+
+        /**
+         * @see SearchVocabulary#CLASS_URI
+         */
+        public static final Node CLASS_URI = SearchVocabulary.CLASS_URI.asNode();
+
+        /**
+         * @see SearchVocabulary#DEREFENCEABLE_URI
+         */
+        public static final Node DEREFERENCEABLE_URI = SearchVocabulary.DEREFENCEABLE_URI.asNode();
+
+        /**
+         * @see SearchVocabulary#RELATED_KEYWORD
+         */
+        public static final Node RELATED_KEYWORD = SearchVocabulary.RELATED_KEYWORD.asNode();
+
+        /**
+         * @see SearchVocabulary#RELATED_QUERY_KEYWORD
+         */
+        public static final Node RELATED_QUERY_KEYWORD = SearchVocabulary.RELATED_QUERY_KEYWORD.asNode();
+    }
+
+    private SearchVocabulary() {
+
+    }
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,67 @@
+/*
+* 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.
+*/
+package org.apache.stanbol.contenthub.servicesapi.store;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
+
+
+/**
+ * Store and retrieve ContentItem instances.
+ *
+ * Incomplete CRUD for now, we don't need it for our
+ * initial use cases.
+ */
+public interface Store {
+
+    /**
+     * Creates a {@link ContentItem} item based on supplied data,
+     * using an implementation that suits this store.
+     * <p>
+     * Calling this method creates an empty data transfer object in
+     * memory suitable for later saving using the {@link Store#put(ContentItem)} method.
+     * The Store state is unchanged by the call to the
+     * {@link #create(String, byte[], String)} method.
+     *
+     * @param id The value to use {@link ContentItem#getId}. If <code>null</code>
+     * is parsed as id, an id need to be computed based on the parsed content (
+     * e.g. calculating the stream digest (see also
+     * {@link ContentItemHelper#streamDigest(java.io.InputStream, java.io.OutputStream, String)})
+     * @param content the binary content
+     * @param contentType The Mime-Type of the binary data
+     * @return the {@link ContentItem} that was created
+     */
+    ContentItem create(String id, byte[] content, String contentType);
+
+    /** Store supplied {@link ContentItem} and return its id, which
+     *  is assigned by the store if not defined yet.
+     *
+     *  If the {@link ContentItem} already exists, it is overwritten.
+     */
+    String put(ContentItem ci) throws StoreException;
+
+    /** Get a {@link ContentItem} by id, null if non-existing */
+    ContentItem get(String id) throws StoreException;
+
+    /**
+     * Get the graph of triples of enhancements related to the content item from
+     * this store
+     */
+    MGraph getEnhancementGraph();
+
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/StoreException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/StoreException.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/StoreException.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/StoreException.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,35 @@
+package org.apache.stanbol.contenthub.servicesapi.store;
+
+import org.apache.stanbol.contenthub.servicesapi.AbstractContenthubException;
+
+/**
+ * @author anil.sinaci
+ *
+ */
+public class StoreException extends AbstractContenthubException {
+
+    private static final long serialVersionUID = 5670121947624979014L;
+
+    /**
+     * @param msg
+     */
+    public StoreException(String msg) {
+        super(msg);
+    }
+    
+    /**
+     * @param cause
+     */
+    public StoreException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * @param msg
+     * @param cause
+     */
+    public StoreException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrContentItem.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrContentItem.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrContentItem.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrContentItem.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+package org.apache.stanbol.contenthub.servicesapi.store.solr;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+
+/**
+ * Defines a {@link ContentItem} to be stored in Solr.
+ * <p>
+ * Solr provides a mechanism to apply faceted search operations. Facets are passed as
+ * <code>key:[value1,value2]</code> pairs. These facets are named as <b>constraints</b> within
+ * {@link SolrContentItem}.
+ * 
+ * @author meric.taze
+ * 
+ */
+public interface SolrContentItem extends ContentItem {
+
+    /**
+     * Retrieves the constraints (facets) which can be applied on this content item in the search operation.
+     * 
+     * @return A map of constraints (facets).
+     */
+    Map<String,List<Object>> getConstraints();
+
+    /**
+     * Retrieves the title of this content item
+     * 
+     * @return title {@link String}
+     */
+    String getTitle();
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.stanbol.contenthub.servicesapi.store.solr;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.stanbol.contenthub.servicesapi.store.Store;
+import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
+
+/**
+ * {@link Store} interface for Solr.
+ * 
+ * @author anil.sinaci
+ * @author meric.taze
+ * 
+ */
+public interface SolrStore extends Store {
+
+    /**
+     * Creates a {@link SolrContentItem} with the given parameters. Created {@link SolrContentItem} is not
+     * persisted, this function just creates the object.
+     * 
+     * @param content
+     *            The content itself.
+     * @param id
+     *            The unique ID for the item. If it is null, {@link SolrStore} should assign a unique ID for
+     *            this item.
+     * @param title
+     *            The title for the content item.
+     * @param contentType
+     *            The mimeType of the content.
+     * @param constraints
+     *            The facets in <code>key:[value1,value2]</code> pairs.
+     * @return Created {@link SolrContentItem}.
+     */
+    SolrContentItem create(byte[] content,
+                           String id,
+                           String title,
+                           String contentType,
+                           Map<String,List<Object>> constraints);
+
+    /**
+     * Sends the {@link SolrContentItem} to the {@link EnhancementJobManager} to enhance the content.
+     * Afterwards saves the item to Solr.
+     * 
+     * @param sci
+     *            The {@link SolrContentItem} to be enhanced and saved.
+     * @return The unique ID of the {@link SolrContentItem}.
+     */
+    String enhanceAndPut(SolrContentItem sci) throws StoreException;
+
+    String enhanceAndPut(SolrContentItem sci, String ldProgramName) throws StoreException;
+
+    String put(SolrContentItem ci, String ldProgramName) throws StoreException;
+
+    SolrContentItem get(String id, String ldProgramName) throws StoreException;
+    
+    /**
+     * Deletes the {@link ContentItem} from the {@link SolrStore}.
+     * 
+     * @param id
+     *            The ID of the item to be deleted.
+     */
+    void deleteById(String id) throws StoreException ;
+
+    void deleteById(String id, String ldProgramName) throws StoreException ;
+
+    /**
+     * Deletes the {@link ContentItem}s from the {@link SolrStore}.
+     * 
+     * @param id
+     *            The list of IDs of the items to be deleted.
+     */
+    void deleteById(List<String> idList) throws StoreException ;
+
+    void deleteById(List<String> idList, String ldProgramName) throws StoreException ;
+}

Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/vocabulary/SolrVocabulary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/vocabulary/SolrVocabulary.java?rev=1236246&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/vocabulary/SolrVocabulary.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/vocabulary/SolrVocabulary.java Thu Jan 26 15:37:02 2012
@@ -0,0 +1,292 @@
+/*
+ * 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.
+ */
+
+package org.apache.stanbol.contenthub.servicesapi.store.vocabulary;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Vocabulary class which provides constant properties to be used in the communication with Solr. Most of
+ * these properties point to the fields defined in the <b>schema.xml</b> of Solr.
+ * 
+ * @author anil.sinaci
+ * 
+ */
+public class SolrVocabulary {
+
+    private static final String STANBOLRESERVED_PREFIX = "stanbolreserved_";
+
+    public enum SolrFieldName {
+
+        /**
+         * Name of the field which holds entities which carry the dbpedia Place property.
+         */
+        PLACES("places" + SOLR_DYNAMIC_FIELD_TEXT),
+
+        /**
+         * Name of the field which holds entities which carry the dbpedia Person property.
+         */
+        PEOPLE("people" + SOLR_DYNAMIC_FIELD_TEXT),
+
+        /**
+         * Name of the field which holds entities which carry the dbpedia Organization property.
+         */
+        ORGANIZATIONS("organizations" + SOLR_DYNAMIC_FIELD_TEXT),
+
+        /**
+         * Name of the unique ID field.
+         */
+        ID(STANBOLRESERVED_PREFIX + "id"),
+
+        /**
+         * Name of the field which holds the title of the content.
+         */
+        TITLE(STANBOLRESERVED_PREFIX + "title"),
+        
+        /**
+         * Name of the field which holds the actual content.
+         */
+        CONTENT(STANBOLRESERVED_PREFIX + "content"),
+
+        /**
+         * Name of the field which holds the mime type (content type) of the content.
+         */
+        MIMETYPE(STANBOLRESERVED_PREFIX + "mimetype"),
+
+        /**
+         * Name of the field which holds the creation date of the content.
+         */
+        CREATIONDATE(STANBOLRESERVED_PREFIX + "creationdate"),
+
+        /**
+         * Name of the field which holds the number of enhancements for the content.
+         */
+        ENHANCEMENTCOUNT(STANBOLRESERVED_PREFIX + "enhancementcount"),
+
+        /**
+         * Name of the field which holds the countries of the cities mentioned in the content. This field is
+         * populated by the semantic operations through the enhancements of the content.
+         */
+        COUNTRIES(STANBOLRESERVED_PREFIX + "countries"),
+
+        /**
+         * Name of the field which holds the image captions of the entities mentioned in the content. This
+         * field is populated by the semantic operations through the enhancements of the content.
+         */
+        IMAGECAPTIONS(STANBOLRESERVED_PREFIX + "imagecaptions"),
+
+        /**
+         * Name of the field which holds the geographic regions of the cities mentioned in the content. This
+         * field is populated by the semantic operations through the enhancements of the content.
+         */
+        REGIONS(STANBOLRESERVED_PREFIX + "regions"),
+
+        /**
+         * Name of the field which holds the governors of the provinces mentioned in the content. This field
+         * is populated by the semantic operations through the enhancements of the content.
+         */
+        GOVERNORS(STANBOLRESERVED_PREFIX + "governors"),
+
+        /**
+         * Name of the field which holds the capital cities of the countries mentioned in the content. This
+         * field is populated by the semantic operations through the enhancements of the content.
+         */
+        CAPITALS(STANBOLRESERVED_PREFIX + "capitals"),
+
+        /**
+         * Name of the field which holds the largest cities of the entities mentioned in the content. This
+         * field is populated by the semantic operations through the enhancements of the content.
+         */
+        LARGESTCITIES(STANBOLRESERVED_PREFIX + "largestcities"),
+
+        /**
+         * Name of the field which holds the names of the leaders of the countries mentioned in the content.
+         * This field is populated by the semantic operations through the enhancements of the content.
+         */
+        LEADERNAMES(STANBOLRESERVED_PREFIX + "leadernames"),
+
+        /**
+         * Name of the field which holds the given names of the persons mentioned in the content. This field
+         * is populated by the semantic operations through the enhancements of the content.
+         */
+        GIVENNAMES(STANBOLRESERVED_PREFIX + "givennames"),
+
+        /**
+         * Name of the field which holds the important events which are known/invented through the persons
+         * mentioned in the content. This field is populated by the semantic operations through the
+         * enhancements of the content.
+         */
+        KNOWNFORS(STANBOLRESERVED_PREFIX + "knownfors"),
+
+        /**
+         * Name of the field which holds the birthplaces/placeofbirths of the persons mentioned in the
+         * content. This field is populated by the semantic operations through the enhancements of the
+         * content.
+         */
+        BIRTHPLACES(STANBOLRESERVED_PREFIX + "birthplaces"),
+        PLACEOFBIRTHS(STANBOLRESERVED_PREFIX + "placeofbirths"),
+
+        /**
+         * Name of the field which holds the names of the institutions at which the persons mentioned in the
+         * content worked. This field is populated by the semantic operations through the enhancements of the
+         * content.
+         */
+        WORKINSTITUTIONS(STANBOLRESERVED_PREFIX + "workinstitutions"),
+
+        /**
+         * Name of the field which holds the captions of the images belonging to the persons mentioned in the
+         * content. This field is populated by the semantic operations through the enhancements of the
+         * content.
+         */
+        CAPTIONS(STANBOLRESERVED_PREFIX + "captions"),
+
+        /**
+         * Name of the field which holds the short descriptions of the persons mentioned in the content. This
+         * field is populated by the semantic operations through the enhancements of the content.
+         */
+        SHORTDESCRIPTIONS(STANBOLRESERVED_PREFIX + "shortdescriptions"),
+
+        /**
+         * Name of the field which holds the fields on which the persons mentioned in the content studied.
+         * This field is populated by the semantic operations through the enhancements of the content.
+         */
+        FIELDS(STANBOLRESERVED_PREFIX + "fields");
+
+        private final String name;
+
+        private SolrFieldName(String n) {
+            this.name = n;
+        }
+
+        @Override
+        public final String toString() {
+            return this.name;
+        }
+
+        public static SolrFieldName[] getSemanticFieldNames() {
+            // Semantic fields start from the 9th enumeration.
+            SolrFieldName[] allFields = values();
+            SolrFieldName[] semanticFieldNames = new SolrFieldName[allFields.length - 9];
+            for (int i = 9; i < allFields.length; i++) {
+                semanticFieldNames[i - 9] = allFields[i];
+            }
+            return semanticFieldNames;
+        }
+
+        public static SolrFieldName[] getAnnotatedEntityFieldNames() {
+            SolrFieldName[] annotatedEntityFieldNames = {PLACES, PEOPLE, ORGANIZATIONS};
+            return annotatedEntityFieldNames;
+        }
+
+        public static boolean isNameReserved(String name) {
+            // Reserved keywords start from the 3rd enumeration
+            SolrFieldName[] allFields = values();
+            for (int i = 3; i < allFields.length; i++) {
+                if (allFields[i].toString().equals(name)) return true;
+            }
+            return false;
+        }
+        
+        public static boolean isAnnotatedEntityFacet(String facetName) {
+            for (SolrFieldName sfn : getAnnotatedEntityFieldNames()) {
+                if (sfn.toString().equals(facetName)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Ending characters for dynamic fields of {@link String} type.
+     */
+    public static final String SOLR_DYNAMIC_FIELD_TEXT = "_t";
+
+    /**
+     * Ending characters for dynamic fields of {@link Long} type.
+     */
+    public static final String SOLR_DYNAMIC_FIELD_LONG = "_l";
+
+    /**
+     * Ending characters for dynamic fields of {@link Double} type.
+     */
+    public static final String SOLR_DYNAMIC_FIELD_DOUBLE = "_d";
+
+    /**
+     * Ending characters for dynamic fields of {@link Date} type.
+     */
+    public static final String SOLR_DYNAMIC_FIELD_DATE = "_dt";
+
+    /**
+     * "OR" keyword for Solr queries.
+     */
+    public static final String SOLR_OR = " OR ";
+
+    /**
+     * Checks whether the specified field is excluded or not i.e whether the field will be presented as a
+     * facet or not
+     * 
+     * @param name
+     *            field name
+     */
+    public static boolean isNameExcluded(String name) {
+        // trim the data type extension if there is one
+        int underscoreIndex = name.lastIndexOf("_");
+        if (underscoreIndex != -1) {
+            String extension = name.substring(underscoreIndex);
+            if (extension.equals(SOLR_DYNAMIC_FIELD_DATE) || extension.equals(SOLR_DYNAMIC_FIELD_DOUBLE)
+                || extension.equals(SOLR_DYNAMIC_FIELD_LONG) || extension.equals(SOLR_DYNAMIC_FIELD_TEXT)) {
+                name = name.substring(0, underscoreIndex);
+            }
+        }
+
+        return excludedFields.contains(name);
+    }
+
+    /**
+     * Fields that will not be presented as facets
+     */
+    private static List<String> excludedFields = new ArrayList<String>();
+    static {
+        excludedFields.add("skos:definition");
+        excludedFields.add("rdfs:label");
+        excludedFields.add(SolrFieldName.TITLE.toString());
+        excludedFields.add("text_all");
+    }
+
+    /**
+     * Checks whether the specified field is range field or not i.e whether the field will be used in range
+     * queries or not
+     * 
+     * @param name
+     *            field name
+     */
+    public static boolean isNameRangeField(String name) {
+        return rangeFields.contains(name) || name.endsWith(SOLR_DYNAMIC_FIELD_LONG);
+    }
+
+    /**
+     * Fields that will be used in range queries and will not be escaped in {@link SolrSearchEngineHelper}
+     * class
+     */
+    private static List<String> rangeFields = new ArrayList<String>();
+    static {
+        rangeFields.add(SolrFieldName.CREATIONDATE.toString());
+    }
+}

Modified: incubator/stanbol/trunk/contenthub/store/clerezza/src/main/java/org/apache/stanbol/contenthub/store/clerezza/ClerezzaBlob.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/store/clerezza/src/main/java/org/apache/stanbol/contenthub/store/clerezza/ClerezzaBlob.java?rev=1236246&r1=1236245&r2=1236246&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/store/clerezza/src/main/java/org/apache/stanbol/contenthub/store/clerezza/ClerezzaBlob.java (original)
+++ incubator/stanbol/trunk/contenthub/store/clerezza/src/main/java/org/apache/stanbol/contenthub/store/clerezza/ClerezzaBlob.java Thu Jan 26 15:37:02 2012
@@ -1,19 +1,3 @@
-/*
-* 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.
-*/
 package org.apache.stanbol.contenthub.store.clerezza;
 
 import java.io.ByteArrayInputStream;

Modified: incubator/stanbol/trunk/contenthub/store/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/store/pom.xml?rev=1236246&r1=1236245&r2=1236246&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/store/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/store/pom.xml Thu Jan 26 15:37:02 2012
@@ -16,34 +16,39 @@
    limitations under the License.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
-  <modelVersion>4.0.0</modelVersion>
+	<modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.stanbol</groupId>
-  <artifactId>org.apache.stanbol.contenthub.store.reactor</artifactId>
-  <version>0.9.0-incubating-SNAPSHOT</version>
-  <packaging>pom</packaging>
+	<parent>
+		<groupId>org.apache.stanbol</groupId>
+		<artifactId>org.apache.stanbol.contenthub.parent</artifactId>
+		<version>0.9.0-incubating-SNAPSHOT</version>
+		<relativePath>../parent</relativePath>
+	</parent>
 
-  <name>Apache Stanbol Contenthub Store Reactor</name>
-  <description>
+	<artifactId>org.apache.stanbol.contenthub.store.reactor</artifactId>
+	<packaging>pom</packaging>
+
+	<name>Apache Stanbol Contenthub Store Reactor</name>
+	<description>
     Pseudo project to build the Contenthub Store
-  </description>
+    </description>
 
-  <inceptionYear>2011</inceptionYear>
+	<inceptionYear>2011</inceptionYear>
 
-  <scm>
-    <connection>
-      scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/store
+	<scm>
+		<connection>
+				  scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/store
     </connection>
-    <developerConnection>
-      scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/store
+		<developerConnection>
+				  scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/store
     </developerConnection>
-  </scm>
+	</scm>
 
-  <modules>
-    <module>solr</module>
-    <module>clerezza</module>
-    <module>inmemory</module>
-  </modules>
+	<modules>
+		<module>solr</module>
+		<module>clerezza</module>
+		<module>inmemory</module>
+	</modules>
 </project>

Modified: incubator/stanbol/trunk/contenthub/store/solr/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/store/solr/pom.xml?rev=1236246&r1=1236245&r2=1236246&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/store/solr/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/store/solr/pom.xml Thu Jan 26 15:37:02 2012
@@ -33,6 +33,15 @@
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
         <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <!-- We need to provide the default SolrYard indexConfigurations 
+              to the DataFileProvider infrastructure -->
+            <Data-Files>
+              solr/core
+            </Data-Files>
+          </instructions>
+        </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.felix</groupId>
@@ -50,10 +59,6 @@
       <artifactId>org.apache.stanbol.enhancer.servicesapi</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.stanbol</groupId>
-      <artifactId>org.apache.stanbol.contenthub.core</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.apache.clerezza</groupId>
       <artifactId>rdf.core</artifactId>
     </dependency>
@@ -61,7 +66,7 @@
       <groupId>org.apache.clerezza</groupId>
       <artifactId>rdf.jena.facade</artifactId>
     </dependency>
-    
+
     <!-- Solr/Lucene dependencies (needed for using embedded Solr servers) -->
     <dependency>
       <groupId>org.apache.solr</groupId>

Modified: incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrContentItemImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrContentItemImpl.java?rev=1236246&r1=1236245&r2=1236246&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrContentItemImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrContentItemImpl.java Thu Jan 26 15:37:02 2012
@@ -17,9 +17,8 @@
 
 package org.apache.stanbol.contenthub.store.solr;
 
-import static org.apache.stanbol.contenthub.core.utils.ContentItemIDOrganizer.CONTENT_ITEM_URI_PREFIX;
+import static org.apache.stanbol.contenthub.store.solr.util.ContentItemIDOrganizer.CONTENT_ITEM_URI_PREFIX;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -27,9 +26,8 @@ import java.util.Map;
 import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.stanbol.contenthub.core.utils.ContentItemIDOrganizer;
 import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
-import org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary.SolrFieldName;
+import org.apache.stanbol.contenthub.store.solr.util.ContentItemIDOrganizer;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemImpl;
 import org.apache.stanbol.enhancer.servicesapi.helper.InMemoryBlob;
@@ -53,11 +51,6 @@ public class SolrContentItemImpl extends
     private final Map<String,List<Object>> constraints;
     private String title;
 
-// Do not allow ContentItmes without Content!
-//    public SolrContentItemImpl(String id) {
-//        this(id, null, null, null, null);
-//    }
-
     public SolrContentItemImpl(byte[] content, String mimetype) {
         this(null, content, mimetype, null, null);
     }
@@ -80,18 +73,17 @@ public class SolrContentItemImpl extends
                                String mimeType,
                                MGraph metadata,
                                Map<String,List<Object>> constraints) {
-    	super(id == null ? ContentItemHelper.makeDefaultUri(CONTENT_ITEM_URI_PREFIX, content) :
-    		new UriRef(ContentItemIDOrganizer.attachBaseURI(id)),
-    		new InMemoryBlob(content, mimeType),
-    		metadata == null ? new SimpleMGraph() : metadata);
+        super(id == null ? ContentItemHelper.makeDefaultUri(CONTENT_ITEM_URI_PREFIX, content) : new UriRef(
+                ContentItemIDOrganizer.attachBaseURI(id)), new InMemoryBlob(content, mimeType),
+                metadata == null ? new SimpleMGraph() : metadata);
 
         if (metadata == null) {
             metadata = new SimpleMGraph();
         }
-        if(constraints == null) {
+        if (constraints == null) {
             constraints = new HashMap<String,List<Object>>();
         }
-        this.title = determineTitle(title, getUri().getUnicodeString(), constraints);
+        this.title = title;
         this.constraints = constraints;
     }
 
@@ -106,29 +98,4 @@ public class SolrContentItemImpl extends
         }
         return getUri().getUnicodeString();
     }
-
-    private String determineTitle(String title, String id, Map<String,List<Object>> constraints) {
-        if (title != null && !title.trim().equals("")) {
-            title = title.trim();
-            List<Object> titleList = new ArrayList<Object>();
-            titleList.add(title);
-            constraints.put(SolrFieldName.TITLE.toString(), titleList);
-
-        } else {
-            List<Object> titleList = constraints.get(SolrFieldName.TITLE.toString());
-            if (titleList != null) {
-                String titleCons = titleList.toString();
-                titleCons = titleCons.substring(1,titleCons.length()-1);
-                titleList.clear();
-                titleList.add(titleCons);
-                title = titleList.get(0).toString();
-            } else {
-                title = id;
-                titleList = new ArrayList<Object>();
-                titleList.add(title);
-                constraints.put(SolrFieldName.TITLE.toString(), titleList);
-            }
-        }
-        return title;
-    }
 }
\ No newline at end of file