Sam Adams avatar Sam Adams committed 5d59ba8

Tidying up SparqlBuilder

Comments (0)

Files changed (2)

compchem-handler/src/main/java/net/chempound/compchem/search/CompChemSparqlBuilder.java

 import com.hp.hpl.jena.vocabulary.RDFS;
 import net.chempound.compchem.rdf.ont.CompChem;
 import net.chempound.rdf.cml.CmlRdf;
-import net.chempound.webapp.search.SparqlQuery;
+import net.chempound.webapp.search.SparqlQueryBuilder;
 
 /**
  * @author Sam Adams
  */
-public class CompChemSparqlBuilder extends SparqlQuery {
+public class CompChemSparqlBuilder extends SparqlQueryBuilder {
 
     private boolean mol;
 

compchem-handler/src/main/java/net/chempound/compchem/search/CompSearchProvider.java

 import com.hp.hpl.jena.rdf.model.Property;
 import net.chempound.compchem.rdf.ont.CompChem;
 import net.chempound.webapp.search.AbstractSearchProvider;
-import net.chempound.webapp.search.SparqlQuery;
+import net.chempound.webapp.search.SparqlQueryBuilder;
 import org.apache.commons.io.IOUtils;
 
 import java.io.IOException;
         }
     }
 
-    public SparqlQuery createSparqlQuery(final Map<String,String> form) {
+    public SparqlQueryBuilder createSparqlQuery(final Map<String,String> form) {
 
         final CompChemSparqlBuilder queryString = new CompChemSparqlBuilder();
 
         processScalar(form, "point_group", CompChem.pointGroup, queryString);
         processDouble(form, "hf_energy", "hf_energy_op", CompChem.hfEnergy, queryString);
 
-        processInchi(form, queryString);
-        processInchiKey(form, queryString);
+        processInchi(form, "inchi", queryString);
+        processInchiKey(form, "inchi_key", queryString);
 
         return queryString;
 
     }
 
-    private void processScalar(final Map<String, String> form, final String field, final Property prop, final SparqlQuery queryString) {
+    private void processScalar(final Map<String, String> form, final String field, final Property prop, final SparqlQueryBuilder queryString) {
         final String value = form.get(field);
         if (value != null && value.length() > 0) {
             queryString.addProperty(prop, value);
         }
     }
 
-    private void processScalar(final Map<String, String> form, final String field, final String type, final Property prop, final SparqlQuery queryString) {
+    private void processScalar(final Map<String, String> form, final String field, final String type, final Property prop, final SparqlQueryBuilder queryString) {
         final String value = form.get(field);
         if (value != null && value.length() > 0) {
             final String op = form.get(type);
         }
     }
 
-    private void processDouble(final Map<String, String> form, final String field, final String type, final Property prop, final SparqlQuery queryString) {
+    private void processDouble(final Map<String, String> form, final String field, final String type, final Property prop, final SparqlQueryBuilder queryString) {
         final String value = form.get(field);
         if (value != null && value.length() > 0) {
             final String op = form.get(type);
         }
     }
 
-    private void processInchi(final Map<String,String> form, final CompChemSparqlBuilder queryString) {
-        final String value = form.get("inchi");
+    private void processInchi(final Map<String,String> form, final String field, final CompChemSparqlBuilder queryString) {
+        final String value = form.get(field);
         if (value != null && value.length() > 0) {
             queryString.addInchi(value);
         }
     }
 
-    private void processInchiKey(final Map<String,String> form, final CompChemSparqlBuilder queryString) {
-        final String value = form.get("inchi_key");
+    private void processInchiKey(final Map<String,String> form, final String field, final CompChemSparqlBuilder queryString) {
+        final String value = form.get(field);
         if (value != null && value.length() > 0) {
             queryString.addInchiKey(value);
         }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.