Class DataModelGenerator

java.lang.Object
com.sap.cloud.sdk.datamodel.odatav4.generator.DataModelGenerator

public class DataModelGenerator extends Object
Builder for the ODataToVdmGenerator, gathering all relevant parameter or providing default values for unspecified ones.
  • Field Details

    • DEFAULT_INPUT_DIRECTORY_NAME

      public static final String DEFAULT_INPUT_DIRECTORY_NAME
      The default directory name to search and save configuration data in.
      See Also:
    • DEFAULT_OUTPUT_DIRECTORY_NAME

      public static final String DEFAULT_OUTPUT_DIRECTORY_NAME
      The default directory name to store the generated sources in.
      See Also:
    • DEFAULT_DELETE_OUTPUT_DIRECTORY

      public static final Boolean DEFAULT_DELETE_OUTPUT_DIRECTORY
      The default flag indicating whether the output directory should be deleted prior to the generation.
    • DEFAULT_OVERWRITE_FILES

      public static final Boolean DEFAULT_OVERWRITE_FILES
      The default flag indicating whether already existing files should be overwritten. If false, an exception is thrown if a file already exists.
    • DEFAULT_KEEP_EXISTING_SIGNATURES

      public static final boolean DEFAULT_KEEP_EXISTING_SIGNATURES
      The default flag indicating that existing signatures from already generated classes will be considered.
      See Also:
    • DEFAULT_PACKAGE_NAME

      public static final String DEFAULT_PACKAGE_NAME
      The default package prefix of the generated sources.
      See Also:
    • DEFAULT_BASE_PATH

      public static final String DEFAULT_BASE_PATH
      The default base path, used in absence of a swagger file to determine a service path.
    • DEFAULT_SERVICE_NAME_MAPPING_FILE_NAME

      public static final String DEFAULT_SERVICE_NAME_MAPPING_FILE_NAME
      The default file name to the name mapping properties file.
      See Also:
    • DEFAULT_NAMING_STRATEGY

      public static final String DEFAULT_NAMING_STRATEGY
      The default fully-qualified name of the class to use for converting names from the OData world to the Java world.
      See Also:
    • DEFAULT_ANNOTATION_STRATEGY

      public static final String DEFAULT_ANNOTATION_STRATEGY
      The default fully-qualified name of the class to use for providing generated Java classes with necessary annotations.
      See Also:
    • DEFAULT_NAMING_SOURCE

      public static final NameSource DEFAULT_NAMING_SOURCE
      The default naming source used in the S4HanaNamingStrategy.
    • DEFAULT_POJOS_ONLY

      public static final Boolean DEFAULT_POJOS_ONLY
      The default flag indicating whether to generate just the POJO classes (entities and complex types).
    • DEFAULT_EXCLUDES_PATTERN

      public static final String DEFAULT_EXCLUDES_PATTERN
      The default ant style pattern of filenames for which VDM should not be generated - empty string.
      See Also:
    • DEFAULT_FAIL_ON_WARNING

      public static final Boolean DEFAULT_FAIL_ON_WARNING
      The default flag indicating whether to exit with a failure in case a warning occurs.
    • DEFAULT_VERSION_REFERENCE

      public static final Boolean DEFAULT_VERSION_REFERENCE
      The default flag indicating whether to skip generating comments indicating the version reference of the used OData generator plugin.
    • DEFAULT_SERVICE_METHODS_PER_ENTITY_SET

      public static final Boolean DEFAULT_SERVICE_METHODS_PER_ENTITY_SET
      By default the generator generates service methods for the first entity set per entity type only. All additional entity sets of for the entity type are disregarded.
  • Constructor Details

    • DataModelGenerator

      public DataModelGenerator()
  • Method Details

    • withInputDirectory

      @Nonnull public DataModelGenerator withInputDirectory(@Nonnull String inputDirectory)
      Path to the input directory that contains the service definition files.
      Parameters:
      inputDirectory - The directory to read the service data from.
      Returns:
      This DataModelGenerator for chained method calls.
    • withInputDirectory

      @Nonnull public DataModelGenerator withInputDirectory(@Nonnull File inputDirectory)
      Input directory that contains the service definition files.
      Parameters:
      inputDirectory - The directory to read the service data from.
      Returns:
      This DataModelGenerator for chained method calls.
    • withOutputDirectory

      @Nonnull public DataModelGenerator withOutputDirectory(@Nonnull String outputDirectory)
      Path to the output directory to store the generated sources in.

      The generated sources will be stored under this directory according to the packages specified.

      Parameters:
      outputDirectory - The path to the root directory to store the generated sources in.
      Returns:
      This DataModelGenerator for chained method calls.
    • withOutputDirectory

      @Nonnull public DataModelGenerator withOutputDirectory(@Nonnull File outputDirectory)
      Output directory to store the generated sources in.

      The generated sources will be stored under this directory according to the packages specified.

      Parameters:
      outputDirectory - The root directory to store the generated sources in.
      Returns:
      This DataModelGenerator for chained method calls.
    • deleteOutputDirectory

      @Nonnull public DataModelGenerator deleteOutputDirectory()
      Deletes the output directory specified by withPackageName(String) prior to generating the sources.

      This option should be used to determine the whole change set, including deleted files.

      Returns:
      This DataModelGenerator for chained method calls.
    • deleteOutputDirectory

      @Nonnull public DataModelGenerator deleteOutputDirectory(boolean deleteOutputDirectory)
      Defines whether to delete the output directory specified by withPackageName(String) prior to generating the sources.

      This option should be used to determine the whole change set, including deleted files.

      Parameters:
      deleteOutputDirectory - Flag indicating whether the output directory should be cleaned.
      Returns:
      This DataModelGenerator for chained method calls.
    • overwriteFiles

      @Nonnull public DataModelGenerator overwriteFiles()
      Defines that already existing files will get overwritten. Otherwise, an exception is thrown if a file already exists.
      Returns:
      This DataModelGenerator for chained method calls.
    • overwriteFiles

      @Nonnull public DataModelGenerator overwriteFiles(boolean overwriteFiles)
      Defines whether already existing files will get overwritten. If false, an exception is thrown if a file already exists.
      Parameters:
      overwriteFiles - Flag indicating whether already existing files can be overwritten.
      Returns:
      This DataModelGenerator for chained method calls.
    • keepExistingSignatures

      @Nonnull public DataModelGenerator keepExistingSignatures(boolean keepExistingSignatures)
      Defines whether existing signatures from already generated classes will be considered when generating again. If true, breaking changes in method signature will be avoided, when the argument order in OData specification was altered.
      Parameters:
      keepExistingSignatures - Flag indicating whether already generated classes will be considered.
      Returns:
      This DataModelGenerator for chained method calls.
    • withPackageName

      @Nonnull public DataModelGenerator withPackageName(@Nonnull String packageName)
      Specifies the package prefix to be used in the generated sources.
      Parameters:
      packageName - The package prefix for the generated sources.
      Returns:
      This DataModelGenerator for chained method calls.
    • withDefaultBasePath

      @Nonnull public DataModelGenerator withDefaultBasePath(@Nullable String defaultBasePath)
      Specifies the default base path.

      If no swagger file is given, this base path, together with the metadata file name, constitute the service path with the following pattern: <defaultBasePath> + <metadataFileNameWithoutExtension>.

      Parameters:
      defaultBasePath - The default base path.
      Returns:
      This DataModelGenerator for chained method calls.
    • withServiceNameMapping

      @Nonnull public DataModelGenerator withServiceNameMapping(@Nonnull File serviceNameMappingFile)
      The properties file containing the service name mapping.

      Any service not mapped in this file will get created/updated.

      Parameters:
      serviceNameMappingFile - The file to read/set the service name mappings in.
      Returns:
      This DataModelGenerator for chained method calls.
    • withServiceNameMapping

      @Nonnull public DataModelGenerator withServiceNameMapping(@Nonnull String serviceNameMappingFile)
      The path to the properties file containing the service name mapping.

      Any service not mapped in this file will get created/updated.

      Parameters:
      serviceNameMappingFile - The file to read/set the service name mappings in.
      Returns:
      This DataModelGenerator for chained method calls.
    • withNamingStrategy

      @Nonnull public DataModelGenerator withNamingStrategy(@Nonnull NamingStrategy namingStrategy)
      Sets the class to use to convert OData names into suitable Java names.
      Parameters:
      namingStrategy - Instance of a class, which must either implement the CodeNamingStrategy interface, or extend a class which implements this interface.
      Returns:
      This DataModelGenerator for chained method calls.
    • withNamingStrategy

      @Nonnull public DataModelGenerator withNamingStrategy(@Nonnull String namingStrategyClassName)
      Sets the class to use to convert OData names into suitable Java names.
      Parameters:
      namingStrategyClassName - Fully-qualified name of a class, which must either implement the NamingStrategy interface, or extend a class which implements this interface.
      Returns:
      This DataModelGenerator for chained method calls.
    • withNameSource

      @Nonnull public DataModelGenerator withNameSource(@Nonnull NameSource nameSource)
      Getter for the given NameSource.

      If the namingStrategy is S4HanaNamingStrategy, this enum will be used to determine the actual source of the java name.

      Parameters:
      nameSource - The NameSource to be used by the DefaulNamingStrategy.
      Returns:
      This DataModelGenerator for chained method calls.
    • withAnnotationStrategy

      @Nonnull public DataModelGenerator withAnnotationStrategy(@Nonnull AnnotationStrategy annotationStrategy)
      Sets the class to use to provide generated Java classes with necessary annotations.
      Parameters:
      annotationStrategy - Instance of a class, which must either implement the AnnotationStrategy interface, or extend a class which implements this interface.
      Returns:
      This DataModelGenerator for chained method calls.
    • withAnnotationStrategy

      @Nonnull public DataModelGenerator withAnnotationStrategy(@Nonnull String annotationStrategyClassName)
      Sets the class to use to provide generated Java classes with necessary annotations.
      Parameters:
      annotationStrategyClassName - Fully-qualified name of a class, which must either implement the AnnotationStrategy interface, or extend a class which implements this interface.
      Returns:
      This DataModelGenerator for chained method calls.
    • failOnWarning

      @Nonnull public DataModelGenerator failOnWarning(boolean failOnWarning)
      Defines whether to exit with failure in case a warning occurs during processing.
      Parameters:
      failOnWarning - Flag indicating whether to generate just the POJO classes.
      Returns:
      This DataModelGenerator for chained method calls.
    • failOnWarning

      @Nonnull public DataModelGenerator failOnWarning()
      The generator exists with failure in case a warning occurs during processing.
      Returns:
      This DataModelGenerator for chained method calls.
    • pojosOnly

      @Nonnull public DataModelGenerator pojosOnly(boolean pojosOnly)
      Defines whether to generate just the POJO classes (entities and complex types).
      Parameters:
      pojosOnly - Flag indicating whether to generate just the POJO classes.
      Returns:
      This DataModelGenerator for chained method calls.
    • pojosOnly

      @Nonnull public DataModelGenerator pojosOnly()
      Activates POJO only generation, so just entity and complex type classes are generated.
      Returns:
      This DataModelGenerator for chained method calls.
    • serviceMethodsPerEntitySet

      @Nonnull public DataModelGenerator serviceMethodsPerEntitySet(boolean serviceMethodsPerEntitySet)
      The generator generates service methods for each entity set of one entity type. If this flag is not used, the generator generates service methods only for the first entity set of one entity type. All additional entity sets for the entity type are disregarded.
      Parameters:
      serviceMethodsPerEntitySet - Flag indicating whether to generate service methods per entity set
      Returns:
      This DataModelGenerator for chained method calls.
    • serviceMethodsPerEntitySet

      @Nonnull public DataModelGenerator serviceMethodsPerEntitySet()
      The generator generates service methods for each entity set of one entity type.
      Returns:
      This DataModelGenerator for chained method calls.
    • withExcludeFilePattern

      @Nonnull public DataModelGenerator withExcludeFilePattern(@Nonnull String excludeFilePattern)
      The ant style filename pattern for which VDM should not be generated.
      Parameters:
      excludeFilePattern - Provide the ant style pattern for filenames for which VDM should not be generated.
      Returns:
      This DataModelGenerator for chained method calls.
    • linkToApiBusinessHub

      @Nonnull public DataModelGenerator linkToApiBusinessHub(boolean linkToApiBusinessHub)
      Defines whether to generate API reference URLs linking to the SAP Business Accelerator Hub.
      Parameters:
      linkToApiBusinessHub - Flag indicating whether to generate URLs.
      Returns:
      This DataModelGenerator for chained method calls.
    • linkToApiBusinessHub

      @Nonnull public DataModelGenerator linkToApiBusinessHub()
      Activates generation of API reference URLs linking to the SAP Business Accelerator Hub.
      Returns:
      This DataModelGenerator for chained method calls.
    • versionReference

      @Nonnull public DataModelGenerator versionReference(boolean versionReference)
      Defines whether to generate the version reference of the used OData generator plugin.
      Parameters:
      versionReference - Flag indicating whether to generate the comments.
      Returns:
      This DataModelGenerator for chained method calls.
    • versionReference

      @Nonnull public DataModelGenerator versionReference()
      Generate comments, which indicate the version of the used OData VDM generator plugin.
      Returns:
      This DataModelGenerator for chained method calls.
    • copyrightHeader

      @Nonnull public DataModelGenerator copyrightHeader(@Nonnull String copyrightHeader)
      Defines a copyright header to be placed at the beginning of generated files. Use an empty string if no header needs to be set. For setting SAP copyright headers .
      Parameters:
      copyrightHeader - The copyright header to add to generated files.
      Returns:
      This DataModelGenerator for chained method calls.
    • sapCopyrightHeader

      @Nonnull public DataModelGenerator sapCopyrightHeader()
      Generate SAP copyright headers at the top of generated files.
      Returns:
      This DataModelGenerator for chained method calls.
    • withIncludedEntitySets

      @Nonnull public DataModelGenerator withIncludedEntitySets(@Nullable Set<String> includedEntitySets)
      Restricts the generated entity classes to the provided values, plus any dependent complex types. For navigation properties, the associated entity set names must be included in order to be generated.
      Parameters:
      includedEntitySets - List of entity set names to generate classes for. These names must exist in the provided EDMX files in order to be recognized. If a null value is provided, then all entity sets will be generated.
      Returns:
      This DataModelGenerator for chained method calls.
    • withIncludedFunctionImports

      @Nonnull public DataModelGenerator withIncludedFunctionImports(@Nullable Set<String> includedFunctionImports)
      Restricts the generated function imports to the provided values, plus any dependent complex types. If the return type is an entity, then make sure to include its entity set name using withIncludedEntitySets(Set) (or generate all entity sets). Otherwise the function import code cannot be generated.
      Parameters:
      includedFunctionImports - List of function import names to generate code for. These names must exist in the provided EDMX files in order to be recognized. If a null value is provided, then all function imports will be generated.
      Returns:
      This DataModelGenerator for chained method calls.
    • withIncludedActionImports

      @Nonnull public DataModelGenerator withIncludedActionImports(@Nullable Set<String> includedActionImports)
      Restricts the generated action imports to the provided values, plus any dependent complex types. If the return type is an entity, then make sure to include its entity set name using withIncludedEntitySets(Set) (or generate all entity sets). Otherwise the action import code cannot be generated.
      Parameters:
      includedActionImports - List of action import names to generate code for. These names must exist in the provided EDMX files in order to be recognized. If a null value is provided, then all action imports will be generated.
      Returns:
      This DataModelGenerator for chained method calls.
    • withDeprecationNotice

      @Nonnull public DataModelGenerator withDeprecationNotice(@Nonnull String deprecationNotice)
      Generates deprecation notices for generated service,and it's implementation class
      Parameters:
      deprecationNotice - The custom deprecation notice to be added
      Returns:
      This DataModelGenerator for chained method calls
    • getNamingStrategy

      @Nonnull public NamingStrategy getNamingStrategy()
    • execute

      public void execute()
      Executes the actual generator based on the given parameter or, in case of absence, their default values.
    • printExecuteInformation

      protected void printExecuteInformation()
      Prints all information gathered in this builder.
    • failureDueToWarningsNecessary

      public boolean failureDueToWarningsNecessary()
      Get the failure indicator due to warning messages.
      Returns:
      true if there where warning messages and the flag to fail was set.
    • getInputDirectory

      public File getInputDirectory()
    • getOutputDirectory

      public File getOutputDirectory()
    • isDeleteTargetDirectory

      public boolean isDeleteTargetDirectory()
    • isForceFileOverride

      public boolean isForceFileOverride()
    • isKeepExistingSignatures

      public boolean isKeepExistingSignatures()
    • getPackageName

      public String getPackageName()
    • getDefaultBasePath

      public String getDefaultBasePath()
    • getServiceNameMappings

      public File getServiceNameMappings()
    • getNameSource

      public NameSource getNameSource()
    • getAnnotationStrategy

      public AnnotationStrategy getAnnotationStrategy()
    • isGeneratePojosOnly

      public boolean isGeneratePojosOnly()
    • getExcludeFilePattern

      public String getExcludeFilePattern()
    • isGenerateLinksToApiBusinessHub

      public boolean isGenerateLinksToApiBusinessHub()
    • isGenerateVersionReference

      public boolean isGenerateVersionReference()
    • getCopyrightHeader

      public String getCopyrightHeader()
    • getIncludedEntitySets

      public Set<String> getIncludedEntitySets()
    • getIncludedFunctionImports

      public Set<String> getIncludedFunctionImports()
    • getIncludedActionImports

      public Set<String> getIncludedActionImports()
    • isServiceMethodsPerEntitySet

      public boolean isServiceMethodsPerEntitySet()
    • getDeprecationNotice

      public String getDeprecationNotice()
    • isFailOnWarning

      public boolean isFailOnWarning()
      The flag indicating whether the generator fails in case a warning occurs. True, if the generator fails on a warning; false otherwise.