You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by sf...@apache.org on 2010/12/12 16:13:37 UTC

svn commit: r1044832 [8/14] - in /incubator/stanbol/trunk/rick: indexing/dbPedia/src/main/java/eu/iksproject/rick/indexing/dbPedia/cli/ indexing/genericRdf/src/main/java/eu/iksproject/rick/indexing/rdf/ indexing/geonames/src/main/java/eu/iksproject/ric...

Modified: incubator/stanbol/trunk/rick/site/linkedData/src/main/java/eu/iksproject/rick/site/linkedData/impl/SparqlSearcher.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/site/linkedData/src/main/java/eu/iksproject/rick/site/linkedData/impl/SparqlSearcher.java?rev=1044832&r1=1044831&r2=1044832&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/site/linkedData/src/main/java/eu/iksproject/rick/site/linkedData/impl/SparqlSearcher.java (original)
+++ incubator/stanbol/trunk/rick/site/linkedData/src/main/java/eu/iksproject/rick/site/linkedData/impl/SparqlSearcher.java Sun Dec 12 15:13:35 2010
@@ -31,100 +31,100 @@ import eu.iksproject.rick.servicesapi.qu
 import eu.iksproject.rick.servicesapi.site.EntitySearcher;
 
 @Component(
-		name="eu.iksproject.rick.site.SparqlSearcher",
-		factory="eu.iksproject.rick.site.SparqlSearcherFactory",
-		policy=ConfigurationPolicy.REQUIRE, //the queryUri and the SPARQL Endpoint are required
-		specVersion="1.1"
-		) 
+        name="eu.iksproject.rick.site.SparqlSearcher",
+        factory="eu.iksproject.rick.site.SparqlSearcherFactory",
+        policy=ConfigurationPolicy.REQUIRE, //the queryUri and the SPARQL Endpoint are required
+        specVersion="1.1"
+        )
 public class SparqlSearcher extends AbstractEntitySearcher implements EntitySearcher {
 
-	public SparqlSearcher() {
-		super(LoggerFactory.getLogger(SparqlSearcher.class));
-	}
+    public SparqlSearcher() {
+        super(LoggerFactory.getLogger(SparqlSearcher.class));
+    }
 
-	@Reference
+    @Reference
     protected Parser parser;
 
-	protected static final String DEFAULT_RDF_CONTENT_TYPE = SupportedFormat.N3;
-	protected static final String DEFAULT_SPARQL_RESULT_CONTENT_TYPE = SparqlEndpointUtils.SPARQL_RESULT_JSON;
-	@Override
-	public QueryResultList<String> findEntities(FieldQuery parsedQuery)  throws IOException {
-		final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
-		String sparqlQuery = query.toSparqlSelect(false);
-		InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, DEFAULT_SPARQL_RESULT_CONTENT_TYPE);
-		//Move to util class!
-		final List<String> entities = extractEntitiesFromJsonResult(in,query.getRootVariableName());
-		return new QueryResultListImpl<String>(query, entities.iterator(),String.class);
-	}
-
-	/**
-	 * Extracts the values of the Query. Also used by {@link VirtuosoSearcher}
-	 * and {@link LarqSearcher}
-	 * @param rootVariable the name of the variable to extract
-	 * @param in the input stream with the data
-	 * @return the extracted results
-	 * @throws IOException if the input streams decides to explode
-	 */
-	protected static List<String> extractEntitiesFromJsonResult(InputStream in, final String rootVariable) throws IOException {
-		final List<String> entities;
-		try {
-			JSONObject result = new JSONObject(IOUtils.toString(in));
-			JSONObject results = result.getJSONObject("results");
-			if(results != null){
-				JSONArray bindings = results.getJSONArray("bindings");
-				if(bindings != null && bindings.length()>0){
-					entities = new ArrayList<String>(bindings.length());
-					for(int i=0;i<bindings.length();i++){
-						JSONObject solution = bindings.getJSONObject(i);
-						if(solution != null){
-							JSONObject rootVar = solution.getJSONObject(rootVariable);
-							if(rootVar != null){
-								String entityId = rootVar.getString("value");
-								if(entityId != null){
-									entities.add(entityId);
-								} //else missing value (very unlikely)
-							} //else missing binding for rootVar (very unlikely)
-						} //else solution in array is null (very unlikely) 
-					} //end for all solutions
-				} else {
-					entities = Collections.emptyList();
-				}
-			} else {
-				entities = Collections.emptyList();
-			}
-		} catch (JSONException e) {
-			//TODO: convert in better exception
-			throw new IOException("Unable to parse JSON Result Set for parsed query",e);
-		}
-		return entities;
-	}
-
-	@Override
-	public QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException{
-		long start = System.currentTimeMillis();
-		final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
-		String sparqlQuery = query.toSparqlConstruct();
-		long initEnd = System.currentTimeMillis();
-		log.info("  > InitTime: "+(initEnd-start));
-		log.info("  > SPARQL query:\n"+sparqlQuery);
-		InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, DEFAULT_RDF_CONTENT_TYPE);
-		long queryEnd = System.currentTimeMillis();
-		log.info("  > QueryTime: "+(queryEnd-initEnd));
-		if(in != null){
-			MGraph graph;
-	        TripleCollection rdfData = parser.parse(in, DEFAULT_RDF_CONTENT_TYPE);
-			if(rdfData instanceof MGraph){
-				graph = (MGraph) rdfData;
-			} else {
-				graph = new SimpleMGraph(rdfData);
-			}
-			long parseEnd = System.currentTimeMillis();
-			log.info("  > ParseTime: "+(parseEnd-queryEnd));
-			return new RdfQueryResultList(query, graph);
-		} else {
-			return null;
-		}
-	}
+    protected static final String DEFAULT_RDF_CONTENT_TYPE = SupportedFormat.N3;
+    protected static final String DEFAULT_SPARQL_RESULT_CONTENT_TYPE = SparqlEndpointUtils.SPARQL_RESULT_JSON;
+    @Override
+    public QueryResultList<String> findEntities(FieldQuery parsedQuery)  throws IOException {
+        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
+        String sparqlQuery = query.toSparqlSelect(false);
+        InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, DEFAULT_SPARQL_RESULT_CONTENT_TYPE);
+        //Move to util class!
+        final List<String> entities = extractEntitiesFromJsonResult(in,query.getRootVariableName());
+        return new QueryResultListImpl<String>(query, entities.iterator(),String.class);
+    }
+
+    /**
+     * Extracts the values of the Query. Also used by {@link VirtuosoSearcher}
+     * and {@link LarqSearcher}
+     * @param rootVariable the name of the variable to extract
+     * @param in the input stream with the data
+     * @return the extracted results
+     * @throws IOException if the input streams decides to explode
+     */
+    protected static List<String> extractEntitiesFromJsonResult(InputStream in, final String rootVariable) throws IOException {
+        final List<String> entities;
+        try {
+            JSONObject result = new JSONObject(IOUtils.toString(in));
+            JSONObject results = result.getJSONObject("results");
+            if(results != null){
+                JSONArray bindings = results.getJSONArray("bindings");
+                if(bindings != null && bindings.length()>0){
+                    entities = new ArrayList<String>(bindings.length());
+                    for(int i=0;i<bindings.length();i++){
+                        JSONObject solution = bindings.getJSONObject(i);
+                        if(solution != null){
+                            JSONObject rootVar = solution.getJSONObject(rootVariable);
+                            if(rootVar != null){
+                                String entityId = rootVar.getString("value");
+                                if(entityId != null){
+                                    entities.add(entityId);
+                                } //else missing value (very unlikely)
+                            } //else missing binding for rootVar (very unlikely)
+                        } //else solution in array is null (very unlikely)
+                    } //end for all solutions
+                } else {
+                    entities = Collections.emptyList();
+                }
+            } else {
+                entities = Collections.emptyList();
+            }
+        } catch (JSONException e) {
+            //TODO: convert in better exception
+            throw new IOException("Unable to parse JSON Result Set for parsed query",e);
+        }
+        return entities;
+    }
+
+    @Override
+    public QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException{
+        long start = System.currentTimeMillis();
+        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
+        String sparqlQuery = query.toSparqlConstruct();
+        long initEnd = System.currentTimeMillis();
+        log.info("  > InitTime: "+(initEnd-start));
+        log.info("  > SPARQL query:\n"+sparqlQuery);
+        InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, DEFAULT_RDF_CONTENT_TYPE);
+        long queryEnd = System.currentTimeMillis();
+        log.info("  > QueryTime: "+(queryEnd-initEnd));
+        if(in != null){
+            MGraph graph;
+            TripleCollection rdfData = parser.parse(in, DEFAULT_RDF_CONTENT_TYPE);
+            if(rdfData instanceof MGraph){
+                graph = (MGraph) rdfData;
+            } else {
+                graph = new SimpleMGraph(rdfData);
+            }
+            long parseEnd = System.currentTimeMillis();
+            log.info("  > ParseTime: "+(parseEnd-queryEnd));
+            return new RdfQueryResultList(query, graph);
+        } else {
+            return null;
+        }
+    }
 
 
 

