Esempio n. 1
0
  public String findByUserAndKey(User user, String key) {
    UserVariableKeyDAO variableKeyDAO = DAOFactory.getInstance().getUserVariableKeyDAO();

    UserVariableKey userVariableKey = variableKeyDAO.findByVariableKey(key);
    if (userVariableKey != null) {
      UserVariable userVariable = findByUserAndVariableKey(user, userVariableKey);
      return userVariable == null ? null : userVariable.getValue();
    } else {
      throw new PersistenceException("Unknown VariableKey");
    }
  }
Esempio n. 2
0
  private UserVariable create(User user, UserVariableKey key, String value) {
    EntityManager entityManager = getEntityManager();

    UserVariable userVariable = new UserVariable();
    userVariable.setUser(user);
    userVariable.setKey(key);
    userVariable.setValue(value);
    entityManager.persist(userVariable);

    user.getVariables().add(userVariable);
    entityManager.persist(user);

    return userVariable;
  }
Esempio n. 3
0
 private void updateValue(UserVariable userVariable, String value) {
   EntityManager entityManager = getEntityManager();
   userVariable.setValue(value);
   entityManager.persist(userVariable);
 }