POST target process of entity
Requirement:
Invoke custom jobs once the entity load is complete in DMF.
Solution:
writing a postTargetProcess method on the entity it will run after the import completion either succeeded or failed.
/// <summary>
/// After the entity has finished loading in the tables, it triggers a process to ship the transfer orders.
/// </summary>
/// <param name = "_dmfDefinitionGroupExecution">
/// The definition group that should be processed.
/// </param>
public static void postTargetProcess(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
{
PopulateTransferService PopulateTransferService;
PopulateTransferContract PopulateTransferContract;
Query query;
//check if the import job is finished without errors
if (_dmfDefinitionGroupExecution.StagingStatus == DMFBatchJobStatus::Finished
&& !InboundEntity::isImportCompleteWithoutError(_dmfDefinitionGroupExecution.ExecutionId,_dmfDefinitionGroupExecution.RecId))
{
//initializing the job we want to invoke
PopulateTransferService = new PopulateTransferService();
PopulateTransferContract = new PopulateTransferContract();
query = new Query(queryStr(PopulateTransferQuery));/// After the entity has finished loading in the tables, it triggers a process to ship the transfer orders.
/// </summary>
/// <param name = "_dmfDefinitionGroupExecution">
/// The definition group that should be processed.
/// </param>
public static void postTargetProcess(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
{
PopulateTransferService PopulateTransferService;
PopulateTransferContract PopulateTransferContract;
Query query;
//check if the import job is finished without errors
if (_dmfDefinitionGroupExecution.StagingStatus == DMFBatchJobStatus::Finished
&& !InboundEntity::isImportCompleteWithoutError(_dmfDefinitionGroupExecution.ExecutionId,_dmfDefinitionGroupExecution.RecId))
{
//initializing the job we want to invoke
PopulateTransferService = new PopulateTransferService();
PopulateTransferContract = new PopulateTransferContract();
PopulateTransferContract.setQuery(query);
PopulateTransferService.process(PopulateTransferContract);
}
}
we want our process to run only when the import job is completed successfully so adding a method to check the complete success of entity import.
/// <summary>
/// Check whether all the entities in the project are imported correctly
/// Check whether all the entities in the project are imported correctly
/// </summary>
/// <param name = "_executionId">execution id of the job</param>
/// <param name = "_recId">recid of last entity</param>
/// <returns>return true or false </returns>
/// <param name = "_executionId">execution id of the job</param>
/// <param name = "_recId">recid of last entity</param>
/// <returns>return true or false </returns>
private static boolean isImportCompleteWithoutError(DMFExecutionId _executionId, RecId _recId)
{
DMFDefinitionGroupExecution groupExecution;
boolean isError = false;
while select * from groupExecution
where groupExecution.ExecutionId == _executionId
&& groupExecution.RecId != _recId
{
DMFExecutionSummaryStatus currentEntityStatus = groupExecution.GetExecutionSummaryStatus();
if (currentEntityStatus != DMFExecutionSummaryStatus::Succeeded)
{
return true;
}
}
return isError;
}
{
DMFDefinitionGroupExecution groupExecution;
boolean isError = false;
while select * from groupExecution
where groupExecution.ExecutionId == _executionId
&& groupExecution.RecId != _recId
{
DMFExecutionSummaryStatus currentEntityStatus = groupExecution.GetExecutionSummaryStatus();
if (currentEntityStatus != DMFExecutionSummaryStatus::Succeeded)
{
return true;
}
}
return isError;
}
Comments
Post a Comment