Skip to content

Part of the Crowdery framework. Java implementation of the Crowdflower API.

License

Notifications You must be signed in to change notification settings

WISDelft/crowdery-crowdflower-java

Repository files navigation

JCrowdFlower

JCrowdflower is a library for crowdflower web interface wrapped up in java.

This project is part of Web information Systems groups.

Contributors

  • Debarshi Basak (main developer)
  • Jasper Oosterman (reviewer)
  • Alessandro Bozzon (project conceptualization)

jCrowdFlower

This projects is a Java wrapper for web APIs exposed by CrowdFlower. This project is located in master branch.

You need to build the project as follows

mvn clean install

Tutorial

Simple job creation

Note

  • Create a file called default.properties.
  • Add a property apiKey="your-api-key"
  • Include this project in your pom.xml as follows
<dependency>
    <groupId>crowdflower-java</groupId>
    <artifactId>crowdflower-java</artifactId>
    <version>1.0.1-SNAPSHOT</version>
<dependency>

Then the following is the implementation for creating a job

import nl.wisdelft.cf.*;
import nl.wisdelft.cf.datamodel.*;
import nl.wisdelft.cf.exception.*;
import nl.wisdelft.cf.job.*;
import nl.wisdelft.cf.order.*;

public class CrowdFlowerTutorial {

    public static void main(String[] args) throws NullAPIKeyException, InterruptedException
    {
        /**
         * Alternatively you can declare it as
         * CrowdFlowerFactory.setProperties("/path/to/properties/file");
         *
         * or
         *
         * CrowdFlowerFactory.setApiKey("api-key");
         */

        JobController myJobController = CrowdFlowerFactory.getJobController();
        Job myJob = new Job();

        /**
         * You must have following three properties to create a job successfully
         */

        myJob.addProperty(JobAttribute.TITLE, "Test Job title");
        myJob.addProperty(JobAttribute.INSTRUCTIONS, "Test instructions");
        myJob.addProperty(JobAttribute.CML, "<cml>Test cml </cml>");
        myJob.addProperty(JobAttribute.PAGES_PER_ASSIGNMENT,
                          "0.1");
        myJob.addProperty(JobAttribute.UNITS_PER_ASSIGNMENT,
                          "1");

        Job myJobAfterCreation = myJobController.create(myJob);

        myJobController.upload(myJobAfterCreation, "log/crowd.csv", "text/csv");

        OrderController myOrderController = CrowdFlowerFactory.getOrderController();

        Order myOrder = new Order(myJobAfterCreation.getId());
        myOrder.setDebitUnitCount("3");
        myOrder.addChannel("amt");

        /*
        * Costs money
        */

        myOrderController.create(myOrder);

        /**
         * Takes some time to create
         */
        myOrderController.cancel(myJobAfterCreation.getId());
    }
}

Crowdflower behaviour

The Crowdflower API is running under version number 2. Error handling is however not yet consistent or clear. Some problems on the Crowdflower side return HTTP error. Other errors return a HTTP 200 with a error attribute in the (JSON) body of the response.

When updating an entity we have seen the following behaviour:

  • Unknown attributes are ignored
  • Read-only atributes are ignored
  • When an error attribute is returned no fields have been updated
  • When a HTTP 200 reponse is returned with no error attribute all attributes are updated.

Organization

Delft University of Technology
[Faculty] Electrical Engineering, Computer Science and Mathematics
[Department] Software and Computing Technology [Group] Web Information Systems
[Contact] [email protected]

tudelft

About

Part of the Crowdery framework. Java implementation of the Crowdflower API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages