www.pudn.com > code_source_compiere_erp_crm_logiciel_java.zip > MAssignment.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  Business Solution 
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc. 
 * Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts 
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved. 
 * Contributor(s): ______________________________________. 
 *****************************************************************************/ 
package org.compiere.model; 
 
import java.sql.*; 
import java.util.*; 
import java.math.*; 
 
import org.compiere.util.*; 
 
/** 
 *	Resource Assignment Model 
 * 
 * 	@author 	Jorg Janke 
 * 	@version 	$Id: MAssignment.java,v 1.7 2002/07/14 01:01:33 jjanke Exp $ 
 */ 
public class MAssignment extends PO 
{ 
	/** 
	 *	Assignment Constructor. 
	 *  
 
	 *  Fields: 
	 *	- S_ResourceAssignment_ID 
	 *  - S_Resource_ID 
	 *  - AssignDateFrom 
	 *  - AssignDateTo 
	 *  - Qty 
	 *  - IsConfirmed 
	 *  - Name 
	 *  - Description 
	 *  
* @param ctx context * @param S_ResourceAssignment_ID ID */ public MAssignment (Properties ctx, int S_ResourceAssignment_ID) { super (ctx, S_ResourceAssignment_ID); p_info.setUpdateable(true); // default table is not updateable // Default values if (S_ResourceAssignment_ID == 0) { setAssignDateFrom(new Timestamp(System.currentTimeMillis())); setQty(new BigDecimal(1.0)); setName("."); setConfirmed(false); } } // MAssignment /** * Initialize POInfo * @param ctx context * @return POInfo */ protected POInfo initPO (Properties ctx) { int AD_Table_ID = 485; POInfo poi = POInfo.getPOInfo (ctx, AD_Table_ID); return poi; } // initPO /** * String Representation * @return string */ public String toString() { StringBuffer sb = new StringBuffer ("MAssignment[ID="); sb.append(getID()) .append(",S_Resource_ID=").append(getS_Resource_ID()) .append(",From=").append(getAssignDateFrom()) .append(",To=").append(getAssignDateTo()) .append(",Qty=").append(getQty()) .append("]"); return sb.toString(); } // toString /*************************************************************************/ /** * Get ResourceAssignment ID * @return S_ResourceAssignment_ID or 0 */ public int getS_ResourceAssignment_ID() { return getID(); } // getS_ResourceAssignment_ID /** * Get Resource ID * @return S_Resource_ID or 0 */ public int getS_Resource_ID() { Integer ii = (Integer)getValue("S_Resource_ID"); if (ii == null) return 0; return ii.intValue(); } // getS_Resource_ID /** * Set Resource ID * @param S_Resource_ID resource */ public void setS_Resource_ID (int S_Resource_ID) { Integer ii = new Integer(S_Resource_ID); if (S_Resource_ID == 0) setValue("S_Resource_ID", null); else setValue("S_Resource_ID", ii); } // getS_Resource_ID /** * Get Start Assign Date * @return AssignDateFrom or null */ public Timestamp getAssignDateFrom() { return (Timestamp)getValue("AssignDateFrom"); } // getAssignDateFrom /** * Set Start Assign Date * @param AssignDateFrom assignment date from */ public void setAssignDateFrom (Timestamp AssignDateFrom) { setValue("AssignDateFrom", AssignDateFrom); } // setAssignDateFrom /** * Get End Assign Date * @return AssignDateTo or null */ public Timestamp getAssignDateTo() { return (Timestamp)getValue("AssignDateTo"); } // getAssignDateTo /** * Set End Assign Date * @param AssignDateTo assignment date to */ public void setAssignDateTo (Timestamp AssignDateTo) { setValue("AssignDateTo", AssignDateTo); } // setAssignDateTo /** * Get Qty * @return Qty or null */ public BigDecimal getQty() { return (BigDecimal)getValue("Qty"); } // getQty /** * Set Qty * @param Qty quantity */ public void setQty (BigDecimal Qty) { setValue("Qty", Qty); } // setQty /** * Get Confirm Status * @return false if not confirmed */ public boolean isConfirmed() { Boolean bb = (Boolean)getValue("IsConfirmed"); if (bb == null) return false; return bb.booleanValue(); } // isConfirmed /** * Set Confirm Status * @param confirmed true if confirmed */ public void setConfirmed (boolean confirmed) { Boolean bb = new Boolean(confirmed); setValue("IsConfirmed", bb); } // setConfirmed /** * Set Name * @param name name */ public void setName(String name) { setValue("Name", name); } // setName /** * Get Name * @return name */ public String getName() { return (String)getValue("Name"); } // getName /** * Set Description * @param description desciption */ public void setDescription(String description) { setValue("Description", description); } // setDescription /** * Get Description * @return description */ public String getDescription() { return (String)getValue("Description"); } // getDescription /*************************************************************************/ /** * Delete (set inactive) * @return true i deleted */ public boolean delete() { // allow to delete, when not confirmed if (isConfirmed()) return false; StringBuffer sql = new StringBuffer ("UPDATE "); sql.append(getTableName()).append( " SET IsActive='N' WHERE "); sql.append(" WHERE ").append(getTableName()).append("_ID=").append(getID()); int no = DB.executeUpdate(sql.toString()); return no == 1; } // delete } // MAssignment