Skip to content
This repository was archived by the owner on Apr 16, 2022. It is now read-only.

Clean up unused members and functions #745

Merged
merged 15 commits into from
Jul 17, 2019
12 changes: 0 additions & 12 deletions src/org/opendatakit/briefcase/export/SubmissionMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ public Optional<OffsetDateTime> getSubmissionDate() {
return submissionDate;
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! This is done with Iso8601Helpers

* Fixes ISO8601-ish strings not in this form: 2018-05-13T17:32:57±00:00
*/
static String regularizeDateTime(String iso8601DateTime) {
// 2018-04-26T08:58:20.525Z
if (iso8601DateTime.endsWith("Z")) // Replace the Z with a zero offset
return iso8601DateTime.substring(0, iso8601DateTime.length() - 1) + "+00:00";

// 2018-05-13T17:32:57+00 Add the minutes if not present
return iso8601DateTime + (iso8601DateTime.length() - iso8601DateTime.lastIndexOf(":") == 3 ? "" : ":00");
}

/**
* Returns this submission's instance ID, which is taken from the &lt;instanceID&gt;
* element's value, or from the root node's "instanceID" attribute.
Expand Down
11 changes: 0 additions & 11 deletions src/org/opendatakit/briefcase/pull/PullEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Optional;
import java.util.function.BiConsumer;
import org.opendatakit.briefcase.model.FormStatus;
import org.opendatakit.briefcase.model.ServerConnectionInfo;
import org.opendatakit.briefcase.pull.aggregate.Cursor;
import org.opendatakit.briefcase.reused.transfer.RemoteServer;

Expand Down Expand Up @@ -61,16 +60,6 @@ public Cancel(String cause) {
}
}

public static class NewForm extends PullEvent {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

public final FormStatus form;
public final Optional<ServerConnectionInfo> transferSettings;

public NewForm(FormStatus form, ServerConnectionInfo transferSettings) {
this.form = form;
this.transferSettings = Optional.ofNullable(transferSettings);
}
}

public static class CleanAllResumePoints extends PullEvent {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@
import org.opendatakit.briefcase.reused.job.Job;
import org.opendatakit.briefcase.reused.job.RunnerStatus;
import org.opendatakit.briefcase.reused.transfer.AggregateServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PullFromAggregate {
public static final Logger log = LoggerFactory.getLogger(PullFromAggregate.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

private final Http http;
private final AggregateServer server;
private final BriefcasePreferences prefs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@
import org.opendatakit.briefcase.reused.job.RunnerStatus;
import org.opendatakit.briefcase.reused.transfer.CentralAttachment;
import org.opendatakit.briefcase.reused.transfer.CentralServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PullFromCentral {
public static final Logger log = LoggerFactory.getLogger(PullFromCentral.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

private final Http http;
private final CentralServer server;
private final Path briefcaseDir;
Expand Down
34 changes: 0 additions & 34 deletions src/org/opendatakit/briefcase/reused/UncheckedFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.UncheckedIOException;
import java.math.BigInteger;
import java.net.URI;
Expand Down Expand Up @@ -58,14 +57,6 @@ public class UncheckedFiles {
"contents unless explicitly directed to do so.\n";
private static final Logger log = LoggerFactory.getLogger(UncheckedFiles.class);

public static Path createTempFile(String prefix, String suffix, FileAttribute<?>... attrs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Probably only (was) used in tests

try {
return Files.createTempFile(prefix, suffix, attrs);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public static Path write(Path path, List<String> lines, OpenOption... options) {
return write(path, lines.stream(), options);
}
Expand Down Expand Up @@ -136,14 +127,6 @@ public static Stream<Path> walk(Path path, FileVisitOption... options) {
}
}

public static Path createTempDirectory(Path dir, String prefix, FileAttribute<?>... attrs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Probably only (was) used in tests

try {
return Files.createTempDirectory(dir, prefix, attrs);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public static Path createTempDirectory(String prefix, FileAttribute<?>... attrs) {
try {
return Files.createTempDirectory(prefix, attrs);
Expand Down Expand Up @@ -288,23 +271,6 @@ public static URI toURI(URL url) {
}
}

public static void append(String content, OutputStreamWriter outputStreamWriter) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Probably only (were) used in tests

try {
outputStreamWriter.append(content);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public static void close(OutputStreamWriter osw) {
try {
osw.flush();
osw.close();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public static Stream<Path> list(Path dir) {
try {
return Files.list(dir);
Expand Down
9 changes: 0 additions & 9 deletions src/org/opendatakit/briefcase/reused/http/HttpException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.opendatakit.briefcase.reused.http;

import org.opendatakit.briefcase.reused.BriefcaseException;
import org.opendatakit.briefcase.reused.http.response.Response;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


public class HttpException extends BriefcaseException {

Expand All @@ -28,12 +27,4 @@ public HttpException(String message) {
public HttpException(String message, Throwable cause) {
super(message, cause);
}

public HttpException(Response<?> response) {
super("HTTP Response status code " + response.getStatusCode());
}

public HttpException(Response<?> response, Throwable cause) {
super("HTTP Response status code " + response.getStatusCode(), cause);
}
}

This file was deleted.

1 change: 0 additions & 1 deletion src/org/opendatakit/briefcase/reused/job/JobsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public static JobsRunner launchAsync(Stream<Job<?>> jobs, Consumer<Throwable> on
return new JobsRunner(executor);
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

/**
* Run the provided job asynchronously and return an instance that
* will let the caller cancel the background process.
Expand Down
12 changes: 0 additions & 12 deletions src/org/opendatakit/briefcase/reused/transfer/AggregateServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import static org.opendatakit.briefcase.reused.UncheckedFiles.newInputStream;
import static org.opendatakit.briefcase.reused.http.RequestBuilder.get;
import static org.opendatakit.briefcase.reused.http.RequestBuilder.head;
import static org.opendatakit.briefcase.reused.http.RequestBuilder.url;

import java.io.InputStream;
import java.net.URL;
Expand All @@ -38,7 +37,6 @@
import org.opendatakit.briefcase.model.BriefcasePreferences;
import org.opendatakit.briefcase.model.FormStatus;
import org.opendatakit.briefcase.model.RemoteFormDefinition;
import org.opendatakit.briefcase.model.ServerConnectionInfo;
import org.opendatakit.briefcase.pull.aggregate.Cursor;
import org.opendatakit.briefcase.pull.aggregate.DownloadedSubmission;
import org.opendatakit.briefcase.reused.OptionalProduct;
Expand Down Expand Up @@ -70,16 +68,6 @@ public static AggregateServer normal(URL baseUrl) {
return new AggregateServer(baseUrl, Optional.empty());
}

public static AggregateServer from(ServerConnectionInfo sci) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return new AggregateServer(
url(sci.getUrl()),
OptionalProduct.all(
Optional.ofNullable(sci.getUsername()),
Optional.ofNullable(sci.getPassword()).map(String::new)
).map(Credentials::new)
);
}

public URL getBaseUrl() {
return baseUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,21 @@

public class ConfigurationPanel {
private final ConfigurationPanelForm form;
private final ConfigurationPanelMode mode;

private ConfigurationPanel(ExportConfiguration initialConfiguration, ConfigurationPanelForm form, ConfigurationPanelMode mode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

private ConfigurationPanel(ExportConfiguration initialConfiguration, ConfigurationPanelForm form) {
this.form = form;
this.mode = mode;

form.initialize(initialConfiguration);
}

static ConfigurationPanel overridePanel(ExportConfiguration initialConfiguration, boolean savePasswordsConsent, boolean hasTransferSettings) {
ConfigurationPanelMode mode = ConfigurationPanelMode.overridePanel(savePasswordsConsent, hasTransferSettings);
return new ConfigurationPanel(
initialConfiguration,
new ConfigurationPanelForm(mode),
mode
);
return new ConfigurationPanel(initialConfiguration, new ConfigurationPanelForm(mode));
}

static ConfigurationPanel defaultPanel(ExportConfiguration initialConfiguration, boolean savePasswordsConsent) {
ConfigurationPanelMode mode = ConfigurationPanelMode.defaultPanel(savePasswordsConsent);
return new ConfigurationPanel(
initialConfiguration,
new ConfigurationPanelForm(mode),
mode
);
return new ConfigurationPanel(initialConfiguration, new ConfigurationPanelForm(mode));
}

public ConfigurationPanelForm getForm() {
Expand All @@ -59,9 +49,4 @@ public void setEnabled(boolean enabled, boolean savePasswordsConsent) {
form.setEnabled(enabled);
form.changeMode(savePasswordsConsent);
}

public boolean isEmpty() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return form.getConfiguration().isEmpty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,6 @@ private void triggerOnChange() {
onChangeCallbacks.forEach(callback -> callback.accept(conf));
}

public ExportConfiguration getConfiguration() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Oh gosh, I don't know what I was thinking with this one xD

return null;
}

void changeMode(boolean savePasswordsConsent) {
mode.setSavePasswordsConsent(savePasswordsConsent);
mode.decorate(this, uiLocked);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ void decorate(ConfigurationPanelForm form, boolean uiLocked) {
form.removeGroupNamesOverrideField.setVisible(isOverridePanel);
}

boolean isOverridePanel() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return isOverridePanel;
}

boolean isExportDirCleanable() {
return isOverridePanel;
}
Expand Down
4 changes: 2 additions & 2 deletions src/org/opendatakit/briefcase/ui/reused/FileChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static FileChooser directory(Container parent, Optional<File> initialLocation, P

return isLinux() || isWindows()
? new SwingFileChooser(parent, fileChooser, filter, filterDescription)
: new NativeFileChooser(parent, buildFileDialog(parent, initialLocation, fileChooser), fileChooser, filter, filterDescription);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

: new NativeFileChooser(buildFileDialog(parent, initialLocation, fileChooser), fileChooser, filter, filterDescription);
}

static FileChooser file(Container parent, Optional<File> initialFile) {
Expand All @@ -92,7 +92,7 @@ static FileChooser file(Container parent, Optional<File> initialFile, Predicate<

return isLinux() || isWindows()
? new SwingFileChooser(parent, fileChooser, filter, filterDescription)
: new NativeFileChooser(parent, buildFileDialog(parent, initialFile, fileChooser), fileChooser, filter, filterDescription);
: new NativeFileChooser(buildFileDialog(parent, initialFile, fileChooser), fileChooser, filter, filterDescription);
}

static FileDialog buildFileDialog(Container parent, Optional<File> initialLocation, JFileChooser fileChooser) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static javax.swing.JFileChooser.FILES_ONLY;
import static org.opendatakit.briefcase.ui.reused.UI.errorMessage;

import java.awt.Container;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import java.awt.FileDialog;
import java.io.File;
import java.nio.file.Files;
Expand All @@ -29,14 +28,12 @@
import javax.swing.JFileChooser;

class NativeFileChooser implements FileChooser {
private Container parent;
private final FileDialog fileDialog;
private JFileChooser fileChooser;
private Predicate<File> filter;
private String filterDescription;

NativeFileChooser(Container parent, FileDialog fileDialog, JFileChooser fileChooser, Predicate<File> filter, String filterDescription) {
this.parent = parent;
NativeFileChooser(FileDialog fileDialog, JFileChooser fileChooser, Predicate<File> filter, String filterDescription) {
this.fileDialog = fileDialog;
this.fileChooser = fileChooser;
this.filter = filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ void addOption(T item) {
selectField.addItem(item);
}

public JPanel getContainer() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return container;
}

@SuppressWarnings("unchecked")
Optional<T> getSelectedOption() {
return Optional.ofNullable((T) selectField.getSelectedItem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ private void createUIComponents() {
// TODO: place custom component creation code here
}

public JComponent getContainer() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return container;
}

@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@
import org.opendatakit.briefcase.reused.transfer.CentralServer;
import org.opendatakit.briefcase.transfer.TransferForms;
import org.opendatakit.briefcase.ui.reused.transfer.sourcetarget.SourceOrTarget;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public interface PullSource<T> extends SourceOrTarget<T> {
Logger log = LoggerFactory.getLogger(PullSource.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


static PullSource<AggregateServer> aggregate(Http http, Consumer<PullSource> consumer) {
return new Aggregate(http, server -> http.execute(server.getFormListRequest()), "Data Viewer", consumer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@
import org.opendatakit.briefcase.reused.transfer.CentralServer;
import org.opendatakit.briefcase.transfer.TransferForms;
import org.opendatakit.briefcase.ui.reused.transfer.sourcetarget.SourceOrTarget;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public interface PushTarget<T> extends SourceOrTarget<T> {
Logger log = LoggerFactory.getLogger(PushTarget.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


static void clearSourcePrefs(BriefcasePreferences prefs) {
AggregateServer.clearStoredPrefs(prefs);
CentralServer.clearStoredPrefs(prefs);
Expand Down
Loading