Exemple #1
0
  public Map<String, Object> update(final JsonCommand command) {
    final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(9);

    if (command.isChangeInIntegerParameterNamed(
        GroupingTypesApiConstants.statusParamName, this.status)) {
      final Integer newValue =
          command.integerValueOfParameterNamed(GroupingTypesApiConstants.statusParamName);
      actualChanges.put(
          GroupingTypesApiConstants.statusParamName, GroupingTypeEnumerations.status(newValue));
      this.status = GroupingTypeStatus.fromInt(newValue).getValue();
    }

    if (command.isChangeInStringParameterNamed(
        GroupingTypesApiConstants.externalIdParamName, this.externalId)) {
      final String newValue =
          command.stringValueOfParameterNamed(GroupingTypesApiConstants.externalIdParamName);
      actualChanges.put(GroupingTypesApiConstants.externalIdParamName, newValue);
      this.externalId = StringUtils.defaultIfEmpty(newValue, null);
    }

    if (command.isChangeInLongParameterNamed(
        GroupingTypesApiConstants.officeIdParamName, this.office.getId())) {
      final Long newValue =
          command.longValueOfParameterNamed(GroupingTypesApiConstants.officeIdParamName);
      actualChanges.put(GroupingTypesApiConstants.officeIdParamName, newValue);
    }

    if (command.isChangeInLongParameterNamed(
        GroupingTypesApiConstants.staffIdParamName, staffId())) {
      final Long newValue =
          command.longValueOfParameterNamed(GroupingTypesApiConstants.staffIdParamName);
      actualChanges.put(GroupingTypesApiConstants.staffIdParamName, newValue);
    }

    if (command.isChangeInStringParameterNamed(
        GroupingTypesApiConstants.nameParamName, this.name)) {
      final String newValue =
          command.stringValueOfParameterNamed(GroupingTypesApiConstants.nameParamName);
      actualChanges.put(GroupingTypesApiConstants.nameParamName, newValue);
      this.name = StringUtils.defaultIfEmpty(newValue, null);
    }

    final String dateFormatAsInput = command.dateFormat();
    final String localeAsInput = command.locale();

    if (command.isChangeInLocalDateParameterNamed(
        GroupingTypesApiConstants.activationDateParamName, getActivationLocalDate())) {
      final String valueAsInput =
          command.stringValueOfParameterNamed(GroupingTypesApiConstants.activationDateParamName);
      actualChanges.put(GroupingTypesApiConstants.activationDateParamName, valueAsInput);
      actualChanges.put(GroupingTypesApiConstants.dateFormatParamName, dateFormatAsInput);
      actualChanges.put(GroupingTypesApiConstants.localeParamName, localeAsInput);

      final LocalDate newValue =
          command.localDateValueOfParameterNamed(GroupingTypesApiConstants.activationDateParamName);
      this.activationDate = newValue.toDate();
    }

    return actualChanges;
  }
  public Map<String, Object> update(JsonCommand command) {
    final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(1);

    final String businessLine = "businessLine";
    final String mediaCategory = "mediaCategory";
    final String revenueShareType = "revenueShareType";

    if (command.isChangeInLongParameterNamed(businessLine, this.businessLine)) {
      final Long newValue = command.longValueOfParameterNamed(businessLine);
      actualChanges.put(businessLine, newValue);
      this.businessLine = newValue;
    }
    if (command.isChangeInLongParameterNamed(mediaCategory, this.mediaCategory)) {
      final Long newValue = command.longValueOfParameterNamed(mediaCategory);
      actualChanges.put(mediaCategory, newValue);
      this.mediaCategory = newValue;
    }
    if (command.isChangeInLongParameterNamed(revenueShareType, this.revenueShareType)) {
      final Long newValue = command.longValueOfParameterNamed(revenueShareType);
      actualChanges.put(revenueShareType, newValue);
      this.revenueShareType = newValue;
    }

    return actualChanges;
  }
