Пример #1
0
 public void saveProp(UserProperty prop) {
   if (prop.getId() != null && prop.getId().intValue() > 0) {
     merge(prop);
   } else {
     persist(prop);
   }
 }
Пример #2
0
 public void saveProp(String provider, String userPropertyName, String value) {
   UserProperty prop = getProp(provider, userPropertyName);
   if (prop == null) {
     prop = new UserProperty();
     prop.setProviderNo(provider);
     prop.setName(userPropertyName);
   }
   prop.setValue(value);
   saveProp(prop);
 }
Пример #3
0
 // Should properties be updateable?
 public void saveProp(String name, String val) {
   if (val != null) {
     UserProperty prop = getProp(name);
     if (prop == null) {
       prop = new UserProperty();
       prop.setName(name);
     }
     prop.setValue(val);
     saveProp(prop);
   }
 }
Пример #4
0
  public Map<String, String> getProviderPropertiesAsMap(String providerNo) {
    Map<String, String> map = new HashMap<String, String>();

    Query query = entityManager.createQuery("select p from UserProperty p where p.providerNo = ?");
    query.setParameter(1, providerNo);

    @SuppressWarnings("unchecked")
    List<UserProperty> list = query.getResultList();
    for (UserProperty p : list) {
      map.put(p.getName(), p.getValue());
    }
    return map;
  }
Пример #5
0
  public ActionForward saveGeneral(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response) {
    // Is there a password change?
    if (!getParameter(request, "new_password").isEmpty()) {
      try {
        changePassword(request);
      } catch (Exception e) {
        logger.error("Error", e);
      }
    }

    Iterator<Object> iter = request.getParameterMap().keySet().iterator();
    while (iter.hasNext()) {
      String key = (String) iter.next();
      if (!key.startsWith("pref.")) continue;

      String value = request.getParameter(key);

      // a couple special cases
      if (key.equals("pref." + UserProperty.ENCOUNTER_FORM_NAME)
          || key.equals("pref." + UserProperty.EFORM_NAME)) {
        String[] values = request.getParameterValues(key);
        StringBuilder sb = new StringBuilder();
        for (int x = 0; x < values.length; x++) {
          if (x > 0) sb.append(",");
          sb.append(values[x]);
        }
        value = sb.toString();
      }

      UserProperty up =
          userPropertyDao.getProp(
              LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo(), key);
      if (up != null) {
        up.setValue(value);
        userPropertyDao.saveProp(up);
      } else {
        up = new UserProperty();
        up.setProviderNo(LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo());
        up.setName(key);
        up.setValue(value);
        userPropertyDao.saveProp(up);
      }
    }

    return form(mapping, actionForm, request, response);
  }
Пример #6
0
 public void saveProperties(String providerNo, Map<String, String> props) {
   for (String key : props.keySet()) {
     String value = props.get(key);
     if (value == null) value = new String();
     UserProperty prop = null;
     if ((prop = this.getProp(providerNo, key)) != null) {
       prop.setValue(value);
     } else {
       prop = new UserProperty();
       prop.setName(key);
       prop.setProviderNo(providerNo);
       prop.setValue(value);
     }
     saveProp(prop);
   }
 }
Пример #7
0
 public ActionForward form(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response) {
   if (!inited) init();
   Map<String, String> prefs = new HashMap<String, String>();
   List<UserProperty> userProperties =
       userPropertyDao.getDemographicProperties(
           LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo());
   prefs.putAll(defaults);
   prefs.putAll(siteDefaults);
   for (UserProperty up : userProperties) {
     prefs.put(up.getName(), up.getValue());
   }
   request.setAttribute("prefs", prefs);
   return mapping.findForward("form");
 }
  public ActionForward update(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    String value = request.getParameter("value");
    Provider provider = LoggedInInfo.loggedInInfo.get().loggedInProvider;
    UserProperty prop = propertyDao.getProp(provider.getProviderNo(), "rxInteractionWarningLevel");
    if (prop == null) {
      prop = new UserProperty();
      prop.setName("rxInteractionWarningLevel");
      prop.setProviderNo(provider.getProviderNo());
    }
    prop.setValue(value);
    propertyDao.saveProp(prop);

    try {
      response.getWriter().println("ok");
    } catch (IOException e) {
      logger.error("error", e);
    }
    return null;
  }
Пример #9
0
 public void delete(UserProperty prop) {
   remove(prop.getId());
 }