Skip to content

Commit e415247

Browse files
Merge pull request #238 from regulaforensics/develop
Develop -> Stable
2 parents ff79bda + fab6b37 commit e415247

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

client/src/main/generated/com/regula/documentreader/webclient/model/ProcessParams.java

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ public class ProcessParams {
129129
@javax.annotation.Nullable
130130
private List<TextFieldType> fieldTypesFilter;
131131

132+
public static final String SERIALIZED_NAME_FIELD_TYPES_IGNORE_FILTER = "fieldTypesIgnoreFilter";
133+
134+
@SerializedName(SERIALIZED_NAME_FIELD_TYPES_IGNORE_FILTER)
135+
@javax.annotation.Nullable
136+
private List<TextFieldType> fieldTypesIgnoreFilter;
137+
132138
public static final String SERIALIZED_NAME_DATE_FORMAT = "dateFormat";
133139

134140
@SerializedName(SERIALIZED_NAME_DATE_FORMAT)
@@ -769,8 +775,11 @@ public ProcessParams addFieldTypesFilterItem(TextFieldType fieldTypesFilterItem)
769775
}
770776

771777
/**
772-
* List of text field types to extract. If empty, all text fields from template will be extracted.
773-
* Narrowing the list can shorten processing time. Empty by default.
778+
* If a document contains Visual zone, you can set the list of field types to extract. In this
779+
* case, other fields are skipped during the processing, i.e. document recognition becomes faster.
780+
* This filter is not applicable to the MRZ, barcode or RFID. If the fieldTypesFilter is empty,
781+
* all fields are extracted. Empty by default. If fieldTypesFilter and fieldTypesIgnoreFilter are
782+
* used simultaneously, fieldTypesFilter takes priority.
774783
*
775784
* @return fieldTypesFilter
776785
*/
@@ -783,6 +792,40 @@ public void setFieldTypesFilter(@javax.annotation.Nullable List<TextFieldType> f
783792
this.fieldTypesFilter = fieldTypesFilter;
784793
}
785794

