[ExtensionOf(formStr(JmgRegistration))]
final class JmgRegistration_Extension
{
public QueryBuildDataSource qbdsJmgIpcActivityIndirectactivity;
public container containerActivityId, conResourceGroup;
public void showIPC()
{
WrkCtrTable selectedWrkCtrTable;
WrkCtrResourceGroup wrkCtrResourceGroup;
next showIPC();
containerActivityId = conNull();
conResourceGroup = conNull();
//Filter the data based on the resource group
if (curWrkCtrId)
{
conResourceGroup += curWrkCtrId;
selectedWrkCtrTable = WrkCtrTable::find(curWrkCtrId);
//Checking for only resource groups but not resources in the WrkCtrTable.
if (selectedWrkCtrTable.IsIndividualResource == NoYes::No)
{
this.JmgIpcActivityIndirectactivityRange();
}
}
//Filter the data based on the production unit with no resource group
if(curProdUnitId && !curWrkCtrId)
{
//Fetching the list of resource group that are attached to a production unit.
while select wrkCtrId from wrkCtrResourceGroup
where wrkCtrResourceGroup.ProdUnitId == curProdUnitId
{
conResourceGroup += wrkCtrResourceGroup.WrkCtrId;
}
this.JmgIpcActivityIndirectactivityRange();
}
jmgJobTable_DS.executeQuery();
}
//Filter the form datasource JmgJobTable_ds based on the activityID list.
public void JmgIpcActivityIndirectactivityRange()
{
Query queryJmgIpResourceGroup, queryJmgIpActivity;
QueryBuildDataSource qbdsJmgIpResourceGroup, qbdsJmgIpActivity;
QueryBuildRange qbrJmgIpResourceGroup, qbrJmgIpActivity;
QueryRun qrJmgIpResourceGroup, qrJmgIpActivity;
WrkCtrResourceGroup wrkCtrResourceGroup;
JmgIpcActivity jmgIpActivity;
JmgIpActivityResourceGroup jmgIpResourceGroup;
//Query to fetch the list of activityID's with the resource groups attached.
queryJmgIpResourceGroup = new Query();
qbdsJmgIpResourceGroup = queryJmgIpResourceGroup.addDataSource(tableNum(JmgIpActivityResourceGroup));
qbdsJmgIpResourceGroup.addGroupByField(fieldNum(JmgIpActivityResourceGroup, Activity));
qbdsJmgIpResourceGroup.addGroupByField(fieldNum(JmgIpActivityResourceGroup, WrkCtrId));
qbrJmgIpResourceGroup = qbdsJmgIpResourceGroup.addRang e(fieldNum(JmgIpActivityResourceGroup, WrkCtrId));
qbrJmgIpResourceGroup.value(con2Str(conResourceGroup));
qbdsJmgIpActivity = qbdsJmgIpResourceGroup.addDataSource(tableNum(JmgIpcActivity));
qbdsJmgIpActivity.joinMode(JoinMode::ExistsJoin);
qbdsJmgIpActivity.addLink(fieldNum(JmgIpActivityResourceGroup, Activity),fieldNum(JmgIpcActivity, Activity));
qrJmgIpResourceGroup = new QueryRun(queryJmgIpResourceGroup);
while (qrJmgIpResourceGroup.next())
{
jmgIpResourceGroup = qrJmgIpResourceGroup.get(tableNum(JmgIpActivityResourceGroup));
containerActivityId += jmgIpResourceGroup.Activity;
}
//Query to fetch the list of activityID's without the resource group
queryJmgIpActivity = new Query();
qbdsJmgIpActivity = queryJmgIpActivity.addDataSource(tableNum(JmgIpcActivity));
qbdsJmgIpResourceGroup = qbdsJmgIpActivity.addDataSource(tableNum(JmgIpActivityResourceGroup));
qbdsJmgIpResourceGroup.joinMode(JoinMode::NoExistsJoin);
qbdsJmgIpResourceGroup.addLink(fieldNum(JmgIpcActivity, Activity),fieldNum(JmgIpActivityResourceGroup, Activity));
qrJmgIpActivity = new QueryRun(queryJmgIpActivity);
while (qrJmgIpActivity.next())
{
jmgIpActivity = qrJmgIpActivity.get(tableNum(JmgIpcActivity));
containerActivityId += jmgIpActivity.Activity;
}
//Final query to filter the data in the JmgJobTable_ds based on the activityID list.
qbdsJmgIpcActivityIndirectactivity = qbdsJmgJobTable.addDataSource(tableNum(JmgIpcActivity));
qbdsJmgIpcActivityIndirectactivity.joinMode(JoinMode::ExistsJoin);
qbdsJmgIpcActivityIndirectactivity.addLink(fieldNum(JmgJobTable, JobId),fieldNum(JmgIpcActivity, JobId));
qbdsJmgIpcActivityIndirectactivity.addRange(fieldNum(JmgIpcActivity, Activity)).value(con2Str(containerActivityId));
}
public void removeJmgIpcActivityIndirectactivityRange()
{
if (qbdsJmgIpcActivityIndirectactivity)
{
qbdsJmgIpcActivityIndirectactivity.enabled(false);
}
}
}
// To remove the newly build query when standard query being executed and thus making the datasource to work based on the standard behaviour.
class JmgRegistrationsEventHandlers
{
[PreHandlerFor(formStr(JmgRegistration), formMethodStr(JmgRegistration, showProductionJobs))]
public static void JmgRegistration_Pre_showProductionJobs(XppPrePostArgs args)
{
FormRun jmgRegistration = args.getThis();
jmgRegistration.removeJmgIpcActivityIndirectactivityRange();
}
[PreHandlerFor(formStr(JmgRegistration), formMethodStr(JmgRegistration, showProject))]
public static void JmgRegistration_Pre_showProject(XppPrePostArgs args)
{
FormRun jmgRegistration = args.getThis();
jmgRegistration.removeJmgIpcActivityIndirectactivityRange();
}
[PreHandlerFor(formStr(JmgRegistration), formMethodStr(JmgRegistration, showIPC))]
public static void JmgRegistration_Pre_showIPC(XppPrePostArgs args)
{
FormRun jmgRegistration = args.getThis();
jmgRegistration.removeJmgIpcActivityIndirectactivityRange();
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment