/** * Creates a HIT asynchronously using the Axis worker thread pool. * It returns an AsyncReply object, which can either be used to * wait for the asynchronous call to complete and to get the result * of the call. Alternatively, a callback handler can be passed * that is notified when the call has completed. * * The work queue is using a pool of daemon threads to process the submitted tasks. * To guarantee that all work submitted to the queue was processed before the JVM * exits, this requires to wait for all future results of the submitted work items. * This can conveniently be done using the getResult() method of the AsyncReply * object returned by this method. A typical usage pattern would be to first submit * all requests to the work queue, store the AsyncReply objects in an array and then * call getResult() for each of the objects in the array. * * @throws ServiceException */ public AsyncReply createHITAsync(String hitTypeId, String title, String description, String keywords, String question, Double reward, Long assignmentDurationInSeconds, Long autoApprovalDelayInSeconds, Long lifetimeInSeconds, Integer maxAssignments, String requesterAnnotation, QualificationRequirement[] qualificationRequirements, String[] responseGroup, String uniqueRequestToken, ReviewPolicy assignmentReviewPolicy, ReviewPolicy hitReviewPolicy, AsyncCallback callback) { CreateHITRequest request = wrapHITParams(hitTypeId, title, description, keywords, question, reward, assignmentDurationInSeconds, autoApprovalDelayInSeconds, lifetimeInSeconds, maxAssignments, requesterAnnotation, qualificationRequirements, responseGroup, uniqueRequestToken, assignmentReviewPolicy, hitReviewPolicy, null, null); return executeAsyncRequest(request, ResultMatch.CreateHIT.name(), ResultMatch.CreateHIT.getResultTypeName(), callback); }
/** * Support for creating HITs using HIT layouts * @see http://docs.amazonwebservices.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_HITLayoutArticle.html */ public AsyncReply createHITAsync(String hitTypeId, String title, String description, String keywords, Double reward, Long assignmentDurationInSeconds, Long autoApprovalDelayInSeconds, Long lifetimeInSeconds, Integer maxAssignments, String requesterAnnotation, QualificationRequirement[] qualificationRequirements, String[] responseGroup, String uniqueRequestToken, ReviewPolicy assignmentReviewPolicy, ReviewPolicy hitReviewPolicy, String hitLayoutId, HITLayoutParameter[] hitLayoutParameters, AsyncCallback callback) { CreateHITRequest request = wrapHITParams(hitTypeId, title, description, keywords, null, reward, assignmentDurationInSeconds, autoApprovalDelayInSeconds, lifetimeInSeconds, maxAssignments, requesterAnnotation, qualificationRequirements, responseGroup, uniqueRequestToken, assignmentReviewPolicy, hitReviewPolicy, hitLayoutId, hitLayoutParameters); return executeAsyncRequest(request, ResultMatch.CreateHIT.name(), ResultMatch.CreateHIT.getResultTypeName(), callback); }
/** * Checks if method is createHIT and appends 'myHIT' to the set of keywords */ @Override public Reply execute(Message m) throws ServiceException { if (m.getMethodName().equals("CreateHIT")) { CreateHITRequest[] requestArray = (CreateHITRequest[]) m.getRequests(); for (CreateHITRequest request : requestArray) { StringBuffer keywords = new StringBuffer(); //append existing keywords to string buffer if (request.getKeywords() != null) { keywords.append(request.getKeywords()); keywords.append(", "); } keywords.append("myHIT"); request.setKeywords(keywords.toString()); } } //pass the message to the next filter return passMessage(m); }
private CreateHITRequest wrapHITParams(String hitTypeId, String title, String description, String keywords, String question, Double reward, Long assignmentDurationInSeconds, Long autoApprovalDelayInSeconds, Long lifetimeInSeconds, Integer maxAssignments, String requesterAnnotation, QualificationRequirement[] qualificationRequirements, String[] responseGroup, String uniqueRequestToken, ReviewPolicy assignmentReviewPolicy, ReviewPolicy hitReviewPolicy, String hitLayoutId, HITLayoutParameter[] hitLayoutParameters) { CreateHITRequest request = new CreateHITRequest(); if (question != null) request.setQuestion(question); if (lifetimeInSeconds != null)request.setLifetimeInSeconds(lifetimeInSeconds); if (hitTypeId != null) request.setHITTypeId(hitTypeId); if (title != null) request.setTitle(title); if (description != null) request.setDescription(description); if (keywords != null) request.setKeywords(keywords); if (maxAssignments != null) request.setMaxAssignments(maxAssignments); if (responseGroup != null) request.setResponseGroup(responseGroup); if (hitReviewPolicy != null) request.setHITReviewPolicy(hitReviewPolicy); if (hitLayoutId != null) request.setHITLayoutId(hitLayoutId); if (requesterAnnotation != null) request.setRequesterAnnotation(requesterAnnotation); if (assignmentDurationInSeconds != null)request.setAssignmentDurationInSeconds(assignmentDurationInSeconds); if (autoApprovalDelayInSeconds != null) request.setAutoApprovalDelayInSeconds(autoApprovalDelayInSeconds); if (qualificationRequirements != null) request.setQualificationRequirement(qualificationRequirements); if (assignmentReviewPolicy != null) request.setAssignmentReviewPolicy(assignmentReviewPolicy); if (uniqueRequestToken != null) request.setUniqueRequestToken(uniqueRequestToken); if (hitLayoutParameters != null) request.setHITLayoutParameter(hitLayoutParameters); if (reward != null) { Price p = new Price(); p.setAmount(new BigDecimal(reward)); p.setCurrencyCode("USD"); request.setReward(p); } return request; }
public Reply execute(Message m) { if (m.getMethodName().equals("CreateHIT")) { CreateHITRequest[] requestArray = (CreateHITRequest[]) m.getRequests(); for (CreateHITRequest request : requestArray) { if (request.getReward().getAmount().doubleValue() < 0.05) { request.getReward().setAmount(new BigDecimal(0.05)); } } } return passMessage(m); }