@Override public int insertAction(ActionVO<Integer, Integer> action, boolean useDateFromVO) { if (logger.isTraceEnabled()) { logger.trace("inserting action=" + action); } // validate non-empty fields (NOT NULL) validateNonEmptyFields(action, useDateFromVO); Object[] args = {action.getTenant(), action.getUser(), action.getSessionId(), action.getIp(), ((action.getItem() != null) ? action.getItem().getItem() : null), ((action.getItem() != null) ? action.getItem().getType() : null), action.getActionType(), action.getRatingValue(), action.getSearchSucceeded(), action.getNumberOfFoundItems(), action.getDescription(), ((useDateFromVO && action.getActionTime() != null) ? action.getActionTime() : new Date(System.currentTimeMillis()))}; KeyHolder keyHolder = new GeneratedKeyHolder(); int rowsAffected = getJdbcTemplate().update(PS_INSERT_ACTION.newPreparedStatementCreator(args), keyHolder); // retrieve auto increment id, and set to VO action.setId(keyHolder.getKey().intValue()); return rowsAffected; }
@Override public ActionVO<Integer, String> convertActionVO(Integer tenantId, ActionVO<Integer, Integer> action) { if (action == null) { return null; } return new ActionVO<Integer, String>( action.getId(), action.getTenant(), action.getUser(), action.getSessionId(), action.getIp(), convertItemVO(tenantId, action.getItem()), actionTypeDAO.getTypeById(tenantId, action.getActionType()), action.getRatingValue(), action.getSearchSucceeded(), action.getNumberOfFoundItems(), action.getDescription(), action.getActionTime()); }
@Override public ActionVO<Integer, Integer> convertTypedActionVO(Integer tenantId, ActionVO<Integer, String> typedAction) { if (typedAction == null) { return null; } return new ActionVO<Integer, Integer>( typedAction.getId(), typedAction.getTenant(), typedAction.getUser(), typedAction.getSessionId(), typedAction.getIp(), convertTypedItemVO(tenantId, typedAction.getItem()), actionTypeDAO.getIdOfType(tenantId, typedAction.getActionType()), typedAction.getRatingValue(), typedAction.getSearchSucceeded(), typedAction.getNumberOfFoundItems(), typedAction.getDescription(), typedAction.getActionTime()); }