Skip to content

Commit

Permalink
RDF: Skeleton viewBioDetailsRdf and viewBioDetailsTurtle
Browse files Browse the repository at this point in the history
  • Loading branch information
stain committed May 22, 2013
1 parent 63673c8 commit 115d4c3
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class OrcidApiConstants {

public static final String ORCID_XML = "application/orcid+xml; qs=3";
public static final String ORCID_JSON = "application/orcid+json; qs=2";
public static final String TEXT_TURTLE = "text/turtle; charset=utf8; qs=3";
public static final String TEXT_N3 = "text/n3; charset=utf8; qs=2";
public static final String APPLICATION_RDFXML = "application/rdf+xml; qs=2";
public static final String VND_ORCID_XML = "application/vnd.orcid+xml; qs=5";
public static final String VND_ORCID_JSON = "application/vnd.orcid+json; qs=4";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,33 @@ public interface OrcidApiService<T> {
@Path(BIO_PATH)
T viewBioDetailsJson(@PathParam("orcid") String orcid);

/**
* GETs the RDF/XML representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF/XML representation of the ORCID record
*/
@GET
@Produces(value = { APPLICATION_RDFXML })
@Path(BIO_PATH)
T viewBioDetailsRdf(@PathParam("orcid") String orcid);


/**
* GETs the RDF Turtle representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF Turtle representation of the ORCID record
*/
@GET
@Produces(value = { TEXT_N3, TEXT_TURTLE })
@Path(BIO_PATH)
T viewBioDetailsTurtle(@PathParam("orcid") String orcid);

/**
* GETs the HTML representation of the ORCID external identifiers
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.orcid.api.t2.server;

import static org.orcid.api.common.OrcidApiConstants.APPLICATION_RDFXML;
import static org.orcid.api.common.OrcidApiConstants.BIO_PATH;
import static org.orcid.api.common.OrcidApiConstants.BIO_SEARCH_PATH;
import static org.orcid.api.common.OrcidApiConstants.EXTERNAL_IDENTIFIER_PATH;
Expand All @@ -25,6 +26,8 @@
import static org.orcid.api.common.OrcidApiConstants.PROFILE_GET_PATH;
import static org.orcid.api.common.OrcidApiConstants.PROFILE_POST_PATH;
import static org.orcid.api.common.OrcidApiConstants.STATUS_PATH;
import static org.orcid.api.common.OrcidApiConstants.TEXT_N3;
import static org.orcid.api.common.OrcidApiConstants.TEXT_TURTLE;
import static org.orcid.api.common.OrcidApiConstants.VND_ORCID_JSON;
import static org.orcid.api.common.OrcidApiConstants.VND_ORCID_XML;
import static org.orcid.api.common.OrcidApiConstants.WEBHOOKS_PATH;
Expand Down Expand Up @@ -159,6 +162,40 @@ public Response viewBioDetailsJson(@PathParam("orcid") String orcid) {
return serviceDelegator.findBioDetails(orcid);
}

/**
* GETs the RDF Turtle representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF Turtle representation of the ORCID record
*/
@Override
@GET
@Produces(value = { TEXT_N3, TEXT_TURTLE })
@Path(BIO_PATH)
public Response viewBioDetailsTurtle(@PathParam("orcid") String orcid) {
T2_GET_REQUESTS.inc();
return serviceDelegator.findBioDetails(orcid);
}

/**
* GETs the RDF/XML representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF/XML representation of the ORCID record
*/
@Override
@GET
@Produces(value = { APPLICATION_RDFXML })
@Path(BIO_PATH)
public Response viewBioDetailsRdf(@PathParam("orcid") String orcid) {
T2_GET_REQUESTS.inc();
return serviceDelegator.findBioDetails(orcid);
}

/**
* GETs the HTML representation of the ORCID external identifiers
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,32 @@ public ClientResponse viewBioDetailsJson(@PathParam("orcid") String orcid) {
return orcidClientHelper.getClientResponse(UriBuilder.fromPath(BIO_PATH_NO_REGEX).build(orcid), VND_ORCID_JSON);
}

/**
* GETs the RDF/XML representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF/XML representation of the ORCID record
*/
@Override
public ClientResponse viewBioDetailsRdf(@PathParam("orcid") String orcid) {
return orcidClientHelper.getClientResponse(UriBuilder.fromPath(BIO_PATH_NO_REGEX).build(orcid), APPLICATION_RDFXML);
}

/**
* GETs the RDF Turtle representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF Turtle representation of the ORCID record
*/
@Override
public ClientResponse viewBioDetailsTurtle(@PathParam("orcid") String orcid) {
return orcidClientHelper.getClientResponse(UriBuilder.fromPath(BIO_PATH_NO_REGEX).build(orcid), TEXT_TURTLE);
}

/**
* GETs the HTML representation of the ORCID external identifiers
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,39 @@ public Response viewBioDetailsXml(@PathParam("orcid") String orcid) {
T1_GET_REQUESTS.inc();
return serviceDelegator.findBioDetails(orcid);
}

/**
* GETs the RDF/XML representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF/XML representation of the ORCID record
*/
@Override
@GET
@Produces(value = { APPLICATION_RDFXML })
@Path(BIO_PATH)
public Response viewBioDetailsRdf(@PathParam("orcid") String orcid) {
T1_GET_REQUESTS.inc();
return serviceDelegator.findBioDetails(orcid);
}

/**
* GETs the RDF Turtle representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF Turtle representation of the ORCID record
*/
@GET
@Produces(value = { TEXT_N3, TEXT_TURTLE })
@Path(BIO_PATH)
public Response viewBioDetailsTurtle(@PathParam("orcid") String orcid) {
T1_GET_REQUESTS.inc();
return serviceDelegator.findBioDetails(orcid);
}

/**
* GETs the JSON representation of the ORCID record containing only the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@ public ClientResponse viewBioDetailsHtml(@PathParam("orcid") String orcid) {
public ClientResponse viewBioDetailsXml(@PathParam("orcid") String orcid) {
return orcidClientHelper.getClientResponse(UriBuilder.fromPath(BIO_PATH_NO_REGEX).build(orcid), VND_ORCID_XML);
}

/**
* GETs the RDF/XML representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF/XML representation of the ORCID record
*/
@Override
public ClientResponse viewBioDetailsRdf(@PathParam("orcid") String orcid) {
return orcidClientHelper.getClientResponse(UriBuilder.fromPath(BIO_PATH_NO_REGEX).build(orcid), APPLICATION_RDFXML);
}

/**
* GETs the RDF Turtle representation of the ORCID record containing only the
* Biography details
*
* @param orcid
* the ORCID that corresponds to the user's record
* @return the RDF Turtle representation of the ORCID record
*/
@Override
public ClientResponse viewBioDetailsTurtle(@PathParam("orcid") String orcid) {
return orcidClientHelper.getClientResponse(UriBuilder.fromPath(BIO_PATH_NO_REGEX).build(orcid), TEXT_TURTLE);
}

/**
* GETs the JSON representation of the ORCID record containing only the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,53 +113,55 @@ public void testCounterUnaffectedByViewStatus() {
}

@Test
public void testViewBioDetailsJson() {
public void testViewBioDetailsRdf() {
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
assertTrue(T1OrcidApiServiceImpl.T1_GET_REQUESTS.count() == 0);
when(mockServiceDelegator.findBioDetails(any(String.class))).thenReturn(fakeBio());
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
Response response = t1OrcidApiService.viewBioDetailsJson("orcid");
Response response = t1OrcidApiService.viewBioDetailsRdf("orcid");
assertEquals(200, response.getStatus());
System.out.println(response.getEntity());
assertTrue(T1OrcidApiServiceImpl.T1_GET_REQUESTS.count() == 1);
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
}

/*
@Test
public void testViewExternalIdentifiersJson() {
public void testViewExternalIdentifiersRdf() {
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
assertTrue(T1OrcidApiServiceImpl.T1_GET_REQUESTS.count() == 0);
when(mockServiceDelegator.findExternalIdentifiers(any(String.class))).thenReturn(successResponse);
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
Response response = t1OrcidApiService.viewExternalIdentifiersJson("orcid");
Response response = t1OrcidApiService.viewExternalIdentifiersRdf("orcid");
assertEquals(200, response.getStatus());
assertTrue(T1OrcidApiServiceImpl.T1_GET_REQUESTS.count() == 1);
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
}
@Test
public void testViewFullDetailsJson() {
public void testViewFullDetailsRdf() {
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
assertTrue(T1OrcidApiServiceImpl.T1_GET_REQUESTS.count() == 0);
when(mockServiceDelegator.findFullDetails(any(String.class))).thenReturn(successResponse);
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
Response response = t1OrcidApiService.viewFullDetailsJson("orcid");
Response response = t1OrcidApiService.viewFullDetailsRdf("orcid");
assertEquals(200, response.getStatus());
assertTrue(T1OrcidApiServiceImpl.T1_GET_REQUESTS.count() == 1);
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
}
@Test
public void testViewWorksDetailsJson() {
public void testViewWorksDetailsRdf() {
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
assertTrue(T1OrcidApiServiceImpl.T1_GET_REQUESTS.count() == 0);
when(mockServiceDelegator.findWorksDetails(any(String.class))).thenReturn(successResponse);
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
Response response = t1OrcidApiService.viewWorksDetailsJson("orcid");
Response response = t1OrcidApiService.viewWorksDetailsRdf("orcid");
assertEquals(200, response.getStatus());
assertTrue(T1OrcidApiServiceImpl.T1_GET_REQUESTS.count() == 1);
assertTrue(T1OrcidApiServiceImpl.T1_SEARCH_REQUESTS.count() == 0);
}
*/

private MultivaluedMap<String, String> queryParams() {
return new MultivaluedMapImpl();
Expand Down

0 comments on commit 115d4c3

Please sign in to comment.