diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.form index d2221c582..45e8e413f 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.form @@ -481,6 +481,17 @@ + + + + + + + + + + + diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.java index c1fbf7091..561ef5f00 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/JKanzleiGUI.java @@ -1129,6 +1129,7 @@ private void initComponents() { mnuDocumentTags = new javax.swing.JMenuItem(); mnuScanOptions = new javax.swing.JMenuItem(); mnuSearchIndex = new javax.swing.JMenuItem(); + mnuDocumentNameTemplates = new javax.swing.JMenuItem(); mnuDocumentPreview = new javax.swing.JMenuItem(); mnuCustomLauncherOptions = new javax.swing.JMenuItem(); mnuMappingTables = new javax.swing.JMenuItem(); @@ -1636,6 +1637,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); mnuDocumentOptions.add(mnuSearchIndex); + mnuDocumentNameTemplates.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N + mnuDocumentNameTemplates.setText("Dateinamen"); + mnuDocumentNameTemplates.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mnuDocumentNameTemplatesActionPerformed(evt); + } + }); + mnuDocumentOptions.add(mnuDocumentNameTemplates); + mnuDocumentPreview.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/baseline_preview_black_48dp.png"))); // NOI18N mnuDocumentPreview.setText("Dokumentenvorschau"); mnuDocumentPreview.addActionListener(new java.awt.event.ActionListener() { @@ -2802,6 +2812,14 @@ private void mnuAssistantPromptsActionPerformed(java.awt.event.ActionEvent evt) } }//GEN-LAST:event_mnuAssistantPromptsActionPerformed + private void mnuDocumentNameTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuDocumentNameTemplatesActionPerformed + if (checkAdmin()) { + DocumentNameTemplatesSetupDialog dlg = new DocumentNameTemplatesSetupDialog(this, true); + FrameUtils.centerDialog(dlg, this); + dlg.setVisible(true); + } + }//GEN-LAST:event_mnuDocumentNameTemplatesActionPerformed + /** * @param args the command line arguments */ @@ -2867,6 +2885,7 @@ public static void main(String args[]) { private javax.swing.JMenuItem mnuCustomLauncherOptions; private javax.swing.JMenuItem mnuDocumentFolderTemplates; private javax.swing.JMenuItem mnuDocumentMonitor; + private javax.swing.JMenuItem mnuDocumentNameTemplates; private javax.swing.JMenu mnuDocumentOptions; private javax.swing.JMenuItem mnuDocumentPreview; private javax.swing.JMenuItem mnuDocumentTags; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.form index 3948147b1..6efd5e11b 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.form @@ -448,13 +448,6 @@ - - - - - - - diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.java index cdc58f651..626771caf 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaInboxPanel.java @@ -2472,11 +2472,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea dlg.dispose(); } - java.util.Date receivedPrefix = m.getReceptionTime(); - if (receivedPrefix == null) { - receivedPrefix = new java.util.Date(); - } - // user hit cancel if (targetCase == null) { return false; @@ -2512,8 +2507,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea } bulkEntry.setDocumentFilename(attachmentName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName); - bulkSaveDlg.addEntry(bulkEntry); } @@ -2543,8 +2536,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea } bulkEntry.setDocumentFilename(attachmentName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName); - bulkSaveDlg.addEntry(bulkEntry); } } @@ -2568,8 +2559,7 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea BulkSaveEntry bulkEntry = new BulkSaveEntry(); bulkEntry.setDocumentDate(m.getReceptionTime()); bulkEntry.setDocumentBytes(data); - bulkEntry.setDocumentFilename(newName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + m.getId() + "_" + newName); + bulkEntry.setDocumentFilename(m.getId() + "_" + newName); bulkSaveDlg.addEntry(bulkEntry); } @@ -2597,7 +2587,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea bulkEntry.setDocumentDate(m.getReceptionTime()); bulkEntry.setDocumentBytes(attachmentData); bulkEntry.setDocumentFilename(attachmentName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName); bulkSaveDlg.addEntry(bulkEntry); } @@ -2627,8 +2616,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea } bulkEntry.setDocumentFilename(attachmentName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName); - bulkSaveDlg.addEntry(bulkEntry); } @@ -2862,7 +2849,7 @@ private void saveEebResponse(Message m, MessageHeader originalMessage, String re ArchiveFileServiceRemote remote = locator.lookupArchiveFileServiceRemote(); MessageExport mex = BeaAccess.exportMessage(m); - String newName = FileUtils.getNewFileName(m.getId() + "_eEb-" + rejectionOrConfirmation + ".bea", false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "eEb-Antwort speichern"); + String newName = FileUtils.getNewFileName(targetCase, m.getId() + "_eEb-" + rejectionOrConfirmation + ".bea", false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "eEb-Antwort speichern"); if (newName == null || "".equals(newName)) { newName=m.getId() + "_eEb-" + rejectionOrConfirmation + ".bea"; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaMessageContentUI.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaMessageContentUI.java index 7048fa6a0..b13ac4399 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaMessageContentUI.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/BeaMessageContentUI.java @@ -1501,7 +1501,7 @@ private void mnuSearchSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN byte[] data = ((Attachment) selected).getContent(); - String newName = FileUtils.getNewFileName(selected.toString(), true); + String newName = FileUtils.getNewFileName(sel, selected.toString(), true, true); if (newName == null) { return; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SaveBeaMessageAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SaveBeaMessageAction.java index 50f0c679d..09f56d6d2 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SaveBeaMessageAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SaveBeaMessageAction.java @@ -820,7 +820,7 @@ public boolean execute() throws Exception { if (receivedPrefix == null) { receivedPrefix = new java.util.Date(); } - String newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(mex.getFileName(), true, receivedPrefix, this.indicator); + String newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(this.archiveFile, mex.getFileName(), true, receivedPrefix, true, this.indicator); if (newName == null) { return false; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageAction.java index f8ed03c2e..2645c3d3f 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageAction.java @@ -862,7 +862,7 @@ public boolean execute() throws Exception { if (receivedPrefix == null) { receivedPrefix = new java.util.Date(); } - String newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(mex.getFileName(), true, receivedPrefix, this.indicator, "Datei benennen"); + String newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(this.archiveFile, mex.getFileName(), true, receivedPrefix, true, this.indicator, "Datei benennen"); if (newName == null) { return false; } @@ -880,7 +880,7 @@ public boolean execute() throws Exception { boolean documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); while (documentExists) { - newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(newName, true, receivedPrefix, this.indicator, "Datei benennen"); + newName = com.jdimension.jlawyer.client.utils.FileUtils.getNewFileName(this.archiveFile, newName, true, receivedPrefix, true, this.indicator, "Datei benennen"); if (newName == null || "".equals(newName)) { break; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageDialog.java index 93b78014f..a51d6b86f 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageDialog.java @@ -663,6 +663,7 @@ */ package com.jdimension.jlawyer.client.bea; +import com.jdimension.jlawyer.client.utils.TemplatesUtil; import com.jdimension.jlawyer.client.calendar.CalendarUtils; import com.jdimension.jlawyer.client.components.MultiCalDialog; import com.jdimension.jlawyer.client.configuration.UserListCellRenderer; @@ -2041,7 +2042,7 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- EmailTemplate tpl = locator.lookupIntegrationServiceRemote().getEmailTemplate(tplName); List selectedParties = this.pnlParties.getSelectedParties(new ArrayList(allPartyTypes)); - ArrayList placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getSubject(), allPartyTypesPlaceholders,new ArrayList<>()); + ArrayList placeHolderNames = TemplatesUtil.getPlaceHoldersInTemplate(tpl.getSubject(), allPartyTypesPlaceholders,new ArrayList<>()); HashMap ht = new HashMap<>(); for (String ph : placeHolderNames) { ht.put(ph, ""); @@ -2069,9 +2070,9 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- partiesTriplets.add(triplet); } HashMap htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, this.contextArchiveFile, partiesTriplets, this.contextDictateSign, null, new HashMap<>(), caseLawyer, caseAssistant, author, null, null, null, null); - this.txtSubject.setText(EmailTemplateAccess.replacePlaceHolders(tpl.getSubject(), htValues)); + this.txtSubject.setText(TemplatesUtil.replacePlaceHolders(tpl.getSubject(), htValues)); - placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders,new ArrayList<>()); + placeHolderNames = TemplatesUtil.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders,new ArrayList<>()); ht = new HashMap<>(); for (String ph : placeHolderNames) { ht.put(ph, ""); @@ -2079,7 +2080,7 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, this.contextArchiveFile, partiesTriplets, this.contextDictateSign, null, new HashMap<>(), caseLawyer, caseAssistant, author, null, null, null, null); - String t = EmailTemplateAccess.replacePlaceHolders(tpl.getBody(), htValues) + System.getProperty("line.separator"); + String t = TemplatesUtil.replacePlaceHolders(tpl.getBody(), htValues) + System.getProperty("line.separator"); int cursorIndex = t.indexOf(PLACEHOLDER_CURSOR); if (cursorIndex > -1) { t = t.replace(PLACEHOLDER_CURSOR, ""); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplateAccess.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplateTableCellRenderer.java old mode 100755 new mode 100644 similarity index 96% rename from j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplateAccess.java rename to j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplateTableCellRenderer.java index 9349c6654..5c209d19f --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplateAccess.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplateTableCellRenderer.java @@ -661,44 +661,46 @@ * For more information on this, and how to apply and follow the GNU AGPL, see * . */ -package com.jdimension.jlawyer.client.mail; +package com.jdimension.jlawyer.client.configuration; -import com.jdimension.jlawyer.documents.PlaceHolders; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; +import com.jdimension.jlawyer.persistence.DocumentNameTemplate; +import java.awt.Color; +import java.awt.Component; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import themes.colors.DefaultColorTheme; /** * * @author jens */ -public class EmailTemplateAccess { - - public static ArrayList getPlaceHoldersInTemplate(String templateText, List allPartyTypesPlaceHolders, Collection formPlaceHolders) { - ArrayList result=new ArrayList<>(); - if(templateText==null) - templateText=""; - for (String r : PlaceHolders.getAllPlaceHolders(allPartyTypesPlaceHolders, formPlaceHolders)) { - if(templateText.contains(r)) - result.add(r); - +public class DocumentNameTemplateTableCellRenderer extends DefaultTableCellRenderer { + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + + DocumentNameTemplate tpl = (DocumentNameTemplate) table.getValueAt(row, 0); + + Object returnRenderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (column == 0) { + ((JLabel) ((Component) returnRenderer)).setText(tpl.getDisplayName()); } - return result; - } - - public static String replacePlaceHolders(String content, HashMap values) { - for (String key: values.keySet()) { - String keyRegX = "\\{\\{" + key.substring(2, key.length() - 2) + "\\}\\}"; - String value = (String) values.get(key); - if (value == null) { - value = ""; - } - content = content.replaceAll(keyRegX, value); + if (isSelected) { + ((JLabel) ((Component) returnRenderer)).setForeground(Color.WHITE); + if (column != 1) { + ((JLabel) ((Component) returnRenderer)).setBackground(DefaultColorTheme.COLOR_LOGO_BLUE); + } + } else { + ((JLabel) ((Component) returnRenderer)).setForeground(Color.BLACK); + if (column != 1) { + ((JLabel) ((Component) returnRenderer)).setBackground(Color.WHITE); + } } - return content; + return (Component) returnRenderer; } - } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplatesSetupDialog.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplatesSetupDialog.form new file mode 100644 index 000000000..c2ce557df --- /dev/null +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplatesSetupDialog.form @@ -0,0 +1,397 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor"> + <JTableSelectionModel selectionMode="0"/> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="tblTemplatesMouseClicked"/> + <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="tblTemplatesKeyReleased"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="cmdAdd"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/icons/edit_add.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdAddActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="cmdRemove"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/icons/trashcan_full.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdRemoveActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="cmdClose"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="cmdClose" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/icons/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" value="Schliessen"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdCloseActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="jLabel1" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="text" type="java.lang.String" value="Anzeigename:"/> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtDisplayName"> + </Component> + <Component class="javax.swing.JButton" name="cmdSave"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="cmdSave" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/icons/agt_action_success.png"/> + </Property> + <Property name="text" type="java.lang.String" value="Übernehmen"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdSaveActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font bold="true" component="jLabel5" property="font" relativeSize="true" size="-2"/> + </FontInfo> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="99" green="99" red="99" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="Konfiguration"/> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtPattern"> + <Events> + <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtPatternKeyReleased"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="jLabel2" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="text" type="java.lang.String" value="Schema:"/> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="chkDefault"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="chkDefault" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="text" type="java.lang.String" value="als Standard verwenden"/> + <Property name="toolTipText" type="java.lang.String" value="Rechnungsnummer bei Rechnungserstellung manuell editierbar machen"/> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane2"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstPreview"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="lstPreview" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="5"> + <StringItem index="0" value="Item 1"/> + <StringItem index="1" value="Item 2"/> + <StringItem index="2" value="Item 3"/> + <StringItem index="3" value="Item 4"/> + <StringItem index="4" value="Item 5"/> + </StringArray> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="lblError"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font bold="true" component="lblError" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="33" red="cc" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value=" "/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="jLabel10" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="text" type="java.lang.String" value="y m d (y...Jahr m...Monat d...Tag)"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="jLabel11" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="text" type="java.lang.String" value="weitere Zeichen als fixe Bestandteile"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel14"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> + <FontInfo relative="true"> + <Font component="jLabel14" property="font" relativeSize="true" size="0"/> + </FontInfo> + </Property> + <Property name="text" type="java.lang.String" value="DATEINAME als Platzhalter für ursprünglichen Namen"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="text" type="java.lang.String" value="Platzhalter, bspw. {{MANDANT_NAME}}"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplatesSetupDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplatesSetupDialog.java new file mode 100644 index 000000000..2d8f0ec41 --- /dev/null +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/DocumentNameTemplatesSetupDialog.java @@ -0,0 +1,1221 @@ +/* + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<https://www.gnu.org/licenses/>. + */ +package com.jdimension.jlawyer.client.configuration; + +import com.jdimension.jlawyer.client.settings.ClientSettings; +import com.jdimension.jlawyer.client.utils.CaseInsensitiveStringComparator; +import com.jdimension.jlawyer.client.utils.ComponentUtils; +import com.jdimension.jlawyer.persistence.DocumentNameTemplate; +import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import java.util.List; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import org.apache.log4j.Logger; +import themes.colors.DefaultColorTheme; + +/** + * + * @author jens + */ +public class DocumentNameTemplatesSetupDialog extends javax.swing.JDialog { + + private static final Logger log = Logger.getLogger(DocumentNameTemplatesSetupDialog.class.getName()); + + /** + * Creates new form DocumentNameTemplatesSetupDialog + * + * @param parent + * @param modal + */ + public DocumentNameTemplatesSetupDialog(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + + this.lstPreview.setModel(new DefaultListModel()); + + this.resetDetails(); + + this.tblTemplates.setSelectionForeground(DefaultColorTheme.COLOR_LOGO_BLUE); + + ClientSettings settings = ClientSettings.getInstance(); + try { + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + List<DocumentNameTemplate> templates = locator.lookupSystemManagementRemote().getDocumentNameTemplates(); + + this.tblTemplates.setDefaultRenderer(Object.class, new DocumentNameTemplateTableCellRenderer()); + + for (DocumentNameTemplate t : templates) { + ((DefaultTableModel) this.tblTemplates.getModel()).addRow(new Object[]{t, t.getPattern()}); + + } + TableRowSorter<TableModel> sorter = new TableRowSorter<>(this.tblTemplates.getModel()); + sorter.setComparator(0, new CaseInsensitiveStringComparator()); + this.tblTemplates.setRowSorter(sorter); + this.tblTemplates.getRowSorter().toggleSortOrder(0); + + } catch (Exception ex) { + log.error("Error connecting to server", ex); + JOptionPane.showMessageDialog(this, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); + return; + } + + ComponentUtils.autoSizeColumns(tblTemplates); + + } + + private void resetDetails() { + this.txtDisplayName.setText(""); + this.txtPattern.setText(""); + this.chkDefault.setSelected(false); + + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + tblTemplates = new javax.swing.JTable(); + cmdAdd = new javax.swing.JButton(); + cmdRemove = new javax.swing.JButton(); + cmdClose = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + txtDisplayName = new javax.swing.JTextField(); + cmdSave = new javax.swing.JButton(); + jLabel5 = new javax.swing.JLabel(); + txtPattern = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + chkDefault = new javax.swing.JCheckBox(); + jScrollPane2 = new javax.swing.JScrollPane(); + lstPreview = new javax.swing.JList<>(); + lblError = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel14 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Dateinamen konfigurieren"); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Definitionen für Dateinamen")); + + tblTemplates.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "Name", "Schema" + } + ) { + boolean[] canEdit = new boolean [] { + false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + tblTemplates.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + tblTemplates.getTableHeader().setReorderingAllowed(false); + tblTemplates.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + tblTemplatesMouseClicked(evt); + } + }); + tblTemplates.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + tblTemplatesKeyReleased(evt); + } + }); + jScrollPane1.setViewportView(tblTemplates); + + cmdAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/edit_add.png"))); // NOI18N + cmdAdd.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmdAddActionPerformed(evt); + } + }); + + cmdRemove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/trashcan_full.png"))); // NOI18N + cmdRemove.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmdRemoveActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(cmdAdd) + .addComponent(cmdRemove)) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(cmdAdd) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cmdRemove) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + ); + + cmdClose.setFont(cmdClose.getFont()); + cmdClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/cancel.png"))); // NOI18N + cmdClose.setText("Schliessen"); + cmdClose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmdCloseActionPerformed(evt); + } + }); + + jLabel1.setFont(jLabel1.getFont()); + jLabel1.setText("Anzeigename:"); + + cmdSave.setFont(cmdSave.getFont()); + cmdSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/agt_action_success.png"))); // NOI18N + cmdSave.setText("Ãœbernehmen"); + cmdSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmdSaveActionPerformed(evt); + } + }); + + jLabel5.setFont(jLabel5.getFont().deriveFont(jLabel5.getFont().getStyle() | java.awt.Font.BOLD, jLabel5.getFont().getSize()-2)); + jLabel5.setForeground(new java.awt.Color(153, 153, 153)); + jLabel5.setText("Konfiguration"); + + txtPattern.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + txtPatternKeyReleased(evt); + } + }); + + jLabel2.setFont(jLabel2.getFont()); + jLabel2.setText("Schema:"); + + chkDefault.setFont(chkDefault.getFont()); + chkDefault.setText("als Standard verwenden"); + chkDefault.setToolTipText("Rechnungsnummer bei Rechnungserstellung manuell editierbar machen"); + + lstPreview.setFont(lstPreview.getFont()); + lstPreview.setModel(new javax.swing.AbstractListModel<String>() { + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; + public int getSize() { return strings.length; } + public String getElementAt(int i) { return strings[i]; } + }); + jScrollPane2.setViewportView(lstPreview); + + lblError.setFont(lblError.getFont().deriveFont(lblError.getFont().getStyle() | java.awt.Font.BOLD)); + lblError.setForeground(new java.awt.Color(204, 51, 0)); + lblError.setText(" "); + + jLabel10.setFont(jLabel10.getFont()); + jLabel10.setText("y m d (y...Jahr m...Monat d...Tag)"); + + jLabel11.setFont(jLabel11.getFont()); + jLabel11.setText("weitere Zeichen als fixe Bestandteile"); + + jLabel14.setFont(jLabel14.getFont()); + jLabel14.setText("DATEINAME als Platzhalter für ursprünglichen Namen"); + + jLabel3.setText("Platzhalter, bspw. {{MANDANT_NAME}}"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(cmdSave) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cmdClose)) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(jLabel2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtPattern) + .addComponent(txtDisplayName) + .addGroup(layout.createSequentialGroup() + .addComponent(lblError, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(258, 258, 258)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel10) + .addComponent(chkDefault) + .addComponent(jLabel14) + .addComponent(jLabel11) + .addComponent(jLabel3)) + .addGap(0, 55, Short.MAX_VALUE)) + .addComponent(jScrollPane2)))))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtDisplayName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtPattern, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel10) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel14) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel11) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(chkDefault) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 369, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(lblError) + .addGap(0, 8, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(cmdClose) + .addComponent(cmdSave)))) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void cmdCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCloseActionPerformed + this.setVisible(false); + this.dispose(); + }//GEN-LAST:event_cmdCloseActionPerformed + + private void tblTemplatesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblTemplatesMouseClicked + if (evt.getClickCount() == 1 && !evt.isConsumed()) { + + int row = this.tblTemplates.getSelectedRow(); + + if (row < 0) { + this.resetDetails(); + } else { + + DocumentNameTemplate tpl = (DocumentNameTemplate) this.tblTemplates.getValueAt(row, 0); + + ClientSettings settings = ClientSettings.getInstance(); + // reload, because the default flag might have been removed by setting the default on another + try { + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + tpl = locator.lookupSystemManagementRemote().getDocumentNameTemplate(tpl.getId()); + } catch (Exception ex) { + log.error("Error getting document name template", ex); + JOptionPane.showMessageDialog(this, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); + } + this.updateUI(tpl); + this.updatePreview(); + } + + } + }//GEN-LAST:event_tblTemplatesMouseClicked + + private void cmdAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAddActionPerformed + Object newNameObject = JOptionPane.showInputDialog(this, "Anzeigename: ", "Neue Namensvorlage", JOptionPane.QUESTION_MESSAGE, null, null, "neue Namensvorlage"); + if (newNameObject == null) { + return; + } + + ClientSettings settings = ClientSettings.getInstance(); + try { + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + DocumentNameTemplate tpl = new DocumentNameTemplate(); + tpl.setDisplayName(newNameObject.toString()); + tpl.setDefaultTemplate(false); + tpl.setPattern("yyyy-mm-dd_DATEINAME"); + DocumentNameTemplate savedTpl = locator.lookupSystemManagementRemote().addDocumentNameTemplate(tpl); + + ((DefaultTableModel) this.tblTemplates.getModel()).addRow(new Object[]{savedTpl, savedTpl.getPattern()}); + this.tblTemplates.getSelectionModel().setSelectionInterval(this.tblTemplates.getRowCount() - 1, this.tblTemplates.getRowCount() - 1); + + } catch (Exception ex) { + log.error("Error creating new document name template", ex); + JOptionPane.showMessageDialog(this, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); + } + + }//GEN-LAST:event_cmdAddActionPerformed + + private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdSaveActionPerformed + + int row = this.tblTemplates.getSelectedRow(); + + if (row >= 0) { + + DocumentNameTemplate tpl = (DocumentNameTemplate) this.tblTemplates.getValueAt(row, 0); + tpl.setDisplayName(this.txtDisplayName.getText()); + tpl.setPattern(this.txtPattern.getText()); + tpl.setDefaultTemplate(this.chkDefault.isSelected()); + + ClientSettings settings = ClientSettings.getInstance(); + try { + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + DocumentNameTemplate savedTpl = locator.lookupSystemManagementRemote().updateDocumentNameTemplate(tpl); + row = this.tblTemplates.convertRowIndexToModel(row); + ((DefaultTableModel) this.tblTemplates.getModel()).setValueAt(savedTpl, row, 0); + ((DefaultTableModel) this.tblTemplates.getModel()).setValueAt(savedTpl.getPattern(), row, 1); + + } catch (Exception ex) { + log.error("Error updating document name template", ex); + JOptionPane.showMessageDialog(this, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); + } + } + + + }//GEN-LAST:event_cmdSaveActionPerformed + + private void cmdRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdRemoveActionPerformed + int row = this.tblTemplates.getSelectedRow(); + + if (row >= 0) { + + DocumentNameTemplate tpl = (DocumentNameTemplate) this.tblTemplates.getValueAt(row, 0); + ClientSettings settings = ClientSettings.getInstance(); + try { + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + locator.lookupSystemManagementRemote().removeDocumentNameTemplate(tpl); + row = this.tblTemplates.convertRowIndexToModel(row); + ((DefaultTableModel) this.tblTemplates.getModel()).removeRow(row); + + this.resetDetails(); + } catch (Exception ex) { + log.error("Error removing document name template", ex); + JOptionPane.showMessageDialog(this, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); + } + } + }//GEN-LAST:event_cmdRemoveActionPerformed + + private void tblTemplatesKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblTemplatesKeyReleased + int row = this.tblTemplates.getSelectedRow(); + + if (row < 0) { + this.resetDetails(); + } else { + + DocumentNameTemplate tpl = (DocumentNameTemplate) this.tblTemplates.getValueAt(row, 0); + ClientSettings settings = ClientSettings.getInstance(); + // reload, because the default flag might have been removed by setting the default on another + try { + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + tpl = locator.lookupSystemManagementRemote().getDocumentNameTemplate(tpl.getId()); + } catch (Exception ex) { + log.error("Error getting document name template", ex); + JOptionPane.showMessageDialog(this, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); + } + this.updateUI(tpl); + this.updatePreview(); + } + }//GEN-LAST:event_tblTemplatesKeyReleased + + private void txtPatternKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPatternKeyReleased + if (this.tblTemplates.getSelectedRow() > -1) + this.updatePreview(); + }//GEN-LAST:event_txtPatternKeyReleased + + private void updateUI(DocumentNameTemplate tpl) { + + this.txtDisplayName.setText(tpl.getDisplayName()); + this.txtPattern.setText(tpl.getPattern()); + this.chkDefault.setSelected(tpl.isDefaultTemplate()); + + } + + private void updatePreview() { + + this.lblError.setText(" "); + DefaultListModel dm = new DefaultListModel(); + this.lstPreview.setModel(dm); + + ClientSettings settings = ClientSettings.getInstance(); + try { + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + DocumentNameTemplate testTpl = new DocumentNameTemplate(); + testTpl.setPattern(this.txtPattern.getText()); + List<String> preview = locator.lookupSystemManagementRemote().previewDocumentNamesForTemplate(testTpl, "Beispieldatei.pdf"); + + for (String p : preview) { + dm.addElement(p); + } + } catch (Exception ex) { + this.lblError.setText(ex.getMessage()); + this.cmdSave.setEnabled(false); + return; + } + + this.cmdSave.setEnabled(true); + + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(DocumentNameTemplatesSetupDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + //</editor-fold> + + //</editor-fold> + //</editor-fold> + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(() -> { + DocumentNameTemplatesSetupDialog dialog = new DocumentNameTemplatesSetupDialog(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox chkDefault; + private javax.swing.JButton cmdAdd; + private javax.swing.JButton cmdClose; + private javax.swing.JButton cmdRemove; + private javax.swing.JButton cmdSave; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel5; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JLabel lblError; + private javax.swing.JList<String> lstPreview; + private javax.swing.JTable tblTemplates; + private javax.swing.JTextField txtDisplayName; + private javax.swing.JTextField txtPattern; + // End of variables declaration//GEN-END:variables +} diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/DrebisInboxPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/DrebisInboxPanel.java index ccecd5758..c3d9ae901 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/DrebisInboxPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/DrebisInboxPanel.java @@ -776,12 +776,6 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { } - public String getNewFileName(String currentFileName) { - - return FileUtils.getNewFileName(currentFileName, false); - - } - public void clear() { this.txtClaimNumber.setText(""); this.txtFileName.setText(""); @@ -1181,27 +1175,35 @@ private void cmdSaveConfirmActionPerformed(java.awt.event.ActionEvent evt) {//GE try { String archiveFileNumber = this.txtFileNumber.getText(); - - // just in case the Drebis request was started in the portal without the leading zeroes - // removed due to custom file numbers - // archiveFileNumber=ArchiveFileUtils.addLeadingZeroes(archiveFileNumber); - CaseFolder rootFolder = null; - CaseFolder targetFolder = null; + ArchiveFileBean targetCase=null; + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = null; + try { + locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + targetCase=locator.lookupArchiveFileServiceRemote().getArchiveFileByFileNumber(archiveFileNumber); + } catch (Exception ex) { + log.error("Error getting case by reference number", ex); + } + + if(targetCase == null) { + CaseFolder rootFolder = null; + CaseFolder targetFolder = null; - // get folders - SearchAndAssignDialog saDlg = new SearchAndAssignDialog(EditorsRegistry.getInstance().getMainWindow(), true, "" + archiveFileNumber, null); - saDlg.setVisible(true); - ArchiveFileBean targetCase = saDlg.getCaseSelection(); - targetFolder = saDlg.getFolderSelection(); - rootFolder = saDlg.getRootFolder(); - - saDlg.dispose(); + // get folders + SearchAndAssignDialog saDlg = new SearchAndAssignDialog(EditorsRegistry.getInstance().getMainWindow(), true, "" + archiveFileNumber, null); + saDlg.setVisible(true); + targetCase = saDlg.getCaseSelection(); + targetFolder = saDlg.getFolderSelection(); + rootFolder = saDlg.getRootFolder(); + bulkSaveDlg.setCaseFolder(rootFolder, targetFolder); + saDlg.dispose(); + } if (targetCase == null) return; - bulkSaveDlg.setCaseFolder(rootFolder, targetFolder); + bulkSaveDlg.setSelectedCase(targetCase); for (int i = 0; i < this.tblAttachments.getRowCount(); i++) { @@ -1215,9 +1217,7 @@ private void cmdSaveConfirmActionPerformed(java.awt.event.ActionEvent evt) {//GE String newName = da.getName() + "." + da.getSuffix(); newName = FileUtils.sanitizeFileName(newName); - bulkEntry.setDocumentFilename(da.getName() + "." + da.getSuffix()); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(new Date()) + newName); - + bulkEntry.setDocumentFilename(newName); bulkSaveDlg.addEntry(bulkEntry); } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextReceiptStep.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextReceiptStep.java index 802d10a8a..3161c1ee2 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextReceiptStep.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextReceiptStep.java @@ -740,7 +740,7 @@ public void finishedEvent() { log.error("Unable to unarchive case " + sel.getFileNumber(), ex); } - String newName = this.getNewFileName(attachment.getName() + "." + attachment.getSuffix()); + String newName = this.getNewFileName(sel, attachment.getName() + "." + attachment.getSuffix()); if (newName == null) { newName = attachment.getName() + "." + attachment.getSuffix(); } @@ -864,8 +864,8 @@ public String getStepName() { return this.getName(); } - public String getNewFileName(String currentFileName) { - return FileUtils.getNewFileName(currentFileName, false, new Date(), this, "Datei benennen"); + public String getNewFileName(ArchiveFileBean selectedCase, String currentFileName) { + return FileUtils.getNewFileName(selectedCase, currentFileName, false, new Date(), true, this, "Datei benennen"); } @Override diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextStep.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextStep.java index 6e60199b7..6b1375c60 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextStep.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextStep.java @@ -665,7 +665,7 @@ import com.jdimension.jlawyer.client.editors.files.PartiesPanelEntry; import com.jdimension.jlawyer.client.editors.files.PartiesSelectionListener; -import com.jdimension.jlawyer.client.mail.EmailTemplateAccess; +import com.jdimension.jlawyer.client.utils.TemplatesUtil; import com.jdimension.jlawyer.client.settings.ClientSettings; import com.jdimension.jlawyer.client.settings.UserSettings; import com.jdimension.jlawyer.client.utils.ComponentUtils; @@ -940,7 +940,7 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- EmailTemplate tpl = locator.lookupIntegrationServiceRemote().getEmailTemplate(tplName); - ArrayList<String> placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getSubject(), allPartyTypesPlaceholders, formPlaceHolders); + ArrayList<String> placeHolderNames = TemplatesUtil.getPlaceHoldersInTemplate(tpl.getSubject(), allPartyTypesPlaceholders, formPlaceHolders); HashMap<String, Object> ht = new HashMap<>(); for (String ph : placeHolderNames) { ht.put(ph, ""); @@ -968,14 +968,14 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- partiesTriplets.add(triplet); } - placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders, formPlaceHolders); + placeHolderNames = TemplatesUtil.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders, formPlaceHolders); ht = new HashMap<>(); for (String ph : placeHolderNames) { ht.put(ph, ""); } HashMap<String, Object> htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, contextArchiveFile, partiesTriplets, null, null, formPlaceHolderValues, caseLawyer, caseAssistant, author, null, null, null, null); - String t = EmailTemplateAccess.replacePlaceHolders(tpl.getBody(), htValues); + String t = TemplatesUtil.replacePlaceHolders(tpl.getBody(), htValues); int cursorIndex = t.indexOf(EmailTemplate.PLACEHOLDER_CURSOR); if (cursorIndex > -1) { t = t.replace(EmailTemplate.PLACEHOLDER_CURSOR, ""); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/ScannerPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/ScannerPanel.java index 6b5ce1e59..1839f515f 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/ScannerPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/ScannerPanel.java @@ -1488,9 +1488,7 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea } newName = FileUtils.sanitizeFileName(newName); - bulkEntry.setDocumentFilename(fileName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(new Date()) + newName); - + bulkEntry.setDocumentFilename(newName); bulkSaveDlg.addEntry(bulkEntry); } catch (Exception ex) { @@ -1531,7 +1529,7 @@ public boolean renameCallback() { for (int r : selRow) { String fileName = this.tblDirContent.getValueAt(r, 2).toString(); - String toFileName = FileUtils.getNewFileName(fileName, false); + String toFileName = FileUtils.getNewFileName(null, fileName, false, false); if (toFileName == null) { // user cancelled continue; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFileDetailLoadAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFileDetailLoadAction.java index ea44752f3..0b757ae80 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFileDetailLoadAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFileDetailLoadAction.java @@ -935,7 +935,7 @@ public boolean execute() throws Exception { HashMap<String, CaseFolderSettings> folderSettings = fileService.getCaseFolderSettings(folderIds); caseFolders.setReadOnly(readOnly || this.caseDto.isArchived()); caseFolders.setRootFolder(this.caseDto.getRootFolder(), folderSettings); - caseFolders.setCaseId(archiveFileKey); + caseFolders.setCase(this.caseDto); caseFolders.setDocuments(new ArrayList<>(documents), docToInvoice); caseFolders.sort(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java index 5ddc9b1a3..7646bf3de 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java @@ -4736,13 +4736,13 @@ public void uploadDocument(Invoice invoice) { ThreadUtils.setWaitCursor(this); ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true); pi.setShowCancelButton(true); - UploadDocumentsAction a = new UploadDocumentsAction(pi, this, dto.getId(), this.caseFolderPanel1, files, null, invoice); + UploadDocumentsAction a = new UploadDocumentsAction(pi, this, dto, this.caseFolderPanel1, files, null, invoice); a.start(); } else { ThreadUtils.setWaitCursor(this); ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true); pi.setShowCancelButton(true); - UploadDocumentsAction a = new UploadDocumentsAction(pi, this, dto.getId(), this.caseFolderPanel1, files, null, invoice); + UploadDocumentsAction a = new UploadDocumentsAction(pi, this, dto, this.caseFolderPanel1, files, null, invoice); a.execute(); } @@ -4804,7 +4804,7 @@ private void mnuDuplicateDocumentActionPerformed(java.awt.event.ActionEvent evt) byte[] content = remote.getDocumentContent(doc.getId()); ArchiveFileDocumentsBean orgDoc = remote.getDocument(doc.getId()); - String newName = FileUtils.getNewFileName(doc.getName(), false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Dokument duplizieren"); + String newName = FileUtils.getNewFileName(dto, doc.getName(), false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Dokument duplizieren"); if (newName == null || "".equals(newName)) { return; @@ -4942,7 +4942,7 @@ private void mnuRenameDocumentActionPerformed(java.awt.event.ActionEvent evt) {/ return; } ArchiveFileDocumentsBean doc = selectedDocs.get(0); - String newName = FileUtils.getNewFileName(doc.getName(), false, null, this, "Dokument umbenennen"); + String newName = FileUtils.getNewFileName(dto, doc.getName(), false, null, false, this, "Dokument umbenennen"); this.lastPopupClosed = System.currentTimeMillis(); if (newName == null) { return; @@ -5507,7 +5507,7 @@ private void mnuCopyDocumentToOtherCaseActionPerformed(java.awt.event.ActionEven try { byte[] content = remote.getDocumentContent(doc.getId()); - String newName = FileUtils.getNewFileName(doc.getName(), false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Dokument kopieren"); + String newName = FileUtils.getNewFileName(sel, doc.getName(), false, new Date(), false, EditorsRegistry.getInstance().getMainWindow(), "Dokument kopieren"); if (newName == null || "".equalsIgnoreCase(newName)) { this.lastPopupClosed = System.currentTimeMillis(); return; @@ -5570,7 +5570,7 @@ public void convertDocumentToPdf(ArchiveFileDocumentsBean doc) throws Exception int response = JOptionPane.showOptionDialog(EditorsRegistry.getInstance().getMainWindow(), "Eine Datei mit dem Namen '" + newName + "' existiert bereits, soll diese ersetzt werden?", "Datei ersetzen?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[]{"Ja", "Nein"}, "Nein"); replaceDocument = response == JOptionPane.YES_OPTION; if (!replaceDocument) { - newName = FileUtils.getNewFileName(newName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für PDF-Dokument"); + newName = FileUtils.getNewFileName(dto, newName, false, new Date(), false, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für PDF-Dokument"); if (newName == null || "".equals(newName)) { this.lastPopupClosed = System.currentTimeMillis(); return; @@ -5977,7 +5977,7 @@ private void mnuUseDocumentAsTemplateActionPerformed(java.awt.event.ActionEvent for (ArchiveFileDocumentsBean doc : selectedDocs) { if (doc.getName().toLowerCase().endsWith(".ods") || doc.getName().toLowerCase().endsWith(".odt") || doc.getName().toLowerCase().endsWith(".docx")) { byte[] content = remote.getDocumentContent(doc.getId()); - String newName = FileUtils.getNewFileName(doc.getName(), false, new Date(), this, "Dokument als Vorlage speichern"); + String newName = FileUtils.getNewFileName(dto, doc.getName(), false, new Date(), false, this, "Dokument als Vorlage speichern"); if (newName == null || "".equals(newName)) { this.lastPopupClosed = System.currentTimeMillis(); @@ -6813,7 +6813,7 @@ private void mnuMoveDocumentToOtherCaseActionPerformed(java.awt.event.ActionEven try { byte[] content = remote.getDocumentContent(doc.getId()); - String newName = FileUtils.getNewFileName(doc.getName(), false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Dokument verschieben"); + String newName = FileUtils.getNewFileName(sel, doc.getName(), false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Dokument verschieben"); if (newName == null || "".equalsIgnoreCase(newName)) { this.lastPopupClosed = System.currentTimeMillis(); return; @@ -7181,7 +7181,7 @@ private void fillDTO(ArchiveFileBean aFile, boolean withReviews) throws Exceptio protected DropTarget getMyDropTarget() { if (dropTarget == null) { //dropTarget = new DropTarget(this.tblDocuments, DnDConstants.ACTION_COPY_OR_MOVE, null); - dropTarget = new DropTarget(this.caseFolderPanel1, DnDConstants.ACTION_COPY_OR_MOVE, null); + dropTarget = new DropTarget(this.caseFolderPanel1, DnDConstants.ACTION_COPY, null); } return dropTarget; } @@ -7472,7 +7472,7 @@ public void drop(DropTargetDropEvent dtde) { ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true); pi.setShowCancelButton(true); - UploadDocumentsAction a = new UploadDocumentsAction(pi, p, dto.getId(), caseFolderPanel1, files, null, null); + UploadDocumentsAction a = new UploadDocumentsAction(pi, p, dto, caseFolderPanel1, files, caseFolderPanel1.getFoldersListPanel().getRootFolder(), null); a.start(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveDialog.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveDialog.form index 2796ccafe..b540bc40b 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveDialog.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveDialog.form @@ -16,6 +16,12 @@ </Container> <Container class="javax.swing.JPopupMenu" name="popCommonFolder"> + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + </Container> + <Container class="javax.swing.JPopupMenu" name="popNameTemplates"> + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> <Property name="useNullLayout" type="boolean" value="true"/> </Layout> @@ -47,13 +53,10 @@ <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> - <Group type="102" alignment="0" attributes="0"> + <Group type="102" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Component id="lblCase" max="32767" attributes="0"/> - <Component id="lblByFileTypes" max="32767" attributes="0"/> - <Component id="jSeparator2" max="32767" attributes="0"/> - <Component id="jScrollPane2" max="32767" attributes="0"/> <Component id="jSeparator1" max="32767" attributes="0"/> <Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/> <Group type="102" alignment="0" attributes="0"> @@ -76,19 +79,29 @@ <EmptySpace max="32767" attributes="0"/> <Component id="cmdFolderAll" min="-2" max="-2" attributes="0"/> </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="cmdCommonNameTemplate" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="lblCommonNameTemplate" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="cmdNameTemplateAll" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="lblByFileTypes" max="32767" attributes="0"/> + <Component id="jSeparator2" max="32767" attributes="0"/> + <Component id="jScrollPane2" max="32767" attributes="0"/> <Group type="102" alignment="1" attributes="0"> <EmptySpace min="0" pref="0" max="32767" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> - <Group type="102" alignment="1" attributes="0"> - <Component id="cmdSave" min="-2" max="-2" attributes="0"/> - <EmptySpace max="-2" attributes="0"/> - <Component id="cmdCancel" min="-2" max="-2" attributes="0"/> - </Group> <Group type="102" alignment="1" attributes="0"> <Component id="lblFileCount" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="lblTotalSize" min="-2" pref="51" max="-2" attributes="0"/> </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="cmdSave" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="cmdCancel" min="-2" max="-2" attributes="0"/> + </Group> </Group> </Group> </Group> @@ -121,6 +134,12 @@ <Component id="cmdFolderAll" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="cmdCommonNameTemplate" pref="30" max="32767" attributes="0"/> + <Component id="cmdNameTemplateAll" max="-2" attributes="0"/> + <Component id="lblCommonNameTemplate" alignment="0" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> <Component id="lblByFileTypes" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="jScrollPane2" min="-2" pref="79" max="-2" attributes="0"/> @@ -131,8 +150,8 @@ <Component id="cmdCancel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cmdSave" alignment="3" min="-2" max="-2" attributes="0"/> </Group> - <EmptySpace type="unrelated" max="-2" attributes="0"/> - <Component id="jScrollPane1" pref="349" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" pref="414" max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="lblTotalSize" alignment="3" min="-2" max="-2" attributes="0"/> @@ -346,5 +365,32 @@ <Property name="text" type="java.lang.String" value="Auswahl nach Dateitypen:"/> </Properties> </Component> + <Component class="javax.swing.JButton" name="cmdCommonNameTemplate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/icons/edit.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Dateinamenschema"/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="cmdCommonNameTemplateMousePressed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="lblCommonNameTemplate"> + <Properties> + <Property name="text" type="java.lang.String" value="Dateinamens-Template"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="cmdNameTemplateAll"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/icons16/baseline_keyboard_double_arrow_down_black_48dp.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="für alle zum Speichern markierten Dateien übernehmen"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdNameTemplateAllActionPerformed"/> + </Events> + </Component> </SubComponents> </Form> diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveDialog.java index 5152308e2..ea3338852 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveDialog.java @@ -678,13 +678,18 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.client.utils.StringUtils; import com.jdimension.jlawyer.client.utils.ThreadUtils; import com.jdimension.jlawyer.persistence.AppOptionGroupBean; +import com.jdimension.jlawyer.persistence.AppUserBean; +import com.jdimension.jlawyer.persistence.ArchiveFileAddressesBean; import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean; import com.jdimension.jlawyer.persistence.ArchiveFileTagsBean; import com.jdimension.jlawyer.persistence.CaseFolder; +import com.jdimension.jlawyer.persistence.DocumentNameTemplate; import com.jdimension.jlawyer.persistence.DocumentTagsBean; +import com.jdimension.jlawyer.persistence.PartyTypeBean; import com.jdimension.jlawyer.services.ArchiveFileServiceRemote; import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import com.jdimension.jlawyer.services.PartiesTriplet; import com.jdimension.jlawyer.ui.folders.JMenuItemWithFolder; import com.jdimension.jlawyer.ui.tagging.TagToggleButton; import com.jdimension.jlawyer.ui.tagging.WrapLayout; @@ -694,6 +699,7 @@ You should also get your employer (if you work as a programmer) or school, import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; @@ -710,63 +716,75 @@ You should also get your employer (if you work as a programmer) or school, * @author jens */ public class BulkSaveDialog extends javax.swing.JDialog { - - public static final String TYPE_MAIL="mail"; - public static final String TYPE_BEA="bea"; - public static final String TYPE_SCAN="scan"; - public static final String TYPE_DREBIS="drebis"; - + + public static final String TYPE_MAIL = "mail"; + public static final String TYPE_BEA = "bea"; + public static final String TYPE_SCAN = "scan"; + public static final String TYPE_DREBIS = "drebis"; + private static final Logger log = Logger.getLogger(BulkSaveDialog.class.getName()); - - private String sourceType=TYPE_MAIL; - - protected BulkSaveEntryProcessor entryProcessor=null; - + + private String sourceType = TYPE_MAIL; + + protected BulkSaveEntryProcessor entryProcessor = null; + protected ArchiveFileBean selectedCase = null; protected CaseFolder caseFolder = null; protected CaseFolder rootFolder = null; + protected DocumentNameTemplate nameTemplate=null; + protected List<DocumentNameTemplate> allNameTemplates=new ArrayList<>(); private ArrayList<BulkSaveEntry> entryList = new ArrayList<>(); private ArrayList<String> existingFileNames = new ArrayList<>(); + + protected boolean failedOrCancelled = true; + + // caching for data that is required to build the file name if it contains place holders + private List<PartyTypeBean> allPartyTypes=null; + private Collection<String> formPlaceHolders=null; + private HashMap<String, String> formPlaceHolderValues=null; + private AppUserBean caseLawyer=null; + private AppUserBean caseAssistant=null; + private List<PartiesTriplet> parties=new ArrayList<>(); - protected boolean failedOrCancelled=true; /** * Creates new form BulkSaveDialog + * * @param type * @param parent * @param modal */ public BulkSaveDialog(String type, java.awt.Frame parent, boolean modal) { super(parent, modal); - this.sourceType=type; - + this.sourceType = type; + initComponents(); - + this.lblByFileTypes.setForeground(DefaultColorTheme.COLOR_DARK_GREY); pnlEntries.setLayout(new javax.swing.BoxLayout(pnlEntries, javax.swing.BoxLayout.Y_AXIS)); ComponentUtils.restoreDialogSize(this); - this.initializeTags(); + this.initializeOptions(); this.extensionsPanel.setLayout(new WrapLayout()); - + this.cmdCommonTags.setEnabled(false); this.cmdCommonFolder.setEnabled(false); this.cmdTagAll.setEnabled(false); this.cmdFolderAll.setEnabled(false); - + this.jScrollPane1.getVerticalScrollBar().setUnitIncrement(16); } - private void initializeTags() { + private void initializeOptions() { try { ClientSettings settings = ClientSettings.getInstance(); - + String[] lastBulkSaveCaseTags = UserSettings.getInstance().getSettingArray(UserSettings.CONF_BULKSAVE_LASTCASETAGS_PREFIX + this.sourceType, new String[]{""}); AppOptionGroupBean[] allCaseTags = settings.getArchiveFileTagDtos(); List<String> allCaseTagsAsString = new ArrayList<>(); @@ -774,7 +792,7 @@ private void initializeTags() { allCaseTagsAsString.add(aog.getValue()); } - this.buildPopup(this.cmdCaseTags, this.popCaseTags, allCaseTagsAsString, lastBulkSaveCaseTags, UserSettings.CONF_BULKSAVE_LASTCASETAGS_PREFIX + this.sourceType, this.lblCaseTags); + this.buildCheckboxPopup(this.cmdCaseTags, this.popCaseTags, allCaseTagsAsString, lastBulkSaveCaseTags, UserSettings.CONF_BULKSAVE_LASTCASETAGS_PREFIX + this.sourceType, this.lblCaseTags); lblCaseTags.setText(ComponentUtils.getSelectedPopupMenuItemsAsString(this.popCaseTags)); String[] lastBulkSaveDocumentTags = UserSettings.getInstance().getSettingArray(UserSettings.CONF_BULKSAVE_LASTDOCTAGS_PREFIX + this.sourceType, new String[]{""}); @@ -784,16 +802,47 @@ private void initializeTags() { allDocTagsAsString.add(aog.getValue()); } - this.buildPopup(this.cmdCommonTags, this.popCommonDocumentTags, allDocTagsAsString, lastBulkSaveDocumentTags, UserSettings.CONF_BULKSAVE_LASTDOCTAGS_PREFIX + this.sourceType, this.lblCommonTags); + this.buildCheckboxPopup(this.cmdCommonTags, this.popCommonDocumentTags, allDocTagsAsString, lastBulkSaveDocumentTags, UserSettings.CONF_BULKSAVE_LASTDOCTAGS_PREFIX + this.sourceType, this.lblCommonTags); lblCommonTags.setText(ComponentUtils.getSelectedPopupMenuItemsAsString(this.popCommonDocumentTags)); } catch (Exception ex) { log.error("Error connecting to server", ex); ThreadUtils.showErrorDialog(this, "Fehler beim Laden der Aktenetiketten", "Aktenetiketten"); } + + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + this.allNameTemplates = locator.lookupSystemManagementRemote().getDocumentNameTemplates(); + DocumentNameTemplate defaultNameTemplate = locator.lookupSystemManagementRemote().getDefaultDocumentNameTemplate(); + + this.popNameTemplates.removeAll(); + + String lastNameTemplate=StringUtils.nonEmpty(UserSettings.getInstance().getSetting(UserSettings.CONF_BULKSAVE_LASTNAMETEMPLATE_PREFIX + this.sourceType, defaultNameTemplate.getDisplayName())); + for (DocumentNameTemplate t : allNameTemplates) { + if(lastNameTemplate.equals(t.getDisplayName())) + this.nameTemplate=t; + + JMenuItem mi = new JMenuItem(t.getDisplayName()); + mi.addActionListener((ActionEvent e) -> { + this.lblCommonNameTemplate.setText(t.getDisplayName()); + nameTemplate=t; + UserSettings.getInstance().setSetting(UserSettings.CONF_BULKSAVE_LASTNAMETEMPLATE_PREFIX + this.sourceType, t.getDisplayName()); + }); + popNameTemplates.add(mi); + + } + if(this.nameTemplate==null) + this.nameTemplate=defaultNameTemplate; + + this.lblCommonNameTemplate.setText(this.nameTemplate.getDisplayName()); + } catch (Exception ex) { + log.error("Error connecting to server", ex); + ThreadUtils.showErrorDialog(this, "Fehler beim Laden der Dateinamenvorlagen", "Dateinamen"); + } } - private void buildPopup(JButton button, JPopupMenu popup, List<String> tagsInUse, String[] lastFilterTags, String userSettingsKey, JLabel allValues) { + private void buildCheckboxPopup(JButton button, JPopupMenu popup, List<String> tagsInUse, String[] lastFilterTags, String userSettingsKey, JLabel allValues) { if (tagsInUse == null) { tagsInUse = new ArrayList<>(); @@ -855,6 +904,7 @@ private void initComponents() { popCaseTags = new javax.swing.JPopupMenu(); popCommonDocumentTags = new javax.swing.JPopupMenu(); popCommonFolder = new javax.swing.JPopupMenu(); + popNameTemplates = new javax.swing.JPopupMenu(); lblTotalSize = new javax.swing.JLabel(); lblFileCount = new javax.swing.JLabel(); lblCommonTags = new javax.swing.JLabel(); @@ -875,6 +925,9 @@ private void initComponents() { cmdCancel = new javax.swing.JButton(); jSeparator2 = new javax.swing.JSeparator(); lblByFileTypes = new javax.swing.JLabel(); + cmdCommonNameTemplate = new javax.swing.JButton(); + lblCommonNameTemplate = new javax.swing.JLabel(); + cmdNameTemplateAll = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Dateien zur Akte speichern"); @@ -991,6 +1044,24 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { lblByFileTypes.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblByFileTypes.setText("Auswahl nach Dateitypen:"); + cmdCommonNameTemplate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N + cmdCommonNameTemplate.setToolTipText("Dateinamenschema"); + cmdCommonNameTemplate.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + cmdCommonNameTemplateMousePressed(evt); + } + }); + + lblCommonNameTemplate.setText("Dateinamens-Template"); + + cmdNameTemplateAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/baseline_keyboard_double_arrow_down_black_48dp.png"))); // NOI18N + cmdNameTemplateAll.setToolTipText("für alle zum Speichern markierten Dateien übernehmen"); + cmdNameTemplateAll.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmdNameTemplateAllActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( @@ -999,9 +1070,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblCase, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(lblByFileTypes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jSeparator2) - .addComponent(jScrollPane2) .addComponent(jSeparator1) .addComponent(jScrollPane1) .addGroup(layout.createSequentialGroup() @@ -1021,17 +1089,26 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(lblCommonFolder, javax.swing.GroupLayout.PREFERRED_SIZE, 644, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(cmdFolderAll)) + .addGroup(layout.createSequentialGroup() + .addComponent(cmdCommonNameTemplate) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(lblCommonNameTemplate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cmdNameTemplateAll)) + .addComponent(lblByFileTypes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jSeparator2) + .addComponent(jScrollPane2) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(cmdSave) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cmdCancel)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(lblFileCount) .addGap(18, 18, 18) - .addComponent(lblTotalSize, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addComponent(lblTotalSize, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(cmdSave) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cmdCancel))))) .addContainerGap()) ); layout.setVerticalGroup( @@ -1056,6 +1133,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(lblCommonFolder, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cmdFolderAll)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(cmdCommonNameTemplate, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE) + .addComponent(cmdNameTemplateAll) + .addComponent(lblCommonNameTemplate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblByFileTypes) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -1065,8 +1147,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cmdCancel) .addComponent(cmdSave)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblTotalSize) @@ -1086,45 +1168,47 @@ private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST } catch (Exception ex) { log.error("Unable to unarchive case " + selectedCase.getFileNumber(), ex); } - + Thread worker = new Thread(() -> { try { - + ClientSettings settings = ClientSettings.getInstance(); JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote(); - - List<String> caseTags=ComponentUtils.getSelectedPopupMenuItems(this.popCaseTags); - for(String selCaseTag: caseTags) { - ArchiveFileTagsBean tb=new ArchiveFileTagsBean(); + + List<String> caseTags = ComponentUtils.getSelectedPopupMenuItems(this.popCaseTags); + for (String selCaseTag : caseTags) { + ArchiveFileTagsBean tb = new ArchiveFileTagsBean(); tb.setArchiveFileKey(selectedCase); tb.setTagName(selCaseTag); afs.setTag(this.selectedCase.getId(), tb, true); } - + int fails = 0; for (BulkSaveEntry e : entryList) { if (e.isSelected()) { try { - + SwingUtilities.invokeAndWait(() -> { e.setDownloadProgress(); }); - - if(getEntryProcessor()!=null && getEntryProcessor().isPreSaveProcessor()) + + if (getEntryProcessor() != null && getEntryProcessor().isPreSaveProcessor()) { getEntryProcessor().preSave(e, entryList); - - String newDocId=null; - if(getEntryProcessor()!=null && getEntryProcessor().isSaveProcessor()) { - newDocId=getEntryProcessor().save(e, selectedCase); + } + + String newDocId = null; + if (getEntryProcessor() != null && getEntryProcessor().isSaveProcessor()) { + newDocId = getEntryProcessor().save(e, selectedCase); } else { ArchiveFileDocumentsBean newlyAddedDocument = afs.addDocument(selectedCase.getId(), e.getDocumentFilenameNew(), e.getDocumentBytes(), "", null); - newDocId=newlyAddedDocument.getId(); + newDocId = newlyAddedDocument.getId(); } - - if(getEntryProcessor()!=null && getEntryProcessor().isPostSaveProcessor()) + + if (getEntryProcessor() != null && getEntryProcessor().isPostSaveProcessor()) { getEntryProcessor().postSave(e); - + } + if (e.getDocumentDate() != null) { afs.setDocumentDate(newDocId, e.getDocumentDate()); } @@ -1133,11 +1217,11 @@ private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST docList.add(newDocId); afs.moveDocumentsToFolder(docList, e.getSelectedCaseFolder().getId()); } - - if(e.isFavorite()) { + + if (e.isFavorite()) { afs.setDocumentFavorite(newDocId, true); } - + List<String> tags = e.getDocumentTags(); for (String docTag : tags) { afs.setDocumentTag(newDocId, new DocumentTagsBean(newDocId, docTag), true); @@ -1146,36 +1230,36 @@ private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST e.setDownloadSuccess(true, null); e.setSelected(false); }); - + } catch (Exception ex) { - failedOrCancelled=true; - fails = fails+1; + failedOrCancelled = true; + fails = fails + 1; log.error(ex); SwingUtilities.invokeAndWait(() -> { e.setDownloadSuccess(false, ex.getMessage()); }); - + } - + } } - - if (fails==0) { - this.failedOrCancelled=false; + + if (fails == 0) { + this.failedOrCancelled = false; try { Thread.sleep(1500); } catch (Exception ex) { - + } SwingUtilities.invokeAndWait(() -> { setVisible(false); dispose(); }); - + } else { ThreadUtils.showErrorDialog(EditorsRegistry.getInstance().getMainWindow(), "" + fails + " Dokument(e) konnten nicht gespeichert werden - bitte prüfen.", com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_WARNING); } - + EventBroker eb = EventBroker.getInstance(); eb.publishEvent(new CasesChangedEvent()); } catch (Exception ex) { @@ -1196,7 +1280,7 @@ private void cmdFolderAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN- }//GEN-LAST:event_cmdFolderAllActionPerformed private void cmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCancelActionPerformed - this.failedOrCancelled=true; + this.failedOrCancelled = true; this.setVisible(false); this.dispose(); }//GEN-LAST:event_cmdCancelActionPerformed @@ -1226,6 +1310,18 @@ private void cmdCommonFolderMousePressed(java.awt.event.MouseEvent evt) {//GEN-F this.popCommonFolder.show(this.cmdCommonFolder, evt.getX(), evt.getY()); }//GEN-LAST:event_cmdCommonFolderMousePressed + private void cmdCommonNameTemplateMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdCommonNameTemplateMousePressed + this.popNameTemplates.show(this.cmdCommonFolder, evt.getX(), evt.getY()); + }//GEN-LAST:event_cmdCommonNameTemplateMousePressed + + private void cmdNameTemplateAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdNameTemplateAllActionPerformed + for (BulkSaveEntry e : this.entryList) { + if (e.isSelected()) { + e.setNameTemplate(this.nameTemplate); + } + } + }//GEN-LAST:event_cmdNameTemplateAllActionPerformed + private void rebuildExtensionsPanel() { this.extensionsPanel.removeAll(); ArrayList<String> extensions = new ArrayList<>(); @@ -1245,7 +1341,7 @@ private void rebuildExtensionsPanel() { tb.setUnselectedIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/material/baseline_file_download_off_black_48dp.png"))); tb.addActionListener((ActionEvent arg0) -> { for (BulkSaveEntry e : this.entryList) { - if(tb.isSelected()) { + if (tb.isSelected()) { tb.setToolTipText("Dateien mit Endung ." + extString + " werden gespeichert"); } else { tb.setToolTipText("Dateien mit Endung ." + extString + " werden nicht gespeichert"); @@ -1261,20 +1357,24 @@ private void rebuildExtensionsPanel() { public void addEntry(BulkSaveEntry e) { e.setSaveDialog(this); + + e.setPlaceHoldersCache(this.allPartyTypes, this.formPlaceHolders, this.formPlaceHolderValues, this.caseLawyer, this.caseAssistant, this.parties); this.entryList.add(e); this.pnlEntries.add(e); e.setDocumentTags(ComponentUtils.getPopupMenuItems(this.popCommonDocumentTags)); e.selectDocumentTags(ComponentUtils.getSelectedPopupMenuItems(this.popCommonDocumentTags)); e.setCaseFolder(this.rootFolder, caseFolder); + e.setAllNameTemplates(allNameTemplates); + e.setNameTemplate(this.nameTemplate); this.updateTotals(); this.rebuildExtensionsPanel(); this.checkForDuplicateFileNames(); - - this.cmdCommonTags.setEnabled(this.entryList.size()>0); - this.cmdCommonFolder.setEnabled(this.entryList.size()>0); - this.cmdTagAll.setEnabled(this.entryList.size()>0); - this.cmdFolderAll.setEnabled(this.entryList.size()>0); + + this.cmdCommonTags.setEnabled(!this.entryList.isEmpty()); + this.cmdCommonFolder.setEnabled(!this.entryList.isEmpty()); + this.cmdTagAll.setEnabled(!this.entryList.isEmpty()); + this.cmdFolderAll.setEnabled(!this.entryList.isEmpty()); } public void updateTotals() { @@ -1283,8 +1383,9 @@ public void updateTotals() { for (BulkSaveEntry e : this.entryList) { if (e.isSelected()) { files++; - if(e.getDocumentBytes()!=null) + if (e.getDocumentBytes() != null) { totalSize += e.getDocumentBytes().length; + } } } this.lblFileCount.setText(files + " / " + this.entryList.size() + " Datei(en)"); @@ -1321,20 +1422,20 @@ public static void main(String args[]) { /* Create and display the dialog */ java.awt.EventQueue.invokeLater(() -> { FlatLaf.registerCustomDefaultsSource("themes"); - + FlatInterFont.install(); FlatLaf.setPreferredFontFamily(FlatInterFont.FAMILY); FlatLaf.setPreferredLightFontFamily(FlatInterFont.FAMILY_LIGHT); FlatLaf.setPreferredSemiboldFontFamily(FlatInterFont.FAMILY_SEMIBOLD); - + FlatIntelliJLaf.setup(); - + BulkSaveDialog dialog = new BulkSaveDialog(TYPE_MAIL, new javax.swing.JFrame(), true); - + for (int i = 0; i < 10; i++) { dialog.addEntry(new BulkSaveEntry()); } - + dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { @@ -1349,8 +1450,10 @@ public void windowClosing(java.awt.event.WindowEvent e) { private javax.swing.JButton cmdCancel; private javax.swing.JButton cmdCaseTags; private javax.swing.JButton cmdCommonFolder; + private javax.swing.JButton cmdCommonNameTemplate; private javax.swing.JButton cmdCommonTags; private javax.swing.JButton cmdFolderAll; + private javax.swing.JButton cmdNameTemplateAll; private javax.swing.JButton cmdSave; private javax.swing.JButton cmdTagAll; private javax.swing.JPanel extensionsPanel; @@ -1362,6 +1465,7 @@ public void windowClosing(java.awt.event.WindowEvent e) { private javax.swing.JLabel lblCase; private javax.swing.JLabel lblCaseTags; private javax.swing.JLabel lblCommonFolder; + private javax.swing.JLabel lblCommonNameTemplate; private javax.swing.JLabel lblCommonTags; private javax.swing.JLabel lblFileCount; private javax.swing.JLabel lblTotalSize; @@ -1369,6 +1473,7 @@ public void windowClosing(java.awt.event.WindowEvent e) { private javax.swing.JPopupMenu popCaseTags; private javax.swing.JPopupMenu popCommonDocumentTags; private javax.swing.JPopupMenu popCommonFolder; + private javax.swing.JPopupMenu popNameTemplates; // End of variables declaration//GEN-END:variables /** @@ -1393,6 +1498,28 @@ public void setSelectedCase(ArchiveFileBean selectedCase) { for (ArchiveFileDocumentsBean d : docs) { existingFileNames.add(d.getName().toLowerCase()); } + + // cached and passed to BulkSaveEntry to avoid loading for each entry + this.allPartyTypes = locator.lookupSystemManagementRemote().getPartyTypes(); + if(this.selectedCase != null) { + try { + this.caseAssistant = locator.lookupSystemManagementRemote().getUser(this.selectedCase.getAssistant()); + } catch (Exception ex) {} + try { + this.caseLawyer = locator.lookupSystemManagementRemote().getUser(this.selectedCase.getLawyer()); + } catch (Exception ex) {} + this.formPlaceHolders = locator.lookupFormsServiceRemote().getPlaceHoldersForCase(this.selectedCase.getId()); + this.formPlaceHolderValues = locator.lookupFormsServiceRemote().getPlaceHolderValuesForCase(this.selectedCase.getId()); + + try { + List<ArchiveFileAddressesBean> involved = locator.lookupArchiveFileServiceRemote().getInvolvementDetailsForCase(this.selectedCase.getId(), false); + for (ArchiveFileAddressesBean aab : involved) { + parties.add(new PartiesTriplet(aab.getAddressKey(), aab.getReferenceType(), aab)); + } + } catch (Exception ex) { + log.error("Could not load involvements for case " + this.selectedCase.getId(), ex); + } + } } catch (Exception ex) { log.error("Error getting docments for case " + selectedCase.getId(), ex); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.form index 4b1b4da7f..e7e2677f1 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.form @@ -10,6 +10,12 @@ </Container> <Container class="javax.swing.JPopupMenu" name="popFolder"> + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + </Container> + <Container class="javax.swing.JPopupMenu" name="popNameTemplates"> + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> <Property name="useNullLayout" type="boolean" value="true"/> </Layout> @@ -53,9 +59,13 @@ </Group> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> - <Component id="txtFileNameNew" max="32767" attributes="0"/> <Component id="lblSelectedTags" max="32767" attributes="0"/> <Component id="lblFolder" pref="401" max="32767" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="txtFileNameNew" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="cmdNameTemplate" min="-2" max="-2" attributes="0"/> + </Group> </Group> </Group> </Group> @@ -78,7 +88,10 @@ <Component id="lblDownloaded" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> - <Component id="txtFileNameNew" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="txtFileNameNew" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="cmdNameTemplate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> </Group> <Component id="togFavorite" min="-2" max="-2" attributes="0"/> </Group> @@ -197,5 +210,15 @@ </Property> </Properties> </Component> + <Component class="javax.swing.JButton" name="cmdNameTemplate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/icons/edit.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="cmdNameTemplateMouseReleased"/> + </Events> + </Component> </SubComponents> </Form> diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.java index dcf2fdd77..ba3234917 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/BulkSaveEntry.java @@ -668,20 +668,30 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.client.launcher.Launcher; import com.jdimension.jlawyer.client.launcher.LauncherFactory; import com.jdimension.jlawyer.client.launcher.ReadOnlyDocumentStore; +import com.jdimension.jlawyer.client.settings.ClientSettings; import com.jdimension.jlawyer.client.utils.ComponentUtils; import com.jdimension.jlawyer.client.utils.FileUtils; import com.jdimension.jlawyer.client.utils.StringUtils; +import com.jdimension.jlawyer.client.utils.TemplatesUtil; +import com.jdimension.jlawyer.client.utils.ThreadUtils; +import com.jdimension.jlawyer.persistence.AppUserBean; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.persistence.CaseFolder; +import com.jdimension.jlawyer.persistence.DocumentNameTemplate; +import com.jdimension.jlawyer.persistence.PartyTypeBean; +import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import com.jdimension.jlawyer.services.PartiesTriplet; import com.jdimension.jlawyer.ui.folders.JMenuItemWithFolder; import java.awt.Color; import java.awt.Component; import java.awt.Cursor; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.List; import javax.swing.Icon; import javax.swing.JButton; @@ -708,11 +718,20 @@ public class BulkSaveEntry extends javax.swing.JPanel { protected String documentFilenameNew=null; protected CaseFolder caseFolder = null; + private DocumentNameTemplate nameTemplate=null; protected BulkSaveDialog saveDialog=null; protected boolean favorite=false; - + + // caching for data that is required to build the file name if it contains place holders + private List<PartyTypeBean> allPartyTypes=null; + private Collection<String> formPlaceHolders=null; + private HashMap<String, String> formPlaceHolderValues=null; + private AppUserBean caseLawyer=null; + private AppUserBean caseAssistant=null; + private List<PartiesTriplet> parties=null; + /** * Creates new form BulkSaveEntry */ @@ -722,6 +741,15 @@ public BulkSaveEntry() { this.lblDownloaded.setText(""); this.sepBottom.setForeground(DefaultColorTheme.COLOR_DARK_GREY); } + + public void setPlaceHoldersCache(List<PartyTypeBean> allPartyTypes, Collection<String> formPlaceHolders, HashMap<String, String> formPlaceHolderValues, AppUserBean caseLawyer, AppUserBean caseAssistant, List<PartiesTriplet> parties) { + this.allPartyTypes=allPartyTypes; + this.formPlaceHolders=formPlaceHolders; + this.formPlaceHolderValues=formPlaceHolderValues; + this.caseLawyer=caseLawyer; + this.caseAssistant=caseAssistant; + this.parties=parties; + } /** * This method is called from within the constructor to initialize the form. @@ -734,6 +762,7 @@ private void initComponents() { popDocTags = new javax.swing.JPopupMenu(); popFolder = new javax.swing.JPopupMenu(); + popNameTemplates = new javax.swing.JPopupMenu(); togSave = new javax.swing.JToggleButton(); lblFileNameOrg = new javax.swing.JLabel(); txtFileNameNew = new javax.swing.JTextField(); @@ -745,6 +774,7 @@ private void initComponents() { cmdDocTags = new javax.swing.JButton(); cmdFolder = new javax.swing.JButton(); lblDownloaded = new javax.swing.JLabel(); + cmdNameTemplate = new javax.swing.JButton(); togSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/material/baseline_file_download_off_black_48dp.png"))); // NOI18N togSave.setSelected(true); @@ -809,6 +839,13 @@ public void mousePressed(java.awt.event.MouseEvent evt) { lblDownloaded.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/material/empty_20.png"))); // NOI18N + cmdNameTemplate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N + cmdNameTemplate.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseReleased(java.awt.event.MouseEvent evt) { + cmdNameTemplateMouseReleased(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -834,9 +871,12 @@ public void mousePressed(java.awt.event.MouseEvent evt) { .addComponent(togFavorite)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(txtFileNameNew) .addComponent(lblSelectedTags, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(lblFolder, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)))))) + .addComponent(lblFolder, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(txtFileNameNew) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cmdNameTemplate))))))) .addContainerGap()) ); layout.setVerticalGroup( @@ -851,7 +891,9 @@ public void mousePressed(java.awt.event.MouseEvent evt) { .addComponent(lblFileSize) .addComponent(lblDownloaded)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtFileNameNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtFileNameNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(cmdNameTemplate))) .addComponent(togFavorite)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) @@ -899,7 +941,7 @@ private void cmdFolderMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:e this.popFolder.show(this.cmdFolder, evt.getX(), evt.getY()); }//GEN-LAST:event_cmdFolderMousePressed - private void txtFileNameNewKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtFileNameNewKeyReleased + private void fileNameChanged() { this.documentFilenameNew=this.txtFileNameNew.getText(); String oldExt=FileUtils.getExtension(this.documentFilename); String newExt=FileUtils.getExtension(this.documentFilenameNew); @@ -921,7 +963,12 @@ private void txtFileNameNewKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST this.txtFileNameNew.setCaretPosition(caretPosition); } - this.saveDialog.checkForDuplicateFileNames(); + if(this.saveDialog!=null) + this.saveDialog.checkForDuplicateFileNames(); + } + + private void txtFileNameNewKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtFileNameNewKeyReleased + this.fileNameChanged(); }//GEN-LAST:event_txtFileNameNewKeyReleased private void lblFileNameOrgMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblFileNameOrgMouseEntered @@ -962,6 +1009,10 @@ private void togFavoriteItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FI this.favorite=this.togFavorite.isSelected(); }//GEN-LAST:event_togFavoriteItemStateChanged + private void cmdNameTemplateMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdNameTemplateMouseReleased + this.popNameTemplates.show(this.cmdNameTemplate, evt.getX(), evt.getY()); + }//GEN-LAST:event_cmdNameTemplateMouseReleased + public void setDownloadProgress() { this.lblDownloaded.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/material/baseline_hourglass_top_black_48dp.png"))); } @@ -985,7 +1036,7 @@ public List<String> getDocumentTags() { public void selectDocumentTags(List<String> tags) { ComponentUtils.selectPopupMenuItems(this.popDocTags, tags); - if (tags.size() > 0) { + if (!tags.isEmpty()) { this.cmdDocTags.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/material/baseline_label_green_36dp.png"))); } else { this.cmdDocTags.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons16/material/baseline_label_white_36dp.png"))); @@ -1035,6 +1086,7 @@ private void buildPopup(JButton button, JPopupMenu popup, List<String> tagsInUse // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cmdDocTags; private javax.swing.JButton cmdFolder; + private javax.swing.JButton cmdNameTemplate; private javax.swing.JLabel lblDownloaded; private javax.swing.JLabel lblFileNameOrg; private javax.swing.JLabel lblFileSize; @@ -1042,6 +1094,7 @@ private void buildPopup(JButton button, JPopupMenu popup, List<String> tagsInUse private javax.swing.JLabel lblSelectedTags; private javax.swing.JPopupMenu popDocTags; private javax.swing.JPopupMenu popFolder; + private javax.swing.JPopupMenu popNameTemplates; private javax.swing.JSeparator sepBottom; private javax.swing.JToggleButton togFavorite; private javax.swing.JToggleButton togSave; @@ -1108,9 +1161,10 @@ public String getDocumentFilenameNew() { /** * @param documentFilenameNew the documentFilenameNew to set */ - public void setDocumentFilenameNew(String documentFilenameNew) { + private void setDocumentFilenameNew(String documentFilenameNew) { this.documentFilenameNew = documentFilenameNew; this.txtFileNameNew.setText(documentFilenameNew); + this.fileNameChanged(); } public void setDocumentFilenameNewOutline(String flatLafOutline) { @@ -1218,4 +1272,62 @@ public void setFavorite(boolean favorite) { this.favorite = favorite; this.togFavorite.setSelected(favorite); } + + /** + * @return the nameTemplate + */ + public DocumentNameTemplate getNameTemplate() { + return nameTemplate; + } + + /** + * @param nameTemplate the nameTemplate to set + */ + public void setNameTemplate(DocumentNameTemplate nameTemplate) { + this.nameTemplate = nameTemplate; + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + if(this.documentDate==null) + this.documentDate=new Date(); + + + String extension=FileUtils.getExtension(this.documentFilename); + String docName=locator.lookupArchiveFileServiceRemote().getNewDocumentName(this.documentFilename, this.documentDate, nameTemplate); + + ArchiveFileBean selectedCase=null; + if(this.saveDialog!=null) + selectedCase=this.saveDialog.getSelectedCase(); + + HashMap<String, Object> placeHolders=TemplatesUtil.getPlaceHolderValues(docName, selectedCase, this.parties, null, this.allPartyTypes, this.formPlaceHolders, this.formPlaceHolderValues, this.caseLawyer, this.caseAssistant); + docName=TemplatesUtil.replacePlaceHolders(docName, placeHolders); + docName=FileUtils.sanitizeFileName(docName); + + // remove any extension, because of the template it might be somewhere in the middle of the new name + docName=docName.replace("." + extension, ""); + + // add back extension + docName=FileUtils.preserveExtension(this.documentFilename, docName); + + this.setDocumentFilenameNew(docName); + + } catch (Exception ex) { + log.error("Error getting new document name", ex); + ThreadUtils.showErrorDialog(this, "Fehler beim Anwenden der Dateinamensvorschrift", "Dateinamen"); + } + } + + public void setAllNameTemplates(List<DocumentNameTemplate> allTemplates) { + this.popNameTemplates.removeAll(); + + for (DocumentNameTemplate t : allTemplates) { + JMenuItem mi = new JMenuItem(t.getDisplayName()); + mi.addActionListener((ActionEvent e) -> { + setNameTemplate(t); + }); + popNameTemplates.add(mi); + + } + } } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ExportAsPdfMergeStep.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ExportAsPdfMergeStep.java index eb533fa55..b772f6af9 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ExportAsPdfMergeStep.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ExportAsPdfMergeStep.java @@ -794,7 +794,7 @@ public void finishedEvent() { try { ArchiveFileBean exportCase=(ArchiveFileBean)this.data.get("export.case"); byte[] content = FileUtils.readFile(new File(resultFile)); - String newName = FileUtils.getNewFileName(new File(resultFile).getName(), false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "PDF-Export zur Akte speichern"); + String newName = FileUtils.getNewFileName(exportCase, new File(resultFile).getName(), false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "PDF-Export zur Akte speichern"); if (newName == null || "".equalsIgnoreCase(newName)) { return; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/UploadDocumentsAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/UploadDocumentsAction.java index 1ea981bb3..8937197c3 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/UploadDocumentsAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/UploadDocumentsAction.java @@ -688,27 +688,27 @@ public class UploadDocumentsAction extends ProgressableAction { private static final Logger log = Logger.getLogger(UploadDocumentsAction.class.getName()); - - private String archiveFileKey; + + private ArchiveFileBean archiveFile; private Component owner; private CaseFolderPanel docTarget; - private CaseFolder targetFolder=null; - private Invoice invoice=null; + private CaseFolder targetFolder = null; + private Invoice invoice = null; private List<File> files; - public UploadDocumentsAction(ProgressIndicator i, Component owner, String archiveFileKey, CaseFolderPanel docTarget, List<File> files, CaseFolder targetFolder, Invoice invoice) { + public UploadDocumentsAction(ProgressIndicator i, Component owner, ArchiveFileBean archiveFile, CaseFolderPanel docTarget, List<File> files, CaseFolder targetFolder, Invoice invoice) { super(i, false); - this.archiveFileKey = archiveFileKey; + this.archiveFile = archiveFile; this.owner = owner; this.docTarget = docTarget; this.files = files; - this.targetFolder=targetFolder; - this.invoice=invoice; + this.targetFolder = targetFolder; + this.invoice = invoice; } - + @Override public int getMax() { return files.size(); @@ -730,57 +730,100 @@ public boolean execute() throws Exception { for (File f : this.files) { if (!this.isCancelled()) { - this.progress("Speichere " + f.getName() + "..."); - if (!f.isDirectory()) { - - byte[] data = FileUtils.readFile(f); - - String newName = f.getName(); - boolean documentExists = afs.doesDocumentExist(this.archiveFileKey, newName); - while (documentExists) { - - newName = FileUtils.getNewFileName(newName, false, new Date(), this.indicator, "neuer Dateiname"); - if (newName == null || "".equals(newName)) { - EditorsRegistry.getInstance().clearStatus(true); - ThreadUtils.setDefaultCursor(this.owner); - return false; - } - documentExists = afs.doesDocumentExist(this.archiveFileKey, newName); - - } - - final ArchiveFileDocumentsBean doc = afs.addDocument(this.archiveFileKey, newName, data, null, null); - - if(this.invoice!=null) { - afs.linkInvoiceDocument(doc.getId(), invoice.getId()); - } - -// persisting the folder for this document is automatically done by this call (not just UI update) - SwingUtilities.invokeLater(() -> { - docTarget.addDocument(doc, invoice); - if(targetFolder!=null) { - ArrayList<ArchiveFileDocumentsBean> docs=new ArrayList<>(); - docs.add(doc); - docTarget.moveDocumentsToFolder(docs, targetFolder); - } - }); + if (f.isDirectory()) { + boolean proceed=this.processDirectory(f, this.targetFolder, afs); + if(!proceed) + return false; + } else { + boolean proceed=this.processFile(f, this.targetFolder, afs); + if(!proceed) + return false; } } } } catch (Exception ex) { log.error("Error connecting to server", ex); JOptionPane.showMessageDialog(this.indicator, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); + return true; + } finally { EditorsRegistry.getInstance().clearStatus(true); ThreadUtils.setDefaultCursor(this.owner); + } + + return true; + + } + + private boolean processFile(File f, CaseFolder folder, ArchiveFileServiceRemote afs) throws Exception { + this.progress("Speichere " + f.getName() + "..."); + + byte[] data = FileUtils.readFile(f); + + String newName = f.getName(); + boolean documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); + while (documentExists) { + + newName = FileUtils.getNewFileName(this.archiveFile, newName, false, new Date(), true, this.indicator, "neuer Dateiname"); + if (newName == null || "".equals(newName)) { + EditorsRegistry.getInstance().clearStatus(true); + ThreadUtils.setDefaultCursor(this.owner); + return false; + } + documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); - return true; } - EditorsRegistry.getInstance().clearStatus(true); - ThreadUtils.setDefaultCursor(this.owner); + final ArchiveFileDocumentsBean doc = afs.addDocument(this.archiveFile.getId(), newName, data, null, null); + if (this.invoice != null) { + afs.linkInvoiceDocument(doc.getId(), invoice.getId()); + } + + // persisting the folder for this document is automatically done by this call (not just UI update) + SwingUtilities.invokeLater(() -> { + docTarget.addDocument(doc, invoice); + if (folder != null) { + ArrayList<ArchiveFileDocumentsBean> docs = new ArrayList<>(); + docs.add(doc); + docTarget.moveDocumentsToFolder(docs, folder); + } + }); + return true; + } + private boolean processDirectory(File f, CaseFolder parentFolder, ArchiveFileServiceRemote afs) throws Exception { + + if(!f.isDirectory()) + throw new Exception(f.getName() + " ist kein Ordner!"); + + File[] children=f.listFiles(); + CaseFolder newFolder=null; + if(children.length>0) { + if(!parentFolder.hasChild(f.getName())) { + newFolder=afs.createCaseFolder(parentFolder.getId(), f.getName()); + this.docTarget.getFoldersListPanel().folderAdded(parentFolder, newFolder); + } else { + newFolder=parentFolder.getChild(f.getName()); + } + } + + for(File file: children) { + if (!this.isCancelled()) { + + if (file.isDirectory()) { + boolean proceed=this.processDirectory(file, newFolder, afs); + if(!proceed) + return false; + } else { + boolean proceed=this.processFile(file, newFolder, afs); + if(!proceed) + return false; + } + } + } + return true; + } } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailFolderTreeCellRenderer.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailFolderTreeCellRenderer.java index 4103543f3..001413a26 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailFolderTreeCellRenderer.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailFolderTreeCellRenderer.java @@ -667,7 +667,10 @@ import java.awt.Color; import java.awt.Component; import java.awt.Font; +import java.util.HashMap; +import java.util.Map; import javax.mail.Folder; +import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; @@ -682,11 +685,13 @@ public class EmailFolderTreeCellRenderer extends DefaultTreeCellRenderer { private static final Logger log = Logger.getLogger(EmailFolderTreeCellRenderer.class.getName()); - - private static final String FOLDER_SENT="sent"; - private static final String FOLDER_TRASH="trash"; - private static final String FOLDER_INBOX="inbox"; - private static final String FOLDER_DRAFTS="drafts"; + + private static final String FOLDER_SENT = "sent"; + private static final String FOLDER_TRASH = "trash"; + private static final String FOLDER_INBOX = "inbox"; + private static final String FOLDER_DRAFTS = "drafts"; + + private static final Map<String, Icon> folderIcons = new HashMap<>(); private final ImageIcon draftsIcon = new javax.swing.ImageIcon(EmailFolderTreeCellRenderer.class.getResource("/icons/drafts.png")); private final ImageIcon trashIcon = new javax.swing.ImageIcon(EmailFolderTreeCellRenderer.class.getResource("/icons/trashcan_full.png")); @@ -694,16 +699,17 @@ public class EmailFolderTreeCellRenderer extends DefaultTreeCellRenderer { private final ImageIcon inboxIcon = new javax.swing.ImageIcon(EmailFolderTreeCellRenderer.class.getResource("/icons/folder_inbox.png")); private final ImageIcon mailboxIcon = new javax.swing.ImageIcon(EmailFolderTreeCellRenderer.class.getResource("/icons/mail_send_2.png")); private final ImageIcon importedIcon = new javax.swing.ImageIcon(getClass().getResource("/icons16/jlawyerorg.png")); - - private Font boldFont=null; - private Font plainFont=null; - + + private Font boldFont = null; + private Font plainFont = null; /** * Creates a new instance of EmailFolderTreeCellRenderer */ public EmailFolderTreeCellRenderer() { super(); + this.boldFont = this.getFont().deriveFont(Font.BOLD); + this.plainFont = this.getFont().deriveFont(Font.PLAIN); } @Override @@ -720,65 +726,26 @@ public Component getTreeCellRendererComponent(JTree jTree, Object object, boolea } - if (((DefaultMutableTreeNode) object).getUserObject() == null) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) object; + Object userObject = node.getUserObject(); + + if (userObject == null) { return this; } - if(this.boldFont == null) - this.boldFont = this.getFont().deriveFont(Font.BOLD); - if (this.plainFont == null) - this.plainFont=this.getFont().deriveFont(Font.PLAIN); - +// if(this.boldFont == null) +// this.boldFont = this.getFont().deriveFont(Font.BOLD); +// if (this.plainFont == null) +// this.plainFont=this.getFont().deriveFont(Font.PLAIN); try { - if (((DefaultMutableTreeNode) object).getUserObject() instanceof FolderContainer) { - FolderContainer fc = (FolderContainer) ((DefaultMutableTreeNode) object).getUserObject(); + if (userObject instanceof FolderContainer) { + FolderContainer fc = (FolderContainer) userObject; Folder f = fc.getFolder(); - - if (FOLDER_TRASH.equalsIgnoreCase(f.getName())) { - this.setIcon(trashIcon); - } else if (FOLDER_SENT.equalsIgnoreCase(f.getName())) { - this.setIcon(sentIcon); - } else if (FOLDER_DRAFTS.equalsIgnoreCase(f.getName())) { - this.setIcon(draftsIcon); - } else if (FOLDER_INBOX.equalsIgnoreCase(f.getName())) { - this.setIcon(inboxIcon); - } else if ("in Akte importiert".equalsIgnoreCase(f.getName())) { - this.setIcon(importedIcon); - } else { - boolean iconIsSet = false; - for (String a : EmailUtils.getFolderAliases(CommonMailUtils.TRASH)) { - if (a.equalsIgnoreCase(f.getName())) { - this.setIcon(trashIcon); - iconIsSet = true; - break; - } - } - for (String a : EmailUtils.getFolderAliases(CommonMailUtils.DRAFTS)) { - if (a.equalsIgnoreCase(f.getName())) { - this.setIcon(draftsIcon); - iconIsSet = true; - break; - } - } - if (!iconIsSet) { - for (String a : EmailUtils.getFolderAliases(CommonMailUtils.SENT)) { - if (a.equalsIgnoreCase(f.getName())) { - this.setIcon(sentIcon); - iconIsSet = true; - break; - } - } - } - if (!iconIsSet) { - for (String a : EmailUtils.getFolderAliases(CommonMailUtils.INBOX)) { - if (a.equalsIgnoreCase(f.getName())) { - this.setIcon(inboxIcon); - break; - } - } - } - } + Icon icon=this.getIconByFolder(f); + if(icon!=null) + this.setIcon(icon); + int unread = fc.getUnreadMessageCount(); if (unread > 0) { this.setFont(this.boldFont); @@ -786,10 +753,10 @@ public Component getTreeCellRendererComponent(JTree jTree, Object object, boolea this.setFont(this.plainFont); } } else { - if (((DefaultMutableTreeNode) object).toString().contains("@")) { + if (object.toString().contains("@")) { this.setIcon(mailboxIcon); this.setFont(this.boldFont); - if(selected) { + if (selected) { this.setForeground(Color.WHITE); } else { this.setForeground(DefaultColorTheme.COLOR_LOGO_BLUE); @@ -804,4 +771,56 @@ public Component getTreeCellRendererComponent(JTree jTree, Object object, boolea } + private Icon getIconByFolder(Folder f) { + + if (!folderIcons.containsKey(f.getName())) { + + if (FOLDER_TRASH.equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), trashIcon); + } else if (FOLDER_SENT.equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), sentIcon); + } else if (FOLDER_DRAFTS.equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), draftsIcon); + } else if (FOLDER_INBOX.equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), inboxIcon); + } else if ("in Akte importiert".equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), importedIcon); + } else { + boolean iconIsSet = false; + for (String a : EmailUtils.getFolderAliases(CommonMailUtils.TRASH)) { + if (a.equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), trashIcon); + iconIsSet = true; + break; + } + } + for (String a : EmailUtils.getFolderAliases(CommonMailUtils.DRAFTS)) { + if (a.equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), draftsIcon); + iconIsSet = true; + break; + } + } + if (!iconIsSet) { + for (String a : EmailUtils.getFolderAliases(CommonMailUtils.SENT)) { + if (a.equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), sentIcon); + iconIsSet = true; + break; + } + } + } + if (!iconIsSet) { + for (String a : EmailUtils.getFolderAliases(CommonMailUtils.INBOX)) { + if (a.equalsIgnoreCase(f.getName())) { + folderIcons.put(f.getName(), inboxIcon); + break; + } + } + } + } + } + return folderIcons.get(f.getName()); + } + } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailInboxPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailInboxPanel.java index 32bc445bf..8c5abe148 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailInboxPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailInboxPanel.java @@ -3055,14 +3055,7 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea newName = ""; } newName = FileUtils.sanitizeFileName(newName); - java.util.Date receivedPrefix = m.getReceivedDate(); - if (receivedPrefix == null) { - receivedPrefix = new java.util.Date(); - } - - bulkEntry.setDocumentFilename(attachmentName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName); - + bulkEntry.setDocumentFilename(newName); bulkSaveDlg.addEntry(bulkEntry); } } @@ -3084,7 +3077,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea bulkEntry.setDocumentDate(sentDate); bulkEntry.setDocumentBytes(data); bulkEntry.setDocumentFilename(newName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName); bulkSaveDlg.addEntry(bulkEntry); } @@ -3102,10 +3094,6 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea newName = ""; } newName = FileUtils.sanitizeFileName(newName); - java.util.Date receivedPrefix = m.getReceivedDate(); - if (receivedPrefix == null) { - receivedPrefix = new java.util.Date(); - } String formerName = newName; newName = FileUtils.preserveExtension(formerName, newName); newName = FileUtils.sanitizeFileName(newName); @@ -3115,8 +3103,7 @@ public boolean saveToCaseCallback(String caseId, boolean withAttachments, boolea } bulkEntry.setDocumentBytes(attachmentData); - bulkEntry.setDocumentFilename(attachmentName); - bulkEntry.setDocumentFilenameNew(FileUtils.getNewFileNamePrefix(receivedPrefix) + newName); + bulkEntry.setDocumentFilename(newName); bulkSaveDlg.addEntry(bulkEntry); } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.form index 9cdddaf81..6056b8f8f 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.form @@ -432,7 +432,6 @@ </Container> <Component class="javax.swing.JComboBox" name="cmbPlaceHolderTarget"> <Properties> - <Property name="maximumRowCount" type="int" value="15"/> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <StringArray count="4"> <StringItem index="0" value="Item 1"/> diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java index 38baa671e..be13dd124 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java @@ -1258,7 +1258,7 @@ private void cmdRenameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR String oldName = selectedValue.toString(); - String newName = FileUtils.getNewFileName(oldName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Vorlage umbenennen"); + String newName = FileUtils.getNewFileName(null, oldName, false, new Date(), false, EditorsRegistry.getInstance().getMainWindow(), "Vorlage umbenennen"); if (newName==null || newName.isEmpty()) { JOptionPane.showMessageDialog(this, "Name darf nicht leer sein.", CommonStrings.HINT, JOptionPane.INFORMATION_MESSAGE); return; @@ -1291,7 +1291,7 @@ private void cmdDuplicateActionPerformed(java.awt.event.ActionEvent evt) {//GEN- String oldName = selectedValue.toString(); - String newName = FileUtils.getNewFileName(oldName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Vorlage duplizieren"); + String newName = FileUtils.getNewFileName(null, oldName, false, new Date(), false, EditorsRegistry.getInstance().getMainWindow(), "Vorlage duplizieren"); if (newName==null || newName.isEmpty()) { JOptionPane.showMessageDialog(this, "Name darf nicht leer sein.", CommonStrings.HINT, JOptionPane.INFORMATION_MESSAGE); return; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/FolderContainer.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/FolderContainer.java index 66e8a688c..272578764 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/FolderContainer.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/FolderContainer.java @@ -664,7 +664,7 @@ package com.jdimension.jlawyer.client.mail; import com.jdimension.jlawyer.email.CommonMailUtils; -import java.util.Hashtable; +import java.util.HashMap; import java.util.Iterator; import java.util.Set; import javax.mail.Folder; @@ -678,15 +678,16 @@ */ public class FolderContainer { - private long cachedToStringUpdated = -1; private String cachedToString = null; - + private long cachedUnreadUpdated = -1; private int cachedUnread = -1; private static final Logger log = Logger.getLogger(FolderContainer.class.getName()); - private static Hashtable<String, String> folderNameMapping = new Hashtable<>(); + private static final HashMap<String, String> folderNameMapping = new HashMap<>(); + + double retentionTime = -1; static { folderNameMapping.put(CommonMailUtils.INBOX, "Posteingang"); @@ -700,38 +701,45 @@ public class FolderContainer { public FolderContainer(Folder f) { this.folder = f; } - + public void resetCaches() { - this.cachedToStringUpdated=-1; - this.cachedUnreadUpdated=-1; + this.cachedToStringUpdated = -1; + this.cachedUnreadUpdated = -1; } - - public int getUnreadMessageCount() { - - // refresh unread message count frequently for inbox, trash, sent, drafts, not for others - // default 15mins plus up to 5hrs - double retentionTime=((15l * 60l * 1000l)+(Math.random()*1000l * 60l * 60l * 5l)); - if(this.folder!=null && this.folder.getName()!=null) { - String folderName=this.folder.getName(); - if(EmailUtils.isInbox(folderName)) { - // 5mins plus up to 5min for inbox - retentionTime=((5l * 60l * 1000l)+(Math.random()*60000l*5l)); - } else if(EmailUtils.isDrafts(folderName) || EmailUtils.isSent(folderName) || EmailUtils.isTrash(folderName)) { - // 15mins plus up to 45min for drafts, sent, trash - retentionTime=((15l * 60l * 1000l)+(Math.random()*60000l*45l)); + + private double getRetentionTime() { + + if (this.retentionTime == -1) { + + // refresh unread message count frequently for inbox, trash, sent, drafts, not for others + // default 15mins plus up to 8hrs + this.retentionTime = ((15l * 60l * 1000l) + (Math.random() * 1000l * 60l * 60l * 8l)); + if (this.folder != null && this.folder.getName() != null) { + String folderName = this.folder.getName(); + if (EmailUtils.isInbox(folderName)) { + // 5mins plus up to 5min for inbox + retentionTime = ((5l * 60l * 1000l) + (Math.random() * 60000l * 5l)); + } else if (EmailUtils.isDrafts(folderName) || EmailUtils.isSent(folderName) || EmailUtils.isTrash(folderName)) { + // 15mins plus up to 45min for drafts, sent, trash + retentionTime = ((15l * 60l * 1000l) + (Math.random() * 60000l * 45l)); + } } } - - if (this.cachedUnreadUpdated == -1 || ((System.currentTimeMillis() - cachedUnreadUpdated) > retentionTime)) { - if(this.folder!=null) { + return this.retentionTime; + } + + public int getUnreadMessageCount() { + + if (this.cachedUnreadUpdated == -1 || ((System.currentTimeMillis() - cachedUnreadUpdated) > this.getRetentionTime())) { + if (this.folder != null) { try { - this.cachedUnread=this.folder.getUnreadMessageCount(); + this.cachedUnread = this.folder.getUnreadMessageCount(); } catch (StoreClosedException stex) { log.warn("Unable to determine number of unread messages - folder is closed"); } catch (MessagingException ex) { log.error("Unable to determine number of unread messages", ex); } - this.cachedUnreadUpdated=System.currentTimeMillis(); + this.cachedUnreadUpdated = System.currentTimeMillis(); } } return cachedUnread; @@ -739,26 +747,13 @@ public int getUnreadMessageCount() { /* * Called e.g. by the email tree cell renderer, therefore it is performance critical - */ + */ @Override public String toString() { - - // refresh unread message count frequently for inbox, trash, sent, drafts, not for others - // default 15mins plus up to 5hrs - double retentionTime=((15l * 60l * 1000l)+(Math.random()*1000l * 60l * 60l * 5l)); - if(this.folder!=null && this.folder.getName()!=null) { - String folderName=this.folder.getName(); - if(EmailUtils.isInbox(folderName)) { - // 5mins plus up to 3min for inbox - retentionTime=((5l * 60l * 1000l)+(Math.random()*60000l*3l)); - } else if(EmailUtils.isDrafts(folderName) || EmailUtils.isSent(folderName) || EmailUtils.isTrash(folderName)) { - // 15mins plus up to 30min for drafts, sent, trash - retentionTime=((15l * 60l * 1000l)+(Math.random()*60000l*30l)); - } - } - - if (this.cachedToStringUpdated == -1 || ((System.currentTimeMillis() - cachedToStringUpdated) > retentionTime)) { + + if (this.cachedToStringUpdated == -1 || ((System.currentTimeMillis() - cachedToStringUpdated) > this.getRetentionTime())) { try { + String name = this.folder.getName(); Set mapKey = folderNameMapping.keySet(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java index 96738f34c..e47ecbfe6 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java @@ -1970,7 +1970,7 @@ private void mnuSearchSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN } } - String newName = FileUtils.getNewFileName(selected.toString(), true); + String newName = FileUtils.getNewFileName(sel, selected.toString(), true, true); if (newName == null) { return; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendAction.java index c4eb3e1d5..032c4ee9d 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendAction.java @@ -936,7 +936,7 @@ public PasswordAuthentication getPasswordAuthentication() { newName = newName + ".eml"; newName = FileUtils.sanitizeFileName(newName); java.util.Date sentPrefix = new Date(); - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this.indicator, "Datei benennen"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, true, sentPrefix, true, this.indicator, "Datei benennen"); if (newName != null) { if (newName.trim().length() == 0) { newName = "E-Mail"; @@ -948,7 +948,7 @@ public PasswordAuthentication getPasswordAuthentication() { boolean documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); while (documentExists) { - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this.indicator, "Datei benennen"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, true, sentPrefix, true, this.indicator, "Datei benennen"); if (newName == null || "".equals(newName)) { break; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java index 8f41e24b2..17d730447 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java @@ -663,6 +663,7 @@ */ package com.jdimension.jlawyer.client.mail; +import com.jdimension.jlawyer.client.utils.TemplatesUtil; import com.jdimension.jlawyer.ai.AiCapability; import com.jdimension.jlawyer.ai.AiRequestStatus; import com.jdimension.jlawyer.ai.InputData; @@ -2139,12 +2140,14 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- EmailTemplate tpl = locator.lookupIntegrationServiceRemote().getEmailTemplate(tplName); - ArrayList<String> placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getSubject(), allPartyTypesPlaceholders, this.formPlaceHolders); + // get a list of placeholders + ArrayList<String> placeHolderNames = TemplatesUtil.getPlaceHoldersInTemplate(tpl.getSubject(), allPartyTypesPlaceholders, this.formPlaceHolders); HashMap<String, Object> ht = new HashMap<>(); for (String ph : placeHolderNames) { ht.put(ph, ""); } + // get user objects for this case AppUserBean caseLawyer = null; AppUserBean caseAssistant = null; AppUserBean author = UserSettings.getInstance().getCurrentUser(); @@ -2161,16 +2164,18 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- } } + // get selected parties List<PartiesPanelEntry> selectedParties = this.pnlParties.getSelectedParties(new ArrayList(allPartyTypes)); List<PartiesTriplet> partiesTriplets=new ArrayList<>(); for(PartiesPanelEntry pe: selectedParties) { PartiesTriplet triplet=new PartiesTriplet(pe.getAddress(), pe.getReferenceType(), pe.getInvolvement()); partiesTriplets.add(triplet); } + // get all placeholder values for the given set of placeholders HashMap<String, Object> htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, this.contextArchiveFile, partiesTriplets, this.contextDictateSign, null, this.formPlaceHolderValues, caseLawyer, caseAssistant, author, null, null, null, null); - this.txtSubject.setText(EmailTemplateAccess.replacePlaceHolders(tpl.getSubject(), htValues)); + this.txtSubject.setText(TemplatesUtil.replacePlaceHolders(tpl.getSubject(), htValues)); - placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders, this.formPlaceHolders); + placeHolderNames = TemplatesUtil.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders, this.formPlaceHolders); ht = new HashMap<>(); for (String ph : placeHolderNames) { ht.put(ph, ""); @@ -2183,7 +2188,7 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- if (tpl.isText()) { if (ms != null) { - String t = EmailTemplateAccess.replacePlaceHolders(tpl.getBody(), htValues) + System.getProperty("line.separator") + System.getProperty("line.separator") + EmailUtils.html2Text(ms.getEmailSignature()); + String t = TemplatesUtil.replacePlaceHolders(tpl.getBody(), htValues) + System.getProperty("line.separator") + System.getProperty("line.separator") + EmailUtils.html2Text(ms.getEmailSignature()); int cursorIndex = t.indexOf(EmailTemplate.PLACEHOLDER_CURSOR); if (cursorIndex > -1) { t = t.replace(EmailTemplate.PLACEHOLDER_CURSOR, ""); @@ -2201,7 +2206,7 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- if (sig == null) { sig = ""; } - String t = EmailTemplateAccess.replacePlaceHolders(tpl.getBody(), htValues) + "<br/><br/><div><blockquote style=\"border-left: #ccc 0px solid; margin: 0px 0px 0px 0.8ex; padding-left: 1ex\">" + sig + "</blockquote></div>"; + String t = TemplatesUtil.replacePlaceHolders(tpl.getBody(), htValues) + "<br/><br/><div><blockquote style=\"border-left: #ccc 0px solid; margin: 0px 0px 0px 0.8ex; padding-left: 1ex\">" + sig + "</blockquote></div>"; int cursorIndex = t.indexOf(EmailTemplate.PLACEHOLDER_CURSOR); if (cursorIndex > -1) { t = t.replace(EmailTemplate.PLACEHOLDER_CURSOR, ""); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEncryptedAction.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEncryptedAction.java index bd76c7de2..c942874aa 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEncryptedAction.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEncryptedAction.java @@ -963,7 +963,7 @@ public PasswordAuthentication getPasswordAuthentication() { newName = newName + ".eml"; newName = FileUtils.sanitizeFileName(newName); java.util.Date sentPrefix = new Date(); - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this.indicator, "Datei benennen"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, true, sentPrefix, true, this.indicator, "Datei benennen"); if (newName != null) { if (newName.trim().length() == 0) { @@ -976,7 +976,7 @@ public PasswordAuthentication getPasswordAuthentication() { boolean documentExists = afs.doesDocumentExist(this.archiveFile.getId(), newName); while (documentExists) { - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this.indicator, "Datei benennen"); + newName = FileUtils.getNewFileName(this.archiveFile, newName, true, sentPrefix, true, this.indicator, "Datei benennen"); if (newName == null || "".equals(newName)) { break; } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/templates/TemplatesTreePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/templates/TemplatesTreePanel.java index 44b69e8fd..a744ae5f0 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/templates/TemplatesTreePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/templates/TemplatesTreePanel.java @@ -1371,7 +1371,7 @@ private void mnuRenameTemplateActionPerformed(java.awt.event.ActionEvent evt) {/ } DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) tp.getLastPathComponent(); GenericNode folder = (GenericNode) selNode.getUserObject(); - String newName=FileUtils.getNewFileName(this.lstTemplates.getSelectedValue().toString(), false, null, this, "Vorlage umbenennen"); + String newName=FileUtils.getNewFileName(null, this.lstTemplates.getSelectedValue().toString(), false, null, false, this, "Vorlage umbenennen"); if(newName==null) return; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java index 11ac84324..c97795dca 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java @@ -666,6 +666,7 @@ import com.jdimension.jlawyer.client.editors.EditorsRegistry; import com.jdimension.jlawyer.client.launcher.LauncherFactory; import com.jdimension.jlawyer.client.settings.ClientSettings; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.server.utils.ServerFileUtils; import java.awt.Component; import java.awt.Toolkit; @@ -721,14 +722,6 @@ private FileUtils() { } - public static String getExtension(String fileName) { - int index = fileName.lastIndexOf('.'); - if (index > -1 && index < fileName.length()) { - return fileName.substring(index + 1); - } - return "url-with-no-extension"; - } - public Icon getFileTypeIcon(String fileName) { if (fileName == null) { @@ -841,19 +834,19 @@ public static String getFileSizeHumanReadable(long size) { } } - public static String getNewFileName(String currentFileName, boolean datetimePrefix) { - return getNewFileName(currentFileName, datetimePrefix, new java.util.Date()); + public static String getNewFileName(ArchiveFileBean selectedCase, String currentFileName, boolean datetimePrefix, boolean applyNameTemplate) { + return getNewFileName(selectedCase, currentFileName, datetimePrefix, new java.util.Date(), applyNameTemplate); } - public static String getNewFileName(String currentFileName, boolean datetimePrefix, java.util.Date d) { + public static String getNewFileName(ArchiveFileBean selectedCase, String currentFileName, boolean datetimePrefix, java.util.Date d, boolean applyNameTemplate) { - return getNewFileName(currentFileName, datetimePrefix, d, EditorsRegistry.getInstance().getMainWindow(), "Datei benennen"); + return getNewFileName(selectedCase, currentFileName, datetimePrefix, d, applyNameTemplate, EditorsRegistry.getInstance().getMainWindow(), "Datei benennen"); } - public static String getNewFileName(String currentFileName, boolean datetimePrefix, java.util.Date d, Component parent) { + public static String getNewFileName(ArchiveFileBean selectedCase, String currentFileName, boolean datetimePrefix, java.util.Date d, boolean applyNameTemplate, Component parent) { - return getNewFileName(currentFileName, datetimePrefix, d, parent, "Datei benennen"); + return getNewFileName(selectedCase, currentFileName, datetimePrefix, d, applyNameTemplate, parent, "Datei benennen"); } @@ -1058,7 +1051,7 @@ public static void cleanupTempFile(String url) { } - public static String getNewFileName(String currentFileName, boolean datetimePrefix, java.util.Date d, Component parent, String title) { + public static String getNewFileName(ArchiveFileBean selectedCase, String currentFileName, boolean datetimePrefix, java.util.Date d, boolean applyNameTemplate, Component parent, String title) { String dtPrefix = ""; if (datetimePrefix) { @@ -1069,8 +1062,13 @@ public static String getNewFileName(String currentFileName, boolean datetimePref parent = EditorsRegistry.getInstance().getMainWindow(); } - NewFilenameOptionPanel p = new NewFilenameOptionPanel(); - p.setFilename(dtPrefix + currentFileName); + NewFilenameOptionPanel p = null; + if(selectedCase==null) + p = new NewFilenameOptionPanel(); + else + p = new NewFilenameOptionPanel(selectedCase); + + p.setFilename(currentFileName, d, applyNameTemplate); JOptionPane pane = new JOptionPane(p, JOptionPane.QUESTION_MESSAGE); JDialog dialog = pane.createDialog(parent, title); dialog.doLayout(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.form index 14c3fe300..231730748 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.form @@ -1,6 +1,14 @@ <?xml version="1.0" encoding="UTF-8" ?> <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <NonVisualComponents> + <Container class="javax.swing.JPopupMenu" name="popNameTemplates"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + </Container> + </NonVisualComponents> <Properties> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Dimension value="[600, 81]"/> @@ -27,15 +35,21 @@ <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <Component id="jLabel1" min="-2" max="-2" attributes="0"/> - <EmptySpace min="0" pref="414" max="32767" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="534" max="32767" attributes="0"/> + <Component id="cmdCancel" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="txtNewName" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="cmdNameTemplate" min="-2" max="-2" attributes="0"/> </Group> - <Component id="txtNewName" max="32767" attributes="0"/> </Group> </Group> - <Group type="102" attributes="0"> - <EmptySpace min="0" pref="0" max="32767" attributes="0"/> - <Component id="lblCancel" min="-2" max="-2" attributes="0"/> - </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> @@ -46,9 +60,10 @@ <Group type="103" groupAlignment="3" attributes="0"> <Component id="txtNewName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblIcon" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="cmdNameTemplate" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> - <Component id="lblCancel" min="-2" max="-2" attributes="0"/> + <Component id="cmdCancel" min="-2" max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/> </Group> </Group> @@ -67,12 +82,22 @@ </Component> <Component class="javax.swing.JTextField" name="txtNewName"> </Component> - <Component class="javax.swing.JButton" name="lblCancel"> + <Component class="javax.swing.JButton" name="cmdCancel"> <Properties> <Property name="text" type="java.lang.String" value="Abbrechen"/> </Properties> <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lblCancelActionPerformed"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="cmdNameTemplate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/icons/edit.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="cmdNameTemplateMouseReleased"/> </Events> </Component> </SubComponents> diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.java index 78e0f89a9..4c76456a9 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/NewFilenameOptionPanel.java @@ -663,8 +663,27 @@ */ package com.jdimension.jlawyer.client.utils; +import com.jdimension.jlawyer.client.settings.ClientSettings; +import com.jdimension.jlawyer.client.settings.UserSettings; +import com.jdimension.jlawyer.persistence.AppOptionGroupBean; +import com.jdimension.jlawyer.persistence.AppUserBean; +import com.jdimension.jlawyer.persistence.ArchiveFileAddressesBean; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; +import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean; +import com.jdimension.jlawyer.persistence.DocumentNameTemplate; +import com.jdimension.jlawyer.persistence.PartyTypeBean; +import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import com.jdimension.jlawyer.services.PartiesTriplet; import java.awt.Container; +import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; import javax.swing.JDialog; +import javax.swing.JMenuItem; +import org.apache.log4j.Logger; /** * @@ -672,21 +691,185 @@ */ public class NewFilenameOptionPanel extends javax.swing.JPanel { + private static final Logger log = Logger.getLogger(NewFilenameOptionPanel.class.getName()); + + private ArrayList<String> existingFileNames = new ArrayList<>(); + + private DocumentNameTemplate nameTemplate=null; + + // caching for data that is required to build the file name if it contains place holders + private List<PartyTypeBean> allPartyTypes = null; + private Collection<String> formPlaceHolders = null; + private HashMap<String, String> formPlaceHolderValues = null; + private AppUserBean caseLawyer = null; + private AppUserBean caseAssistant = null; + private List<PartiesTriplet> parties = new ArrayList<>(); + + private ArchiveFileBean selectedCase = null; + private Date documentDate=null; + private String documentFilename=null; + private String documentFilenameNew=null; + /** * Creates new form NewFilenameOptionPanel */ public NewFilenameOptionPanel() { initComponents(); + + initializeOptions(); + } + + public NewFilenameOptionPanel(ArchiveFileBean selectedCase) { + initComponents(); + + initializeOptions(); + + this.selectedCase = selectedCase; + if (this.selectedCase != null) { + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + Collection<ArchiveFileDocumentsBean> docs = locator.lookupArchiveFileServiceRemote().getDocuments(selectedCase.getId()); + for (ArchiveFileDocumentsBean d : docs) { + existingFileNames.add(d.getName().toLowerCase()); + } + + // cached and passed to BulkSaveEntry to avoid loading for each entry + this.allPartyTypes = locator.lookupSystemManagementRemote().getPartyTypes(); + if (this.selectedCase != null) { + try { + this.caseAssistant = locator.lookupSystemManagementRemote().getUser(this.selectedCase.getAssistant()); + } catch (Exception ex) { + } + try { + this.caseLawyer = locator.lookupSystemManagementRemote().getUser(this.selectedCase.getLawyer()); + } catch (Exception ex) { + } + this.formPlaceHolders = locator.lookupFormsServiceRemote().getPlaceHoldersForCase(this.selectedCase.getId()); + this.formPlaceHolderValues = locator.lookupFormsServiceRemote().getPlaceHolderValuesForCase(this.selectedCase.getId()); + + try { + List<ArchiveFileAddressesBean> involved = locator.lookupArchiveFileServiceRemote().getInvolvementDetailsForCase(this.selectedCase.getId(), false); + for (ArchiveFileAddressesBean aab : involved) { + parties.add(new PartiesTriplet(aab.getAddressKey(), aab.getReferenceType(), aab)); + } + } catch (Exception ex) { + log.error("Could not load involvements for case " + this.selectedCase.getId(), ex); + } + } + + } catch (Exception ex) { + log.error("Error getting docments for case " + selectedCase.getId(), ex); + ThreadUtils.showErrorDialog(this, "Fehler beim Laden der Dokumente der Akte", "Dokumente speichern"); + } + } } - public void setFilename(String name) { - this.txtNewName.setText(name); - this.lblIcon.setIcon(FileUtils.getInstance().getFileTypeIcon(name)); + private void initializeOptions() { + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + List<DocumentNameTemplate> allNameTemplates = locator.lookupSystemManagementRemote().getDocumentNameTemplates(); + DocumentNameTemplate defaultNameTemplate = locator.lookupSystemManagementRemote().getDefaultDocumentNameTemplate(); + + this.popNameTemplates.removeAll(); + + for (DocumentNameTemplate t : allNameTemplates) { + JMenuItem mi = new JMenuItem(t.getDisplayName()); + mi.addActionListener((ActionEvent e) -> { + setNameTemplate(t); + }); + popNameTemplates.add(mi); + + } + this.nameTemplate=defaultNameTemplate; + } catch (Exception ex) { + log.error("Error connecting to server", ex); + ThreadUtils.showErrorDialog(this, "Fehler beim Laden der Dateinamenvorlagen", "Dateinamen"); + } + } + + public void setNameTemplate(DocumentNameTemplate nameTemplate) { + this.nameTemplate = nameTemplate; + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + String extension=FileUtils.getExtension(this.documentFilename); + String docName=locator.lookupArchiveFileServiceRemote().getNewDocumentName(this.documentFilename, this.documentDate, this.nameTemplate); + + HashMap<String, Object> placeHolders=TemplatesUtil.getPlaceHolderValues(docName, selectedCase, this.parties, null, this.allPartyTypes, this.formPlaceHolders, this.formPlaceHolderValues, this.caseLawyer, this.caseAssistant); + docName=TemplatesUtil.replacePlaceHolders(docName, placeHolders); + docName=FileUtils.sanitizeFileName(docName); + + // remove any extension, because of the template it might be somewhere in the middle of the new name + docName=docName.replace("." + extension, ""); + + // add back extension + docName=FileUtils.preserveExtension(this.documentFilename, docName); + + + this.setDocumentFilenameNew(docName); + + } catch (Exception ex) { + log.error("Error getting new document name", ex); + ThreadUtils.showErrorDialog(this, "Fehler beim Anwenden der Dateinamensvorschrift", "Dateinamen"); + } + } + + private void setDocumentFilenameNew(String documentFilenameNew) { + this.documentFilenameNew = documentFilenameNew; + this.txtNewName.setText(documentFilenameNew); + this.fileNameChanged(); + } + + private void fileNameChanged() { + this.documentFilenameNew=this.txtNewName.getText(); + String oldExt=FileUtils.getExtension(this.documentFilename); + String newExt=FileUtils.getExtension(this.documentFilenameNew); + if(!oldExt.equalsIgnoreCase(newExt)) { + int caretPosition=this.txtNewName.getCaretPosition(); + this.documentFilenameNew=FileUtils.preserveExtension(this.documentFilename, this.documentFilenameNew); + this.txtNewName.setText(this.documentFilenameNew); + if(this.txtNewName.getText().length()>=caretPosition) + this.txtNewName.setCaretPosition(caretPosition); + } + + // use may have typed invalid characters + String checkedName=FileUtils.sanitizeFileName(this.documentFilenameNew); + if(!checkedName.equals(this.txtNewName.getText())) { + int caretPosition=this.txtNewName.getCaretPosition(); + this.txtNewName.setText(checkedName); + this.documentFilenameNew=checkedName; + if(this.txtNewName.getText().length()>=caretPosition) + this.txtNewName.setCaretPosition(caretPosition); + } } + public void setFilename(String name, Date documentDate, boolean applyNameTemplate) { + + if(documentDate==null) + this.documentDate=new Date(); + else + this.documentDate=documentDate; + + this.documentFilename=name; + if(applyNameTemplate) + this.setNameTemplate(this.nameTemplate); + else + this.setDocumentFilenameNew(name); + + this.lblIcon.setIcon(FileUtils.getInstance().getFileTypeIcon(name)); + + } + public String getFilename() { - return this.txtNewName.getText(); + if(StringUtils.isEmpty(this.txtNewName.getText())) + return null; + else + return FileUtils.preserveExtension(this.documentFilename, this.txtNewName.getText()); } /** @@ -698,10 +881,12 @@ public String getFilename() { // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { + popNameTemplates = new javax.swing.JPopupMenu(); lblIcon = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); txtNewName = new javax.swing.JTextField(); - lblCancel = new javax.swing.JButton(); + cmdCancel = new javax.swing.JButton(); + cmdNameTemplate = new javax.swing.JButton(); setPreferredSize(new java.awt.Dimension(600, 81)); @@ -709,10 +894,17 @@ private void initComponents() { jLabel1.setText("neuer Dateiname:"); - lblCancel.setText("Abbrechen"); - lblCancel.addActionListener(new java.awt.event.ActionListener() { + cmdCancel.setText("Abbrechen"); + cmdCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - lblCancelActionPerformed(evt); + cmdCancelActionPerformed(evt); + } + }); + + cmdNameTemplate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N + cmdNameTemplate.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseReleased(java.awt.event.MouseEvent evt) { + cmdNameTemplateMouseReleased(evt); } }); @@ -726,11 +918,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) - .addGap(0, 414, Short.MAX_VALUE)) - .addComponent(txtNewName))) - .addGroup(layout.createSequentialGroup() - .addGap(0, 0, Short.MAX_VALUE) - .addComponent(lblCancel)) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 534, Short.MAX_VALUE) + .addComponent(cmdCancel)) + .addComponent(txtNewName)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cmdNameTemplate)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -739,30 +935,38 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtNewName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lblIcon)) + .addComponent(lblIcon) + .addComponent(cmdNameTemplate)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(lblCancel) + .addComponent(cmdCancel) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents - private void lblCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lblCancelActionPerformed + private void cmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdCancelActionPerformed this.txtNewName.setText(""); - Container dialog=this.findDialog(this); + Container dialog = this.findDialog(this); dialog.setVisible(false); - }//GEN-LAST:event_lblCancelActionPerformed + }//GEN-LAST:event_cmdCancelActionPerformed + + private void cmdNameTemplateMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdNameTemplateMouseReleased + this.popNameTemplates.show(this.cmdNameTemplate, evt.getX(), evt.getY()); + }//GEN-LAST:event_cmdNameTemplateMouseReleased private Container findDialog(Container c) { - while(!(c.getParent() instanceof JDialog) && c.getParent()!=null) - c=c.getParent(); - + while (!(c.getParent() instanceof JDialog) && c.getParent() != null) { + c = c.getParent(); + } + return c.getParent(); } // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton cmdCancel; + private javax.swing.JButton cmdNameTemplate; private javax.swing.JLabel jLabel1; - private javax.swing.JButton lblCancel; private javax.swing.JLabel lblIcon; + private javax.swing.JPopupMenu popNameTemplates; private javax.swing.JTextField txtNewName; // End of variables declaration//GEN-END:variables } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/TemplatesUtil.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/TemplatesUtil.java new file mode 100755 index 000000000..5b0bc411c --- /dev/null +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/TemplatesUtil.java @@ -0,0 +1,767 @@ +/* + * GNU AFFERO GENERAL PUBLIC LICENSE + * Version 3, 19 November 2007 + * + * Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. + * + * Preamble + * + * The GNU Affero General Public License is a free, copyleft license for + * software and other kinds of works, specifically designed to ensure + * cooperation with the community in the case of network server software. + * + * The licenses for most software and other practical works are designed + * to take away your freedom to share and change the works. By contrast, + * our General Public Licenses are intended to guarantee your freedom to + * share and change all versions of a program--to make sure it remains free + * software for all its users. + * + * When we speak of free software, we are referring to freedom, not + * price. Our General Public Licenses are designed to make sure that you + * have the freedom to distribute copies of free software (and charge for + * them if you wish), that you receive source code or can get it if you + * want it, that you can change the software or use pieces of it in new + * free programs, and that you know you can do these things. + * + * Developers that use our General Public Licenses protect your rights + * with two steps: (1) assert copyright on the software, and (2) offer + * you this License which gives you legal permission to copy, distribute + * and/or modify the software. + * + * A secondary benefit of defending all users' freedom is that + * improvements made in alternate versions of the program, if they + * receive widespread use, become available for other developers to + * incorporate. Many developers of free software are heartened and + * encouraged by the resulting cooperation. However, in the case of + * software used on network servers, this result may fail to come about. + * The GNU General Public License permits making a modified version and + * letting the public access it on a server without ever releasing its + * source code to the public. + * + * The GNU Affero General Public License is designed specifically to + * ensure that, in such cases, the modified source code becomes available + * to the community. It requires the operator of a network server to + * provide the source code of the modified version running there to the + * users of that server. Therefore, public use of a modified version, on + * a publicly accessible server, gives the public access to the source + * code of the modified version. + * + * An older license, called the Affero General Public License and + * published by Affero, was designed to accomplish similar goals. This is + * a different license, not a version of the Affero GPL, but Affero has + * released a new version of the Affero GPL which permits relicensing under + * this license. + * + * The precise terms and conditions for copying, distribution and + * modification follow. + * + * TERMS AND CONDITIONS + * + * 0. Definitions. + * + * "This License" refers to version 3 of the GNU Affero General Public License. + * + * "Copyright" also means copyright-like laws that apply to other kinds of + * works, such as semiconductor masks. + * + * "The Program" refers to any copyrightable work licensed under this + * License. Each licensee is addressed as "you". "Licensees" and + * "recipients" may be individuals or organizations. + * + * To "modify" a work means to copy from or adapt all or part of the work + * in a fashion requiring copyright permission, other than the making of an + * exact copy. The resulting work is called a "modified version" of the + * earlier work or a work "based on" the earlier work. + * + * A "covered work" means either the unmodified Program or a work based + * on the Program. + * + * To "propagate" a work means to do anything with it that, without + * permission, would make you directly or secondarily liable for + * infringement under applicable copyright law, except executing it on a + * computer or modifying a private copy. Propagation includes copying, + * distribution (with or without modification), making available to the + * public, and in some countries other activities as well. + * + * To "convey" a work means any kind of propagation that enables other + * parties to make or receive copies. Mere interaction with a user through + * a computer network, with no transfer of a copy, is not conveying. + * + * An interactive user interface displays "Appropriate Legal Notices" + * to the extent that it includes a convenient and prominently visible + * feature that (1) displays an appropriate copyright notice, and (2) + * tells the user that there is no warranty for the work (except to the + * extent that warranties are provided), that licensees may convey the + * work under this License, and how to view a copy of this License. If + * the interface presents a list of user commands or options, such as a + * menu, a prominent item in the list meets this criterion. + * + * 1. Source Code. + * + * The "source code" for a work means the preferred form of the work + * for making modifications to it. "Object code" means any non-source + * form of a work. + * + * A "Standard Interface" means an interface that either is an official + * standard defined by a recognized standards body, or, in the case of + * interfaces specified for a particular programming language, one that + * is widely used among developers working in that language. + * + * The "System Libraries" of an executable work include anything, other + * than the work as a whole, that (a) is included in the normal form of + * packaging a Major Component, but which is not part of that Major + * Component, and (b) serves only to enable use of the work with that + * Major Component, or to implement a Standard Interface for which an + * implementation is available to the public in source code form. A + * "Major Component", in this context, means a major essential component + * (kernel, window system, and so on) of the specific operating system + * (if any) on which the executable work runs, or a compiler used to + * produce the work, or an object code interpreter used to run it. + * + * The "Corresponding Source" for a work in object code form means all + * the source code needed to generate, install, and (for an executable + * work) run the object code and to modify the work, including scripts to + * control those activities. However, it does not include the work's + * System Libraries, or general-purpose tools or generally available free + * programs which are used unmodified in performing those activities but + * which are not part of the work. For example, Corresponding Source + * includes interface definition files associated with source files for + * the work, and the source code for shared libraries and dynamically + * linked subprograms that the work is specifically designed to require, + * such as by intimate data communication or control flow between those + * subprograms and other parts of the work. + * + * The Corresponding Source need not include anything that users + * can regenerate automatically from other parts of the Corresponding + * Source. + * + * The Corresponding Source for a work in source code form is that + * same work. + * + * 2. Basic Permissions. + * + * All rights granted under this License are granted for the term of + * copyright on the Program, and are irrevocable provided the stated + * conditions are met. This License explicitly affirms your unlimited + * permission to run the unmodified Program. The output from running a + * covered work is covered by this License only if the output, given its + * content, constitutes a covered work. This License acknowledges your + * rights of fair use or other equivalent, as provided by copyright law. + * + * You may make, run and propagate covered works that you do not + * convey, without conditions so long as your license otherwise remains + * in force. You may convey covered works to others for the sole purpose + * of having them make modifications exclusively for you, or provide you + * with facilities for running those works, provided that you comply with + * the terms of this License in conveying all material for which you do + * not control copyright. Those thus making or running the covered works + * for you must do so exclusively on your behalf, under your direction + * and control, on terms that prohibit them from making any copies of + * your copyrighted material outside their relationship with you. + * + * Conveying under any other circumstances is permitted solely under + * the conditions stated below. Sublicensing is not allowed; section 10 + * makes it unnecessary. + * + * 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + * + * No covered work shall be deemed part of an effective technological + * measure under any applicable law fulfilling obligations under article + * 11 of the WIPO copyright treaty adopted on 20 December 1996, or + * similar laws prohibiting or restricting circumvention of such + * measures. + * + * When you convey a covered work, you waive any legal power to forbid + * circumvention of technological measures to the extent such circumvention + * is effected by exercising rights under this License with respect to + * the covered work, and you disclaim any intention to limit operation or + * modification of the work as a means of enforcing, against the work's + * users, your or third parties' legal rights to forbid circumvention of + * technological measures. + * + * 4. Conveying Verbatim Copies. + * + * You may convey verbatim copies of the Program's source code as you + * receive it, in any medium, provided that you conspicuously and + * appropriately publish on each copy an appropriate copyright notice; + * keep intact all notices stating that this License and any + * non-permissive terms added in accord with section 7 apply to the code; + * keep intact all notices of the absence of any warranty; and give all + * recipients a copy of this License along with the Program. + * + * You may charge any price or no price for each copy that you convey, + * and you may offer support or warranty protection for a fee. + * + * 5. Conveying Modified Source Versions. + * + * You may convey a work based on the Program, or the modifications to + * produce it from the Program, in the form of source code under the + * terms of section 4, provided that you also meet all of these conditions: + * + * a) The work must carry prominent notices stating that you modified + * it, and giving a relevant date. + * + * b) The work must carry prominent notices stating that it is + * released under this License and any conditions added under section + * 7. This requirement modifies the requirement in section 4 to + * "keep intact all notices". + * + * c) You must license the entire work, as a whole, under this + * License to anyone who comes into possession of a copy. This + * License will therefore apply, along with any applicable section 7 + * additional terms, to the whole of the work, and all its parts, + * regardless of how they are packaged. This License gives no + * permission to license the work in any other way, but it does not + * invalidate such permission if you have separately received it. + * + * d) If the work has interactive user interfaces, each must display + * Appropriate Legal Notices; however, if the Program has interactive + * interfaces that do not display Appropriate Legal Notices, your + * work need not make them do so. + * + * A compilation of a covered work with other separate and independent + * works, which are not by their nature extensions of the covered work, + * and which are not combined with it such as to form a larger program, + * in or on a volume of a storage or distribution medium, is called an + * "aggregate" if the compilation and its resulting copyright are not + * used to limit the access or legal rights of the compilation's users + * beyond what the individual works permit. Inclusion of a covered work + * in an aggregate does not cause this License to apply to the other + * parts of the aggregate. + * + * 6. Conveying Non-Source Forms. + * + * You may convey a covered work in object code form under the terms + * of sections 4 and 5, provided that you also convey the + * machine-readable Corresponding Source under the terms of this License, + * in one of these ways: + * + * a) Convey the object code in, or embodied in, a physical product + * (including a physical distribution medium), accompanied by the + * Corresponding Source fixed on a durable physical medium + * customarily used for software interchange. + * + * b) Convey the object code in, or embodied in, a physical product + * (including a physical distribution medium), accompanied by a + * written offer, valid for at least three years and valid for as + * long as you offer spare parts or customer support for that product + * model, to give anyone who possesses the object code either (1) a + * copy of the Corresponding Source for all the software in the + * product that is covered by this License, on a durable physical + * medium customarily used for software interchange, for a price no + * more than your reasonable cost of physically performing this + * conveying of source, or (2) access to copy the + * Corresponding Source from a network server at no charge. + * + * c) Convey individual copies of the object code with a copy of the + * written offer to provide the Corresponding Source. This + * alternative is allowed only occasionally and noncommercially, and + * only if you received the object code with such an offer, in accord + * with subsection 6b. + * + * d) Convey the object code by offering access from a designated + * place (gratis or for a charge), and offer equivalent access to the + * Corresponding Source in the same way through the same place at no + * further charge. You need not require recipients to copy the + * Corresponding Source along with the object code. If the place to + * copy the object code is a network server, the Corresponding Source + * may be on a different server (operated by you or a third party) + * that supports equivalent copying facilities, provided you maintain + * clear directions next to the object code saying where to find the + * Corresponding Source. Regardless of what server hosts the + * Corresponding Source, you remain obligated to ensure that it is + * available for as long as needed to satisfy these requirements. + * + * e) Convey the object code using peer-to-peer transmission, provided + * you inform other peers where the object code and Corresponding + * Source of the work are being offered to the general public at no + * charge under subsection 6d. + * + * A separable portion of the object code, whose source code is excluded + * from the Corresponding Source as a System Library, need not be + * included in conveying the object code work. + * + * A "User Product" is either (1) a "consumer product", which means any + * tangible personal property which is normally used for personal, family, + * or household purposes, or (2) anything designed or sold for incorporation + * into a dwelling. In determining whether a product is a consumer product, + * doubtful cases shall be resolved in favor of coverage. For a particular + * product received by a particular user, "normally used" refers to a + * typical or common use of that class of product, regardless of the status + * of the particular user or of the way in which the particular user + * actually uses, or expects or is expected to use, the product. A product + * is a consumer product regardless of whether the product has substantial + * commercial, industrial or non-consumer uses, unless such uses represent + * the only significant mode of use of the product. + * + * "Installation Information" for a User Product means any methods, + * procedures, authorization keys, or other information required to install + * and execute modified versions of a covered work in that User Product from + * a modified version of its Corresponding Source. The information must + * suffice to ensure that the continued functioning of the modified object + * code is in no case prevented or interfered with solely because + * modification has been made. + * + * If you convey an object code work under this section in, or with, or + * specifically for use in, a User Product, and the conveying occurs as + * part of a transaction in which the right of possession and use of the + * User Product is transferred to the recipient in perpetuity or for a + * fixed term (regardless of how the transaction is characterized), the + * Corresponding Source conveyed under this section must be accompanied + * by the Installation Information. But this requirement does not apply + * if neither you nor any third party retains the ability to install + * modified object code on the User Product (for example, the work has + * been installed in ROM). + * + * The requirement to provide Installation Information does not include a + * requirement to continue to provide support service, warranty, or updates + * for a work that has been modified or installed by the recipient, or for + * the User Product in which it has been modified or installed. Access to a + * network may be denied when the modification itself materially and + * adversely affects the operation of the network or violates the rules and + * protocols for communication across the network. + * + * Corresponding Source conveyed, and Installation Information provided, + * in accord with this section must be in a format that is publicly + * documented (and with an implementation available to the public in + * source code form), and must require no special password or key for + * unpacking, reading or copying. + * + * 7. Additional Terms. + * + * "Additional permissions" are terms that supplement the terms of this + * License by making exceptions from one or more of its conditions. + * Additional permissions that are applicable to the entire Program shall + * be treated as though they were included in this License, to the extent + * that they are valid under applicable law. If additional permissions + * apply only to part of the Program, that part may be used separately + * under those permissions, but the entire Program remains governed by + * this License without regard to the additional permissions. + * + * When you convey a copy of a covered work, you may at your option + * remove any additional permissions from that copy, or from any part of + * it. (Additional permissions may be written to require their own + * removal in certain cases when you modify the work.) You may place + * additional permissions on material, added by you to a covered work, + * for which you have or can give appropriate copyright permission. + * + * Notwithstanding any other provision of this License, for material you + * add to a covered work, you may (if authorized by the copyright holders of + * that material) supplement the terms of this License with terms: + * + * a) Disclaiming warranty or limiting liability differently from the + * terms of sections 15 and 16 of this License; or + * + * b) Requiring preservation of specified reasonable legal notices or + * author attributions in that material or in the Appropriate Legal + * Notices displayed by works containing it; or + * + * c) Prohibiting misrepresentation of the origin of that material, or + * requiring that modified versions of such material be marked in + * reasonable ways as different from the original version; or + * + * d) Limiting the use for publicity purposes of names of licensors or + * authors of the material; or + * + * e) Declining to grant rights under trademark law for use of some + * trade names, trademarks, or service marks; or + * + * f) Requiring indemnification of licensors and authors of that + * material by anyone who conveys the material (or modified versions of + * it) with contractual assumptions of liability to the recipient, for + * any liability that these contractual assumptions directly impose on + * those licensors and authors. + * + * All other non-permissive additional terms are considered "further + * restrictions" within the meaning of section 10. If the Program as you + * received it, or any part of it, contains a notice stating that it is + * governed by this License along with a term that is a further + * restriction, you may remove that term. If a license document contains + * a further restriction but permits relicensing or conveying under this + * License, you may add to a covered work material governed by the terms + * of that license document, provided that the further restriction does + * not survive such relicensing or conveying. + * + * If you add terms to a covered work in accord with this section, you + * must place, in the relevant source files, a statement of the + * additional terms that apply to those files, or a notice indicating + * where to find the applicable terms. + * + * Additional terms, permissive or non-permissive, may be stated in the + * form of a separately written license, or stated as exceptions; + * the above requirements apply either way. + * + * 8. Termination. + * + * You may not propagate or modify a covered work except as expressly + * provided under this License. Any attempt otherwise to propagate or + * modify it is void, and will automatically terminate your rights under + * this License (including any patent licenses granted under the third + * paragraph of section 11). + * + * However, if you cease all violation of this License, then your + * license from a particular copyright holder is reinstated (a) + * provisionally, unless and until the copyright holder explicitly and + * finally terminates your license, and (b) permanently, if the copyright + * holder fails to notify you of the violation by some reasonable means + * prior to 60 days after the cessation. + * + * Moreover, your license from a particular copyright holder is + * reinstated permanently if the copyright holder notifies you of the + * violation by some reasonable means, this is the first time you have + * received notice of violation of this License (for any work) from that + * copyright holder, and you cure the violation prior to 30 days after + * your receipt of the notice. + * + * Termination of your rights under this section does not terminate the + * licenses of parties who have received copies or rights from you under + * this License. If your rights have been terminated and not permanently + * reinstated, you do not qualify to receive new licenses for the same + * material under section 10. + * + * 9. Acceptance Not Required for Having Copies. + * + * You are not required to accept this License in order to receive or + * run a copy of the Program. Ancillary propagation of a covered work + * occurring solely as a consequence of using peer-to-peer transmission + * to receive a copy likewise does not require acceptance. However, + * nothing other than this License grants you permission to propagate or + * modify any covered work. These actions infringe copyright if you do + * not accept this License. Therefore, by modifying or propagating a + * covered work, you indicate your acceptance of this License to do so. + * + * 10. Automatic Licensing of Downstream Recipients. + * + * Each time you convey a covered work, the recipient automatically + * receives a license from the original licensors, to run, modify and + * propagate that work, subject to this License. You are not responsible + * for enforcing compliance by third parties with this License. + * + * An "entity transaction" is a transaction transferring control of an + * organization, or substantially all assets of one, or subdividing an + * organization, or merging organizations. If propagation of a covered + * work results from an entity transaction, each party to that + * transaction who receives a copy of the work also receives whatever + * licenses to the work the party's predecessor in interest had or could + * give under the previous paragraph, plus a right to possession of the + * Corresponding Source of the work from the predecessor in interest, if + * the predecessor has it or can get it with reasonable efforts. + * + * You may not impose any further restrictions on the exercise of the + * rights granted or affirmed under this License. For example, you may + * not impose a license fee, royalty, or other charge for exercise of + * rights granted under this License, and you may not initiate litigation + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * any patent claim is infringed by making, using, selling, offering for + * sale, or importing the Program or any portion of it. + * + * 11. Patents. + * + * A "contributor" is a copyright holder who authorizes use under this + * License of the Program or a work on which the Program is based. The + * work thus licensed is called the contributor's "contributor version". + * + * A contributor's "essential patent claims" are all patent claims + * owned or controlled by the contributor, whether already acquired or + * hereafter acquired, that would be infringed by some manner, permitted + * by this License, of making, using, or selling its contributor version, + * but do not include claims that would be infringed only as a + * consequence of further modification of the contributor version. For + * purposes of this definition, "control" includes the right to grant + * patent sublicenses in a manner consistent with the requirements of + * this License. + * + * Each contributor grants you a non-exclusive, worldwide, royalty-free + * patent license under the contributor's essential patent claims, to + * make, use, sell, offer for sale, import and otherwise run, modify and + * propagate the contents of its contributor version. + * + * In the following three paragraphs, a "patent license" is any express + * agreement or commitment, however denominated, not to enforce a patent + * (such as an express permission to practice a patent or covenant not to + * sue for patent infringement). To "grant" such a patent license to a + * party means to make such an agreement or commitment not to enforce a + * patent against the party. + * + * If you convey a covered work, knowingly relying on a patent license, + * and the Corresponding Source of the work is not available for anyone + * to copy, free of charge and under the terms of this License, through a + * publicly available network server or other readily accessible means, + * then you must either (1) cause the Corresponding Source to be so + * available, or (2) arrange to deprive yourself of the benefit of the + * patent license for this particular work, or (3) arrange, in a manner + * consistent with the requirements of this License, to extend the patent + * license to downstream recipients. "Knowingly relying" means you have + * actual knowledge that, but for the patent license, your conveying the + * covered work in a country, or your recipient's use of the covered work + * in a country, would infringe one or more identifiable patents in that + * country that you have reason to believe are valid. + * + * If, pursuant to or in connection with a single transaction or + * arrangement, you convey, or propagate by procuring conveyance of, a + * covered work, and grant a patent license to some of the parties + * receiving the covered work authorizing them to use, propagate, modify + * or convey a specific copy of the covered work, then the patent license + * you grant is automatically extended to all recipients of the covered + * work and works based on it. + * + * A patent license is "discriminatory" if it does not include within + * the scope of its coverage, prohibits the exercise of, or is + * conditioned on the non-exercise of one or more of the rights that are + * specifically granted under this License. You may not convey a covered + * work if you are a party to an arrangement with a third party that is + * in the business of distributing software, under which you make payment + * to the third party based on the extent of your activity of conveying + * the work, and under which the third party grants, to any of the + * parties who would receive the covered work from you, a discriminatory + * patent license (a) in connection with copies of the covered work + * conveyed by you (or copies made from those copies), or (b) primarily + * for and in connection with specific products or compilations that + * contain the covered work, unless you entered into that arrangement, + * or that patent license was granted, prior to 28 March 2007. + * + * Nothing in this License shall be construed as excluding or limiting + * any implied license or other defenses to infringement that may + * otherwise be available to you under applicable patent law. + * + * 12. No Surrender of Others' Freedom. + * + * If conditions are imposed on you (whether by court order, agreement or + * otherwise) that contradict the conditions of this License, they do not + * excuse you from the conditions of this License. If you cannot convey a + * covered work so as to satisfy simultaneously your obligations under this + * License and any other pertinent obligations, then as a consequence you may + * not convey it at all. For example, if you agree to terms that obligate you + * to collect a royalty for further conveying from those to whom you convey + * the Program, the only way you could satisfy both those terms and this + * License would be to refrain entirely from conveying the Program. + * + * 13. Remote Network Interaction; Use with the GNU General Public License. + * + * Notwithstanding any other provision of this License, if you modify the + * Program, your modified version must prominently offer all users + * interacting with it remotely through a computer network (if your version + * supports such interaction) an opportunity to receive the Corresponding + * Source of your version by providing access to the Corresponding Source + * from a network server at no charge, through some standard or customary + * means of facilitating copying of software. This Corresponding Source + * shall include the Corresponding Source for any work covered by version 3 + * of the GNU General Public License that is incorporated pursuant to the + * following paragraph. + * + * Notwithstanding any other provision of this License, you have + * permission to link or combine any covered work with a work licensed + * under version 3 of the GNU General Public License into a single + * combined work, and to convey the resulting work. The terms of this + * License will continue to apply to the part which is the covered work, + * but the work with which it is combined will remain governed by version + * 3 of the GNU General Public License. + * + * 14. Revised Versions of this License. + * + * The Free Software Foundation may publish revised and/or new versions of + * the GNU Affero General Public License from time to time. Such new versions + * will be similar in spirit to the present version, but may differ in detail to + * address new problems or concerns. + * + * Each version is given a distinguishing version number. If the + * Program specifies that a certain numbered version of the GNU Affero General + * Public License "or any later version" applies to it, you have the + * option of following the terms and conditions either of that numbered + * version or of any later version published by the Free Software + * Foundation. If the Program does not specify a version number of the + * GNU Affero General Public License, you may choose any version ever published + * by the Free Software Foundation. + * + * If the Program specifies that a proxy can decide which future + * versions of the GNU Affero General Public License can be used, that proxy's + * public statement of acceptance of a version permanently authorizes you + * to choose that version for the Program. + * + * Later license versions may give you additional or different + * permissions. However, no additional obligations are imposed on any + * author or copyright holder as a result of your choosing to follow a + * later version. + * + * 15. Disclaimer of Warranty. + * + * THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY + * APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT + * HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM + * IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF + * ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + * + * 16. Limitation of Liability. + * + * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + * WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS + * THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY + * GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE + * USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF + * DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD + * PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), + * EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGES. + * + * 17. Interpretation of Sections 15 and 16. + * + * If the disclaimer of warranty and limitation of liability provided + * above cannot be given local legal effect according to their terms, + * reviewing courts shall apply local law that most closely approximates + * an absolute waiver of all civil liability in connection with the + * Program, unless a warranty or assumption of liability accompanies a + * copy of the Program in return for a fee. + * + * END OF TERMS AND CONDITIONS + * + * How to Apply These Terms to Your New Programs + * + * If you develop a new program, and you want it to be of the greatest + * possible use to the public, the best way to achieve this is to make it + * free software which everyone can redistribute and change under these terms. + * + * To do so, attach the following notices to the program. It is safest + * to attach them to the start of each source file to most effectively + * state the exclusion of warranty; and each file should have at least + * the "copyright" line and a pointer to where the full notice is found. + * + * <one line to give the program's name and a brief idea of what it does.> + * Copyright (C) <year> <name of author> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + * Also add information on how to contact you by electronic and paper mail. + * + * If your software can interact with users remotely through a computer + * network, you should also make sure that it provides a way for users to + * get its source. For example, if your program is a web application, its + * interface could display a "Source" link that leads users to an archive + * of the code. There are many ways you could offer source, and different + * solutions will be better for different programs; see section 13 for the + * specific requirements. + * + * You should also get your employer (if you work as a programmer) or school, + * if any, to sign a "copyright disclaimer" for the program, if necessary. + * For more information on this, and how to apply and follow the GNU AGPL, see + * <https://www.gnu.org/licenses/>. + */ +package com.jdimension.jlawyer.client.utils; + +import com.jdimension.jlawyer.client.settings.ClientSettings; +import com.jdimension.jlawyer.client.settings.UserSettings; +import com.jdimension.jlawyer.documents.PlaceHolders; +import com.jdimension.jlawyer.persistence.AppUserBean; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; +import com.jdimension.jlawyer.persistence.Invoice; +import com.jdimension.jlawyer.persistence.PartyTypeBean; +import com.jdimension.jlawyer.services.JLawyerServiceLocator; +import com.jdimension.jlawyer.services.PartiesTriplet; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author jens + */ +public class TemplatesUtil { + + private static final Logger log = Logger.getLogger(TemplatesUtil.class.getName()); + + public static ArrayList<String> getPlaceHoldersInTemplate(String templateText, List<String> allPartyTypesPlaceHolders, Collection<String> formPlaceHolders) { + ArrayList<String> result = new ArrayList<>(); + if (templateText == null) { + templateText = ""; + } + for (String r : PlaceHolders.getAllPlaceHolders(allPartyTypesPlaceHolders, formPlaceHolders)) { + if (templateText.contains(r)) { + result.add(r); + } + + } + return result; + } + + public static String replacePlaceHolders(String content, HashMap<String, Object> values) { + for (String key : values.keySet()) { + String keyRegX = "\\{\\{" + key.substring(2, key.length() - 2) + "\\}\\}"; + String value = (String) values.get(key); + if (value == null) { + value = ""; + } + + content = content.replaceAll(keyRegX, value); + } + + return content; + } + + public static HashMap<String, Object> getPlaceHolderValues(String content, ArchiveFileBean contextArchiveFile, List<PartiesTriplet> partiesTriplets, Invoice invoice, List<PartyTypeBean> allPartyTypes, Collection<String> formPlaceHolders, HashMap<String, String> formPlaceHolderValues, AppUserBean caseLawyer, AppUserBean caseAssistant) { + try { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + + if(allPartyTypes==null) { + allPartyTypes = locator.lookupSystemManagementRemote().getPartyTypes(); + } + List<String> allPartyTypesPlaceholders = new ArrayList<>(); + for (PartyTypeBean ptb : allPartyTypes) { + allPartyTypesPlaceholders.add(ptb.getPlaceHolder()); + } + + if(formPlaceHolders==null && contextArchiveFile != null) { + formPlaceHolders = locator.lookupFormsServiceRemote().getPlaceHoldersForCase(contextArchiveFile.getId()); + } + if(formPlaceHolderValues==null && contextArchiveFile != null) { + formPlaceHolderValues = locator.lookupFormsServiceRemote().getPlaceHolderValuesForCase(contextArchiveFile.getId()); + } + + ArrayList<String> placeHolderNames = getPlaceHoldersInTemplate(content, allPartyTypesPlaceholders, formPlaceHolders); + HashMap<String, Object> ht = new HashMap<>(); + for (String ph : placeHolderNames) { + ht.put(ph, ""); + } + + AppUserBean author = UserSettings.getInstance().getCurrentUser(); + if (contextArchiveFile != null) { + try { + if(caseLawyer==null && !StringUtils.isEmpty(contextArchiveFile.getLawyer())) + caseLawyer = locator.lookupSystemManagementRemote().getUser(contextArchiveFile.getLawyer()); + } catch (Exception ex) { + log.warn("Unable to load lawyer with id " + contextArchiveFile.getLawyer()); + } + try { + if(caseAssistant==null && !StringUtils.isEmpty(contextArchiveFile.getAssistant())) + caseAssistant = locator.lookupSystemManagementRemote().getUser(contextArchiveFile.getAssistant()); + } catch (Exception ex) { + log.warn("Unable to load assistant with id " + contextArchiveFile.getAssistant()); + } + } + + return locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, contextArchiveFile, partiesTriplets, "", null, formPlaceHolderValues, caseLawyer, caseAssistant, author, invoice, null, null, null); + + } catch (Exception ex) { + log.error("Error getting placeholder values", ex); + return new HashMap<>(); + } + } + +} diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/EpostLetterSendStatus.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/EpostLetterSendStatus.java index d22967b28..35824cbac 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/EpostLetterSendStatus.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/EpostLetterSendStatus.java @@ -670,6 +670,7 @@ import com.jdimension.jlawyer.client.utils.StringUtils; import com.jdimension.jlawyer.client.wizard.*; import com.jdimension.jlawyer.epost.EpostLetter; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean; import com.jdimension.jlawyer.persistence.ArchiveFileHistoryBean; import com.jdimension.jlawyer.services.ArchiveFileServiceRemote; @@ -882,6 +883,8 @@ public void display() { try { + ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote(); + ArchiveFileBean selectedCase=afs.getArchiveFile(this.data.get("epost.letter.caseid").toString()); String newName = "E-POST-Brief_" + l.getFileName(); if (newName.length() > 228) { @@ -889,7 +892,7 @@ public void display() { } newName = FileUtils.sanitizeFileName(newName); java.util.Date sentPrefix = new Date(); - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this, "Datei benennen"); + newName = FileUtils.getNewFileName(selectedCase, newName, true, sentPrefix, true, this, "Datei benennen"); if (newName != null) { if (newName.trim().length() == 0) { newName = "E-POST-Brief"; @@ -898,11 +901,10 @@ public void display() { if (!newName.toLowerCase().endsWith(".pdf")) { newName = newName + ".pdf"; } - ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote(); boolean documentExists = afs.doesDocumentExist(this.data.get("epost.letter.caseid").toString(), newName); while (documentExists) { - newName = FileUtils.getNewFileName(newName, true, sentPrefix, this, "Datei benennen"); + newName = FileUtils.getNewFileName(selectedCase, newName, true, sentPrefix, true, this, "Datei benennen"); if (newName == null || "".equals(newName)) { break; } @@ -912,7 +914,7 @@ public void display() { } if (newName != null) { - ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote(); + ArchiveFileDocumentsBean newDoc = afs.addDocument(this.data.get("epost.letter.caseid").toString(), newName, (byte[]) this.data.get("pdf.bytes"), "", null); ArchiveFileHistoryBean historyDto = new ArchiveFileHistoryBean(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/MailingStatusPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/MailingStatusPanel.java index 7098cccd8..23fbca6b3 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/MailingStatusPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/voip/MailingStatusPanel.java @@ -1259,7 +1259,7 @@ private void cmdSaveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN for (String id : faxEntriesIds) { String defaultName = locator.lookupVoipServiceRemote().getNewFaxReportFileName(id); - defaultName = FileUtils.getNewFileName(defaultName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für Faxbericht"); + defaultName = FileUtils.getNewFileName(faxEntries.get(id).getCase(), defaultName, false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für Faxbericht"); if(defaultName==null) { this.clearDetails(); return; @@ -1267,7 +1267,7 @@ private void cmdSaveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN boolean documentExists = locator.lookupArchiveFileServiceRemote().doesDocumentExist(faxEntries.get(id).getCase().getId(), defaultName); while (documentExists) { - defaultName = FileUtils.getNewFileName(defaultName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für Faxbericht"); + defaultName = FileUtils.getNewFileName(faxEntries.get(id).getCase(), defaultName, false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für Faxbericht"); if (defaultName == null || "".equals(defaultName)) { this.clearDetails(); return; @@ -1280,7 +1280,7 @@ private void cmdSaveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN for (int id : epostEntriesIds) { String defaultName = locator.lookupVoipServiceRemote().getNewEpostReportFileName(id); - defaultName = FileUtils.getNewFileName(defaultName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für E-POST-Bericht"); + defaultName = FileUtils.getNewFileName(epostEntries.get(id).getCase(), defaultName, false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für E-POST-Bericht"); if(defaultName==null) { this.clearDetails(); return; @@ -1288,7 +1288,7 @@ private void cmdSaveReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN boolean documentExists = locator.lookupArchiveFileServiceRemote().doesDocumentExist(epostEntries.get(id).getCase().getId(), defaultName); while (documentExists) { - defaultName = FileUtils.getNewFileName(defaultName, false, new Date(), EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für E-POST-Bericht"); + defaultName = FileUtils.getNewFileName(epostEntries.get(id).getCase(), defaultName, false, new Date(), true, EditorsRegistry.getInstance().getMainWindow(), "Neuer Name für E-POST-Bericht"); if (defaultName == null || "".equals(defaultName)) { this.clearDetails(); return; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.form index c0acbf74a..94b96841a 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.form @@ -180,14 +180,12 @@ <Group type="102" alignment="0" attributes="0"> <Group type="103" groupAlignment="1" max="-2" attributes="0"> <Component id="cmdSelectAll1" alignment="0" max="32767" attributes="0"/> - <Group type="103" alignment="0" groupAlignment="0" max="-2" attributes="0"> - <Component id="cmdActions" max="32767" attributes="0"/> - <Group type="103" groupAlignment="3" attributes="0"> - <Component id="sortChangeDate" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="cmdMoveToFolder" alignment="3" min="-2" max="-2" attributes="0"/> - </Group> - <Component id="cmdSelectNone1" alignment="0" max="32767" attributes="0"/> + <Component id="cmdActions" alignment="0" max="32767" attributes="0"/> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="sortChangeDate" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="cmdMoveToFolder" alignment="3" min="-2" max="-2" attributes="0"/> </Group> + <Component id="cmdSelectNone1" alignment="0" max="32767" attributes="0"/> <Group type="103" alignment="0" groupAlignment="3" attributes="0"> <Component id="sortFolder" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="sortName" alignment="3" min="-2" max="-2" attributes="0"/> diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.java index aa4c4d9e1..2b496276a 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/CaseFolderPanel.java @@ -673,6 +673,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.client.settings.UserSettings; import com.jdimension.jlawyer.client.utils.FileUtils; import com.jdimension.jlawyer.client.utils.StringUtils; +import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean; import com.jdimension.jlawyer.persistence.CaseFolder; import com.jdimension.jlawyer.persistence.CaseFolderSettings; @@ -727,7 +728,7 @@ public class CaseFolderPanel extends javax.swing.JPanel implements EventConsumer private HashMap<String,Invoice> linkedInvoices=new HashMap<>(); private ArchiveFilePanel caseContainer = null; private JPopupMenu documentsPopup = null; - private String caseId = null; + private ArchiveFileBean selectedCase = null; /** * Creates new form CaseFolderPanel @@ -764,13 +765,17 @@ public CaseFolderPanel(boolean readonly) { b.subscribeConsumer(this, Event.TYPE_DOCUMENTLOCK); } + + public FoldersListPanel getFoldersListPanel() { + return this.foldersListPanel; + } - public String getCaseId() { - return this.caseId; + public ArchiveFileBean getCase() { + return this.selectedCase; } - public void setCaseId(String caseId) { - this.caseId = caseId; + public void setCase(ArchiveFileBean afb) { + this.selectedCase = afb; } public CaseFolderPanel() { diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FolderListCell.java b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FolderListCell.java index b63d110a5..56495aaa7 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FolderListCell.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FolderListCell.java @@ -1123,7 +1123,7 @@ public void drop(DropTargetDropEvent dtde) { dtde.rejectDrop(); } - if (this.parent.getCaseFolderPanel().getCaseId() == null) { + if (this.parent.getCaseFolderPanel().getCase() == null) { dtde.rejectDrop(); } @@ -1150,7 +1150,7 @@ public void drop(DropTargetDropEvent dtde) { ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true); pi.setShowCancelButton(true); - UploadDocumentsAction a = new UploadDocumentsAction(pi, EditorsRegistry.getInstance().getMainEditorsPane(), this.parent.getCaseFolderPanel().getCaseId(), this.parent.getCaseFolderPanel(), files, this.folder, null); + UploadDocumentsAction a = new UploadDocumentsAction(pi, EditorsRegistry.getInstance().getMainEditorsPane(), this.parent.getCaseFolderPanel().getCase(), this.parent.getCaseFolderPanel(), files, this.folder, null); a.start(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FoldersListPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FoldersListPanel.java index 6166dad61..802884e03 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FoldersListPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/FoldersListPanel.java @@ -862,7 +862,7 @@ public void folderRemoved(CaseFolder parent, CaseFolder removedFolder) { parent.getChildren().remove(removedFolder); // need to rebuild the popup menu with all the folders - this.caseFolderPanel.setRootFolder(this.rootFolder, this.getUnselectedFolderIds()); + this.caseFolderPanel.setRootFolder(this.getRootFolder(), this.getUnselectedFolderIds()); this.revalidate(); this.repaint(); @@ -881,7 +881,7 @@ private void collectSubtreeIds(CaseFolder f, ArrayList<String> ids) { public String getFolderPath(String folderId) { HashMap<String,String> folderPaths=new HashMap<>(); - this.collectFolderPaths(folderPaths, this.rootFolder, ""); + this.collectFolderPaths(folderPaths, this.getRootFolder(), ""); if(folderPaths.containsKey(folderId)) { return folderPaths.get(folderId); } else { @@ -908,7 +908,7 @@ private void collectFolderPaths(HashMap<String,String> items, CaseFolder folder, public void folderAdded(CaseFolder parent, CaseFolder newFolder) { parent.getChildren().add(newFolder); - this.caseFolderPanel.setRootFolder(this.rootFolder, this.getUnselectedFolderIds()); + this.caseFolderPanel.setRootFolder(this.getRootFolder(), this.getUnselectedFolderIds()); this.revalidate(); this.repaint(); this.forceRelayout(); @@ -984,4 +984,11 @@ void folderUpdated(CaseFolder folder) { this.caseFolderPanel.updateDocumentsInFolder(folder); this.forceRelayout(); } + + /** + * @return the rootFolder + */ + public CaseFolder getRootFolder() { + return rootFolder; + } } diff --git a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/ArchiveFileServiceRemote.java b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/ArchiveFileServiceRemote.java index 32f42054b..b884d272d 100644 --- a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/ArchiveFileServiceRemote.java +++ b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/ArchiveFileServiceRemote.java @@ -717,6 +717,8 @@ public interface ArchiveFileServiceRemote { byte[] getDocumentContent(String id) throws Exception; + String getNewDocumentName(String fileName, Date date, DocumentNameTemplate tpl) throws Exception; + ArchiveFileDocumentsBean getDocument(String id) throws Exception; Collection<ArchiveFileAddressesBean> getArchiveFileAddressesForAddress(String adressId); diff --git a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/SystemManagementRemote.java b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/SystemManagementRemote.java index 563e8094b..c1871cae4 100644 --- a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/SystemManagementRemote.java +++ b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/SystemManagementRemote.java @@ -820,4 +820,18 @@ public interface SystemManagementRemote { AssistantConfig updateAssistant(AssistantConfig assistant) throws Exception; + DocumentNameTemplate addDocumentNameTemplate(DocumentNameTemplate template) throws Exception; + + DocumentNameTemplate updateDocumentNameTemplate(DocumentNameTemplate template) throws Exception; + + void removeDocumentNameTemplate(DocumentNameTemplate template) throws Exception; + + List<DocumentNameTemplate> getDocumentNameTemplates() throws Exception; + + DocumentNameTemplate getDefaultDocumentNameTemplate() throws Exception; + + List<String> previewDocumentNamesForTemplate(DocumentNameTemplate template, String fileName) throws Exception; + + DocumentNameTemplate getDocumentNameTemplate(String templateId) throws Exception; + } diff --git a/j-lawyer-server-common/src/com/jdimension/jlawyer/documents/PlaceHolders.java b/j-lawyer-server-common/src/com/jdimension/jlawyer/documents/PlaceHolders.java index d8a24acc5..05c5aa5d3 100755 --- a/j-lawyer-server-common/src/com/jdimension/jlawyer/documents/PlaceHolders.java +++ b/j-lawyer-server-common/src/com/jdimension/jlawyer/documents/PlaceHolders.java @@ -835,7 +835,8 @@ public static ArrayList<String> getAllPlaceHolders(List<String> allPartyTypesPla ArrayList<String> ALLPLACEHOLDERS = new ArrayList<>(); - ALLPLACEHOLDERS.addAll(formsPlaceHolders); + if(formsPlaceHolders!=null) + ALLPLACEHOLDERS.addAll(formsPlaceHolders); ALLPLACEHOLDERS.add(PROFIL_FIRMA); ALLPLACEHOLDERS.add(PROFIL_STRASSE); diff --git a/j-lawyer-server-common/src/com/jdimension/jlawyer/server/services/settings/UserSettingsKeys.java b/j-lawyer-server-common/src/com/jdimension/jlawyer/server/services/settings/UserSettingsKeys.java index 54af60f5c..72308e8df 100644 --- a/j-lawyer-server-common/src/com/jdimension/jlawyer/server/services/settings/UserSettingsKeys.java +++ b/j-lawyer-server-common/src/com/jdimension/jlawyer/server/services/settings/UserSettingsKeys.java @@ -733,6 +733,7 @@ public class UserSettingsKeys { // for new bulk save dialog public static final String CONF_BULKSAVE_LASTCASETAGS_PREFIX="user.bulksave.lastcasetags."; public static final String CONF_BULKSAVE_LASTDOCTAGS_PREFIX="user.bulksave.lastdoctags."; + public static final String CONF_BULKSAVE_LASTNAMETEMPLATE_PREFIX="user.bulksave.lastnametpl."; // invoice related public static final String INVOICE_LASTUSEDCURRENCY="invoice.currency.lastused"; diff --git a/j-lawyer-server-common/src/com/jdimension/jlawyer/server/utils/ServerFileUtils.java b/j-lawyer-server-common/src/com/jdimension/jlawyer/server/utils/ServerFileUtils.java index 552eba2e7..d036fff96 100755 --- a/j-lawyer-server-common/src/com/jdimension/jlawyer/server/utils/ServerFileUtils.java +++ b/j-lawyer-server-common/src/com/jdimension/jlawyer/server/utils/ServerFileUtils.java @@ -699,6 +699,14 @@ protected ServerFileUtils() { } + public static String getExtension(String fileName) { + int index = fileName.lastIndexOf('.'); + if (index > -1 && index < fileName.length()) { + return fileName.substring(index + 1); + } + return "url-with-no-extension"; + } + public static String sanitizeFileName(String fileName) { String name = fileName; name = name.replace(",", " "); diff --git a/j-lawyer-server-entities/src/conf/persistence.xml b/j-lawyer-server-entities/src/conf/persistence.xml index ecce25dc4..02daab676 100644 --- a/j-lawyer-server-entities/src/conf/persistence.xml +++ b/j-lawyer-server-entities/src/conf/persistence.xml @@ -62,6 +62,7 @@ <class>com.jdimension.jlawyer.persistence.AssistantPrompt</class> <class>com.jdimension.jlawyer.persistence.TimesheetAllowedPositionTpl</class> <class>com.jdimension.jlawyer.persistence.CalendarEntryTemplate</class> + <class>com.jdimension.jlawyer.persistence.DocumentNameTemplate</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <!-- changed from update to validate to avoid deployment during an update installer run to create columns that will be added by a sql script later in the process --> diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/CaseFolder.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/CaseFolder.java index 7d687b6c5..e7490532c 100644 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/CaseFolder.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/CaseFolder.java @@ -781,6 +781,16 @@ private void collectFolderIds(CaseFolder f, List<String> idList) { } } + public CaseFolder getChild(String name) { + if(this.children!=null) { + for(CaseFolder c: this.children) { + if(c.getName().equalsIgnoreCase(name)) + return c; + } + } + return null; + } + public boolean hasChild(String name) { if(this.children!=null) { for(CaseFolder c: this.children) { diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplate.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplate.java new file mode 100644 index 000000000..01f3956ea --- /dev/null +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplate.java @@ -0,0 +1,779 @@ +/* GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<https://www.gnu.org/licenses/>. + */ +package com.jdimension.jlawyer.persistence; + +import java.io.Serializable; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author jens + */ +@Entity +@Table(name = "document_name_tpls") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "DocumentNameTemplate.findAll", query = "SELECT t FROM DocumentNameTemplate t"), + @NamedQuery(name = "DocumentNameTemplate.findDefault", query = "SELECT t FROM DocumentNameTemplate t where t.defaultTemplate = 1"), + @NamedQuery(name = "DocumentNameTemplate.findById", query = "SELECT t FROM DocumentNameTemplate t WHERE t.id = :id")}) +public class DocumentNameTemplate implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @Column(name = "id") + private String id; + + @Column(name = "display_name") + private String displayName; + + @Column(name = "schema_syntax") + private String pattern; + + @Column(name = "default_tpl") + private boolean defaultTemplate=true; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof DocumentNameTemplate)) { + return false; + } + DocumentNameTemplate other = (DocumentNameTemplate) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return this.getDisplayName(); + } + + /** + * @return the displayName + */ + public String getDisplayName() { + return displayName; + } + + /** + * @param displayName the displayName to set + */ + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * @return the pattern + */ + public String getPattern() { + return pattern; + } + + /** + * @param pattern the pattern to set + */ + public void setPattern(String pattern) { + this.pattern = pattern; + } + + /** + * @return the defaultTemplate + */ + public boolean isDefaultTemplate() { + return defaultTemplate; + } + + /** + * @param defaultTemplate the defaultTemplate to set + */ + public void setDefaultTemplate(boolean defaultTemplate) { + this.defaultTemplate = defaultTemplate; + } + +} diff --git a/j-lawyer-server-entities/src/java/db/migration/V2_7_0_8__AddDocumentNameTpls.sql b/j-lawyer-server-entities/src/java/db/migration/V2_7_0_8__AddDocumentNameTpls.sql new file mode 100644 index 000000000..44a18f05d --- /dev/null +++ b/j-lawyer-server-entities/src/java/db/migration/V2_7_0_8__AddDocumentNameTpls.sql @@ -0,0 +1,12 @@ +CREATE TABLE document_name_tpls ( +`id` VARCHAR(50) BINARY NOT NULL, +`display_name` VARCHAR(250) BINARY NOT NULL, +`schema_syntax` VARCHAR(250) BINARY NOT NULL, +`default_tpl` BIT(1) DEFAULT 0, +CONSTRAINT `pk_document_name_tpls` PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +insert into document_name_tpls (id, display_name, schema_syntax, default_tpl) values ('default-tpl','Standard','yyyy-mm-dd_DATEINAME',1); + +insert into server_settings(settingKey, settingValue) values('jlawyer.server.database.version','2.7.0.8') ON DUPLICATE KEY UPDATE settingValue = '2.7.0.8'; +commit; \ No newline at end of file diff --git a/j-lawyer-server-entities/src/java/db/migration/V2_7_0_9__AddDocumentNameTpls.sql b/j-lawyer-server-entities/src/java/db/migration/V2_7_0_9__AddDocumentNameTpls.sql new file mode 100644 index 000000000..4930383ad --- /dev/null +++ b/j-lawyer-server-entities/src/java/db/migration/V2_7_0_9__AddDocumentNameTpls.sql @@ -0,0 +1,4 @@ +insert into document_name_tpls (id, display_name, schema_syntax, default_tpl) values ('dateiname-tpl','ursprünglicher Name','DATEINAME',0); + +insert into server_settings(settingKey, settingValue) values('jlawyer.server.database.version','2.7.0.9') ON DUPLICATE KEY UPDATE settingValue = '2.7.0.9'; +commit; \ No newline at end of file diff --git a/j-lawyer-server/j-lawyer-server-ejb/nbproject/project.properties b/j-lawyer-server/j-lawyer-server-ejb/nbproject/project.properties index 19174b417..b8ca11034 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/nbproject/project.properties +++ b/j-lawyer-server/j-lawyer-server-ejb/nbproject/project.properties @@ -22,7 +22,7 @@ file.reference.poi-excelant-4.1.2.jar=lib/poi/poi-excelant-4.1.2.jar file.reference.poi-ooxml-4.1.2.jar=lib/poi/poi-ooxml-4.1.2.jar file.reference.poi-ooxml-schemas-4.1.2.jar=lib/poi/poi-ooxml-schemas-4.1.2.jar file.reference.poi-scratchpad-4.1.2.jar=lib/poi/poi-scratchpad-4.1.2.jar -j2ee.platform.classpath=${j2ee.server.home}/modules/system/layers/base/javax/activation/api/main/jakarta.activation-1.2.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/annotation/api/main/jboss-annotations-api_1.3_spec-2.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/batch/api/main/jboss-batch-api_1.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/ejb/api/main/jboss-ejb-api_3.2_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/el/api/main/jboss-el-api_3.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/enterprise/api/main/jakarta.enterprise.cdi-api-2.0.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/enterprise/concurrent/api/main/jboss-concurrency-api_1.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/faces/api/main/jboss-jsf-api_2.3_spec-3.1.0.SP01.jar:${j2ee.server.home}/modules/system/layers/base/javax/inject/api/main/jakarta.inject-api-1.0.5.jar:${j2ee.server.home}/modules/system/layers/base/javax/interceptor/api/main/jboss-interceptors-api_1.2_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/jms/api/main/jboss-jms-api_2.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/json/api/main/jakarta.json-api-1.1.6.jar:${j2ee.server.home}/modules/system/layers/base/javax/json/bind/api/main/jakarta.json.bind-api-1.0.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/jws/api/main/jsr181-api-1.0-MR1.jar:${j2ee.server.home}/modules/system/layers/base/javax/mail/api/main/jakarta.mail-1.6.7.jar:${j2ee.server.home}/modules/system/layers/base/javax/management/j2ee/api/main/jboss-j2eemgmt-api_1.1_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/orb/api/main/openjdk-orb-8.1.7.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/persistence/api/main/jakarta.persistence-api-2.2.3.jar:${j2ee.server.home}/modules/system/layers/base/javax/resource/api/main/jboss-connector-api_1.7_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/auth/message/api/main/jboss-jaspi-api_1.1_spec-2.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/enterprise/api/main/jakarta.security.enterprise-api-1.0.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/jacc/api/main/jboss-jacc-api_1.5_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/api/main/jboss-servlet-api_4.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jsp/api/main/jboss-jsp-api_2.3_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-compat-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-impl-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-spec-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/transaction/api/main/jboss-transaction-api_1.3_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/validation/api/main/jakarta.validation-api-2.0.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/websocket/api/main/jboss-websocket-api_1.1_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/ws/rs/api/main/jboss-jaxrs-api_2.1_spec-2.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/wsdl4j/api/main/wsdl4j-1.6.3.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/bind/api/main/jboss-jaxb-api_2.3_spec-2.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/rpc/api/main/jboss-jaxrpc-api_1.1_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/soap/api/main/jboss-saaj-api_1.4_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/ws/api/main/jboss-jaxws-api_2.3_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/org/glassfish/javax/enterprise/concurrent/main/jakarta.enterprise.concurrent-1.1.1.jar +j2ee.platform.classpath=${j2ee.server.home}/modules/system/layers/base/javax/activation/api/main/activation-1.1.1.jar:${j2ee.server.home}/modules/system/layers/base/javax/annotation/api/main/jboss-annotations-api_1.3_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/batch/api/main/jboss-batch-api_1.0_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/ejb/api/main/jboss-ejb-api_3.2_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/el/api/main/jboss-el-api_3.0_spec-1.0.13.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/enterprise/api/main/cdi-api-2.0.SP1.jar:${j2ee.server.home}/modules/system/layers/base/javax/enterprise/concurrent/api/main/jboss-concurrency-api_1.0_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/faces/api/main/jboss-jsf-api_2.3_spec-2.3.9.SP01.jar:${j2ee.server.home}/modules/system/layers/base/javax/inject/api/main/javax.inject-1.jar:${j2ee.server.home}/modules/system/layers/base/javax/interceptor/api/main/jboss-interceptors-api_1.2_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/jms/api/main/jboss-jms-api_2.0_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/json/api/main/javax.json-api-1.1.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/json/bind/api/main/javax.json.bind-api-1.0.jar:${j2ee.server.home}/modules/system/layers/base/javax/jws/api/main/jsr181-api-1.0-MR1.jar:${j2ee.server.home}/modules/system/layers/base/javax/mail/api/main/javax.mail-1.6.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/management/j2ee/api/main/jboss-j2eemgmt-api_1.1_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/orb/api/main/openjdk-orb-8.1.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/persistence/api/main/javax.persistence-api-2.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/resource/api/main/jboss-connector-api_1.7_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/auth/message/api/main/jboss-jaspi-api_1.1_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/enterprise/api/main/javax.security.enterprise-api-1.0.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/jacc/api/main/jboss-jacc-api_1.5_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/api/main/jboss-servlet-api_4.0_spec-1.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jsp/api/main/jboss-jsp-api_2.3_spec-1.0.3.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-compat-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-impl-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-spec-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/transaction/api/main/jboss-transaction-api_1.2_spec-1.1.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/validation/api/main/validation-api-2.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/websocket/api/main/jboss-websocket-api_1.1_spec-1.1.3.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/ws/rs/api/main/jboss-jaxrs-api_2.1_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/wsdl4j/api/main/wsdl4j-1.6.3.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/bind/api/main/jboss-jaxb-api_2.3_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/rpc/api/main/jboss-jaxrpc-api_1.1_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/soap/api/main/jboss-saaj-api_1.3_spec-1.0.6.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/ws/api/main/jboss-jaxws-api_2.3_spec-1.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/org/glassfish/javax/el/main/javax.el-impl-3.0.1-b08-jbossorg-1.jar:${j2ee.server.home}/modules/system/layers/base/org/glassfish/javax/enterprise/concurrent/main/javax.enterprise.concurrent-1.0.jar:${j2ee.server.home}/modules/system/layers/base/org/glassfish/javax/json/main/javax.json-1.1.2.jar javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir}:\ diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/conf/persistence.xml b/j-lawyer-server/j-lawyer-server-ejb/src/conf/persistence.xml index d691830c4..afeec02da 100755 --- a/j-lawyer-server/j-lawyer-server-ejb/src/conf/persistence.xml +++ b/j-lawyer-server/j-lawyer-server-ejb/src/conf/persistence.xml @@ -62,6 +62,7 @@ <class>com.jdimension.jlawyer.persistence.AssistantPrompt</class> <class>com.jdimension.jlawyer.persistence.TimesheetAllowedPositionTpl</class> <class>com.jdimension.jlawyer.persistence.CalendarEntryTemplate</class> + <class>com.jdimension.jlawyer.persistence.DocumentNameTemplate</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <!-- changed from update to validate to avoid deployment during an update installer run to create columns that will be added by a sql script later in the process --> diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplateFacade.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplateFacade.java new file mode 100644 index 000000000..5728ba2f0 --- /dev/null +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplateFacade.java @@ -0,0 +1,704 @@ +/* + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<https://www.gnu.org/licenses/>. + */ +package com.jdimension.jlawyer.persistence; + +import java.util.List; +import javax.ejb.Stateless; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +/** + * + * @author jens + */ +@Stateless +public class DocumentNameTemplateFacade extends AbstractFacade<DocumentNameTemplate> implements DocumentNameTemplateFacadeLocal { + + @PersistenceContext(unitName = "j-lawyer-server-ejbPU") + private EntityManager em; + + @Override + protected EntityManager getEntityManager() { + return em; + } + + public DocumentNameTemplateFacade() { + super(DocumentNameTemplate.class); + } + + @Override + public DocumentNameTemplate findDefault() { + + List<DocumentNameTemplate> defaultTemplates=(List<DocumentNameTemplate>) em.createNamedQuery("DocumentNameTemplate.findDefault").getResultList(); + if(defaultTemplates.isEmpty()) { + // no default - use first + return findAll().get(0); + } else { + // there is only one default expected + return defaultTemplates.get(0); + } + + } + +} diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplateFacadeLocal.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplateFacadeLocal.java new file mode 100644 index 000000000..18a55cf94 --- /dev/null +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/DocumentNameTemplateFacadeLocal.java @@ -0,0 +1,692 @@ +/* + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<https://www.gnu.org/licenses/>. + */ +package com.jdimension.jlawyer.persistence; + +import java.util.List; +import javax.ejb.Local; + +/** + * + * @author jens + */ +@Local +public interface DocumentNameTemplateFacadeLocal { + + void create(DocumentNameTemplate documentNameTemplate); + + void edit(DocumentNameTemplate documentNameTemplate); + + void remove(DocumentNameTemplate documentNameTemplate); + + DocumentNameTemplate find(Object id); + + List<DocumentNameTemplate> findAll(); + + List<DocumentNameTemplate> findRange(int[] range); + + int count(); + + DocumentNameTemplate findDefault(); + +} diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/server/utils/FileNameGenerator.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/server/utils/FileNameGenerator.java new file mode 100644 index 000000000..ae4046f9d --- /dev/null +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/server/utils/FileNameGenerator.java @@ -0,0 +1,768 @@ +/* + * GNU AFFERO GENERAL PUBLIC LICENSE + * Version 3, 19 November 2007 + * + * Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. + * + * Preamble + * + * The GNU Affero General Public License is a free, copyleft license for + * software and other kinds of works, specifically designed to ensure + * cooperation with the community in the case of network server software. + * + * The licenses for most software and other practical works are designed + * to take away your freedom to share and change the works. By contrast, + * our General Public Licenses are intended to guarantee your freedom to + * share and change all versions of a program--to make sure it remains free + * software for all its users. + * + * When we speak of free software, we are referring to freedom, not + * price. Our General Public Licenses are designed to make sure that you + * have the freedom to distribute copies of free software (and charge for + * them if you wish), that you receive source code or can get it if you + * want it, that you can change the software or use pieces of it in new + * free programs, and that you know you can do these things. + * + * Developers that use our General Public Licenses protect your rights + * with two steps: (1) assert copyright on the software, and (2) offer + * you this License which gives you legal permission to copy, distribute + * and/or modify the software. + * + * A secondary benefit of defending all users' freedom is that + * improvements made in alternate versions of the program, if they + * receive widespread use, become available for other developers to + * incorporate. Many developers of free software are heartened and + * encouraged by the resulting cooperation. However, in the case of + * software used on network servers, this result may fail to come about. + * The GNU General Public License permits making a modified version and + * letting the public access it on a server without ever releasing its + * source code to the public. + * + * The GNU Affero General Public License is designed specifically to + * ensure that, in such cases, the modified source code becomes available + * to the community. It requires the operator of a network server to + * provide the source code of the modified version running there to the + * users of that server. Therefore, public use of a modified version, on + * a publicly accessible server, gives the public access to the source + * code of the modified version. + * + * An older license, called the Affero General Public License and + * published by Affero, was designed to accomplish similar goals. This is + * a different license, not a version of the Affero GPL, but Affero has + * released a new version of the Affero GPL which permits relicensing under + * this license. + * + * The precise terms and conditions for copying, distribution and + * modification follow. + * + * TERMS AND CONDITIONS + * + * 0. Definitions. + * + * "This License" refers to version 3 of the GNU Affero General Public License. + * + * "Copyright" also means copyright-like laws that apply to other kinds of + * works, such as semiconductor masks. + * + * "The Program" refers to any copyrightable work licensed under this + * License. Each licensee is addressed as "you". "Licensees" and + * "recipients" may be individuals or organizations. + * + * To "modify" a work means to copy from or adapt all or part of the work + * in a fashion requiring copyright permission, other than the making of an + * exact copy. The resulting work is called a "modified version" of the + * earlier work or a work "based on" the earlier work. + * + * A "covered work" means either the unmodified Program or a work based + * on the Program. + * + * To "propagate" a work means to do anything with it that, without + * permission, would make you directly or secondarily liable for + * infringement under applicable copyright law, except executing it on a + * computer or modifying a private copy. Propagation includes copying, + * distribution (with or without modification), making available to the + * public, and in some countries other activities as well. + * + * To "convey" a work means any kind of propagation that enables other + * parties to make or receive copies. Mere interaction with a user through + * a computer network, with no transfer of a copy, is not conveying. + * + * An interactive user interface displays "Appropriate Legal Notices" + * to the extent that it includes a convenient and prominently visible + * feature that (1) displays an appropriate copyright notice, and (2) + * tells the user that there is no warranty for the work (except to the + * extent that warranties are provided), that licensees may convey the + * work under this License, and how to view a copy of this License. If + * the interface presents a list of user commands or options, such as a + * menu, a prominent item in the list meets this criterion. + * + * 1. Source Code. + * + * The "source code" for a work means the preferred form of the work + * for making modifications to it. "Object code" means any non-source + * form of a work. + * + * A "Standard Interface" means an interface that either is an official + * standard defined by a recognized standards body, or, in the case of + * interfaces specified for a particular programming language, one that + * is widely used among developers working in that language. + * + * The "System Libraries" of an executable work include anything, other + * than the work as a whole, that (a) is included in the normal form of + * packaging a Major Component, but which is not part of that Major + * Component, and (b) serves only to enable use of the work with that + * Major Component, or to implement a Standard Interface for which an + * implementation is available to the public in source code form. A + * "Major Component", in this context, means a major essential component + * (kernel, window system, and so on) of the specific operating system + * (if any) on which the executable work runs, or a compiler used to + * produce the work, or an object code interpreter used to run it. + * + * The "Corresponding Source" for a work in object code form means all + * the source code needed to generate, install, and (for an executable + * work) run the object code and to modify the work, including scripts to + * control those activities. However, it does not include the work's + * System Libraries, or general-purpose tools or generally available free + * programs which are used unmodified in performing those activities but + * which are not part of the work. For example, Corresponding Source + * includes interface definition files associated with source files for + * the work, and the source code for shared libraries and dynamically + * linked subprograms that the work is specifically designed to require, + * such as by intimate data communication or control flow between those + * subprograms and other parts of the work. + * + * The Corresponding Source need not include anything that users + * can regenerate automatically from other parts of the Corresponding + * Source. + * + * The Corresponding Source for a work in source code form is that + * same work. + * + * 2. Basic Permissions. + * + * All rights granted under this License are granted for the term of + * copyright on the Program, and are irrevocable provided the stated + * conditions are met. This License explicitly affirms your unlimited + * permission to run the unmodified Program. The output from running a + * covered work is covered by this License only if the output, given its + * content, constitutes a covered work. This License acknowledges your + * rights of fair use or other equivalent, as provided by copyright law. + * + * You may make, run and propagate covered works that you do not + * convey, without conditions so long as your license otherwise remains + * in force. You may convey covered works to others for the sole purpose + * of having them make modifications exclusively for you, or provide you + * with facilities for running those works, provided that you comply with + * the terms of this License in conveying all material for which you do + * not control copyright. Those thus making or running the covered works + * for you must do so exclusively on your behalf, under your direction + * and control, on terms that prohibit them from making any copies of + * your copyrighted material outside their relationship with you. + * + * Conveying under any other circumstances is permitted solely under + * the conditions stated below. Sublicensing is not allowed; section 10 + * makes it unnecessary. + * + * 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + * + * No covered work shall be deemed part of an effective technological + * measure under any applicable law fulfilling obligations under article + * 11 of the WIPO copyright treaty adopted on 20 December 1996, or + * similar laws prohibiting or restricting circumvention of such + * measures. + * + * When you convey a covered work, you waive any legal power to forbid + * circumvention of technological measures to the extent such circumvention + * is effected by exercising rights under this License with respect to + * the covered work, and you disclaim any intention to limit operation or + * modification of the work as a means of enforcing, against the work's + * users, your or third parties' legal rights to forbid circumvention of + * technological measures. + * + * 4. Conveying Verbatim Copies. + * + * You may convey verbatim copies of the Program's source code as you + * receive it, in any medium, provided that you conspicuously and + * appropriately publish on each copy an appropriate copyright notice; + * keep intact all notices stating that this License and any + * non-permissive terms added in accord with section 7 apply to the code; + * keep intact all notices of the absence of any warranty; and give all + * recipients a copy of this License along with the Program. + * + * You may charge any price or no price for each copy that you convey, + * and you may offer support or warranty protection for a fee. + * + * 5. Conveying Modified Source Versions. + * + * You may convey a work based on the Program, or the modifications to + * produce it from the Program, in the form of source code under the + * terms of section 4, provided that you also meet all of these conditions: + * + * a) The work must carry prominent notices stating that you modified + * it, and giving a relevant date. + * + * b) The work must carry prominent notices stating that it is + * released under this License and any conditions added under section + * 7. This requirement modifies the requirement in section 4 to + * "keep intact all notices". + * + * c) You must license the entire work, as a whole, under this + * License to anyone who comes into possession of a copy. This + * License will therefore apply, along with any applicable section 7 + * additional terms, to the whole of the work, and all its parts, + * regardless of how they are packaged. This License gives no + * permission to license the work in any other way, but it does not + * invalidate such permission if you have separately received it. + * + * d) If the work has interactive user interfaces, each must display + * Appropriate Legal Notices; however, if the Program has interactive + * interfaces that do not display Appropriate Legal Notices, your + * work need not make them do so. + * + * A compilation of a covered work with other separate and independent + * works, which are not by their nature extensions of the covered work, + * and which are not combined with it such as to form a larger program, + * in or on a volume of a storage or distribution medium, is called an + * "aggregate" if the compilation and its resulting copyright are not + * used to limit the access or legal rights of the compilation's users + * beyond what the individual works permit. Inclusion of a covered work + * in an aggregate does not cause this License to apply to the other + * parts of the aggregate. + * + * 6. Conveying Non-Source Forms. + * + * You may convey a covered work in object code form under the terms + * of sections 4 and 5, provided that you also convey the + * machine-readable Corresponding Source under the terms of this License, + * in one of these ways: + * + * a) Convey the object code in, or embodied in, a physical product + * (including a physical distribution medium), accompanied by the + * Corresponding Source fixed on a durable physical medium + * customarily used for software interchange. + * + * b) Convey the object code in, or embodied in, a physical product + * (including a physical distribution medium), accompanied by a + * written offer, valid for at least three years and valid for as + * long as you offer spare parts or customer support for that product + * model, to give anyone who possesses the object code either (1) a + * copy of the Corresponding Source for all the software in the + * product that is covered by this License, on a durable physical + * medium customarily used for software interchange, for a price no + * more than your reasonable cost of physically performing this + * conveying of source, or (2) access to copy the + * Corresponding Source from a network server at no charge. + * + * c) Convey individual copies of the object code with a copy of the + * written offer to provide the Corresponding Source. This + * alternative is allowed only occasionally and noncommercially, and + * only if you received the object code with such an offer, in accord + * with subsection 6b. + * + * d) Convey the object code by offering access from a designated + * place (gratis or for a charge), and offer equivalent access to the + * Corresponding Source in the same way through the same place at no + * further charge. You need not require recipients to copy the + * Corresponding Source along with the object code. If the place to + * copy the object code is a network server, the Corresponding Source + * may be on a different server (operated by you or a third party) + * that supports equivalent copying facilities, provided you maintain + * clear directions next to the object code saying where to find the + * Corresponding Source. Regardless of what server hosts the + * Corresponding Source, you remain obligated to ensure that it is + * available for as long as needed to satisfy these requirements. + * + * e) Convey the object code using peer-to-peer transmission, provided + * you inform other peers where the object code and Corresponding + * Source of the work are being offered to the general public at no + * charge under subsection 6d. + * + * A separable portion of the object code, whose source code is excluded + * from the Corresponding Source as a System Library, need not be + * included in conveying the object code work. + * + * A "User Product" is either (1) a "consumer product", which means any + * tangible personal property which is normally used for personal, family, + * or household purposes, or (2) anything designed or sold for incorporation + * into a dwelling. In determining whether a product is a consumer product, + * doubtful cases shall be resolved in favor of coverage. For a particular + * product received by a particular user, "normally used" refers to a + * typical or common use of that class of product, regardless of the status + * of the particular user or of the way in which the particular user + * actually uses, or expects or is expected to use, the product. A product + * is a consumer product regardless of whether the product has substantial + * commercial, industrial or non-consumer uses, unless such uses represent + * the only significant mode of use of the product. + * + * "Installation Information" for a User Product means any methods, + * procedures, authorization keys, or other information required to install + * and execute modified versions of a covered work in that User Product from + * a modified version of its Corresponding Source. The information must + * suffice to ensure that the continued functioning of the modified object + * code is in no case prevented or interfered with solely because + * modification has been made. + * + * If you convey an object code work under this section in, or with, or + * specifically for use in, a User Product, and the conveying occurs as + * part of a transaction in which the right of possession and use of the + * User Product is transferred to the recipient in perpetuity or for a + * fixed term (regardless of how the transaction is characterized), the + * Corresponding Source conveyed under this section must be accompanied + * by the Installation Information. But this requirement does not apply + * if neither you nor any third party retains the ability to install + * modified object code on the User Product (for example, the work has + * been installed in ROM). + * + * The requirement to provide Installation Information does not include a + * requirement to continue to provide support service, warranty, or updates + * for a work that has been modified or installed by the recipient, or for + * the User Product in which it has been modified or installed. Access to a + * network may be denied when the modification itself materially and + * adversely affects the operation of the network or violates the rules and + * protocols for communication across the network. + * + * Corresponding Source conveyed, and Installation Information provided, + * in accord with this section must be in a format that is publicly + * documented (and with an implementation available to the public in + * source code form), and must require no special password or key for + * unpacking, reading or copying. + * + * 7. Additional Terms. + * + * "Additional permissions" are terms that supplement the terms of this + * License by making exceptions from one or more of its conditions. + * Additional permissions that are applicable to the entire Program shall + * be treated as though they were included in this License, to the extent + * that they are valid under applicable law. If additional permissions + * apply only to part of the Program, that part may be used separately + * under those permissions, but the entire Program remains governed by + * this License without regard to the additional permissions. + * + * When you convey a copy of a covered work, you may at your option + * remove any additional permissions from that copy, or from any part of + * it. (Additional permissions may be written to require their own + * removal in certain cases when you modify the work.) You may place + * additional permissions on material, added by you to a covered work, + * for which you have or can give appropriate copyright permission. + * + * Notwithstanding any other provision of this License, for material you + * add to a covered work, you may (if authorized by the copyright holders of + * that material) supplement the terms of this License with terms: + * + * a) Disclaiming warranty or limiting liability differently from the + * terms of sections 15 and 16 of this License; or + * + * b) Requiring preservation of specified reasonable legal notices or + * author attributions in that material or in the Appropriate Legal + * Notices displayed by works containing it; or + * + * c) Prohibiting misrepresentation of the origin of that material, or + * requiring that modified versions of such material be marked in + * reasonable ways as different from the original version; or + * + * d) Limiting the use for publicity purposes of names of licensors or + * authors of the material; or + * + * e) Declining to grant rights under trademark law for use of some + * trade names, trademarks, or service marks; or + * + * f) Requiring indemnification of licensors and authors of that + * material by anyone who conveys the material (or modified versions of + * it) with contractual assumptions of liability to the recipient, for + * any liability that these contractual assumptions directly impose on + * those licensors and authors. + * + * All other non-permissive additional terms are considered "further + * restrictions" within the meaning of section 10. If the Program as you + * received it, or any part of it, contains a notice stating that it is + * governed by this License along with a term that is a further + * restriction, you may remove that term. If a license document contains + * a further restriction but permits relicensing or conveying under this + * License, you may add to a covered work material governed by the terms + * of that license document, provided that the further restriction does + * not survive such relicensing or conveying. + * + * If you add terms to a covered work in accord with this section, you + * must place, in the relevant source files, a statement of the + * additional terms that apply to those files, or a notice indicating + * where to find the applicable terms. + * + * Additional terms, permissive or non-permissive, may be stated in the + * form of a separately written license, or stated as exceptions; + * the above requirements apply either way. + * + * 8. Termination. + * + * You may not propagate or modify a covered work except as expressly + * provided under this License. Any attempt otherwise to propagate or + * modify it is void, and will automatically terminate your rights under + * this License (including any patent licenses granted under the third + * paragraph of section 11). + * + * However, if you cease all violation of this License, then your + * license from a particular copyright holder is reinstated (a) + * provisionally, unless and until the copyright holder explicitly and + * finally terminates your license, and (b) permanently, if the copyright + * holder fails to notify you of the violation by some reasonable means + * prior to 60 days after the cessation. + * + * Moreover, your license from a particular copyright holder is + * reinstated permanently if the copyright holder notifies you of the + * violation by some reasonable means, this is the first time you have + * received notice of violation of this License (for any work) from that + * copyright holder, and you cure the violation prior to 30 days after + * your receipt of the notice. + * + * Termination of your rights under this section does not terminate the + * licenses of parties who have received copies or rights from you under + * this License. If your rights have been terminated and not permanently + * reinstated, you do not qualify to receive new licenses for the same + * material under section 10. + * + * 9. Acceptance Not Required for Having Copies. + * + * You are not required to accept this License in order to receive or + * run a copy of the Program. Ancillary propagation of a covered work + * occurring solely as a consequence of using peer-to-peer transmission + * to receive a copy likewise does not require acceptance. However, + * nothing other than this License grants you permission to propagate or + * modify any covered work. These actions infringe copyright if you do + * not accept this License. Therefore, by modifying or propagating a + * covered work, you indicate your acceptance of this License to do so. + * + * 10. Automatic Licensing of Downstream Recipients. + * + * Each time you convey a covered work, the recipient automatically + * receives a license from the original licensors, to run, modify and + * propagate that work, subject to this License. You are not responsible + * for enforcing compliance by third parties with this License. + * + * An "entity transaction" is a transaction transferring control of an + * organization, or substantially all assets of one, or subdividing an + * organization, or merging organizations. If propagation of a covered + * work results from an entity transaction, each party to that + * transaction who receives a copy of the work also receives whatever + * licenses to the work the party's predecessor in interest had or could + * give under the previous paragraph, plus a right to possession of the + * Corresponding Source of the work from the predecessor in interest, if + * the predecessor has it or can get it with reasonable efforts. + * + * You may not impose any further restrictions on the exercise of the + * rights granted or affirmed under this License. For example, you may + * not impose a license fee, royalty, or other charge for exercise of + * rights granted under this License, and you may not initiate litigation + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * any patent claim is infringed by making, using, selling, offering for + * sale, or importing the Program or any portion of it. + * + * 11. Patents. + * + * A "contributor" is a copyright holder who authorizes use under this + * License of the Program or a work on which the Program is based. The + * work thus licensed is called the contributor's "contributor version". + * + * A contributor's "essential patent claims" are all patent claims + * owned or controlled by the contributor, whether already acquired or + * hereafter acquired, that would be infringed by some manner, permitted + * by this License, of making, using, or selling its contributor version, + * but do not include claims that would be infringed only as a + * consequence of further modification of the contributor version. For + * purposes of this definition, "control" includes the right to grant + * patent sublicenses in a manner consistent with the requirements of + * this License. + * + * Each contributor grants you a non-exclusive, worldwide, royalty-free + * patent license under the contributor's essential patent claims, to + * make, use, sell, offer for sale, import and otherwise run, modify and + * propagate the contents of its contributor version. + * + * In the following three paragraphs, a "patent license" is any express + * agreement or commitment, however denominated, not to enforce a patent + * (such as an express permission to practice a patent or covenant not to + * sue for patent infringement). To "grant" such a patent license to a + * party means to make such an agreement or commitment not to enforce a + * patent against the party. + * + * If you convey a covered work, knowingly relying on a patent license, + * and the Corresponding Source of the work is not available for anyone + * to copy, free of charge and under the terms of this License, through a + * publicly available network server or other readily accessible means, + * then you must either (1) cause the Corresponding Source to be so + * available, or (2) arrange to deprive yourself of the benefit of the + * patent license for this particular work, or (3) arrange, in a manner + * consistent with the requirements of this License, to extend the patent + * license to downstream recipients. "Knowingly relying" means you have + * actual knowledge that, but for the patent license, your conveying the + * covered work in a country, or your recipient's use of the covered work + * in a country, would infringe one or more identifiable patents in that + * country that you have reason to believe are valid. + * + * If, pursuant to or in connection with a single transaction or + * arrangement, you convey, or propagate by procuring conveyance of, a + * covered work, and grant a patent license to some of the parties + * receiving the covered work authorizing them to use, propagate, modify + * or convey a specific copy of the covered work, then the patent license + * you grant is automatically extended to all recipients of the covered + * work and works based on it. + * + * A patent license is "discriminatory" if it does not include within + * the scope of its coverage, prohibits the exercise of, or is + * conditioned on the non-exercise of one or more of the rights that are + * specifically granted under this License. You may not convey a covered + * work if you are a party to an arrangement with a third party that is + * in the business of distributing software, under which you make payment + * to the third party based on the extent of your activity of conveying + * the work, and under which the third party grants, to any of the + * parties who would receive the covered work from you, a discriminatory + * patent license (a) in connection with copies of the covered work + * conveyed by you (or copies made from those copies), or (b) primarily + * for and in connection with specific products or compilations that + * contain the covered work, unless you entered into that arrangement, + * or that patent license was granted, prior to 28 March 2007. + * + * Nothing in this License shall be construed as excluding or limiting + * any implied license or other defenses to infringement that may + * otherwise be available to you under applicable patent law. + * + * 12. No Surrender of Others' Freedom. + * + * If conditions are imposed on you (whether by court order, agreement or + * otherwise) that contradict the conditions of this License, they do not + * excuse you from the conditions of this License. If you cannot convey a + * covered work so as to satisfy simultaneously your obligations under this + * License and any other pertinent obligations, then as a consequence you may + * not convey it at all. For example, if you agree to terms that obligate you + * to collect a royalty for further conveying from those to whom you convey + * the Program, the only way you could satisfy both those terms and this + * License would be to refrain entirely from conveying the Program. + * + * 13. Remote Network Interaction; Use with the GNU General Public License. + * + * Notwithstanding any other provision of this License, if you modify the + * Program, your modified version must prominently offer all users + * interacting with it remotely through a computer network (if your version + * supports such interaction) an opportunity to receive the Corresponding + * Source of your version by providing access to the Corresponding Source + * from a network server at no charge, through some standard or customary + * means of facilitating copying of software. This Corresponding Source + * shall include the Corresponding Source for any work covered by version 3 + * of the GNU General Public License that is incorporated pursuant to the + * following paragraph. + * + * Notwithstanding any other provision of this License, you have + * permission to link or combine any covered work with a work licensed + * under version 3 of the GNU General Public License into a single + * combined work, and to convey the resulting work. The terms of this + * License will continue to apply to the part which is the covered work, + * but the work with which it is combined will remain governed by version + * 3 of the GNU General Public License. + * + * 14. Revised Versions of this License. + * + * The Free Software Foundation may publish revised and/or new versions of + * the GNU Affero General Public License from time to time. Such new versions + * will be similar in spirit to the present version, but may differ in detail to + * address new problems or concerns. + * + * Each version is given a distinguishing version number. If the + * Program specifies that a certain numbered version of the GNU Affero General + * Public License "or any later version" applies to it, you have the + * option of following the terms and conditions either of that numbered + * version or of any later version published by the Free Software + * Foundation. If the Program does not specify a version number of the + * GNU Affero General Public License, you may choose any version ever published + * by the Free Software Foundation. + * + * If the Program specifies that a proxy can decide which future + * versions of the GNU Affero General Public License can be used, that proxy's + * public statement of acceptance of a version permanently authorizes you + * to choose that version for the Program. + * + * Later license versions may give you additional or different + * permissions. However, no additional obligations are imposed on any + * author or copyright holder as a result of your choosing to follow a + * later version. + * + * 15. Disclaimer of Warranty. + * + * THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY + * APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT + * HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM + * IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF + * ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + * + * 16. Limitation of Liability. + * + * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + * WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS + * THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY + * GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE + * USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF + * DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD + * PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), + * EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGES. + * + * 17. Interpretation of Sections 15 and 16. + * + * If the disclaimer of warranty and limitation of liability provided + * above cannot be given local legal effect according to their terms, + * reviewing courts shall apply local law that most closely approximates + * an absolute waiver of all civil liability in connection with the + * Program, unless a warranty or assumption of liability accompanies a + * copy of the Program in return for a fee. + * + * END OF TERMS AND CONDITIONS + * + * How to Apply These Terms to Your New Programs + * + * If you develop a new program, and you want it to be of the greatest + * possible use to the public, the best way to achieve this is to make it + * free software which everyone can redistribute and change under these terms. + * + * To do so, attach the following notices to the program. It is safest + * to attach them to the start of each source file to most effectively + * state the exclusion of warranty; and each file should have at least + * the "copyright" line and a pointer to where the full notice is found. + * + * <one line to give the program's name and a brief idea of what it does.> + * Copyright (C) <year> <name of author> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + * Also add information on how to contact you by electronic and paper mail. + * + * If your software can interact with users remotely through a computer + * network, you should also make sure that it provides a way for users to + * get its source. For example, if your program is a web application, its + * interface could display a "Source" link that leads users to an archive + * of the code. There are many ways you could offer source, and different + * solutions will be better for different programs; see section 13 for the + * specific requirements. + * + * You should also get your employer (if you work as a programmer) or school, + * if any, to sign a "copyright disclaimer" for the program, if necessary. + * For more information on this, and how to apply and follow the GNU AGPL, see + * <https://www.gnu.org/licenses/>. + */ +package com.jdimension.jlawyer.server.utils; + +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Random; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * @author jens + */ +public class FileNameGenerator { + + private static final String SHORTCODECHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + private static final boolean DBG = false; + + public static boolean compilePattern(String pattern) throws InvalidSchemaPatternException { + + if (pattern.contains("yyy") && !pattern.contains("yyyy")) { + throw new InvalidSchemaPatternException("y muss als yy oder yyyy enthalten sein"); + } + if (pattern.contains("yyyyy")) { + throw new InvalidSchemaPatternException("y muss als yy oder yyyy enthalten sein"); + } + + if (pattern.contains("mmm")) { + throw new InvalidSchemaPatternException("m muss als m oder mm enthalten sein"); + } + if (pattern.contains("ddd")) { + throw new InvalidSchemaPatternException("d muss als d oder dd enthalten sein"); + } + + if (pattern.indexOf('n') > -1 && !pattern.contains("nnn")) { + throw new InvalidSchemaPatternException("n muss mindestens als nnn (999 Rechnungen pro Jahr) enthalten sein"); + } + + return true; + } + + public static String getFileName(String pattern, String fileName) throws InvalidSchemaPatternException { + + compilePattern(pattern); + + return next(pattern, fileName); + } + + public static String getFileName(String pattern, Date d, String fileName) throws InvalidSchemaPatternException { + + compilePattern(pattern); + + return next(pattern, d, fileName); + } + + private static synchronized String next(String pattern, String fileName) throws InvalidSchemaPatternException { + return next(pattern, new Date(), fileName); + } + + private static synchronized String next(String pattern, Date date, String fileName) throws InvalidSchemaPatternException { + + SimpleDateFormat shortYear = new SimpleDateFormat("yy"); + SimpleDateFormat longYear = new SimpleDateFormat("yyyy"); + + SimpleDateFormat shortMonth = new SimpleDateFormat("M"); + SimpleDateFormat longMonth = new SimpleDateFormat("MM"); + + SimpleDateFormat shortDay = new SimpleDateFormat("d"); + SimpleDateFormat longDay = new SimpleDateFormat("dd"); + + Date current = date; + if (current == null) { + current = new Date(); + } + + // fixed values + while (pattern.contains("yyyy")) { + pattern = pattern.replace("yyyy", longYear.format(current)); + } + while (pattern.contains("yy")) { + pattern = pattern.replace("yy", shortYear.format(current)); + } + + while (pattern.contains("mm")) { + pattern = pattern.replace("mm", longMonth.format(current)); + } + while (pattern.contains("m")) { + pattern = pattern.replace("m", shortMonth.format(current)); + } + + while (pattern.contains("dd")) { + pattern = pattern.replace("dd", longDay.format(current)); + } + while (pattern.contains("d")) { + pattern = pattern.replace("d", shortDay.format(current)); + } + + // variable values + pattern = pattern.replace("DATEINAME", fileName); + + return pattern; + + } +} diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java index 5ff6222f8..2a3825119 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java @@ -681,6 +681,7 @@ import com.jdimension.jlawyer.persistence.utils.StringGenerator; import com.jdimension.jlawyer.pojo.DataBucket; import com.jdimension.jlawyer.server.utils.CaseNumberGenerator; +import com.jdimension.jlawyer.server.utils.FileNameGenerator; import com.jdimension.jlawyer.server.utils.InvalidSchemaPatternException; import com.jdimension.jlawyer.server.utils.SecurityUtils; import com.jdimension.jlawyer.server.utils.ServerFileUtils; @@ -2000,6 +2001,18 @@ public boolean setDocumentContent(String id, byte[] content) throws Exception { return true; } + @Override + @RolesAllowed({"loginRole"}) + public String getNewDocumentName(String fileName, Date date, DocumentNameTemplate tpl) throws Exception { + + try { + return FileNameGenerator.getFileName(tpl.getPattern(), date, fileName); + } catch (InvalidSchemaPatternException isp) { + throw new Exception(isp.getMessage()); + } + + } + @Override @RolesAllowed({"readArchiveFileRole"}) public byte[] getDocumentContent(String id) throws Exception { @@ -4974,7 +4987,7 @@ public Invoice addInvoice(String caseId, InvoicePool invoicePool, InvoiceType in i.setId(idGen.getID().toString()); i.setInvoiceNumber(this.invoiceService.nextInvoiceNumber(pool)); - i.setName(aFile.getName()); + i.setName(aFile.getReason()); if (aFile.getDateCreated() != null) { i.setPeriodFrom(aFile.getDateCreated()); } else { diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SystemManagement.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SystemManagement.java index 233ec4199..3e6323060 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SystemManagement.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SystemManagement.java @@ -673,6 +673,8 @@ import com.jdimension.jlawyer.server.services.MonitoringSnapshot; import com.jdimension.jlawyer.server.services.ServerInformation; import com.jdimension.jlawyer.server.services.settings.ServerSettingsKeys; +import com.jdimension.jlawyer.server.utils.FileNameGenerator; +import com.jdimension.jlawyer.server.utils.InvalidSchemaPatternException; import com.jdimension.jlawyer.server.utils.ServerFileUtils; import com.jdimension.jlawyer.server.utils.ServerStringUtils; import com.jdimension.jlawyer.server.utils.StringUtils; @@ -687,6 +689,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; @@ -775,6 +778,8 @@ public class SystemManagement implements SystemManagementRemote, SystemManagemen private FormsServiceLocal formsService; @EJB private AssistantConfigFacadeLocal assistantFacade; + @EJB + private DocumentNameTemplateFacadeLocal documentNameTemplates; @Inject @JMSConnectionFactory("java:/JmsXA") @@ -2386,5 +2391,85 @@ public AssistantConfig updateAssistant(AssistantConfig assistant) throws Excepti this.assistantFacade.edit(assistant); return this.assistantFacade.find(assistant.getId()); } + + @Override + @RolesAllowed({"adminRole"}) + public DocumentNameTemplate addDocumentNameTemplate(DocumentNameTemplate template) throws Exception { + StringGenerator idGen=new StringGenerator(); + String id=idGen.getID().toString(); + template.setId(id); + this.documentNameTemplates.create(template); + return this.documentNameTemplates.find(id); + } + + @Override + @RolesAllowed({"adminRole"}) + public DocumentNameTemplate updateDocumentNameTemplate(DocumentNameTemplate template) throws Exception { + this.documentNameTemplates.edit(template); + + if(template.isDefaultTemplate()) { + // default template - remove default flag from any other templates + for(DocumentNameTemplate t: this.documentNameTemplates.findAll()) { + if(!t.equals(template)) { + t.setDefaultTemplate(false); + this.documentNameTemplates.edit(t); + } + } + } + + return this.documentNameTemplates.find(template.getId()); + } + + @Override + @RolesAllowed({"loginRole"}) + public DocumentNameTemplate getDocumentNameTemplate(String templateId) throws Exception { + return this.documentNameTemplates.find(templateId); + } + + @Override + @RolesAllowed({"adminRole"}) + public void removeDocumentNameTemplate(DocumentNameTemplate template) throws Exception { + this.documentNameTemplates.remove(template); + } + + @Override + @RolesAllowed({"loginRole"}) + public List<DocumentNameTemplate> getDocumentNameTemplates() throws Exception { + + List<DocumentNameTemplate> allTemplates=this.documentNameTemplates.findAll(); + allTemplates.sort(Comparator.comparing( + entry -> entry.getDisplayName().toLowerCase() + )); + return allTemplates; + + } + + @Override + @RolesAllowed({"loginRole"}) + public DocumentNameTemplate getDefaultDocumentNameTemplate() throws Exception { + + return this.documentNameTemplates.findDefault(); + + } + + @Override + @RolesAllowed({"loginRole"}) + public List<String> previewDocumentNamesForTemplate(DocumentNameTemplate template, String fileName) throws Exception { + ArrayList<String> previews = new ArrayList<>(); + + try { + + for (int i = 0; i < 10; i++) { + java.util.Date now = new Date(System.currentTimeMillis() + 24l * 60l * 60l * 1000l * i); + String next = FileNameGenerator.getFileName(template.getPattern(), now, fileName); + previews.add(next); + } + + return previews; + + } catch (InvalidSchemaPatternException isp) { + throw new Exception(isp.getMessage()); + } + } } diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/org/jlawyer/utils/PlaceHolderServerUtils.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/org/jlawyer/utils/PlaceHolderServerUtils.java index 9821065c5..0c29afd18 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/org/jlawyer/utils/PlaceHolderServerUtils.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/org/jlawyer/utils/PlaceHolderServerUtils.java @@ -677,6 +677,7 @@ import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -778,12 +779,16 @@ public static HashMap<String,Object> getPlaceHolderValues(HashMap<String,Object> placeHolders.put(PROFIL_KONTONR_AK, getSetting(set, ServerSettingsKeys.PROFILE_COMPANYACCOUNTNO_AK, "")); } + if(formsPlaceHolderValues==null) + formsPlaceHolderValues=new HashMap<>(); for(String formPh: formsPlaceHolderValues.keySet()) { if(placeHolders.containsKey(formPh)) { placeHolders.put(formPh, formsPlaceHolderValues.get(formPh)); } } + if(selectedParties==null) + selectedParties=new ArrayList<>(); for(PartiesTriplet ppe: selectedParties) { AddressBean selected=ppe.getAddress();