Ejemplo n.º 1
0
  public static void main(final String[] args) {

    Adempiere.startupEnvironment(false);
    Ini.setAdempiereHome(".");
    Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, true);

    doIt();
  }
Ejemplo n.º 2
0
 public static void main(String[] args) {
   Adempiere.startup(true);
   Ini.setProperty(Ini.P_UID, "SuperUser");
   Ini.setProperty(Ini.P_PWD, "System");
   Ini.setProperty(Ini.P_ROLE, "GardenWorld Admin");
   Ini.setProperty(Ini.P_CLIENT, "GardenWorld");
   Ini.setProperty(Ini.P_ORG, "HQ");
   Ini.setProperty(Ini.P_WAREHOUSE, "HQ Warehouse");
   Ini.setProperty(Ini.P_LANGUAGE, "English");
   // Ini.setProperty(Ini.P_PRINTER,"MyPrinter");
   Login login = new Login(Env.getCtx());
   login.batchLogin();
   ForecastEngine engine = ForecastEngine.get();
 }
Ejemplo n.º 3
0
  public Boolean savePreferences(Map<String, String> ctx) {
    CContext cContext = getContext();
    MUser user = MUser.get(cContext);
    MUserPreference preference = user.getPreference();
    String printerName = ctx.get("PrinterName");
    if (printerName != null && printerName.trim().equalsIgnoreCase("")) {
      cContext.setPrinterName(printerName);
      preference.setPrinterName(printerName);
    }
    String autoCommit = ctx.get("AutoCommit");
    if (autoCommit != null) {
      cContext.setAutoCommit(autoCommit.trim().equalsIgnoreCase("Y"));
      preference.setIsAutoCommit(autoCommit.trim().equalsIgnoreCase("Y"));
    }
    String showAdvanced = ctx.get("#ShowAdvanced");
    if (showAdvanced != null) {
      cContext.setContext("#ShowAdvanced", showAdvanced);
      preference.setIsShowAdvanced(showAdvanced.trim().equalsIgnoreCase("Y"));
    }
    String showAccounting = ctx.get("#ShowAcct");
    if (showAccounting != null) {
      cContext.setContext("#ShowAcct", showAccounting);
      preference.setIsShowAcct(showAccounting.trim().equalsIgnoreCase("Y"));
    }
    String showTranslation = ctx.get("#ShowTrl");
    if (showTranslation != null) {
      cContext.setContext("#ShowTrl", showTranslation);
      preference.setIsShowTrl(showTranslation.trim().equalsIgnoreCase("Y"));
    }
    String uiTheme = ctx.get("#UITheme");
    if (uiTheme != null && !uiTheme.trim().equalsIgnoreCase("")) {
      cContext.setContext("#UITheme", uiTheme);
      preference.setUITheme(uiTheme);
    }

    String printPreview = ctx.get("#PrintPreview");
    if (printPreview != null) {
      cContext.setPrintPreview(printPreview.equalsIgnoreCase("Y"));
      Ini.setProperty(Ini.P_PRINTPREVIEW, printPreview.equalsIgnoreCase("Y"));
      Ini.saveProperties(Ini.isClient());
    }

    String date = ctx.get("#Date");
    cContext.setContext("#Date", date);

    return preference.save();
  }
  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(
        "--------------------------------------------------------------------------------------------");
  }
Ejemplo n.º 5
0
  private String getDefaultPrinterNameFromIni(final String propName) {
    log.debug("Looking for " + propName + " in ini file");

    String printerName = Ini.getProperty(propName);
    if (!Check.isEmpty(printerName)) {
      log.debug("Found printerName: " + printerName);
      return printerName;
    }

    log.debug("Looking for machine's printers");
    final PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
    if (services == null || services.length == 0) {
      // [email protected]: so what? we don't need a printer to generate PDFs
      // log.warn("No default printer found on this machine");
      return "";
    }

    printerName = services[0].getName();
    Ini.setProperty(propName, printerName);
    log.debug("Found printerName: " + printerName);
    return printerName;
  }