Class CampaignItemResource
java.lang.Object
io.goobi.viewer.api.rest.v1.crowdsourcing.CampaignItemResource
REST resource for accessing crowdsourcing campaign items and submitting annotations.
The following api points are defined:
- /crowdsourcing/campaigns/{campaignId}/{pi}/
GET aCampaignItemfor the given campaignId and pi, or PUT the status for that combination - /crowdsourcing/campaigns/{campaignId}/{pi}/annotations/
GET a list of annotations for the given campaignId and pi, sorted by target, or PUT the annotations for this combination
- Author:
- Florian Alpers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUsed to create or read a list of WebAnnotations sorted by their target (a iiif manifest or canvas). -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCampaignItemResource(HttpServletRequest servletRequest, AbstractApiUrlManager urls, Long campaignId) CampaignItemResource(HttpServletRequest servletRequest, Long campaignId) Creates a new CampaignItemResource instance. -
Method Summary
Modifier and TypeMethodDescriptioncreatePersistentAnnotation(String pi, Integer pageOrder, de.intranda.api.annotation.wa.WebAnnotation anno) List<de.intranda.api.annotation.wa.WebAnnotation> getAnnotationsForManifest(String pi, HttpServletRequest request) Gets all annotations for the given campaign and work, sorted by target.getItemForManifest(String persistentIdentifier, HttpServletRequest servletRequest) Gets theCampaignItemfor a campaign and work, containing the URL of the targeted resource (IIIF manifest) and all information to create a GUI for the campaign's questions.voidTakes a map of annotation target (canvas/manifest) ids and replaces all annotations for the given campaign, pi and targeted pages if target is canvas) with the ones contained in the map.voidsetItemForManifest(CampaignItem item, String persistentIdentifier, int page) Sets theCrowdsourcingStatusfor the given campaign and work and records theUserwho made the change.
-
Field Details
-
urls
-
-
Constructor Details
-
CampaignItemResource
public CampaignItemResource(@Context HttpServletRequest servletRequest, @PathParam("campaignId") Long campaignId) Creates a new CampaignItemResource instance.- Parameters:
servletRequest- incoming HTTP servlet requestcampaignId- campaign database ID used to look up the campaign
-
CampaignItemResource
public CampaignItemResource(@Context HttpServletRequest servletRequest, AbstractApiUrlManager urls, @PathParam("campaignId") Long campaignId) - Parameters:
servletRequest- incoming HTTP servlet requesturls- API URL manager for building and parsing resource URLscampaignId- campaign database ID used to look up the campaign
-
-
Method Details
-
getItemForManifest
@GET @Path("/{pi}") @Produces("application/json") public CampaignItem getItemForManifest(@PathParam("pi") String persistentIdentifier, @Context HttpServletRequest servletRequest) throws URISyntaxException, DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException Gets theCampaignItemfor a campaign and work, containing the URL of the targeted resource (IIIF manifest) and all information to create a GUI for the campaign's questions.- Parameters:
persistentIdentifier- persistent identifier of the target recordservletRequest- incoming HTTP servlet request- Returns:
- a
CampaignItem - Throws:
URISyntaxException- if any.DAOException- if any.de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException- if any.
-
setItemForManifest
@PUT @Path("/{pi}/{page}") @Consumes("application/json") public void setItemForManifest(CampaignItem item, @PathParam("pi") String persistentIdentifier, @PathParam("page") int page) throws DAOException Sets theCrowdsourcingStatusfor the given campaign and work and records theUserwho made the change.- Parameters:
item- campaign item containing the new crowdsourcing statuspersistentIdentifier- persistent identifier of the target recordpage- page order number within the record- Throws:
DAOException- if any.
-
getAnnotationsForManifest
@GET @Path("/{pi}/annotations") @Produces("application/json") public List<de.intranda.api.annotation.wa.WebAnnotation> getAnnotationsForManifest(@PathParam("pi") String pi, @Context HttpServletRequest request) throws URISyntaxException, DAOException Gets all annotations for the given campaign and work, sorted by target.- Parameters:
pi- persistent identifier of the record to query annotations forrequest- incoming HTTP servlet request- Returns:
- A map of target URIs (manifest or canvas) mapped to a submap of question URIs mapped to questions
- Throws:
URISyntaxException- if any.DAOException- if any.
-
setAnnotationsForManifest
@PUT @Path("/{pi}/annotations") @Consumes("application/json") public void setAnnotationsForManifest(List<CampaignItemResource.AnnotationPage> pages, @PathParam("pi") String pi) throws URISyntaxException, DAOException Takes a map of annotation target (canvas/manifest) ids and replaces all annotations for the given campaign, pi and targeted pages if target is canvas) with the ones contained in the map.- Parameters:
pages- list of annotation pages containing the new or updated annotationspi- persistent identifier of the annotated record- Throws:
URISyntaxException- if any.DAOException- if any.
-
createPersistentAnnotation
public CrowdsourcingAnnotation createPersistentAnnotation(String pi, Integer pageOrder, de.intranda.api.annotation.wa.WebAnnotation anno) - Parameters:
pi- persistent identifier of the annotated recordpageOrder- page order number within the record, or null for record-level annotationsanno- web annotation to convert to a persistent crowdsourcing annotation- Returns:
- a
CrowdsourcingAnnotation. Either with an existing database id, or without id if ann doesn't has an empty id property
-