Class CampaignItemResource

java.lang.Object
io.goobi.viewer.api.rest.v1.crowdsourcing.CampaignItemResource

@Path("/crowdsourcing/campaigns/{campaignId}") public class CampaignItemResource extends Object
REST resource for accessing crowdsourcing campaign items and submitting annotations.

The following api points are defined:

  • /crowdsourcing/campaigns/{campaignId}/{pi}/
    GET a CampaignItem for 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
  • Field Details

  • Constructor Details

    • CampaignItemResource

      public CampaignItemResource(@Context HttpServletRequest servletRequest, @PathParam("campaignId") Long campaignId)
      Creates a new CampaignItemResource instance.
      Parameters:
      servletRequest - incoming HTTP servlet request
      campaignId - 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 request
      urls - API URL manager for building and parsing resource URLs
      campaignId - 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 the CampaignItem for 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 record
      servletRequest - 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 the CrowdsourcingStatus for the given campaign and work and records the User who made the change.
      Parameters:
      item - campaign item containing the new crowdsourcing status
      persistentIdentifier - persistent identifier of the target record
      page - 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 for
      request - 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 annotations
      pi - 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 record
      pageOrder - page order number within the record, or null for record-level annotations
      anno - 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