Concept of X-Class and M-Class
Purpose of X Classes is to provide getter and setter method to Model classes. X Classes are the properties classes, which are based on a database tables. Whenever you change the fields of a table you need to update its X class.
M Classes are used to write business logic and it extends X Classes for getter and setter method. If a tab of window using a workflow processes with node have Document Action functionality, then M Class should implements DocAction class.
With the help of X-Classes and M Classes, business logic for the window will be created.
Following is an example of an X-Class :
namespace ViennaAdvantage.Model
{
/** Generated Model - DO NOT CHANGE */
using System;
using System.Text;
using VAdvantage.DataBase;
using VAdvantage.Common;
using VAdvantage.Classes;
using VAdvantage.Process;
using VAdvantage.Model;
using VAdvantage.Utility;
using System.Data;
/** Generated Model for VAT_Department
@version Vienna Framework 1.1.1 - $Id$ */
publicclassX_VAT_Department : PO
{
public X_VAT_Department (Context ctx, int VAT_Department_ID, Trx trxName) : base (ctx, VAT_Department_ID, trxName)
{
/** if (VAT_Department_ID == 0)
{
SetVAT_Department_ID (0);
}
*/
}
public X_VAT_Department (Ctx ctx, int VAT_Department_ID, Trx trxName) : base (ctx, VAT_Department_ID, trxName)
{
/** if (VAT_Department_ID == 0)
{
SetVAT_Department_ID (0);
}
*/
}
/** Load Constructor
@param ctx context
@param rs result set
@param trxName transaction
*/
public X_VAT_Department (Context ctx, DataRow rs, Trx trxName) : base(ctx, rs, trxName)
{
}
/** Load Constructor
@param ctx context
@param rs result set
@param trxName transaction
*/
public X_VAT_Department (Ctx ctx, DataRow rs, Trx trxName) : base(ctx, rs, trxName)
{
}
/** Load Constructor
@param ctx context
@param rs result set
@param trxName transaction
*/
public X_VAT_Department (Ctx ctx, IDataReader dr, Trx trxName) : base(ctx, dr, trxName)
{
}
/** Static Constructor
Set Table ID By Table Name
added by ->Harwinder */
static X_VAT_Department()
{
Table_ID = Get_Table_ID(Table_Name);
model = newKeyNamePair(Table_ID,Table_Name);
}
/** Serial Version No */
staticlong serialVersionUID = 27697468949538L;
/** Last Updated Timestamp 07-11-2014 12:30:32 */
publicstaticlong updatedMS = 1415343632749L;
/** AD_Table_ID=1000500 */
publicstaticint Table_ID;
// =1000500;
/** TableName=VAT_Department */
publicstaticString Table_Name="VAT_Department";
protectedstaticKeyNamePair model;
protectedDecimal accessLevel = newDecimal(7);
/** AccessLevel
@return 7 - System - Client - Org
*/
protectedoverrideint Get_AccessLevel()
{
returnConvert.ToInt32(accessLevel.ToString());
}
/** Load Meta Data
@param ctx context
@return PO Info
*/
protectedoverridePOInfo InitPO (Context ctx)
{
POInfo poi = POInfo.GetPOInfo (ctx, Table_ID);
return poi;
}
/** Load Meta Data
@param ctx context
@return PO Info
*/
protectedoverridePOInfo InitPO (Ctx ctx)
{
POInfo poi = POInfo.GetPOInfo (ctx, Table_ID);
return poi;
}
/** Info
@return info
*/
publicoverrideString ToString()
{
StringBuilder sb = newStringBuilder ("X_VAT_Department[").Append(Get_ID()).Append("]");
return sb.ToString();
}
/** Set Export.
@param Export_ID Export */
publicvoid SetExport_ID (String Export_ID)
{
if (Export_ID != null&& Export_ID.Length > 50)
{
log.Warning("Length > 50 - truncated");
Export_ID = Export_ID.Substring(0,50);
}
Set_Value ("Export_ID", Export_ID);
}
/** Get Export.
@return Export */
publicString GetExport_ID()
{
return (String)Get_Value("Export_ID");
}
/** Set Department Code.
@param VAT_DepartmentCode Department Code */
publicvoid SetVAT_DepartmentCode (String VAT_DepartmentCode)
{
if (VAT_DepartmentCode != null&& VAT_DepartmentCode.Length > 10)
{
log.Warning("Length > 10 - truncated");
VAT_DepartmentCode = VAT_DepartmentCode.Substring(0,10);
}
Set_Value ("VAT_DepartmentCode", VAT_DepartmentCode);
}
/** Get Department Code.
@return Department Code */
publicString GetVAT_DepartmentCode()
{
return (String)Get_Value("VAT_DepartmentCode");
}
/** Set Department Name.
@param VAT_DepartmentName Department Name */
publicvoid SetVAT_DepartmentName (String VAT_DepartmentName)
{
if (VAT_DepartmentName != null&& VAT_DepartmentName.Length > 10)
{
log.Warning("Length > 10 - truncated");
VAT_DepartmentName = VAT_DepartmentName.Substring(0,10);
}
Set_Value ("VAT_DepartmentName", VAT_DepartmentName);
}
/** Get Department Name.
@return Department Name */
publicString GetVAT_DepartmentName()
{
return (String)Get_Value("VAT_DepartmentName");
}
/** Set VAT_Department_ID.
@param VAT_Department_ID VAT_Department_ID */
publicvoid SetVAT_Department_ID (int VAT_Department_ID)
{
if (VAT_Department_ID < 1) thrownewArgumentException ("VAT_Department_ID is mandatory.");
Set_ValueNoCheck ("VAT_Department_ID", VAT_Department_ID);
}
/** Get VAT_Department_ID.
@return VAT_Department_ID */
publicint GetVAT_Department_ID()
{
Object ii = Get_Value("VAT_Department_ID");
if (ii == null) return 0;
returnConvert.ToInt32(ii);
}
}
}
X-Class’ extends the PO class which is a Standard product class and a part of Model Library.