ElementCommonDataValidatorExpander

Expands:


    $componentRoot.directory$/$artifactSubFolders$/$dataElement.packageName;format="toPath"$/validation/$dataElement.name;format="firstToLower"$
  /$dataElement.name$CommonDataValidator.java

if:

dataElement.component.getOption('enableJaxrs').defined and
    dataElement.component.getOption('enableValidation').defined and
    dataElement.component.getOption('enableJaxrs').defined and
    dataElement.getOption('includeJaxrsConnector').defined
property value
element type DataElement
qualified name net.democritus.expander.rest.logic.validation.ElementCommonDataValidatorExpander
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 net.animals.validation.catBreed;

import animals.validation.DatabaseValidator;

import net.animals.CatBreedDataRef;
import net.animals.CatBreedLocalAgent;
import net.animals.query.CatBreedQueryFilter;

import net.democritus.sys.Context;
import net.democritus.sys.SearchResult;
import net.democritus.sys.search.SearchDetails;
import net.palver.util.Options;

// anchor:nullability-imports:start
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
// anchor:nullability-imports:end

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

public class CatBreedCommonDataValidator {

  @NotNull
  private final Context context;
  @NotNull
  private final DatabaseValidator databaseValidator;

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

  public CatBreedCommonDataValidator(@NotNull Context context, @NotNull DatabaseValidator databaseValidator) {
    this.context = context;
    this.databaseValidator = databaseValidator;
  }

  @NotNull
  public Options.Option<CatBreedDataRef> validateCatBreedExists(@NotNull String catBreedId) {
    if (catBreedId.isEmpty()) {
      return Options.none();
    }

    CatBreedQueryFilter filter = new CatBreedQueryFilter();
    filter.setCatBreedId(catBreedId);
    SearchDetails<CatBreedQueryFilter> searchDetails = SearchDetails.fetchNDataRef(filter, 1);
    SearchResult<CatBreedDataRef> result = CatBreedLocalAgent.getCatBreedAgent(context).querySearch(searchDetails);

    return databaseValidator.existsDataRef(result, "catBreedId");
  }

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

}