Skip to content

Commit

Permalink
added dc title using sparql update, something is not right yet though…
Browse files Browse the repository at this point in the history
… since the property seems no to show up
  • Loading branch information
fasseg committed May 17, 2013
1 parent 461adaa commit 64e7897
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -201,7 +201,7 @@ public FieldSearchResult search(final Query query, final int offSet,
public static String buildQueryString() {
//TODO expand to more fields
final String sqlExpression =
"SELECT * FROM [" + FEDORA_RESOURCE + "] WHERE [dc:identifier] like $sterm OR [dc:title] like $sterm";
"SELECT * FROM [" + FEDORA_RESOURCE + "] WHERE PATH([" + FEDORA_RESOURCE + "]) like $sterm OR [dc:identifier] like $sterm OR [dc:title] like $sterm";
return sqlExpression;
}
}
Expand Up @@ -12,6 +12,7 @@
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicNameValuePair;
import org.codehaus.jettison.json.JSONObject;
import org.junit.Test;
Expand Down Expand Up @@ -47,10 +48,19 @@ public void testSearchSubmitRdfJSON() throws Exception {
postObj.releaseConnection();
assertEquals(201, postResp.getStatusLine().getStatusCode());

/* and add a dc title to the object so the query returns a result */
HttpPost postDc = new HttpPost(serverAddress + "objects/testobj");
postDc.addHeader("Content-Type", "application/sparql-update");
String updateString = "INSERT { <info:fedora/objects/testobj> <http://purl.org/dc/elements/1.1/title> \"testobj\" } WHERE { }";
postDc.setEntity(new StringEntity(updateString));
HttpResponse dcResp = execute(postDc);
assertTrue(dcResp.getStatusLine().toString(),204 == dcResp.getStatusLine().getStatusCode());
postDc.releaseConnection();

final HttpPost method = new HttpPost(serverAddress + "fcr:search");
method.setHeader("Accept", "application/rdf+json");
final List<BasicNameValuePair> list = new ArrayList<>();
list.add(new BasicNameValuePair("terms", "*"));
list.add(new BasicNameValuePair("terms", "testobj"));
list.add(new BasicNameValuePair("offset", "0"));
list.add(new BasicNameValuePair("maxResults", "1"));
final UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(list);
Expand Down

0 comments on commit 64e7897

Please sign in to comment.