コード例 #1
0
  void updateService(ExternalEvent event, Map<String, Object> serviceData) {
    Service svc = serviceDao.getServiceByExternalId(event.getAccountId(), event.getExternalId());
    if (svc == null) {
      log.info(
          "Unable to find service while attempting to update. Returning. Service external id: [{}], account id: [{}]",
          event.getExternalId(),
          event.getAccountId());
      return;
    }

    Map<String, Object> fields = DataUtils.getFields(svc);
    Map<String, Object> updates = new HashMap<String, Object>();
    for (Map.Entry<String, Object> resourceField : serviceData.entrySet()) {
      String fieldName = resourceField.getKey();
      Object newFieldValue = resourceField.getValue();
      Object currentFieldValue = fields.get(fieldName);
      if (ObjectUtils.hasWritableProperty(svc, fieldName)) {
        Object property = ObjectUtils.getProperty(svc, fieldName);
        if (newFieldValue != null && !newFieldValue.equals(property) || property == null) {
          updates.put(fieldName, newFieldValue);
        }
      } else if ((newFieldValue != null && !newFieldValue.equals(currentFieldValue))
          || currentFieldValue != null) {
        updates.put(fieldName, newFieldValue);
      }
    }

    if (!updates.isEmpty()) {
      objectManager.setFields(svc, updates);
      resourceDao.updateAndSchedule(svc);
    }
  }
コード例 #2
0
  private void deactivateThenRemove(ProjectMember member) {
    Object state = ObjectUtils.getPropertyIgnoreErrors(member, ObjectMetaDataManager.STATE_FIELD);

    if (CommonStatesConstants.ACTIVE.equals(state)) {
      objectProcessManager.executeStandardProcess(StandardProcess.DEACTIVATE, member, null);
      member = objectManager.reload(member);
    }

    if (CommonStatesConstants.PURGED.equals(state)) {
      return;
    }

    objectProcessManager.executeStandardProcess(StandardProcess.REMOVE, member, null);
  }