Java 类com.amazonaws.mturk.requester.AssignmentStatus 实例源码

项目:java-aws-mturk    文件:RequesterServiceRaw.java   
/**
 * @see http://docs.amazonwebservices.com/AWSMechanicalTurkRequester/2007-03-12/ApiReference_GetAssignmentsForHITOperation.html
 */ 
public GetAssignmentsForHITResult getAssignmentsForHIT(String hitId, SortDirection sortDirection, AssignmentStatus[] status, 
    GetAssignmentsForHITSortProperty sortProperty, Integer pageNumber, Integer pageSize, String[] responseGroup)
  throws ServiceException { 

  GetAssignmentsForHITRequest request = wrapAssignmentParams(hitId, sortDirection, status, 
          sortProperty, pageNumber, pageSize, responseGroup);

  GetAssignmentsForHITResult result = null;

  result = (GetAssignmentsForHITResult) executeRequest(request, 
      ResultMatch.GetAssignmentsForHIT.name(),
      ResultMatch.GetAssignmentsForHIT.getResultTypeName());    

  if (result == null) {
    throw new ServiceException("No response");
  }

  return result; 
}
项目:mturksdk-java-code-maven    文件:RequesterServiceRaw.java   
/**
 * @see http://docs.amazonwebservices.com/AWSMechanicalTurkRequester/2007-03-12/ApiReference_GetAssignmentsForHITOperation.html
 */ 
public GetAssignmentsForHITResult getAssignmentsForHIT(String hitId, SortDirection sortDirection, AssignmentStatus[] status, 
    GetAssignmentsForHITSortProperty sortProperty, Integer pageNumber, Integer pageSize, String[] responseGroup)
  throws ServiceException { 

  GetAssignmentsForHITRequest request = wrapAssignmentParams(hitId, sortDirection, status, 
          sortProperty, pageNumber, pageSize, responseGroup);

  GetAssignmentsForHITResult result = null;

  result = (GetAssignmentsForHITResult) executeRequest(request, 
      ResultMatch.GetAssignmentsForHIT.name(),
      ResultMatch.GetAssignmentsForHIT.getResultTypeName());    

  if (result == null) {
    throw new ServiceException("No response");
  }

  return result; 
}
项目:java-aws-mturk    文件:HITResults.java   
@SuppressWarnings("unchecked")
private String getAnswers(Assignment assignment) {
  String result = EMPTY;

  AssignmentStatus status = assignment.getAssignmentStatus(); 
  if (status == null) {
    return NO_ANSWER;
  }

  String answerXML = assignment.getAnswer();

  QuestionFormAnswers qfa = RequesterService.parseAnswers(answerXML);
  List<QuestionFormAnswersType.AnswerType> answers = 
    (List<QuestionFormAnswersType.AnswerType>) qfa.getAnswer();

  for (QuestionFormAnswersType.AnswerType answer : answers) {

    String assignmentId = assignment.getAssignmentId();
    String answerValue = RequesterService.getAnswerValue(assignmentId, answer, true);

    if (answerValue != null) {
      result += answerValue + DELIMITER;
    }
  }

  return result;
}
项目:java-aws-mturk    文件:RequesterServiceRaw.java   
private GetAssignmentsForHITRequest wrapAssignmentParams(String hitId, SortDirection sortDirection, AssignmentStatus[] status, 
  GetAssignmentsForHITSortProperty sortProperty, Integer pageNumber, Integer pageSize, String[] responseGroup) {
 GetAssignmentsForHITRequest request = new GetAssignmentsForHITRequest();
 if (hitId != null)          request.setHITId(hitId);
 if (status != null)         request.setAssignmentStatus(status);
 if (pageNumber != null)     request.setPageNumber(pageNumber);
 if (pageSize != null)       request.setPageSize(pageSize);
 if (sortDirection != null)  request.setSortDirection(sortDirection);
 if (sortProperty != null)   request.setSortProperty(sortProperty);
 if (responseGroup != null)  request.setResponseGroup(responseGroup);

 return request;
}
项目:java-aws-mturk    文件:AssignmentsLoader.java   
public AssignmentsLoader(RequesterService service, String hitId, SortDirection sortDirection, 
    AssignmentStatus[] status, GetAssignmentsForHITSortProperty sortProperty, 
    String[] responseGroup, Integer pageSize) {
  this.service = service;
  this.hitId = hitId;
  this.sortDirection = sortDirection;
  this.status = status;
  this.sortProperty = sortProperty;
  this.responseGroup = responseGroup;
  this.pageSize = pageSize;
}
项目:java-aws-mturk    文件:RequesterService.java   
/**
 * Retrieves all assignments that have the 
 * the specified status.
 * 
 * @param hitId   the Id of the HIT for which the assignments are returned
 * @param status  the status value of the assignments to return.
 * @return an array of Assignments
 * @throws ServiceException
 */
