📄 morg.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 org.compiere.util.*;
/**
* Organization Model
*
* @author Jorg Janke
* @version $Id: MOrg.java,v 1.19 2005/10/26 00:38:17 jjanke Exp $
*/
public class MOrg extends X_AD_Org
{
/**
* Get Org from Cache
* @param ctx context
* @param AD_Org_ID id
* @return MOrg
*/
public static MOrg get (Properties ctx, int AD_Org_ID)
{
Integer key = new Integer (AD_Org_ID);
MOrg retValue = (MOrg) s_cache.get (key);
if (retValue != null)
return retValue;
retValue = new MOrg (ctx, AD_Org_ID, null);
if (retValue.get_ID () != 0)
s_cache.put (key, retValue);
return retValue;
} // get
/** Cache */
private static CCache<Integer,MOrg> s_cache = new CCache<Integer,MOrg>("AD_Org", 20);
/**************************************************************************
* Standard Constructor
* @param ctx context
* @param AD_Org_ID id
*/
public MOrg (Properties ctx, int AD_Org_ID, String trxName)
{
super(ctx, AD_Org_ID, trxName);
if (AD_Org_ID == 0)
{
// setValue (null);
// setName (null);
setIsSummary (false);
}
} // MOrg
/**
* Load Constructor
* @param ctx context
* @param rs result set
*/
public MOrg (Properties ctx, ResultSet rs, String trxName)
{
super(ctx, rs, trxName);
} // MOrg
/**
* Parent Constructor
* @param client client
*/
public MOrg (MClient client, String name)
{
this (client.getCtx(), 0, client.get_TrxName());
setAD_Client_ID (client.getAD_Client_ID());
setValue (name);
setName (name);
} // MOrg
/** Org Info */
private MOrgInfo m_info = null;
/** Linked Business Partner */
private Integer m_linkedBPartner = null;
/**
* Get Org Info
* @return Org Info
*/
public MOrgInfo getInfo()
{
if (m_info == null)
m_info = MOrgInfo.get (getCtx(), getAD_Org_ID());
return m_info;
} // getMOrgInfo
/**
* After Save
* @param newRecord new Record
* @param success save success
*/
protected boolean afterSave (boolean newRecord, boolean success)
{
if (!success)
return success;
if (newRecord)
{
// Info
m_info = new MOrgInfo (this);
m_info.save();
// Access
MRoleOrgAccess.createForOrg (this);
MRole.getDefault(getCtx(), true); // reload
// TreeNode
insert_Tree(MTree_Base.TREETYPE_Organization);
}
// Value/Name change
if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name")))
{
MAccount.updateValueDescription(getCtx(), "AD_Org_ID=" + getAD_Org_ID(), get_TrxName());
if ("Y".equals(Env.getContext(getCtx(), "$Element_OT")))
MAccount.updateValueDescription(getCtx(), "AD_OrgTrx_ID=" + getAD_Org_ID(), get_TrxName());
}
return true;
} // afterSave
/**
* After Delete
* @param success
* @return deleted
*/
protected boolean afterDelete (boolean success)
{
if (success)
delete_Tree(MTree_Base.TREETYPE_Organization);
return success;
} // afterDelete
/**
* Get Linked BPartner
* @return C_BPartner_ID
*/
public int getLinkedC_BPartner_ID()
{
if (m_linkedBPartner == null)
{
int C_BPartner_ID = DB.getSQLValue(null,
"SELECT C_BPartner_ID FROM C_BPartner WHERE AD_OrgBP_ID=?",
getAD_Org_ID());
if (C_BPartner_ID < 0) // not found = -1
C_BPartner_ID = 0;
m_linkedBPartner = new Integer (C_BPartner_ID);
}
return m_linkedBPartner.intValue();
} // getLinkedC_BPartner_ID
} // MOrg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -