From 86bbb3f743dccccb370d834e559dcab5f4dd522e Mon Sep 17 00:00:00 2001 From: j-dimension Date: Tue, 7 Nov 2023 01:02:02 +0100 Subject: [PATCH] add change date to documents. close #1938. --- .../editors/files/DateTimePickerDialog.java | 30 ++++++++------- .../jlawyer/client/utils/DateUtils.java | 37 +++++++++++++++++++ .../jlawyer/ui/folders/CaseFolderPanel.form | 2 +- .../jlawyer/ui/folders/CaseFolderPanel.java | 10 ++--- .../ui/folders/DocumentEntryPanel.form | 10 ++--- .../ui/folders/DocumentEntryPanel.java | 28 +++++++------- .../comparator/DocumentsComparator.java | 4 +- .../persistence/ArchiveFileDocumentsBean.java | 18 +++++++++ .../V2_6_0_2__DocumentsAddChanged.sql | 6 +++ .../jlawyer/io/rest/v1/CasesEndpointV1.java | 1 + .../io/rest/v1/pojo/RestfulDocumentV1.java | 15 ++++++++ .../io/rest/v6/TemplatesEndpointV6.java | 1 + .../jdimension/jlawyer/export/HTMLExport.java | 6 +-- .../jlawyer/services/ArchiveFileService.java | 10 +++-- 14 files changed, 132 insertions(+), 46 deletions(-) create mode 100644 j-lawyer-server-entities/src/java/db/migration/V2_6_0_2__DocumentsAddChanged.sql diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/DateTimePickerDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/DateTimePickerDialog.java index f863f67fb..a9f4c1235 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/DateTimePickerDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/DateTimePickerDialog.java @@ -688,13 +688,17 @@ public class DateTimePickerDialog extends javax.swing.JDialog { private CaseFolderPanel table = null; /** - * Creates new form ShowURLDialog + * Creates new form DateTimePickerDialog + * @param parent + * @param modal + * @param d + * @param table */ public DateTimePickerDialog(java.awt.Frame parent, boolean modal, ArchiveFileDocumentsBean d, CaseFolderPanel table) { super(parent, modal); initComponents(); this.doc = d; - this.setDate(d.getCreationDate()); + this.setDate(d.getChangeDate()); this.spinDateTime.setValue(this.date); this.table = table; try { @@ -807,7 +811,7 @@ private void confirmWithDate(Date d) { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); ArchiveFileServiceRemote remote = locator.lookupArchiveFileServiceRemote(); remote.setDocumentDate(doc.getId(), d); - doc.setCreationDate(d); + doc.setChangeDate(d); this.table.updateDocument(doc); this.setVisible(false); @@ -847,17 +851,15 @@ public static void main(String args[]) { // /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - DateTimePickerDialog dialog = new DateTimePickerDialog(new javax.swing.JFrame(), true, null, null); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } + java.awt.EventQueue.invokeLater(() -> { + DateTimePickerDialog dialog = new DateTimePickerDialog(new javax.swing.JFrame(), true, null, null); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); }); } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/DateUtils.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/DateUtils.java index ac11a93c5..228244250 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/DateUtils.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/DateUtils.java @@ -702,4 +702,41 @@ public static String getHumanReadableTimeInPast(Date d) { return "vor " + sekunden + (sekunden == 1 ? " Sekunde" : " Sekunden"); } } + + public static String getHumanReadableTime(Date d) { + + if(d==null) + return "unbekannt"; + + long jetzt = System.currentTimeMillis(); + long vergangeneZeitInMs = d.getTime(); + + long differenzInMs = jetzt - vergangeneZeitInMs; + String prefix="vor "; + if(differenzInMs<0) { + prefix="in "; + differenzInMs=differenzInMs*-1l; + } + + long sekunden = differenzInMs / 1000; + long minuten = sekunden / 60; + long stunden = minuten / 60; + long tage = stunden / 24; + long wochen = tage / 7; + long jahre=wochen / 52; + + if(jahre>0) { + return prefix + jahre + (jahre == 1 ? " Jahr" : " Jahren"); + } else if (wochen > 0) { + return prefix + wochen + (wochen == 1 ? " Woche" : " Wochen"); + } else if (tage > 0) { + return prefix + tage + (tage == 1 ? " Tag" : " Tagen"); + } else if (stunden > 0) { + return prefix + stunden + (stunden == 1 ? " Stunde" : " Stunden"); + } else if (minuten > 0) { + return prefix + minuten + (minuten == 1 ? " Minute" : " Minuten"); + } else { + return prefix + sekunden + (sekunden == 1 ? " Sekunde" : " Sekunden"); + } + } } 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 0bf037f0a..5f746eb2d 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 @@ -194,7 +194,7 @@ - + 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 acdfce142..7d3e726e6 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 @@ -868,12 +868,12 @@ public void sort() { ArchiveFileDocumentsBean d2 = (ArchiveFileDocumentsBean) t2; if (sortDate.getSortState() == SortButton.SORT_ASC) { - Date date1 = d1.getCreationDate(); - Date date2 = d2.getCreationDate(); + Date date1 = d1.getChangeDate(); + Date date2 = d2.getChangeDate(); return date1.compareTo(date2); } else if (sortDate.getSortState() == SortButton.SORT_DESC) { - Date date1 = d1.getCreationDate(); - Date date2 = d2.getCreationDate(); + Date date1 = d1.getChangeDate(); + Date date2 = d2.getChangeDate(); return date2.compareTo(date1); } else if (sortSize.getSortState() == SortButton.SORT_ASC) { long l1 = d1.getSize(); @@ -1066,7 +1066,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { ); sortDate.setText("Datum"); - sortDate.setToolTipText("nach Erstellungsdatum sortieren"); + sortDate.setToolTipText("nach Änderungsdatum sortieren"); sortDate.setIconTextGap(2); sortDate.setInheritsPopupMenu(true); sortDate.addMouseListener(new java.awt.event.MouseAdapter() { diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.form b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.form index 89e51d4e6..5507230cb 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.form @@ -29,7 +29,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -101,17 +101,17 @@ - + - + - + diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.java index 96d99def0..eb6420165 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/ui/folders/DocumentEntryPanel.java @@ -670,6 +670,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.client.settings.ClientSettings; import com.jdimension.jlawyer.client.utils.FileUtils; import com.jdimension.jlawyer.client.utils.FrameUtils; +import com.jdimension.jlawyer.client.utils.DateUtils; import com.jdimension.jlawyer.persistence.ArchiveFileDocumentsBean; import com.jdimension.jlawyer.persistence.Invoice; import com.jdimension.jlawyer.services.ArchiveFileServiceRemote; @@ -733,7 +734,7 @@ public DocumentEntryPanel() { DnDConstants.ACTION_MOVE, this); - this.lblCreationDate.setForeground(DefaultColorTheme.COLOR_DARK_GREY); + this.lblChangeDate.setForeground(DefaultColorTheme.COLOR_DARK_GREY); this.lblDictateSign.setForeground(DefaultColorTheme.COLOR_DARK_GREY); this.lblFileSize.setForeground(DefaultColorTheme.COLOR_DARK_GREY); @@ -758,7 +759,7 @@ public DocumentEntryPanel(ArchiveFilePanel caseContainer, CaseFolderPanel docume DnDConstants.ACTION_MOVE, this); - this.lblCreationDate.setForeground(DefaultColorTheme.COLOR_DARK_GREY); + this.lblChangeDate.setForeground(DefaultColorTheme.COLOR_DARK_GREY); this.lblDictateSign.setForeground(DefaultColorTheme.COLOR_DARK_GREY); this.lblFileSize.setForeground(DefaultColorTheme.COLOR_DARK_GREY); @@ -851,7 +852,7 @@ private void initComponents() { lblFileIcon = new javax.swing.JLabel(); lblFileName = new javax.swing.JLabel(); - lblCreationDate = new javax.swing.JLabel(); + lblChangeDate = new javax.swing.JLabel(); lblDictateSign = new javax.swing.JLabel(); lblFileSize = new javax.swing.JLabel(); chkSelected = new javax.swing.JCheckBox(); @@ -888,11 +889,11 @@ public void mouseExited(java.awt.event.MouseEvent evt) { } }); - lblCreationDate.setFont(lblCreationDate.getFont().deriveFont(lblCreationDate.getFont().getStyle() | java.awt.Font.BOLD, lblCreationDate.getFont().getSize()-2)); - lblCreationDate.setText("10.10.2020"); - lblCreationDate.addMouseListener(new java.awt.event.MouseAdapter() { + lblChangeDate.setFont(lblChangeDate.getFont().deriveFont(lblChangeDate.getFont().getStyle() | java.awt.Font.BOLD, lblChangeDate.getFont().getSize()-2)); + lblChangeDate.setText("10.10.2020"); + lblChangeDate.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { - lblCreationDateMouseClicked(evt); + lblChangeDateMouseClicked(evt); } }); @@ -979,7 +980,7 @@ public void mouseExited(java.awt.event.MouseEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(lblCreationDate) + .addComponent(lblChangeDate) .addGap(18, 18, 18) .addComponent(lblFileSize) .addGap(18, 18, 18) @@ -1001,7 +1002,7 @@ public void mouseExited(java.awt.event.MouseEvent evt) { .addComponent(lblFileName) .addGap(2, 2, 2) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(lblCreationDate) + .addComponent(lblChangeDate) .addComponent(lblDictateSign) .addComponent(lblFileSize) .addComponent(lblFolder)) @@ -1141,9 +1142,9 @@ private void chkSelectedKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:ev } }//GEN-LAST:event_chkSelectedKeyReleased - private void lblCreationDateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCreationDateMouseClicked + private void lblChangeDateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblChangeDateMouseClicked this.lblFileNameMouseClicked(evt); - }//GEN-LAST:event_lblCreationDateMouseClicked + }//GEN-LAST:event_lblChangeDateMouseClicked private void lblFileSizeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblFileSizeMouseClicked this.lblFileNameMouseClicked(evt); @@ -1225,7 +1226,7 @@ public void setFavorite(boolean favorite) { private javax.swing.JCheckBox chkSelected; private javax.swing.JButton cmdHighlight1; private javax.swing.JButton cmdHighlight2; - private javax.swing.JLabel lblCreationDate; + private javax.swing.JLabel lblChangeDate; private javax.swing.JLabel lblDictateSign; private javax.swing.JLabel lblFavorite; private javax.swing.JLabel lblFileIcon; @@ -1247,7 +1248,8 @@ void setDocument(ArchiveFileDocumentsBean doc, Invoice linkedInvoice) { this.lblFileName.setText(doc.getName()); this.lblFileName.setToolTipText(doc.getName()); this.lblFileIcon.setToolTipText(doc.getName()); - this.lblCreationDate.setText(dfDateTime.format(doc.getCreationDate())); + this.lblChangeDate.setText(DateUtils.getHumanReadableTime(doc.getChangeDate())); + this.lblChangeDate.setToolTipText("erstellt: " + dfDateTime.format(doc.getCreationDate()) + System.lineSeparator() + "geändert: " + dfDateTime.format(doc.getChangeDate())); this.lblDictateSign.setText(doc.getDictateSign()); if(this.document.getFolder()==null) { this.lblFolder.setIcon(null); diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/comparator/DocumentsComparator.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/comparator/DocumentsComparator.java index 9c3dc2563..478e20ca3 100755 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/comparator/DocumentsComparator.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/comparator/DocumentsComparator.java @@ -691,8 +691,8 @@ public int compare(Object obj1, Object obj2) { ArchiveFileDocumentsBean dto1=(ArchiveFileDocumentsBean)obj1; ArchiveFileDocumentsBean dto2=(ArchiveFileDocumentsBean)obj2; - Date d1=dto1.getCreationDate(); - Date d2=dto2.getCreationDate(); + Date d1=dto1.getChangeDate(); + Date d2=dto2.getChangeDate(); if(d1!=null) return d1.compareTo(d2); diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/ArchiveFileDocumentsBean.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/ArchiveFileDocumentsBean.java index 804d228bf..33ea82e8c 100755 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/ArchiveFileDocumentsBean.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/ArchiveFileDocumentsBean.java @@ -733,6 +733,9 @@ public class ArchiveFileDocumentsBean implements Serializable { @Column(name = "document_type", columnDefinition = "INTEGER DEFAULT 10") protected long documentType=TYPE_GENERIC; + @Column(name = "date_changed") + @Temporal(TemporalType.TIMESTAMP) + private Date changeDate; public ArchiveFileDocumentsBean() { } @@ -928,6 +931,7 @@ public void setVersion(long version) { public void bumpVersion() { this.setVersion(this.version+1); + this.setChangeDate(new Date()); } /** @@ -971,5 +975,19 @@ public long getDocumentType() { public void setDocumentType(long documentType) { this.documentType = documentType; } + + /** + * @return the changeDate + */ + public Date getChangeDate() { + return changeDate; + } + + /** + * @param changeDate the changeDate to set + */ + public void setChangeDate(Date changeDate) { + this.changeDate = changeDate; + } } diff --git a/j-lawyer-server-entities/src/java/db/migration/V2_6_0_2__DocumentsAddChanged.sql b/j-lawyer-server-entities/src/java/db/migration/V2_6_0_2__DocumentsAddChanged.sql new file mode 100644 index 000000000..c1d0b9a55 --- /dev/null +++ b/j-lawyer-server-entities/src/java/db/migration/V2_6_0_2__DocumentsAddChanged.sql @@ -0,0 +1,6 @@ +ALTER TABLE case_documents ADD `date_changed` datetime default null; +alter table case_documents add index `IDX_DOCDATECHANGED` (date_changed); +update case_documents set date_changed=creationDate; + +insert into server_settings(settingKey, settingValue) values('jlawyer.server.database.version','2.6.0.2') ON DUPLICATE KEY UPDATE settingValue = '2.6.0.2'; +commit; \ No newline at end of file diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/CasesEndpointV1.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/CasesEndpointV1.java index f705f80a5..1bf503431 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/CasesEndpointV1.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/CasesEndpointV1.java @@ -990,6 +990,7 @@ public Response getCaseDocuments(@PathParam("id") String id) { d.setVersion(doc.getVersion()); d.setName(doc.getName()); d.setCreationDate(doc.getCreationDate()); + d.setChangeDate(doc.getChangeDate()); d.setFavorite(doc.isFavorite()); d.setSize(doc.getSize()); d.setHighlight1(doc.getHighlight1()); diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/pojo/RestfulDocumentV1.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/pojo/RestfulDocumentV1.java index cd2e34f27..7ba0e7ea2 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/pojo/RestfulDocumentV1.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/pojo/RestfulDocumentV1.java @@ -674,6 +674,7 @@ public class RestfulDocumentV1 { private String id=null; private String name=null; private Date creationDate=null; + private Date changeDate=null; private long size=0l; private boolean favorite=false; protected String folderId=null; @@ -809,6 +810,20 @@ public int getHighlight2() { public void setHighlight2(int highlight2) { this.highlight2 = highlight2; } + + /** + * @return the changeDate + */ + public Date getChangeDate() { + return changeDate; + } + + /** + * @param changeDate the changeDate to set + */ + public void setChangeDate(Date changeDate) { + this.changeDate = changeDate; + } diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/TemplatesEndpointV6.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/TemplatesEndpointV6.java index 2d1478d65..1ee75025f 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/TemplatesEndpointV6.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/TemplatesEndpointV6.java @@ -886,6 +886,7 @@ public Response addDocumentFromTemplate(@PathParam("caseId") String caseId, @Pat ArchiveFileDocumentsBean newDoc=casesvc.addDocumentFromTemplate(caseId, fileName, null, folder, template, placeHoldersInTemplateMap, ""); RestfulDocumentV1 rdoc=new RestfulDocumentV1(); rdoc.setCreationDate(newDoc.getCreationDate()); + rdoc.setChangeDate(newDoc.getChangeDate()); rdoc.setFavorite(rdoc.isFavorite()); rdoc.setFolderId(newDoc.getFolder().getId()); rdoc.setId(newDoc.getId()); diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/export/HTMLExport.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/export/HTMLExport.java index 142e98b72..9ca7d014e 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/export/HTMLExport.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/export/HTMLExport.java @@ -924,8 +924,8 @@ public String export(ArchiveFileBean dto, Date lastModified) throws Exception { docOut.write(docContent); } File docOutFile = new File(newDir3.getAbsolutePath() + System.getProperty("file.separator") + dbNewName); - if (db.getCreationDate() != null) { - docOutFile.setLastModified(db.getCreationDate().getTime()); + if (db.getChangeDate() != null) { + docOutFile.setLastModified(db.getChangeDate().getTime()); } } catch (Throwable t) { log.error("Could not export document " + db.getName() + " from case " + dto.getFileNumber(), t); @@ -934,7 +934,7 @@ public String export(ArchiveFileBean dto, Date lastModified) throws Exception { // sb.append("