Exemple #3
0
  public Map<String, Object> update(JsonCommand command) {

    final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(1);
    final String firstnameParamName = "planCode";
    if (command.isChangeInStringParameterNamed(firstnameParamName, this.planCode)) {
      final String newValue = command.stringValueOfParameterNamed(firstnameParamName);
      actualChanges.put(firstnameParamName, newValue);
      this.planCode = StringUtils.defaultIfEmpty(newValue, null);
    }
    final String descriptionParamName = "planDescription";
    if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) {
      final String newValue = command.stringValueOfParameterNamed(descriptionParamName);
      actualChanges.put(firstnameParamName, newValue);
      this.description = StringUtils.defaultIfEmpty(newValue, null);
    }
    final String provisioingSystem = "provisioingSystem";
    if (command.isChangeInStringParameterNamed(provisioingSystem, this.provisionSystem)) {
      final String newValue = command.stringValueOfParameterNamed(provisioingSystem);
      actualChanges.put(provisioingSystem, newValue);
      this.provisionSystem = StringUtils.defaultIfEmpty(newValue, null);
    }

    final String startDateParamName = "startDate";
    if (command.isChangeInLocalDateParameterNamed(
        startDateParamName, new LocalDate(this.startDate))) {
      final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName);
      actualChanges.put(startDateParamName, newValue);
      this.startDate = newValue.toDate();
    }

    final String endDateParamName = "endDate";
    if (command.isChangeInLocalDateParameterNamed(endDateParamName, new LocalDate(this.endDate))) {
      final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName);
      actualChanges.put(endDateParamName, newValue);
      if (newValue != null) this.endDate = newValue.toDate();
    }
    final String billRuleParamName = "billRule";
    if (command.isChangeInLongParameterNamed(billRuleParamName, this.billRule)) {
      final Long newValue = command.longValueOfParameterNamed(billRuleParamName);
      actualChanges.put(billRuleParamName, newValue);
      this.billRule = newValue;
    }
    final String statusParamName = "status";
    if (command.isChangeInLongParameterNamed(statusParamName, this.status)) {
      final Long newValue = command.longValueOfParameterNamed(statusParamName);
      actualChanges.put(statusParamName, newValue);
      this.status = newValue;
    }
    final boolean isPrepaid = command.booleanPrimitiveValueOfParameterNamed("isPrepaid");
    final char isPrepaidParamName = isPrepaid ? 'Y' : 'N';
    this.isPrepaid = isPrepaidParamName;

    final boolean allowTopupParamName = command.booleanPrimitiveValueOfParameterNamed("allowTopup");
    this.allowTopup = allowTopupParamName ? 'Y' : 'N';

    final boolean isHwReqParamName = command.booleanPrimitiveValueOfParameterNamed("isHwReq");
    this.isHwReq = isHwReqParamName ? 'Y' : 'N';
    return actualChanges;
  }
  public Map<String, Object> update(
      final JsonCommand command, final PlatformPasswordEncoder platformPasswordEncoder) {

    final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(7);

    // unencoded password provided
    final String passwordParamName = "password";
    final String passwordEncodedParamName = "passwordEncoded";
    if (command.hasParameter(passwordParamName)) {
      if (command.isChangeInPasswordParameterNamed(
          passwordParamName, this.password, platformPasswordEncoder, this.getId())) {
        final String passwordEncodedValue =
            command.passwordValueOfParameterNamed(
                passwordParamName, platformPasswordEncoder, this.getId());
        actualChanges.put(passwordEncodedParamName, passwordEncodedValue);
        updatePassword(passwordEncodedValue);
      }
    }

    if (command.hasParameter(passwordEncodedParamName)) {
      if (command.isChangeInStringParameterNamed(passwordEncodedParamName, this.password)) {
        final String newValue = command.stringValueOfParameterNamed(passwordEncodedParamName);
        actualChanges.put(passwordEncodedParamName, newValue);
        updatePassword(newValue);
      }
    }

    final String officeIdParamName = "officeId";
    if (command.isChangeInLongParameterNamed(officeIdParamName, this.office.getId())) {
      final Long newValue = command.longValueOfParameterNamed(officeIdParamName);
      actualChanges.put(officeIdParamName, newValue);
    }

    final String rolesParamName = "roles";
    if (command.isChangeInArrayParameterNamed(rolesParamName, getRolesAsIdStringArray())) {
      final String[] newValue = command.arrayValueOfParameterNamed(rolesParamName);
      actualChanges.put(rolesParamName, newValue);
    }

    final String usernameParamName = "username";
    if (command.isChangeInStringParameterNamed(usernameParamName, this.username)) {
      final String newValue = command.stringValueOfParameterNamed(usernameParamName);
      actualChanges.put(usernameParamName, newValue);
      this.username = newValue;
    }

    final String firstnameParamName = "firstname";
    if (command.isChangeInStringParameterNamed(firstnameParamName, this.firstname)) {
      final String newValue = command.stringValueOfParameterNamed(firstnameParamName);
      actualChanges.put(firstnameParamName, newValue);
      this.firstname = newValue;
    }

    final String lastnameParamName = "lastname";
    if (command.isChangeInStringParameterNamed(lastnameParamName, this.lastname)) {
      final String newValue = command.stringValueOfParameterNamed(lastnameParamName);
      actualChanges.put(lastnameParamName, newValue);
      this.lastname = newValue;
    }

    final String emailParamName = "email";
    if (command.isChangeInStringParameterNamed(emailParamName, this.email)) {
      final String newValue = command.stringValueOfParameterNamed(emailParamName);
      actualChanges.put(emailParamName, newValue);
      this.email = newValue;
    }

    return actualChanges;
  }