⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mreportsource.java

📁 Java写的ERP系统
💻 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  and ComPiere, Inc.
 * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.report;

import java.util.*;
import java.sql.*;
import java.math.*;
import java.io.Serializable;

import org.compiere.model.*;
import org.compiere.util.*;


/**
 *	Report Line Source Model
 *
 *  @author Jorg Janke
 *  @version $Id: MReportSource.java,v 1.4 2003/03/15 07:02:38 jjanke Exp $
 */
public class MReportSource extends PO
{
	/**
	 * 	Constructor
	 * 	@param ctx context
	 * 	@param PA_ReportSource_ID id
	 */
	public MReportSource (Properties ctx, int PA_ReportSource_ID)
	{
		super (ctx, PA_ReportSource_ID);
		if (PA_ReportSource_ID == 0)
		{
			setElementType (null);
			setPA_ReportLine_ID (0);
		}
	}	//	MReportSource

	/**
	 * 	Constructor
	 * 	@param ctx context
	 * 	@param rs ResultSet to load from
	 */
	public MReportSource (Properties ctx, ResultSet rs)
	{
		super (ctx, rs);
	}	//	MReportSource

	/**
	 * 	Copy Constructor
	 * 	@param ctx context
	 * 	@param AD_Client_ID parent
	 * 	@param AD_Org_ID parent
	 * 	@param PA_ReportLine_ID parent
	 * 	@param source copy source
	 */
	public MReportSource (Properties ctx, int AD_Client_ID, int AD_Org_ID, int PA_ReportLine_ID, MReportSource source)
	{
		super (ctx, source, AD_Client_ID, AD_Org_ID);
		setPA_ReportLine_ID(PA_ReportLine_ID);
	}	//	MReportSource

	/**	Map with Tree				*/
	private static HashMap		s_trees = new HashMap();

	/**
	 * 	Initialize
	 * 	@param ctx context
	 * 	@return meta data
	 */
	protected POInfo initPO (Properties ctx)
	{
		int AD_Table_ID = 450;
		POInfo poi = POInfo.getPOInfo (ctx, AD_Table_ID);
		return poi;
	}	//	initPO

	/**
	 * 	Get SQL where clause
	 * 	@return where clause
	 */
	public String getWhereClause()
	{
		String et = getElementType();
		String TreeType = et;

		//	Get Key ColumnName & ID for tree
		String ColumnName = AcctSchemaElement.getColumnName(et);
		int ID = 0;
		//
		if (AcctSchemaElement.SEGMENT_Account.equals(et))
		{
			ID = getC_ElementValue_ID ();
			TreeType = MTree.TREETYPE_ElementValue;
		}
		else if (AcctSchemaElement.SEGMENT_Activity.equals(et))
			ID = getC_Activity_ID ();
		else if (AcctSchemaElement.SEGMENT_BPartner.equals(et))
			ID = getC_BPartner_ID ();
		else if (AcctSchemaElement.SEGMENT_Campaign.equals(et))
			ID = getC_Campaign_ID ();
		else if (AcctSchemaElement.SEGMENT_LocationFrom.equals(et))
			ID = getC_Location_ID ();
		else if (AcctSchemaElement.SEGMENT_LocationTo.equals(et))
			ID = getC_Location_ID ();
		else if (AcctSchemaElement.SEGMENT_Org.equals(et))
			ID = getOrg_ID ();
		else if (AcctSchemaElement.SEGMENT_Product.equals(et))
			ID = getM_Product_ID ();
		else if (AcctSchemaElement.SEGMENT_Project.equals(et))
			ID = getC_Project_ID ();
		else if (AcctSchemaElement.SEGMENT_SalesRegion.equals(et))
			ID = getC_SalesRegion_ID ();
		else if (AcctSchemaElement.SEGMENT_TrxOrg.equals(et))
			ID = getOrg_ID ();
		else if (AcctSchemaElement.SEGMENT_User1.equals(et))
			ID = getC_ElementValue_ID ();
		else if (AcctSchemaElement.SEGMENT_User2.equals(et))
			ID = getC_ElementValue_ID ();

		//	Get Tree
		MTree tree = (MTree)s_trees.get(et);
		if (tree == null)
		{
			tree = MTree.getTree (TreeType);
			Log.trace(Log.l4_Data, "MReportSource.getWhereClause - create tree for " + TreeType, tree);
			s_trees.put(et, tree);
		}
		//	Search in Tree
		if (tree != null)
		{
			MTreeNode node = tree.getRoot().findNode(ID);
			if (node != null && node.isSummary())
			{
				StringBuffer sb = new StringBuffer();
				Enumeration en = node.preorderEnumeration();
			//	System.out.println("Parent=" + node);
				while (en.hasMoreElements())
				{
					MTreeNode nn = (MTreeNode)en.nextElement();
					if (!nn.isSummary())
					{
						if (sb.length () > 0)
							sb.append (",");
						sb.append(nn.getID());
					//	System.out.println("- " + nn);
					}
				//	else
				//		System.out.println("- (" + nn + ")");
				}
				return new StringBuffer (ColumnName).append(" IN (").append(sb).append(")").toString();
			}
		}

		//	Nothing found or not summary
		return new StringBuffer (ColumnName).append("=").append(ID).toString();
	}	//	getWhereClause


