Ejemplo n.º 1
0
 public AbstractPerson getPerson(final long inItemID) throws BOMException {
   try {
     final KeyObject lKey = new KeyObjectImpl();
     lKey.setValue(KEY_ID, new Long(inItemID));
     return (AbstractPerson) findByKey(lKey);
   } catch (final VException exc) {
     throw new BOMException(exc.getMessage());
   }
 }
Ejemplo n.º 2
0
 @Override
 public void deleteItem(final long inItemID) throws BOMException {
   try {
     final KeyObject lKey = new KeyObjectImpl();
     lKey.setValue(KEY_ID, new Long(inItemID));
     delete(lKey, true);
   } catch (final VException exc) {
     throw new BOMException(exc.getMessage());
   } catch (final SQLException exc) {
     throw new BOMException(exc.getMessage());
   }
 }
Ejemplo n.º 3
0
  /**
   * Create a new person entry in the database and returns the new item.
   *
   * @param inName String
   * @param inFirstname String
   * @param inFrom String
   * @param inTo String
   * @param inText String
   * @return Person
   * @throws BOMException
   */
  public AbstractPerson newPerson(
      final String inName,
      final String inFirstname,
      final String inFrom,
      final String inTo,
      final String inText)
      throws BOMException {
    try {
      final Timestamp lCreated = new Timestamp(System.currentTimeMillis());
      final Person outPerson = (Person) create();
      outPerson.set(PersonHome.KEY_NAME, inName);
      outPerson.set(PersonHome.KEY_FIRSTNAME, inFirstname);
      outPerson.set(PersonHome.KEY_FROM, inFrom);
      outPerson.set(PersonHome.KEY_TO, inTo);
      outPerson.set(PersonHome.KEY_TEXT, inText);
      outPerson.set(KEY_CREATED, lCreated);
      outPerson.set(KEY_MODIFIED, lCreated);

      final Long lID = outPerson.insert(true);
      outPerson.set(KEY_ID, lID);
      // final KeyObject lKey = new KeyObjectImpl();
      // lKey.setValue(KEY_ID, new BigDecimal(lID.doubleValue()));
      // outPerson = (Person) findByKey(lKey);

      // index person
      getIndexer().addToIndex(outPerson);

      return outPerson;
    } catch (final VException exc) {
      throw new BOMException(exc.getMessage());
    } catch (final IOException exc) {
      throw new BOMException(exc.getMessage());
    } catch (final SQLException exc) {
      if (AbstractItem.TRUNCATION_STATE.equals(exc.getSQLState())) {
        throw new BOMTruncationException(AbstractItem.TRUNCATION_MSG);
      }
      throw new BOMException(exc.getMessage());
    }
  }