Skip to content

Commit

Permalink
add change date to documents. close #1938.
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Nov 7, 2023
1 parent 63a14ac commit 86bbb3f
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -847,17 +851,15 @@ public static void main(String args[]) {
//</editor-fold>

/* 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);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<Component class="com.jdimension.jlawyer.ui.folders.SortButton" name="sortDate">
<Properties>
<Property name="text" type="java.lang.String" value="Datum"/>
<Property name="toolTipText" type="java.lang.String" value="nach Erstellungsdatum sortieren"/>
<Property name="toolTipText" type="java.lang.String" value="nach &#xc4;nderungsdatum sortieren"/>
<Property name="iconTextGap" type="int" value="2"/>
<Property name="inheritsPopupMenu" type="boolean" value="true"/>
</Properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="lblCreationDate" min="-2" max="-2" attributes="0"/>
<Component id="lblChangeDate" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="lblFileSize" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
Expand All @@ -56,7 +56,7 @@
<Component id="lblFileName" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblCreationDate" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblChangeDate" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblDictateSign" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFileSize" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFolder" alignment="3" min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -101,17 +101,17 @@
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblFileNameMouseExited"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblCreationDate">
<Component class="javax.swing.JLabel" name="lblChangeDate">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="lblCreationDate" property="font" relativeSize="true" size="-2"/>
<Font bold="true" component="lblChangeDate" property="font" relativeSize="true" size="-2"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" value="10.10.2020"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCreationDateMouseClicked"/>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblChangeDateMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblDictateSign">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
});

Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down Expand Up @@ -928,6 +931,7 @@ public void setVersion(long version) {

public void bumpVersion() {
this.setVersion(this.version+1);
this.setChangeDate(new Date());
}

/**
Expand Down Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -934,7 +934,7 @@ public String export(ArchiveFileBean dto, Date lastModified) throws Exception {

// <tr><td><p class="post_info">01.01.2013</p></td><td><p class="post_info">dings</p></td></tr>
sb.append("<tr valign=\"top\"><td><p class=\"post_info\">");
sb.append(toDate(df, db.getCreationDate()));
sb.append(toDate(df, db.getChangeDate()));
sb.append("</p></td><td><p class=\"post_info\"><a href=\"documents/");
sb.append(dbNewName);
sb.append("\">");
Expand Down
Loading

0 comments on commit 86bbb3f

Please sign in to comment.