"); - sb.append(toDate(df, db.getCreationDate())); + sb.append(toDate(df, db.getChangeDate())); sb.append("

"); 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 aa882d4c3..801ba42b8 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 @@ -1737,7 +1737,9 @@ public ArchiveFileDocumentsBean addDocument(String archiveFileId, String fileNam db.setVersion(1); db.setDictateSign(dictateSign); db.setArchiveFileKey(aFile); - db.setCreationDate(new Date()); + Date created=new Date(); + db.setCreationDate(created); + db.setChangeDate(created); db.setName(fileName); db.setFolder(aFile.getRootFolder()); if (data != null) { @@ -3469,7 +3471,9 @@ public ArchiveFileDocumentsBean addDocumentFromTemplate(String archiveFileId, St db.setVersion(1); db.setDictateSign(dictateSign); db.setArchiveFileKey(aFile); - db.setCreationDate(new Date()); + Date created=new Date(); + db.setCreationDate(created); + db.setChangeDate(created); db.setName(fileName); db.setFolder(aFile.getRootFolder()); if (new File(dstId).exists()) { @@ -3693,7 +3697,7 @@ public List getTaggedDocuments(java.lang.String[] docT st = con.prepareStatement("select distinct(docid) from (select a5.id as docid from " + " (SELECT id, date_changed, archived from cases) a1, " + " document_tags a4, case_documents a5 " - + " where a1.archived=0 and a5.deleted=0 and (((a4.tagName in (" + inClause + ") and a4.documentKey=a5.id and a5.archiveFileKey=a1.id))) order by date_changed DESC) allkeys limit 0,?"); + + " where a1.archived=0 and a5.deleted=0 and (((a4.tagName in (" + inClause + ") and a4.documentKey=a5.id and a5.archiveFileKey=a1.id))) order by a1.date_changed DESC) allkeys limit 0,?"); int index = 1;