	/**
	 * 	String Representation
	 * 	@return info
	 */
	public String toString ()
	{
		StringBuffer sb = new StringBuffer ("MReportSource[")
			.append(getID()).append(" - ").append(getDescription())
			.append(" - ").append(getElementType())
			.append(" - ").append(getWhereClause());
		sb.append ("]");
		return sb.toString ();
	}	//	toString



	public boolean save ()
	{
		Log.trace (Log.l4_Data, "MReportSource.save");
		return super.save ();
	}

	public void setElementType (String ElementType)
	{
		if (ElementType.equals ("AC") || ElementType.equals ("AY")
		  || ElementType.equals ("BP") || ElementType.equals ("LF")
		  || ElementType.equals ("LT") || ElementType.equals ("MC")
		  || ElementType.equals ("OO") || ElementType.equals ("OT")
		  || ElementType.equals ("PJ") || ElementType.equals ("PR")
		  || ElementType.equals ("SR") || ElementType.equals ("U1")
		  || ElementType.equals ("U2"))
			;
		else
			throw new IllegalArgumentException ("ElementType Invalid value - Reference_ID=181 - AC - AY - BP - LF - LT - MC - OO - OT - PJ - PR - SR - U1 - U2");
		if (ElementType == null)
			throw new IllegalArgumentException ("ElementType is mandatory");
		setValue ("ElementType", ElementType);
	}

	public String getElementType ()
	{
		return (String)getValue ("ElementType");
	}

	public void setC_Location_ID (int C_Location_ID)
	{
		setValue ("C_Location_ID", new Integer (C_Location_ID));
	}

	public int getC_Location_ID ()
	{
		Integer ii = (Integer)getValue ("C_Location_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setM_Product_ID (int M_Product_ID)
	{
		setValue ("M_Product_ID", new Integer (M_Product_ID));
	}

	public int getM_Product_ID ()
	{
		Integer ii = (Integer)getValue ("M_Product_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setOrg_ID (int Org_ID)
	{
		setValue ("Org_ID", new Integer (Org_ID));
	}

	public int getOrg_ID ()
	{
		Integer ii = (Integer)getValue ("Org_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_ElementValue_ID (int C_ElementValue_ID)
	{
		setValue ("C_ElementValue_ID", new Integer (C_ElementValue_ID));
	}

	public int getC_ElementValue_ID ()
	{
		Integer ii = (Integer)getValue ("C_ElementValue_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_Campaign_ID (int C_Campaign_ID)
	{
		setValue ("C_Campaign_ID", new Integer (C_Campaign_ID));
	}

	public int getC_Campaign_ID ()
	{
		Integer ii = (Integer)getValue ("C_Campaign_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setDescription (String Description)
	{
		setValue ("Description", Description);
	}

	public String getDescription ()
	{
		return (String)getValue ("Description");
	}

	void setPA_ReportLine_ID (int PA_ReportLine_ID)
	{
		setValueNoCheck ("PA_ReportLine_ID", new Integer (PA_ReportLine_ID));
	}

	public int getPA_ReportLine_ID ()
	{
		Integer ii = (Integer)getValue ("PA_ReportLine_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_SalesRegion_ID (int C_SalesRegion_ID)
	{
		setValue ("C_SalesRegion_ID", new Integer (C_SalesRegion_ID));
	}

	public int getC_SalesRegion_ID ()
	{
		Integer ii = (Integer)getValue ("C_SalesRegion_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_Project_ID (int C_Project_ID)
	{
		setValue ("C_Project_ID", new Integer (C_Project_ID));
	}

	public int getC_Project_ID ()
	{
		Integer ii = (Integer)getValue ("C_Project_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public int getPA_ReportSource_ID ()
	{
		return getID();
	}

	public void setC_Activity_ID (int C_Activity_ID)
	{
		setValue ("C_Activity_ID", new Integer (C_Activity_ID));
	}

	public int getC_Activity_ID ()
	{
		Integer ii = (Integer)getValue ("C_Activity_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}

	public void setC_BPartner_ID (int C_BPartner_ID)
	{
		setValue ("C_BPartner_ID", new Integer (C_BPartner_ID));
	}

	public int getC_BPartner_ID ()
	{
		Integer ii = (Integer)getValue ("C_BPartner_ID");
		if (ii == null)
			return 0;
		return ii.intValue ();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -