Skip to content

Commit 225cecc

Browse files
committed
Updated some dependencies (#10)
1 parent 0dba38c commit 225cecc

File tree

14 files changed

+155
-172
lines changed

14 files changed

+155
-172
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: java
22

33
jdk:
4-
- oraclejdk7
4+
- oraclejdk8
55

66
before_install:
77
- chmod +x gradlew

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
## Synthetic data generator
22

3+
**Changes in version 0.3**
4+
5+
- Removed Class-Path attribute from generated JAR.
6+
- Updated layout library from version 1.3.3 to version 1.4.
7+
- Updated algorithm library from version 1.4 to version 1.4.4.
8+
- Updated Staging library from version 2.0 to version 2.3.
9+
- Updated Commons IO library from version 2.4 to version 2.5.
10+
- This library now requires Java 8 at minimum.
11+
312
**Changes in version 0.2**
413

514
- Improved parameters validation.

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3-SNAPSHOT
1+
0.3

build.gradle

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id 'checkstyle'
66
id 'findbugs'
77
id 'com.bmuschko.nexus' version '2.3.1'
8-
id 'com.github.johnrengelman.shadow' version '1.2.1'
8+
id 'com.github.johnrengelman.shadow' version '1.2.3'
99
}
1010

1111
group = 'com.imsweb'
@@ -19,10 +19,10 @@ repositories {
1919
}
2020

2121
dependencies {
22-
compile 'commons-io:commons-io:2.4'
23-
compile 'com.imsweb:layout:1.3.3'
24-
compile 'com.imsweb:staging-client-java:2.0'
22+
compile 'com.imsweb:layout:1.4'
2523
compile 'com.imsweb:algorithms:1.4'
24+
compile 'com.imsweb:staging-client-java:2.3'
25+
compile 'commons-io:commons-io:2.5'
2626
testCompile 'junit:junit:4.12'
2727
}
2828

@@ -43,8 +43,7 @@ jar {
4343
'Built-By': System.getProperty('user.name'),
4444
'Built-Date': new Date(),
4545
'Built-JDK': System.getProperty('java.version'),
46-
'Main-Class': 'com.imsweb.datagenerator.gui.StandaloneNaaccrDataGenerator',
47-
'Class-Path': configurations.compile.collect { it.getName() }.join(' '))
46+
'Main-Class': 'com.imsweb.datagenerator.gui.StandaloneNaaccrDataGenerator')
4847
}
4948
from ('VERSION') {
5049
rename 'VERSION', 'DATA-GENERATOR-VERSION'
@@ -54,14 +53,20 @@ jar {
5453
}
5554
}
5655

56+
// this sucks, but they made the Javadoc way too stritct in Java 8 and it's not worth my time fixing it!
57+
tasks.withType(Javadoc) {
58+
options.addStringOption('Xdoclint:none', '-quiet')
59+
}
60+
61+
5762
// we don't want these files in the "all" jar, it's confusing
5863
shadowJar {
5964
exclude('XMLPULL_1_1_3_1_VERSION')
6065
exclude('XPP3_1.1.4c_MIN_VERSION')
61-
from ('VERSION') {
66+
from('VERSION') {
6267
rename 'VERSION', 'DATA-GENERATOR-VERSION'
6368
}
64-
from ('LICENSE') {
69+
from('LICENSE') {
6570
rename 'LICENSE', 'DATA-GENERATOR-LICENSE'
6671
}
6772
}

src/main/java/com/imsweb/datagenerator/gui/StandaloneNaaccrDataGenerator.java

+85-117
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import java.io.IOException;
2626
import java.io.InputStream;
2727
import java.io.OutputStream;
28+
import java.nio.charset.StandardCharsets;
29+
import java.time.LocalDate;
2830
import java.util.regex.Matcher;
2931
import java.util.regex.Pattern;
3032

@@ -53,7 +55,6 @@
5355
import javax.swing.border.TitledBorder;
5456

5557
import org.apache.commons.io.IOUtils;
56-
import org.joda.time.LocalDate;
5758

5859
import com.imsweb.datagenerator.naaccr.NaaccrDataGeneratorOptions;
5960
import com.imsweb.layout.LayoutFactory;
@@ -121,18 +122,10 @@ public StandaloneNaaccrDataGenerator() {
121122
centerPnl.add(createControlsPanel());
122123
this.getContentPane().add(centerPnl, BorderLayout.CENTER);
123124

124-
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
125-
@Override
126-
public void uncaughtException(Thread t, final Throwable e) {
127-
SwingUtilities.invokeLater(new Runnable() {
128-
@Override
129-
public void run() {
130-
String msg = "An unexpected error happened, it is recommended to close the application.\n\n Error: " + (e.getMessage() == null ? "null access" : e.getMessage());
131-
JOptionPane.showMessageDialog(StandaloneNaaccrDataGenerator.this, msg, "Error", JOptionPane.ERROR_MESSAGE);
132-
}
133-
});
134-
}
135-
});
125+
Thread.setDefaultUncaughtExceptionHandler((t, e) -> SwingUtilities.invokeLater(() -> {
126+
String msg = "An unexpected error happened, it is recommended to close the application.\n\n Error: " + (e.getMessage() == null ? "null access" : e.getMessage());
127+
JOptionPane.showMessageDialog(StandaloneNaaccrDataGenerator.this, msg, "Error", JOptionPane.ERROR_MESSAGE);
128+
}));
136129

137130
this.addComponentListener(new ComponentAdapter() {
138131
@Override
@@ -149,7 +142,7 @@ private static String getVersion() {
149142
// this will make it work when running from the JAR file
150143
try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("DATA-GENERATOR-VERSION")) {
151144
if (is != null)
152-
version = IOUtils.readLines(is).get(0);
145+
version = IOUtils.readLines(is, StandardCharsets.UTF_8).get(0);
153146
}
154147
catch (IOException e) {
155148
version = null;
@@ -158,7 +151,7 @@ private static String getVersion() {
158151
// this will make it work when running from an IDE
159152
if (version == null) {
160153
try (FileInputStream is = new FileInputStream(System.getProperty("user.dir") + File.separator + "VERSION")) {
161-
version = IOUtils.readLines(is).get(0);
154+
version = IOUtils.readLines(is, StandardCharsets.UTF_8).get(0);
162155
}
163156
catch (IOException e) {
164157
version = null;
@@ -195,13 +188,10 @@ protected JPanel createOptionsPanel() {
195188
pathPnl.add(_targetFld);
196189
pathPnl.add(Box.createHorizontalStrut(10));
197190
JButton browseBtn = new JButton("Browse...");
198-
browseBtn.addActionListener(new ActionListener() {
199-
@Override
200-
public void actionPerformed(ActionEvent e) {
201-
if (_fileChooser.showDialog(StandaloneNaaccrDataGenerator.this, "Select") == JFileChooser.APPROVE_OPTION) {
202-
File file = new File(_targetFld.getText());
203-
_targetFld.setText(new File(_fileChooser.getSelectedFile(), file.getName()).getPath());
204-
}
191+
browseBtn.addActionListener(e -> {
192+
if (_fileChooser.showDialog(StandaloneNaaccrDataGenerator.this, "Select") == JFileChooser.APPROVE_OPTION) {
193+
File file = new File(_targetFld.getText());
194+
_targetFld.setText(new File(_fileChooser.getSelectedFile(), file.getName()).getPath());
205195
}
206196
});
207197
pathPnl.add(browseBtn);
@@ -215,12 +205,9 @@ public void actionPerformed(ActionEvent e) {
215205
formatPnl.add(new JLabel("Format:"));
216206
formatPnl.add(Box.createHorizontalStrut(5));
217207
_formatBox = new JComboBox<>(new String[] {_FORMAT_16_ABS, _FORMAT_16_INC, _FORMAT_15_ABS, _FORMAT_15_INC});
218-
_formatBox.addActionListener(new ActionListener() {
219-
@Override
220-
public void actionPerformed(ActionEvent e) {
221-
if (!_targetFld.getText().isEmpty())
222-
_targetFld.setText(fixTargetFile());
223-
}
208+
_formatBox.addActionListener(e -> {
209+
if (!_targetFld.getText().isEmpty())
210+
_targetFld.setText(fixTargetFile());
224211
});
225212
formatPnl.add(_formatBox);
226213
formatPnl.add(Box.createHorizontalStrut(15));
@@ -229,12 +216,9 @@ public void actionPerformed(ActionEvent e) {
229216
formatPnl.add(new JLabel("Compression:"));
230217
formatPnl.add(Box.createHorizontalStrut(5));
231218
_compressionBox = new JComboBox<>(new String[] {_COMPRESSION_NONE, _COMPRESSION_GZIP});
232-
_compressionBox.addActionListener(new ActionListener() {
233-
@Override
234-
public void actionPerformed(ActionEvent e) {
235-
if (!_targetFld.getText().isEmpty())
236-
_targetFld.setText(fixTargetFile());
237-
}
219+
_compressionBox.addActionListener(e -> {
220+
if (!_targetFld.getText().isEmpty())
221+
_targetFld.setText(fixTargetFile());
238222
});
239223
formatPnl.add(_compressionBox);
240224
filePnl.add(formatPnl);
@@ -352,79 +336,73 @@ protected JPanel createControlsPanel() {
352336
JPanel pnl = new JPanel();
353337
pnl.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
354338
_processBtn = new JButton("Create File");
355-
_processBtn.addActionListener(new ActionListener() {
356-
@Override
357-
public void actionPerformed(ActionEvent e) {
358-
359-
// get the target file
360-
File targetFile = new File(_targetFld.getText());
361-
if (targetFile.exists()) {
362-
String msg = "Target file already exists, are you sure you want to replace it?";
363-
int result = JOptionPane.showConfirmDialog(StandaloneNaaccrDataGenerator.this, msg, "Confirmation", JOptionPane.YES_NO_OPTION);
364-
if (result != JOptionPane.YES_OPTION)
365-
return;
366-
}
367-
368-
// get the number of records
369-
String numRecsRaw = _numRecFld.getText().trim();
370-
if (!numRecsRaw.matches("\\d+") || numRecsRaw.length() > 8) {
371-
String message = "Wrong format for number of records, needs to be 1 to 8 digits.";
372-
JOptionPane.showMessageDialog(StandaloneNaaccrDataGenerator.this, message, "Error", JOptionPane.ERROR_MESSAGE);
339+
_processBtn.addActionListener(e -> {
340+
341+
// get the target file
342+
File targetFile = new File(_targetFld.getText());
343+
if (targetFile.exists()) {
344+
String msg = "Target file already exists, are you sure you want to replace it?";
345+
int result = JOptionPane.showConfirmDialog(StandaloneNaaccrDataGenerator.this, msg, "Confirmation", JOptionPane.YES_NO_OPTION);
346+
if (result != JOptionPane.YES_OPTION)
373347
return;
374-
}
375-
int numRecords = Integer.parseInt(numRecsRaw);
376-
377-
// get the DX year range
378-
String dxYearRaw = _dxYearFld.getText();
379-
if (!dxYearRaw.matches("\\d{4}-\\d{4}") && !dxYearRaw.matches("\\d{4}")) {
380-
String message = "Wrong format for DX year, needs to be nnnn or nnnn-nnnn.";
381-
JOptionPane.showMessageDialog(StandaloneNaaccrDataGenerator.this, message, "Error", JOptionPane.ERROR_MESSAGE);
382-
return;
383-
}
384-
int dxStart, dxEnd;
385-
if (dxYearRaw.contains("-")) {
386-
dxStart = Integer.parseInt(dxYearRaw.split("-")[0]);
387-
dxEnd = Integer.parseInt(dxYearRaw.split("-")[1]);
388-
}
389-
else
390-
dxStart = dxEnd = Integer.parseInt(dxYearRaw);
391-
392-
// get the layout ID
393-
String layoutId = getFormatIdFromLabel((String)_formatBox.getSelectedItem());
394-
395-
// create the options
396-
NaaccrDataGeneratorOptions options = new NaaccrDataGeneratorOptions();
397-
try {
398-
if (_numTumPerPatFixed.isSelected())
399-
options.setNumTumorsPerPatient(Integer.valueOf(((String)_numTumPerPatBox.getSelectedItem()).trim()));
400-
options.setMinDxYear(dxStart);
401-
options.setMaxDxYear(dxEnd);
402-
String state = (String)_stateBox.getSelectedItem();
403-
if (state.matches("[A-Z][A-Z]"))
404-
options.setState(state);
405-
if (_vsBox.getSelectedItem().toString().toLowerCase().contains("coc"))
406-
options.setVitalStatusDeadValue("0");
407-
}
408-
catch (IllegalArgumentException exception) {
409-
JOptionPane.showMessageDialog(StandaloneNaaccrDataGenerator.this, exception.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
410-
return;
411-
}
412-
413-
// and finally, create and show a progress dialog
414-
final ProgressDialog progressDlg = new ProgressDialog(StandaloneNaaccrDataGenerator.this, targetFile, numRecords, layoutId, options);
415-
SwingUtilities.invokeLater(new Runnable() {
416-
@Override
417-
public void run() {
418-
// show the dialog in the center of the parent window
419-
Component parent = StandaloneNaaccrDataGenerator.this;
420-
Point center = new Point();
421-
center.setLocation(parent.getLocationOnScreen().x + parent.getWidth() / 2, parent.getLocationOnScreen().y + parent.getHeight() / 2);
422-
progressDlg.pack();
423-
progressDlg.setLocation(center.x - progressDlg.getWidth() / 2, center.y - progressDlg.getHeight() / 2);
424-
progressDlg.setVisible(true);
425-
}
426-
});
427348
}
349+
350+
// get the number of records
351+
String numRecsRaw = _numRecFld.getText().trim();
352+
if (!numRecsRaw.matches("\\d+") || numRecsRaw.length() > 8) {
353+
String message = "Wrong format for number of records, needs to be 1 to 8 digits.";
354+
JOptionPane.showMessageDialog(StandaloneNaaccrDataGenerator.this, message, "Error", JOptionPane.ERROR_MESSAGE);
355+
return;
356+
}
357+
int numRecords = Integer.parseInt(numRecsRaw);
358+
359+
// get the DX year range
360+
String dxYearRaw = _dxYearFld.getText();
361+
if (!dxYearRaw.matches("\\d{4}-\\d{4}") && !dxYearRaw.matches("\\d{4}")) {
362+
String message = "Wrong format for DX year, needs to be nnnn or nnnn-nnnn.";
363+
JOptionPane.showMessageDialog(StandaloneNaaccrDataGenerator.this, message, "Error", JOptionPane.ERROR_MESSAGE);
364+
return;
365+
}
366+
int dxStart, dxEnd;
367+
if (dxYearRaw.contains("-")) {
368+
dxStart = Integer.parseInt(dxYearRaw.split("-")[0]);
369+
dxEnd = Integer.parseInt(dxYearRaw.split("-")[1]);
370+
}
371+
else
372+
dxStart = dxEnd = Integer.parseInt(dxYearRaw);
373+
374+
// get the layout ID
375+
String layoutId = getFormatIdFromLabel((String)_formatBox.getSelectedItem());
376+
377+
// create the options
378+
NaaccrDataGeneratorOptions options = new NaaccrDataGeneratorOptions();
379+
try {
380+
if (_numTumPerPatFixed.isSelected())
381+
options.setNumTumorsPerPatient(Integer.valueOf(((String)_numTumPerPatBox.getSelectedItem()).trim()));
382+
options.setMinDxYear(dxStart);
383+
options.setMaxDxYear(dxEnd);
384+
String state1 = (String)_stateBox.getSelectedItem();
385+
if (state1.matches("[A-Z][A-Z]"))
386+
options.setState(state1);
387+
if (_vsBox.getSelectedItem().toString().toLowerCase().contains("coc"))
388+
options.setVitalStatusDeadValue("0");
389+
}
390+
catch (IllegalArgumentException exception) {
391+
JOptionPane.showMessageDialog(StandaloneNaaccrDataGenerator.this, exception.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
392+
return;
393+
}
394+
395+
// and finally, create and show a progress dialog
396+
final ProgressDialog progressDlg = new ProgressDialog(StandaloneNaaccrDataGenerator.this, targetFile, numRecords, layoutId, options);
397+
SwingUtilities.invokeLater(() -> {
398+
// show the dialog in the center of the parent window
399+
Component parent1 = StandaloneNaaccrDataGenerator.this;
400+
Point center = new Point();
401+
center.setLocation(parent1.getLocationOnScreen().x + parent1.getWidth() / 2, parent1.getLocationOnScreen().y + parent1.getHeight() / 2);
402+
progressDlg.pack();
403+
progressDlg.setLocation(center.x - progressDlg.getWidth() / 2, center.y - progressDlg.getHeight() / 2);
404+
progressDlg.setVisible(true);
405+
});
428406
});
429407
pnl.add(_processBtn);
430408
return pnl;
@@ -496,12 +474,7 @@ else if ("menu-about".equals(cmd)) {
496474
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
497475
Point center = new Point(screenSize.width / 2, screenSize.height / 2);
498476
dlg.setLocation(center.x - dlg.getWidth() / 2, center.y - dlg.getHeight() / 2);
499-
SwingUtilities.invokeLater(new Runnable() {
500-
@Override
501-
public void run() {
502-
dlg.setVisible(true);
503-
}
504-
});
477+
SwingUtilities.invokeLater(() -> dlg.setVisible(true));
505478
}
506479
}
507480

@@ -528,11 +501,6 @@ public static void main(String[] args) {
528501
Point center = new Point(screenSize.width / 2, screenSize.height / 2);
529502
frame.setLocation(center.x - frame.getWidth() / 2, center.y - frame.getHeight() / 2);
530503

531-
SwingUtilities.invokeLater(new Runnable() {
532-
@Override
533-
public void run() {
534-
frame.setVisible(true);
535-
}
536-
});
504+
SwingUtilities.invokeLater(() -> frame.setVisible(true));
537505
}
538506
}

src/main/java/com/imsweb/datagenerator/naaccr/NaaccrDataGeneratorOptions.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
*/
44
package com.imsweb.datagenerator.naaccr;
55

6+
import java.time.LocalDate;
67
import java.util.Arrays;
78
import java.util.Map;
89

9-
import org.joda.time.LocalDate;
10-
1110
public class NaaccrDataGeneratorOptions {
1211

1312
// if provided, each patient will have this number of tumors; otherwise a random distribution will be used.
@@ -122,7 +121,7 @@ public void setVitalStatusDeadValue(String vitalStatusDeadValue) {
122121
* If min DX year was defined, this will return the first day of that year
123122
*/
124123
public LocalDate getMinDxDate() {
125-
return _minDxYear == null ? LocalDate.now().minusYears(10) : new LocalDate(_minDxYear, 1, 1);
124+
return _minDxYear == null ? LocalDate.now().minusYears(10) : LocalDate.of(_minDxYear, 1, 1);
126125
}
127126

128127
/**
@@ -133,6 +132,6 @@ public LocalDate getMinDxDate() {
133132
public LocalDate getMaxDxDate() {
134133
if (_maxDxYear == null || _maxDxYear == LocalDate.now().getYear())
135134
return LocalDate.now();
136-
return new LocalDate(_maxDxYear, 12, 31);
135+
return LocalDate.of(_maxDxYear, 12, 31);
137136
}
138137
}

0 commit comments

Comments
 (0)