Revision: 13718
          http://gate.svn.sourceforge.net/gate/?rev=13718&view=rev
Author:   valyt
Date:     2011-04-20 15:31:24 +0000 (Wed, 20 Apr 2011)

Log Message:
-----------
Added support for query prefix and suffix (which can be used to supply e.g. 
PREFIX statements inside the Index template).

Modified Paths:
--------------
    
mimir/trunk/plugins/sparql/src/gate/mimir/sparql/SPARQLSemanticAnnotationHelper.java

Modified: 
mimir/trunk/plugins/sparql/src/gate/mimir/sparql/SPARQLSemanticAnnotationHelper.java
===================================================================
--- 
mimir/trunk/plugins/sparql/src/gate/mimir/sparql/SPARQLSemanticAnnotationHelper.java
        2011-04-20 15:06:12 UTC (rev 13717)
+++ 
mimir/trunk/plugins/sparql/src/gate/mimir/sparql/SPARQLSemanticAnnotationHelper.java
        2011-04-20 15:31:24 UTC (rev 13718)
@@ -55,7 +55,24 @@
   private static final Logger logger = Logger
       .getLogger(SPARQLSemanticAnnotationHelper.class);
 
+  
   /**
+   * A query fragment that, if set, gets prepended to all SPARQL queries sent 
+   * to the end point. This could be used, for example, for setting up a list 
of 
+   * prefixes.
+   */
+  private String queryPrefix;
+  
+
+  /**
+   * A query fragment that, if set, gets appended to all SPARQL queries sent 
+   * to the end point. This could be used, for example, for setting up a 
+   * LIMIT constraint.
+   */
+  private String querySuffix;
+  
+  
+  /**
    * The name used for the synthetic feature used at query time to supply the
    * SPARQL query.
    */
@@ -66,6 +83,41 @@
    */
   private String sparqlEndpoint;
 
+  
+  /**
+   * See {@link #setQueryPrefix(String)}
+   * @return
+   */
+  public String getQueryPrefix() {
+    return queryPrefix;
+  }
+
+  /**
+   * Sets the query prefix: a query fragment that, if set, gets prepended to 
+   * all SPARQL queries sent to the end point. This could be used, for example,
+   * for setting up a list of PREFIXes.
+   */
+  public void setQueryPrefix(String queryPrefix) {
+    this.queryPrefix = queryPrefix;
+  }
+
+  /**
+   * See {@link #setQuerySuffix(String)}.
+   * @return
+   */
+  public String getQuerySuffix() {
+    return querySuffix;
+  }
+
+  /**
+   * Sets the query suffix: a query fragment that, if set, gets appended to 
+   * all SPARQL queries sent to the end point. This could be used, for example,
+   * for setting up a LIMIT constraint.
+   */  
+  public void setQuerySuffix(String querySuffix) {
+    this.querySuffix = querySuffix;
+  }
+
   public SPARQLSemanticAnnotationHelper(String annotationType,
       String sparqlEndpoint, String[] nominalFeatureNames,
       String[] integerFeatureNames, String[] floatFeatureNames,
@@ -90,7 +142,9 @@
     String query = null;
     for(Constraint aConstraint : constraints) {
       if(aConstraint.getFeatureName() == SPARQL_QUERY_FEATURE_NAME) {
-        query = (String)aConstraint.getValue();
+        query = (queryPrefix != null ? queryPrefix : "") + 
+            (String)aConstraint.getValue() + 
+            (querySuffix != null ? querySuffix : "");
       } else {
         passThroughConstraints.add(aConstraint);
       }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to