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);
    }
  }
  /**
   * @param entity
   * @param user
   */
  public void remove(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();
    metadata.setState(QaMetaState.INACTIVE);
    metadata.setDeletedDate(new Timestamp(System.currentTimeMillis()));
    metadata.setDeleter(user.getId());
    ((QaMetaObject) entity).setMetadata(metadata);

    // update
    session.update(entity);
  }
  /**
   * @param entity
   * @param user
   * @return
   * @throws org.springframework.dao.DataAccessException
   */
  public void deactivate(I entity, QaUser user) {
    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.setModifiedDate(new Timestamp(System.currentTimeMillis()));
    metadata.setModifier(user.getId());
    metadata.setState(QaMetaState.INACTIVE);
    ((QaMetaObject) entity).setMetadata(metadata);

    // update
    session.update(entity);
  }