795+
public ProcessParams fieldTypesIgnoreFilter(
796+
@javax.annotation.Nullable List<TextFieldType> fieldTypesIgnoreFilter) {
797+
this.fieldTypesIgnoreFilter = fieldTypesIgnoreFilter;
798+
return this;
799+
}
800+
801+
public ProcessParams addFieldTypesIgnoreFilterItem(TextFieldType fieldTypesIgnoreFilterItem) {
802+
if (this.fieldTypesIgnoreFilter == null) {
803+
this.fieldTypesIgnoreFilter = new ArrayList<>();
804+
}
805+
this.fieldTypesIgnoreFilter.add(fieldTypesIgnoreFilterItem);
806+
return this;
807+
}
808+
809+
/**
810+
* If a document contains a Visual zone, you can specify a list of field types that should be
811+
* excluded from extraction. All field types listed in this array are skipped during processing,
812+
* while the remaining fields are recognized. This filter is not applicable to the MRZ, barcode or
813+
* RFID. If the fieldTypesIgnoreFilter is empty, all fields are extracted. Empty by default. If
814+
* fieldTypesFilter and fieldTypesIgnoreFilter are used simultaneously, fieldTypesFilter takes
815+
* priority.
816+
*
817+
* @return fieldTypesIgnoreFilter
818+
*/
819+
@javax.annotation.Nullable
820+
public List<TextFieldType> getFieldTypesIgnoreFilter() {
821+
return fieldTypesIgnoreFilter;
822+
}
823+
824+
public void setFieldTypesIgnoreFilter(
825+
@javax.annotation.Nullable List<TextFieldType> fieldTypesIgnoreFilter) {
826+
this.fieldTypesIgnoreFilter = fieldTypesIgnoreFilter;
827+
}
828+
786829
public ProcessParams dateFormat(@javax.annotation.Nullable String dateFormat) {
787830
this.dateFormat = dateFormat;
788831
return this;
@@ -1902,6 +1945,7 @@ public boolean equals(Object o) {
19021945
&& Objects.equals(
19031946
this.generateDoublePageSpreadImage, processParams.generateDoublePageSpreadImage)
19041947
&& Objects.equals(this.fieldTypesFilter, processParams.fieldTypesFilter)
1948+
&& Objects.equals(this.fieldTypesIgnoreFilter, processParams.fieldTypesIgnoreFilter)
19051949
&& Objects.equals(this.dateFormat, processParams.dateFormat)
19061950
&& Objects.equals(this.measureSystem, processParams.measureSystem)
19071951
&& Objects.equals(this.imageDpiOutMax, processParams.imageDpiOutMax)
@@ -1977,6 +2021,7 @@ public int hashCode() {
19772021
doublePageSpread,
19782022
generateDoublePageSpreadImage,
19792023
fieldTypesFilter,
2024+
fieldTypesIgnoreFilter,
19802025
dateFormat,
19812026
measureSystem,
19822027
imageDpiOutMax,
@@ -2057,6 +2102,9 @@ public String toString() {
20572102
.append(toIndentedString(generateDoublePageSpreadImage))
20582103
.append("\n");
20592104
sb.append(" fieldTypesFilter: ").append(toIndentedString(fieldTypesFilter)).append("\n");
2105+
sb.append(" fieldTypesIgnoreFilter: ")
2106+
.append(toIndentedString(fieldTypesIgnoreFilter))
2107+
.append("\n");
20602108
sb.append(" dateFormat: ").append(toIndentedString(dateFormat)).append("\n");
20612109
sb.append(" measureSystem: ").append(toIndentedString(measureSystem)).append("\n");
20622110
sb.append(" imageDpiOutMax: ").append(toIndentedString(imageDpiOutMax)).append("\n");
@@ -2177,6 +2225,7 @@ private String toIndentedString(Object o) {
21772225
"doublePageSpread",
21782226
"generateDoublePageSpreadImage",
21792227
"fieldTypesFilter",
2228+
"fieldTypesIgnoreFilter",
21802229
"dateFormat",
21812230
"measureSystem",
21822231
"imageDpiOutMax",
@@ -2302,6 +2351,15 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
23022351
"Expected the field `fieldTypesFilter` to be an array in the JSON string but got `%s`",
23032352
jsonObj.get("fieldTypesFilter").toString()));
23042353
}
2354+
// ensure the optional json data is an array if present
2355+
if (jsonObj.get("fieldTypesIgnoreFilter") != null
2356+
&& !jsonObj.get("fieldTypesIgnoreFilter").isJsonNull()
2357+
&& !jsonObj.get("fieldTypesIgnoreFilter").isJsonArray()) {
2358+
System.err.println(
2359+
String.format(
2360+
"Expected the field `fieldTypesIgnoreFilter` to be an array in the JSON string but got `%s`",
2361+
jsonObj.get("fieldTypesIgnoreFilter").toString()));
2362+
}
23052363
if ((jsonObj.get("dateFormat") != null && !jsonObj.get("dateFormat").isJsonNull())
23062364
&& !jsonObj.get("dateFormat").isJsonPrimitive()) {
23072365
System.err.println(

client/src/main/java/com/regula/documentreader/webclient/model/ext/RecognitionResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public OneCandidate documentType() {
114114
return documentType(defaultPageIdx);
115115
}
116116

117+
@Nullable
117118
public OneCandidate documentType(int pageIdx) {
118119
ChosenDocumentTypeResult result = getResult(Result.DOCUMENT_TYPE, pageIdx);
119120
if (result != null) {
@@ -122,6 +123,7 @@ public OneCandidate documentType(int pageIdx) {
122123
return null;
123124
}
124125

126+
@Nullable
125127
public <R> R resultByType(Result type) {
126128
for (ResultItem item : originalResponse.getContainerList().getList()) {
127129
if (item.getResultType() == type) {
@@ -131,6 +133,7 @@ public <R> R resultByType(Result type) {
131133
return null;
132134
}
133135

136+
@Nullable
134137
public <R> R getResult(Result type, int page_idx) {
135138
for (ResultItem item : originalResponse.getContainerList().getList()) {
136139
if (item.getResultType() == type && item.getPageIdx() == page_idx) {
@@ -140,6 +143,7 @@ public <R> R getResult(Result type, int page_idx) {
140143
return null;
141144
}
142145

146+
@Nullable
143147
public <R> List<R> resultsByType(Result type) {
144148
List<R> results = new ArrayList<>();
145149
for (ResultItem item : originalResponse.getContainerList().getList()) {

0 commit comments

Comments
 (0)