Skip to content
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 @@ -45,7 +45,7 @@ public class FilingDocDocassembleJacksonDeserializer {

/** Parses a filing from the DA Json Object. Used by Deserializers that include filings. */
public static Optional<FilingDoc> fromNode(
JsonNode node, Map<String, PartyId> varToPartyId, boolean isLeadDoc, InfoCollector collector)
JsonNode node, Map<String, PartyId> varToPartyId, int sequenceNum, InfoCollector collector)
throws FilingError {
if (!node.isObject()) {
FilingError err =
Expand Down Expand Up @@ -200,7 +200,7 @@ public static Optional<FilingDoc> fromNode(
courtesyCopies,
preliminaryCopies,
action,
isLeadDoc));
sequenceNum));
}

private static Optional<FilingAttachment> getAttachment(JsonNode node, InfoCollector collector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,7 @@ private static List<FilingDoc> extractFilingDocs(
collector.pushAttributeStack("al_court_bundle.elements[" + i + "]");
Optional<FilingDoc> maybeDoc =
FilingDocDocassembleJacksonDeserializer.fromNode(
elems.get(i),
varToPartyId,
i == 0, // the 0th doc is the Lead doc by default
collector);
elems.get(i), varToPartyId, filingDocs.size(), collector);
collector.popAttributeStack();
maybeDoc.ifPresent(
doc -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public CourtLocationInfo() {
this.showdamageamount = false;
this.allowchargeupdate = false;
this.allowpartyid = false;
this.allowserviceoninitial = BoolOrDefault.DEFAULT;
}

public CourtLocationInfo(ResultSet rs) throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public DataFieldRow(
this.location = location;
}

// Used for testing.
public DataFieldRow(
String code, String name, boolean isvisible, boolean isrequired, String location) {
this(code, name, isvisible, isrequired, "", "", "", "", "", "", false, location);
}

/**
* According to the Tyler docs, if some data field is not defined, it defaults to isVisible=False,
* and isRequired=False. Everything else will be empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public class FilingDoc {
private final List<OptionalService> optServices;
private final Optional<FilingAction> filingAction;

private final boolean isLeadDoc;
private final int sequenceNum;

public FilingDoc(
Optional<String> filingCode,
List<PartyId> filingPartyIds,
NonEmptyList<FilingAttachment> filingAttachments,
boolean isLeadDoc) {
int sequenceNum) {
this(
filingCode,
"",
Expand All @@ -59,7 +59,7 @@ public FilingDoc(
List.of(),
List.of(),
Optional.empty(),
isLeadDoc);
sequenceNum);
}

/** Full constructor, in all it's mess. */
Expand All @@ -77,7 +77,7 @@ public FilingDoc(
List<String> courtesyCopies,
List<String> preliminaryCopies,
Optional<FilingAction> filingAction,
boolean isLeadDoc) {
int sequenceNum) {
this.filingCode = filingCode;
this.userProvidedDescription = NonEmptyString.create(userProvidedDescription);
this.filingReferenceNum = filingReferenceNum;
Expand All @@ -93,7 +93,7 @@ public FilingDoc(
this.courtesyCopies = courtesyCopies;
this.preliminaryCopies = preliminaryCopies;
this.filingAction = filingAction;
this.isLeadDoc = isLeadDoc;
this.sequenceNum = sequenceNum;
}

/** Returns the sum of all of the attachment files lengths. */
Expand All @@ -117,8 +117,8 @@ public UUID getId() {
return id;
}

public boolean isLead() {
return isLeadDoc;
public int sequenceNum() {
return sequenceNum;
}

public List<PartyId> getFilingPartyIds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,6 @@ private PersonNameTextType checkName(

public JAXBElement<DocumentType> filingDocToXml(
FilingDoc doc,
int sequenceNum,
boolean isInitialFiling,
CaseCategory caseCategory,
CaseType motionType,
Expand Down Expand Up @@ -780,7 +779,7 @@ public JAXBElement<DocumentType> filingDocToXml(
}
}

docType.setDocumentSequenceID(Ecf4Helper.convertString(Integer.toString(sequenceNum)));
docType.setDocumentSequenceID(Ecf4Helper.convertString(Integer.toString(doc.sequenceNum())));

DocumentMetadataType metadata = ecfOf.createDocumentMetadataType();
metadata.setRegisterActionDescriptionText(Ecf4Helper.convertText(filing.code));
Expand Down Expand Up @@ -968,7 +967,7 @@ public JAXBElement<DocumentType> filingDocToXml(
docType.getDocumentRendition().add(rendition);
docType.setId(doc.getIdString());

if (doc.isLead()) {
if (doc.sequenceNum() == 0) { // default to the first doc being the lead one.
return tylerObjFac.createFilingLeadDocument(docType);
} else {
return tylerObjFac.createFilingConnectedDocument(docType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ private CoreMessageAndNames prepareFiling(
JAXBElement<DocumentType> result =
serializer.filingDocToXml(
filingDoc,
seqNum,
isInitialFiling,
allCodes.cat,
allCodes.type,
Expand All @@ -430,7 +429,7 @@ private CoreMessageAndNames prepareFiling(
collector);
collector.popAttributeStack();
filingIdToObj.put(filingDoc.getIdString(), result.getValue());
if (filingDoc.isLead()) {
if (filingDoc.sequenceNum() == 0) {
cfm.getFilingLeadDocument().add(result);
} else {
cfm.getFilingConnectedDocument().add(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.suffolk.litlab.efsp.model.FilingDoc;
import edu.suffolk.litlab.efsp.model.PartyId;
import edu.suffolk.litlab.efsp.utils.FailFastCollector;
import edu.suffolk.litlab.efsp.utils.FilingError;
Expand All @@ -19,7 +18,6 @@
import java.time.format.DateTimeParseException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
Expand All @@ -35,7 +33,6 @@ public class FilingDocDocassembleJacksonDeserializerTest {

// TODO: more tests FilingAttachment separately, if possible

Optional<FilingDoc> doc;
InfoCollector collector;
Map<String, PartyId> varToPartyId;

Expand All @@ -49,19 +46,19 @@ public void setUp() {
public void testWeirdJsonShouldBeEmpty()
throws JsonMappingException, JsonProcessingException, FilingError {
ObjectMapper m = new ObjectMapper();
assertThatThrownBy(() -> fromNode(m.readTree("null"), varToPartyId, true, collector))
assertThatThrownBy(() -> fromNode(m.readTree("null"), varToPartyId, 0, collector))
.isInstanceOf(FilingError.class);
assertThatThrownBy(() -> fromNode(m.readTree("[]"), varToPartyId, true, collector))
assertThatThrownBy(() -> fromNode(m.readTree("[]"), varToPartyId, 0, collector))
.isInstanceOf(FilingError.class);
doc = fromNode(m.readTree("{}"), varToPartyId, true, collector);
var doc = fromNode(m.readTree("{}"), varToPartyId, 0, collector);
assertThat(doc).isEmpty();
}

// Aka, the old style
@Test
public void noAttachmentsShouldLoadDocument() throws FilingError, IOException {
JsonNode node = readFile("old_style_doc.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
var attachments = doc.get().getFilingAttachments();
assertThat(attachments.length()).isEqualTo(1);
Expand All @@ -71,8 +68,28 @@ public void noAttachmentsShouldLoadDocument() throws FilingError, IOException {
@Test
public void oneAttachmentShouldLoadDocument() throws FilingError, IOException {
JsonNode node = readFile("one_attachment.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var maybeDoc =
FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(maybeDoc).isPresent();
var doc = maybeDoc.get();
assertThat(doc.sequenceNum()).isEqualTo(0);
var attachments = doc.getFilingAttachments();
assertThat(attachments.length()).isEqualTo(1);
assertThat(attachments.head().getDocumentTypeFormatStandardName()).isEqualTo("6586");
var parties = doc.getFilingPartyIds();
assertThat(parties.size()).isEqualTo(1);
assertThat(parties.get(0).isNewInCurrentFiling()).isTrue();
assertThat(doc.getDescription()).isPresent();
assertThat(doc.getDescription().get().get())
.isEqualTo("The Motion to Stay Eviction for Bob Ma");
}

@Test
public void oneAttachmentAsSecondSequenceShouldLoadDocument() throws FilingError, IOException {
JsonNode node = readFile("one_attachment.json");
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 2, collector);
assertThat(doc).isPresent();
assertThat(doc.get().sequenceNum()).isEqualTo(2);
var attachments = doc.get().getFilingAttachments();
assertThat(attachments.length()).isEqualTo(1);
assertThat(attachments.head().getDocumentTypeFormatStandardName()).isEqualTo("6586");
Expand All @@ -84,7 +101,7 @@ public void oneAttachmentShouldLoadDocument() throws FilingError, IOException {
@Test
public void partyIdNotPresent() throws IOException, FilingError {
JsonNode node = readFile("one_attachment.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, Map.of(), true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, Map.of(), 0, collector);
assertThat(doc).isPresent();
var parties = doc.get().getFilingPartyIds();
assertThat(parties.size()).isEqualTo(1);
Expand All @@ -94,7 +111,7 @@ public void partyIdNotPresent() throws IOException, FilingError {
@Test
public void oneEnabledOneDisabledShouldLoadOneAttachment() throws FilingError, IOException {
JsonNode node = readFile("one_enabled_one_disabled.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
var attachments = doc.get().getFilingAttachments();
assertThat(attachments.length()).isEqualTo(1);
Expand All @@ -104,14 +121,14 @@ public void oneEnabledOneDisabledShouldLoadOneAttachment() throws FilingError, I
@Test
public void noEnabledShouldFilingError() throws IOException, FilingError {
JsonNode node = readFile("fail_no_enabled_attachment.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).as("Document shouldn't have parsed").isEmpty();
}

@Test
public void shouldFallbackToParentDocIfNoEnabled() throws FilingError, IOException {
JsonNode node = readFile("fallback_to_upper_doc.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
var attachments = doc.get().getFilingAttachments();
assertThat(attachments.length()).isEqualTo(1);
Expand All @@ -122,7 +139,7 @@ public void shouldFallbackToParentDocIfNoEnabled() throws FilingError, IOExcepti
@Test
public void noDocTypesShouldBeEmptyStrings() throws IOException, FilingError {
JsonNode node = readFile("fail_missing_doc_types.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
var attachments = doc.get().getFilingAttachments();
assertThat(attachments.length()).isEqualTo(1);
Expand All @@ -132,7 +149,7 @@ public void noDocTypesShouldBeEmptyStrings() throws IOException, FilingError {
@Test
public void twoAttachmentsShouldLoadTwoAttachments() throws FilingError, IOException {
JsonNode node = readFile("two_attachments.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
var attachments = doc.get().getFilingAttachments();
assertThat(attachments.length()).isEqualTo(2);
Expand All @@ -146,7 +163,7 @@ public void twoAttachmentsShouldLoadTwoAttachments() throws FilingError, IOExcep
@Test
public void hasOptionalServicesShouldParse() throws FilingError, IOException {
JsonNode node = readFile("has_optional_services.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
var optionalServices = doc.get().getOptionalServices();
assertThat(optionalServices).hasSize(1);
Expand All @@ -157,7 +174,7 @@ public void hasOptionalServicesShouldParse() throws FilingError, IOException {
public void filingActionShouldAlwaysParse() throws IOException, FilingError {
for (var emptyData : List.of("null", "\"\"", "\"clearly_wrong\"")) {
JsonNode node = readTemplate("template_filing_action.json", emptyData);
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
assertThat(doc.get().getFilingAction()).isEmpty();
}
Expand All @@ -169,7 +186,7 @@ public void filingActionShouldAlwaysParse() throws IOException, FilingError {
"\"e_file_and_serve\"",
"\"serve\"")) {
JsonNode node = readTemplate("template_filing_action.json", data);
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
assertThat(doc.get().getFilingAction()).isPresent();
}
Expand All @@ -178,7 +195,7 @@ public void filingActionShouldAlwaysParse() throws IOException, FilingError {
@Test
public void testTylerMergeAttachments() throws IOException, FilingError {
JsonNode node = readFile("tyler_merge_attachments.json");
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
var attachments = doc.get().getFilingAttachments();
assertThat(attachments.length()).isEqualTo(1);
Expand All @@ -202,7 +219,8 @@ record InputSaved(String dateInput, String savedDate) {}
// TODO: weird behavior: local date parses based on server's timezone? Should fix
new InputSaved("\"2024-02-29T01:19:00.123Z\"", "2024-02-28"))) {
JsonNode node = readTemplate(INPUT_FILE, testData.dateInput);
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc =
FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
assertThat(doc.get().getDueDate()).isPresent();
assertThat(doc.get().getDueDate().get()).isEqualTo(testData.savedDate);
Expand All @@ -217,7 +235,8 @@ public void nonTextDueDateShouldBeEmpty() throws IOException, FilingError {
)) { // TODO(brycew): Should also include an empty and blank string, but those error
// right now
JsonNode node = readTemplate(INPUT_FILE, emptyData);
doc = FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, true, collector);
var doc =
FilingDocDocassembleJacksonDeserializer.fromNode(node, varToPartyId, 0, collector);
assertThat(doc).isPresent();
assertThat(doc.get().getDueDate()).isEmpty();
}
Expand All @@ -238,7 +257,7 @@ public void invalidDueDateShouldThrow() throws IOException, FilingError {
assertThatThrownBy(
() ->
FilingDocDocassembleJacksonDeserializer.fromNode(
node, varToPartyId, true, collector))
node, varToPartyId, 0, collector))
.withFailMessage("Failed on %s", badData)
.isInstanceOf(DateTimeParseException.class);
}
Expand All @@ -262,7 +281,7 @@ public void testMalformedDataUrlShouldThrow() throws IOException {
assertThatThrownBy(
() ->
FilingDocDocassembleJacksonDeserializer.fromNode(
node, varToPartyId, true, collector))
node, varToPartyId, 0, collector))
.withFailMessage("Using %s", badData)
.isInstanceOf(FilingError.class);
}
Expand Down
Loading
Loading