public Assignment[] getAllAssignmentsForHIT(String hitId, AssignmentStatus[] status) throws ServiceException {    

  List<Assignment> results = new ArrayList<Assignment>();
  int pageNum = 1;

  do {
    GetAssignmentsForHITResult result = super.getAssignmentsForHIT(hitId,
        DEFAULT_SORT_DIRECTION, 
        status,
        GetAssignmentsForHITSortProperty.SubmitTime,
        pageNum, DEFAULT_PAGE_SIZE, DEFAULT_ASSIGNMENT_RESPONSE_GROUP
    );
    Assignment[] assignment = result.getAssignment();

    if (assignment != null) {
      // Add the results
      Collections.addAll(results, assignment);
    }

    // Check if we're on the last page or not
    if (assignment == null || assignment.length < DEFAULT_PAGE_SIZE)
      break;

    pageNum++;

  } while (true);

  return (Assignment[]) results.toArray(new Assignment[results.size()]);    
}
项目:mturksdk-java-code-maven    文件:HITResults.java   
@SuppressWarnings("unchecked")
private String getAnswers(Assignment assignment) {
  String result = EMPTY;

  AssignmentStatus status = assignment.getAssignmentStatus(); 
  if (status == null) {
    return NO_ANSWER;
  }

  String answerXML = assignment.getAnswer();

  QuestionFormAnswers qfa = RequesterService.parseAnswers(answerXML);
  List<QuestionFormAnswersType.AnswerType> answers = 
    (List<QuestionFormAnswersType.AnswerType>) qfa.getAnswer();

  for (QuestionFormAnswersType.AnswerType answer : answers) {

    String assignmentId = assignment.getAssignmentId();
    String answerValue = RequesterService.getAnswerValue(assignmentId, answer, true);

    if (answerValue != null) {
      result += answerValue + DELIMITER;
    }
  }

  return result;
}
项目:mturksdk-java-code-maven    文件:RequesterServiceRaw.java   
private GetAssignmentsForHITRequest wrapAssignmentParams(String hitId, SortDirection sortDirection, AssignmentStatus[] status, 
  GetAssignmentsForHITSortProperty sortProperty, Integer pageNumber, Integer pageSize, String[] responseGroup) {
 GetAssignmentsForHITRequest request = new GetAssignmentsForHITRequest();
 if (hitId != null)          request.setHITId(hitId);
 if (status != null)         request.setAssignmentStatus(status);
 if (pageNumber != null)     request.setPageNumber(pageNumber);
 if (pageSize != null)       request.setPageSize(pageSize);
 if (sortDirection != null)  request.setSortDirection(sortDirection);
 if (sortProperty != null)   request.setSortProperty(sortProperty);
 if (responseGroup != null)  request.setResponseGroup(responseGroup);

 return request;
}
项目:mturksdk-java-code-maven    文件:AssignmentsLoader.java   
public AssignmentsLoader(RequesterService service, String hitId, SortDirection sortDirection, 
    AssignmentStatus[] status, GetAssignmentsForHITSortProperty sortProperty, 
    String[] responseGroup, Integer pageSize) {
  this.service = service;
  this.hitId = hitId;
  this.sortDirection = sortDirection;
  this.status = status;
  this.sortProperty = sortProperty;
  this.responseGroup = responseGroup;
  this.pageSize = pageSize;
}
项目:mturksdk-java-code-maven    文件:RequesterService.java   
/**
 * Retrieves all assignments that have the 
 * the specified status.
 * 
 * @param hitId   the Id of the HIT for which the assignments are returned
 * @param status  the status value of the assignments to return.
 * @return an array of Assignments
 * @throws ServiceException
 */
