コード例 #1
0
  /**
   * @param entity
   * @param user
   * @return
   * @throws org.springframework.dao.DataAccessException
   */
  public void update(I entity, QaUser user) {

    // sanity check
    // sanity check
    Validate.notNull(user, "User cannot be null");
    Validate.notNull(entity, "Object cannot be null");

    // session
    Session session = sessionFactory.getCurrentSession();

    // prepare metadata
    QaMetadata metadata = ((QaMetaObject) entity).getMetadata();
    if (null == metadata) {
      metadata = new QaMetadata();
      metadata.setCreatedDate(new Timestamp(System.currentTimeMillis()));
      metadata.setCreator(user.getId());
      metadata.setState(QaMetaState.ACTIVE);
    }
    metadata.setModifiedDate(new Timestamp(System.currentTimeMillis()));
    metadata.setModifier(user.getId());
    ((QaMetaObject) entity).setMetadata(metadata);

    // update
    session.update(entity);
  }
コード例 #2
0
  protected void prepareMetadata(I i, QaUser user) {

    if (i instanceof QaMetaObject) {
      QaMetadata metadata = null;
      if (((QaMetaObject) i).getMetadata() != null) metadata = ((QaMetaObject) i).getMetadata();
      else metadata = new QaMetadata();
      metadata.setCreatedDate(new Timestamp(System.currentTimeMillis()));
      metadata.setCreator(user.getId());
      metadata.setState(QaMetaState.ACTIVE);
      ((QaMetaObject) i).setMetadata(metadata);
    }
  }