From: Jorg J. <jj...@us...> - 2005-05-01 06:58:18
|
Update of /cvsroot/compiere/base/src/org/compiere/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10707/src/org/compiere/model Modified Files: MRfQResponse.java MMailText.java MUser.java MBPBankAccount.java MInOut.java MProduct.java MAsset.java MRequest.java Added Files: MAssetGroup.java MProductDownload.java MAssetDelivery.java Removed Files: MAsset_Delivery.java Log Message: --- NEW FILE: MAssetGroup.java --- /****************************************************************************** * The contents of this file are subject to the Compiere License Version 1.1 * ("License"); You may not use this file except in compliance with the License * You may obtain a copy of the License at http://www.compiere.org/license.html * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * The Original Code is Compiere ERP & CRM Business Solution * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc. * Portions created by Jorg Janke are Copyright (C) 1999-2005 Jorg Janke, parts * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved. * Contributor(s): ______________________________________. *****************************************************************************/ package org.compiere.model; import java.sql.*; import java.util.*; import org.compiere.util.*; public class MAssetGroup extends X_A_Asset_Group { /** * Get from Cache * @param ctx context * @param A_Asset_Group_ID id * @return category */ public static MAssetGroup get (Properties ctx, int A_Asset_Group_ID) { Integer ii = new Integer (A_Asset_Group_ID); MAssetGroup pc = (MAssetGroup)s_cache.get(ii); if (pc == null) pc = new MAssetGroup (ctx, A_Asset_Group_ID, null); return pc; } // get /** Categopry Cache */ private static CCache s_cache = new CCache ("A_Asset_Group", 10); /** * Standard Constructor * @param ctx context * @param A_Asset_Group_ID id * @param trxName trx */ public MAssetGroup (Properties ctx, int A_Asset_Group_ID, String trxName) { super (ctx, A_Asset_Group_ID, trxName); if (A_Asset_Group_ID == 0) { // setName (null); setIsDepreciated (false); setIsOneAssetPerUOM (false); setIsOwned (false); } } // MAssetGroup /** * Load Cosntructor * @param ctx context * @param rs result set * @param trxName trx */ public MAssetGroup (Properties ctx, ResultSet rs, String trxName) { super (ctx, rs, trxName); } // MAssetGroup } // MAssetGroup --- NEW FILE: MProductDownload.java --- /****************************************************************************** * The contents of this file are subject to the Compiere License Version 1.1 * ("License"); You may not use this file except in compliance with the License * You may obtain a copy of the License at http://www.compiere.org/license.html * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * The Original Code is Compiere ERP & CRM Business Solution * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc. * Portions created by Jorg Janke are Copyright (C) 1999-2005 Jorg Janke, parts * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved. * Contributor(s): ______________________________________. *****************************************************************************/ package org.compiere.model; import java.sql.*; import java.util.*; /** * Additional Product Download Model * @author Jorg Janke * @version $Id: MProductDownload.java,v 1.1 2005/05/01 06:58:08 jjanke Exp $ */ public class MProductDownload extends X_M_ProductDownload { /** * Standard Constructor * @param ctx context * @param M_ProductDownload_ID id * @param trxName trx */ public MProductDownload (Properties ctx, int M_ProductDownload_ID, String trxName) { super (ctx, M_ProductDownload_ID, trxName); } // MProductDownload /** * Load Constructor * @param ctx context * @param rs result set * @param trxName trx */ public MProductDownload (Properties ctx, ResultSet rs, String trxName) { super (ctx, rs, trxName); } // MProductDownload /** * String Representation * @return info */ public String toString () { StringBuffer sb = new StringBuffer ("MProductDownload[") .append(getID()) .append(",M_Product_ID=").append(getM_Product_ID()) .append(",").append(getDownloadURL()) .append ("]"); return sb.toString (); } // toString } // MProductDownload --- NEW FILE: MAssetDelivery.java --- /****************************************************************************** * The contents of this file are subject to the Compiere License Version 1.1 * ("License"); You may not use this file except in compliance with the License * You may obtain a copy of the License at http://www.compiere.org/license.html * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke * are Copyright (C) 1999-2005 Jorg Janke. * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. * Contributor(s): ______________________________________. *****************************************************************************/ package org.compiere.model; import java.sql.*; import java.util.*; import javax.servlet.http.*; import org.compiere.util.*; /** * Asset Delivery Model * * @author Jorg Janke * @version $Id: MAssetDelivery.java,v 1.1 2005/05/01 06:58:08 jjanke Exp $ */ public class MAssetDelivery extends X_A_Asset_Delivery { /** * Constructor * @param ctx context * @param A_Asset_Delivery_ID id or 0 * @param trxName trx */ public MAssetDelivery (Properties ctx, int A_Asset_Delivery_ID, String trxName) { super (ctx, A_Asset_Delivery_ID, trxName); if (A_Asset_Delivery_ID == 0) { setMovementDate (new Timestamp (System.currentTimeMillis ())); } } // MAssetDelivery /** * Load Constructor * @param ctx context * @param rs result set record */ public MAssetDelivery (Properties ctx, ResultSet rs, String trxName) { super(ctx, rs, trxName); } // MAssetDelivery /** * Create Asset Delivery for HTTP Request * @param asset asset * @param request request * @param AD_User_ID BP Contact */ public MAssetDelivery (MAsset asset, HttpServletRequest request, int AD_User_ID) { super (asset.getCtx(), 0, asset.get_TrxName()); setAD_Client_ID(asset.getAD_Client_ID()); setAD_Org_ID(asset.getAD_Org_ID()); // Asset Info setA_Asset_ID (asset.getA_Asset_ID()); setLot(asset.getLot()); setSerNo(asset.getSerNo()); setVersionNo(asset.getVersionNo()); // setMovementDate (new Timestamp (System.currentTimeMillis ())); // Request setURL(request.getRequestURL().toString()); setReferrer(request.getHeader("Referer")); setRemote_Addr(request.getRemoteAddr()); setRemote_Host(request.getRemoteHost()); // Who setAD_User_ID(AD_User_ID); // save(); } // MAssetDelivery /** * Create Asset Delivery for EMail * @param asset asset * @param email email * @param AD_User_ID BP Contact */ public MAssetDelivery (MAsset asset, EMail email, int AD_User_ID) { super (asset.getCtx(), 0, asset.get_TrxName()); // Asset Info setA_Asset_ID (asset.getA_Asset_ID()); setLot(asset.getLot()); setSerNo(asset.getSerNo()); setVersionNo(asset.getVersionNo()); setDescription(asset.getDownloadName()); // setMovementDate (new Timestamp (System.currentTimeMillis ())); // EMail setEMail(email.getTo().toString()); setMessageID(email.getMessageID()); // Who setAD_User_ID(AD_User_ID); // save(); } // MAssetDelivery /** * String representation * @return info */ public String toString () { StringBuffer sb = new StringBuffer ("MAssetDelivery[") .append (getID ()) .append(",A_Asset_ID=").append(getA_Asset_ID()) .append(",MovementDate=").append(getMovementDate()) .append ("]"); return sb.toString (); } // toString } // MAssetDelivery Index: MRfQResponse.java =================================================================== RCS file: /cvsroot/compiere/base/src/org/compiere/model/MRfQResponse.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MRfQResponse.java 11 Mar 2005 20:26:05 -0000 1.11 --- MRfQResponse.java 1 May 2005 06:58:08 -0000 1.12 *************** *** 220,226 **** { MUser to = MUser.get(getCtx(), getAD_User_ID()); ! if (to.getID() == 0 || to.getEmail() == null || to.getEmail().length() == 0) { ! log.log(Level.SEVERE, "sendRfQ - No User or no EMail - " + to); return false; } --- 220,226 ---- { MUser to = MUser.get(getCtx(), getAD_User_ID()); ! if (to.getID() == 0 || to.getEMail() == null || to.getEMail().length() == 0) { ! log.log(Level.SEVERE, "No User or no EMail - " + to); return false; } Index: MMailText.java =================================================================== RCS file: /cvsroot/compiere/base/src/org/compiere/model/MMailText.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MMailText.java 11 Mar 2005 20:26:04 -0000 1.6 --- MMailText.java 1 May 2005 06:58:08 -0000 1.7 *************** *** 14,19 **** --- 14,22 ---- package org.compiere.model; + import java.sql.*; import java.util.*; + import org.compiere.util.*; + /** * Mail Text Model *************** *** 34,36 **** --- 37,72 ---- } // MMailText + /** + * Load Constructor + * @param ctx context + * @param rs result set + * @param trxName trx + */ + public MMailText (Properties ctx, ResultSet rs, String trxName) + { + super (ctx, rs, trxName); + } // MMailText + + /** + * Get Mail Text + * @param all concatinate all + * @return text + */ + public String getMailText (boolean all) + { + if (!all) + return super.getMailText(); + // + StringBuffer sb = new StringBuffer(); + sb.append(super.getMailText()); + String s = getMailText2(); + if (s != null && s.length() > 0) + sb.append(Env.NL).append(s); + s = getMailText3(); + if (s != null && s.length() > 0) + sb.append(Env.NL).append(s); + return sb.toString(); + } // getMailText + + } // MMailText Index: MUser.java =================================================================== RCS file: /cvsroot/compiere/base/src/org/compiere/model/MUser.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** MUser.java 11 Mar 2005 20:26:04 -0000 1.17 --- MUser.java 1 May 2005 06:58:08 -0000 1.18 *************** *** 18,21 **** --- 18,24 ---- import java.util.logging.*; import javax.mail.internet.*; + import javax.naming.*; + import javax.naming.directory.*; + import org.compiere.util.*; *************** *** 238,242 **** .append(getID()) .append(",Name=").append(getName()) ! .append(",EMailUserID=").append(getEmailUser()) .append ("]"); return sb.toString (); --- 241,245 ---- .append(getID()) .append(",Name=").append(getName()) ! .append(",EMailUserID=").append(getEMailUser()) .append ("]"); return sb.toString (); *************** *** 249,253 **** public boolean isOnline () { ! if (getEmail() == null || getPassword() == null) return false; return true; --- 252,256 ---- public boolean isOnline () { ! if (getEMail() == null || getPassword() == null) return false; return true; *************** *** 260,273 **** public InternetAddress getInternetAddress () { ! String email = getEmail(); if (email == null || email.length() == 0) return null; try { ! return new InternetAddress (email, true); } catch (AddressException ex) { ! log.warning("getInternetAddress - " + email + " - " + ex.getLocalizedMessage()); } return null; --- 263,279 ---- public InternetAddress getInternetAddress () { ! String email = getEMail(); if (email == null || email.length() == 0) return null; try { ! InternetAddress ia = new InternetAddress (email, true); ! if (ia != null) ! ia.validate(); // throws AddressException ! return ia; } catch (AddressException ex) { ! log.warning(email + " - " + ex.getLocalizedMessage()); } return null; *************** *** 275,287 **** /** * Return Email Validation. ! * @return return true if email is valid */ public boolean isEMailValid() { ! return getInternetAddress() != null; } // isEMailValid /** * Get User Roles for Org * @param AD_Org_ID org --- 281,371 ---- /** + * Validate Email (does not work). + * Check DNS MX record + * @param ia email + * @return error message or "" + */ + private String validateEmail (InternetAddress ia) + { + if (ia == null) + return "NoEmail"; + if (true) + return null; + + Hashtable env = new Hashtable(); + env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); + // env.put(Context.PROVIDER_URL, "dns://admin.compiere.org"); + try + { + DirContext ctx = new InitialDirContext(env); + // Attributes atts = ctx.getAttributes("admin"); + Attributes atts = ctx.getAttributes("dns://admin.compiere.org", new String[] {"MX"}); + NamingEnumeration en = atts.getAll(); + // NamingEnumeration en = ctx.list("compiere.org"); + while (en.hasMore()) + { + System.out.println(en.next()); + } + /**/ + } + catch (Exception e) + { + e.printStackTrace(); + return e.getLocalizedMessage(); + } + return null; + } // validateEmail + + /** * Return Email Validation. ! * @return return true if email is valid (artificial check) */ public boolean isEMailValid() { ! return validateEmail(getInternetAddress()) == null; } // isEMailValid /** + * Get EMail Validation Code + * @return code + */ + public String getEMailVerifyCode() + { + long code = getAD_User_ID() + + getName().hashCode(); + return "C" + String.valueOf(Math.abs(code)) + "C"; + } // getEMailValidationCode + + /** + * Check & Set EMail Validation Code. + * @param code code + * @param info info + * @return true if valid + */ + public boolean setEMailVerifyCode (String code, String info) + { + boolean ok = code != null + && code.equals(getEMailVerifyCode()); + if (ok) + setEMailVerifyDate(new Timestamp(System.currentTimeMillis())); + else + setEMailVerifyDate(null); + setEMailVerify(info); + return ok; + } // setEMailValidationCode + + /** + * Is EMail Verified by response + * @return true if verified + */ + public boolean isEMailVerified() + { + return getEMailVerifyDate() != null + && getEMailVerify() != null + && getEMailVerify().length() > 0; + } // isEMailVerified + + + /************************************************************************** * Get User Roles for Org * @param AD_Org_ID org *************** *** 356,359 **** --- 440,457 ---- return m_isAdministrator.booleanValue(); } // isAdministrator + + /** + * Before Save + * @param newRecord new + * @return true + */ + protected boolean beforeSave (boolean newRecord) + { + // New Address invalidates verification + if (!newRecord && is_ValueChanged("EMail")) + setEMailVerifyDate(null); + return true; + } // beforeSave + /** *************** *** 363,369 **** public static void main (String[] args) { ! org.compiere.Compiere.startupClient(); ! System.out.println ( MUser.get(Env.getCtx(), "SuperUser", "22") ); ! } ! */ } // MUser --- 461,475 ---- public static void main (String[] args) { ! try ! { ! validateEmail(new InternetAddress("jj...@co...")); ! } ! catch (Exception e) ! { ! e.printStackTrace(); ! } ! ! // org.compiere.Compiere.startupClient(); ! // System.out.println ( MUser.get(Env.getCtx(), "SuperUser", "22") ); ! } // main /* */ } // MUser Index: MBPBankAccount.java =================================================================== RCS file: /cvsroot/compiere/base/src/org/compiere/model/MBPBankAccount.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MBPBankAccount.java 11 Mar 2005 20:26:03 -0000 1.5 --- MBPBankAccount.java 1 May 2005 06:58:08 -0000 1.6 *************** *** 65,69 **** // setA_Name(bpc.getName()); ! setA_EMail(bpc.getEmail()); // setA_Street(location.getAddress1()); --- 65,69 ---- // setA_Name(bpc.getName()); ! setA_EMail(bpc.getEMail()); // setA_Street(location.getAddress1()); Index: MInOut.java =================================================================== RCS file: /cvsroot/compiere/base/src/org/compiere/model/MInOut.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** MInOut.java 20 Apr 2005 04:55:24 -0000 1.56 --- MInOut.java 1 May 2005 06:58:08 -0000 1.57 *************** *** 1115,1124 **** log.fine("Asset"); info.append("@A_Asset_ID@: "); ! int qty = sLine.getMovementQty().intValue(); ! for (int i = 0; i < qty; i++) { if (i > 0) info.append(" - "); ! MAsset asset = new MAsset (this, sLine, i); if (!asset.save(get_TrxName())) { --- 1115,1129 ---- log.fine("Asset"); info.append("@A_Asset_ID@: "); ! int noAssets = sLine.getMovementQty().intValue(); ! if (!product.isOneAssetPerUOM()) ! noAssets = 1; ! for (int i = 0; i < noAssets; i++) { if (i > 0) info.append(" - "); ! int deliveryCount = i+1; ! if (noAssets == 1) ! deliveryCount = 0; ! MAsset asset = new MAsset (this, sLine, deliveryCount); if (!asset.save(get_TrxName())) { Index: MProduct.java =================================================================== RCS file: /cvsroot/compiere/base/src/org/compiere/model/MProduct.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** MProduct.java 18 Apr 2005 04:58:39 -0000 1.21 --- MProduct.java 1 May 2005 06:58:08 -0000 1.22 *************** *** 194,198 **** } // MProduct ! /** --- 194,199 ---- } // MProduct ! /** Additional Downloads */ ! private MProductDownload[] m_downloads = null; /** *************** *** 362,365 **** --- 363,379 ---- /** + * Create One Asset Per UOM + * @return individual asset + */ + public boolean isOneAssetPerUOM() + { + MProductCategory pc = MProductCategory.get(getCtx(), getM_Product_Category_ID()); + if (pc.getA_Asset_Group_ID() == 0) + return false; + MAssetGroup ag = MAssetGroup.get(getCtx(), getM_Product_Category_ID()); + return ag.isOneAssetPerUOM(); + } // isOneAssetPerUOM + + /** * Product is Item * @return true if item *************** *** 398,401 **** --- 412,460 ---- return MUOM.get(getCtx(), getC_UOM_ID()).getUOMSymbol(); } // getUOMSymbol + + /** + * Get Active Addl. Product Downloads + * @return array of downloads + */ + public MProductDownload[] getProductDownloads (boolean requery) + { + if (m_downloads != null && !requery) + return m_downloads; + // + ArrayList list = new ArrayList (); + String sql = "SELECT * FROM M_ProductDownload " + + "WHERE M_Product_ID=? AND IsActive='Y' ORDER BY Name"; + // + PreparedStatement pstmt = null; + try + { + pstmt = DB.prepareStatement (sql); + pstmt.setInt (1, getM_Product_ID()); + ResultSet rs = pstmt.executeQuery (); + while (rs.next ()) + list.add (new MProductDownload (getCtx(), rs, get_TrxName())); + rs.close (); + pstmt.close (); + pstmt = null; + } + catch (Exception e) + { + log.log (Level.SEVERE, sql, e); + } + try + { + if (pstmt != null) + pstmt.close (); + pstmt = null; + } + catch (Exception e) + { + pstmt = null; + } + // + m_downloads = new MProductDownload[list.size ()]; + list.toArray (m_downloads); + return m_downloads; + } // getProductDownloads /** *************** *** 466,475 **** protected boolean afterSave (boolean newRecord, boolean success) { ! // Value/Name change if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name"))) MAccount.updateValueDescription(getCtx(), "M_Product_ID=" + getM_Product_ID(), get_TrxName()); ! // New ! if (newRecord && success) { insert_Accounting("M_Product_Acct", "M_Product_Category_Acct", --- 525,552 ---- protected boolean afterSave (boolean newRecord, boolean success) { ! if (!success) ! return success; ! ! // Value/Name change in Account if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name"))) MAccount.updateValueDescription(getCtx(), "M_Product_ID=" + getM_Product_ID(), get_TrxName()); ! // Name/Description Change in Asset MAsset.setValueNameDescription ! if (!newRecord && (is_ValueChanged("Name") || is_ValueChanged("Description"))) ! { ! String sql = "UPDATE A_Asset a " ! + "SET (Name, Description)=" ! + "(SELECT SUBSTR(bp.Name || ' - ' || p.Name,1,60), p.Description " ! + "FROM M_Product p, C_BPartner bp " ! + "WHERE p.M_Product_ID=a.M_Product_ID AND bp.C_BPartner_ID=a.C_BPartner_ID) " ! + "WHERE IsActive='Y'" ! // + " AND GuaranteeDate > SysDate" ! + " AND M_Product_ID=" + getM_Product_ID(); ! int no = DB.executeUpdate(sql, get_TrxName()); ! log.fine("Asset Description updated #" + no); ! } ! ! // New - Acct, Tree, Costing ! if (newRecord) { insert_Accounting("M_Product_Acct", "M_Product_Category_Acct", Index: MAsset.java =================================================================== RCS file: /cvsroot/compiere/base/src/org/compiere/model/MAsset.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** MAsset.java 11 Mar 2005 20:26:03 -0000 1.24 --- MAsset.java 1 May 2005 06:58:08 -0000 1.25 *************** *** 15,18 **** --- 15,19 ---- import java.io.*; + import java.math.*; import java.net.*; import java.sql.*; *************** *** 50,53 **** --- 51,55 ---- setIsDisposed (false); setM_AttributeSetInstance_ID(0); + setQty(Env.ONE); } } // MAsset *************** *** 76,79 **** --- 78,82 ---- * Shipment Constructor * @param shipLine shipment line + * @param deliveryCount 0 or number of delivery */ public MAsset (MInOut shipment, MInOutLine shipLine, int deliveryCount) *************** *** 105,108 **** --- 108,113 ---- } setHelp(shipLine.getDescription()); + if (deliveryCount != 0) + setQty(shipLine.getMovementQty()); } // MAsset *************** *** 125,140 **** MProduct product = line.getProduct(); MBPartner partner = shipment.getBPartner(); ! setValueNameDescription(shipment, line, deliveryCount, product, partner); ! } /** ! * Set Value Name Description ! * @param shipment ! * @param line ! * @param deliveryCount ! * @param product ! * @param partner */ ! public void setValueNameDescription(MInOut shipment, MInOutLine line, int deliveryCount, MProduct product, MBPartner partner) { --- 130,144 ---- MProduct product = line.getProduct(); MBPartner partner = shipment.getBPartner(); ! setValueNameDescription(shipment, deliveryCount, product, partner); ! } // setValueNameDescription /** ! * Set Value, Name, Description ! * @param shipment shipment ! * @param deliveryCount count ! * @param product product ! * @param partner partner */ ! public void setValueNameDescription (MInOut shipment, int deliveryCount, MProduct product, MBPartner partner) { *************** *** 142,162 **** if (deliveryCount > 1) documentNo += "_" + deliveryCount; ! // String value = partner.getValue() + "_" + product.getValue(); if (value.length() > 40-documentNo.length()) value = value.substring(0,40-documentNo.length()) + documentNo; setValue(value); ! // ! String name = partner.getName() + "_" + product.getName(); ! if (name.length() > 60-documentNo.length()) ! name = name.substring(0,60-documentNo.length()) + documentNo; setName(name); ! // String description = product.getDescription(); - if (line.getDescription() != null && line.getDescription().length() > 0) - description += " | " + line.getDescription(); setDescription(description); } // setValueNameDescription /** --- 146,176 ---- if (deliveryCount > 1) documentNo += "_" + deliveryCount; ! // Value String value = partner.getValue() + "_" + product.getValue(); if (value.length() > 40-documentNo.length()) value = value.substring(0,40-documentNo.length()) + documentNo; setValue(value); ! ! // Name MProduct.afterSave ! String name = partner.getName() + " - " + product.getName(); ! if (name.length() > 60) ! name = name.substring(0,60); setName(name); ! // Description String description = product.getDescription(); setDescription(description); } // setValueNameDescription + /** + * Get Qty + * @return 1 or Qty + */ + public BigDecimal getQty () + { + BigDecimal qty = super.getQty(); + if (qty == null) + return Env.ONE; + return qty; + } // getQty /** *************** *** 166,170 **** public String toString () { ! StringBuffer sb = new StringBuffer ("MAsset[").append (getID ()).append ("]"); return sb.toString (); } // toString --- 180,187 ---- public String toString () { ! StringBuffer sb = new StringBuffer ("MAsset[") ! .append (getID ()) ! .append("-").append(getValue()) ! .append ("]"); return sb.toString (); } // toString *************** *** 175,179 **** * @return deliveries */ ! public MAsset_Delivery[] getDeliveries() { ArrayList list = new ArrayList(); --- 192,196 ---- * @return deliveries */ ! public MAssetDelivery[] getDeliveries() { ArrayList list = new ArrayList(); *************** *** 187,191 **** ResultSet rs = pstmt.executeQuery(); while (rs.next()) ! list.add(new MAsset_Delivery(getCtx(), rs, get_TrxName())); rs.close(); pstmt.close(); --- 204,208 ---- ResultSet rs = pstmt.executeQuery(); while (rs.next()) ! list.add(new MAssetDelivery(getCtx(), rs, get_TrxName())); rs.close(); pstmt.close(); *************** *** 194,198 **** catch (Exception e) { ! log.log(Level.SEVERE, "getDeliveries", e); } finally --- 211,215 ---- catch (Exception e) { ! log.log(Level.SEVERE, sql, e); } finally *************** *** 208,212 **** } // ! MAsset_Delivery[] retValue = new MAsset_Delivery[list.size()]; list.toArray(retValue); return retValue; --- 225,229 ---- } // ! MAssetDelivery[] retValue = new MAssetDelivery[list.size()]; list.toArray(retValue); return retValue; *************** *** 264,268 **** if (directory == null || directory.length() == 0) { ! s_log.log(Level.SEVERE, "getDownloadFile - Not found " + downloadURL); return null; } --- 281,285 ---- if (directory == null || directory.length() == 0) { ! s_log.log(Level.SEVERE, "Not found " + downloadURL); return null; } *************** *** 275,279 **** return file; ! s_log.log(Level.SEVERE, "getDownloadFile - Not found " + downloadURL + " + " + downloadURL2); return null; } // getDownloadFile --- 292,296 ---- return file; ! s_log.log(Level.SEVERE, "Not found " + downloadURL + " + " + downloadURL2); return null; } // getDownloadFile *************** *** 282,288 **** * Get Download Stream * @param directory optional directory * @return input stream */ ! public InputStream getDownloadStream (String directory) { if (!isDownloadable()) --- 299,306 ---- * Get Download Stream * @param directory optional directory + * @param dl_url download url if null getProductDownloadURL(); * @return input stream */ ! public InputStream getDownloadStream (String directory, String dl_url) { if (!isDownloadable()) *************** *** 290,304 **** InputStream in = null; ! String where = getProductDownloadURL(); try { ! if (where.indexOf ("://") != -1) { ! URL url = new URL (where); in = url.openStream(); } else // file { ! File file = getDownloadFile(where, directory); if (file == null) return null; --- 308,324 ---- InputStream in = null; ! if (dl_url == null) ! dl_url = getProductDownloadURL(); ! try { ! if (dl_url.indexOf ("://") != -1) { ! URL url = new URL (dl_url); in = url.openStream(); } else // file { ! File file = getDownloadFile(dl_url, directory); if (file == null) return null; *************** *** 308,312 **** catch (Exception ex) { ! log.log(Level.SEVERE, "getDownloadStream - " + where, ex); return null; } --- 328,332 ---- catch (Exception ex) { ! log.log(Level.SEVERE, dl_url, ex); return null; } *************** *** 339,343 **** catch (Exception ex) { ! log.log(Level.SEVERE, "getDownloadURL - " + where, ex); return null; } --- 359,363 ---- catch (Exception ex) { ! log.log(Level.SEVERE, where, ex); return null; } *************** *** 398,401 **** --- 418,474 ---- } // getProductInfo + /** + * Get Active Addl. Product Downloads + * @return array of downloads + */ + public MProductDownload[] getProductDownloads() + { + if (m_product == null) + getProduct(); + if (m_product != null) + return m_product.getProductDownloads(false); + return null; + } // getProductDownloads + + /** + * Get Additional Download Names + * @return names + */ + public String[] getAddlDownloadNames() + { + MProductDownload[] dls = getProductDownloads(); + if (dls != null && dls.length > 0) + { + String[] retValue = new String[dls.length]; + for (int i = 0; i < retValue.length; i++) + retValue[i] = dls[i].getName(); + log.fine("#" + dls.length); + return retValue; + } + return new String[]{}; + } // addlDownloadNames + + /** + * Get Additional Download URLs + * @return URLs + */ + public String[] getAddlDownloadURLs() + { + MProductDownload[] dls = getProductDownloads(); + if (dls != null && dls.length > 0) + { + String[] retValue = new String[dls.length]; + for (int i = 0; i < retValue.length; i++) + { + String url = dls[i].getDownloadURL(); + int pos = Math.max(url.lastIndexOf('/'), url.lastIndexOf('\\')); + if (pos != -1) + url = url.substring(pos+1); + retValue[i] = url; + } + return retValue; + } + return new String[]{}; + } // addlDownloadURLs /************************************************************************* *************** *** 404,411 **** * @param AD_User_ID recipient */ ! public MAsset_Delivery confirmDelivery (EMail email, int AD_User_ID) { setVersionNo(getProductVersionNo()); ! MAsset_Delivery ad = new MAsset_Delivery (this, email, AD_User_ID); return ad; } // confirmDelivery --- 477,484 ---- * @param AD_User_ID recipient */ ! public MAssetDelivery confirmDelivery (EMail email, int AD_User_ID) { setVersionNo(getProductVersionNo()); ! MAssetDelivery ad = new MAssetDelivery (this, email, AD_User_ID); return ad; } // confirmDelivery *************** *** 416,423 **** * @param AD_User_ID recipient */ ! public MAsset_Delivery confirmDelivery (HttpServletRequest request, int AD_User_ID) { setVersionNo(getProductVersionNo()); ! MAsset_Delivery ad = new MAsset_Delivery (this, request, AD_User_ID); return ad; } // confirmDelivery --- 489,496 ---- * @param AD_User_ID recipient */ ! public MAssetDelivery confirmDelivery (HttpServletRequest request, int AD_User_ID) { setVersionNo(getProductVersionNo()); ! MAssetDelivery ad = new MAssetDelivery (this, request, AD_User_ID); return ad; } // confirmDelivery Index: MRequest.java =================================================================== RCS file: /cvsroot/compiere/base/src/org/compiere/model/MRequest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** MRequest.java 28 Apr 2005 05:51:43 -0000 1.16 --- MRequest.java 1 May 2005 06:58:08 -0000 1.17 *************** *** 394,398 **** MUser user = getUser(); if (user != null) ! message.append(" - ").append(user.getName()).append(" - ").append(user.getEmail()); if (getDateLastAction() != null) message.append("\n").append(Msg.translate(getCtx(), "DateLastAction")) --- 394,398 ---- MUser user = getUser(); if (user != null) ! message.append(" - ").append(user.getName()).append(" - ").append(user.getEMail()); if (getDateLastAction() != null) message.append("\n").append(Msg.translate(getCtx(), "DateLastAction")) --- MAsset_Delivery.java DELETED --- |