MBOM.java

Index Score
org.compiere.model
Compiere

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
JAVA0034JAVA0034 Missing braces in if statement
JAVA0163JAVA0163 Empty statement
JAVA0174JAVA0174 Assigned local variable never used
JAVA0036JAVA0036 Missing braces in while statement
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0166JAVA0166 Generic exception caught
JAVA0094JAVA0094 Field hides a superclass field
PROGRAM_VOLUMEHalstead program volume
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
RETURNSNumber of return points from functions
CYCLOMATICCyclomatic complexity
SIZESize of the file in bytes
LOGICAL_LINESNumber of statements
BLOCKSNumber of blocks
WHITESPACENumber of whitespace lines
LOOPSNumber of loops
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
FUNCTIONSNumber of function declarations
ELOCEffective lines of code
LINESNumber of lines in the source file
LOCLines of code
INTERFACE_COMPLEXITYInterface complexity
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
OPERANDSNumber of operands
JAVA0003JAVA0003 Minimize use of on-demand (.*) imports
UNIQUE_OPERATORSNumber of unique operators
/****************************************************************************** * Product: Compiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2007 ComPiere, Inc. 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. * * For the text or an alternative of this public license, you may reach us * * ComPiere, Inc., 3600 Bridge Parkway #102, Redwood City, CA 94065, USA * * or via info@compiere.org or http://www.compiere.org/license.html * *****************************************************************************/ package org.compiere.model; import java.sql.*; import java.util.*; import java.util.logging.*; import org.compiere.util.*; /** * BOM Model * @author Jorg Janke * @version $Id: MBOM.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $ */ public class MBOM extends X_M_BOM { /** * */ private static final long serialVersionUID = 1L; /** * Get BOM from Cache * @param ctx context * @param M_BOM_ID id * @return MBOM */ public static MBOM get (Ctx ctx, int M_BOM_ID) { Integer key = new Integer (M_BOM_ID); MBOM retValue = s_cache.get (ctx, key); if (retValue != null) return retValue; retValue = new MBOM (ctx, M_BOM_ID, null); if (retValue.get_ID () != 0) s_cache.put (key, retValue); return retValue; } // get /** * Get BOMs Of Product * @param ctx context * @param M_Product_ID product * @param trxName trx * @param whereClause optional WHERE clause w/o AND * @return array of BOMs */ public static MBOM[] getOfProduct (Ctx ctx, int M_Product_ID, String trxName, String whereClause) { ArrayList<MBOM> list = new ArrayList<MBOM>(); String sql = "SELECT * FROM M_BOM WHERE M_Product_ID=?"; if (whereClause != null && whereClause.length() > 0) sql += " AND " + whereClause; PreparedStatement pstmt = null; try { pstmt = DB.prepareStatement (sql, trxName); pstmt.setInt (1, M_Product_ID); ResultSet rs = pstmt.executeQuery (); while (rs.next ()) list.add (new MBOM (ctx, rs, trxName)); rs.close (); pstmt.close (); pstmt = null; } catch (Exception e) { s_log.log (Level.SEVERE, sql, e); } try { if (pstmt != null) pstmt.close (); pstmt = null; } catch (Exception e) { pstmt = null; } MBOM[] retValue = new MBOM[list.size ()]; list.toArray (retValue); return retValue; } // getOfProduct /** Cache */ private static CCache<Integer,MBOM> s_cache = new CCache<Integer,MBOM>("M_BOM", 20); /** Logger */ private static CLogger s_log = CLogger.getCLogger (MBOM.class); /************************************************************************** * Standard Constructor * @param ctx context * @param M_BOM_ID id * @param trxName trx */ public MBOM (Ctx ctx, int M_BOM_ID, String trxName) { super (ctx, M_BOM_ID, trxName); if (M_BOM_ID == 0) { // setM_Product_ID (0); // setName (null); setBOMType (BOMTYPE_CurrentActive); // A setBOMUse (BOMUSE_Master); // A } } // MBOM /** * Load Constructor * @param ctx ctx * @param rs result set * @param trxName trx */ public MBOM (Ctx ctx, ResultSet rs, String trxName) { super (ctx, rs, trxName); } // MBOM /** * Before Save * @param newRecord new * @return true/false */ @Override protected boolean beforeSave (boolean newRecord) { // BOM Type if (newRecord || is_ValueChanged("BOMType") || is_ValueChanged("BOMUse") ) { // Only one Current Active per BOM Use if (getBOMType().equals(BOMTYPE_CurrentActive)) { MBOM[] boms = getOfProduct(getCtx(), getM_Product_ID(), get_TrxName(), "BOMType='A' AND BOMUse='" + getBOMUse() + "' AND IsActive='Y'"); if (boms.length == 0 // only one = this || (boms.length == 1 && boms[0].getM_BOM_ID() == getM_BOM_ID())) ; else { log.saveError("Error", Msg.getMsg(getCtx(), "BOMCurrentActive")); return false; } } // Only one MTO else if (getBOMType().equals(BOMTYPE_Make_To_Order)) { MBOM[] boms = getOfProduct(getCtx(), getM_Product_ID(), get_TrxName(), "BOMType='O' AND IsActive='Y'"); if (boms.length == 0 // only one = this || (boms.length == 1 && boms[0].getM_BOM_ID() == getM_BOM_ID())) ; else { log.saveError("Error", Msg.getMsg(getCtx(), "BOMMakeToOrder")); return false; } } } // BOM Type return true; } // beforeSave /** * After Save * @param newRecord new * @param success success * @return success */ @Override protected boolean afterSave (boolean newRecord, boolean success) { // BOM Type or Use was changed if (newRecord || is_ValueChanged("BOMType") || is_ValueChanged("BOMUse") || is_ValueChanged("IsActive")) { // Invalidate BOM MProduct product = new MProduct (getCtx(), getM_Product_ID(), get_TrxName()); if (get_TrxName() != null) product.load(get_TrxName()); if (product.isVerified()) { product.setIsVerified(false); product.save(get_TrxName()); } //TODO: Invalidate products where this BOM is used (in a multi-level scenario) } return success; } // afterSave } // MBOM

The table below shows all metrics for MBOM.java.

MetricValueDescription
BLOCKS18.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS71.00Comment lines
COMMENT_DENSITY 0.75Comment density
COMPARISONS23.00Number of comparison operators
CYCLOMATIC29.00Cyclomatic complexity
DECL_COMMENTS11.00Comments in declarations
DOC_COMMENT63.00Number of javadoc comment lines
ELOC95.00Effective lines of code
EXEC_COMMENTS 7.00Comments in executable code
EXITS32.00Procedure exits
FUNCTIONS 6.00Number of function declarations
HALSTEAD_DIFFICULTY48.33Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY24.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 1.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 7.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 1.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 1.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 0.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145451.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 2.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 2.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 2.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'