first draft zahlungsavis
This commit is contained in:
parent
b6518726d9
commit
cbfeb8ef38
6 changed files with 171 additions and 13 deletions
|
|
@ -25,7 +25,7 @@ import org.imixs.workflow.exceptions.PluginException;
|
||||||
* <p>
|
* <p>
|
||||||
* The adapter can be configured through the model result item 'cargosoft'
|
* The adapter can be configured through the model result item 'cargosoft'
|
||||||
* <p>
|
* <p>
|
||||||
* report = report definition to transfere the workitem into the cargosoft xml
|
* report = report definition to transfers the workitem into the cargosoft xml
|
||||||
* structure
|
* structure
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,16 @@ import org.imixs.workflow.exceptions.QueryException;
|
||||||
* Wurde die Rechnugn bereits einem Zahlungsavis zugeordnet passiert nichts.
|
* Wurde die Rechnugn bereits einem Zahlungsavis zugeordnet passiert nichts.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @author rsoika
|
* @author rsoika
|
||||||
*/
|
*/
|
||||||
public class ZahlungsavisAdapter implements SignalAdapter {
|
public class ZahlungsavisAppendAdapter implements SignalAdapter {
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger(ZahlungsavisAdapter.class.getName());
|
private static Logger logger = Logger.getLogger(ZahlungsavisAppendAdapter.class.getName());
|
||||||
|
|
||||||
public static final String ERROR_MISSING_DATA = "MISSING_DATA";
|
public static final String ERROR_MISSING_DATA = "MISSING_DATA";
|
||||||
|
public static final String ERROR_CONFIG = "CONFIG_ERROR";
|
||||||
|
|
||||||
public static final String ITEM_CDTR_NUMBER = "cdtr.number";
|
public static final String ITEM_CDTR_NUMBER = "cdtr.number";
|
||||||
public static final String ITEM_CDTR_NAME = "cdtr.name";
|
public static final String ITEM_CDTR_NAME = "cdtr.name";
|
||||||
|
|
@ -46,10 +48,22 @@ public class ZahlungsavisAdapter implements SignalAdapter {
|
||||||
* @throws PluginException
|
* @throws PluginException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemCollection execute(ItemCollection invoice, ItemCollection event)
|
public ItemCollection execute(ItemCollection document, ItemCollection event)
|
||||||
throws AdapterException, PluginException {
|
throws AdapterException, PluginException {
|
||||||
|
|
||||||
String cdtrNumber = invoice.getItemValueString(ITEM_CDTR_NUMBER);
|
appendInvoice(document);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese method hängt eine referenz der aktuellen Rechnung an den Zahlungsavis
|
||||||
|
*
|
||||||
|
* @param document
|
||||||
|
* @throws PluginException
|
||||||
|
*/
|
||||||
|
private void appendInvoice(ItemCollection document) throws PluginException {
|
||||||
|
String cdtrNumber = document.getItemValueString(ITEM_CDTR_NUMBER);
|
||||||
|
|
||||||
if (cdtrNumber == null || cdtrNumber.isEmpty()) {
|
if (cdtrNumber == null || cdtrNumber.isEmpty()) {
|
||||||
throw new PluginException(PluginException.class.getName(), ERROR_MISSING_DATA,
|
throw new PluginException(PluginException.class.getName(), ERROR_MISSING_DATA,
|
||||||
|
|
@ -63,15 +77,15 @@ public class ZahlungsavisAdapter implements SignalAdapter {
|
||||||
// create a new one
|
// create a new one
|
||||||
zahlungsAvis = new ItemCollection().workflowGroup("Zahlungsavis").task(1000).event(100);
|
zahlungsAvis = new ItemCollection().workflowGroup("Zahlungsavis").task(1000).event(100);
|
||||||
// add cdtr.name
|
// add cdtr.name
|
||||||
zahlungsAvis.setItemValue(ITEM_CDTR_NAME, invoice.getItemValue(ITEM_CDTR_NAME));
|
zahlungsAvis.setItemValue(ITEM_CDTR_NAME, document.getItemValue(ITEM_CDTR_NAME));
|
||||||
zahlungsAvis.setItemValue(ITEM_CDTR_NUMBER, invoice.getItemValue(ITEM_CDTR_NUMBER));
|
zahlungsAvis.setItemValue(ITEM_CDTR_NUMBER, document.getItemValue(ITEM_CDTR_NUMBER));
|
||||||
zahlungsAvis.setItemValue(ITEM_CDTR_NAME_CARGOSOFT, invoice.getItemValue(ITEM_CDTR_NAME_CARGOSOFT));
|
zahlungsAvis.setItemValue(ITEM_CDTR_NAME_CARGOSOFT, document.getItemValue(ITEM_CDTR_NAME_CARGOSOFT));
|
||||||
} else {
|
} else {
|
||||||
// zahlungsavis speichern
|
// zahlungsavis speichern
|
||||||
zahlungsAvis.event(100);
|
zahlungsAvis.event(100);
|
||||||
}
|
}
|
||||||
// Invoice mit zahlungsavis verknüpften (falls noch nicht verknüpft)
|
// Invoice mit zahlungsavis verknüpften (falls noch nicht verknüpft)
|
||||||
zahlungsAvis.appendItemValueUnique("$workitemref", invoice.getUniqueID());
|
zahlungsAvis.appendItemValueUnique("$workitemref", document.getUniqueID());
|
||||||
workflowService.processWorkItem(zahlungsAvis);
|
workflowService.processWorkItem(zahlungsAvis);
|
||||||
|
|
||||||
} catch (QueryException | AccessDeniedException | ProcessingErrorException | ModelException e1) {
|
} catch (QueryException | AccessDeniedException | ProcessingErrorException | ModelException e1) {
|
||||||
|
|
@ -79,8 +93,6 @@ public class ZahlungsavisAdapter implements SignalAdapter {
|
||||||
"Es konnte kein Zahlungsavis zugewiesen werden: " + e1.getMessage());
|
"Es konnte kein Zahlungsavis zugewiesen werden: " + e1.getMessage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return invoice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -0,0 +1,131 @@
|
||||||
|
package com.alexanderlogistics;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.imixs.workflow.FileData;
|
||||||
|
import org.imixs.workflow.ItemCollection;
|
||||||
|
import org.imixs.workflow.SignalAdapter;
|
||||||
|
import org.imixs.workflow.engine.DocumentService;
|
||||||
|
import org.imixs.workflow.engine.WorkflowService;
|
||||||
|
import org.imixs.workflow.exceptions.AdapterException;
|
||||||
|
import org.imixs.workflow.exceptions.PluginException;
|
||||||
|
import org.imixs.workflow.exceptions.QueryException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der ZahlungsavisAdapter importiert eine Excel Datei aus einem Textblock
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
<zahlungsavis name="textblock">textblock-ref</zahlungsavis>
|
||||||
|
<zahlungsavis name="template">filename</zahlungsavis>
|
||||||
|
}
|
||||||
|
* </pre>
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @version 1.0
|
||||||
|
* @author rsoika
|
||||||
|
*/
|
||||||
|
public class ZahlungsavisExportAdapter implements SignalAdapter {
|
||||||
|
|
||||||
|
private static Logger logger = Logger.getLogger(ZahlungsavisExportAdapter.class.getName());
|
||||||
|
|
||||||
|
public static final String ERROR_CONFIG = "CONFIG_ERROR";
|
||||||
|
final String TYPE_TEXTBLOCK = "textblock";
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
WorkflowService workflowService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DocumentService documentService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method finds or create the Zahlungsavis and adds a reference
|
||||||
|
* ($workitemref) to the current invoice.
|
||||||
|
*
|
||||||
|
* @throws PluginException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemCollection execute(ItemCollection document, ItemCollection event)
|
||||||
|
throws AdapterException, PluginException {
|
||||||
|
|
||||||
|
// read the zahlungsavis options
|
||||||
|
ItemCollection evalItemCollection = workflowService.evalWorkflowResult(event, "zahlungsavis", document, false);
|
||||||
|
if (evalItemCollection == null) {
|
||||||
|
throw new PluginException(ZahlungsavisExportAdapter.class.getSimpleName(), ERROR_CONFIG,
|
||||||
|
"missing zahlungsavis configuration in model event - please check model configuration");
|
||||||
|
}
|
||||||
|
String textblock = evalItemCollection.getItemValueString("textblock");
|
||||||
|
String template = evalItemCollection.getItemValueString("template");
|
||||||
|
|
||||||
|
appendExcelTemplate(document, textblock, template);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method loads a text-block for a specified ref and appends the named
|
||||||
|
* fileData object of this document.
|
||||||
|
*
|
||||||
|
* @param document
|
||||||
|
* @throws PluginException
|
||||||
|
*/
|
||||||
|
private void appendExcelTemplate(ItemCollection document, String textblockRef, String template)
|
||||||
|
throws PluginException {
|
||||||
|
|
||||||
|
if ((template == null || template.isEmpty()) || (textblockRef == null || textblockRef.isEmpty())) {
|
||||||
|
throw new PluginException(ZahlungsavisExportAdapter.class.getSimpleName(), ERROR_CONFIG,
|
||||||
|
"invalid zahlungsavis configuration in model event - textblock/template reference not defined!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// load the text block
|
||||||
|
FileData fileData = null;
|
||||||
|
ItemCollection textBlockItemCollection = loadTextBlock(textblockRef);
|
||||||
|
if (textBlockItemCollection != null) {
|
||||||
|
// fetch attachment
|
||||||
|
fileData = textBlockItemCollection.getFileData(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
// do we found the document?
|
||||||
|
if (fileData == null) {
|
||||||
|
throw new PluginException(ZahlungsavisExportAdapter.class.getSimpleName(), ERROR_CONFIG,
|
||||||
|
"invalid zahlungsavis configuration in model event - template=" + template + " not found!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// append document
|
||||||
|
logger.info("...append new Zahlugnsavis Template: " + template);
|
||||||
|
document.addFileData(fileData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a text-block ItemCollection for a specified name.
|
||||||
|
*
|
||||||
|
* @param name in attribute txtname
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ItemCollection loadTextBlock(String name) {
|
||||||
|
ItemCollection textBlockItemCollection = null;
|
||||||
|
|
||||||
|
// load text-block by name....
|
||||||
|
String sQuery = "(type:\"" + TYPE_TEXTBLOCK + "\" AND txtname:\"" + name + "\")";
|
||||||
|
Collection<ItemCollection> col;
|
||||||
|
try {
|
||||||
|
col = documentService.find(sQuery, 1, 0);
|
||||||
|
|
||||||
|
if (col.size() > 0) {
|
||||||
|
textBlockItemCollection = col.iterator().next();
|
||||||
|
} else {
|
||||||
|
logger.warning("Missing text-block : '" + name + "'");
|
||||||
|
}
|
||||||
|
} catch (QueryException e) {
|
||||||
|
logger.warning("getTextBlock - invalid query: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return textBlockItemCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
BIN
reports/zahlungsavis/zahlungsavis_template.xls
Normal file
BIN
reports/zahlungsavis/zahlungsavis_template.xls
Normal file
Binary file not shown.
|
|
@ -46,7 +46,7 @@
|
||||||
<bpmn2:signal id="Signal_3" name="com.alexanderlogistics.CargosoftExportAdapter"/>
|
<bpmn2:signal id="Signal_3" name="com.alexanderlogistics.CargosoftExportAdapter"/>
|
||||||
<bpmn2:signal id="Signal_4" name="com.alexanderlogistics.CargosoftSplitAdapter"/>
|
<bpmn2:signal id="Signal_4" name="com.alexanderlogistics.CargosoftSplitAdapter"/>
|
||||||
<bpmn2:signal id="Signal_5" name="org.imixs.ml.workflow.MLAdapter"/>
|
<bpmn2:signal id="Signal_5" name="org.imixs.ml.workflow.MLAdapter"/>
|
||||||
<bpmn2:signal id="Signal_1" name="com.alexanderlogistics.ZahlungsavisAdapter"/>
|
<bpmn2:signal id="Signal_1" name="com.alexanderlogistics.ZahlungsavisAppendAdapter"/>
|
||||||
<bpmn2:collaboration id="Collaboration_1">
|
<bpmn2:collaboration id="Collaboration_1">
|
||||||
<bpmn2:participant id="Participant_1" name="Rechnungseingang" processRef="Process_1"/>
|
<bpmn2:participant id="Participant_1" name="Rechnungseingang" processRef="Process_1"/>
|
||||||
</bpmn2:collaboration>
|
</bpmn2:collaboration>
|
||||||
|
|
@ -5626,6 +5626,11 @@ result.isValid=true;
|
||||||
<bpmn2:sequenceFlow id="SequenceFlow_115" sourceRef="IntermediateCatchEvent_56" targetRef="IntermediateThrowEvent_9"/>
|
<bpmn2:sequenceFlow id="SequenceFlow_115" sourceRef="IntermediateCatchEvent_56" targetRef="IntermediateThrowEvent_9"/>
|
||||||
<bpmn2:sequenceFlow id="SequenceFlow_116" sourceRef="EventBasedGateway_3" targetRef="IntermediateCatchEvent_56"/>
|
<bpmn2:sequenceFlow id="SequenceFlow_116" sourceRef="EventBasedGateway_3" targetRef="IntermediateCatchEvent_56"/>
|
||||||
<bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_57" imixs:activityid="50" name="Zahlungsavis">
|
<bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_57" imixs:activityid="50" name="Zahlungsavis">
|
||||||
|
<bpmn2:extensionElements>
|
||||||
|
<imixs:item name="txtactivityresult" type="CDATA">
|
||||||
|
<imixs:value><![CDATA[]]></imixs:value>
|
||||||
|
</imixs:item>
|
||||||
|
</bpmn2:extensionElements>
|
||||||
<bpmn2:outgoing>SequenceFlow_119</bpmn2:outgoing>
|
<bpmn2:outgoing>SequenceFlow_119</bpmn2:outgoing>
|
||||||
<bpmn2:dataOutput id="DataOutput_2" name="Signal_1_Output"/>
|
<bpmn2:dataOutput id="DataOutput_2" name="Signal_1_Output"/>
|
||||||
<bpmn2:dataOutputAssociation id="DataOutputAssociation_2">
|
<bpmn2:dataOutputAssociation id="DataOutputAssociation_2">
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
<imixs:value><![CDATA[org.imixs.marty.profile.MailPlugin]]></imixs:value>
|
<imixs:value><![CDATA[org.imixs.marty.profile.MailPlugin]]></imixs:value>
|
||||||
</imixs:item>
|
</imixs:item>
|
||||||
</bpmn2:extensionElements>
|
</bpmn2:extensionElements>
|
||||||
|
<bpmn2:signal id="Signal_1" name="com.alexanderlogistics.ZahlungsavisExportAdapter"/>
|
||||||
<bpmn2:message id="Message_6" name="SEPA-Body">
|
<bpmn2:message id="Message_6" name="SEPA-Body">
|
||||||
<bpmn2:documentation id="Documentation_15"><![CDATA[Der folgende SEPA Lauf wurde für die Verarbeitung fertiggestellt:
|
<bpmn2:documentation id="Documentation_15"><![CDATA[Der folgende SEPA Lauf wurde für die Verarbeitung fertiggestellt:
|
||||||
|
|
||||||
|
|
@ -327,7 +328,8 @@ result.isValid=true;
|
||||||
<imixs:value><![CDATA[]]></imixs:value>
|
<imixs:value><![CDATA[]]></imixs:value>
|
||||||
</imixs:item>
|
</imixs:item>
|
||||||
<imixs:item name="txtactivityresult" type="xs:string">
|
<imixs:item name="txtactivityresult" type="xs:string">
|
||||||
<imixs:value><![CDATA[<item name="action">home</item>]]></imixs:value>
|
<imixs:value><![CDATA[ <zahlungsavis name="textblock">Zahlugnsavis Template</zahlungsavis>
|
||||||
|
<zahlungsavis name="template">zahlungsavis_template.xls</zahlungsavis>]]></imixs:value>
|
||||||
</imixs:item>
|
</imixs:item>
|
||||||
<imixs:item name="keyownershipmode" type="xs:string">
|
<imixs:item name="keyownershipmode" type="xs:string">
|
||||||
<imixs:value><![CDATA[0]]></imixs:value>
|
<imixs:value><![CDATA[0]]></imixs:value>
|
||||||
|
|
@ -342,6 +344,14 @@ result.isValid=true;
|
||||||
<bpmn2:documentation id="Documentation_53"><![CDATA[Vorgang abschließen und archivieren]]></bpmn2:documentation>
|
<bpmn2:documentation id="Documentation_53"><![CDATA[Vorgang abschließen und archivieren]]></bpmn2:documentation>
|
||||||
<bpmn2:incoming>SequenceFlow_8</bpmn2:incoming>
|
<bpmn2:incoming>SequenceFlow_8</bpmn2:incoming>
|
||||||
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
|
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
|
||||||
|
<bpmn2:dataOutput id="DataOutput_1" name="Signal_1_Output"/>
|
||||||
|
<bpmn2:dataOutputAssociation id="DataOutputAssociation_1">
|
||||||
|
<bpmn2:sourceRef>DataOutput_1</bpmn2:sourceRef>
|
||||||
|
</bpmn2:dataOutputAssociation>
|
||||||
|
<bpmn2:outputSet id="OutputSet_1" name="Output Set 1">
|
||||||
|
<bpmn2:dataOutputRefs>DataOutput_1</bpmn2:dataOutputRefs>
|
||||||
|
</bpmn2:outputSet>
|
||||||
|
<bpmn2:signalEventDefinition id="SignalEventDefinition_1" signalRef="Signal_1"/>
|
||||||
</bpmn2:intermediateCatchEvent>
|
</bpmn2:intermediateCatchEvent>
|
||||||
<bpmn2:sequenceFlow id="SequenceFlow_2" sourceRef="IntermediateCatchEvent_18" targetRef="Task_2"/>
|
<bpmn2:sequenceFlow id="SequenceFlow_2" sourceRef="IntermediateCatchEvent_18" targetRef="Task_2"/>
|
||||||
<bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_6" imixs:activityid="10" name="Speichern">
|
<bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_6" imixs:activityid="10" name="Speichern">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue