コード例 #1
0
  public org.iucn.sis.shared.api.models.WorkflowStatus getWorkflowRow(Integer workingSetID)
      throws WorkflowManagerException {
    final SelectQuery query = new SelectQuery();
    query.select(WorkflowConstants.WORKFLOW_TABLE, "*");
    query.constrain(
        new CanonicalColumnName(WorkflowConstants.WORKFLOW_TABLE, "workingsetid"),
        QConstraint.CT_EQUALS,
        workingSetID.toString());

    final Row.Loader rl = new Row.Loader();

    try {
      ec.doQuery(query, rl);
    } catch (DBException e) {
      throw new WorkflowManagerException("Unexpected server error, please try again later.", e);
    }

    org.iucn.sis.shared.api.models.WorkflowStatus model =
        new org.iucn.sis.shared.api.models.WorkflowStatus();
    model.setId(rl.getRow().get("id").getInteger());
    model.setStatus(rl.getRow().get("status").toString());

    return model;
  }
コード例 #2
0
  public void ensureEvaluated(WorkingSet workingSet) throws WorkflowManagerException {
    final Collection<Assessment> assessments =
        WorkflowManager.getAllAssessments(session, workingSet);
    Debug.println("Ensuring evaluation on " + assessments.size() + " assessments...");

    final String table = "RedListEvaluated";
    final Collection<String> failedSpecies = new ArrayList<String>();
    for (Assessment data : assessments) {
      // final String uid = data.getAssessmentID() + "_" + AssessmentType.DRAFT_ASSESSMENT_TYPE;
      final String uid = "" + data.getId();

      final SelectQuery query = new SelectQuery();
      query.select(table, "asm_id");
      query.constrain(
          new CanonicalColumnName(table, "is_evaluated"), QConstraint.CT_EQUALS, "true");
      query.constrain(
          QConstraint.CG_AND,
          new CanonicalColumnName(table, "approval_status"),
          QConstraint.CT_EQUALS,
          Integer.valueOf(1));
      query.constrain(
          QConstraint.CG_AND, new CanonicalColumnName(table, "uid"), QConstraint.CT_EQUALS, uid);

      final Row.Loader rl = new Row.Loader();

      try {
        ec.doQuery(query, rl);
      } catch (DBException e) {
        failedSpecies.add(data.getSpeciesName());
        continue;
      }

      if (rl.getRow() == null) failedSpecies.add(data.getSpeciesName());
    }

    if (!failedSpecies.isEmpty()) {
      final StringBuilder builder = new StringBuilder();
      builder.append("The following species have not yet been marked as evaluted: ");
      for (Iterator<String> iter = failedSpecies.iterator(); iter.hasNext(); )
        builder.append(iter.next() + (iter.hasNext() ? ", " : ""));
      throw new WorkflowManagerException(builder.toString());
    }
  }