Skip to content

Commit

Permalink
einvoiceutils, code cleanup. issue #2165
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Sep 10, 2024
1 parent 95fb214 commit 0f77362
Show file tree
Hide file tree
Showing 15 changed files with 834 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,9 @@ public void display() {
if(insTest!=null && insTest instanceof InsuranceInfo)
insTest2=(InsuranceInfo) this.data.get("claimdetails.insurance");

final InsuranceInfo insurance = insTest2;

final InsuranceInfo insurance = insTest2;
final ArrayList<DrebisPerson> persons = (ArrayList<DrebisPerson>) this.data.get("clients.drebispersons");

final ArrayList<DrebisPerson> others = (ArrayList<DrebisPerson>) this.data.get("others.drebispersons");

final ArrayList<ArchiveFileDocumentsBean> drebDocs = (ArrayList<ArchiveFileDocumentsBean>) this.data.get("documents.drebisdocumentbeans");

new Thread(() -> {
Expand All @@ -875,7 +872,6 @@ public void display() {
for (ArchiveFileDocumentsBean doc: drebDocs) {

ThreadUtils.appendToTextArea("Konvertiere zu PDF: " + doc.getName() + "...", taLog);
//byte[] content = locator.lookupArchiveFileServiceRemote().getDocumentContent(doc.getId());
byte[] content=CachingDocumentLoader.getInstance().getDocument(doc.getId());
String tmpUrl = FileUtils.createTempFile(doc.getName(), content);

Expand Down Expand Up @@ -924,16 +920,12 @@ public void display() {
} catch (DrebisException de) {
log.error("Error submitting claim note", de);
ThreadUtils.appendToTextArea("FEHLER: " + de.getId() + " " + de.getMessage() + " (" + de.getDetailMessage() + "); Objekt: " + de.getErrorObject(), taLog);
return;

} catch (Exception e) {
log.error("Error submitting claim note", e);
ThreadUtils.appendToTextArea("FEHLER: " + e.getMessage(), taLog);
return;
}
}).start();

return;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,21 +697,19 @@ public class SubmitCoverageStep extends javax.swing.JPanel implements WizardStep
private WizardDataContainer data = null;

/**
* Creates new form SampleStep1
* Creates new form SubmitCoverageStep
*/
public SubmitCoverageStep() {
initComponents();
}

@Override
public void nextEvent() {
// this.data.put("data1", this.jTextField1.getText());
return;
}

@Override
public void previousEvent() {
// this.data.put("data1", this.jTextField1.getText());
return;
}

Expand Down Expand Up @@ -851,88 +849,71 @@ public void display() {


final String lBreak = System.getProperty("line.separator");
//this.taSummary.append("Akte: " + this.data.get("clients.archivefilenumber") + " " + this.data.get("clients.archivefilename"));
final InsuranceInfo insurance = (InsuranceInfo) this.data.get("clients.insurance");
//this.taSummary.append("Versicherung: VS " + this.data.get("clients.insurancepolicy") + " bei der " + insName);


final ArrayList<DrebisPerson> persons = (ArrayList<DrebisPerson>) this.data.get("clients.drebispersons");

final ArrayList<DrebisPerson> others = (ArrayList<DrebisPerson>) this.data.get("others.drebispersons");

final ArrayList<ArchiveFileDocumentsBean> drebDocs = (ArrayList<ArchiveFileDocumentsBean>) this.data.get("documents.drebisdocumentbeans");

new Thread(new Runnable() {

public void run() {
try {
ClientSettings settings = ClientSettings.getInstance();
FileConverter conv = FileConverter.getInstance();
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
ArchiveFileServiceRemote remote = locator.lookupArchiveFileServiceRemote();
DrebisServiceRemote drebis=locator.lookupDrebisServiceRemote();
new Thread(() -> {
try {
ClientSettings settings = ClientSettings.getInstance();
FileConverter conv = FileConverter.getInstance();
JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties());
ArchiveFileServiceRemote remote = locator.lookupArchiveFileServiceRemote();
DrebisServiceRemote drebis=locator.lookupDrebisServiceRemote();

ArrayList<DrebisDocument> dDocs=new ArrayList<DrebisDocument>();
for (ArchiveFileDocumentsBean doc: drebDocs) {

ArrayList<DrebisDocument> dDocs=new ArrayList<DrebisDocument>();
//Base64 base64=new Base64();
for (ArchiveFileDocumentsBean doc: drebDocs) {

ThreadUtils.appendToTextArea("Konvertiere zu PDF: " + doc.getName() + "...", taLog);
//byte[] content = locator.lookupArchiveFileServiceRemote().getDocumentContent(doc.getId());
byte[] content=CachingDocumentLoader.getInstance().getDocument(doc.getId());
String tmpUrl = FileUtils.createTempFile(doc.getName(), content);
if (doc.getName().toLowerCase().endsWith(".pdf")) {
//dlg.addAttachment(tmpUrl, doc.getDictateSign());
//String b64=base64.encode(content);
//DrebisDocument dDoc=new DrebisDocument(doc.getName(), b64.getBytes("UTF-8"));
DrebisDocument dDoc=new DrebisDocument(doc.getName(), content);
dDocs.add(dDoc);
ThreadUtils.appendToTextArea("Konvertiere zu PDF: " + doc.getName() + "...", taLog);
byte[] content=CachingDocumentLoader.getInstance().getDocument(doc.getId());
String tmpUrl = FileUtils.createTempFile(doc.getName(), content);
if (doc.getName().toLowerCase().endsWith(".pdf")) {
DrebisDocument dDoc=new DrebisDocument(doc.getName(), content);
dDocs.add(dDoc);
ThreadUtils.appendToTextArea("fertig" + lBreak, taLog);

} else {
String pdfUrl = conv.convertToPDF(tmpUrl);
File pdfFile=new File(pdfUrl);
byte[] pdfContent=FileUtils.readFile(pdfFile);
DrebisDocument dDoc=new DrebisDocument(pdfFile.getName(), pdfContent);
dDocs.add(dDoc);
try {
// give some more time to LibreOfficed to shut down
Thread.sleep(2500);
ThreadUtils.appendToTextArea("fertig" + lBreak, taLog);

} else {
String pdfUrl = conv.convertToPDF(tmpUrl);
File pdfFile=new File(pdfUrl);
byte[] pdfContent=FileUtils.readFile(pdfFile);
//String b64=base64.encode(pdfContent);
//DrebisDocument dDoc=new DrebisDocument(pdfFile.getName(), b64.getBytes("UTF-8"));
DrebisDocument dDoc=new DrebisDocument(pdfFile.getName(), pdfContent);
dDocs.add(dDoc);
try {
// give some more time to LibreOfficed to shut down
Thread.sleep(2500);
ThreadUtils.appendToTextArea("fertig" + lBreak, taLog);
} catch (Throwable t) {
ThreadUtils.appendToTextArea("FEHLER: " + t.getMessage() + lBreak, taLog);
log.error(t);
return;
}

//dlg.addAttachment(pdfUrl, doc.getDictateSign());
new File(tmpUrl).deleteOnExit();
} catch (Throwable t) {
ThreadUtils.appendToTextArea("FEHLER: " + t.getMessage() + lBreak, taLog);
log.error(t);
return;
}

new File(tmpUrl).deleteOnExit();
}

ThreadUtils.appendToTextArea("Sende an Drebis...", taLog);
String url=drebis.sendCoverageRequest((String)data.get("archiveFile.id"), (String)data.get("clients.archivefilename"), insurance, (String)data.get("clients.insurancepolicy"), persons, others, dDocs);
ThreadUtils.appendToTextArea("fertig", taLog);
ThreadUtils.appendToTextArea(lBreak + lBreak + "Beenden Sie jetzt den Vorgang im Drebis-Portal über den unten angegebenen URL!", taLog);
ThreadUtils.updateTextField(txtDrebisUrl, url);
ThreadUtils.enableComponent(cmdCopy, true);
ThreadUtils.enableComponent(cmdOpenDrebis, true);

} catch (DrebisException de) {
log.error("Error submitting coverage request", de);
ThreadUtils.appendToTextArea("FEHLER: " + de.getId() + " " + de.getMessage() + " (" + de.getDetailMessage() + "); Objekt: " + de.getErrorObject(), taLog);
return;

} catch (Exception e) {
log.error("Error submitting coverage request", e);
ThreadUtils.appendToTextArea("FEHLER: " + e.getMessage(), taLog);
return;
}

ThreadUtils.appendToTextArea("Sende an Drebis...", taLog);
String url=drebis.sendCoverageRequest((String)data.get("archiveFile.id"), (String)data.get("clients.archivefilename"), insurance, (String)data.get("clients.insurancepolicy"), persons, others, dDocs);
ThreadUtils.appendToTextArea("fertig", taLog);
ThreadUtils.appendToTextArea(lBreak + lBreak + "Beenden Sie jetzt den Vorgang im Drebis-Portal über den unten angegebenen URL!", taLog);
ThreadUtils.updateTextField(txtDrebisUrl, url);
ThreadUtils.enableComponent(cmdCopy, true);
ThreadUtils.enableComponent(cmdOpenDrebis, true);

} catch (DrebisException de) {
log.error("Error submitting coverage request", de);
ThreadUtils.appendToTextArea("FEHLER: " + de.getId() + " " + de.getMessage() + " (" + de.getDetailMessage() + "); Objekt: " + de.getErrorObject(), taLog);

} catch (Exception e) {
log.error("Error submitting coverage request", e);
ThreadUtils.appendToTextArea("FEHLER: " + e.getMessage(), taLog);
}
}).start();

return;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,13 +697,11 @@ public SubmitFreeTextStep() {

@Override
public void nextEvent() {
// this.data.put("data1", this.jTextField1.getText());
return;
}

@Override
public void previousEvent() {
// this.data.put("data1", this.jTextField1.getText());
return;
}

Expand Down Expand Up @@ -797,9 +795,7 @@ public void display() {

final String lBreak = System.getProperty("line.separator");
final InsuranceInfo insurance = (InsuranceInfo) this.data.get("clients.insurance");

final ArrayList<DrebisPerson> persons = (ArrayList<DrebisPerson>) this.data.get("clients.drebispersons");

final ArrayList<ArchiveFileDocumentsBean> drebDocs = (ArrayList<ArchiveFileDocumentsBean>) this.data.get("documents.drebisdocumentbeans");

new Thread(() -> {
Expand All @@ -813,7 +809,6 @@ public void display() {
for (ArchiveFileDocumentsBean doc: drebDocs) {

ThreadUtils.appendToTextArea("Konvertiere zu PDF: " + doc.getName() + "...", taLog);
//byte[] content = locator.lookupArchiveFileServiceRemote().getDocumentContent(doc.getId());
byte[] content=CachingDocumentLoader.getInstance().getDocument(doc.getId());
String tmpUrl = FileUtils.createTempFile(doc.getName(), content);
if (doc.getName().toLowerCase().endsWith(".pdf")) {
Expand Down Expand Up @@ -853,16 +848,11 @@ public void display() {
} catch (DrebisException de) {
log.error("Error submitting freetext message", de);
ThreadUtils.appendToTextArea("FEHLER: " + de.getId() + " " + de.getMessage() + " (" + de.getDetailMessage() + "); Objekt: " + de.getErrorObject(), taLog);
return;

} catch (Exception e) {
log.error("Error submitting freetext message", e);
ThreadUtils.appendToTextArea("FEHLER: " + e.getMessage(), taLog);
return;
}
}).start();

return;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@
import com.jdimension.jlawyer.client.utils.ThreadUtils;
import com.jdimension.jlawyer.client.wizard.*;
import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -699,7 +698,7 @@ public class ExportAsPdfConversionStep extends javax.swing.JPanel implements Wiz
private ArrayList<File> pdfFiles = new ArrayList<>();

/**
* Creates new form EpostLetterValidationStep
* Creates new form ExportAsPdfConversionStep
*/
public ExportAsPdfConversionStep() {
initComponents();
Expand All @@ -715,7 +714,6 @@ public void nextEvent() {

@Override
public void previousEvent() {
// this.data.put("data1", this.jTextField1.getText());
return;
}

Expand Down
Loading

0 comments on commit 0f77362

Please sign in to comment.