コード例 #1
0
ファイル: ImportPhenotypes.java プロジェクト: bioit/crezoo
  /** Compares all values to whats already in the database returns the number of errors found. */
  private void checkCreate(
      String id_or_alias,
      String ind,
      String variable,
      String value,
      String date,
      String ref,
      String comm,
      int suid) {

    // ResultSet rset;
    int nrErrors = 0;
    String identity = null;
    try {
      // First if no IDENTITY was sent, we need to get it through alias!

      if (id_or_alias.equalsIgnoreCase("ALIAS")
          && (ind != null)
          && (!ind.trim().equalsIgnoreCase(""))) {
        identity = db.getIdentity(ind);
      } else {
        identity = ind;
      }

      // compare to database, is this unique? (can it be inserted?)
      if (!db.isPhenotypeUnique(variable, identity)) {
        // the phenotype exists
        String Message =
            " The Phenotype [V="
                + variable
                + ", I="
                + identity
                + "] already exists, cannot be created.";
        errorList.add(Message);
        nrErrors++;
      }

      // Does the individual exist?
      if (db.isIndividualUnique(identity)) {
        // the Individual does not exist
        String Message = " The Individual with " + id_or_alias + " " + ind + " does not exist.";
        errorList.add(Message);
      }

      // does variable exist?
      if (db.isVariableUnique(variable)) {
        // the variable does not exist
        String Message = " Variable " + variable + " does not exist";
        errorList.add(Message);
      }
    } catch (Exception e) {
      // Flag for error and set the errMessage if it has not been set
      e.printStackTrace(System.err);
    }
  }
コード例 #2
0
ファイル: ImportPhenotypes.java プロジェクト: bioit/crezoo
  private boolean checkValues(
      String identity, String variable, String value, String date, String ref, String comm) {
    boolean ret = true;

    if (identity == null || identity.trim().equals("")) {
      errorList.add("Unable to read Identity/Alias.");
      ret = false;
    } else if (identity.length() > 11) {
      errorList.add("Identity/Alias [" + identity + "] exceeds 11 characters.");
      ret = false;
    }

    if (variable == null || variable.trim().equals("")) {
      errorList.add("Unable to read variable.");
      ret = false;
    } else if (variable.length() > 20) {
      errorList.add("Variable [" + variable + "] exceeds 20 characters.");
      ret = false;
    }

    if (value == null || value.trim().equals("")) {
      errorList.add("Unable to read value.");
      ret = false;
    }

    if (value != null && value.length() > 20) {
      errorList.add("Value [" + value + "] exceeds 20 characters.");
      ret = false;
    }

    if (!(date == null || date.trim().equals(""))) {
      try {
        java.util.Date temp = java.sql.Date.valueOf(date);
      } catch (Exception e) {
        errorList.add("Date not in the format 'YYYY-MM-DD'");
        ret = false;
      }
    }

    if (ref != null && ref.length() > 32) {
      errorList.add("Reference [" + ref + "] exceeds 32 characters.");
      ret = false;
    }

    if (comm != null && comm.length() > 256) {
      errorList.add("Comment exceeds 256 characters.");
      ret = false;
    }
    return ret;
  }
コード例 #3
0
ファイル: ImportPhenotypes.java プロジェクト: bioit/crezoo
  /** Checks if the phenotype exists Makes certain the genotype can be updated */
  private void checkUpdate(
      String id_or_alias,
      String ind,
      String variable,
      String value,
      String date,
      String ref,
      String comm,
      int suid,
      Vector deviationMessages,
      Vector databaseValues,
      char delim) {
    // ResultSet rset;
    String identity = null;
    boolean match = false;

    try {

      // First if no IDENTITY was sent, we need to get it through alias!
      if (id_or_alias.equalsIgnoreCase("ALIAS")
          && ind != null
          && !ind.trim().equalsIgnoreCase("")) {
        identity = db.getIdentity(ind);
      } else identity = ind;

      // compare to database, does genotype exist? can it be updated..
      if (db.isPhenotypeUnique(variable, identity)) {
        String Message = "The Phenotype does not exist, cannot be updated.";
        errorList.add(Message);
      }
      // rset.close();
    } // try
    catch (Exception e) {
      // Flag for error and set the errMessage if it has not been set
      e.printStackTrace(System.err);
    }
  }