private void addNonPreferredNameButtonActionPerformed() {
    Names namesModel = (Names) this.getModel();
    NonPreferredNames newNonPreferredName;
    DomainEditor dialogNonPreferredNames = null;
    try {
      dialogNonPreferredNames =
          DomainEditorFactory.getInstance()
              .createDomainEditorWithParent(NonPreferredNames.class, this.getParentEditor(), false);
    } catch (DomainEditorCreationException e) {
      new ErrorDialog(getParentEditor(), "Error creating editor for NonPreferredNames", e)
          .showDialog();
    }
    dialogNonPreferredNames.setNewRecord(true);

    int returnStatus;
    Boolean done = false;
    while (!done) {
      newNonPreferredName = new NonPreferredNames(namesModel);
      newNonPreferredName.setNameType(namesModel.getNameType());
      dialogNonPreferredNames.setModel(newNonPreferredName, null);
      returnStatus = dialogNonPreferredNames.showDialog();
      if (returnStatus == JOptionPane.OK_OPTION) {
        namesModel.addNonPreferredName(newNonPreferredName);
        nonPreferredNamesTable.getEventList().add(newNonPreferredName);
        done = true;
      } else if (returnStatus == StandardEditor.OK_AND_ANOTHER_OPTION) {
        namesModel.addNonPreferredName(newNonPreferredName);
        nonPreferredNamesTable.getEventList().add(newNonPreferredName);
      } else {
        done = true;
      }
    }
  }
  private void addNote(String whereString) {

    Names namesModel = (Names) super.getModel();
    NameContactNotes newNote;
    DomainEditor dialog = null;
    try {
      dialog =
          DomainEditorFactory.getInstance()
              .createDomainEditorWithParent(NameContactNotes.class, this.getParentEditor(), false);
    } catch (DomainEditorCreationException e) {
      new ErrorDialog(getParentEditor(), "Error creating editor for NameContactNotes", e)
          .showDialog();
    }
    dialog.setNewRecord(true);
    Boolean done = false;
    int sequenceNumber = 0;
    Boolean first = true;
    int returnStatus;

    while (!done) {
      newNote = new NameContactNotes(namesModel);
      if (first) {
        sequenceNumber =
            SequencedObjectsUtils.determineSequenceOfNewItem(whereString, nameContactNotesTable);
        first = false;
      } else {
        sequenceNumber++;
      }
      newNote.setSequenceNumber(sequenceNumber);
      dialog.setModel(newNote, null);
      returnStatus = dialog.showDialog();
      if (returnStatus == javax.swing.JOptionPane.OK_OPTION) {
        namesModel.addNameContactNote(newNote);
        nameContactNotesTable.getEventList().add(newNote);
        done = true;
      } else if (returnStatus == StandardEditor.OK_AND_ANOTHER_OPTION) {
        namesModel.addNameContactNote(newNote);
        nameContactNotesTable.getEventList().add(newNote);
      } else {
        done = true;
      }
    }
    dialog.setNewRecord(false);
  }
  /**
   * Sets the model for this editor.
   *
   * @param model the model to be used
   */
  public final void setModel(final DomainObject model, InfiniteProgressPanel progressPanel) {
    super.setModel(model, progressPanel);

    Names namesModel = (Names) model;
    resourcesTable.updateCollection(namesModel.getResources());
    accessionsTable.updateCollection(namesModel.getAccessions());
    digitalObjectsTable.updateCollection(namesModel.getDigitalObjects());
    nameContactNotesTable.updateCollection(namesModel.getRelatedCollection(NameContactNotes.class));
    nonPreferredNamesTable.updateCollection(
        namesModel.getRelatedCollection(NonPreferredNames.class));

    setPluginModel(); // update any plugins with this new domain object
  }
Пример #4
0
  private Names lookupName(NamesDAO namesDao, NameComplexType nameFromImport)
      throws IllegalAccessException, InvocationTargetException, UnknownLookupListException,
          PersistenceException, NoSuchAlgorithmException, UnsupportedEncodingException {
    Names name = new Names();
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_NAME_TYPE, nameFromImport.getNameType());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_SORT_NAME, nameFromImport.getSortName());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_NAME_RULE, nameFromImport.getNameRule());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_NUMBER, nameFromImport.getNumber());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_QUALIFIER, nameFromImport.getQualifier());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_DESCRIPTION_TYPE, nameFromImport.getDescriptionType());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_DESCRIPTION_NOTE, nameFromImport.getDescriptionNote());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_CITATION, nameFromImport.getCitation());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_SALUTATION, nameFromImport.getSalutation());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_CONTACT_ADDRESS_1, nameFromImport.getContactAddress1());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_CONTACT_ADDRESS_2, nameFromImport.getContactAddress2());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_CONTACT_CITY, nameFromImport.getContactCity());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_CONTACT_REGION, nameFromImport.getContactRegion());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_CONTACT_COUNTRY, nameFromImport.getContactCountry());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_CONTACT_MAIL_CODE, nameFromImport.getContactMailCode());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_CONTACT_PHONE, nameFromImport.getContactPhone());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_CONTACT_FAX, nameFromImport.getContactFax());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_CONTACT_EMAIL, nameFromImport.getContactEmail());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_CONTACT_NAME, nameFromImport.getContactName());
    ImportUtils.nullSafeSet(name, Names.PROPERTYNAME_FAMILY_NAME, nameFromImport.getFamilyName());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_FAMILY_NAME_PREFIX, nameFromImport.getFamilyNamePrefix());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_CORPORATE_PRIMARY_NAME, nameFromImport.getCorporatePrimaryName());
    ImportUtils.nullSafeSet(
        name,
        Names.PROPERTYNAME_CORPORATE_SUBORDINATE_1,
        nameFromImport.getCorporateSubordinate1());
    ImportUtils.nullSafeSet(
        name,
        Names.PROPERTYNAME_CORPORATE_SUBORDINATE_2,
        nameFromImport.getCorporateSubordinate2());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_PERSONAL_PRIMARY_NAME, nameFromImport.getPersonalPrimaryName());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_PERSONAL_REST_OF_NAME, nameFromImport.getPersonalRestOfName());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_PERSONAL_PREFIX, nameFromImport.getPersonalPrefix());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_PERSONAL_SUFFIX, nameFromImport.getPersonalSuffix());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_PERSONAL_FULLER_FORM, nameFromImport.getPersonalFullerForm());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_PERSONAL_TITLE, nameFromImport.getPersonalTitle());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_PERSONAL_DATES, nameFromImport.getPersonalDates());
    ImportUtils.nullSafeSet(
        name, Names.PROPERTYNAME_PERSONAL_DIRECT_ORDER, nameFromImport.isPersonalDirectOrder());
    if (nameFromImport.getNameSource() == null) {
      name.setNameSource("ingest");
    } else {
      name.setNameSource(nameFromImport.getNameSource());
    }
    if (name.getSortName() == null || name.getSortName().length() == 0) {
      name.createSortName();

      // check to see if sort name is still empty. If so, set it to " " so that
      // this record can be inserted into an Oracle DB without throwing an error
      if (name.getSortName().length() == 0) {
        name.setSortName(" ");
      }
    }
    NameUtils.setMd5Hash(name);

    return namesDao.lookupName(name, true);
  }