-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[26103] always produce xml with print at intermediate false for pdf
- Loading branch information
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
bundles/ch.elexis.pdfBills/src/ch/elexis/pdfBills/TarmedXmlUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package ch.elexis.pdfBills; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.StringReader; | ||
|
||
import org.jdom2.Document; | ||
import org.jdom2.JDOMException; | ||
import org.jdom2.input.SAXBuilder; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import at.medevit.elexis.tarmed.model.TarmedJaxbUtil; | ||
|
||
public class TarmedXmlUtil { | ||
|
||
/** | ||
* Modify the print at intermediate attribute of the tarmed xml {@link Document} | ||
* and return a modified {@link Document} object. | ||
* | ||
* @param document | ||
* @param value | ||
* @return | ||
*/ | ||
public static Document setPrintAtIntermediate(Document document, boolean value) { | ||
String version = TarmedJaxbUtil.getXMLVersion(document); | ||
if ("4.5".equals(version)) { | ||
ch.fd.invoice450.request.RequestType invoiceRequest = TarmedJaxbUtil.unmarshalInvoiceRequest450(document); | ||
setPrintAtIntermediate(invoiceRequest, value); | ||
|
||
ByteArrayOutputStream xmlOutput = new ByteArrayOutputStream(); | ||
if (TarmedJaxbUtil.marshallInvoiceRequest(invoiceRequest, xmlOutput)) { | ||
SAXBuilder builder = new SAXBuilder(); | ||
try { | ||
return builder.build(new StringReader(xmlOutput.toString())); | ||
} catch (IOException | JDOMException e) { | ||
LoggerFactory.getLogger(TarmedXmlUtil.class).error("Error loading existing xml document", e); | ||
} | ||
} | ||
} else { | ||
LoggerFactory.getLogger(TarmedXmlUtil.class) | ||
.error("Could not modify xml document with version [" + version + "]"); | ||
} | ||
return document; | ||
} | ||
|
||
private static void setPrintAtIntermediate(ch.fd.invoice450.request.RequestType invoiceRequest, boolean value) { | ||
if (invoiceRequest != null && invoiceRequest.getProcessing() != null) { | ||
invoiceRequest.getProcessing().setPrintAtIntermediate(value); | ||
} | ||
} | ||
} |