From 8354d827f18a9fe0f63d8cc52e672c0c247db1a9 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Mon, 16 Feb 2009 16:35:53 +0000 Subject: [PATCH] Contribute org.adempiere.exceptions.NoUOMConversionException, exception that will be thrown when no UOM exception will be found. For the start, this exception will be used in libero project. --- .../exceptions/NoUOMConversionException.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 base/src/org/adempiere/exceptions/NoUOMConversionException.java diff --git a/base/src/org/adempiere/exceptions/NoUOMConversionException.java b/base/src/org/adempiere/exceptions/NoUOMConversionException.java new file mode 100644 index 0000000000..ff99b88875 --- /dev/null +++ b/base/src/org/adempiere/exceptions/NoUOMConversionException.java @@ -0,0 +1,64 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 2009 SC ARHIPAC SERVICE SRL. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.exceptions; + +import org.compiere.model.MProduct; +import org.compiere.model.MUOM; +import org.compiere.util.Env; + +/** + * Any exception that occurs when no UOM conversion rate was found + * @author Teo Sarca, http://www.arhipac.ro + */ +public class NoUOMConversionException extends AdempiereException +{ + /** + * + */ + private static final long serialVersionUID = -4868882017576097089L; + + public NoUOMConversionException(int M_Product_ID, int C_UOM_ID, int C_UOM_To_ID) + { + super(buildMessage(M_Product_ID, C_UOM_ID, C_UOM_To_ID)); + } + + private static String buildMessage(int M_Product_ID, int C_UOM_ID, int C_UOM_To_ID) + { + StringBuffer sb = new StringBuffer(); + // + sb.append("@M_Product_ID@: "); + MProduct product = MProduct.get(Env.getCtx(), M_Product_ID); + if (product != null) + { + sb.append(product.getValue()).append("_").append(product.getName()); + } + // + sb.append(" @C_UOM_ID@: "); + MUOM uom = MUOM.get(Env.getCtx(), C_UOM_ID); + if (uom != null) + { + sb.append(uom.getUOMSymbol()); + } + // + sb.append(" @C_UOM_To_ID@: "); + MUOM uomTo = MUOM.get(Env.getCtx(), C_UOM_To_ID); + if (uomTo != null) + { + sb.append(uomTo.getUOMSymbol()); + } + // + return sb.toString(); + } + +}