Skip to content

Commit

Permalink
changed query back to not include path, therefore no results are retu…
Browse files Browse the repository at this point in the history
…rned from the integration test
  • Loading branch information
fasseg committed May 17, 2013
1 parent ff1807e commit 461adaa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
Expand Up @@ -35,13 +35,13 @@

import org.fcrepo.AbstractResource;
import org.fcrepo.FedoraResource;
import org.fcrepo.api.rdf.HttpGraphSubjects;
import org.fcrepo.http.RDFMediaType;
import org.fcrepo.jaxb.search.FieldSearchResult;
import org.fcrepo.jaxb.search.ObjectFields;
import org.fcrepo.provider.ModelStreamingOutput;
import org.fcrepo.provider.VelocityViewer;
import org.fcrepo.utils.FedoraJcrTypes;
import org.fcrepo.utils.JcrRdfTools;
import org.slf4j.Logger;
import org.springframework.stereotype.Component;

Expand All @@ -50,8 +50,6 @@
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.update.GraphStore;
import com.hp.hpl.jena.update.GraphStoreFactory;

/**
* @author Vincent Nguyen
Expand Down Expand Up @@ -104,16 +102,13 @@ public Response searchSubmitRdf(@FormParam("terms") final String terms,
searchResult.addProperty(model.createProperty("info:fedora/fedora-system:def/search#maxNumResults"),
model.createTypedLiteral(result.getMaxResults()));


final GraphStore store = GraphStoreFactory.create(model);

/* and add the RDF model of each found fedora:resource node to the response model */
for (ObjectFields field : result.getObjectFieldsList()){
final FedoraResource fo = this.nodeService.getObject(session, field.getPath());
Resource objResource = model.createResource(uriInfo.getBaseUri() + "/rest/" + field.getPath());
store.addGraph(objResource.asNode(),fo.getGraphStore(new HttpGraphSubjects(FedoraNodes.class, uriInfo)).getDefaultGraph());
model.add(JcrRdfTools.getJcrPropertiesModel(FedoraResource.DEFAULT_SUBJECT_FACTORY, fo.getNode()));
}

/* prepare the model for output by using a GraphStore */
return Response.ok(new ModelStreamingOutput(model, bestPossibleResponse.getMediaType())).build();
}finally{
session.logout();
Expand Down Expand Up @@ -206,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 PATH([" + FEDORA_RESOURCE + "]) like $sterm OR [dc:identifier] like $sterm OR [dc:title] like $sterm";
"SELECT * FROM [" + FEDORA_RESOURCE + "] WHERE [dc:identifier] like $sterm OR [dc:title] like $sterm";
return sqlExpression;
}
}
Expand Up @@ -2,7 +2,7 @@
package org.fcrepo.integration.api;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -13,6 +13,7 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.codehaus.jettison.json.JSONObject;
import org.junit.Test;

public class FedoraFieldSearchIT extends AbstractResourceIT {
Expand Down Expand Up @@ -59,9 +60,10 @@ public void testSearchSubmitRdfJSON() throws Exception {
String json = IOUtils.toString(resp.getEntity().getContent());
assertEquals("Server returned\n" + json, 200, resp.getStatusLine().getStatusCode());
logger.debug("RDF/JSON Response for field search:\n" + json);

assertTrue(new JSONObject(json).getJSONObject("http://localhost:8080/rest/fcr:search")
.getJSONArray("info:fedora/fedora-system:def/search#numSearchResults")
.getJSONObject(0).getString("value").equals("1"));
method.releaseConnection();
fail("finish implementing a test");
}

@Test
Expand Down
10 changes: 5 additions & 5 deletions fcrepo-kernel/src/main/java/org/fcrepo/FedoraResource.java
Expand Up @@ -36,7 +36,7 @@ public class FedoraResource extends JcrTools implements FedoraJcrTypes {

private static final Logger LOGGER = getLogger(FedoraResource.class);

private static final GraphSubjects DEFAULT_SUBJECT_FACTORY =
public static final GraphSubjects DEFAULT_SUBJECT_FACTORY =
new DefaultGraphSubjects();

protected Node node;
Expand Down Expand Up @@ -179,7 +179,7 @@ public GraphStore updateGraph(String sparqlUpdateStatement)
throws RepositoryException {
return updateGraph(DEFAULT_SUBJECT_FACTORY, sparqlUpdateStatement);
}

public GraphStore getGraphStore(GraphSubjects subjects)
throws RepositoryException {

Expand All @@ -197,7 +197,7 @@ public GraphStore getGraphStore(GraphSubjects subjects)
public GraphStore getGraphStore() throws RepositoryException {
return getGraphStore(DEFAULT_SUBJECT_FACTORY);
}

public GraphStore getVersionGraphStore(GraphSubjects subjects)
throws RepositoryException {
final Model model = JcrRdfTools.getJcrVersionsModel(subjects, node);
Expand All @@ -206,10 +206,10 @@ public GraphStore getVersionGraphStore(GraphSubjects subjects)

return graphStore;
}

public GraphStore getVersionGraphStore() throws RepositoryException {
return getVersionGraphStore(DEFAULT_SUBJECT_FACTORY);
}
}

public void addVersionLabel(final String label) throws RepositoryException {
final VersionHistory versionHistory = getVersionHistory(node);
Expand Down

0 comments on commit 461adaa

Please sign in to comment.