예제 #1
0
  public void update(User user, Object id, PropertyMap changes) {

    Site site = siteDAO.findById((Integer) id);

    assertSiteEditPrivileges(user, site.getDatabase(), site.getPartner());

    site.setDateEdited(new Date());

    updateSiteProperties(site, changes, false);
    updateAttributeValueProperties(site, changes, false);
    updateLocationProperties(site.getLocation(), changes);
    updateAdminProperties(site.getLocation(), changes, false);

    if (!site.getReportingPeriods().isEmpty()) {
      ReportingPeriod period = site.getReportingPeriods().iterator().next();
      updatePeriodProperties(period, changes, false);
      updateIndicatorValueProperties(period, changes, false);
    }
  }
예제 #2
0
  protected void updateSiteProperties(Site site, PropertyMap changes, boolean creating) {

    for (Map.Entry<String, Object> change : changes.entrySet()) {

      String property = change.getKey();
      Object value = change.getValue();

      if ("date1".equals(property)) {
        site.setDate1((Date) value);

      } else if ("date2".equals(property)) {
        site.setDate2((Date) value);

      } else if ("assessmentId".equals(property)) {
        site.setAssessment(siteDAO.findById((Integer) value));

      } else if ("comments".equals(property)) {
        site.setComments((String) value);

      } else if ("status".equals(property)) {
        site.setStatus((Integer) value);
      }
    }
  }