public Assignment[] getAllAssignmentsForHIT(String hitId, AssignmentStatus[] status) throws ServiceException {    

  List<Assignment> results = new ArrayList<Assignment>();
  int pageNum = 1;

  do {
    GetAssignmentsForHITResult result = super.getAssignmentsForHIT(hitId,
        DEFAULT_SORT_DIRECTION, 
        status,
        GetAssignmentsForHITSortProperty.SubmitTime,
        pageNum, DEFAULT_PAGE_SIZE, DEFAULT_ASSIGNMENT_RESPONSE_GROUP
    );
    Assignment[] assignment = result.getAssignment();

    if (assignment != null) {
      // Add the results
      Collections.addAll(results, assignment);
    }

    // Check if we're on the last page or not
    if (assignment == null || assignment.length < DEFAULT_PAGE_SIZE)
      break;

    pageNum++;

  } while (true);

  return (Assignment[]) results.toArray(new Assignment[results.size()]);    
}
项目:gort-public    文件:Utility.java   
public static Assignment[] getSubmittedAssignments(RequesterService service, String hitId) {
    if (service == null) {
        return null;
    }

    if (hitId == null || hitId.isEmpty()) {
        return null;
    }

    Assignment[] assignments = null;

    try {
        assignments = service.getAllAssignmentsForHIT(hitId);
    } catch (Exception e) {
        System.out.println("Could not connect to receive HIT assignments.");
        //e.printStackTrace();
    }

    if (assignments == null || assignments.length <= 0) {
        return null;
    }

    List<Assignment> retVal = new LinkedList<Assignment>();

    //Only assignments that have been submitted will contain answer data
    for (Assignment a : assignments) {
        if (a == null) {
            continue;
        }

        if (a.getAssignmentStatus() == AssignmentStatus.Submitted) {
            retVal.add(a);
        }

    }

    return (retVal.size() > 0) ? retVal.toArray(new Assignment[retVal.size()]) : null;
}
项目:java-aws-mturk    文件:HITResults.java   
public Map<String,String> getAssignmentResults(Assignment assignment) {

    // Add standard Assignment results
    Map<String,String> results = new LinkedHashMap<String,String>( HITTypeResults.ASSIGNMENT_HEADERS.length );

    results.put( HITProperties.AssignmentField.AssignmentId.getFieldName(), assignment.getAssignmentId());
    results.put( HITProperties.AssignmentField.WorkerId.getFieldName(), assignment.getWorkerId());

    AssignmentStatus status = assignment.getAssignmentStatus();
    String statusStr = status != null ? status.getValue() : EMPTY; 
    results.put( HITProperties.AssignmentField.Status.getFieldName(), statusStr);

    String autoApprovalTime = assignment.getAutoApprovalTime() != null ?
      DATE_FORMATTER.format(assignment.getAutoApprovalTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.AutoApprovalTime.getFieldName(), autoApprovalTime);

    String acceptTime = assignment.getAcceptTime() != null ?
      DATE_FORMATTER.format(assignment.getAcceptTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.AcceptTime.getFieldName(), acceptTime);

    String submitTime = assignment.getSubmitTime() != null ?
      DATE_FORMATTER.format(assignment.getSubmitTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.SubmitTime.getFieldName(), submitTime);

    String approvalTime = assignment.getApprovalTime() != null ?
      DATE_FORMATTER.format(assignment.getApprovalTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.ApprovalTime.getFieldName(), approvalTime);

    String rejectionTime = assignment.getRejectionTime() != null ?
      DATE_FORMATTER.format(assignment.getRejectionTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.RejectionTime.getFieldName(), rejectionTime);

    String deadline = assignment.getDeadline() != null ?
      DATE_FORMATTER.format(assignment.getDeadline().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.Deadline.getFieldName(), deadline);

    String requesterFeedback = assignment.getRequesterFeedback() != null ? 
      assignment.getRequesterFeedback() : EMPTY; 
    results.put( HITProperties.AssignmentField.RequesterFeedback.getFieldName(), requesterFeedback);

    String rejectFlag = status != null && status == AssignmentStatus.Rejected ? "y" : EMPTY; 
    results.put( HITProperties.AssignmentField.RejectFlag.getFieldName(), rejectFlag);

    // Add Assignment-specific answers
    String answers = this.getAnswers(assignment);

    results.put( HITProperties.AssignmentField.Answers.getFieldName(), answers);

    return results;
  }
项目:java-aws-mturk    文件:RequesterServiceRaw.java   
/**
 * Loads all assignment pages for a HIT using the Axis worker thread pool.
 */    
public Assignment[] getAssignmentsForHITAsync(String hitId, SortDirection sortDirection, AssignmentStatus[] status, 
    GetAssignmentsForHITSortProperty sortProperty, Integer pageSize, String[] responseGroup,
    GetAssignmentsForHITResult firstPage,
    AsyncCallback callback) throws ServiceException { 

  Assignment[] ret = new Assignment[] {};
  GetAssignmentsForHITResult result=null;

  if (firstPage==null) {
    // get first page to find how many assignments there are
    AsyncReply first = getAssignmentsForHITAsync(hitId, sortDirection, status, sortProperty,
        1,
        pageSize, responseGroup, callback);

    result = ((GetAssignmentsForHITResult[])first.getResult())[0];
    if (result.getAssignment() != null) {
      ret = result.getAssignment();   
    }
  }
  else {
    result = firstPage;
  }

  // check size and total size and create subsequent requests if necessary
  if (ret.length == pageSize && result.getTotalNumResults() > pageSize) {
    // there are more results
    List<Assignment> results = new ArrayList<Assignment>();
    Collections.addAll(results, ret);

    int numPages = result.getTotalNumResults()/pageSize;

    AsyncReply[] replies = new AsyncReply[numPages];
    for (int i=0; i<numPages; i++) {
      replies[i] = getAssignmentsForHITAsync(hitId, sortDirection, status, sortProperty,
          i+1,
          pageSize, responseGroup, callback);
    }

    // append results
    for (int i=0; i<numPages; i++) {
      result = ((GetAssignmentsForHITResult[])replies[i].getResult())[0];
      if (result.getAssignment() != null) {
        Collections.addAll(results, result.getAssignment());
      }
    }

    ret = (Assignment[]) results.toArray(new Assignment[results.size()]);
  }

  return ret;
}
项目:java-aws-mturk    文件:Reviewer.java   
@SuppressWarnings("unchecked")
/**
 * Prints the submitted results of a HIT when provided with a HIT ID.
 * @param hitId The HIT ID of the HIT to be retrieved.
 */
