public static void main(final String[] args) {
    //
    // Start ADempiere
    AdempiereToolsHelper.getInstance().startupMinimal();
    LogManager.setLevel(Level.DEBUG);
    Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, false); // metas: don't log migration scripts

    final TableAndColumnInfoRepository repository = new TableAndColumnInfoRepository();

    //
    // Get AD_Reference_ID parameter
    if (args.length < 1) {
      throw new AdempiereException("Provide AD_Reference_ID parameter");
    }
    final String adReferenceIdStr = args[0];
    Check.assumeNotEmpty(adReferenceIdStr, "Valid AD_Reference_ID parameter: {}", adReferenceIdStr);
    final int adReferenceId = Integer.parseInt(adReferenceIdStr.trim());

    //
    // Get the AD_Reference list info
    final ListInfo listInfo = repository.getListInfo(adReferenceId).orNull();
    if (listInfo == null) {
      throw new AdempiereException("No list info found for AD_Reference_ID=" + adReferenceId);
    }

    //
    // Generate the Java code
    final String javacode =
        ADRefListGenerator.newInstance()
            .setColumnName("MyColumnName")
            .setListInfo(listInfo)
            .generateConstants();

    //
    // Output the result
    System.out.println("Generated Java code:");
    System.out.println(
        "--------------------------------------------------------------------------------------------");
    System.out.println(javacode);
    System.out.println(
        "--------------------------------------------------------------------------------------------");
  }
Example #2
0
  /**
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    if (Check.isEmpty(System.getProperty("PropertyFile"), true)) {
      throw new AdempiereException("Please set the PropertyFile");
    }

    final String outputFolder = System.getProperty("OutputFolder");
    if (Check.isEmpty(outputFolder, true)) {
      throw new AdempiereException("Please set the OutputFolder");
    }

    final String entityType = System.getProperty("EntityType");
    if (Check.isEmpty(entityType, true)) {
      throw new AdempiereException("Please set the EntityType");
    }

    CLogMgt.initialize(true); // just to make sure we are using the client side settings

    AdempiereToolsHelper.getInstance().startupMinimal();

    final ProcessInfo pi = new ProcessInfo("GenerateCanonicalXSD", -1, 0, 0);
    pi.setParameter(
        new ProcessInfoParameter[] {
          new ProcessInfoParameter("Target_Directory", outputFolder, null, null, null),
          new ProcessInfoParameter("EntityType", entityType, null, null, null),
        });
    pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));

    final GenerateCanonicalXSD process = new GenerateCanonicalXSD();
    process.p_FilterBy_AD_Client_ID = false;

    CLogMgt.setLevel(Level.INFO);
    process.startProcess(Env.getCtx(), pi, ITrx.TRX_None);

    //
    // CanonicalXSDGenerator.validateXML(new File("d:/tmp/C_BPartner.xml"), proc.getSchemaFile());
    // CanonicalXSDGenerator.validateXML(new File("d:/tmp/clientPartners.xml"),
    // proc.getSchemaFile());
  }