Skip to content

Commit

Permalink
impl
Browse files Browse the repository at this point in the history
Issue #160
  • Loading branch information
rsoika committed Feb 23, 2024
1 parent a5653de commit e01e531
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import java.util.List;
import java.util.logging.Logger;

import javax.ejb.EJB;
import javax.inject.Inject;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.SignalAdapter;
import org.imixs.workflow.engine.WorkflowService;
import org.imixs.workflow.exceptions.AccessDeniedException;
import org.imixs.workflow.exceptions.AdapterException;
import org.imixs.workflow.exceptions.ModelException;
Expand Down Expand Up @@ -35,6 +38,8 @@
* <sepa-export name="modelversion">sepa-export-manual-de-3.0</sepa-export>
<sepa-export name="task">1000</sepa-export>
<sepa-export name="key">SEPA Lastschriftverfahren</sepa-export>
<sepa-export name="maxcount">100</sepa-export>
<sepa-export name="maxcount-event">20</sepa-export>
}</pre>
* <p>
* If a workitem is already been linked to a SEPA Export, nothing happens.
Expand All @@ -51,6 +56,14 @@ public class SEPARefAddAdapter implements SignalAdapter {
@Inject
SepaWorkflowService sepaWorkflowService;


@Inject
WorkflowService workflowService;


int invoicesMaxCount=0;
int invoicesMaxCountEvent=0;

/**
* This method finds or create the SEPA Export and adds a reference
* ($workitemref) to the current workitem.
Expand All @@ -67,6 +80,15 @@ public ItemCollection execute(ItemCollection workitem, ItemCollection event)
sepaWorkflowService.updateDbtrDefaultData(workitem);
sepaWorkflowService.updateCdtrDefaultData(workitem);

// compute maxcount properties....
ItemCollection sepaConfig = workflowService.evalWorkflowResult(event, "sepa-export", workitem, true);
if (sepaConfig != null ) {
logger.fine("read max count configuration from event");
if (sepaConfig.getItemValueInteger("maxcount")>0) {
invoicesMaxCount = sepaConfig.getItemValueInteger("maxcount");
invoicesMaxCountEvent = sepaConfig.getItemValueInteger("maxcount-event");
}
}

String key = sepaWorkflowService.computeKey(workitem, event);

Expand All @@ -86,6 +108,14 @@ public ItemCollection execute(ItemCollection workitem, ItemCollection event)
// set event 100
sepaExport.event(SepaWorkflowService.EVENT_ADD_REF);
sepaWorkflowService.processSEPAExport(sepaExport);

// test if the max count was reached.
if (invoicesMaxCount>0 && sepaExport.getItemValue("$workitemref").size()>=invoicesMaxCount) {
logger.info("......Max Count of " + invoicesMaxCount + " invoices reached, executing maxcount-event="+invoicesMaxCountEvent);
// process the maxcoutn event on the sepa export
sepaExport.event(invoicesMaxCountEvent);
sepaWorkflowService.processSEPAExport(sepaExport);
}
}

} catch (QueryException | AccessDeniedException | ProcessingErrorException | ModelException e1) {
Expand Down

0 comments on commit e01e531

Please sign in to comment.