/** * Execute Task locally and wait * * @param cmd command * @return execution info */ public String executeLocal(String cmd) { log.config(cmd); if (m_task != null && m_task.isAlive()) m_task.interrupt(); m_task = new Task(cmd); m_task.start(); StringBuffer sb = new StringBuffer(); while (true) { // Give it a bit of time try { Thread.sleep(500); } catch (InterruptedException ioe) { log.log(Level.SEVERE, cmd, ioe); } // Info to user sb.append(m_task.getOut()) .append("\n-----------\n") .append(m_task.getErr()) .append("\n-----------"); // Are we done? if (!m_task.isAlive()) break; } log.config("done"); return sb.toString(); } // executeLocal
/** * Validate User * * @param ldapURL provider url - e.g. ldap://dc.compiere.org * @param domain domain name = e.g. compiere.org * @param userName user name - e.g. jjanke * @param password password * @return true if validated with ldap */ public static boolean validate(String ldapURL, String domain, String userName, String password) { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); // ldap://dc.compiere.org env.put(Context.PROVIDER_URL, ldapURL); env.put(Context.SECURITY_AUTHENTICATION, "simple"); // [email protected] StringBuffer principal = new StringBuffer(userName).append("@").append(domain); env.put(Context.SECURITY_PRINCIPAL, principal.toString()); env.put(Context.SECURITY_CREDENTIALS, password); // try { // Create the initial context InitialLdapContext ctx = new InitialLdapContext(env, null); // DirContext ctx = new InitialDirContext(env); // Test - Get the attributes Attributes answer = ctx.getAttributes(""); // Print the answer if (false) dump(answer); } catch (AuthenticationException e) { log.info("Error: " + principal + " - " + e.getLocalizedMessage()); return false; } catch (Exception e) { log.log(Level.SEVERE, ldapURL + " - " + principal, e); return false; } log.info("OK: " + principal); return true; } // validate
/** * String Representation * * @return info */ @Override public String toString() { StringBuffer sb = new StringBuffer("MGoal["); sb.append(get_ID()) .append("-") .append(getName()) .append(",") .append(getGoalPerformance()) .append("]"); return sb.toString(); } // toString
/** * String Representation * * @return info */ @Override public String toString() { StringBuffer sb = new StringBuffer("MPeriod["); sb.append(get_ID()) .append("-") .append(getName()) .append(", ") .append(getStartDate()) .append("-") .append(getEndDate()) .append("]"); return sb.toString(); } // toString
/** * String Representation * * @return info */ @Override public String toString() { StringBuffer sb = new StringBuffer("MTask["); sb.append(get_ID()) .append("-") .append(getName()) .append(";Server=") .append(isServerProcess()) .append(";") .append(getOS_Command()) .append("]"); return sb.toString(); } // toString
/** * ************************************************************************ Initialize Table * access - create SQL, dateColumn. <br> * The driving table is "hdr", e.g. for hdr.C_BPartner_ID=.. The line table is "lin", e.g. for * lin.M_Product_ID=.. You use the dateColumn/qtyColumn variable directly as it is table specific. * <br> * The sql is dependent on MatchMode: - If Matched - all (fully or partially) matched records are * listed - If Not Matched - all not fully matched records are listed * * @param display (Invoice, Shipment, Order) see MATCH_* * @param matchToType (Invoice, Shipment, Order) see MATCH_* */ private static void tableInit() { m_sql = new StringBuffer(); if (tableInit_option == 0) { m_sql.append( "SELECT value,tab.M_Product_ID,tab.Name " + "FROM M_Product tab " + "WHERE XX_VMR_VENDORPRODREF_ID=" + LineRefProv.getXX_VMR_VendorProdRef_ID() + " " + "AND ISACTIVE='Y' " + "AND M_ATTRIBUTESET_ID = " + Env.getCtx().getContextAsInt("#XX_L_P_ATTRIBUTESETST_ID")); /*//Si caracteristica larga es null if(LineRefProv.getXX_VMR_LongCharacteristic_ID()!=0) { m_sql.append("AND XX_VMR_LONGCHARACTERISTIC_ID="+LineRefProv.getXX_VMR_LongCharacteristic_ID()+" "); } else{ m_sql.append("AND XX_VMR_LONGCHARACTERISTIC_ID IS NULL "); }*/ m_orderBy = " order by M_Product_ID"; } else if (tableInit_option == 1) { m_sql.append( "SELECT value,tab.M_Product_ID,tab.Name " + "FROM M_Product tab " + "WHERE tab.M_Product_ID IN " + "(select M_Product from XX_VMR_REFERENCEMATRIX where XX_VMR_PO_LINEREFPROV_ID=" + (Integer) LineRefProv.getXX_VMR_PO_LineRefProv_ID() + ")"); } else if (tableInit_option == 2) { m_sql.append( "SELECT value,tab.M_Product_ID,tab.Name " + "FROM M_Product tab " + "WHERE XX_VMR_VENDORPRODREF_ID = 0 AND M_PRODUCT_ID = 0"); } } // tableInit
/** * Fill the table using m_sql * * @param table table */ private static void tableLoad(MiniTable table) { // log.finest(m_sql + " - " + m_groupBy); String sql = MRole.getDefault() .addAccessSQL(m_sql.toString(), "tab", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO) + m_groupBy + m_orderBy; log.finest(sql); try { Statement stmt = DB.createStatement(); ResultSet rs = stmt.executeQuery(sql); table.loadTable(rs); stmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); } } // tableLoad
/** * Get individual Change HTML * * @param sb string to append to * @param columnName column name */ private void getChangeHTML(StringBuffer sb, String columnName) { if (get_Value(columnName) != null) { if (sb.length() > 0) sb.append("<br>"); sb.append(Msg.getElement(getCtx(), columnName)) .append(": ") .append(get_DisplayValue(columnName, true)); } else { String nc = getNullColumns(); if (nc != null && nc.indexOf(columnName) != -1) { if (sb.length() > 0) sb.append("<br>"); sb.append("(").append(Msg.getElement(getCtx(), columnName)).append(")"); } } } // getChangeHTML
/** * Get Changes as HTML string * * @return changes */ public String getChangesHTML() { StringBuffer sb = new StringBuffer(); getChangeHTML(sb, "Priority"); getChangeHTML(sb, "PriorityUser"); getChangeHTML(sb, "R_Category_ID"); getChangeHTML(sb, "R_Group_ID"); getChangeHTML(sb, "R_RequestType_ID"); getChangeHTML(sb, "R_Resolution_ID"); getChangeHTML(sb, "R_Status_ID"); getChangeHTML(sb, "SalesRep_ID"); getChangeHTML(sb, "Summary"); // // getChangeHTML(sb, "AD_Org_ID"); // always stored getChangeHTML(sb, "AD_Role_ID"); getChangeHTML(sb, "AD_User_ID"); getChangeHTML(sb, "C_Activity_ID"); getChangeHTML(sb, "C_BPartner_ID"); getChangeHTML(sb, "C_Invoice_ID"); getChangeHTML(sb, "C_Order_ID"); getChangeHTML(sb, "C_Payment_ID"); getChangeHTML(sb, "C_Project_ID"); getChangeHTML(sb, "DateNextAction"); getChangeHTML(sb, "IsEscalated"); getChangeHTML(sb, "IsInvoiced"); getChangeHTML(sb, "IsSelfService"); getChangeHTML(sb, "M_InOut_ID"); getChangeHTML(sb, "M_Product_ID"); getChangeHTML(sb, "A_Asset_ID"); if (sb.length() == 0) sb.append("./."); // Unicode check char[] chars = sb.toString().toCharArray(); sb = new StringBuffer(chars.length); for (char c : chars) { if (c > 255) sb.append("&#").append(c).append(";"); else sb.append(c); } return sb.toString(); } // getChangesHTML
/** * String Representation incl. Result * * @return Scipt */ @Override public String toString() { StringBuffer sb = new StringBuffer(m_variable); sb.append(" { ").append(m_script).append(" } = ").append(getResult(true)); return sb.toString(); } // toString