📄 macctschemaelement.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 java.util.logging.*;
import org.compiere.util.*;
/**
* Account Schema Element Object
*
* @author Jorg Janke
* @version $Id: MAcctSchemaElement.java,v 1.14 2005/11/25 21:58:31 jjanke Exp $
*/
public final class MAcctSchemaElement extends X_C_AcctSchema_Element
{
/**
* Factory: Return ArrayList of Account Schema Elements
* @param as Accounting Schema
* @return ArrayList with Elements
*/
public static MAcctSchemaElement[] getAcctSchemaElements (MAcctSchema as)
{
Integer key = new Integer (as.getC_AcctSchema_ID());
MAcctSchemaElement[] retValue = (MAcctSchemaElement[]) s_cache.get (key);
if (retValue != null)
return retValue;
s_log.fine("C_AcctSchema_ID=" + as.getC_AcctSchema_ID());
ArrayList<MAcctSchemaElement> list = new ArrayList<MAcctSchemaElement>();
//
String sql = "SELECT * FROM C_AcctSchema_Element "
+ "WHERE C_AcctSchema_ID=? AND IsActive='Y' ORDER BY SeqNo";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, as.get_TrxName());
pstmt.setInt(1, as.getC_AcctSchema_ID());
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
MAcctSchemaElement ase = new MAcctSchemaElement(as.getCtx(), rs, as.get_TrxName());
s_log.fine(" - " + ase);
if (ase.isMandatory() && ase.getDefaultValue() == 0)
s_log.log(Level.SEVERE, "No default value for " + ase.getName());
list.add(ase);
//
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, sql, e);
}
retValue = new MAcctSchemaElement[list.size()];
list.toArray(retValue);
s_cache.put (key, retValue);
return retValue;
} // getAcctSchemaElements
/**
* Get Column Name of ELEMENTTYPE
* @param elementType ELEMENTTYPE
* @return column name
*/
public static String getColumnName(String elementType)
{
if (elementType.equals(ELEMENTTYPE_Organization))
return "AD_Org_ID";
else if (elementType.equals(ELEMENTTYPE_Account))
return "Account_ID";
else if (elementType.equals(ELEMENTTYPE_BPartner))
return "C_BPartner_ID";
else if (elementType.equals(ELEMENTTYPE_Product))
return "M_Product_ID";
else if (elementType.equals(ELEMENTTYPE_Activity))
return "C_Activity_ID";
else if (elementType.equals(ELEMENTTYPE_LocationFrom))
return "C_LocFrom_ID";
else if (elementType.equals(ELEMENTTYPE_LocationTo))
return "C_LocTo_ID";
else if (elementType.equals(ELEMENTTYPE_Campaign))
return "C_Campaign_ID";
else if (elementType.equals(ELEMENTTYPE_OrgTrx))
return "AD_OrgTrx_ID";
else if (elementType.equals(ELEMENTTYPE_Project))
return "C_Project_ID";
else if (elementType.equals(ELEMENTTYPE_SalesRegion))
return "C_SalesRegion_ID";
else if (elementType.equals(ELEMENTTYPE_UserList1))
return "User1_ID";
else if (elementType.equals(ELEMENTTYPE_UserList2))
return "User2_ID";
else if (elementType.equals(ELEMENTTYPE_UserElement1))
return "UserElement1_ID";
else if (elementType.equals(ELEMENTTYPE_UserElement2))
return "UserElement2_ID";
//
return "";
} // getColumnName
/**
* Get Value Query for ELEMENTTYPE Type
* @param elementType ELEMENTTYPE type
* @return query "SELECT Value,Name FROM Table WHERE ID="
*/
public static String getValueQuery (String elementType)
{
if (elementType.equals(ELEMENTTYPE_Organization))
return "SELECT Value,Name FROM AD_Org WHERE AD_Org_ID=";
else if (elementType.equals(ELEMENTTYPE_Account))
return "SELECT Value,Name FROM C_ElementValue WHERE C_ElementValue_ID=";
else if (elementType.equals(ELEMENTTYPE_SubAccount))
return "SELECT Value,Name FROM C_SubAccount WHERE C_SubAccount_ID=";
else if (elementType.equals(ELEMENTTYPE_BPartner))
return "SELECT Value,Name FROM C_BPartner WHERE C_BPartner_ID=";
else if (elementType.equals(ELEMENTTYPE_Product))
return "SELECT Value,Name FROM M_Product WHERE M_Product_ID=";
else if (elementType.equals(ELEMENTTYPE_Activity))
return "SELECT Value,Name FROM C_Activity WHERE C_Activity_ID=";
else if (elementType.equals(ELEMENTTYPE_LocationFrom))
return "SELECT City,Address1 FROM C_Location WHERE C_Location_ID=";
else if (elementType.equals(ELEMENTTYPE_LocationTo))
return "SELECT City,Address1 FROM C_Location WHERE C_Location_ID=";
else if (elementType.equals(ELEMENTTYPE_Campaign))
return "SELECT Value,Name FROM C_Campaign WHERE C_Campaign_ID=";
else if (elementType.equals(ELEMENTTYPE_OrgTrx))
return "SELECT Value,Name FROM AD_Org WHERE AD_Org_ID=";
else if (elementType.equals(ELEMENTTYPE_Project))
return "SELECT Value,Name FROM C_Project WHERE C_Project_ID=";
else if (elementType.equals(ELEMENTTYPE_SalesRegion))
return "SELECT Value,Name FROM C_SalesRegion WHERE C_SalesRegion_ID";
else if (elementType.equals(ELEMENTTYPE_UserList1))
return "SELECT Value,Name FROM C_ElementValue WHERE C_ElementValue_ID=";
else if (elementType.equals(ELEMENTTYPE_UserList2))
return "SELECT Value,Name FROM C_ElementValue WHERE C_ElementValue_ID=";
//
else if (elementType.equals(ELEMENTTYPE_UserElement1))
return null;
else if (elementType.equals(ELEMENTTYPE_UserElement2))
return null;
//
return "";
} // getColumnName
/** Logger */
private static CLogger s_log = CLogger.getCLogger (MAcctSchemaElement.class);
/** Cache */
private static CCache<Integer,MAcctSchemaElement[]> s_cache = new CCache<Integer,MAcctSchemaElement[]>("C_AcctSchema_Element", 10);
/*************************************************************************
* Standard Constructor
* @param ctx context
* @param C_AcctSchema_Element_ID id
*/
public MAcctSchemaElement (Properties ctx, int C_AcctSchema_Element_ID, String trxName)
{
super (ctx, C_AcctSchema_Element_ID, trxName);
if (C_AcctSchema_Element_ID == 0)
{
// setC_AcctSchema_Element_ID (0);
// setC_AcctSchema_ID (0);
// setC_Element_ID (0);
// setElementType (null);
setIsBalanced (false);
setIsMandatory (false);
// setName (null);
// setOrg_ID (0);
// setSeqNo (0);
}
} // MAcctSchemaElement
/**
* Load Constructor
* @param ctx context
* @param rs result set
*/
public MAcctSchemaElement (Properties ctx, ResultSet rs, String trxName)
{
super(ctx, rs, trxName);
} // MAcctSchemaElement
/**
* Parent Constructor
* @param as accounting schema
*/
public MAcctSchemaElement (MAcctSchema as)
{
this (as.getCtx(), 0, as.get_TrxName());
setClientOrg(as);
setC_AcctSchema_ID (as.getC_AcctSchema_ID());
// setC_Element_ID (0);
// setElementType (null);
// setName (null);
// setSeqNo (0);
} // MAcctSchemaElement
/** User Element Column Name */
private String m_ColumnName = null;
/**
* Set Organization Type
* @param SeqNo sequence
* @param Name name
* @param Org_ID id
*/
public void setTypeOrg (int SeqNo, String Name, int Org_ID)
{
setElementType (ELEMENTTYPE_Organization);
setSeqNo(SeqNo);
setName (Name);
setOrg_ID(Org_ID);
} // setTypeOrg
public void setTypeAccount (int SeqNo, String Name, int C_Element_ID, int C_ElementValue_ID)
{
setElementType (ELEMENTTYPE_Account);
setSeqNo(SeqNo);
setName (Name);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -