Extension framework

Step 1 : create an enum with following elements:

Enum:           EAMReferenceDataType

elements are: FaultType, Correctiveaction..

Step 2: Create a class with below methods.

class eamReferenceData
{
Common common;
}

public Common parmCommon(Common _common = common)
{
common = _common;

return common;
}

public Common parmCommon(Common _common = common)
{
common = _common;

return common;
}

public static EAMReferenceData construct(EAMReferenceDataType _referenceDataType)
{
EAMReferenceData referenceData = SysExtensionAppClassFactory::getClassFromSysAttribute(classStr(EAMReferenceData), new EAMReferenceDataAtrribute(_referenceDataType));

return referenceData;
}

Step3: Create an attribute class

class eamReferenceDataAtrribute extends SysAttribute
{
EAMReferenceDataType referenceDataType;
}

public void new(EAMReferenceDataType _referenceDataType)
{
super();

this.parmreferenceDataType(_referenceDataType);
}

public EAMReferenceDataType parmreferenceDataType(EAMReferenceDataType _referenceDataType = referenceDataType)
{
referenceDataType = _referenceDataType;

return referenceDataType;
}

Step4: Now create the new class extended from class 1. This run based on the enum that we are passing.

[EAMReferenceDataAtrribute(EAMReferenceDataType::FaultType)]
public class EamReferenceData_FaultType extends EAMReferenceData
{
MROParmFaultType faultTypeLoc;
}

public void run()
{
;

super();
faultTypeLoc = this.parmCommon();
this.generateFaultTypeOutbound();
}

public void generateFaultTypeOutbound()
{
//write  ur logic.
}

//You can create as many classes as possible based on the enum elements and call them while calling using enum.

 

Step5: Calling the class based on the enum:

Class gets called based on the relevant enum.

public static void callFaultTypeService(XppPrePostArgs _args)
{
MROParmFaultType faultType;
EAMReferenceData referenceData;
;

faultType = _args.getThis();

referenceData = EAMReferenceData::construct(EAMReferenceDataType::FaultType);
referenceData.parmCommon(faultType);
referenceData.run();
}

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s