public void reviewAnswers(String hitId) {
  Assignment[] assignments = service.getAllAssignmentsForHIT(hitId);

  System.out.println("--[Reviewing HITs]----------");
  System.out.println("  HIT Id: " + hitId);

  for (Assignment assignment : assignments) {

    //Only assignments that have been submitted will contain answer data
    if (assignment.getAssignmentStatus() == AssignmentStatus.Submitted) {

      //By default, answers are specified in XML
      String answerXML = assignment.getAnswer();

      //Calling a convenience method that will parse the answer XML and extract out the question/answer pairs.
      QuestionFormAnswers qfa = RequesterService.parseAnswers(answerXML);
      List<QuestionFormAnswersType.AnswerType> answers =
        (List<QuestionFormAnswersType.AnswerType>) qfa.getAnswer();

      for (QuestionFormAnswersType.AnswerType answer : answers) {

        String assignmentId = assignment.getAssignmentId();
        String answerValue = RequesterService.getAnswerValue(assignmentId, answer);

        if (answerValue != null) {
          System.out.println("Got an answer \"" + answerValue
              + "\" from worker " + assignment.getWorkerId() + ".");


        }
      }
      //Approving the assignment.
      service.approveAssignment(assignment.getAssignmentId(), "Well Done!");
      System.out.println("Approved.");

    }
  }

  System.out.println("--[End Reviewing HITs]----------");
}
项目:mturksdk-java-code-maven    文件:HITResults.java   
public Map<String,String> getAssignmentResults(Assignment assignment) {

    // Add standard Assignment results
    Map<String,String> results = new LinkedHashMap<String,String>( HITTypeResults.ASSIGNMENT_HEADERS.length );

    results.put( HITProperties.AssignmentField.AssignmentId.getFieldName(), assignment.getAssignmentId());
    results.put( HITProperties.AssignmentField.WorkerId.getFieldName(), assignment.getWorkerId());

    AssignmentStatus status = assignment.getAssignmentStatus();
    String statusStr = status != null ? status.getValue() : EMPTY; 
    results.put( HITProperties.AssignmentField.Status.getFieldName(), statusStr);

    String autoApprovalTime = assignment.getAutoApprovalTime() != null ?
      DATE_FORMATTER.format(assignment.getAutoApprovalTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.AutoApprovalTime.getFieldName(), autoApprovalTime);

    String acceptTime = assignment.getAcceptTime() != null ?
      DATE_FORMATTER.format(assignment.getAcceptTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.AcceptTime.getFieldName(), acceptTime);

    String submitTime = assignment.getSubmitTime() != null ?
      DATE_FORMATTER.format(assignment.getSubmitTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.SubmitTime.getFieldName(), submitTime);

    String approvalTime = assignment.getApprovalTime() != null ?
      DATE_FORMATTER.format(assignment.getApprovalTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.ApprovalTime.getFieldName(), approvalTime);

    String rejectionTime = assignment.getRejectionTime() != null ?
      DATE_FORMATTER.format(assignment.getRejectionTime().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.RejectionTime.getFieldName(), rejectionTime);

    String deadline = assignment.getDeadline() != null ?
      DATE_FORMATTER.format(assignment.getDeadline().getTime()) : EMPTY;
    results.put( HITProperties.AssignmentField.Deadline.getFieldName(), deadline);

    String requesterFeedback = assignment.getRequesterFeedback() != null ? 
      assignment.getRequesterFeedback() : EMPTY; 
    results.put( HITProperties.AssignmentField.RequesterFeedback.getFieldName(), requesterFeedback);

    String rejectFlag = status != null && status == AssignmentStatus.Rejected ? "y" : EMPTY; 
    results.put( HITProperties.AssignmentField.RejectFlag.getFieldName(), rejectFlag);

    // Add Assignment-specific answers
    String answers = this.getAnswers(assignment);

    results.put( HITProperties.AssignmentField.Answers.getFieldName(), answers);

    return results;
  }
项目:mturksdk-java-code-maven    文件:RequesterServiceRaw.java   
/**
 * Loads all assignment pages for a HIT using the Axis worker thread pool.
 */    
public Assignment[] getAssignmentsForHITAsync(String hitId, SortDirection sortDirection, AssignmentStatus[] status, 
    GetAssignmentsForHITSortProperty sortProperty, Integer pageSize, String[] responseGroup,
    GetAssignmentsForHITResult firstPage,
    AsyncCallback callback) throws ServiceException { 

  Assignment[] ret = new Assignment[] {};
  GetAssignmentsForHITResult result=null;

  if (firstPage==null) {
    // get first page to find how many assignments there are
    AsyncReply first = getAssignmentsForHITAsync(hitId, sortDirection, status, sortProperty,
        1,
        pageSize, responseGroup, callback);

    result = ((GetAssignmentsForHITResult[])first.getResult())[0];
    if (result.getAssignment() != null) {
      ret = result.getAssignment();   
    }
  }
  else {
    result = firstPage;
  }

  // check size and total size and create subsequent requests if necessary
  if (ret.length == pageSize && result.getTotalNumResults() > pageSize) {
    // there are more results
    List<Assignment> results = new ArrayList<Assignment>();
    Collections.addAll(results, ret);

    int numPages = result.getTotalNumResults()/pageSize;

    AsyncReply[] replies = new AsyncReply[numPages];
    for (int i=0; i<numPages; i++) {
      replies[i] = getAssignmentsForHITAsync(hitId, sortDirection, status, sortProperty,
          i+1,
          pageSize, responseGroup, callback);
    }

    // append results
    for (int i=0; i<numPages; i++) {
      result = ((GetAssignmentsForHITResult[])replies[i].getResult())[0];
      if (result.getAssignment() != null) {
        Collections.addAll(results, result.getAssignment());
      }
    }

    ret = (Assignment[]) results.toArray(new Assignment[results.size()]);
  }

  return ret;
}
项目:mturksdk-java-code-maven    文件:Reviewer.java   
@SuppressWarnings("unchecked")
/**
 * Prints the submitted results of a HIT when provided with a HIT ID.
 * @param hitId The HIT ID of the HIT to be retrieved.
 */
