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
  /**
   * Test
   *
   * @param args ignored
   */
  public static void main(String[] args) {

    Adempiere.startupEnvironment(false);
    CLogMgt.setLevel(Level.CONFIG);

    ColumnEncryption columnEncryption = new ColumnEncryption();

    int processId = 328; // AD_ColumnEncryption
    int columnId = 417; // AD_User - Password
    Env.setContext(Env.getCtx(), I_AD_Column.COLUMNNAME_AD_Column_ID, columnId);

    MPInstance instance;
    MPInstancePara instanceParameters;

    instance = new MPInstance(Env.getCtx(), processId, columnId);
    instance.saveEx();

    instanceParameters = new MPInstancePara(instance, 10);
    instanceParameters.setParameter(I_AD_Column.COLUMNNAME_IsEncrypted, true);
    instanceParameters.saveEx();

    instanceParameters = new MPInstancePara(instance, 20);
    instanceParameters.setParameter("ChangeSetting", true);
    instanceParameters.saveEx();

    ProcessInfo pi = new ProcessInfo("AD_ColumnEncryption", processId);
    pi.setRecord_ID(instance.getRecord_ID());
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    pi.setAD_Client_ID(0);
    pi.setAD_User_ID(100);

    columnEncryption.startProcess(Env.getCtx(), pi, null);

    /*List<MUser> users = new Query(Env.getCtx(), I_AD_User.Table_Name , "Password IS NOT NULL", null).list();
    for (MUser user : users)
    {
        user.setPassword(user.getPassword());
        user.saveEx();
    }*/

    processId = 53259; // Convert password to hashed

    pi = new ProcessInfo("AD_User_HashPassword", processId);
    pi.setAD_Client_ID(0);
    pi.setAD_User_ID(100);

    HashPasswords process = new HashPasswords();
    process.startProcess(Env.getCtx(), pi, null);
  }
Ejemplo n.º 3
0
  // add main method, preparing for nightly build
  public static void main(String[] args) {
    Adempiere.startupEnvironment(false);
    CLogMgt.setLevel(Level.FINE);
    s_log.info("Synchronize Terminology");
    s_log.info("-----------------------");
    ProcessInfo pi = new ProcessInfo("Synchronize Terminology", 172);
    pi.setAD_Client_ID(0);
    pi.setAD_User_ID(100);

    SynchronizeTerminology sc = new SynchronizeTerminology();
    sc.startProcess(Env.getCtx(), pi, null);

    System.out.println(
        "Process=" + pi.getTitle() + " Error=" + pi.isError() + " Summary=" + pi.getSummary());
  }
Ejemplo n.º 4
0
  /**
   * Main test
   *
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) {
    Adempiere.startupEnvironment(true);
    CLogMgt.setLevel(Level.INFO);

    Properties ctx = Env.getCtx();
    int AD_Process_ID = 53156; // HARDCODED

    MPInstance pinstance = new MPInstance(ctx, AD_Process_ID, -1);
    pinstance.saveEx();

    ProcessInfo pi = new ProcessInfo("", AD_Process_ID, 0, 0);
    pi.setAD_Client_ID(Env.getAD_Client_ID(ctx));
    pi.setAD_User_ID(Env.getAD_User_ID(ctx));
    pi.setAD_PInstance_ID(pinstance.getAD_PInstance_ID());
    //
    EnableNativeSequence proc = new EnableNativeSequence();
    proc.startProcess(ctx, pi, null);
    if (pi.isError()) {
      throw new AdempiereException(pi.getSummary());
    }
  }
Ejemplo n.º 5
0
  /**
   * ************************************************************************ Generate PO Model
   * Class.
   *
   * <pre>
   * 	Example: java GenerateModel.class mydirectory myPackage 'U','A'
   * 	would generate entity type User and Application classes into mydirectory.
   * 	Without parameters, the default is used:
   * 	C:\Adempiere\adempiere-all\extend\src\adempiere\model\ adempiere.model 'U','A'
   * 	</pre>
   *
   * @param args directory package entityType - directory where to save the generated file - package
   *     of the classes to be generated - entityType to be generated
   */
  public static void main(String[] args) {
    org.compiere.Adempiere.startupEnvironment(true);
    CLogMgt.setLevel(Level.FINE);
    //	CLogMgt.setLevel(Level.ALL);
    log.info("Generate Model   $Revision: 1.5 $");
    log.info("----------------------------------");
    //	first parameter
    String directory = "/app/adempiere/adempiere_branch_3.1.1/dbPort/src/org/adempiere/model/";
    if (args.length > 0) directory = args[0];
    if (directory == null || directory.length() == 0) {
      System.err.println("No Directory");
      System.exit(1);
    }
    log.info("Directory: " + directory);

    //	second parameter
    String packageName = "adempiere.model";
    if (args.length > 1) packageName = args[1];
    if (packageName == null || packageName.length() == 0) {
      System.err.println("No package");
      System.exit(1);
    }
    log.info("Package:   " + packageName);

    //	third parameter
    String entityType = "'U','A','D'"; // 	User, Application
    if (args.length > 2) entityType = args[2];
    if (entityType == null || entityType.length() == 0) {
      System.err.println("No EntityType");
      System.exit(1);
    }
    StringBuffer sql = new StringBuffer("EntityType IN (").append(entityType).append(")");
    log.info(sql.toString());
    log.info("----------------------------------");

    //	complete sql
    sql.insert(
        0,
        "SELECT AD_Table_ID "
            + "FROM AD_Table "
            + "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" //	special views
            + " OR IsView='N')"
            + " AND TableName NOT LIKE '%_Trl' AND ");
    sql.append(" ORDER BY TableName");

    //
    int count = 0;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql.toString(), null);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        new GenerateModelJPA(rs.getInt(1), directory, packageName);
        count++;
      }
    } catch (Exception e) {
      log.severe("main - " + e);
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }

    log.info("Generated = " + count);
  } //	main
  /**
   * ************************************************************************* Generate Interface.
   *
   * <pre>
   *  	Example: java GenerateInterafce.class mydirectory myPackage 'U','A'
   *  	would generate entity type User and Application classes into mydirectory.
   *  	Without parameters, the default is used:
   *  	C:\extend\src\compiere\model\ compiere.model 'U','A'
   *
   * </pre>
   *
   * @param args directory package entityType - directory where to save the generated file - package
   *     of the classes to be generated - entityType to be generated
   */
  public static void main(String[] args) {
    Adempiere.startupEnvironment(true);
    CLogMgt.setLevel(Level.FINE);
    log.info("Generate Interface   $Revision: 1.0 $");
    log.info("----------------------------------");
    // first parameter
    String directory = "C:\\Adempiere\\adempiere-all\\extend\\src\\compiere\\model\\";
    if (args.length > 0) directory = args[0];
    if (directory == null || directory.length() == 0) {
      System.err.println("No Directory");
      System.exit(1);
    }
    log.info("Directory: " + directory);

    // second parameter
    String packageName = "compiere.model";
    if (args.length > 1) packageName = args[1];
    if (packageName == null || packageName.length() == 0) {
      System.err.println("No package");
      System.exit(1);
    }
    log.info("Package:   " + packageName);

    // third parameter
    String entityType = "'U','A'"; // User, Application
    if (args.length > 2) entityType = args[2];
    if (entityType == null || entityType.length() == 0) {
      System.err.println("No EntityType");
      System.exit(1);
    }
    StringBuffer sql = new StringBuffer("EntityType IN (").append(entityType).append(")");
    log.info(sql.toString());
    log.info("----------------------------------");

    // Table name like
    String tableLike = "'%'"; // 	All tables
    // tableLike = "'AD_OrgInfo', 'AD_Role', 'C_CashLine', 'C_Currency', 'C_Invoice', 'C_Order',
    // 'C_Payment', 'M_InventoryLine', 'M_PriceList', 'M_Product', 'U_POSTerminal'"; // only
    // specific tables
    if (args.length > 3) tableLike = args[3];
    log.info("Table Like: " + tableLike);

    // complete sql
    sql.insert(
        0,
        "SELECT AD_Table_ID "
            + "FROM AD_Table "
            + "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" // special views
            + " OR IsView='N') AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' AND ");
    sql.append(" AND TableName LIKE ").append(tableLike);
    // sql.append(" AND TableName IN (").append( tableLike ).append(")");
    sql.append(" ORDER BY TableName");

    //
    int count = 0;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql.toString(), null);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        new ModelInterfaceGenerator(rs.getInt(1), directory, packageName);
        count++;
      }
    } catch (SQLException e) {
      throw new DBException(e, sql.toString());
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }
    log.info("Generated = " + count);
  }
Ejemplo n.º 7
0
  /**
   * ************************************************************************ Generate PO Model
   * Class.
   *
   * <pre>
   * 	Example: java GenerateModel.class mydirectory myPackage 'U','A'
   * 	would generate entity type User and Application classes into mydirectory.
   * 	Without parameters, the default is used:
   * 	C:\Compiere\compiere-all\extend\src\compiere\model\ compiere.model 'U','A'
   * 	</pre>
   *
   * @param args directory package entityType - directory where to save the generated file - package
   *     of the classes to be generated - entityType to be generated
   */
  public static void main(String[] args) {
    Adempiere.startupEnvironment((args.length > 4 && args[4].equals("Client")));
    CLogMgt.setLevel(Level.FINE);
    log.info("Generate Model   $Revision: 1.42 $");
    log.info("----------------------------------");
    //	first parameter
    // mgrigioni 13/07/2010
    String directory = "dbPort/src/";
    // String directory = "C:\\Compiere\\compiere-all\\extend\\src\\compiere\\model\\";
    if (args.length > 0) directory = args[0];
    if (directory == null || directory.length() == 0) {
      System.err.println("No Directory");
      System.exit(1);
    }
    log.info("Directory: " + directory);

    //	second parameter
    String packageName = "org.adempierelbr.wrapper"; // ORIGINAL WAS compiere.model
    if (args.length > 1) packageName = args[1];
    if (packageName == null || packageName.length() == 0) {
      System.err.println("No package");
      System.exit(1);
    }
    log.info("Package:   " + packageName);

    //	third parameter
    // String entityType = "'U','A'";	//	User, Application
    String entityType = "'A', 'D'";
    String entityTypeColumn = "'LBRA'";
    String preffix = "W_";

    if (args.length > 2) entityType = args[2];
    if (entityType == null || entityType.length() == 0) {
      System.err.println("No EntityType");
      System.exit(1);
    }
    StringBuffer sql = new StringBuffer("EntityType IN (").append(entityType).append(")");
    log.info(sql.toString());
    log.info("----------------------------------");

    String tableLike = null;
    tableLike = "'%'"; // 	All tables
    // tableLike = "'AD_OrgInfo', 'AD_Role', 'C_CashLine', 'C_Currency', 'C_Invoice', 'C_Order',
    // 'C_Payment', 'M_InventoryLine', 'M_PriceList', 'M_Product', 'U_POSTerminal'";	//	Only
    // specific tables
    if (args.length > 3) tableLike = args[3];
    log.info("Table Like: " + tableLike);

    //	complete sql
    sql.insert(
        0,
        "SELECT AD_Table_ID, EntityType "
            + "FROM AD_Table "
            + "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" //	special views
            + " OR IsView='N')"
            + " AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' AND TableName NOT LIKE '%AAAA%'"
            + " AND EXISTS (SELECT '1' FROM AD_Column c WHERE c.AD_Table_ID=AD_Table.AD_Table_ID AND c.EntityType IN ("
            + entityTypeColumn
            + ")) AND ");
    sql.append(" AND TableName LIKE ").append(tableLike);
    // sql.append(" AND TableName IN (").append(tableLike).append(")"); // only specific tables

    sql.append(" ORDER BY TableName");

    //
    int count = 0;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql.toString(), null);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        String etmodelpackage = packageName;
        String classDirectory = directory;
        if (etmodelpackage != null) {
          packageName = etmodelpackage;
          String packages[] = packageName.split("\\.");
          for (String pack : packages) {
            classDirectory += pack + "/";
          }
        } else {
          classDirectory += "org/compiere/model/";
        }

        new ModelWrapperGenerator(
            rs.getInt(1), classDirectory, packageName, entityTypeColumn, preffix);
        count++;
      }
    } catch (Exception e) {
      log.log(Level.SEVERE, sql.toString(), e);
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }
    log.info("Generated = " + count);
  }