Modified: incubator/stanbol/trunk/rick/site/linkedData/src/main/java/eu/iksproject/rick/site/linkedData/impl/VirtuosoSearcher.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/site/linkedData/src/main/java/eu/iksproject/rick/site/linkedData/impl/VirtuosoSearcher.java?rev=1044832&r1=1044831&r2=1044832&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/site/linkedData/src/main/java/eu/iksproject/rick/site/linkedData/impl/VirtuosoSearcher.java (original)
+++ incubator/stanbol/trunk/rick/site/linkedData/src/main/java/eu/iksproject/rick/site/linkedData/impl/VirtuosoSearcher.java Sun Dec 12 15:13:35 2010
@@ -25,56 +25,56 @@ import eu.iksproject.rick.servicesapi.qu
 import eu.iksproject.rick.servicesapi.site.EntitySearcher;
 
 @Component(
-		name="eu.iksproject.rick.site.VirtuosoSearcher",
-		factory="eu.iksproject.rick.site.VirtuosoSearcherFactory",
-		policy=ConfigurationPolicy.REQUIRE, //the queryUri and the SPARQL Endpoint are required
-		specVersion="1.1"
-		) 
+        name="eu.iksproject.rick.site.VirtuosoSearcher",
+        factory="eu.iksproject.rick.site.VirtuosoSearcherFactory",
+        policy=ConfigurationPolicy.REQUIRE, //the queryUri and the SPARQL Endpoint are required
+        specVersion="1.1"
+        )
 public class VirtuosoSearcher extends AbstractEntitySearcher implements EntitySearcher{
-	@Reference
+    @Reference
     protected Parser parser;
 
-	public VirtuosoSearcher() {
-		super(LoggerFactory.getLogger(VirtuosoSearcher.class));
-	}
+    public VirtuosoSearcher() {
+        super(LoggerFactory.getLogger(VirtuosoSearcher.class));
+    }
 
-	@Override
-	public QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException {
-		long start = System.currentTimeMillis();
-		final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
-		query.setEndpointType(EndpointTypeEnum.Virtuoso);
-		String sparqlQuery = query.toSparqlConstruct();
-		long initEnd = System.currentTimeMillis();
-		log.info("  > InitTime: "+(initEnd-start));
-		log.info("  > SPARQL query:\n"+sparqlQuery);
-		InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, SparqlSearcher.DEFAULT_RDF_CONTENT_TYPE);
-		long queryEnd = System.currentTimeMillis();
-		log.info("  > QueryTime: "+(queryEnd-initEnd));
-		if(in != null){
-			MGraph graph;
-	        TripleCollection rdfData = parser.parse(in, SparqlSearcher.DEFAULT_RDF_CONTENT_TYPE);
-			if(rdfData instanceof MGraph){
-				graph = (MGraph) rdfData;
-			} else {
-				graph = new SimpleMGraph(rdfData);
-			}
-			long parseEnd = System.currentTimeMillis();
-			log.info("  > ParseTime: "+(parseEnd-queryEnd));
-			return new RdfQueryResultList(query, graph);
-		} else {
-			return null;
-		}
-	}
+    @Override
+    public QueryResultList<Representation> find(FieldQuery parsedQuery) throws IOException {
+        long start = System.currentTimeMillis();
+        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
+        query.setEndpointType(EndpointTypeEnum.Virtuoso);
+        String sparqlQuery = query.toSparqlConstruct();
+        long initEnd = System.currentTimeMillis();
+        log.info("  > InitTime: "+(initEnd-start));
+        log.info("  > SPARQL query:\n"+sparqlQuery);
+        InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, SparqlSearcher.DEFAULT_RDF_CONTENT_TYPE);
+        long queryEnd = System.currentTimeMillis();
+        log.info("  > QueryTime: "+(queryEnd-initEnd));
+        if(in != null){
+            MGraph graph;
+            TripleCollection rdfData = parser.parse(in, SparqlSearcher.DEFAULT_RDF_CONTENT_TYPE);
+            if(rdfData instanceof MGraph){
+                graph = (MGraph) rdfData;
+            } else {
+                graph = new SimpleMGraph(rdfData);
+            }
+            long parseEnd = System.currentTimeMillis();
+            log.info("  > ParseTime: "+(parseEnd-queryEnd));
+            return new RdfQueryResultList(query, graph);
+        } else {
+            return null;
+        }
+    }
 
-	@Override
-	public QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
-		final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
-		query.setEndpointType(EndpointTypeEnum.Virtuoso);
-		String sparqlQuery = query.toSparqlSelect(false);
-		InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, SparqlSearcher.DEFAULT_SPARQL_RESULT_CONTENT_TYPE);
-		//Move to util class!
-		final List<String> entities = SparqlSearcher.extractEntitiesFromJsonResult(in,query.getRootVariableName());
-		return new QueryResultListImpl<String>(query, entities.iterator(),String.class);
-	}
+    @Override
+    public QueryResultList<String> findEntities(FieldQuery parsedQuery) throws IOException {
+        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
+        query.setEndpointType(EndpointTypeEnum.Virtuoso);
+        String sparqlQuery = query.toSparqlSelect(false);
+        InputStream in = SparqlEndpointUtils.sendSparqlRequest(getQueryUri(), sparqlQuery, SparqlSearcher.DEFAULT_SPARQL_RESULT_CONTENT_TYPE);
+        //Move to util class!
+        final List<String> entities = SparqlSearcher.extractEntitiesFromJsonResult(in,query.getRootVariableName());
+        return new QueryResultListImpl<String>(query, entities.iterator(),String.class);
+    }
 
 }

Modified: incubator/stanbol/trunk/rick/yard/clerezza/src/main/java/eu/iksproject/rick/yard/clerezza/impl/ClerezzaYard.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/yard/clerezza/src/main/java/eu/iksproject/rick/yard/clerezza/impl/ClerezzaYard.java?rev=1044832&r1=1044831&r2=1044832&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/yard/clerezza/src/main/java/eu/iksproject/rick/yard/clerezza/impl/ClerezzaYard.java (original)
+++ incubator/stanbol/trunk/rick/yard/clerezza/src/main/java/eu/iksproject/rick/yard/clerezza/impl/ClerezzaYard.java Sun Dec 12 15:13:35 2010
@@ -56,346 +56,346 @@ import eu.iksproject.rick.servicesapi.ya
  * Implementation of the Yard Interface based on a RDF Triple Store. This
  * Implementation uses Clerezza as RDF Framework. The actual Triple Store used
  * to store the data depends on the configuration of Clerezza.<p>
- * This implementation uses {@link LockableMGraph} interface for write locks 
+ * This implementation uses {@link LockableMGraph} interface for write locks
  * when updating the graph. SPARQL queries are not within a write lock.<p>
  *
  * @author Rupert Westenthaler
  *
  */
 @Component(
-		//name="eu.iksproject.rick.yard.clerezzaYard",
-		//factory="eu.iksproject.rick.yard.clerezzaYardFactory",
-		configurationFactory=true,
-		policy=ConfigurationPolicy.REQUIRE, //the ID is required!
-		specVersion="1.1",
-		metatype = true
-		)
+        //name="eu.iksproject.rick.yard.clerezzaYard",
+        //factory="eu.iksproject.rick.yard.clerezzaYardFactory",
+        configurationFactory=true,
+        policy=ConfigurationPolicy.REQUIRE, //the ID is required!
+        specVersion="1.1",
+        metatype = true
+        )
 @Service
 //@Properties(value={
