Example #1
0
  private ExperimentBean validateForm() {
    ExperimentBean newExp;
    if (select.getValue() == null) // new experiment
    {

      String expName = (String) expNameField.getValue();
      String expSpecies = (String) speciesField.getValue();
      String expSampleType = (String) sampleTypeField.getValue();
      String expSampleProcessing = (String) sampleProcessingField.getValue();
      String expInstrumentType = (String) instrumentTypeField.getValue();
      String expFragMode = (String) fragModeField.getValue();
      String expUploadedByName = (String) UploadedByNameField.getValue();
      String expEmail = (String) emailField.getValue();
      String expPublicationLink = (String) publicationLinkField.getValue();
      String expDescription = (String) descriptionField.getValue();

      if ((expName == null)
          || (expDescription == null)
          || (expSpecies == null)
          || (expSampleType == null)
          || (expSampleProcessing == null)
          || (expInstrumentType == null)
          || (expFragMode == null)
          || (expUploadedByName == null)
          || (expEmail == null)
          || expName.equals("")
          || expDescription.equals("")
          || expSpecies.equals("")
          || expSampleType.equals("")
          || expSampleProcessing.equals("")
          || expInstrumentType.equals("")
          || expFragMode.equals("")
          || expUploadedByName.equals("")
          || expEmail.equals("")) {
        // file didn't store in data base
        newExpForm.commit();
        newExpForm.focus();
        return null;

      } else {
        boolean checkName = false;

        for (ExperimentBean exp : expList.values()) {
          if (exp.getName().equalsIgnoreCase(expName)) {
            checkName = true;
            break;
          }
        }
        if (checkName) {
          expNameField.setValue("This Name is Not  Available Please Choose Another Name ");
          expNameField.commit();
          newExpForm.focus();
          return null;
        } else {

          newExp = new ExperimentBean();
          newExp.setName(expName);
          newExp.setSpecies(expSpecies);
          newExp.setSampleType(expSampleType);
          newExp.setSampleProcessing(expSampleProcessing);
          newExp.setInstrumentType(expInstrumentType);
          newExp.setFragMode(expFragMode);
          newExp.setUploadedByName(expUploadedByName);
          newExp.setEmail(expEmail);
          newExp.setPublicationLink(expPublicationLink);
          newExp.setExpId(-1);
          newExp.setDescription(expDescription);
          return newExp;
        }
      }
    } else // update old experiment
    {
      String str = select.getValue().toString();
      String[] strArr = str.split("\t");
      int id = (Integer.valueOf(strArr[0]));
      ExperimentBean exp = expList.get(id);
      return exp;
    }
  }