Example #1
0
  public int createValueDomain(CreateValueDomain cvd) {
    ValueDomain vd = new ValueDomain();
    // to do - temporary - will change when datatype tables set up
    if (cvd.getDatatype() == "A") {
      vd.setDatatype(1);
    } else {
      vd.setDatatype(2);
    }
    vd.setAdministrativeStatus(cvd.getAdministrativestatus());
    vd.setAdminObjectType(AdminObject.adminObjectTypeValueDomain); // value domain
    vd.setClassification(cvd.getClassification());
    vd.setClassifiedby(cvd.getClassifiedby());
    vd.setCreatedby(cvd.getSubmittedby());
    vd.setCreatedOn(new Date());
    vd.setDateFirstActive(new Date());
    if (cvd.getEnumerated() == "true") {
      vd.setEnumerated(true);
    } else {
      vd.setEnumerated(false);
    }

    vd.setFormat(cvd.getFormat());
    // to do - temporary - will change when permissible value tables set up
    if (cvd.getPermissiblevalue() == "A") {
      vd.setPermissiblevalue(1);
    } else if (cvd.getPermissiblevalue() == "B") {
      vd.setPermissiblevalue(2);
    } else {
      vd.setPermissiblevalue(3);
    }

    // to do - temporary - will change when unit of measure  tables set up
    if (cvd.getUnitofmeasure() == "A") {
      vd.setUnitofmeasure(1);
    } else if (cvd.getUnitofmeasure() == "B") {
      vd.setUnitofmeasure(2);
    } else {
      vd.setUnitofmeasure(3);
    }

    vd.setLastModifiedby(cvd.getSubmittedby());
    vd.setLastModifiedOn(new Date());

    vd.setRegisteredOn(new Date());

    vd.setSubmittedby(cvd.getSubmittedby());
    String term = cvd.getTerm();
    String tmDesc = "Value Domain";

    Term newTerm = searchTerm(term);
    if (newTerm == null) {
      newTerm = createTerm(term, tmDesc);
    }
    vd.setTerm(newTerm);
    vd.setTermid(newTerm.getId());

    vd.setComments(cvd.getComments());
    vd.setFormat(cvd.getFormat());
    vd.setAdministeredby(cvd.getAdministeredby());
    vd.setRegisteredby(cvd.getRegisteredby());
    vd.setRegistrationStatus(cvd.getRegistrationstatus());

    int ref = vdDao.createValueDomain(vd);
    return ref;
  }