public void reviewAnswers(String hitId) {
  Assignment[] assignments = service.getAllAssignmentsForHIT(hitId);

  System.out.println("--[Reviewing HITs]----------");
  System.out.println("  HIT Id: " + hitId);

  for (Assignment assignment : assignments) {

    //Only assignments that have been submitted will contain answer data
    if (assignment.getAssignmentStatus() == AssignmentStatus.Submitted) {

      //By default, answers are specified in XML
      String answerXML = assignment.getAnswer();

      //Calling a convenience method that will parse the answer XML and extract out the question/answer pairs.
      QuestionFormAnswers qfa = RequesterService.parseAnswers(answerXML);
      List<QuestionFormAnswersType.AnswerType> answers =
        (List<QuestionFormAnswersType.AnswerType>) qfa.getAnswer();

      for (QuestionFormAnswersType.AnswerType answer : answers) {

        String assignmentId = assignment.getAssignmentId();
        String answerValue = RequesterService.getAnswerValue(assignmentId, answer);

        if (answerValue != null) {
          System.out.println("Got an answer \"" + answerValue
              + "\" from worker " + assignment.getWorkerId() + ".");


        }
      }
      //Approving the assignment.
      service.approveAssignment(assignment.getAssignmentId(), "Well Done!");
      System.out.println("Approved.");

    }
  }

  System.out.println("--[End Reviewing HITs]----------");
}
项目:hiding    文件:Reviewer.java   
@SuppressWarnings("unchecked")
  /**
   * Prints the submitted results of a HIT when provided with a HIT ID.
   * @param hitId The HIT ID of the HIT to be retrieved.
   */
  public void reviewAnswers(ReviewHIT hit) {
    Assignment[] assignments = service.getAllAssignmentsForHIT(hit.id);

    System.out.println("--[Reviewing HITs]----------");
    System.out.println("author:review=" + hit.author + ":" + hit.review);
    System.out.println("  HIT Id: " + hit.id);
    for (Assignment assignment : assignments) {
      String path = Utils.getTranslatedFixedFilename(filenames.get(hit.author), hit.review);
      System.out.println(path.substring(path.lastIndexOf('/')+1));
      //Only assignments that have been submitted will contain answer data
      if (assignment.getAssignmentStatus() == AssignmentStatus.Submitted) {

        //By default, answers are specified in XML
        String answerXML = assignment.getAnswer();

        //Calling a convenience method that will parse the answer XML and extract out the question/answer pairs.
        QuestionFormAnswers qfa = RequesterService.parseAnswers(answerXML);
        List<QuestionFormAnswersType.AnswerType> answers =
          (List<QuestionFormAnswersType.AnswerType>) qfa.getAnswer();
        for (QuestionFormAnswersType.AnswerType answer : answers) {

          String assignmentId = assignment.getAssignmentId();
          String answerValue = RequesterService.getAnswerValue(assignmentId, answer);

          if (answerValue != null) {
            if (answerValue.equals("emptyanswer") ||
                answerValue.equals("fair") ||
                answerValue.equals("nice") ||
                answerValue.equals("poor")) {
//              service.rejectAssignment(assignmentId, "");
              System.out.println("BAD ANSWER");
            } else {
//              service.rejectAssignment(assignmentId, "");
              System.out.println("Got an answer \"" + answerValue
                  + "\" from worker " + assignment.getWorkerId() + ".");
              size += 1;
            }
          }
//          ReviewWriter.writeTranslatedFixedReview(answerValue, hit.author, hit.review);
          /** Reject bad workers here. */
//          if (false) {
//            System.out.println("BAD WORKER");
//            service.rejectAssignment(assignmentId, "Do not follow the submission instructions: Submit a result(explained below) followed by the explanation of differences.");
//          }
        }
//        Approving the assignment.
//        service.approveAssignment(assignment.getAssignmentId(), "Well Done!");
//        System.out.println("Approved.");
//        service.disposeHIT(hit.id);
//        service.disableHIT(hit.id);
//
      }
    }
    System.out.println("--[End Reviewing HITs]----------");
  }
项目:gort-public    文件:Reviewer.java   
@SuppressWarnings("unchecked")
/**
 * Prints the submitted results of a HIT when provided with a HIT ID.
 * @param hitId The HIT ID of the HIT to be retrieved.
 */
public void reviewAnswers(String hitId) {
  Assignment[] assignments = service.getAllAssignmentsForHIT(hitId);

  System.out.println("--[Reviewing HITs]----------");
  System.out.println("  HIT Id: " + hitId);

  for (Assignment assignment : assignments) {

    //Only assignments that have been submitted will contain answer data
    if (assignment.getAssignmentStatus() == AssignmentStatus.Submitted) {

      //By default, answers are specified in XML
      String answerXML = assignment.getAnswer();

      //Calling a convenience method that will parse the answer XML and extract out the question/answer pairs.
      QuestionFormAnswers qfa = RequesterService.parseAnswers(answerXML);
      List<QuestionFormAnswersType.AnswerType> answers =
        (List<QuestionFormAnswersType.AnswerType>) qfa.getAnswer();

      for (QuestionFormAnswersType.AnswerType answer : answers) {

        String assignmentId = assignment.getAssignmentId();
        String answerValue = RequesterService.getAnswerValue(assignmentId, answer);

        if (answerValue != null) {
          System.out.println("Got an answer \"" + answerValue
              + "\" from worker " + assignment.getWorkerId() + ".");


        }
      }
      //Approving the assignment.
      service.approveAssignment(assignment.getAssignmentId(), "Well Done!");
      System.out.println("Approved.");

    }
  }

  System.out.println("--[End Reviewing HITs]----------");
}
项目:java-aws-mturk    文件:RequesterServiceRaw.java   
/**
 * Loads an assignments page for 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.
 */  
public AsyncReply getAssignmentsForHITAsync(String hitId, SortDirection sortDirection, AssignmentStatus[] status, 
    GetAssignmentsForHITSortProperty sortProperty, Integer pageNumber, Integer pageSize, String[] responseGroup,
    AsyncCallback callback) throws ServiceException { 

  GetAssignmentsForHITRequest request = wrapAssignmentParams(hitId, sortDirection, status, 
      sortProperty, pageNumber, pageSize, responseGroup);

  return executeAsyncRequest(request, 
      ResultMatch.GetAssignmentsForHIT.name(),
      ResultMatch.GetAssignmentsForHIT.getResultTypeName(),
      callback); 
}
项目:mturksdk-java-code-maven    文件:RequesterServiceRaw.java   
/**
 * Loads an assignments page for 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.
 */  
public AsyncReply getAssignmentsForHITAsync(String hitId, SortDirection sortDirection, AssignmentStatus[] status, 
    GetAssignmentsForHITSortProperty sortProperty, Integer pageNumber, Integer pageSize, String[] responseGroup,
    AsyncCallback callback) throws ServiceException { 

  GetAssignmentsForHITRequest request = wrapAssignmentParams(hitId, sortDirection, status, 
      sortProperty, pageNumber, pageSize, responseGroup);

  return executeAsyncRequest(request, 
      ResultMatch.GetAssignmentsForHIT.name(),
      ResultMatch.GetAssignmentsForHIT.getResultTypeName(),
      callback); 
}