Skip to content

Commit

Permalink
use data of involved parties as anonymizer terms by default. issue #2682
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Dec 1, 2024
1 parent e35218b commit be5f116
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7342,8 +7342,14 @@ private void mnuAnonymizePdfActionPerformed(java.awt.event.ActionEvent evt) {//G
byte[] content = CachingDocumentLoader.getInstance().getDocument(selectedDocs.get(0).getId());
// Save as temporary file
String tempPath = FileUtils.createTempFile(selectedDocs.get(0).getName(), content);

StringBuilder anonymizeTerms=new StringBuilder();
anonymizeTerms.append(this.dto.getFileNumber()).append(", ");
for (ArchiveFileAddressesBean aab : this.pnlInvolvedParties.getInvolvedParties()) {
anonymizeTerms.append(System.lineSeparator()).append(aab.getAnonymizeTerms());
}

PdfAnonymizerDialog anoDia = new PdfAnonymizerDialog(EditorsRegistry.getInstance().getMainWindow(), true, selectedDocs.get(0).getName(), pdfText, content, tempPath);
PdfAnonymizerDialog anoDia = new PdfAnonymizerDialog(EditorsRegistry.getInstance().getMainWindow(), true, selectedDocs.get(0).getName(), pdfText, content, tempPath, anonymizeTerms.toString());
FrameUtils.centerDialog(anoDia, EditorsRegistry.getInstance().getMainWindow());
anoDia.setVisible(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<Group type="102" alignment="0" attributes="0">
<Component id="pnlTitle" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="splitMain" pref="444" max="32767" attributes="0"/>
<Component id="splitMain" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cmdCancel" alignment="3" min="-2" max="-2" attributes="0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ public class PdfAnonymizerDialog extends javax.swing.JDialog implements Assistan
* @param content
* @param tempFilePath
*/
public PdfAnonymizerDialog(java.awt.Frame parent, boolean modal, String fileName, String pdfText, byte[] content, String tempFilePath) {
public PdfAnonymizerDialog(java.awt.Frame parent, boolean modal, String fileName, String pdfText, byte[] content, String tempFilePath, String anonymizeTerms) {
super(parent, modal);
initComponents();

Expand All @@ -720,6 +720,7 @@ public PdfAnonymizerDialog(java.awt.Frame parent, boolean modal, String fileName
this.content = content;
this.tempFilePath = tempFilePath;
this.pdfText=pdfText;
this.taRemoveWords.setText(anonymizeTerms);

ComponentUtils.restoreDialogSize(this);

Expand Down Expand Up @@ -957,7 +958,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addGroup(layout.createSequentialGroup()
.addComponent(pnlTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(splitMain, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
.addComponent(splitMain)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdCancel)
Expand All @@ -980,6 +981,8 @@ private void cmdSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
for (String w : words) {
wordList.add(w.trim());
}
wordList.sort((s1, s2) -> Integer.compare(s2.length(), s1.length()));

ByteArrayInputStream in = new ByteArrayInputStream(this.content);
FileOutputStream out = new FileOutputStream(this.tempFilePath);

Expand Down Expand Up @@ -1108,7 +1111,7 @@ public static void main(String args[]) {
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
PdfAnonymizerDialog dialog = new PdfAnonymizerDialog(new javax.swing.JFrame(), true, null, null, null, null);
PdfAnonymizerDialog dialog = new PdfAnonymizerDialog(new javax.swing.JFrame(), true, null, null, null, null, "");
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
Expand Down Expand Up @@ -1181,7 +1184,7 @@ public void processOutput(AiCapability c, AiRequestStatus status) {
resultText = result.toString();
}
}
this.taRemoveWords.setText(resultText);
this.taRemoveWords.setText(this.taRemoveWords.getText() + ", " + resultText);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1860,5 +1860,88 @@ public String getLeitwegId() {
public void setLeitwegId(String leitwegId) {
this.leitwegId = leitwegId;
}

public String getAnonymizeTerms() {
StringBuilder sb=new StringBuilder();
if(this.bankAccount!=null && !"".equals(this.bankAccount.trim()))
sb.append(this.bankAccount).append(", ");

if(this.bankCode!=null && !"".equals(this.bankCode.trim()))
sb.append(this.bankCode).append(", ");

if(this.beaSafeId!=null && !"".equals(this.beaSafeId.trim()))
sb.append(this.beaSafeId).append(", ");

if(this.birthDate!=null && !"".equals(this.birthDate.trim()))
sb.append(this.birthDate).append(", ");

if(this.birthName!=null && !"".equals(this.birthName.trim()))
sb.append(this.birthName).append(", ");

if(this.city!=null && !"".equals(this.city.trim()))
sb.append(this.city).append(", ");

if(this.company!=null && !"".equals(this.company.trim()))
sb.append(this.company).append(", ");

if(this.companyRegistrationNumber!=null && !"".equals(this.companyRegistrationNumber.trim()))
sb.append(this.companyRegistrationNumber).append(", ");

if(this.dateOfDeath!=null && !"".equals(this.dateOfDeath.trim()))
sb.append(this.dateOfDeath).append(", ");

if(this.department!=null && !"".equals(this.department.trim()))
sb.append(this.department).append(", ");

if(this.district!=null && !"".equals(this.district.trim()))
sb.append(this.district).append(", ");

if(this.email!=null && !"".equals(this.email.trim()))
sb.append(this.email).append(", ");

if(this.fax!=null && !"".equals(this.fax.trim()))
sb.append(this.fax).append(", ");

if(this.firstName!=null && !"".equals(this.firstName.trim()))
sb.append(this.firstName).append(", ");

if(this.firstName2!=null && !"".equals(this.firstName2.trim()))
sb.append(this.firstName2).append(", ");

if(this.insuranceNumber!=null && !"".equals(this.insuranceNumber.trim()))
sb.append(this.insuranceNumber).append(", ");

if(this.mobile!=null && !"".equals(this.mobile.trim()))
sb.append(this.mobile).append(", ");

if(this.motorInsuranceNumber!=null && !"".equals(this.motorInsuranceNumber.trim()))
sb.append(this.motorInsuranceNumber).append(", ");

if(this.name!=null && !"".equals(this.name.trim()))
sb.append(this.name).append(", ");

if(this.phone!=null && !"".equals(this.phone.trim()))
sb.append(this.phone).append(", ");

if(this.street!=null && !"".equals(this.street.trim()))
sb.append(this.street).append(", ");

if(this.tin!=null && !"".equals(this.tin.trim()))
sb.append(this.tin).append(", ");

if(this.trafficInsuranceNumber!=null && !"".equals(this.trafficInsuranceNumber.trim()))
sb.append(this.trafficInsuranceNumber).append(", ");

if(this.vatId!=null && !"".equals(this.vatId.trim()))
sb.append(this.vatId).append(", ");

if(this.website!=null && !"".equals(this.website.trim()))
sb.append(this.website).append(", ");

if(this.zipCode!=null && !"".equals(this.zipCode.trim()))
sb.append(this.zipCode).append(", ");

return sb.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,17 @@ public ArchiveFileAddressesBean(String id, PartyTypeBean referenceType) {
this.id = id;
this.referenceType = referenceType;
}

public String getAnonymizeTerms() {
StringBuilder sb=new StringBuilder();
if(this.reference!=null && !"".equals(this.reference.trim()))
sb.append(this.reference).append(", ");

if(this.addressKey!=null)
sb.append(this.addressKey.getAnonymizeTerms());

return sb.toString();
}

public String getId() {
return id;
Expand Down

0 comments on commit be5f116

Please sign in to comment.