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

Reduce scope of members #825

Merged
merged 4 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private static class XFormParserWithBindEnhancements extends XFormParser {
private Document xmldoc;
private BaseFormParserForJavaRosa parser;

public XFormParserWithBindEnhancements(BaseFormParserForJavaRosa parser, Document form) {
private XFormParserWithBindEnhancements(BaseFormParserForJavaRosa parser, Document form) {
super(form);
this.xmldoc = form;
this.parser = parser;
Expand All @@ -215,17 +215,17 @@ private static synchronized final XFormParserWithBindEnhancements parseFormDefin
* The ODK Id that uniquely identifies the form
*/
public transient final FormDef rootJavaRosaFormDef;
protected final XFormParameters rootElementDefn;
private final XFormParameters rootElementDefn;
protected transient final TreeElement trueSubmissionElement;
protected transient final TreeElement submissionElement;
private transient final TreeElement submissionElement;
protected final XFormParameters submissionElementDefn;
protected final String base64RsaPublicKey;
private final String base64RsaPublicKey;
protected final boolean isFileEncryptedForm;
protected final boolean isNotUploadableForm;
protected final boolean isInvalidFormXmlns; // legacy 0.9.8 form
private final boolean isNotUploadableForm;
private final boolean isInvalidFormXmlns; // legacy 0.9.8 form
protected final String title;
protected final boolean isFieldEncryptedForm;
protected final String base64EncryptedFieldRsaPublicKey;
private final String base64EncryptedFieldRsaPublicKey;

/**
* The XForm definition in XML
Expand Down Expand Up @@ -526,7 +526,7 @@ private void printTreeElementInfo(TreeElement treeElement) {
+ " repeatable: " + treeElement.isRepeatable());
}

public String getTreeElementPath(AbstractTreeElement<?> e) {
private String getTreeElementPath(AbstractTreeElement<?> e) {
if (e == null)
return null;
String s = getTreeElementPath(e.getParent());
Expand Down Expand Up @@ -555,10 +555,6 @@ private List<Element> getBindingsForTreeElement(TreeElement treeElement) {
return (l);
}

public String getFormId() {
return rootElementDefn.formId;
}

/**
* Compare two XML files to assess their level of structural difference (if
* any).
Expand Down
6 changes: 3 additions & 3 deletions src/org/opendatakit/briefcase/export/ExportConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class ExportConfiguration {
private final OverridableBoolean removeGroupNames;
private final OverridableBoolean smartAppend;

public ExportConfiguration(Optional<String> exportFileName, Optional<Path> exportDir, Optional<Path> pemFile, DateRange dateRange, OverridableBoolean pullBefore, OverridableBoolean overwriteFiles, OverridableBoolean exportMedia, OverridableBoolean splitSelectMultiples, OverridableBoolean includeGeoJsonExport, OverridableBoolean removeGroupNames, OverridableBoolean smartAppend) {
private ExportConfiguration(Optional<String> exportFileName, Optional<Path> exportDir, Optional<Path> pemFile, DateRange dateRange, OverridableBoolean pullBefore, OverridableBoolean overwriteFiles, OverridableBoolean exportMedia, OverridableBoolean splitSelectMultiples, OverridableBoolean includeGeoJsonExport, OverridableBoolean removeGroupNames, OverridableBoolean smartAppend) {
this.exportFileName = exportFileName;
this.exportDir = exportDir;
this.pemFile = pemFile;
Expand Down Expand Up @@ -338,7 +338,7 @@ public int hashCode() {
}

public static class Builder {
public static final Consumer<String> NO_OP = __ -> { };
private static final Consumer<String> NO_OP = __ -> { };
private String exportFilename;
private Path exportDir;
private Path pemFile;
Expand Down Expand Up @@ -405,7 +405,7 @@ public ExportConfiguration build() {
public Builder setExportFilename(String fileName) {
return setExportFilename(Optional.ofNullable(fileName));
}

public Builder setExportFilename(Optional<String> fileName) {
exportFilename = fileName.orElse(null);
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/org/opendatakit/briefcase/export/FormDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static FormDefinition from(BriefcaseFormDefinition briefcaseFormDefinitio
briefcaseFormDefinition.getFormName(),
briefcaseFormDefinition.isFileEncryptedForm(),
// TODO Improve getting the FormDef out of the BriefcaseFormDefinition
new Model(briefcaseFormDefinition.getSubmissionElement(), getFormControls(briefcaseFormDefinition.formDefn.rootJavaRosaFormDef))
new Model(briefcaseFormDefinition.getSubmissionElement(), getFormControls(briefcaseFormDefinition.getFormDefn().rootJavaRosaFormDef))
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/org/opendatakit/briefcase/export/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* It can hold the root level model or any of its fields.
*/
class Model {
final TreeElement model;
private final TreeElement model;
private Map<String, QuestionDef> controls;

/**
Expand Down Expand Up @@ -339,7 +339,7 @@ enum ControlType {
* @param intControlType the int value of the requested DataType
* @return the related {@link ControlType} instance
*/
public static ControlType from(int intControlType) {
static ControlType from(int intControlType) {
for (ControlType ct : values()) {
if (ct.value == intControlType)
return ct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class BriefcaseFormDefinition implements IFormDefinition, Serializable {
private final File formFolder;
private final File revisedFormFile;
private boolean needsMediaUpdate;
public JavaRosaParserWrapper formDefn;
private JavaRosaParserWrapper formDefn;

private static String readFile(File formDefinitionFile) throws BadFormDefinition {
StringBuilder xmlBuilder = new StringBuilder();
Expand Down Expand Up @@ -303,6 +303,10 @@ public String toString() {
public File getFormDirectory() {
return formFolder;
}

public JavaRosaParserWrapper getFormDefn() {
return formDefn;
}

@Override
public String getFormName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public Preferences preferenceFactory(Class<?> node) {
}
};

public abstract Preferences preferenceFactory(Class<?> node);
protected abstract Preferences preferenceFactory(Class<?> node);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/org/opendatakit/briefcase/model/TerminationFuture.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void markAsCancelled(PushEvent.Cancel event) {
@EventSubscriber(eventClass = PullEvent.Cancel.class)
public void markAsCancelled(PullEvent.Cancel event) {
cancelled = true;
log.info("cancel requested: " + event.cause);
log.info("cancel requested: " + event.getCause());
}

public void reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
package org.opendatakit.briefcase.model;

public class UpdatedBriefcaseFormDefinitionEvent {
public final BriefcaseFormDefinition definition;
private final BriefcaseFormDefinition definition;

UpdatedBriefcaseFormDefinitionEvent(BriefcaseFormDefinition definition) {
this.definition = definition;
}

public BriefcaseFormDefinition getDefinition() {
return this.definition;
}
}
2 changes: 1 addition & 1 deletion src/org/opendatakit/briefcase/model/form/FormKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static Pair<String, String> getFormNameAndId(FormStatus formStatus) {
// We can't trust the form's title because JavaRosaParserWrapper strips illegal chars
// from it for some reason and then we can't use it to match any stored form metadata
BriefcaseFormDefinition formDef = (BriefcaseFormDefinition) formStatus.getFormDefinition();
XmlElement root = XmlElement.from(formDef.formDefn.xml);
XmlElement root = XmlElement.from(formDef.getFormDefn().xml);
String formName = root.findElement("head")
.flatMap(e -> e.findElement("title"))
.flatMap(XmlElement::maybeValue)
Expand Down
24 changes: 20 additions & 4 deletions src/org/opendatakit/briefcase/pull/PullEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,28 @@
public class PullEvent {

public static class Success extends PullEvent {
public final FormStatus form;
public final Optional<RemoteServer> remoteServer;
public final Optional<Cursor> lastCursor;
private final FormStatus form;
private final Optional<RemoteServer> remoteServer;
private final Optional<Cursor> lastCursor;

private Success(FormStatus form, Optional<RemoteServer> remoteServer, Optional<Cursor> lastCursor) {
this.form = form;
this.remoteServer = remoteServer;
this.lastCursor = lastCursor;
}

public FormStatus getForm() {
return form;
}

public Optional<RemoteServer> getRemoteServer() {
return remoteServer;
}

public Optional<Cursor> getLastCursor() {
return lastCursor;
}

public static Success of(FormStatus form) {
return new Success(form, Optional.empty(), Optional.empty());
}
Expand All @@ -53,11 +65,15 @@ public void ifRemoteServer(BiConsumer<FormStatus, RemoteServer> consumer) {
}

public static class Cancel extends PullEvent {
public final String cause;
private final String cause;

public Cancel(String cause) {
this.cause = cause;
}

public String getCause() {
return this.cause;
}
}

public static class CleanAllResumePoints extends PullEvent {
Expand Down
4 changes: 2 additions & 2 deletions src/org/opendatakit/briefcase/reused/http/CommonsHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ private <T> Response<T> uncheckedExecute(Request<T> request, Executor executor)
MultipartEntityBuilder bodyBuilder = MultipartEntityBuilder.create();
for (MultipartMessage part : request.multipartMessages)
bodyBuilder = bodyBuilder.addPart(
part.name,
new InputStreamBody(part.body, ContentType.create(part.contentType), part.attachmentName)
part.getName(),
new InputStreamBody(part.getBody(), ContentType.create(part.getContentType()), part.getAttachmentName())
);
body = bodyBuilder.build();
} else {
Expand Down
24 changes: 20 additions & 4 deletions src/org/opendatakit/briefcase/reused/http/MultipartMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import java.util.Objects;

public class MultipartMessage {
final String name;
final String contentType;
final String attachmentName;
final InputStream body;
private final String name;
private final String contentType;
private final String attachmentName;
private final InputStream body;

MultipartMessage(String name, String contentType, String attachmentName, InputStream body) {
this.name = name;
Expand All @@ -32,6 +32,22 @@ public class MultipartMessage {
this.body = body;
}

public String getName() {
return name;
}

public String getContentType() {
return contentType;
}

public String getAttachmentName() {
return attachmentName;
}

public InputStream getBody() {
return body;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

public class CentralServerDialog {
private static final Logger log = LoggerFactory.getLogger(CentralServerDialog.class);
final CentralServerDialogForm form;
private final CentralServerDialogForm form;
private final List<Consumer<CentralServer>> onConnectCallbacks = new ArrayList<>();

private CentralServerDialog(CentralServerDialogForm form, Test<CentralServer> serverTester) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static <T> TypeSafeMatcher<RequestSpy<T>> hasPartNames(String... parts) {
@Override
protected boolean matchesSafely(RequestSpy<T> item) {
List<String> partNames = item.request.multipartMessages
.stream().map(mm -> mm.name)
.stream().map(mm -> mm.getName())
.collect(toList());
return partNames.size() == parts.length
&& partNames.containsAll(Arrays.asList(parts));
Expand All @@ -77,7 +77,7 @@ public void describeTo(Description description) {
@Override
protected void describeMismatchSafely(RequestSpy<T> item, Description mismatchDescription) {
List<String> partNames = item.request.multipartMessages
.stream().map(mm -> mm.name)
.stream().map(mm -> mm.getName())
.collect(toList());
mismatchDescription.appendText("has parts with names ").appendValue(partNames);
}
Expand All @@ -90,9 +90,9 @@ public static <T> TypeSafeMatcher<RequestSpy<T>> hasPart(String name, String con
protected boolean matchesSafely(RequestSpy<T> item) {
return item.request.multipartMessages
.stream()
.anyMatch(mm -> mm.name.equals(name)
& mm.contentType.equals(contentType)
&& mm.attachmentName.equals(attachmentName));
.anyMatch(mm -> mm.getName().equals(name)
& mm.getContentType().equals(contentType)
&& mm.getAttachmentName().equals(attachmentName));
}

@Override
Expand Down