示例#1
0
  protected void updateLocationProperties(Location location, PropertyMap changes) {

    boolean isAdminBound = location.getLocationType().getBoundAdminLevel() != null;

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

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

      if (!isAdminBound && "locationName".equals(property)) {
        location.setName((String) value);

      } else if ("locationAxe".equals(property)) {
        location.setAxe((String) value);

      } else if ("x".equals(property)) {
        location.setX((Double) value);

      } else if ("y".equals(property)) {
        location.setY((Double) changes.get("y"));

      } else if (isAdminBound
          && AdminLevelDTO.getPropertyName(location.getLocationType().getBoundAdminLevel().getId())
              .equals(property)) {

        location.setName(adminDAO.findById(((AdminEntityDTO) value).getId()).getName());
      }
    }
  }
示例#2
0
  protected void updateAdminProperties(Location location, PropertyMap changes, boolean creating) {

    for (Map.Entry<String, Object> change : changes.entrySet()) {
      String property = change.getKey();
      Object value = change.getValue();

      if (property.startsWith(AdminLevelDTO.PROPERTY_PREFIX)) {

        int levelId = AdminLevelDTO.levelIdForPropertyName(property);
        AdminEntityDTO entity = (AdminEntityDTO) value;

        if (creating) {
          if (entity != null) {
            locationDAO.addAdminMembership(location.getId(), entity.getId());
          }
        } else {
          if (entity != null) {
            locationDAO.updateAdminMembership(location.getId(), levelId, entity.getId());
          } else {
            locationDAO.removeMembership(location.getId(), levelId);
          }
        }
      }
    }
  }
示例#3
0
  protected void updateAttributeValueProperties(Site site, PropertyMap changes, boolean creating) {

    Map<Integer, Boolean> attributeValues = new HashMap<Integer, Boolean>();

    for (Map.Entry<String, Object> change : changes.entrySet()) {
      if (change.getKey().startsWith(AttributeDTO.PROPERTY_PREFIX)) {
        attributeValues.put(
            AttributeDTO.idForPropertyName(change.getKey()), (Boolean) change.getValue());
      }
    }
    if (!attributeValues.isEmpty()) {
      siteDAO.updateAttributeValues(site.getId(), attributeValues);
    }
  }
示例#4
0
  protected void updatePeriodProperties(
      ReportingPeriod period, PropertyMap changes, boolean creating) {
    for (Map.Entry<String, Object> change : changes.entrySet()) {

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

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

      } else if ("date2".equals(property)) {
        period.setDate2((Date) value);
      }
    }
  }
示例#5
0
  protected void updateIndicatorValueProperties(
      ReportingPeriod period, PropertyMap changes, boolean creating) {

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

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

      if (property.startsWith(IndicatorDTO.PROPERTY_PREFIX)) {

        int indicatorId = IndicatorDTO.indicatorIdForPropertyName(property);

        if (creating) {
          if (value != null) {
            reportingPeriodDAO.addIndicatorValue(period.getId(), indicatorId, (Double) value);
          }
        } else {
          reportingPeriodDAO.updateIndicatorValue(period.getId(), indicatorId, (Double) value);
        }
      }
    }
  }
示例#6
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);
      }
    }
  }