UpdateDetailsFillerExpander

Expands:


    $componentRoot.directory$/$artifactSubFolders$/$dataElement.packageName;format="toPath"$/command/$dataElement.name;format="firstToLower"$/filler
  /Update$dataElement.name$Filler.java

if:

dataElement.component.getOption('enableJaxrs').defined and
    dataElement.getOption('includeJaxrsConnector').defined and
    dataElement.getOption('exposePatchEndpoint').defined and
    !dataElement.dataCommands.{^ #this.name.equals('update' + dataElement.name) }.empty
property value
element type DataElement
qualified name net.democritus.expander.rest.logic.command.filler.UpdateDetailsFillerExpander
layer LOGIC_LAYER
technology EJB3
sourceType JAVA
phase expansion
features  

Example

Some example of the content generated by the expander:

// expanded with nsx-expanders:4.16.3, expansionResource net.democritus:rest-expanders:2.4.2
package com.example.city.command.city.filler;

import cities.command.CustomCommandResult;

import com.example.city.CityCommand;
import com.example.city.CityDetails;
import com.example.CountryFindByCodeEqDetails;
import com.example.CountryLocalAgent;

import net.democritus.sys.Context;
import net.democritus.sys.DataRef;
import net.democritus.sys.DiagnosticFactory;
import net.democritus.sys.SearchResult;
import net.democritus.sys.search.SearchDetails;

// @anchor:imports:start
// @anchor:imports:end
// anchor:custom-imports:start
// anchor:custom-imports:end

public class UpdateCityFiller {

  private final DiagnosticFactory diagnosticFactory = new DiagnosticFactory("cities", "City");
  private final Context context;

  // @anchor:fields:start
  // @anchor:fields:end
  // anchor:custom-fields:start
  // anchor:custom-fields:end

  public UpdateCityFiller(Context context) {
    this.context = context;
  }

  public CustomCommandResult fill(CityDetails cityDetails, CityCommand.UpdateCity command) {
    if (command.getName() != null) {
      cityDetails.setName(command.getName());
    }
    if (command.getPostalCode() != null) {
      cityDetails.setPostalCode(command.getPostalCode());
    }
    CustomCommandResult countryResult = fillCountry(cityDetails, command);
    if (countryResult.isError()) {
      return countryResult;
    }

    // @anchor:fill:start
    // @anchor:fill:end
    // anchor:custom-fill:start
    // anchor:custom-fill:end

    return CustomCommandResult.success(command.getCommandId());
  }

  public CustomCommandResult fillCountry(CityDetails cityDetails, CityCommand.UpdateCity command) {
    if (command.getCountry() == null) {
      return CustomCommandResult.success(command.getCommandId());
    }

    CountryFindByCodeEqDetails finder = new CountryFindByCodeEqDetails();
    finder.setCode(command.getCountry());
    SearchDetails<CountryFindByCodeEqDetails> searchDetails = SearchDetails.fetchNDataRef(finder, 1);
    SearchResult<DataRef> searchResult = CountryLocalAgent.getCountryAgent(context).find(searchDetails);

    if (searchResult.isError()) {
      return CustomCommandResult.customError(command.getCommandId(), searchResult.getDiagnostics());
    }
    if (searchResult.getFirst().isEmpty()) {
      return CustomCommandResult.customError(command.getCommandId(), diagnosticFactory.error("City.country.findFailed"));
    }
    cityDetails.setCountry(searchResult.getFirst().getValue());

    // @anchor:fill-country:start
    // @anchor:fill-country:end
    // anchor:custom-fill-country:start
    // anchor:custom-fill-country:end

    return CustomCommandResult.success(command.getCommandId());
  }

  // @anchor:methods:start
  // @anchor:methods:end
  // anchor:custom-methods:start
  // anchor:custom-methods:end

}

These expanders have the same isApplicable as UpdateDetailsFillerExpander.