-//		@Property(name=Yard.ID,value="rickYard"),
-//		@Property(name=Yard.NAME,value="Rick Yard"),
-//		@Property(name=Yard.DESCRIPTION,value="Default values for configuring the RickYard without editing")
+//        @Property(name=Yard.ID,value="rickYard"),
+//        @Property(name=Yard.NAME,value="Rick Yard"),
+//        @Property(name=Yard.DESCRIPTION,value="Default values for configuring the RickYard without editing")
 //})
 public class ClerezzaYard extends AbstractYard implements Yard {
-	Logger log = LoggerFactory.getLogger(ClerezzaYard.class);
-	public static final String YARD_URI_PREFIX = "urn:eu.iksproject:rick.yard:rdf.clerezza:";
-	public static final UriRef REPRESENTATION = new UriRef(RdfResourceEnum.Representation.getUri());
-	/**
-	 * This property is used to check if a URI in the graph represents a representation by
-	 * calling {@link TripleCollection#filter(org.apache.clerezza.rdf.core.NonLiteral, UriRef, Resource)}
-	 * with the reuqested ID as subject, this {@link UriRef} as property and
-	 * <code>null</code> as value.<p>
-	 * This is the easiest way to do that, because each representation MUST HAVE
-	 * a rick:label. If this is requirements is changed in future, than the code
-	 * using this property MUST BE changed accordingly!
-	 */
-	private static UriRef RICK_LABEL_URIREF = new UriRef(RdfResourceEnum.label.getUri());
-//	protected ComponentContext context;
-//	protected Dictionary<String,?> properties;
-	@Reference
-	private TcManager tcManager;
+    Logger log = LoggerFactory.getLogger(ClerezzaYard.class);
+    public static final String YARD_URI_PREFIX = "urn:eu.iksproject:rick.yard:rdf.clerezza:";
+    public static final UriRef REPRESENTATION = new UriRef(RdfResourceEnum.Representation.getUri());
+    /**
+     * This property is used to check if a URI in the graph represents a representation by
+     * calling {@link TripleCollection#filter(org.apache.clerezza.rdf.core.NonLiteral, UriRef, Resource)}
+     * with the reuqested ID as subject, this {@link UriRef} as property and
+     * <code>null</code> as value.<p>
+     * This is the easiest way to do that, because each representation MUST HAVE
+     * a rick:label. If this is requirements is changed in future, than the code
+     * using this property MUST BE changed accordingly!
+     */
+    private static UriRef RICK_LABEL_URIREF = new UriRef(RdfResourceEnum.label.getUri());
+//    protected ComponentContext context;
+//    protected Dictionary<String,?> properties;
+    @Reference
+    private TcManager tcManager;
     private UriRef yardGraphUri;
     private LockableMGraph graph;
-    
-	public ClerezzaYard() {
-		super();
-	}
-	public ClerezzaYard(String yardId) {
-		super();
-	}
-	@SuppressWarnings("unchecked")
-	@Activate
-	protected void activate(ComponentContext context) throws ConfigurationException {
-		log.info("in "+ClerezzaYard.class+" activate with context "+context);
-		if(context == null || context.getProperties() == null){
-			throw new IllegalStateException("No valid"+ComponentContext.class+" parsed in activate!");
-		}
-		activate(new DefaultYardConfig(context.getProperties()));
-	}
-	protected final void activate(YardConfig config) throws ConfigurationException,IllegalArgumentException {
-		super.activate(RdfValueFactory.getInstance(), SparqlFieldQueryFactory.getInstance(), config);
-		this.yardGraphUri = new UriRef(YARD_URI_PREFIX+config.getId());
-		try {
+
+    public ClerezzaYard() {
+        super();
+    }
+    public ClerezzaYard(String yardId) {
+        super();
+    }
+    @SuppressWarnings("unchecked")
+    @Activate
+    protected void activate(ComponentContext context) throws ConfigurationException {
+        log.info("in "+ClerezzaYard.class+" activate with context "+context);
+        if(context == null || context.getProperties() == null){
+            throw new IllegalStateException("No valid"+ComponentContext.class+" parsed in activate!");
+        }
+        activate(new DefaultYardConfig(context.getProperties()));
+    }
+    protected final void activate(YardConfig config) throws ConfigurationException,IllegalArgumentException {
+        super.activate(RdfValueFactory.getInstance(), SparqlFieldQueryFactory.getInstance(), config);
+        this.yardGraphUri = new UriRef(YARD_URI_PREFIX+config.getId());
+        try {
             this.graph = tcManager.getMGraph(yardGraphUri);
             log.info("  ... (re)use existing Graph "+yardGraphUri+" for Yard "+config.getName());
         } catch (NoSuchEntityException e) {
-        	log.info("   ... create new Graph "+yardGraphUri+" for Yard "+config.getName()+"!");
+            log.info("   ... create new Graph "+yardGraphUri+" for Yard "+config.getName()+"!");
             this.graph =  tcManager.createMGraph(yardGraphUri);
         }
 
-	}
-	@Deactivate
-	protected void deactivate(ComponentContext context) {
-		log.info("in "+ClerezzaYard.class.getSimpleName()+" deactivate with context "+context);
-		this.yardGraphUri = null;
-		this.graph = null;
-		super.deactivate();
-	}
-	/**
-	 * Getter for the URI used for the named graph. The returned value is
-	 * {@link #YARD_URI_PREFIX}+{@link #getId()}.
-	 * @return the URI used for the RDF graph that stores all the data of this
-	 * yard.
-	 */
-	public String getYardGraphUri(){
-		return yardGraphUri.getUnicodeString();
-	}
+    }
+    @Deactivate
+    protected void deactivate(ComponentContext context) {
+        log.info("in "+ClerezzaYard.class.getSimpleName()+" deactivate with context "+context);
+        this.yardGraphUri = null;
+        this.graph = null;
+        super.deactivate();
+    }
+    /**
+     * Getter for the URI used for the named graph. The returned value is
+     * {@link #YARD_URI_PREFIX}+{@link #getId()}.
+     * @return the URI used for the RDF graph that stores all the data of this
+     * yard.
+     */
+    public String getYardGraphUri(){
+        return yardGraphUri.getUnicodeString();
+    }
+
+    @Override
+    public Representation getRepresentation(String id) {
+        if(id == null){
+            return null;
+        }
+        return getRepresentation(new UriRef(id),true);
+    }
+    /**
+     * Internally used to create Representations for URIs
+     * @param uri the uri
+     * @param check if <code>false</code> than there is no check if the URI
+     *     refers to a Resource in the graph that is of type {@link #REPRESENTATION}
+     * @return the Representation
+     */
+    protected Representation getRepresentation(UriRef uri, boolean check) {
+        if(!check || graph.filter(uri, RICK_LABEL_URIREF, null).hasNext()){
+            /*
+             * We need to use an own graph for the Representation, because
+             * changes to the Representation should not be reflected in the
+             * Yard until a store() or update().
+             * Currently the GraphNode.getNodeContext() functionality is used
+             * to calculate the graph included for the Representation.
+             */
+            GraphNode node = new GraphNode(uri, graph);
+            //create a changeable graph for the representation, because
+            //node.getNodeContext returns an immutable Graph!
+            MGraph nodeGraph = new SimpleMGraph(node.getNodeContext());
+            return ((RdfValueFactory)valueFactory).createRdfRepresentation(uri, nodeGraph);
+        } else {
+            return null; //not found
+        }
+    }
 
-	@Override
-	public Representation getRepresentation(String id) {
-		if(id == null){
-			return null;
-		}
-		return getRepresentation(new UriRef(id),true);
-	}
-	/**
-	 * Internally used to create Representations for URIs
-	 * @param uri the uri
-	 * @param check if <code>false</code> than there is no check if the URI
-	 *     refers to a Resource in the graph that is of type {@link #REPRESENTATION}
-	 * @return the Representation
-	 */
-	protected Representation getRepresentation(UriRef uri, boolean check) {
-		if(!check || graph.filter(uri, RICK_LABEL_URIREF, null).hasNext()){
-			/*
-			 * We need to use an own graph for the Representation, because
-			 * changes to the Representation should not be reflected in the
-			 * Yard until a store() or update().
-			 * Currently the GraphNode.getNodeContext() functionality is used
-			 * to calculate the graph included for the Representation.
-			 */
-			GraphNode node = new GraphNode(uri, graph);
-			//create a changeable graph for the representation, because
-			//node.getNodeContext returns an immutable Graph!
-			MGraph nodeGraph = new SimpleMGraph(node.getNodeContext());
-			return ((RdfValueFactory)valueFactory).createRdfRepresentation(uri, nodeGraph);
-		} else {
-			return null; //not found
-		}
-	}
-	
-	@Override
-	public boolean isRepresentation(String id) {
-		return id!=null?graph.filter(new UriRef(id), RICK_LABEL_URIREF , null).hasNext():null;
-	}
+    @Override
+    public boolean isRepresentation(String id) {
+        return id!=null?graph.filter(new UriRef(id), RICK_LABEL_URIREF , null).hasNext():null;
+    }
 
-	@Override
-	public void remove(String id) throws IllegalArgumentException {
-		if(id == null) return;
-		UriRef resource = new UriRef(id);
-		Lock writeLock = graph.getLock().writeLock();
-		writeLock.lock();
-		try {
-			if(graph.filter(resource, RDF.type, REPRESENTATION).hasNext()){
-				GraphNode node = new GraphNode(resource, graph);
-				/*
-				 * Currently the "context" of the Clerezza GraphNode implementation
-				 * is used for CRUD operations on Representations.
-				 * This includes incoming and outgoing relations the resource and
-				 * recursively bNodes.
-				 */
-				node.deleteNodeContext();
-			} //else not found  -> nothing to do
-		}finally {
-			writeLock.unlock();
-		}
-	}
-	@Override
-	public void remove(Iterable<String> ids) throws IllegalArgumentException, YardException {
-		if(ids == null){
-			throw new IllegalArgumentException("The parsed Iterable over the IDs to remove MUST NOT be NULL!");
-		}
-		for(String id : ids){
-			remove(id);
-		}
-	}
-	@Override
-	public Representation store(Representation representation) throws IllegalArgumentException, YardException {
-		return store(representation,true,true);
-	}
-	@Override
-	public Iterable<Representation> store(Iterable<Representation> representations) throws IllegalArgumentException, YardException {
-		if(representations == null){
-			throw new IllegalArgumentException("The parsed Iterable over the Representations to store MUST NOT be NULL!");
-		}
-		return store(representations, true);
-	}
-	@Override
-	public Representation update(Representation representation) throws IllegalArgumentException, YardException {
-		return store(representation,false,true);
-	}
-	@Override
-	public Iterable<Representation> update(Iterable<Representation> representations) throws YardException, IllegalArgumentException {
-		if(representations == null){
-			throw new IllegalArgumentException("The parsed Iterable over the Representations to update MUST NOT be NULL!");
-		}
-		return store(representations,false);
-	}
-	protected final Iterable<Representation> store(Iterable<Representation> representations,boolean allowCreate) throws IllegalArgumentException, YardException{
-		ArrayList<Representation> added = new ArrayList<Representation>();
-		for(Representation representation : representations){
-			added.add(store(representation,allowCreate,false));
-		}
-		return added;
-	}
-	protected final Representation store(Representation representation,boolean allowCreate,boolean canNotCreateIsError) throws IllegalArgumentException, YardException{
-		log.info("store Representation "+representation.getId());
-//		log.info("  > rick size: "+graph.size());
-		if(representation == null) return null;
-		if(isRepresentation(representation.getId())){
-//			log.info("  > remove previous version");
-			remove(representation.getId());
-//			log.info("  > rick size: "+graph.size());
-		} else if(!allowCreate){
-			if(canNotCreateIsError) {
-				throw new YardException("Parsed Representation "+representation.getId()+" in not managed by this Yard "+getName()+"(id="+getId()+")");
-			} else {
-				return null;
-			}
-		}
-		//get the graph for the Representation and add it to the store
-		RdfRepresentation toAdd = ((RdfValueFactory)valueFactory).toRdfRepresentation(representation);
-//		log.info("  > add "+toAdd.size()+" triples to Yard "+getId());
-		Lock writeLock = graph.getLock().writeLock();
-		writeLock.lock();
-		try {
-			graph.addAll(toAdd.getRdfGraph());
-		} finally {
-			writeLock.unlock();
-		}
-//		log.info("  > currently "+graph.size()+" triples in Yard "+getId());
-		return toAdd;
-	}
-	
-	@Override
-	public QueryResultList<String> findReferences(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
-		if(parsedQuery == null){
-			throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
-		}
-		final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
-		int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
-		SelectQuery sparqlQuery;
-		String sparqlQueryString = SparqlQueryUtils.createSparqlSelectQuery(query, false,limit,EndpointTypeEnum.Standard);
-		try {
-			sparqlQuery = (SelectQuery)QueryParser.getInstance().parse(sparqlQueryString);
-		} catch (ParseException e) {
-			log.error("ParseException for SPARQL Query in findRepresentation");
-			log.error("FieldQuery: "+query);
-			log.error("SPARQL Query: "+sparqlQueryString);
-			throw new YardException("Unable to parse SPARQL query generated for the parse FieldQuery",e);
-		} catch (ClassCastException e){
-			log.error("ClassCastExeption because parsed SPARQL Query is not of Type "+SelectQuery.class);
-			log.error("FieldQuery: "+query);
-			log.error("SPARQL Query: "+sparqlQueryString);
-			throw new YardException("Unable to parse SPARQL SELECT query generated for the parse FieldQuery",e);
-		}
-		final ResultSet result = tcManager.executeSparqlQuery((SelectQuery)sparqlQuery, graph);
-		//A little bit complex construct ...
-		// first we use the adaptingIterator to convert reseource to string
-		// to get the resources we have to retrieve the root-variable of the
-		// Iterator<SolutionMapping> provided by the ResultSet of the SPARQL query
-		Iterator<String> representationIdIterator = new AdaptingIterator<Resource, String>(
-				new Iterator<Resource>() {
-					@Override public void remove() { result.remove(); }
-					@Override public Resource next() {
-						return result.next().get(query.getRootVariableName()); }
-					@Override public boolean hasNext() { return result.hasNext(); }
-				}, 
-				new Resource2StringAdapter<Resource>(), String.class);
-		return new QueryResultListImpl<String>(query,representationIdIterator,String.class); 
-	}
-	@Override
-	public QueryResultList<Representation> findRepresentation(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
-		if(parsedQuery == null){
-			throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
-		}
-		final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
-		int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
-		SelectQuery sparqlQuery;
-		String sparqlQueryString = SparqlQueryUtils.createSparqlSelectQuery(query, false,limit,EndpointTypeEnum.Standard);
-		try {
-			sparqlQuery = (SelectQuery)QueryParser.getInstance().parse(sparqlQueryString);
-		} catch (ParseException e) {
-			log.error("ParseException for SPARQL Query in findRepresentation");
-			log.error("FieldQuery: "+query);
-			log.error("SPARQL Query: "+sparqlQueryString);
-			throw new YardException("Unable to parse SPARQL query generated for the parse FieldQuery",e);
-		} catch (ClassCastException e){
-			log.error("ClassCastExeption because parsed SPARQL Query is not of Type "+SelectQuery.class);
-			log.error("FieldQuery: "+query);
-			log.error("SPARQL Query: "+sparqlQueryString);
-			throw new YardException("Unable to parse SPARQL SELECT query generated for the parse FieldQuery",e);
-		}
-		final ResultSet result = tcManager.executeSparqlQuery((SelectQuery)sparqlQuery, graph);
-		//Note: An other possibility would be to first iterate over all results and add it to
-		//      a list and create this Iterator than based on the List. This would
-		//      be the preferenced way if changes in the graph could affect the
-		//     Iteration over the SPARQL query results.
-		Iterator<Representation> representationIterator = new AdaptingIterator<SolutionMapping, Representation>(
-				result, new AdaptingIterator.Adapter<SolutionMapping, Representation>() {
-					/**
-					 * Adapter that gets the rootVariable of the Query (selecting the ID)
-					 * and creates a Representation for it.
-					 * @param solution a solution of the query
-					 * @param type the type (no generics here)
-					 * @return the representation or <code>null</code> if result is
-					 * not an UriRef or there is no Representation for the result.
-					 */
-					@Override
-					public Representation adapt(SolutionMapping solution, Class<Representation> type) {
-						Resource resource = solution.get(query.getRootVariableName());
-						if(resource != null && resource instanceof UriRef){
-							try {
-								return getRepresentation((UriRef)resource,false);
-							} catch (IllegalArgumentException e) {
-								log.warn("Unable to create Representation for ID "+resource+"! -> ignore query result");
-								return null;
-							}
-						} else {
-							return null;
-						}
-					}
-				}, Representation.class);
-		//NOTE: currently this list iterates in the constructor over all elements
-		//      of the Iterator. This means, that all the representations are
-		//      created before the method returns.
-		return new QueryResultListImpl<Representation>(query,representationIterator,Representation.class); 
-	}
-	@Override
-	public QueryResultList<Representation> find(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
-		if(parsedQuery == null){
-			throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
-		}
-		final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
-		int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
-		Query sparqlQuery;
-		//NOTE(s): 
-		// - parse RdfResourceEnum.representationType as additional field, because
-		//   this info is needed to correctly init the Representations
-		// - use the endpoint type standard, because we do not know what type of
-		//   SPARQL implementation is configured for Clerezza via OSGI
-		String sparqlQueryString = SparqlQueryUtils.createSparqlConstructQuery(query, limit,EndpointTypeEnum.Standard,RdfResourceEnum.signType.getUri());
-		try {
-			sparqlQuery = QueryParser.getInstance().parse(sparqlQueryString);
-		} catch (ParseException e) {
-			log.error("ParseException for SPARQL Query in findRepresentation");
-			log.error("FieldQuery: "+query);
-			log.error("SPARQL Query: "+sparqlQueryString);
-			throw new YardException("Unable to parse SPARQL query generated for the parse FieldQuery",e);
-		}
-		Object resultObject = tcManager.executeSparqlQuery(sparqlQuery, graph);
-		final MGraph resultGraph;
-		if(resultObject instanceof MGraph){
-			resultGraph = (MGraph)resultObject;
-		} else if(resultObject instanceof Graph){
-			resultGraph = new SimpleMGraph();
-			resultGraph.addAll((Graph)resultObject);
-		} else {
-			log.error("Unable to create "+MGraph.class+" instance for query reults of type "+resultObject.getClass()+" (this indicates that the used SPARQL Query was not of type CONSTRUCT)");
-			log.error("FieldQuery: "+query);
-			log.error("SPARQL Query: "+sparqlQueryString);
-			throw new YardException("Unable to process results of Query");
-		}
-		return new RdfQueryResultList(query, resultGraph);
-	}
+    @Override
+    public void remove(String id) throws IllegalArgumentException {
+        if(id == null) return;
+        UriRef resource = new UriRef(id);
+        Lock writeLock = graph.getLock().writeLock();
+        writeLock.lock();
+        try {
+            if(graph.filter(resource, RDF.type, REPRESENTATION).hasNext()){
+                GraphNode node = new GraphNode(resource, graph);
+                /*
+                 * Currently the "context" of the Clerezza GraphNode implementation
+                 * is used for CRUD operations on Representations.
+                 * This includes incoming and outgoing relations the resource and
+                 * recursively bNodes.
+                 */
+                node.deleteNodeContext();
+            } //else not found  -> nothing to do
+        }finally {
+            writeLock.unlock();
+        }
+    }
+    @Override
+    public void remove(Iterable<String> ids) throws IllegalArgumentException, YardException {
+        if(ids == null){
+            throw new IllegalArgumentException("The parsed Iterable over the IDs to remove MUST NOT be NULL!");
+        }
+        for(String id : ids){
+            remove(id);
+        }
+    }
+    @Override
+    public Representation store(Representation representation) throws IllegalArgumentException, YardException {
+        return store(representation,true,true);
+    }
+    @Override
+    public Iterable<Representation> store(Iterable<Representation> representations) throws IllegalArgumentException, YardException {
+        if(representations == null){
+            throw new IllegalArgumentException("The parsed Iterable over the Representations to store MUST NOT be NULL!");
+        }
+        return store(representations, true);
+    }
+    @Override
+    public Representation update(Representation representation) throws IllegalArgumentException, YardException {
+        return store(representation,false,true);
+    }
+    @Override
+    public Iterable<Representation> update(Iterable<Representation> representations) throws YardException, IllegalArgumentException {
+        if(representations == null){
+            throw new IllegalArgumentException("The parsed Iterable over the Representations to update MUST NOT be NULL!");
+        }
+        return store(representations,false);
+    }
+    protected final Iterable<Representation> store(Iterable<Representation> representations,boolean allowCreate) throws IllegalArgumentException, YardException{
+        ArrayList<Representation> added = new ArrayList<Representation>();
+        for(Representation representation : representations){
+            added.add(store(representation,allowCreate,false));
+        }
+        return added;
+    }
+    protected final Representation store(Representation representation,boolean allowCreate,boolean canNotCreateIsError) throws IllegalArgumentException, YardException{
+        log.info("store Representation "+representation.getId());
+//        log.info("  > rick size: "+graph.size());
+        if(representation == null) return null;
+        if(isRepresentation(representation.getId())){
+//            log.info("  > remove previous version");
+            remove(representation.getId());
+//            log.info("  > rick size: "+graph.size());
+        } else if(!allowCreate){
+            if(canNotCreateIsError) {
+                throw new YardException("Parsed Representation "+representation.getId()+" in not managed by this Yard "+getName()+"(id="+getId()+")");
+            } else {
+                return null;
+            }
+        }
+        //get the graph for the Representation and add it to the store
+        RdfRepresentation toAdd = ((RdfValueFactory)valueFactory).toRdfRepresentation(representation);
+//        log.info("  > add "+toAdd.size()+" triples to Yard "+getId());
+        Lock writeLock = graph.getLock().writeLock();
+        writeLock.lock();
+        try {
+            graph.addAll(toAdd.getRdfGraph());
+        } finally {
+            writeLock.unlock();
+        }
+//        log.info("  > currently "+graph.size()+" triples in Yard "+getId());
+        return toAdd;
+    }
+
+    @Override
+    public QueryResultList<String> findReferences(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
+        if(parsedQuery == null){
+            throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
+        }
+        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
+        int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
+        SelectQuery sparqlQuery;
+        String sparqlQueryString = SparqlQueryUtils.createSparqlSelectQuery(query, false,limit,EndpointTypeEnum.Standard);
+        try {
+            sparqlQuery = (SelectQuery)QueryParser.getInstance().parse(sparqlQueryString);
+        } catch (ParseException e) {
+            log.error("ParseException for SPARQL Query in findRepresentation");
+            log.error("FieldQuery: "+query);
+            log.error("SPARQL Query: "+sparqlQueryString);
+            throw new YardException("Unable to parse SPARQL query generated for the parse FieldQuery",e);
+        } catch (ClassCastException e){
+            log.error("ClassCastExeption because parsed SPARQL Query is not of Type "+SelectQuery.class);
+            log.error("FieldQuery: "+query);
+            log.error("SPARQL Query: "+sparqlQueryString);
+            throw new YardException("Unable to parse SPARQL SELECT query generated for the parse FieldQuery",e);
+        }
+        final ResultSet result = tcManager.executeSparqlQuery((SelectQuery)sparqlQuery, graph);
+        //A little bit complex construct ...
+        // first we use the adaptingIterator to convert reseource to string
+        // to get the resources we have to retrieve the root-variable of the
+        // Iterator<SolutionMapping> provided by the ResultSet of the SPARQL query
+        Iterator<String> representationIdIterator = new AdaptingIterator<Resource, String>(
+                new Iterator<Resource>() {
+                    @Override public void remove() { result.remove(); }
+                    @Override public Resource next() {
+                        return result.next().get(query.getRootVariableName()); }
+                    @Override public boolean hasNext() { return result.hasNext(); }
+                },
+                new Resource2StringAdapter<Resource>(), String.class);
+        return new QueryResultListImpl<String>(query,representationIdIterator,String.class);
+    }
+    @Override
+    public QueryResultList<Representation> findRepresentation(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
+        if(parsedQuery == null){
+            throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
+        }
+        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
+        int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
+        SelectQuery sparqlQuery;
+        String sparqlQueryString = SparqlQueryUtils.createSparqlSelectQuery(query, false,limit,EndpointTypeEnum.Standard);
+        try {
+            sparqlQuery = (SelectQuery)QueryParser.getInstance().parse(sparqlQueryString);
+        } catch (ParseException e) {
+            log.error("ParseException for SPARQL Query in findRepresentation");
+            log.error("FieldQuery: "+query);
+            log.error("SPARQL Query: "+sparqlQueryString);
+            throw new YardException("Unable to parse SPARQL query generated for the parse FieldQuery",e);
+        } catch (ClassCastException e){
+            log.error("ClassCastExeption because parsed SPARQL Query is not of Type "+SelectQuery.class);
+            log.error("FieldQuery: "+query);
+            log.error("SPARQL Query: "+sparqlQueryString);
+            throw new YardException("Unable to parse SPARQL SELECT query generated for the parse FieldQuery",e);
+        }
+        final ResultSet result = tcManager.executeSparqlQuery((SelectQuery)sparqlQuery, graph);
+        //Note: An other possibility would be to first iterate over all results and add it to
+        //      a list and create this Iterator than based on the List. This would
+        //      be the preferenced way if changes in the graph could affect the
+        //     Iteration over the SPARQL query results.
+        Iterator<Representation> representationIterator = new AdaptingIterator<SolutionMapping, Representation>(
+                result, new AdaptingIterator.Adapter<SolutionMapping, Representation>() {
+                    /**
+                     * Adapter that gets the rootVariable of the Query (selecting the ID)
+                     * and creates a Representation for it.
+                     * @param solution a solution of the query
+                     * @param type the type (no generics here)
+                     * @return the representation or <code>null</code> if result is
+                     * not an UriRef or there is no Representation for the result.
+                     */
+                    @Override
+                    public Representation adapt(SolutionMapping solution, Class<Representation> type) {
+                        Resource resource = solution.get(query.getRootVariableName());
+                        if(resource != null && resource instanceof UriRef){
+                            try {
+                                return getRepresentation((UriRef)resource,false);
+                            } catch (IllegalArgumentException e) {
+                                log.warn("Unable to create Representation for ID "+resource+"! -> ignore query result");
+                                return null;
+                            }
+                        } else {
+                            return null;
+                        }
+                    }
+                }, Representation.class);
+        //NOTE: currently this list iterates in the constructor over all elements
+        //      of the Iterator. This means, that all the representations are
+        //      created before the method returns.
+        return new QueryResultListImpl<Representation>(query,representationIterator,Representation.class);
+    }
+    @Override
+    public QueryResultList<Representation> find(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
+        if(parsedQuery == null){
+            throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
+        }
+        final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
+        int limit = QueryUtils.getLimit(query, config.getDefaultQueryResultNumber(), config.getMaxQueryResultNumber());
+        Query sparqlQuery;
+        //NOTE(s):
+        // - parse RdfResourceEnum.representationType as additional field, because
+        //   this info is needed to correctly init the Representations
+        // - use the endpoint type standard, because we do not know what type of
+        //   SPARQL implementation is configured for Clerezza via OSGI
+        String sparqlQueryString = SparqlQueryUtils.createSparqlConstructQuery(query, limit,EndpointTypeEnum.Standard,RdfResourceEnum.signType.getUri());
+        try {
+            sparqlQuery = QueryParser.getInstance().parse(sparqlQueryString);
+        } catch (ParseException e) {
+            log.error("ParseException for SPARQL Query in findRepresentation");
+            log.error("FieldQuery: "+query);
+            log.error("SPARQL Query: "+sparqlQueryString);
+            throw new YardException("Unable to parse SPARQL query generated for the parse FieldQuery",e);
+        }
+        Object resultObject = tcManager.executeSparqlQuery(sparqlQuery, graph);
+        final MGraph resultGraph;
+        if(resultObject instanceof MGraph){
+            resultGraph = (MGraph)resultObject;
+        } else if(resultObject instanceof Graph){
+            resultGraph = new SimpleMGraph();
+            resultGraph.addAll((Graph)resultObject);
+        } else {
+            log.error("Unable to create "+MGraph.class+" instance for query reults of type "+resultObject.getClass()+" (this indicates that the used SPARQL Query was not of type CONSTRUCT)");
+            log.error("FieldQuery: "+query);
+            log.error("SPARQL Query: "+sparqlQueryString);
+            throw new YardException("Unable to process results of Query");
+        }
+        return new RdfQueryResultList(query, resultGraph);
+    }
 }

Modified: incubator/stanbol/trunk/rick/yard/solr/src/main/java/eu/iksproject/rick/yard/solr/defaults/IndexDataTypeEnum.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/yard/solr/src/main/java/eu/iksproject/rick/yard/solr/defaults/IndexDataTypeEnum.java?rev=1044832&r1=1044831&r2=1044832&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/yard/solr/src/main/java/eu/iksproject/rick/yard/solr/defaults/IndexDataTypeEnum.java (original)
+++ incubator/stanbol/trunk/rick/yard/solr/src/main/java/eu/iksproject/rick/yard/solr/defaults/IndexDataTypeEnum.java Sun Dec 12 15:13:35 2010
@@ -20,163 +20,163 @@ import eu.iksproject.rick.yard.solr.mode
  * Holds the default configuration for <ul>
  * <li> {@link IndexDataType}s
  * <li> Default mapping of {@link IndexDataType}s to Java Objects
- * <li> Prefixes/Suffixes used to mark {@link IndexDataType}s in 
+ * <li> Prefixes/Suffixes used to mark {@link IndexDataType}s in
  *      SolrDocument fields
  * </ul>
  * This Enumeration may be replaced later on by a more flexible way to configure
  * such things.
- * 
+ *
  * @author Rupert Westenthaler
  *
  */
 public enum IndexDataTypeEnum {
-	BOOLEAN(NamespaceEnum.xsd+"boolean","bool",Boolean.class),
-//	BYTE("byt",Byte.class),
-	INT(NamespaceEnum.xsd+"integer","int",Integer.class),
-	LONG(NamespaceEnum.xsd+"long","lon",Long.class),
-	FLOAT(NamespaceEnum.xsd+"float","flo",Float.class),
-	DOUBLE(NamespaceEnum.xsd+"double","dou",Double.class),
-	REF(RdfResourceEnum.ReferenceDataType.getUri(),"ref",Reference.class),
-//	URI(NamespaceEnum.xsd+"anyURI","uri",URI.class), //currently URIs are modelled as REF
-	//TODO: DATE & DUR to be removed. The plan is to add explicit support for ranged queries over time spans/points!
-	DATE(NamespaceEnum.xsd+"dateTime","cal",Date.class),
-	DUR(NamespaceEnum.xsd+"duration","dur",Duration.class),  
-	TXT(RdfResourceEnum.TextDataType.getUri(),null,Text.class), //no type prefix, but typically language prefixes
-	STR(NamespaceEnum.xsd+"string","str",String.class), //string values (not used for language)
-	ID(NamespaceEnum.xsd+"id","id",UUID.class),
-	;
-	private IndexDataType indexType;
-	private Class<?> javaType;
-	private String prefix;
-	private String suffix;
-	private IndexDataTypeEnum(String name,String prefix,Class<?> type) {
-		this(name,prefix,null,type);
-	}
-	private IndexDataTypeEnum(String name,String prefix,String suffix, Class<?> type) {
-		this.indexType = new IndexDataType(name);
-		this.prefix = prefix;
-		this.suffix = suffix;
-		this.javaType = type;
-	}
-	/**
-	 * The prefix to be used for index fields of that type
-	 * @return the prefix
-	 */
-	public String getPrefix() {
-		return prefix;
-	}
-	/**
-	 * The suffix to be used for index fields of that type
-	 * @return
-	 */
-	public String getSuffix(){
-		return suffix;
-	}
-	/**
-	 * The index type
-	 * @return the indexType
-	 */
-	public IndexDataType getIndexType(){
-		return indexType;
-	}
-	/**
-	 * The java type
-	 * @return the java class for the index type
-	 */
-	public final Class<?> getJavaType() {
-		return javaType;
-	}
-	
-	/*--------------------------------------------------------------------------
-	 * Code that reads the config and inits lookup tables (also checks config)
-	 * --------------------------------------------------------------------------
-	 */
-	
-	private static Map<Class<?>, IndexDataTypeEnum> javaTypeMap;
-	private static Map<IndexDataType, IndexDataTypeEnum> indexTypeMap;
-	private static Map<List<String>,IndexDataTypeEnum> prefixSuffixMap;
-	private static Map<String,IndexDataTypeEnum> uriMap;
-	static {
-		/*
-		 * This inits the Mappings and also validates the configuration provided
-		 * by the Enumeration! 
-		 */
-		Map<Class<?>, IndexDataTypeEnum> jtm = new HashMap<Class<?>, IndexDataTypeEnum>();
-		Map<IndexDataType, IndexDataTypeEnum> itm = new HashMap<IndexDataType, IndexDataTypeEnum>();
-		Map<List<String>, IndexDataTypeEnum> psm = new HashMap<List<String>, IndexDataTypeEnum>();
-		Map<String,IndexDataTypeEnum> um = new HashMap<String, IndexDataTypeEnum>();
-		for(IndexDataTypeEnum dt : IndexDataTypeEnum.values()){
-			if(jtm.containsKey(dt.javaType)){
-				throw new IllegalStateException(String.format("Found multiple IndexTypes %s and %s for Class %s! Wrong Data provided by %s",
-						dt.indexType,jtm.get(dt.javaType).indexType,dt.javaType,IndexDataTypeEnum.class));
-			} else {
-				jtm.put(dt.javaType, dt);
-			}
-			if(itm.containsKey(dt.indexType)){
-				throw new IllegalStateException(String.format("Found multiple Entries with IndexType %s! Wrong Data provided by %s",
-						dt.indexType,IndexDataTypeEnum.class));
-			} else {
-				itm.put(dt.indexType, dt);
-			}
-			//NOTE: Do not use Arrays.asList(..) directly, because it does not
-			//      implement equals and hashCode!
-			List<String> ps = new ArrayList<String>(2);
-			ps.add(dt.prefix);
-			ps.add(dt.suffix);
-			psm.put(ps, dt);
-			if(um.containsKey(dt.getIndexType().getId())){
-				throw new IllegalStateException(String.format("Found multiple Entries with the same data type URI %s! Uri used by %s and %s!",
-						dt.getIndexType().getId(),dt.name(),um.get(dt.getIndexType().getName()).name()));
-			} else {
-				um.put(dt.getIndexType().getId(), dt);
-			}
-		}
-		javaTypeMap = Collections.unmodifiableMap(jtm);
-		indexTypeMap = Collections.unmodifiableMap(itm);
-		prefixSuffixMap = Collections.unmodifiableMap(psm);
-		uriMap = Collections.unmodifiableMap(um);
-	}
-	/**
-	 * Lookup table for the IndexDataTypeEnum based on the java type
-	 * @param type the java type
-	 * @return the IndexDataTypeEnum for the parsed type or <code>null</code> if
-	 * no IndexDataTypeEnum is configured for the parsed type.
-	 */
-	public static IndexDataTypeEnum forJavaType(Class<?> type){
-		return javaTypeMap.get(type);
-	}
-	/**
-	 * Lookup table for the IndexDataTypeEnum based on the IndexType.
-	 * @param indexType the indexType
-	 * @return the IndexDataTypeEnum for the parsed IndexTyep or <code>null</code>
-	 * if no IndexDataTypeEnum is configured for the parsed IndexType.
-	 */
-	public static IndexDataTypeEnum forIndexType(IndexDataType indexType){
-		return indexTypeMap.get(indexType);
-	}
-	/**
-	 * Lookup table for the IndexDataTypeEnum based on the prefix and suffix
-	 * @param prefix the prefix (might be <code>null</code>)
-	 * @param suffix the suffix ( (might be <code>null</code>)
-	 * @return the IndexDataTypeEnum for the parsed prefix and suffix or 
-	 * <code>null</code> if no IndexDataTypeEnum is configured for the parsed 
-	 * parameter. 
-	 */
-	public static IndexDataTypeEnum forPrefixSuffix(String prefix,String suffix){
-		List<String> ps = new ArrayList<String>(2);
-		ps.add(prefix);
-		ps.add(suffix);
-		return prefixSuffixMap.get(ps);
-	}
-	/**
-	 * Lookup table for the IndexDataTypeEnum based on the data type uri
-	 * as stored in the {@link IndexDataType#getName()} property.
-	 * @param uri the uri of the dataType
-	 * @return the IndexDataTypeEnum for the parsed uri or  <code>null</code> if 
-	 * no IndexDataTypeEnum is configured for the parsed parameter. 
-	 */
-	public static IndexDataTypeEnum forUri(String uri){
-		return uriMap.get(uri);
-	}
+    BOOLEAN(NamespaceEnum.xsd+"boolean","bool",Boolean.class),
+//    BYTE("byt",Byte.class),
+    INT(NamespaceEnum.xsd+"integer","int",Integer.class),
+    LONG(NamespaceEnum.xsd+"long","lon",Long.class),
+    FLOAT(NamespaceEnum.xsd+"float","flo",Float.class),
+    DOUBLE(NamespaceEnum.xsd+"double","dou",Double.class),
+    REF(RdfResourceEnum.ReferenceDataType.getUri(),"ref",Reference.class),
+//    URI(NamespaceEnum.xsd+"anyURI","uri",URI.class), //currently URIs are modelled as REF
+    //TODO: DATE & DUR to be removed. The plan is to add explicit support for ranged queries over time spans/points!
+    DATE(NamespaceEnum.xsd+"dateTime","cal",Date.class),
+    DUR(NamespaceEnum.xsd+"duration","dur",Duration.class),
+    TXT(RdfResourceEnum.TextDataType.getUri(),null,Text.class), //no type prefix, but typically language prefixes
+    STR(NamespaceEnum.xsd+"string","str",String.class), //string values (not used for language)
+    ID(NamespaceEnum.xsd+"id","id",UUID.class),
+    ;
+    private IndexDataType indexType;
+    private Class<?> javaType;
+    private String prefix;
+    private String suffix;
+    private IndexDataTypeEnum(String name,String prefix,Class<?> type) {
+        this(name,prefix,null,type);
+    }
+    private IndexDataTypeEnum(String name,String prefix,String suffix, Class<?> type) {
+        this.indexType = new IndexDataType(name);
+        this.prefix = prefix;
+        this.suffix = suffix;
+        this.javaType = type;
+    }
+    /**
+     * The prefix to be used for index fields of that type
+     * @return the prefix
+     */
+    public String getPrefix() {
+        return prefix;
+    }
+    /**
+     * The suffix to be used for index fields of that type
+     * @return
+     */
+    public String getSuffix(){
+        return suffix;
+    }
+    /**
+     * The index type
+     * @return the indexType
+     */
+    public IndexDataType getIndexType(){
+        return indexType;
+    }
+    /**
+     * The java type
+     * @return the java class for the index type
+     */
+    public final Class<?> getJavaType() {
+        return javaType;
+    }
+
+    /*--------------------------------------------------------------------------
+     * Code that reads the config and inits lookup tables (also checks config)
+     * --------------------------------------------------------------------------
+     */
+
+    private static Map<Class<?>, IndexDataTypeEnum> javaTypeMap;
+    private static Map<IndexDataType, IndexDataTypeEnum> indexTypeMap;
+    private static Map<List<String>,IndexDataTypeEnum> prefixSuffixMap;
+    private static Map<String,IndexDataTypeEnum> uriMap;
+    static {
+        /*
+         * This inits the Mappings and also validates the configuration provided
+         * by the Enumeration!
+         */
+        Map<Class<?>, IndexDataTypeEnum> jtm = new HashMap<Class<?>, IndexDataTypeEnum>();
+        Map<IndexDataType, IndexDataTypeEnum> itm = new HashMap<IndexDataType, IndexDataTypeEnum>();
+        Map<List<String>, IndexDataTypeEnum> psm = new HashMap<List<String>, IndexDataTypeEnum>();
+        Map<String,IndexDataTypeEnum> um = new HashMap<String, IndexDataTypeEnum>();
+        for(IndexDataTypeEnum dt : IndexDataTypeEnum.values()){
+            if(jtm.containsKey(dt.javaType)){
+                throw new IllegalStateException(String.format("Found multiple IndexTypes %s and %s for Class %s! Wrong Data provided by %s",
+                        dt.indexType,jtm.get(dt.javaType).indexType,dt.javaType,IndexDataTypeEnum.class));
+            } else {
+                jtm.put(dt.javaType, dt);
+            }
+            if(itm.containsKey(dt.indexType)){
+                throw new IllegalStateException(String.format("Found multiple Entries with IndexType %s! Wrong Data provided by %s",
+                        dt.indexType,IndexDataTypeEnum.class));
+            } else {
+                itm.put(dt.indexType, dt);
+            }
+            //NOTE: Do not use Arrays.asList(..) directly, because it does not
+            //      implement equals and hashCode!
+            List<String> ps = new ArrayList<String>(2);
+            ps.add(dt.prefix);
+            ps.add(dt.suffix);
+            psm.put(ps, dt);
+            if(um.containsKey(dt.getIndexType().getId())){
+                throw new IllegalStateException(String.format("Found multiple Entries with the same data type URI %s! Uri used by %s and %s!",
+                        dt.getIndexType().getId(),dt.name(),um.get(dt.getIndexType().getName()).name()));
+            } else {
+                um.put(dt.getIndexType().getId(), dt);
+            }
+        }
+        javaTypeMap = Collections.unmodifiableMap(jtm);
+        indexTypeMap = Collections.unmodifiableMap(itm);
+        prefixSuffixMap = Collections.unmodifiableMap(psm);
+        uriMap = Collections.unmodifiableMap(um);
+    }
+    /**
+     * Lookup table for the IndexDataTypeEnum based on the java type
+     * @param type the java type
+     * @return the IndexDataTypeEnum for the parsed type or <code>null</code> if
+     * no IndexDataTypeEnum is configured for the parsed type.
+     */
+    public static IndexDataTypeEnum forJavaType(Class<?> type){
+        return javaTypeMap.get(type);
+    }
+    /**
+     * Lookup table for the IndexDataTypeEnum based on the IndexType.
+     * @param indexType the indexType
+     * @return the IndexDataTypeEnum for the parsed IndexTyep or <code>null</code>
+     * if no IndexDataTypeEnum is configured for the parsed IndexType.
+     */
+    public static IndexDataTypeEnum forIndexType(IndexDataType indexType){
+        return indexTypeMap.get(indexType);
+    }
+    /**
+     * Lookup table for the IndexDataTypeEnum based on the prefix and suffix
+     * @param prefix the prefix (might be <code>null</code>)
+     * @param suffix the suffix ( (might be <code>null</code>)
+     * @return the IndexDataTypeEnum for the parsed prefix and suffix or
+     * <code>null</code> if no IndexDataTypeEnum is configured for the parsed
+     * parameter.
+     */
+    public static IndexDataTypeEnum forPrefixSuffix(String prefix,String suffix){
+        List<String> ps = new ArrayList<String>(2);
+        ps.add(prefix);
+        ps.add(suffix);
+        return prefixSuffixMap.get(ps);
+    }
+    /**
+     * Lookup table for the IndexDataTypeEnum based on the data type uri
+     * as stored in the {@link IndexDataType#getName()} property.
+     * @param uri the uri of the dataType
+     * @return the IndexDataTypeEnum for the parsed uri or  <code>null</code> if
+     * no IndexDataTypeEnum is configured for the parsed parameter.
+     */
+    public static IndexDataTypeEnum forUri(String uri){
+        return uriMap.get(uri);
+    }
 
 }

Modified: incubator/stanbol/trunk/rick/yard/solr/src/main/java/eu/iksproject/rick/yard/solr/defaults/SolrConst.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rick/yard/solr/src/main/java/eu/iksproject/rick/yard/solr/defaults/SolrConst.java?rev=1044832&r1=1044831&r2=1044832&view=diff
==============================================================================
--- incubator/stanbol/trunk/rick/yard/solr/src/main/java/eu/iksproject/rick/yard/solr/defaults/SolrConst.java (original)
+++ incubator/stanbol/trunk/rick/yard/solr/src/main/java/eu/iksproject/rick/yard/solr/defaults/SolrConst.java Sun Dec 12 15:13:35 2010
@@ -9,79 +9,79 @@ package eu.iksproject.rick.yard.solr.def
  *
  */
 public class SolrConst {
-	/**
-	 * Char used to mark special fields. Special fields are internally used
-	 * fields that do not represent a value that was present in the original
-	 * resource. They are used to store configurations, to collect values of
-	 * different fields (e.g. labels with different languages)
-	 */
-	public static final char SPECIAL_FIELD_PREFIX = '_';
-	/**
-	 * The Char used to separate prefix, path elements and suffix.
-	 * Currently there is no support for escaping path elements. Therefore
-	 * there is only the possibility to use '/' or '#' because they do not
-	 * appear in prefixes or suffixes and are replaced by prefixes for the
-	 * path elements.
-	 */
-	public static final char PATH_SEPERATOR = '/';
-	/**
-	 * All fields indicating a language start with this character.
-	 * Special fields that indicate a language start with the 
-	 * {@link #SPECIAL_FIELD_PREFIX} followed by this one.<p>
-	 * Examples:<ul>
-	 * <li>@en ... for a field storing English text
-	 * <li>@ ... for a field storing text without a language 
-	 *           (meaning that this text is valid in any language)
-	 * <li>_!@ ... for a field that index all labels in any language. This field
-	 *    uses the {@link #SPECIAL_FIELD_PREFIX},{@link #MERGER_INDICATOR} and
-	 *    the {@link #LANG_INDICATOR}
-	 * </ul>
-	 */
-	public static final char LANG_INDICATOR = '@';
-	/**
-	 * Merger Fields are fields that collect different values already indexed
-	 * in some other fields. This fields are usually configured as 
-	 * <code>store=false</code> and <code>multiValue=true</code> in the index 
-	 * and are used for queries.<p>
-	 * The most used merger field is the {@link #LANG_MERGER_FIELD} that contains
-	 * all natural language values of all languages!
-	 */
-	public static final char MERGER_INDICATOR = '!';
-	/**
-	 * Field that stores all natural language text values of a field - 
-	 * regardless of the language of the text.
-	 */
-	public static final String LANG_MERGER_FIELD = ""+SPECIAL_FIELD_PREFIX+MERGER_INDICATOR+LANG_INDICATOR;
-	/**
-	 * The name of the field used to store the unique id of the Documents (usually
-	 * the URI of the resource)
-	 */
-	public static final String DOCUMENT_ID_FIELD = "uri";
-	/**
-	 * This is used as field name to store all URIs a document 
-	 * refers to. If a document is deleted from the index, than all other documents
-	 * that refer to this URI need to be updated
-	 */
-	public static final String REFERRED_DOCUMENT_FIELD = SPECIAL_FIELD_PREFIX+"ref";
-	/**
-	 * This is used as field name to store all URIs a document uses in one of
-	 * it's paths.<p> If a document in the index is changed, than all documents
-	 * that are dependent on this one need to be updated.
-	 */
-	public static final String DEPENDENT_DOCUMENT_FIELD = SPECIAL_FIELD_PREFIX+"dep";
+    /**
+     * Char used to mark special fields. Special fields are internally used
+     * fields that do not represent a value that was present in the original
+     * resource. They are used to store configurations, to collect values of
+     * different fields (e.g. labels with different languages)
+     */
+    public static final char SPECIAL_FIELD_PREFIX = '_';
+    /**
+     * The Char used to separate prefix, path elements and suffix.
+     * Currently there is no support for escaping path elements. Therefore
+     * there is only the possibility to use '/' or '#' because they do not
+     * appear in prefixes or suffixes and are replaced by prefixes for the
+     * path elements.
+     */
+    public static final char PATH_SEPERATOR = '/';
+    /**
+     * All fields indicating a language start with this character.
+     * Special fields that indicate a language start with the
+     * {@link #SPECIAL_FIELD_PREFIX} followed by this one.<p>
+     * Examples:<ul>
+     * <li>@en ... for a field storing English text
+     * <li>@ ... for a field storing text without a language
+     *           (meaning that this text is valid in any language)
+     * <li>_!@ ... for a field that index all labels in any language. This field
+     *    uses the {@link #SPECIAL_FIELD_PREFIX},{@link #MERGER_INDICATOR} and
+     *    the {@link #LANG_INDICATOR}
+     * </ul>
+     */
+    public static final char LANG_INDICATOR = '@';
+    /**
+     * Merger Fields are fields that collect different values already indexed
+     * in some other fields. This fields are usually configured as
+     * <code>store=false</code> and <code>multiValue=true</code> in the index
+     * and are used for queries.<p>
+     * The most used merger field is the {@link #LANG_MERGER_FIELD} that contains
+     * all natural language values of all languages!
+     */
+    public static final char MERGER_INDICATOR = '!';
+    /**
+     * Field that stores all natural language text values of a field -
+     * regardless of the language of the text.
+     */
+    public static final String LANG_MERGER_FIELD = ""+SPECIAL_FIELD_PREFIX+MERGER_INDICATOR+LANG_INDICATOR;
+    /**
+     * The name of the field used to store the unique id of the Documents (usually
+     * the URI of the resource)
+     */
+    public static final String DOCUMENT_ID_FIELD = "uri";
+    /**
+     * This is used as field name to store all URIs a document
+     * refers to. If a document is deleted from the index, than all other documents
+     * that refer to this URI need to be updated
+     */
+    public static final String REFERRED_DOCUMENT_FIELD = SPECIAL_FIELD_PREFIX+"ref";
+    /**
+     * This is used as field name to store all URIs a document uses in one of
+     * it's paths.<p> If a document in the index is changed, than all documents
+     * that are dependent on this one need to be updated.
+     */
+    public static final String DEPENDENT_DOCUMENT_FIELD = SPECIAL_FIELD_PREFIX+"dep";
+
+    public static final String SPECIAL_CONFIG_FIELD = SPECIAL_FIELD_PREFIX+"config";
+    /**
+     * The name of the field that indicates the domain of a document.<p>
+     * Within the schema.xml this field is usually configures as
+     * <code>multiValued=false stored=false indexed=true</code>.
+     * NOTE: that the two domains sharing the same SolrIndex MUST NOT add
+     * Documents with the same ID (equal values for {@link #DOCUMENT_ID_FIELD})
+     */
+    public static final String DOMAIN_FIELD = SPECIAL_FIELD_PREFIX+"domain";
+    /**
+     * The field name used by Solr for the score of query results
+     */
+    public static final String SCORE_FIELD = "score";
 
-	public static final String SPECIAL_CONFIG_FIELD = SPECIAL_FIELD_PREFIX+"config";
-	/**
-	 * The name of the field that indicates the domain of a document.<p>
-	 * Within the schema.xml this field is usually configures as 
-	 * <code>multiValued=false stored=false indexed=true</code>.
-	 * NOTE: that the two domains sharing the same SolrIndex MUST NOT add
-	 * Documents with the same ID (equal values for {@link #DOCUMENT_ID_FIELD})
-	 */
-	public static final String DOMAIN_FIELD = SPECIAL_FIELD_PREFIX+"domain";
-	/**
-	 * The field name used by Solr for the score of query results
-	 */
-	public static final String SCORE_FIELD = "score";
-	
 }