Class ModelGeneratorOptions

java.lang.Object
org.adempiere.util.ModelGeneratorOptions

public class ModelGeneratorOptions extends Object
Command line options of the model generator (ModelGeneratorApplication).

Two forms are accepted:

  • positional, unchanged: folder packageName tableEntityType tableName [columnEntityType]
  • named: --folder= --package= --tables= --table-entity-type= --column-entity-type= --output=interface,class,accessor --suffix= --columns= --template= --check; --help prints the usage
The class has no database access, so it can be tested on its own; the caller supplies what needs the dictionary (template values, system entity types).
  • Field Details

  • Method Details

    • isHelp

      public static boolean isHelp(String[] args)
      Parameters:
      args - command line arguments
      Returns:
      true when --help is one of them
    • parse

      public static ModelGeneratorOptions parse(String[] args)
      Parse command line arguments.
      Parameters:
      args - arguments, positional or named (a first argument starting with -- selects the named form)
      Returns:
      options
      Throws:
      IllegalArgumentException - for an unknown argument, a missing value, a wrong number of positional arguments or a named argument mixed into positional ones
    • applyTemplate

      public void applyTemplate(String tFolder, String tPackageName, String tTableName, String tTableEntityType, String tColumnEntityType)
      Fill the values not given on the command line from a Generate Model Template. Explicit arguments win over the template.
    • missing

      public List<String> missing()
      Returns:
      names of the required values that are still missing (after a template was applied)
    • safetyProblems

      public List<String> safetyProblems(Predicate<String> isSystemEntityType)
      Safety rules. Each problem is a combination that writes into another owner's classes.
      • S1: a system table entity type with no column entity type writes every column of the dictionary, custom ones included, into the generated classes of core tables
      • S2: a column entity type filter together with class output writes an X_ class that has only some columns of the table but is annotated for the whole table
      • S4: a core package with a column entity type other than D writes plug-in columns into core files
      • S7: accessor output for the columns of the dictionary entity type D, or with no column entity type and no --columns (every column); the accessor only gets and sets values and skips the logic of the model classes (MOrder.setC_BPartner_ID also sets the bill-to partner). Columns named with --columns are checked by the generator, which reads their entity types
      Parameters:
      isSystemEntityType - tells whether an entity type is system maintained, for example D
      Returns:
      problems, empty when the call is safe
    • isRefused

      public boolean isRefused(String problem)
      Parameters:
      problem - a problem returned by safetyProblems(Predicate)
      Returns:
      true when the call must be refused: every problem in the named form, and S4 also in the positional form, because it writes plug-in columns into core sources; the other problems only warn in the positional form, so existing scripts keep working
    • warnings

      public List<String> warnings()
      Warnings that never refuse a call.
      • S6: an interface for a column subset of a table of another entity type, without a suffix, has the same simple name as the owner's interface (I_C_Order); code in the same package may bind to the wrong one
      Returns:
      warnings, empty when there are none
    • entityTypes

      public static List<String> entityTypes(String list)
      Parameters:
      list - comma separated entity types, optionally quoted
      Returns:
      entity types without quotes and blanks
    • usage

      public static String usage()
      Returns:
      usage text for both forms
    • getFolder

      public String getFolder()
    • getPackageName

      public String getPackageName()
    • getTableName

      public String getTableName()
    • getTableEntityType

      public String getTableEntityType()
    • getColumnEntityType

      public String getColumnEntityType()
    • isGenerateInterface

      public boolean isGenerateInterface()
    • isGenerateClass

      public boolean isGenerateClass()
    • isGenerateAccessor

      public boolean isGenerateAccessor()
    • getSuffix

      public String getSuffix()
    • getColumns

      public String getColumns()
      Returns:
      comma separated column names, or null for all columns of the column entity types
    • getTemplate

      public String getTemplate()
    • isCheck

      public boolean isCheck()
    • isCheckPassed

      public static boolean isCheckPassed(int generated, int outOfDate)
      A check that generated no file has not checked anything, so it must not pass.
      Parameters:
      generated - number of files the call generated
      outOfDate - number of generated files that are missing or differ in the target folder
      Returns:
      true when files were generated and all of them are up to date
    • isNamed

      public boolean isNamed()
      Returns:
      true for the named form; safety problems are then refused, in the positional form only reported