Initial commit
This commit is contained in:
commit
4cd5a979c8
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Ignore Gradle build output directory
|
||||
build
|
||||
bin
|
||||
.gradle/
|
||||
src/auto/
|
||||
.settings/
|
||||
.classpath
|
||||
.project
|
||||
src/main/resources/static
|
||||
gradlew
|
||||
gradlew.bat
|
||||
.idea/
|
||||
gradle/wrapper/gradle-wrapper.jar
|
||||
gradle/wrapper/gradle-wrapper.properties
|
||||
dependencies.gradle
|
||||
/idcore.tar
|
||||
/VERSION
|
51
build.gradle
Normal file
51
build.gradle
Normal file
@ -0,0 +1,51 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '3.1.1'
|
||||
id 'io.spring.dependency-management' version '1.0.7.RELEASE'
|
||||
}
|
||||
|
||||
|
||||
if (file('dependencies.gradle').exists())
|
||||
apply from: 'dependencies.gradle'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
sourceSets.main.java.srcDirs += 'src/auto/java'
|
||||
sourceSets.main.resources.srcDirs += 'src/auto/resources'
|
||||
|
||||
dependencies {
|
||||
implementation group: 'com.machinezoo.sourceafis', name: 'sourceafis', version: '3.11.0'
|
||||
|
||||
implementation 'com.cedarsoftware:json-io:4.13.0'
|
||||
implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
|
||||
implementation 'org.apache.logging.log4j:log4j-api:2.20.0'
|
||||
implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.20.0'
|
||||
|
||||
implementation 'jakarta.servlet:jakarta.servlet-api:6.0.0'
|
||||
implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: '2.1.1'
|
||||
|
||||
|
||||
implementation "org.keycloak:keycloak-spring-boot-starter:21.1.2"
|
||||
|
||||
implementation group: 'org.bouncycastle', name: 'bcpg-fips', version: '1.0.7.1'
|
||||
implementation group: 'org.bouncycastle', name: 'bcpkix-fips', version: '1.0.7'
|
||||
|
||||
implementation "org.springframework.boot:spring-boot-starter-security:3.1.1"
|
||||
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-jose', version: '6.1.1'
|
||||
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-resource-server', version: '6.1.1'
|
||||
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||
|
||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||
if (file('dependencies.gradle').exists())
|
||||
implementation rootProject.ext.softomatonDependencies
|
||||
}
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "io.grpc:grpc-bom:1.48.0"
|
||||
}
|
||||
}
|
10
settings.gradle
Normal file
10
settings.gradle
Normal file
@ -0,0 +1,10 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
if (settings.hasProperty("repo"))
|
||||
maven {
|
||||
url repo
|
||||
}
|
||||
|
||||
}
|
||||
}
|
281
src/main/java/systems/archide/core/RestEndpoints.java
Normal file
281
src/main/java/systems/archide/core/RestEndpoints.java
Normal file
@ -0,0 +1,281 @@
|
||||
package systems.archide.core;
|
||||
|
||||
import com.cocentris.spring.rest.security.EndpointsPermissions;
|
||||
|
||||
public class RestEndpoints {
|
||||
public final static String REGISTRAR = "REGISTRAR";
|
||||
public final static String DIGITALIZER = "DIGITALIZER";
|
||||
public final static String CLERK = "CLERK";
|
||||
public final static String RV4_MIGRATION_TOOL = "RV4_MIGRATION_TOOL";
|
||||
public final static String E_ID_SERVER = "E_ID_SERVER";
|
||||
public final static String VAN_ELECT = "VAN_ELECT";
|
||||
|
||||
static final String READ_CIVIL_STATUS_MTLB_ENDPOINT = "/civil-status-mtlb/[0-9]+";
|
||||
static final String SEARCH_CIVIL_STATUS_MTLB_ENDPOINT = "/civil-status-mtlb/search-by-mtlb-type-and-status/";
|
||||
static final String COUNT_CIVIL_STATUS_MTLB_ENDPOINT = "/civil-status-mtlb/count/search-by-mtlb-type-and-status/";
|
||||
static final String CREATE_CIVIL_STATUS_MTLB_ENDPOINT = "/apply/create-civil-status-mtlb";
|
||||
static final String UPDATE_CIVIL_STATUS_MTLB_ENDPOINT = "/civil-status-mtlb";
|
||||
static final String CIVIL_STATUS_MTLB_TAG = "/civil-status-mtlb-tag/search/";
|
||||
static final String CIVIL_STATUS_MTLB_PENDING_UPDATE = "/civil-status-mtlb/pending/update";
|
||||
static final String CIVIL_STATUS_MTLB_PENDING_REJECT = "/civil-status-mtlb/pending/reject";
|
||||
static final String CIVIL_STATUS_MTLB_READY_APPROVE = "/civil-status-mtlb/ready/approve";
|
||||
static final String CIVIL_STATUS_MTLB_READY_REJECT = "/civil-status-mtlb/ready/reject";
|
||||
static final String CIVIL_STATUS_MTLB_ATTACHMENT_ENDPOINT = "/civil-status-mtlb-attachment/civil-status-mtlb/join/civil-status-mtlb-id";
|
||||
|
||||
static final String READ_VITAL_RECORD_ATTACHMENT_ENDPOINT = "/vital-record-attachment/[0-9]+/.*";
|
||||
|
||||
static final String SEARCH_RV4_BIRTH_MTLB_ENDPOINT = "/rvfour-birth-mtlb/search-by-mtlb-type-and-status/";
|
||||
static final String COUNT_RV4_BIRTH_MTLB_ENDPOINT = "/rvfour-birth-mtlb/count/search-by-mtlb-type-and-status/";
|
||||
static final String READ_RV4_BIRTH_MTLB_ENDPOINT = "/rvfour-birth-mtlb/[0-9]+";
|
||||
static final String SEARCH_RV4_BIRTH_MTLB_TAG_ENDPOINT = "/rvfour-birth-mtlb-tag/search/";
|
||||
|
||||
static final String CREATE_GEO_DATA_ENDPOINT = "/geo-data-service/save-by-area-id";
|
||||
|
||||
static final String CREATE_ID_MTLB_ENDPOINT = "/apply/create-id-mtlb";
|
||||
static final String UPDATE_ID_MTLB_ENDPOINT = "/id-mtlb";
|
||||
static final String READ_ID_MTLB_ENDPOINT = "/id-mtlb/[0-9]+";
|
||||
static final String ID_MTLB_TAG = "/id-mtlb-tag/search/";
|
||||
static final String ID_MTLB_PENDING_UPDATE = "/id-mtlb/pending/update";
|
||||
static final String ID_MTLB_PENDING_REJECT = "/id-mtlb/pending/reject";
|
||||
static final String SEARCH_ID_MTLB_ENDPOINT = "/id-mtlb/search-by-id-mtlb-type-and-status/";
|
||||
static final String COUNT_ID_MTLB_ENDPOINT = "/id-mtlb/count/search-by-id-mtlb-type-and-status/";
|
||||
|
||||
static final String CREATE_DIGITALIZATION_MTLB_ENDPOINT = "/apply/create-digitalization-mtlb";
|
||||
static final String ATTACH_DIGITALIZATION_MTLB = "/apply/attach-digitalization-mtlb";
|
||||
|
||||
static final String SEARCH_UNION_MTLB = "/union-mtlb/search-by-union-mtlb-type-and-status/";
|
||||
static final String COUNT_UNION_MTLB = "/union-mtlb/count/search-by-union-mtlb-type-and-status/";
|
||||
static final String READ_VITAL_RECORD_ENDPOINT = "/vital-record/[0-9]+";
|
||||
static final String SEARCH_VITAL_RECORD_ENDPOINT = "/vital-record/search-by-active/";
|
||||
static final String COUNT_VITAL_RECORD_ENDPOINT = "/vital-record/count/search-by-active/";
|
||||
static final String SEARCH_VITAL_RECORD_ENDPOINT_TAG = "/vital-record-tag/search/";
|
||||
|
||||
static final String READ_FACE_ENDPOINT = "/face/[0-9]+";
|
||||
|
||||
static final String READ_ISSUED_DOCUMENTS_ENDPOINT = "/issued-documents/[0-9]+";
|
||||
static final String SEARCH_ISSUED_DOCUMENTS_ENDPOINT = "/issued-documents/search-by-document-type/";
|
||||
static final String COUNT_ISSUED_DOCUMENTS_ENDPOINT = "/issued-documents/count/search-by-document-type/";
|
||||
static final String SEARCH_DIGITALIZATION_ENDPOINT = "/civil-status-mtlb/digitalization/search";
|
||||
static final String COUNT_DIGITALIZATION_ENDPOINT = "/civil-status-mtlb/digitalization/count";
|
||||
static final String SEARCH_CIVIL_STATUS_ATTACHMENTS_ENDPOINT = "/civil-status-mtlb-attachment/search/";
|
||||
|
||||
static final String SEARCH_ADDRESS_ENDPOINT = "/address/search/";
|
||||
static final String SEARCH_EMAIL_ENDPOINT = "/email/search/";
|
||||
static final String SEARCH_PHONE_NUMBER_ENDPOINT = "/phone-number/search/";
|
||||
|
||||
static final String SEARCH_TRANSLATION_ENDPOINT = "/i18n/search/";
|
||||
static final String COUNT_TRANSLATION_ENDPOINT = "/i18n/count/";
|
||||
static final String READ_TRANSLATION_ENDPOINT = "/i18n/[0-9]+";
|
||||
static final String CREATE_TRANSLATION_ENDPOINT = "/i18n";
|
||||
|
||||
static final String SEARCH_OCCUPATION_METADATA_ENDPOINT = "/occupation-metadata/search/";
|
||||
static final String COUNT_OCCUPATION_METADATA_ENDPOINT = "/occupation-metadata/count/";
|
||||
static final String READ_OCCUPATION_METADATA_ENDPOINT = "/occupation-metadata/[0-9]+";
|
||||
static final String CREATE_OCCUPATION_METADATA_ENDPOINT = "/occupation-metadata";
|
||||
|
||||
static final String READ_PREFERENCES = "/preferences/read";
|
||||
static final String SAVE_PREFERENCES = "/preferences/save";
|
||||
|
||||
static final String SEARCH_COUNTRY = "/country/search/";
|
||||
static final String COUNT_COUNTRY_ENDPOINT = "/country/count/";
|
||||
static final String READ_COUNTRY_ENDPOINT = "/country/[0-9]+";
|
||||
static final String CREATE_COUNTRY_ENDPOINT = "/country";
|
||||
|
||||
static final String LOCATIONS_SEARCH = "/locations/search/";
|
||||
static final String PROVINCE_SEARCH = "/province/search/";
|
||||
static final String POLLING_STATIONS_SEARCH = "/polling-stations/search/";
|
||||
static final String WHO_AMI = "/users/whoami";
|
||||
|
||||
static final String READ_GLOBAL_STATE = "/global-state/[0-9]+";
|
||||
static final String SET_GLOBAL_STATE = "/global-state/set";
|
||||
static final String GET_GLOBAL_STATE = "/global-state/get";
|
||||
|
||||
static final String CREATE_RV4_BIRTH_MTLB_ENDPOINT = "/apply/save-rv4-birth-mtlb-by-vital-record-id";
|
||||
static final String CREATE_RV4_BIRTH_MTLB_ATTACHMENTS_ENDPOINT = "/rv4-birth-mtlb-attachment/save-by-rv4-mtlb-id";
|
||||
|
||||
static final String CREATE_RV4_DEATH_MTLB_ENDPOINT = "/apply/save-rv4-death-mtlb-by-vital-record-id";
|
||||
static final String CREATE_RV4_UNION_MTLB_ENDPOINT = "/apply/save-rv4-marraige-mtlb-by-union-id";
|
||||
static final String CREATE_RV4_DIVORCE_MTLB_ENDPOINT = "/apply/save-rv4-divorce-mtlb-by-union-id";
|
||||
static final String CREATE_RV4_ID_CARD_MTLB_ENDPOINT = "/apply/save-rv4-id-card-mtlb-by-id-card-number";
|
||||
|
||||
static final String GET_VOTER_RECORD_LIST = "/van-elect-service/get-voter-record-list";
|
||||
|
||||
static final String READ_CIVIL_RECORD_INFO = "/civil-record-info-service/read";
|
||||
|
||||
static final String GENERAL_STATISTICS_REPORT_ENDPOINT = "/reports/general-statistics";
|
||||
|
||||
static final String READ_FACE_ENDPOINT_IMAGE = "/face/image/[0-9]+/.*";
|
||||
static final String READ_ID_MTLB_FACE_ENDPOINT_IMAGE = "/id-mtlb/face/[0-9]+/.*";
|
||||
|
||||
static final String READ_CIVIL_STATUS_MTLB_FACE_ENDPOINT_IMAGE = "/civil-status-mtlb/face/[0-9]+/.*";
|
||||
|
||||
static final String READ_COUNTRY_FLAG_ENDPOINT = "/geo-data/flag/[0-9]+/.*";
|
||||
|
||||
static final String READ_CIVIL_STATUS_MTLB_ATTACHMENT_ENDPOINT = "/civil-status-mtlb/attachment/content/[0-9]+/.*";
|
||||
static final String READ_CIVIL_STATUS_MTLB_ATTACHMENT_PREVIEW_ENDPOINT = "/civil-status-mtlb/attachment/preview/[0-9]+/.*";
|
||||
static final String READ_CIVIL_STATUS_MTLB_ATTACHMENT_DOWNLOAD_ENDPOINT = "/civil-status-mtlb/attachment/[0-9]+/.*";
|
||||
|
||||
static final String READ_CIVIL_STATUS_MTLB_MEDICAL_NOTIFICATION_ENDPOINT = "/civil-status-mtlb/medical-notification-file/content/[0-9]+/.*";
|
||||
|
||||
static final String READ_CIVIL_STATUS_MTLB_MEDICAL_NOTIFICATION_PREVIEW_ENDPOINT = "/civil-status-mtlb/medical-notification-file/preview/[0-9]+/.*";
|
||||
static final String READ_CIVIL_STATUS_MTLB_MEDICAL_NOTIFICATION_DOWNLOAD_ENDPOINT = "/civil-status-mtlb/medical-notification-file/[0-9]+/.*";
|
||||
|
||||
static final String READ_VITAL_RECORD_ATTACHMENT_PREVIEW_ENDPOINT = "/vital-record-attachment/preview/[0-9]+/.*";
|
||||
static final String READ_VITAL_RECORD_ATTACHMENT_DOWNLOAD_ENDPOINT = "/vital-record/attachment/[0-9]+/.*";
|
||||
|
||||
static final String READ_DEATH_RECORD_ATTACHMENT_PREVIEW_ENDPOINT = "/death-record-attachment/preview/[0-9]+/.*";
|
||||
static final String READ_DEATH_RECORD_ATTACHMENT_DOWNLOAD_ENDPOINT = "/death-record/attachment/[0-9]+/.*";
|
||||
static final String READ_DEATH_RECORD_ATTACHMENT_DOWNLOAD = "/death-record-attachment/[0-9]+/.*";
|
||||
|
||||
static final String READ_UNION_RECORD_ATTACHMENT_PREVIEW_ENDPOINT = "/union-record-attachment/preview/[0-9]+/.*";
|
||||
static final String READ_UNION_RECORD_ATTACHMENT_DOWNLOAD_ENDPOINT = "/union-record/attachment/[0-9]+/.*";
|
||||
static final String READ_UNION_RECORD_ATTACHMENT_DOWNLOAD = "/union-record-attachment/[0-9]+/.*";
|
||||
|
||||
|
||||
static final String READ_UNION_MTLB_ATTACHMENT_PREVIEW_ENDPOINT = "/union-mtlb/attachment/preview/[0-9]+/.*";
|
||||
static final String READ_UNION_MTLB_ATTACHMENT_DOWNLOAD_ENDPOINT = "/union-mtlb/attachment/[0-9]+/.*";
|
||||
|
||||
static final String READ_VITAL_RECORD_MEDICAL_NOTIFICATION_ENDPOINT = "/vital-record/medical-notification-file/content/[0-9]+/.*";
|
||||
static final String READ_VITAL_RECORD_MEDICAL_NOTIFICATION_PREVIEW_ENDPOINT = "/vital-record/medical-notification-file/preview/[0-9]+/.*";
|
||||
static final String READ_VITAL_RECORD_MEDICAL_NOTIFICATION_DOWNLOAD_ENDPOINT = "/vital-record/medical-notification-file/[0-9]+/.*";
|
||||
|
||||
|
||||
static final String READ_CIVIL_STATUS_MTLB_DEATH_NOTIFICATION_ENDPOINT = "/civil-status-mtlb/death-notification-file/content/[0-9]+/.*";
|
||||
static final String READ_CIVIL_STATUS_MTLB_DEATH_NOTIFICATION_PREVIEW_ENDPOINT = "/civil-status-mtlb/death-notification-file/preview/[0-9]+/.*";
|
||||
static final String READ_CIVIL_STATUS_MTLB_DEATH_NOTIFICATION_DOWNLOAD_ENDPOINT = "/civil-status-mtlb/death-notification-file/[0-9]+/.*";
|
||||
|
||||
static final String VITAL_RECORD_ADVANCED_SEARCH = "/vital-record/advanced-search";
|
||||
static final String VITAL_RECORD_ADVANCED_SEARCH_COUNT = "/vital-record/count/advanced-search";
|
||||
|
||||
public static void init() {
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(VITAL_RECORD_ADVANCED_SEARCH, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(VITAL_RECORD_ADVANCED_SEARCH, REGISTRAR, DIGITALIZER, CLERK);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_CIVIL_STATUS_MTLB_ENDPOINT,
|
||||
EndpointsPermissions.AUTHENTICATED);
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_DIGITALIZATION_MTLB_ENDPOINT,
|
||||
EndpointsPermissions.AUTHENTICATED);
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_DIGITALIZATION_ENDPOINT, DIGITALIZER, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_DIGITALIZATION_ENDPOINT, DIGITALIZER, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_FACE_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_VITAL_RECORD_ATTACHMENT_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_ATTACHMENT_PREVIEW_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_CIVIL_STATUS_ATTACHMENTS_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_CIVIL_STATUS_MTLB_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_CIVIL_STATUS_MTLB_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(CIVIL_STATUS_MTLB_TAG, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(CIVIL_STATUS_MTLB_PENDING_UPDATE, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(CIVIL_STATUS_MTLB_PENDING_REJECT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(CIVIL_STATUS_MTLB_READY_APPROVE, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(CIVIL_STATUS_MTLB_READY_REJECT, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(UPDATE_CIVIL_STATUS_MTLB_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_ID_MTLB_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(UPDATE_ID_MTLB_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_ID_MTLB_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(ID_MTLB_TAG, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(ID_MTLB_PENDING_UPDATE, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(ID_MTLB_PENDING_REJECT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_ID_MTLB_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_ID_MTLB_ENDPOINT, REGISTRAR, CLERK);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_VITAL_RECORD_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_VITAL_RECORD_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_VITAL_RECORD_ENDPOINT, DIGITALIZER, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_VITAL_RECORD_ENDPOINT_TAG, REGISTRAR, DIGITALIZER, CLERK);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_ISSUED_DOCUMENTS_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_ISSUED_DOCUMENTS_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_ISSUED_DOCUMENTS_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_UNION_MTLB, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_UNION_MTLB, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_TRANSLATION_ENDPOINT, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_TRANSLATION_ENDPOINT, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_TRANSLATION_ENDPOINT, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_TRANSLATION_ENDPOINT, REGISTRAR);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_OCCUPATION_METADATA_ENDPOINT, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_OCCUPATION_METADATA_ENDPOINT, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_OCCUPATION_METADATA_ENDPOINT, REGISTRAR);
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_OCCUPATION_METADATA_ENDPOINT, REGISTRAR);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_ADDRESS_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_EMAIL_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_PHONE_NUMBER_ENDPOINT, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(ATTACH_DIGITALIZATION_MTLB, REGISTRAR, DIGITALIZER, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_PREFERENCES, EndpointsPermissions.AUTHENTICATED);
|
||||
EndpointsPermissions.setRequiredPermissions(SAVE_PREFERENCES, EndpointsPermissions.AUTHENTICATED);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(LOCATIONS_SEARCH, EndpointsPermissions.AUTHENTICATED);
|
||||
EndpointsPermissions.setRequiredPermissions(PROVINCE_SEARCH, EndpointsPermissions.AUTHENTICATED);
|
||||
EndpointsPermissions.setRequiredPermissions(POLLING_STATIONS_SEARCH, EndpointsPermissions.AUTHENTICATED);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(WHO_AMI, EndpointsPermissions.AUTHENTICATED);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_RV4_BIRTH_MTLB_ENDPOINT, RV4_MIGRATION_TOOL);
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_RV4_BIRTH_MTLB_ATTACHMENTS_ENDPOINT, RV4_MIGRATION_TOOL);
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_RV4_BIRTH_MTLB_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_RV4_BIRTH_MTLB_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(COUNT_RV4_BIRTH_MTLB_ENDPOINT, REGISTRAR, CLERK);
|
||||
EndpointsPermissions.setRequiredPermissions(SEARCH_RV4_BIRTH_MTLB_TAG_ENDPOINT, REGISTRAR, CLERK);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(SET_GLOBAL_STATE, EndpointsPermissions.AUTHENTICATED);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_GLOBAL_STATE, EndpointsPermissions.AUTHENTICATED);
|
||||
EndpointsPermissions.setRequiredPermissions(GET_GLOBAL_STATE, EndpointsPermissions.AUTHENTICATED);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_GEO_DATA_ENDPOINT, RV4_MIGRATION_TOOL);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_RV4_DEATH_MTLB_ENDPOINT, RV4_MIGRATION_TOOL);
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_RV4_UNION_MTLB_ENDPOINT, RV4_MIGRATION_TOOL);
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_RV4_DIVORCE_MTLB_ENDPOINT, RV4_MIGRATION_TOOL);
|
||||
EndpointsPermissions.setRequiredPermissions(CREATE_RV4_ID_CARD_MTLB_ENDPOINT, RV4_MIGRATION_TOOL);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(GET_VOTER_RECORD_LIST, VAN_ELECT);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_RECORD_INFO, E_ID_SERVER);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(GENERAL_STATISTICS_REPORT_ENDPOINT, EndpointsPermissions.AUTHENTICATED);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_ATTACHMENT_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_ATTACHMENT_DOWNLOAD_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_MEDICAL_NOTIFICATION_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_MEDICAL_NOTIFICATION_DOWNLOAD_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_MEDICAL_NOTIFICATION_PREVIEW_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_VITAL_RECORD_ATTACHMENT_PREVIEW_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_VITAL_RECORD_ATTACHMENT_DOWNLOAD_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_UNION_RECORD_ATTACHMENT_PREVIEW_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_UNION_RECORD_ATTACHMENT_DOWNLOAD_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_UNION_RECORD_ATTACHMENT_DOWNLOAD, EndpointsPermissions.PUBLIC);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_DEATH_RECORD_ATTACHMENT_PREVIEW_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_DEATH_RECORD_ATTACHMENT_DOWNLOAD_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_DEATH_RECORD_ATTACHMENT_DOWNLOAD, EndpointsPermissions.PUBLIC);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_UNION_MTLB_ATTACHMENT_PREVIEW_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_UNION_MTLB_ATTACHMENT_DOWNLOAD_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_VITAL_RECORD_MEDICAL_NOTIFICATION_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_VITAL_RECORD_MEDICAL_NOTIFICATION_DOWNLOAD_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_VITAL_RECORD_MEDICAL_NOTIFICATION_PREVIEW_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_DEATH_NOTIFICATION_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_DEATH_NOTIFICATION_DOWNLOAD_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_DEATH_NOTIFICATION_PREVIEW_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_FACE_ENDPOINT_IMAGE, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_ID_MTLB_FACE_ENDPOINT_IMAGE, EndpointsPermissions.PUBLIC);
|
||||
EndpointsPermissions.setRequiredPermissions(READ_CIVIL_STATUS_MTLB_FACE_ENDPOINT_IMAGE, EndpointsPermissions.PUBLIC);
|
||||
|
||||
EndpointsPermissions.setRequiredPermissions(READ_COUNTRY_FLAG_ENDPOINT, EndpointsPermissions.PUBLIC);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package systems.archide.core.controller;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import systems.archide.core.pojo.Address;
|
||||
import systems.archide.core.pojo.BirthCertificateData;
|
||||
import systems.archide.core.pojo.ChildData;
|
||||
import systems.archide.core.pojo.DeathCertificateData;
|
||||
import systems.archide.core.pojo.DeathRecord;
|
||||
import systems.archide.core.pojo.UnionRecord;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.AddressRepository;
|
||||
import systems.archide.core.repository.DeathRecordRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.UnionRecordRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/birth-certificate")
|
||||
public class BirthCertificateController {
|
||||
|
||||
@Autowired
|
||||
DeathRecordRepository deathRecordRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@GetMapping("/read/{id}")
|
||||
public ResponseEntity<BirthCertificateData> getDeathCertificateData(@PathVariable Long id) {
|
||||
BirthCertificateData data = queries.getBirthCertificateData(id);
|
||||
List<DeathRecord> d = deathRecordRepository.findByVitalRecordId(id);
|
||||
|
||||
if (d.isEmpty())
|
||||
data.setDead(false);
|
||||
else
|
||||
data.setDead(true);
|
||||
return ResponseEntity.ok(data);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
package systems.archide.core.controller;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import systems.archide.core.pojo.Address;
|
||||
import systems.archide.core.pojo.BirthCertificateData;
|
||||
import systems.archide.core.pojo.ChildData;
|
||||
import systems.archide.core.pojo.DeathCertificateData;
|
||||
import systems.archide.core.pojo.DeathRecord;
|
||||
import systems.archide.core.pojo.UnionRecord;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.AddressRepository;
|
||||
import systems.archide.core.repository.DeathRecordRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.UnionRecordRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/death-certificate")
|
||||
public class DeathCertificateController {
|
||||
|
||||
@Autowired
|
||||
DeathRecordRepository deathRecordRepository;
|
||||
|
||||
@Autowired
|
||||
AddressRepository addressRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
UnionRecordRepository unionRecordRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@GetMapping("/read/{id}")
|
||||
public ResponseEntity<DeathCertificateData> getDeathCertificateData(@PathVariable Long id) {
|
||||
DeathRecord deathRecord = deathRecordRepository.findById(id);
|
||||
DeathCertificateData data = getDeathCertificateData(deathRecord);
|
||||
return ResponseEntity.ok(data);
|
||||
}
|
||||
|
||||
private DeathCertificateData getDeathCertificateData(DeathRecord deathRecord) {
|
||||
DeathCertificateData certificateData = new DeathCertificateData();
|
||||
certificateData.setId(deathRecord.getId());
|
||||
certificateData.setFirstname(deathRecord.getFirstname());
|
||||
certificateData.setDeathPlace(deathRecord.getDeathLocation());
|
||||
certificateData.setThirdname(deathRecord.getThirdname());
|
||||
certificateData.setFourthname(deathRecord.getFourthname());
|
||||
certificateData.setTimeOfDeath(deathRecord.getTimeOfDeath());
|
||||
certificateData.setDateOfDeath(deathRecord.getDateOfDeath());
|
||||
certificateData.setGender(deathRecord.getGender());
|
||||
certificateData.setReportedRecord(false);
|
||||
certificateData.setVitalRecordId(deathRecord.getVitalRecordId());
|
||||
certificateData.setTimestamp(deathRecord.getTimestamp());
|
||||
List<Address> addressList = addressRepository.findByVitalRecordId(deathRecord.getVitalRecordId());
|
||||
if (!addressList.isEmpty())
|
||||
certificateData.setAddress(addressList.get(0).getAreaId());
|
||||
if (deathRecord.getFatherId() != null) {
|
||||
VitalRecord fatherRecord = vitalRecordRepository.findById(deathRecord.getFatherId());
|
||||
if (fatherRecord != null) {
|
||||
certificateData.setFatherName(fatherRecord.getFirstname() + " " + fatherRecord.getFourthname());
|
||||
}
|
||||
} else if (deathRecord.getReportedFatherName() != null) {
|
||||
certificateData.setFatherName(deathRecord.getReportedFatherName());
|
||||
}
|
||||
if (deathRecord.getMotherId() != null) {
|
||||
VitalRecord motherRecord = vitalRecordRepository.findById(deathRecord.getMotherId());
|
||||
if (motherRecord != null) {
|
||||
certificateData.setMotherName(motherRecord.getFirstname() + " " + motherRecord.getFourthname());
|
||||
}
|
||||
} else if (deathRecord.getReportedMotherName() != null) {
|
||||
certificateData.setMotherName(deathRecord.getReportedMotherName());
|
||||
}
|
||||
certificateData.setId(deathRecord.getId());
|
||||
|
||||
if (deathRecord.getDeclarantId() != null) {
|
||||
certificateData.setDeclarantId(deathRecord.getDeclarantId());
|
||||
VitalRecord dr = vitalRecordRepository.findById(deathRecord.getDeclarantId());
|
||||
if (dr != null) {
|
||||
certificateData.setDeclarantFirstname(dr.getFirstname());
|
||||
certificateData.setDeclarantSecondname(dr.getSecondname());
|
||||
certificateData.setDeclarantFourthname(dr.getFourthname());
|
||||
}
|
||||
}
|
||||
|
||||
if (deathRecord.getVitalRecordId() != null) {
|
||||
VitalRecord r = vitalRecordRepository.findById(deathRecord.getVitalRecordId());
|
||||
if (r != null) {
|
||||
certificateData.setBirthdate(r.getBirthdate());
|
||||
certificateData.setBirthPlace(r.getBirthPlace());
|
||||
certificateData.setGender(r.getGender());
|
||||
List<UnionRecord> uList = null;
|
||||
if (r.getGender() == 1) {
|
||||
uList = unionRecordRepository.findByPartner1VitalRecordId(r.getId());
|
||||
if (!uList.isEmpty())
|
||||
for (UnionRecord u : uList) {
|
||||
if (u.getDateOfEffect() == null && u.getDateOfOrder() == null) {
|
||||
certificateData.setSpouseId(u.getPartner2VitalRecordId());
|
||||
certificateData.setSpouseName(u.getPartner2Firstname() + " " + u.getPartner2Surname());
|
||||
certificateData.setMarriageDate(u.getDateOfMarriage());
|
||||
certificateData.setMarriageLocation(u.getPlace());
|
||||
}
|
||||
}
|
||||
List<VitalRecord> childrenRecods = queries.getFatherChildren(r.getId());
|
||||
if (!childrenRecods.isEmpty()) {
|
||||
List<ChildData> children = new ArrayList<>();
|
||||
for (VitalRecord childRecord : childrenRecods) {
|
||||
ChildData child = new ChildData();
|
||||
child.setAge(Period.between(childRecord.getBirthdate(), LocalDate.now()).getYears());
|
||||
child.setName(childRecord.getFirstname() + " " + childRecord.getFourthname());
|
||||
child.setGender((childRecord.getGender() == 1)?"MALE":(childRecord.getGender() == 2)?"FEMALE": "Unknown");
|
||||
children.add(child);
|
||||
}
|
||||
certificateData.setChildren(children);
|
||||
}
|
||||
}
|
||||
else if (r.getGender() == 2) {
|
||||
uList = unionRecordRepository.findByPartner2VitalRecordId(r.getId());
|
||||
if (!uList.isEmpty())
|
||||
for (UnionRecord u : uList) {
|
||||
if (u.getDateOfEffect() == null && u.getDateOfOrder() == null) {
|
||||
certificateData.setSpouseId(u.getPartner1VitalRecordId());
|
||||
certificateData.setSpouseName(u.getPartner2Firstname() + " " + u.getPartner1Surname());
|
||||
certificateData.setMarriageDate(u.getDateOfMarriage());
|
||||
certificateData.setMarriageLocation(u.getPlace());
|
||||
}
|
||||
}
|
||||
List<VitalRecord> childrenRecods = queries.getMotherChildren(r.getId());
|
||||
if (!childrenRecods.isEmpty()) {
|
||||
List<ChildData> children = new ArrayList<>();
|
||||
for (VitalRecord childRecord : childrenRecods) {
|
||||
ChildData child = new ChildData();
|
||||
child.setAge(Period.between(childRecord.getBirthdate(), LocalDate.now()).getYears());
|
||||
child.setName(childRecord.getFirstname() + " " + childRecord.getFourthname());
|
||||
child.setGender((childRecord.getGender() == 1)?"MALE":(childRecord.getGender() == 2)?"FEMALE": "Unknown");
|
||||
children.add(child);
|
||||
}
|
||||
certificateData.setChildren(children);
|
||||
}
|
||||
}
|
||||
if (r.getMotherId() != null) {
|
||||
VitalRecord motherRecord = vitalRecordRepository.findById(r.getMotherId());
|
||||
if (motherRecord != null)
|
||||
certificateData.setMotherName(motherRecord.getFirstname() + " " + motherRecord.getFourthname());
|
||||
} else
|
||||
certificateData.setMotherName(r.getReportedMotherName());
|
||||
if (r.getFatherId() != null) {
|
||||
VitalRecord fatherRecord = vitalRecordRepository.findById(r.getFatherId());
|
||||
if (fatherRecord != null)
|
||||
certificateData.setFatherName(fatherRecord.getFirstname() + " " + fatherRecord.getFourthname());
|
||||
} else
|
||||
certificateData.setFatherName(r.getReportedFatherName());
|
||||
}
|
||||
else
|
||||
certificateData.setReportedRecord(true);
|
||||
|
||||
}
|
||||
else
|
||||
certificateData.setReportedRecord(true);
|
||||
return certificateData;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package systems.archide.core.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import systems.archide.core.pojo.Address;
|
||||
import systems.archide.core.pojo.DivorceCertificateResponse;
|
||||
import systems.archide.core.pojo.UnionRecord;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.AddressRepository;
|
||||
import systems.archide.core.repository.UnionRecordRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/divorce-certificate")
|
||||
public class DivorceCertificateController {
|
||||
|
||||
@Autowired
|
||||
UnionRecordRepository unionRecordRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
AddressRepository addressRepository;
|
||||
|
||||
@GetMapping("/read/{id}")
|
||||
public ResponseEntity<DivorceCertificateResponse> readDivorceCertificateData(@PathVariable Long id) {
|
||||
UnionRecord u = unionRecordRepository.findById(id);
|
||||
DivorceCertificateResponse certificate = record2certificate(u);
|
||||
return ResponseEntity.ok(certificate);
|
||||
}
|
||||
|
||||
private DivorceCertificateResponse record2certificate(UnionRecord u) {
|
||||
DivorceCertificateResponse c = new DivorceCertificateResponse();
|
||||
c.setDateOfEffect(u.getDateOfEffect());
|
||||
c.setDateOfOrder(u.getDateOfOrder());
|
||||
c.setDeclarationDate(u.getDateOfMarriage());
|
||||
c.setTimeOfMarriage(u.getTimeOfMarriage());
|
||||
c.setPartner1Name(u.getPartner1Firstname() + " " + u.getPartner1Surname());
|
||||
c.setPartner2Name(u.getPartner2Firstname() + " " + u.getPartner2Surname());
|
||||
c.setDeclarationPlace(u.getPlace());
|
||||
c.setAnnulmentOrder(u.getAnnulmentOrder());
|
||||
c.setUnionRecordId(u.getId());
|
||||
if (u.getPartner1VitalRecordId() != null) {
|
||||
VitalRecord p1Record = vitalRecordRepository.findById(u.getPartner1VitalRecordId());
|
||||
if (p1Record != null) {
|
||||
c.setPartner1Name(p1Record.getFirstname() + " " + p1Record.getFourthname());
|
||||
}
|
||||
if (u.getPartner2VitalRecordId() != null) {
|
||||
VitalRecord p2Record = vitalRecordRepository.findById(u.getPartner2VitalRecordId());
|
||||
if (p2Record != null) {
|
||||
c.setPartner2Name(p2Record.getFirstname() + " " + p2Record.getFourthname());
|
||||
}
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package systems.archide.core.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import systems.archide.core.pojo.Address;
|
||||
import systems.archide.core.pojo.MarriageCertificateResponse;
|
||||
import systems.archide.core.pojo.UnionRecord;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.AddressRepository;
|
||||
import systems.archide.core.repository.UnionRecordRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/marriage-certificate")
|
||||
public class MarriageCertificateController {
|
||||
|
||||
@Autowired
|
||||
UnionRecordRepository unionRecordRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
AddressRepository addressRepository;
|
||||
|
||||
@GetMapping("/read/{id}")
|
||||
public ResponseEntity<MarriageCertificateResponse> readMarriageCertificateData(@PathVariable Long id) {
|
||||
UnionRecord u = unionRecordRepository.findById(id);
|
||||
MarriageCertificateResponse certificate = record2certificate(u);
|
||||
return ResponseEntity.ok(certificate);
|
||||
}
|
||||
|
||||
private MarriageCertificateResponse record2certificate(UnionRecord u) {
|
||||
MarriageCertificateResponse c = new MarriageCertificateResponse();
|
||||
c.setDeclarationDate(u.getDateOfMarriage());
|
||||
c.setPartner1VitalRecordId(u.getPartner1VitalRecordId());
|
||||
c.setPartner2VitalRecordId(u.getPartner2VitalRecordId());
|
||||
c.setPartner1reported(false);
|
||||
c.setPartner2reported(false);
|
||||
if (u.getCelebrantId() != null) {
|
||||
VitalRecord cr = vitalRecordRepository.findById(u.getCelebrantId());
|
||||
if (cr != null)
|
||||
c.setCelebrant(cr.getFourthname() + " " + cr.getFirstname() );
|
||||
} else
|
||||
c.setCelebrant(u.getReportedCelebrant());
|
||||
if (u.getOfficerId() != null) {
|
||||
VitalRecord or = vitalRecordRepository.findById(u.getOfficerId());
|
||||
if (or != null)
|
||||
c.setOfficer(or.getFourthname() + " " + or.getFirstname() );
|
||||
} else
|
||||
c.setOfficer(u.getReportedOfficer());
|
||||
|
||||
if (u.getDeclarantId() != null) {
|
||||
VitalRecord dr = vitalRecordRepository.findById(u.getDeclarantId());
|
||||
if (dr != null)
|
||||
c.setDeclarationFullName(dr.getFourthname() + " " + dr.getFirstname() );
|
||||
} else
|
||||
c.setDeclarationFullName(u.getReportedDeclarant());
|
||||
c.setPosition(u.getPosition());
|
||||
c.setMarriageType(u.getUnionRegime());
|
||||
c.setTimeOfMarriage(u.getTimeOfMarriage());
|
||||
c.setDeclarationPlace(u.getAddress());
|
||||
c.setRegistrationLocation(u.getRegistrationLocation());
|
||||
c.setMentions(u.getMentions());
|
||||
if (u.getFirstWitnessId() != null) {
|
||||
c.setFirstWitnessId(u.getFirstWitnessId());
|
||||
VitalRecord fw = vitalRecordRepository.findById(u.getFirstWitnessId());
|
||||
if (fw != null)
|
||||
c.setFirstWitnessName(fw.getFirstname() + " " + fw.getFourthname());
|
||||
}
|
||||
if (u.getSecondWitnessId() != null) {
|
||||
c.setSecondWitnessId(u.getSecondWitnessId());
|
||||
VitalRecord fw = vitalRecordRepository.findById(u.getSecondWitnessId());
|
||||
if (fw != null)
|
||||
c.setSecondWitnessName(fw.getFirstname() + " " + fw.getFourthname());
|
||||
}
|
||||
if (u.getPartner1VitalRecordId() != null) {
|
||||
VitalRecord p1Record = vitalRecordRepository.findById(u.getPartner1VitalRecordId());
|
||||
if (p1Record != null) {
|
||||
c.setPartner1BirthLocation(p1Record.getBirthPlace());
|
||||
c.setPartner1DateOfBirth(p1Record.getBirthdate());
|
||||
c.setPartner1FirstNames(p1Record.getFirstname());
|
||||
c.setPartner1MelanesianName(p1Record.getThirdname());
|
||||
c.setPartner1Surname(p1Record.getFourthname());
|
||||
c.setPartner1Sex(p1Record.getGender());
|
||||
List<Address> addressList = addressRepository.findByVitalRecordId(p1Record.getId());
|
||||
if (!addressList.isEmpty())
|
||||
c.setPartner1UsualResidence(addressList.get(0).getAreaId());
|
||||
if (p1Record.getFatherId() != null) {
|
||||
VitalRecord p1FatherRecord = vitalRecordRepository.findById(p1Record.getFatherId());
|
||||
if (p1FatherRecord != null) {
|
||||
c.setPartner1FatherName(p1FatherRecord.getFirstname() + " " + p1FatherRecord.getFourthname());
|
||||
}
|
||||
} else if (p1Record.getReportedFatherName() != null) {
|
||||
c.setPartner1FatherName(p1Record.getReportedFatherName());
|
||||
}
|
||||
if (p1Record.getMotherId() != null) {
|
||||
VitalRecord p1MotherRecord = vitalRecordRepository.findById(p1Record.getMotherId());
|
||||
if (p1MotherRecord != null) {
|
||||
c.setPartner1MotherName(p1MotherRecord.getFirstname() + " " + p1MotherRecord.getFourthname());
|
||||
}
|
||||
} else if (p1Record.getReportedMotherName() != null) {
|
||||
c.setPartner1MotherName(p1Record.getReportedMotherName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
c.setPartner1FirstNames(u.getPartner1Firstname());
|
||||
c.setPartner1Surname(u.getPartner1Surname());
|
||||
c.setPartner1FatherName(u.getPartner1FatherName());
|
||||
c.setPartner1MotherName(u.getPartner1MotherName());
|
||||
c.setPartner1reported(true);
|
||||
}
|
||||
}
|
||||
if (u.getPartner2VitalRecordId() != null) {
|
||||
VitalRecord p2Record = vitalRecordRepository.findById(u.getPartner2VitalRecordId());
|
||||
if (p2Record != null) {
|
||||
c.setPartner2BirthLocation(p2Record.getBirthPlace());
|
||||
c.setPartner2DateOfBirth(p2Record.getBirthdate());
|
||||
c.setPartner2FirstNames(p2Record.getFirstname());
|
||||
c.setPartner2MelanesianName(p2Record.getThirdname());
|
||||
c.setPartner2Surname(p2Record.getFourthname());
|
||||
c.setPartner2Sex(p2Record.getGender());
|
||||
List<Address> addressList = addressRepository.findByVitalRecordId(p2Record.getId());
|
||||
if (!addressList.isEmpty())
|
||||
c.setPartner2UsualResidence(addressList.get(0).getAreaId());
|
||||
if (p2Record.getFatherId() != null) {
|
||||
VitalRecord p2FatherRecord = vitalRecordRepository.findById(p2Record.getFatherId());
|
||||
if (p2FatherRecord != null) {
|
||||
c.setPartner2FatherName(p2FatherRecord.getFirstname() + " " + p2FatherRecord.getFourthname());
|
||||
}
|
||||
} else if (p2Record.getReportedFatherName() != null) {
|
||||
c.setPartner2FatherName(p2Record.getReportedFatherName());
|
||||
}
|
||||
if (p2Record.getMotherId() != null) {
|
||||
VitalRecord p2MotherRecord = vitalRecordRepository.findById(p2Record.getMotherId());
|
||||
if (p2MotherRecord != null) {
|
||||
c.setPartner2MotherName(p2MotherRecord.getFirstname() + " " + p2MotherRecord.getFourthname());
|
||||
}
|
||||
} else if (p2Record.getReportedMotherName() != null) {
|
||||
c.setPartner2MotherName(p2Record.getReportedMotherName());
|
||||
|
||||
}
|
||||
} else {
|
||||
c.setPartner2FirstNames(u.getPartner2Firstname());
|
||||
c.setPartner2Surname(u.getPartner2Surname());
|
||||
c.setPartner2FatherName(u.getPartner2FatherName());
|
||||
c.setPartner2MotherName(u.getPartner2MotherName());
|
||||
c.setPartner2reported(true);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package systems.archide.core.controller;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import systems.archide.core.pojo.JobMtlb;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.repository.JobMtlbRepository;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/reports")
|
||||
public class ReportsController {
|
||||
|
||||
@Autowired
|
||||
JobMtlbRepository jobMtlbRepository;
|
||||
|
||||
@PostMapping("/new-document")
|
||||
public ResponseEntity<Long> newDocument(@RequestBody String name,
|
||||
Authentication authentication) {
|
||||
Long id = newDocument(name);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(id);
|
||||
}
|
||||
|
||||
private Long newDocument(String name) {
|
||||
JobMtlb job = new JobMtlb();
|
||||
job.setTimestamp(LocalDateTime.now());
|
||||
job.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
job.setMtlbType(MtlbType.GENERAL_STATISTICS);
|
||||
return jobMtlbRepository.insert(job);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
public class ArchideMtlbAnnex {
|
||||
ArrayList<ArchideMtlbAnnexTag> tags = new ArrayList<>();
|
||||
ArrayList<ArchideMtlbAnnexLogEntry> notes = new ArrayList<>();
|
||||
ArrayList<ArchideMtlbAnnexLogEntry> mentions = new ArrayList<>();
|
||||
|
||||
public ArchideMtlbAnnex() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void addTag(String name, String type, String content) {
|
||||
tags.add(new ArchideMtlbAnnexTag(name, type, content));
|
||||
}
|
||||
|
||||
public void addNote(String author, String type, String message) {
|
||||
notes.add(new ArchideMtlbAnnexLogEntry(author, type, message));
|
||||
}
|
||||
|
||||
public ArrayList<ArchideMtlbAnnexTag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public ArrayList<ArchideMtlbAnnexLogEntry> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public ArrayList<ArchideMtlbAnnexLogEntry> getMentions() {
|
||||
return mentions;
|
||||
}
|
||||
|
||||
public String toJsonString() {
|
||||
try {
|
||||
return ArchideMtlbAnnexUtil.objectMapper.writeValueAsString(this);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class ArchideMtlbAnnexLogEntry {
|
||||
String author;
|
||||
String type;
|
||||
String content;
|
||||
LocalDateTime timestamp;
|
||||
|
||||
public ArchideMtlbAnnexLogEntry() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public ArchideMtlbAnnexLogEntry(String author, String type, String content) {
|
||||
super();
|
||||
this.author = author;
|
||||
this.content = content;
|
||||
this.type = type;
|
||||
this.timestamp = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public ArchideMtlbAnnexLogEntry(String author, String type, String content, LocalDateTime timestamp) {
|
||||
super();
|
||||
this.author = author;
|
||||
this.content = content;
|
||||
this.type = type;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
public class ArchideMtlbAnnexTag {
|
||||
String name;
|
||||
String type;
|
||||
String value;
|
||||
|
||||
public ArchideMtlbAnnexTag() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ArchideMtlbAnnexTag(String name, String type, String value) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
public class ArchideMtlbAnnexUtil {
|
||||
public static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public static final ArchideMtlbAnnex deserialize(String annex) throws JsonMappingException, JsonProcessingException {
|
||||
objectMapper.registerModule(new JavaTimeModule());
|
||||
return objectMapper.readValue(annex, ArchideMtlbAnnex.class);
|
||||
}
|
||||
}
|
32
src/main/java/systems/archide/core/pojo/ChildData.java
Normal file
32
src/main/java/systems/archide/core/pojo/ChildData.java
Normal file
@ -0,0 +1,32 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
public class ChildData {
|
||||
|
||||
String name;
|
||||
String gender;
|
||||
int age;
|
||||
|
||||
public ChildData() {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
}
|
36
src/main/java/systems/archide/core/pojo/DateRange.java
Normal file
36
src/main/java/systems/archide/core/pojo/DateRange.java
Normal file
@ -0,0 +1,36 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class DateRange {
|
||||
|
||||
LocalDate min;
|
||||
LocalDate max;
|
||||
|
||||
public DateRange(LocalDate min, LocalDate max) {
|
||||
super();
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public DateRange() {
|
||||
|
||||
}
|
||||
|
||||
public LocalDate getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public void setMin(LocalDate min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public LocalDate getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setMax(LocalDate max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,268 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
public class DeathCertificateData {
|
||||
|
||||
Long id;
|
||||
Long vitalRecordId;
|
||||
String firstname;
|
||||
LocalDate dateOfDeath;
|
||||
Short gender;
|
||||
String thirdname;
|
||||
String motherName;
|
||||
String fourthname;
|
||||
String fatherName;
|
||||
LocalTime timeOfDeath;
|
||||
String deathPlace;
|
||||
String address;
|
||||
LocalDate birthdate;
|
||||
String occupation;
|
||||
String spouseName;
|
||||
Long spouseId;
|
||||
LocalDate marriageDate;
|
||||
String marriageLocation;
|
||||
String birthPlace;
|
||||
Long declarantId;
|
||||
List<ChildData> children;
|
||||
Boolean reportedRecord;
|
||||
String declarantFirstname;
|
||||
String declarantSecondname;
|
||||
String declarantFourthname;
|
||||
LocalDateTime timestamp;
|
||||
|
||||
String registrationLocation;
|
||||
String mentions;
|
||||
|
||||
public DeathCertificateData() {
|
||||
}
|
||||
|
||||
public String getRegistrationLocation() {
|
||||
return registrationLocation;
|
||||
}
|
||||
|
||||
public void setRegistrationLocation(String registrationLocation) {
|
||||
this.registrationLocation = registrationLocation;
|
||||
}
|
||||
|
||||
public String getMentions() {
|
||||
return mentions;
|
||||
}
|
||||
|
||||
public void setMentions(String mentions) {
|
||||
this.mentions = mentions;
|
||||
}
|
||||
|
||||
public String getDeclarantFirstname() {
|
||||
return declarantFirstname;
|
||||
}
|
||||
|
||||
public void setDeclarantFirstname(String declarantFirstname) {
|
||||
this.declarantFirstname = declarantFirstname;
|
||||
}
|
||||
|
||||
public String getDeclarantSecondname() {
|
||||
return declarantSecondname;
|
||||
}
|
||||
|
||||
public void setDeclarantSecondname(String declarantSecondname) {
|
||||
this.declarantSecondname = declarantSecondname;
|
||||
}
|
||||
|
||||
public String getDeclarantFourthname() {
|
||||
return declarantFourthname;
|
||||
}
|
||||
|
||||
public void setDeclarantFourthname(String declarantFourthname) {
|
||||
this.declarantFourthname = declarantFourthname;
|
||||
}
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getBirthPlace() {
|
||||
return birthPlace;
|
||||
}
|
||||
|
||||
public Long getDeclarantId() {
|
||||
return declarantId;
|
||||
}
|
||||
|
||||
public void setDeclarantId(Long declarantId) {
|
||||
this.declarantId = declarantId;
|
||||
}
|
||||
|
||||
|
||||
public void setBirthPlace(String birthPlace) {
|
||||
this.birthPlace = birthPlace;
|
||||
}
|
||||
|
||||
public Boolean getReportedRecord() {
|
||||
return reportedRecord;
|
||||
}
|
||||
|
||||
public void setReportedRecord(Boolean reportedRecord) {
|
||||
this.reportedRecord = reportedRecord;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVitalRecordId() {
|
||||
return vitalRecordId;
|
||||
}
|
||||
|
||||
public void setVitalRecordId(Long vitalRecordId) {
|
||||
this.vitalRecordId = vitalRecordId;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public LocalDate getDateOfDeath() {
|
||||
return dateOfDeath;
|
||||
}
|
||||
|
||||
public void setDateOfDeath(LocalDate dateOfDeath) {
|
||||
this.dateOfDeath = dateOfDeath;
|
||||
}
|
||||
|
||||
public Short getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(Short gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getThirdname() {
|
||||
return thirdname;
|
||||
}
|
||||
|
||||
public void setThirdname(String thirdname) {
|
||||
this.thirdname = thirdname;
|
||||
}
|
||||
|
||||
public String getMotherName() {
|
||||
return motherName;
|
||||
}
|
||||
|
||||
public void setMotherName(String motherName) {
|
||||
this.motherName = motherName;
|
||||
}
|
||||
|
||||
public String getFourthname() {
|
||||
return fourthname;
|
||||
}
|
||||
|
||||
public void setFourthname(String fourthname) {
|
||||
this.fourthname = fourthname;
|
||||
}
|
||||
|
||||
public String getFatherName() {
|
||||
return fatherName;
|
||||
}
|
||||
|
||||
public void setFatherName(String fatherName) {
|
||||
this.fatherName = fatherName;
|
||||
}
|
||||
|
||||
public LocalTime getTimeOfDeath() {
|
||||
return timeOfDeath;
|
||||
}
|
||||
|
||||
public void setTimeOfDeath(LocalTime timeOfDeath) {
|
||||
this.timeOfDeath = timeOfDeath;
|
||||
}
|
||||
|
||||
public String getDeathPlace() {
|
||||
return deathPlace;
|
||||
}
|
||||
|
||||
public void setDeathPlace(String deathPlace) {
|
||||
this.deathPlace = deathPlace;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public LocalDate getBirthdate() {
|
||||
return birthdate;
|
||||
}
|
||||
|
||||
public void setBirthdate(LocalDate birthdate) {
|
||||
this.birthdate = birthdate;
|
||||
}
|
||||
|
||||
public String getOccupation() {
|
||||
return occupation;
|
||||
}
|
||||
|
||||
public void setOccupation(String occupation) {
|
||||
this.occupation = occupation;
|
||||
}
|
||||
|
||||
public String getSpouseName() {
|
||||
return spouseName;
|
||||
}
|
||||
|
||||
public void setSpouseName(String spouseName) {
|
||||
this.spouseName = spouseName;
|
||||
}
|
||||
|
||||
public Long getSpouseId() {
|
||||
return spouseId;
|
||||
}
|
||||
|
||||
public void setSpouseId(Long spouseId) {
|
||||
this.spouseId = spouseId;
|
||||
}
|
||||
|
||||
public LocalDate getMarriageDate() {
|
||||
return marriageDate;
|
||||
}
|
||||
|
||||
public void setMarriageDate(LocalDate marriageDate) {
|
||||
this.marriageDate = marriageDate;
|
||||
}
|
||||
|
||||
public String getMarriageLocation() {
|
||||
return marriageLocation;
|
||||
}
|
||||
|
||||
public void setMarriageLocation(String marriageLocation) {
|
||||
this.marriageLocation = marriageLocation;
|
||||
}
|
||||
|
||||
public List<ChildData> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<ChildData> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public class DivorceCertificateResponse {
|
||||
|
||||
String partner1Name;
|
||||
LocalDate dateOfEffect;
|
||||
LocalDate dateOfOrder;
|
||||
String partner2Name;
|
||||
LocalDate declarationDate;
|
||||
String declarationPlace;
|
||||
String annulmentOrder;
|
||||
LocalTime timeOfMarriage;
|
||||
Long unionRecordId;
|
||||
|
||||
public DivorceCertificateResponse() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Long getUnionRecordId() {
|
||||
return unionRecordId;
|
||||
}
|
||||
|
||||
|
||||
public void setUnionRecordId(Long unionRecordId) {
|
||||
this.unionRecordId = unionRecordId;
|
||||
}
|
||||
|
||||
|
||||
public LocalTime getTimeOfMarriage() {
|
||||
return timeOfMarriage;
|
||||
}
|
||||
|
||||
|
||||
public void setTimeOfMarriage(LocalTime timeOfMarriage) {
|
||||
this.timeOfMarriage = timeOfMarriage;
|
||||
}
|
||||
|
||||
|
||||
public String getPartner1Name() {
|
||||
return partner1Name;
|
||||
}
|
||||
public void setPartner1Name(String partner1Name) {
|
||||
this.partner1Name = partner1Name;
|
||||
}
|
||||
public LocalDate getDateOfEffect() {
|
||||
return dateOfEffect;
|
||||
}
|
||||
public void setDateOfEffect(LocalDate dateOfEffect) {
|
||||
this.dateOfEffect = dateOfEffect;
|
||||
}
|
||||
public LocalDate getDateOfOrder() {
|
||||
return dateOfOrder;
|
||||
}
|
||||
public void setDateOfOrder(LocalDate dateOfOrder) {
|
||||
this.dateOfOrder = dateOfOrder;
|
||||
}
|
||||
public String getPartner2Name() {
|
||||
return partner2Name;
|
||||
}
|
||||
public void setPartner2Name(String partner2Name) {
|
||||
this.partner2Name = partner2Name;
|
||||
}
|
||||
public LocalDate getDeclarationDate() {
|
||||
return declarationDate;
|
||||
}
|
||||
public void setDeclarationDate(LocalDate declarationDate) {
|
||||
this.declarationDate = declarationDate;
|
||||
}
|
||||
public String getDeclarationPlace() {
|
||||
return declarationPlace;
|
||||
}
|
||||
public void setDeclarationPlace(String declarationPlace) {
|
||||
this.declarationPlace = declarationPlace;
|
||||
}
|
||||
public String getAnnulmentOrder() {
|
||||
return annulmentOrder;
|
||||
}
|
||||
public void setAnnulmentOrder(String annulmentOrder) {
|
||||
this.annulmentOrder = annulmentOrder;
|
||||
}
|
||||
|
||||
|
||||
}
|
237
src/main/java/systems/archide/core/pojo/GeneralStatistics.java
Normal file
237
src/main/java/systems/archide/core/pojo/GeneralStatistics.java
Normal file
@ -0,0 +1,237 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GeneralStatistics {
|
||||
|
||||
Long issuedIdCardsNumber;
|
||||
Long notExpiredIdCardsNumber;
|
||||
Long notCancelledIdCardsNumber;
|
||||
Long activatedIdCardsNumber;
|
||||
Long distinctIndividualsIdCardsNumber;
|
||||
Long authorizedBirthRecordsNumber;
|
||||
Long livingAuthorizedBirthRecordsNumber;
|
||||
Long livingFemalesAged18To29Number;
|
||||
Long livingMalesAged18To29Number;
|
||||
Long livingMalesAgedUnder18Number;
|
||||
Long livingFemalesAgedUnder18Number;
|
||||
Long livingMalesAged30To49Number;
|
||||
Long livingFemalesAged30To49Number;
|
||||
Long livingMalesAgedOver49Number;
|
||||
Long livingFemalesAgedOver49Number;
|
||||
Long livingPeopleWithCardsNumber;
|
||||
Long livingMalesAgedUnder18WithCardsNumber;
|
||||
Long livingFemalesAgedUnder18WithCardsNumber;
|
||||
Long livingMalesAged18To29WithCardsNumber;
|
||||
Long livingFemalesAged18To29WithCardsNumber;
|
||||
Long livingMalesAged30To49WithCardsNumber;
|
||||
Long livingFemalesAged30To49WithCardsNumber;
|
||||
Long livingMalesAgedOver49WithCardsNumber;
|
||||
Long livingFemalesAgedOver49WithCardsNumber;
|
||||
List<ProvinceGeneralStatistics> provinceGeneralStatisticsList;
|
||||
|
||||
public GeneralStatistics() {
|
||||
|
||||
}
|
||||
|
||||
public Long getIssuedIdCardsNumber() {
|
||||
return issuedIdCardsNumber;
|
||||
}
|
||||
|
||||
public void setIssuedIdCardsNumber(Long issuedIdCardsNumber) {
|
||||
this.issuedIdCardsNumber = issuedIdCardsNumber;
|
||||
}
|
||||
|
||||
public Long getNotExpiredIdCardsNumber() {
|
||||
return notExpiredIdCardsNumber;
|
||||
}
|
||||
|
||||
public void setNotExpiredIdCardsNumber(Long notExpiredIdCardsNumber) {
|
||||
this.notExpiredIdCardsNumber = notExpiredIdCardsNumber;
|
||||
}
|
||||
|
||||
public Long getNotCancelledIdCardsNumber() {
|
||||
return notCancelledIdCardsNumber;
|
||||
}
|
||||
|
||||
public void setNotCancelledIdCardsNumber(Long notCancelledIdCardsNumber) {
|
||||
this.notCancelledIdCardsNumber = notCancelledIdCardsNumber;
|
||||
}
|
||||
|
||||
public Long getActivatedIdCardsNumber() {
|
||||
return activatedIdCardsNumber;
|
||||
}
|
||||
|
||||
public void setActivatedIdCardsNumber(Long activatedIdCardsNumber) {
|
||||
this.activatedIdCardsNumber = activatedIdCardsNumber;
|
||||
}
|
||||
|
||||
public Long getDistinctIndividualsIdCardsNumber() {
|
||||
return distinctIndividualsIdCardsNumber;
|
||||
}
|
||||
|
||||
public void setDistinctIndividualsIdCardsNumber(Long distinctIndividualsIdCardsNumber) {
|
||||
this.distinctIndividualsIdCardsNumber = distinctIndividualsIdCardsNumber;
|
||||
}
|
||||
|
||||
public Long getAuthorizedBirthRecordsNumber() {
|
||||
return authorizedBirthRecordsNumber;
|
||||
}
|
||||
|
||||
public void setAuthorizedBirthRecordsNumber(Long authorizedBirthRecordsNumber) {
|
||||
this.authorizedBirthRecordsNumber = authorizedBirthRecordsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingAuthorizedBirthRecordsNumber() {
|
||||
return livingAuthorizedBirthRecordsNumber;
|
||||
}
|
||||
|
||||
public void setLivingAuthorizedBirthRecordsNumber(Long livingAuthorizedBirthRecordsNumber) {
|
||||
this.livingAuthorizedBirthRecordsNumber = livingAuthorizedBirthRecordsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAged18To29Number() {
|
||||
return livingFemalesAged18To29Number;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAged18To29Number(Long livingFemalesAged18To29Number) {
|
||||
this.livingFemalesAged18To29Number = livingFemalesAged18To29Number;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAged18To29Number() {
|
||||
return livingMalesAged18To29Number;
|
||||
}
|
||||
|
||||
public void setLivingMalesAged18To29Number(Long livingMalesAged18To29Number) {
|
||||
this.livingMalesAged18To29Number = livingMalesAged18To29Number;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAgedUnder18Number() {
|
||||
return livingMalesAgedUnder18Number;
|
||||
}
|
||||
|
||||
public void setLivingMalesAgedUnder18Number(Long livingMalesAgedUnder18Number) {
|
||||
this.livingMalesAgedUnder18Number = livingMalesAgedUnder18Number;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAgedUnder18Number() {
|
||||
return livingFemalesAgedUnder18Number;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAgedUnder18Number(Long livingFemalesAgedUnder18Number) {
|
||||
this.livingFemalesAgedUnder18Number = livingFemalesAgedUnder18Number;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAged30To49Number() {
|
||||
return livingMalesAged30To49Number;
|
||||
}
|
||||
|
||||
public void setLivingMalesAged30To49Number(Long livingMalesAged30To49Number) {
|
||||
this.livingMalesAged30To49Number = livingMalesAged30To49Number;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAged30To49Number() {
|
||||
return livingFemalesAged30To49Number;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAged30To49Number(Long livingFemalesAged30To49Number) {
|
||||
this.livingFemalesAged30To49Number = livingFemalesAged30To49Number;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAgedOver49Number() {
|
||||
return livingMalesAgedOver49Number;
|
||||
}
|
||||
|
||||
public void setLivingMalesAgedOver49Number(Long livingMalesAgedOver49Number) {
|
||||
this.livingMalesAgedOver49Number = livingMalesAgedOver49Number;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAgedOver49Number() {
|
||||
return livingFemalesAgedOver49Number;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAgedOver49Number(Long livingFemalesAgedOver49Number) {
|
||||
this.livingFemalesAgedOver49Number = livingFemalesAgedOver49Number;
|
||||
}
|
||||
|
||||
public Long getLivingPeopleWithCardsNumber() {
|
||||
return livingPeopleWithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingPeopleWithCardsNumber(Long livingPeopleWithCardsNumber) {
|
||||
this.livingPeopleWithCardsNumber = livingPeopleWithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAgedUnder18WithCardsNumber() {
|
||||
return livingMalesAgedUnder18WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingMalesAgedUnder18WithCardsNumber(Long livingMalesAgedUnder18WithCardsNumber) {
|
||||
this.livingMalesAgedUnder18WithCardsNumber = livingMalesAgedUnder18WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAgedUnder18WithCardsNumber() {
|
||||
return livingFemalesAgedUnder18WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAgedUnder18WithCardsNumber(Long livingFemalesAgedUnder18WithCardsNumber) {
|
||||
this.livingFemalesAgedUnder18WithCardsNumber = livingFemalesAgedUnder18WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAged18To29WithCardsNumber() {
|
||||
return livingMalesAged18To29WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingMalesAged18To29WithCardsNumber(Long livingMalesAged18To29WithCardsNumber) {
|
||||
this.livingMalesAged18To29WithCardsNumber = livingMalesAged18To29WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAged18To29WithCardsNumber() {
|
||||
return livingFemalesAged18To29WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAged18To29WithCardsNumber(Long livingFemalesAged18To29WithCardsNumber) {
|
||||
this.livingFemalesAged18To29WithCardsNumber = livingFemalesAged18To29WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAged30To49WithCardsNumber() {
|
||||
return livingMalesAged30To49WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingMalesAged30To49WithCardsNumber(Long livingMalesAged30To49WithCardsNumber) {
|
||||
this.livingMalesAged30To49WithCardsNumber = livingMalesAged30To49WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAged30To49WithCardsNumber() {
|
||||
return livingFemalesAged30To49WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAged30To49WithCardsNumber(Long livingFemalesAged30To49WithCardsNumber) {
|
||||
this.livingFemalesAged30To49WithCardsNumber = livingFemalesAged30To49WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAgedOver49WithCardsNumber() {
|
||||
return livingMalesAgedOver49WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingMalesAgedOver49WithCardsNumber(Long livingMalesAgedOver49WithCardsNumber) {
|
||||
this.livingMalesAgedOver49WithCardsNumber = livingMalesAgedOver49WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAgedOver49WithCardsNumber() {
|
||||
return livingFemalesAgedOver49WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAgedOver49WithCardsNumber(Long livingFemalesAgedOver49WithCardsNumber) {
|
||||
this.livingFemalesAgedOver49WithCardsNumber = livingFemalesAgedOver49WithCardsNumber;
|
||||
}
|
||||
|
||||
public List<ProvinceGeneralStatistics> getProvinceGeneralStatisticsList() {
|
||||
return provinceGeneralStatisticsList;
|
||||
}
|
||||
|
||||
public void setProvinceGeneralStatisticsList(List<ProvinceGeneralStatistics> provinceGeneralStatisticsList) {
|
||||
this.provinceGeneralStatisticsList = provinceGeneralStatisticsList;
|
||||
}
|
||||
|
||||
}
|
35
src/main/java/systems/archide/core/pojo/LongRange.java
Normal file
35
src/main/java/systems/archide/core/pojo/LongRange.java
Normal file
@ -0,0 +1,35 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
public class LongRange {
|
||||
|
||||
Long min;
|
||||
Long max;
|
||||
|
||||
public LongRange() {
|
||||
|
||||
}
|
||||
|
||||
public LongRange(Long min, Long max) {
|
||||
super();
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public Long getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public void setMin(Long min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public Long getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setMax(Long max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,552 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public class MarriageCertificateResponse {
|
||||
|
||||
String partner1Surname;
|
||||
String partner1FirstNames;
|
||||
String partner1MelanesianName;
|
||||
String partner1SurnameAtBirth;
|
||||
String partner1FirstNamesAtBirth;
|
||||
short partner1Sex;
|
||||
LocalDate partner1DateOfBirth;
|
||||
String partner1BirthLocation;
|
||||
String partner1UsualResidence;
|
||||
|
||||
String partner2Surname;
|
||||
String partner2FirstNames;
|
||||
String partner2MelanesianName;
|
||||
String partner2SurnameAtBirth;
|
||||
String partner2FirstNamesAtBirth;
|
||||
short partner2Sex;
|
||||
LocalDate partner2DateOfBirth;
|
||||
String partner2BirthLocation;
|
||||
String partner2UsualResidence;
|
||||
|
||||
String declarationFullName;
|
||||
Long declarationNationalIdNumber;
|
||||
LocalDate declarationDate;
|
||||
String declarationPlace;
|
||||
String declarationOfficer;
|
||||
String declarationPosition;
|
||||
|
||||
String partner1MotherFamilyName;
|
||||
String partner1MotherFirstNames;
|
||||
String partner1MotherFamilyNameAtBirth;
|
||||
Long partner1MotherNationalIdNumber;
|
||||
String partner1FatherFamilyName;
|
||||
String partner1FatherFirstNames;
|
||||
String partner1FatherFamilyNameAtBirth;
|
||||
Long partner1FatherNationalIdNumber;
|
||||
|
||||
String partner2MotherFamilyName;
|
||||
String partner2MotherFirstNames;
|
||||
String partner2MotherFamilyNameAtBirth;
|
||||
Long partner2MotherNationalIdNumber;
|
||||
String partner2FatherFamilyName;
|
||||
String partner2FatherFirstNames;
|
||||
String partner2FatherFamilyNameAtBirth;
|
||||
Long partner2FatherNationalIdNumber;
|
||||
String partner1FatherName;
|
||||
String partner1MotherName;
|
||||
String partner2FatherName;
|
||||
String partner2MotherName;
|
||||
Long partner2VitalRecordId;
|
||||
Long partner1VitalRecordId;
|
||||
String celebrant;
|
||||
String firstWitnessName;
|
||||
Long firstWitnessId;
|
||||
String secondWitnessName;
|
||||
Long secondWitnessId;
|
||||
|
||||
String position;
|
||||
String officer;
|
||||
Integer marriageType;
|
||||
|
||||
LocalTime timeOfMarriage;
|
||||
|
||||
Boolean partner1reported;
|
||||
Boolean partner2reported;
|
||||
|
||||
String registrationLocation;
|
||||
String mentions;
|
||||
|
||||
public MarriageCertificateResponse() {
|
||||
|
||||
}
|
||||
|
||||
public String getRegistrationLocation() {
|
||||
return registrationLocation;
|
||||
}
|
||||
|
||||
public void setRegistrationLocation(String registrationLocation) {
|
||||
this.registrationLocation = registrationLocation;
|
||||
}
|
||||
|
||||
public String getMentions() {
|
||||
return mentions;
|
||||
}
|
||||
|
||||
public void setMentions(String mentions) {
|
||||
this.mentions = mentions;
|
||||
}
|
||||
|
||||
public Integer getMarriageType() {
|
||||
return marriageType;
|
||||
}
|
||||
|
||||
public void setMarriageType(Integer marriageType) {
|
||||
this.marriageType = marriageType;
|
||||
}
|
||||
|
||||
public LocalTime getTimeOfMarriage() {
|
||||
return timeOfMarriage;
|
||||
}
|
||||
|
||||
public void setTimeOfMarriage(LocalTime timeOfMarriage) {
|
||||
this.timeOfMarriage = timeOfMarriage;
|
||||
}
|
||||
|
||||
public String getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(String position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public String getOfficer() {
|
||||
return officer;
|
||||
}
|
||||
|
||||
public void setOfficer(String officer) {
|
||||
this.officer = officer;
|
||||
}
|
||||
|
||||
public Boolean getPartner1reported() {
|
||||
return partner1reported;
|
||||
}
|
||||
|
||||
public void setPartner1reported(Boolean partner1reported) {
|
||||
this.partner1reported = partner1reported;
|
||||
}
|
||||
|
||||
public Boolean getPartner2reported() {
|
||||
return partner2reported;
|
||||
}
|
||||
|
||||
public void setPartner2reported(Boolean partner2reported) {
|
||||
this.partner2reported = partner2reported;
|
||||
}
|
||||
|
||||
public String getFirstWitnessName() {
|
||||
return firstWitnessName;
|
||||
}
|
||||
|
||||
public void setFirstWitnessName(String firstWitnessName) {
|
||||
this.firstWitnessName = firstWitnessName;
|
||||
}
|
||||
|
||||
public Long getFirstWitnessId() {
|
||||
return firstWitnessId;
|
||||
}
|
||||
|
||||
public void setFirstWitnessId(Long firstWitnessId) {
|
||||
this.firstWitnessId = firstWitnessId;
|
||||
}
|
||||
|
||||
public String getSecondWitnessName() {
|
||||
return secondWitnessName;
|
||||
}
|
||||
|
||||
public void setSecondWitnessName(String secondWitnessName) {
|
||||
this.secondWitnessName = secondWitnessName;
|
||||
}
|
||||
|
||||
public Long getSecondWitnessId() {
|
||||
return secondWitnessId;
|
||||
}
|
||||
|
||||
public void setSecondWitnessId(Long secondWitnessId) {
|
||||
this.secondWitnessId = secondWitnessId;
|
||||
}
|
||||
|
||||
public Long getPartner2VitalRecordId() {
|
||||
return partner2VitalRecordId;
|
||||
}
|
||||
|
||||
public void setPartner2VitalRecordId(Long partner2VitalRecordId) {
|
||||
this.partner2VitalRecordId = partner2VitalRecordId;
|
||||
}
|
||||
|
||||
public Long getPartner1VitalRecordId() {
|
||||
return partner1VitalRecordId;
|
||||
}
|
||||
|
||||
public void setPartner1VitalRecordId(Long partner1VitalRecordId) {
|
||||
this.partner1VitalRecordId = partner1VitalRecordId;
|
||||
}
|
||||
|
||||
public String getCelebrant() {
|
||||
return celebrant;
|
||||
}
|
||||
|
||||
public void setCelebrant(String celebrant) {
|
||||
this.celebrant = celebrant;
|
||||
}
|
||||
|
||||
public String getPartner1MotherName() {
|
||||
return partner1MotherName;
|
||||
}
|
||||
|
||||
public void setPartner1MotherName(String partner1MotherName) {
|
||||
this.partner1MotherName = partner1MotherName;
|
||||
}
|
||||
|
||||
public String getPartner2FatherName() {
|
||||
return partner2FatherName;
|
||||
}
|
||||
|
||||
public void setPartner2FatherName(String partner2FatherName) {
|
||||
this.partner2FatherName = partner2FatherName;
|
||||
}
|
||||
|
||||
public String getPartner2MotherName() {
|
||||
return partner2MotherName;
|
||||
}
|
||||
|
||||
public void setPartner2MotherName(String partner2MotherName) {
|
||||
this.partner2MotherName = partner2MotherName;
|
||||
}
|
||||
|
||||
public String getPartner1FatherName() {
|
||||
return partner1FatherName;
|
||||
}
|
||||
|
||||
public void setPartner1FatherFirstNames(String partner1FatherFirstNames) {
|
||||
this.partner1FatherFirstNames = partner1FatherFirstNames;
|
||||
}
|
||||
|
||||
public String getPartner1Surname() {
|
||||
return partner1Surname;
|
||||
}
|
||||
|
||||
public void setPartner1Surname(String partner1Surname) {
|
||||
this.partner1Surname = partner1Surname;
|
||||
}
|
||||
|
||||
public String getPartner1FirstNames() {
|
||||
return partner1FirstNames;
|
||||
}
|
||||
|
||||
public void setPartner1FirstNames(String partner1FirstNames) {
|
||||
this.partner1FirstNames = partner1FirstNames;
|
||||
}
|
||||
|
||||
public String getPartner1MelanesianName() {
|
||||
return partner1MelanesianName;
|
||||
}
|
||||
|
||||
public void setPartner1MelanesianName(String partner1MelanesianName) {
|
||||
this.partner1MelanesianName = partner1MelanesianName;
|
||||
}
|
||||
|
||||
public String getPartner1SurnameAtBirth() {
|
||||
return partner1SurnameAtBirth;
|
||||
}
|
||||
|
||||
public void setPartner1SurnameAtBirth(String partner1SurnameAtBirth) {
|
||||
this.partner1SurnameAtBirth = partner1SurnameAtBirth;
|
||||
}
|
||||
|
||||
public String getPartner1FirstNamesAtBirth() {
|
||||
return partner1FirstNamesAtBirth;
|
||||
}
|
||||
|
||||
public void setPartner1FirstNamesAtBirth(String partner1FirstNamesAtBirth) {
|
||||
this.partner1FirstNamesAtBirth = partner1FirstNamesAtBirth;
|
||||
}
|
||||
|
||||
public short getPartner1Sex() {
|
||||
return partner1Sex;
|
||||
}
|
||||
|
||||
public void setPartner1Sex(short partner1Sex) {
|
||||
this.partner1Sex = partner1Sex;
|
||||
}
|
||||
|
||||
public LocalDate getPartner1DateOfBirth() {
|
||||
return partner1DateOfBirth;
|
||||
}
|
||||
|
||||
public void setPartner1DateOfBirth(LocalDate partner1DateOfBirth) {
|
||||
this.partner1DateOfBirth = partner1DateOfBirth;
|
||||
}
|
||||
|
||||
public String getPartner1BirthLocation() {
|
||||
return partner1BirthLocation;
|
||||
}
|
||||
|
||||
public void setPartner1BirthLocation(String partner1BirthLocation) {
|
||||
this.partner1BirthLocation = partner1BirthLocation;
|
||||
}
|
||||
|
||||
public String getPartner1UsualResidence() {
|
||||
return partner1UsualResidence;
|
||||
}
|
||||
|
||||
public void setPartner1UsualResidence(String partner1UsualResidence) {
|
||||
this.partner1UsualResidence = partner1UsualResidence;
|
||||
}
|
||||
|
||||
public String getPartner2Surname() {
|
||||
return partner2Surname;
|
||||
}
|
||||
|
||||
public void setPartner2Surname(String partner2Surname) {
|
||||
this.partner2Surname = partner2Surname;
|
||||
}
|
||||
|
||||
public String getPartner2FirstNames() {
|
||||
return partner2FirstNames;
|
||||
}
|
||||
|
||||
public void setPartner2FirstNames(String partner2FirstNames) {
|
||||
this.partner2FirstNames = partner2FirstNames;
|
||||
}
|
||||
|
||||
public String getPartner2MelanesianName() {
|
||||
return partner2MelanesianName;
|
||||
}
|
||||
|
||||
public void setPartner2MelanesianName(String partner2MelanesianName) {
|
||||
this.partner2MelanesianName = partner2MelanesianName;
|
||||
}
|
||||
|
||||
public String getPartner2SurnameAtBirth() {
|
||||
return partner2SurnameAtBirth;
|
||||
}
|
||||
|
||||
public void setPartner2SurnameAtBirth(String partner2SurnameAtBirth) {
|
||||
this.partner2SurnameAtBirth = partner2SurnameAtBirth;
|
||||
}
|
||||
|
||||
public String getPartner2FirstNamesAtBirth() {
|
||||
return partner2FirstNamesAtBirth;
|
||||
}
|
||||
|
||||
public void setPartner2FirstNamesAtBirth(String partner2FirstNamesAtBirth) {
|
||||
this.partner2FirstNamesAtBirth = partner2FirstNamesAtBirth;
|
||||
}
|
||||
|
||||
public short getPartner2Sex() {
|
||||
return partner2Sex;
|
||||
}
|
||||
|
||||
public void setPartner2Sex(short partner2Sex) {
|
||||
this.partner2Sex = partner2Sex;
|
||||
}
|
||||
|
||||
public LocalDate getPartner2DateOfBirth() {
|
||||
return partner2DateOfBirth;
|
||||
}
|
||||
|
||||
public void setPartner2DateOfBirth(LocalDate partner2DateOfBirth) {
|
||||
this.partner2DateOfBirth = partner2DateOfBirth;
|
||||
}
|
||||
|
||||
public String getPartner2BirthLocation() {
|
||||
return partner2BirthLocation;
|
||||
}
|
||||
|
||||
public void setPartner2BirthLocation(String partner2BirthLocation) {
|
||||
this.partner2BirthLocation = partner2BirthLocation;
|
||||
}
|
||||
|
||||
public String getPartner2UsualResidence() {
|
||||
return partner2UsualResidence;
|
||||
}
|
||||
|
||||
public void setPartner2UsualResidence(String partner2UsualResidence) {
|
||||
this.partner2UsualResidence = partner2UsualResidence;
|
||||
}
|
||||
|
||||
public String getDeclarationFullName() {
|
||||
return declarationFullName;
|
||||
}
|
||||
|
||||
public void setDeclarationFullName(String declarationFullName) {
|
||||
this.declarationFullName = declarationFullName;
|
||||
}
|
||||
|
||||
public Long getDeclarationNationalIdNumber() {
|
||||
return declarationNationalIdNumber;
|
||||
}
|
||||
|
||||
public void setDeclarationNationalIdNumber(Long declarationNationalIdNumber) {
|
||||
this.declarationNationalIdNumber = declarationNationalIdNumber;
|
||||
}
|
||||
|
||||
public LocalDate getDeclarationDate() {
|
||||
return declarationDate;
|
||||
}
|
||||
|
||||
public void setDeclarationDate(LocalDate declarationDate) {
|
||||
this.declarationDate = declarationDate;
|
||||
}
|
||||
|
||||
public String getDeclarationPlace() {
|
||||
return declarationPlace;
|
||||
}
|
||||
|
||||
public void setDeclarationPlace(String declarationPlace) {
|
||||
this.declarationPlace = declarationPlace;
|
||||
}
|
||||
|
||||
public String getDeclarationOfficer() {
|
||||
return declarationOfficer;
|
||||
}
|
||||
|
||||
public void setDeclarationOfficer(String declarationOfficer) {
|
||||
this.declarationOfficer = declarationOfficer;
|
||||
}
|
||||
|
||||
public String getDeclarationPosition() {
|
||||
return declarationPosition;
|
||||
}
|
||||
|
||||
public void setDeclarationPosition(String declarationPosition) {
|
||||
this.declarationPosition = declarationPosition;
|
||||
}
|
||||
|
||||
public String getPartner1MotherFamilyName() {
|
||||
return partner1MotherFamilyName;
|
||||
}
|
||||
|
||||
public void setPartner1MotherFamilyName(String partner1MotherFamilyName) {
|
||||
this.partner1MotherFamilyName = partner1MotherFamilyName;
|
||||
}
|
||||
|
||||
public String getPartner1MotherFirstNames() {
|
||||
return partner1MotherFirstNames;
|
||||
}
|
||||
|
||||
public void setPartner1MotherFirstNames(String partner1MotherFirstNames) {
|
||||
this.partner1MotherFirstNames = partner1MotherFirstNames;
|
||||
}
|
||||
|
||||
public String getPartner1MotherFamilyNameAtBirth() {
|
||||
return partner1MotherFamilyNameAtBirth;
|
||||
}
|
||||
|
||||
public void setPartner1MotherFamilyNameAtBirth(String partner1MotherFamilyNameAtBirth) {
|
||||
this.partner1MotherFamilyNameAtBirth = partner1MotherFamilyNameAtBirth;
|
||||
}
|
||||
|
||||
public Long getPartner1MotherNationalIdNumber() {
|
||||
return partner1MotherNationalIdNumber;
|
||||
}
|
||||
|
||||
public void setPartner1MotherNationalIdNumber(Long partner1MotherNationalIdNumber) {
|
||||
this.partner1MotherNationalIdNumber = partner1MotherNationalIdNumber;
|
||||
}
|
||||
|
||||
public String getPartner1FatherFamilyName() {
|
||||
return partner1FatherFamilyName;
|
||||
}
|
||||
|
||||
public void setPartner1FatherFamilyName(String partner1FatherFamilyName) {
|
||||
this.partner1FatherFamilyName = partner1FatherFamilyName;
|
||||
}
|
||||
|
||||
public String getPartner1FatherFirstNames() {
|
||||
return partner1FatherFirstNames;
|
||||
}
|
||||
|
||||
public void setPartner1FatherName(String partner1FatherName) {
|
||||
this.partner1FatherName= partner1FatherName;
|
||||
}
|
||||
|
||||
public String getPartner1FatherFamilyNameAtBirth() {
|
||||
return partner1FatherFamilyNameAtBirth;
|
||||
}
|
||||
|
||||
public void setPartner1FatherFamilyNameAtBirth(String partner1FatherFamilyNameAtBirth) {
|
||||
this.partner1FatherFamilyNameAtBirth = partner1FatherFamilyNameAtBirth;
|
||||
}
|
||||
|
||||
public Long getPartner1FatherNationalIdNumber() {
|
||||
return partner1FatherNationalIdNumber;
|
||||
}
|
||||
|
||||
public void setPartner1FatherNationalIdNumber(Long partner1FatherNationalIdNumber) {
|
||||
this.partner1FatherNationalIdNumber = partner1FatherNationalIdNumber;
|
||||
}
|
||||
|
||||
public String getPartner2MotherFamilyName() {
|
||||
return partner2MotherFamilyName;
|
||||
}
|
||||
|
||||
public void setPartner2MotherFamilyName(String partner2MotherFamilyName) {
|
||||
this.partner2MotherFamilyName = partner2MotherFamilyName;
|
||||
}
|
||||
|
||||
public String getPartner2MotherFirstNames() {
|
||||
return partner2MotherFirstNames;
|
||||
}
|
||||
|
||||
public void setPartner2MotherFirstNames(String partner2MotherFirstNames) {
|
||||
this.partner2MotherFirstNames = partner2MotherFirstNames;
|
||||
}
|
||||
|
||||
public String getPartner2MotherFamilyNameAtBirth() {
|
||||
return partner2MotherFamilyNameAtBirth;
|
||||
}
|
||||
|
||||
public void setPartner2MotherFamilyNameAtBirth(String partner2MotherFamilyNameAtBirth) {
|
||||
this.partner2MotherFamilyNameAtBirth = partner2MotherFamilyNameAtBirth;
|
||||
}
|
||||
|
||||
public Long getPartner2MotherNationalIdNumber() {
|
||||
return partner2MotherNationalIdNumber;
|
||||
}
|
||||
|
||||
public void setPartner2MotherNationalIdNumber(Long partner2MotherNationalIdNumber) {
|
||||
this.partner2MotherNationalIdNumber = partner2MotherNationalIdNumber;
|
||||
}
|
||||
|
||||
public String getPartner2FatherFamilyName() {
|
||||
return partner2FatherFamilyName;
|
||||
}
|
||||
|
||||
public void setPartner2FatherFamilyName(String partner2FatherFamilyName) {
|
||||
this.partner2FatherFamilyName = partner2FatherFamilyName;
|
||||
}
|
||||
|
||||
public String getPartner2FatherFirstNames() {
|
||||
return partner2FatherFirstNames;
|
||||
}
|
||||
|
||||
public void setPartner2FatherFirstNames(String partner2FatherFirstNames) {
|
||||
this.partner2FatherFirstNames = partner2FatherFirstNames;
|
||||
}
|
||||
|
||||
public String getPartner2FatherFamilyNameAtBirth() {
|
||||
return partner2FatherFamilyNameAtBirth;
|
||||
}
|
||||
|
||||
public void setPartner2FatherFamilyNameAtBirth(String partner2FatherFamilyNameAtBirth) {
|
||||
this.partner2FatherFamilyNameAtBirth = partner2FatherFamilyNameAtBirth;
|
||||
}
|
||||
|
||||
public Long getPartner2FatherNationalIdNumber() {
|
||||
return partner2FatherNationalIdNumber;
|
||||
}
|
||||
|
||||
public void setPartner2FatherNationalIdNumber(Long partner2FatherNationalIdNumber) {
|
||||
this.partner2FatherNationalIdNumber = partner2FatherNationalIdNumber;
|
||||
}
|
||||
|
||||
}
|
31
src/main/java/systems/archide/core/pojo/PreparedQuery.java
Normal file
31
src/main/java/systems/archide/core/pojo/PreparedQuery.java
Normal file
@ -0,0 +1,31 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PreparedQuery {
|
||||
|
||||
private String query;
|
||||
private List<Object> parameters;
|
||||
|
||||
public PreparedQuery(String query, List<Object> parameters) {
|
||||
this.query = query;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public List<Object> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(List<Object> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
public class ProvinceGeneralStatistics {
|
||||
|
||||
String provinceName;
|
||||
Long authorizedBirthRecordsNumber;
|
||||
Long livingAuthorizedBirthRecordsNumber;
|
||||
Long livingFemalesAged18To29Number;
|
||||
Long livingMalesAged18To29Number;
|
||||
Long livingMalesAgedUnder18Number;
|
||||
Long livingFemalesAgedUnder18Number;
|
||||
Long livingMalesAged30To49Number;
|
||||
Long livingFemalesAged30To49Number;
|
||||
Long livingMalesAgedOver49Number;
|
||||
Long livingFemalesAgedOver49Number;
|
||||
Long livingPeopleWithCardsNumber;
|
||||
Long livingMalesAgedUnder18WithCardsNumber;
|
||||
Long livingFemalesAgedUnder18WithCardsNumber;
|
||||
Long livingMalesAged18To29WithCardsNumber;
|
||||
Long livingFemalesAged18To29WithCardsNumber;
|
||||
Long livingMalesAged30To49WithCardsNumber;
|
||||
Long livingFemalesAged30To49WithCardsNumber;
|
||||
Long livingMalesAgedOver49WithCardsNumber;
|
||||
Long livingFemalesAgedOver49WithCardsNumber;
|
||||
|
||||
public ProvinceGeneralStatistics() {
|
||||
|
||||
}
|
||||
|
||||
public String getProvinceName() {
|
||||
return provinceName;
|
||||
}
|
||||
|
||||
public void setProvinceName(String provinceName) {
|
||||
this.provinceName = provinceName;
|
||||
}
|
||||
|
||||
public Long getAuthorizedBirthRecordsNumber() {
|
||||
return authorizedBirthRecordsNumber;
|
||||
}
|
||||
|
||||
public void setAuthorizedBirthRecordsNumber(Long authorizedBirthRecordsNumber) {
|
||||
this.authorizedBirthRecordsNumber = authorizedBirthRecordsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingAuthorizedBirthRecordsNumber() {
|
||||
return livingAuthorizedBirthRecordsNumber;
|
||||
}
|
||||
|
||||
public void setLivingAuthorizedBirthRecordsNumber(Long livingAuthorizedBirthRecordsNumber) {
|
||||
this.livingAuthorizedBirthRecordsNumber = livingAuthorizedBirthRecordsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAged18To29Number() {
|
||||
return livingFemalesAged18To29Number;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAged18To29Number(Long livingFemalesAged18To29Number) {
|
||||
this.livingFemalesAged18To29Number = livingFemalesAged18To29Number;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAged18To29Number() {
|
||||
return livingMalesAged18To29Number;
|
||||
}
|
||||
|
||||
public void setLivingMalesAged18To29Number(Long livingMalesAged18To29Number) {
|
||||
this.livingMalesAged18To29Number = livingMalesAged18To29Number;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAgedUnder18Number() {
|
||||
return livingMalesAgedUnder18Number;
|
||||
}
|
||||
|
||||
public void setLivingMalesAgedUnder18Number(Long livingMalesAgedUnder18Number) {
|
||||
this.livingMalesAgedUnder18Number = livingMalesAgedUnder18Number;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAgedUnder18Number() {
|
||||
return livingFemalesAgedUnder18Number;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAgedUnder18Number(Long livingFemalesAgedUnder18Number) {
|
||||
this.livingFemalesAgedUnder18Number = livingFemalesAgedUnder18Number;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAged30To49Number() {
|
||||
return livingMalesAged30To49Number;
|
||||
}
|
||||
|
||||
public void setLivingMalesAged30To49Number(Long livingMalesAged30To49Number) {
|
||||
this.livingMalesAged30To49Number = livingMalesAged30To49Number;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAged30To49Number() {
|
||||
return livingFemalesAged30To49Number;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAged30To49Number(Long livingFemalesAged30To49Number) {
|
||||
this.livingFemalesAged30To49Number = livingFemalesAged30To49Number;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAgedOver49Number() {
|
||||
return livingMalesAgedOver49Number;
|
||||
}
|
||||
|
||||
public void setLivingMalesAgedOver49Number(Long livingMalesAgedOver49Number) {
|
||||
this.livingMalesAgedOver49Number = livingMalesAgedOver49Number;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAgedOver49Number() {
|
||||
return livingFemalesAgedOver49Number;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAgedOver49Number(Long livingFemalesAgedOver49Number) {
|
||||
this.livingFemalesAgedOver49Number = livingFemalesAgedOver49Number;
|
||||
}
|
||||
|
||||
public Long getLivingPeopleWithCardsNumber() {
|
||||
return livingPeopleWithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingPeopleWithCardsNumber(Long livingPeopleWithCardsNumber) {
|
||||
this.livingPeopleWithCardsNumber = livingPeopleWithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAgedUnder18WithCardsNumber() {
|
||||
return livingMalesAgedUnder18WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingMalesAgedUnder18WithCardsNumber(Long livingMalesAgedUnder18WithCardsNumber) {
|
||||
this.livingMalesAgedUnder18WithCardsNumber = livingMalesAgedUnder18WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAgedUnder18WithCardsNumber() {
|
||||
return livingFemalesAgedUnder18WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAgedUnder18WithCardsNumber(Long livingFemalesAgedUnder18WithCardsNumber) {
|
||||
this.livingFemalesAgedUnder18WithCardsNumber = livingFemalesAgedUnder18WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAged18To29WithCardsNumber() {
|
||||
return livingMalesAged18To29WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingMalesAged18To29WithCardsNumber(Long livingMalesAged18To29WithCardsNumber) {
|
||||
this.livingMalesAged18To29WithCardsNumber = livingMalesAged18To29WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAged18To29WithCardsNumber() {
|
||||
return livingFemalesAged18To29WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAged18To29WithCardsNumber(Long livingFemalesAged18To29WithCardsNumber) {
|
||||
this.livingFemalesAged18To29WithCardsNumber = livingFemalesAged18To29WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAged30To49WithCardsNumber() {
|
||||
return livingMalesAged30To49WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingMalesAged30To49WithCardsNumber(Long livingMalesAged30To49WithCardsNumber) {
|
||||
this.livingMalesAged30To49WithCardsNumber = livingMalesAged30To49WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAged30To49WithCardsNumber() {
|
||||
return livingFemalesAged30To49WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAged30To49WithCardsNumber(Long livingFemalesAged30To49WithCardsNumber) {
|
||||
this.livingFemalesAged30To49WithCardsNumber = livingFemalesAged30To49WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingMalesAgedOver49WithCardsNumber() {
|
||||
return livingMalesAgedOver49WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingMalesAgedOver49WithCardsNumber(Long livingMalesAgedOver49WithCardsNumber) {
|
||||
this.livingMalesAgedOver49WithCardsNumber = livingMalesAgedOver49WithCardsNumber;
|
||||
}
|
||||
|
||||
public Long getLivingFemalesAgedOver49WithCardsNumber() {
|
||||
return livingFemalesAgedOver49WithCardsNumber;
|
||||
}
|
||||
|
||||
public void setLivingFemalesAgedOver49WithCardsNumber(Long livingFemalesAgedOver49WithCardsNumber) {
|
||||
this.livingFemalesAgedOver49WithCardsNumber = livingFemalesAgedOver49WithCardsNumber;
|
||||
}
|
||||
|
||||
}
|
176
src/main/java/systems/archide/core/pojo/QueryBuilder.java
Normal file
176
src/main/java/systems/archide/core/pojo/QueryBuilder.java
Normal file
@ -0,0 +1,176 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
import systems.archide.core.controller.search.Fuzziness;
|
||||
|
||||
public class QueryBuilder {
|
||||
private List<Object> parameters = new ArrayList<>();
|
||||
|
||||
public PreparedQuery buildQuery(SearchQueryInput input, String tableName, Long limit, Long offset, String orderBy) {
|
||||
StringBuilder query = new StringBuilder("SELECT * FROM " + tableName + " WHERE ");
|
||||
for (int i = 0; i < input.getColumns().size(); i++) {
|
||||
if (i < input.getColumns().size() - 1)
|
||||
appendCondition(query, input.getColumns().get(i), true, input.getCaseSensitiveSearch());
|
||||
else
|
||||
appendCondition(query, input.getColumns().get(i), false, input.getCaseSensitiveSearch());
|
||||
}
|
||||
if (orderBy != null)
|
||||
query.append(" order by " + orderBy);
|
||||
if (limit != null)
|
||||
query.append(" limit " + limit);
|
||||
if (offset != null) {
|
||||
query.append(" offset " + offset);
|
||||
}
|
||||
return new PreparedQuery(query.toString(), parameters);
|
||||
}
|
||||
|
||||
private void appendCondition(StringBuilder query, SearchColumn column, Boolean and, Boolean caseSensitiveSearch) {
|
||||
switch (column.getType().toLowerCase()) {
|
||||
case "text":
|
||||
handleTextType(query, column, and, caseSensitiveSearch);
|
||||
break;
|
||||
case "number":
|
||||
handleNumberType(query, column, and);
|
||||
break;
|
||||
case "boolean":
|
||||
handleBooleanType(query, column, and);
|
||||
break;
|
||||
case "date":
|
||||
handleDateType(query, column, and);
|
||||
break;
|
||||
case "enum":
|
||||
handleEnumType(query, column, and);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported column type: " + column.getType());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTextType(StringBuilder query, SearchColumn column, Boolean and, Boolean caseSensitiveSearch) {
|
||||
if (column.getTextValue() != null) {
|
||||
if (column.getSearchType().equals("fuzzy")) {
|
||||
query.append("(SIMILARITY(").append(formatColumnName(column.getName())).append(", ?) > ").append(Fuzziness.AUTO.getFuzzinessValue()).append(") ");
|
||||
parameters.add(column.getTextValue());
|
||||
} else if (column.getSearchType().equals("exact")) {
|
||||
query.append(formatColumnName(column.getName())).append(" = ?");
|
||||
parameters.add(column.getTextValue());
|
||||
} else if (column.getSearchType().equals("startsWith")) {
|
||||
if (caseSensitiveSearch) {
|
||||
query.append(formatColumnName(column.getName())).append(" LIKE ?");
|
||||
} else {
|
||||
query.append(formatColumnName(column.getName())).append(" ILIKE ?");
|
||||
}
|
||||
parameters.add(column.getTextValue() + "%");
|
||||
} else if (column.getSearchType().equals("notStartsWith")) {
|
||||
if (caseSensitiveSearch) {
|
||||
query.append(formatColumnName(column.getName())).append(" NOT LIKE ?");
|
||||
} else {
|
||||
query.append(formatColumnName(column.getName())).append(" NOT ILIKE ?");
|
||||
}
|
||||
parameters.add(column.getTextValue() + "%");
|
||||
} else {
|
||||
query.append("(SIMILARITY(").append(formatColumnName(column.getName())).append(", ?) > ").append(Fuzziness.AUTO.getFuzzinessValue()).append(") ");
|
||||
parameters.add(column.getTextValue());
|
||||
}
|
||||
if (and)
|
||||
query.append(" ").append("and").append(" ");
|
||||
else
|
||||
query.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleNumberType(StringBuilder query, SearchColumn column, Boolean and) {
|
||||
if (column.getLongRange() != null) {
|
||||
query.append(formatColumnName(column.getName())).append(" BETWEEN ? AND ?");
|
||||
parameters.add(column.getLongRange().getMin());
|
||||
parameters.add(column.getLongRange().getMax());
|
||||
if (and)
|
||||
query.append(" ").append("and").append(" ");
|
||||
else
|
||||
query.append(" ");
|
||||
} else if (column.getLongValue() != null) {
|
||||
query.append(formatColumnName(column.getName())).append(" = ?");
|
||||
parameters.add(column.getLongValue()); // Assuming value is provided
|
||||
if (and)
|
||||
query.append(" ").append("and").append(" ");
|
||||
else
|
||||
query.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDateType(StringBuilder query, SearchColumn column, Boolean and) {
|
||||
if (column.getDateRange() != null) {
|
||||
query.append(formatColumnName(column.getName())).append(" BETWEEN ? AND ?");
|
||||
parameters.add(column.getDateRange().getMin());
|
||||
parameters.add(column.getDateRange().getMax());
|
||||
if (and)
|
||||
query.append(" ").append("and").append(" ");
|
||||
else
|
||||
query.append(" ");
|
||||
} else if (column.getDateValue() != null) {
|
||||
query.append(formatColumnName(column.getName())).append(" = ?");
|
||||
parameters.add(column.getDateValue()); // Assuming value is provided
|
||||
if (and)
|
||||
query.append(" ").append("and").append(" ");
|
||||
else
|
||||
query.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBooleanType(StringBuilder query, SearchColumn column, Boolean and) {
|
||||
if (column.getBooleanValue() != null) {
|
||||
query.append(formatColumnName(column.getName())).append(" = ?");
|
||||
parameters.add(column.getBooleanValue());
|
||||
if (and)
|
||||
query.append(" ").append("and").append(" ");
|
||||
else
|
||||
query.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: This is hardcoded enum type (need to add enum type: shor or integer ...)
|
||||
private void handleEnumType(StringBuilder query, SearchColumn column, Boolean and) {
|
||||
if (column.getEnumValues() != null)
|
||||
if (!column.getEnumValues().isEmpty()) {
|
||||
query.append(formatColumnName(column.getName())).append(" IN (");
|
||||
for (int i = 0; i < column.getEnumValues().size(); i++) {
|
||||
query.append("?");
|
||||
if (i < column.getEnumValues().size() - 1) {
|
||||
query.append(", ");
|
||||
}
|
||||
parameters.add(Short.parseShort(column.getEnumValues().get(i)));
|
||||
}
|
||||
query.append(")");
|
||||
if (and)
|
||||
query.append(" ").append("and").append(" ");
|
||||
else
|
||||
query.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private String formatColumnName(String columnName) {
|
||||
return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, columnName);
|
||||
}
|
||||
|
||||
public PreparedQuery buildQuery(SearchQueryInput input, String tableName) {
|
||||
if (!input.getColumns().isEmpty()) {
|
||||
StringBuilder query = new StringBuilder("select count(id) from " + tableName + " WHERE ");
|
||||
for (int i = 0; i < input.getColumns().size(); i++) {
|
||||
if (i < input.getColumns().size() - 1)
|
||||
appendCondition(query, input.getColumns().get(i), true, input.getCaseSensitiveSearch());
|
||||
else
|
||||
appendCondition(query, input.getColumns().get(i), false, input.getCaseSensitiveSearch());
|
||||
}
|
||||
return new PreparedQuery(query.toString(), parameters);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
128
src/main/java/systems/archide/core/pojo/SearchColumn.java
Normal file
128
src/main/java/systems/archide/core/pojo/SearchColumn.java
Normal file
@ -0,0 +1,128 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public class SearchColumn {
|
||||
|
||||
String name;
|
||||
String type;
|
||||
String searchType;
|
||||
LongRange longRange;
|
||||
DateRange dateRange;
|
||||
List<String> enumValues;
|
||||
Boolean booleanValue;
|
||||
String textValue;
|
||||
Long longValue;
|
||||
LocalDate dateValue;
|
||||
Boolean and;
|
||||
|
||||
public SearchColumn(String name, String type, String searchType, LongRange longRange, DateRange dateRange,
|
||||
List<String> enumValues, Boolean and, Boolean booleanValue, String textValue, Long longValue, LocalDate dateValue) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.searchType = searchType;
|
||||
this.longRange = longRange;
|
||||
this.dateRange = dateRange;
|
||||
this.enumValues = enumValues;
|
||||
this.booleanValue = booleanValue;
|
||||
this.textValue = textValue;
|
||||
this.longValue = longValue;
|
||||
this.dateValue = dateValue;
|
||||
this.and = and;
|
||||
}
|
||||
|
||||
public SearchColumn() {
|
||||
|
||||
}
|
||||
|
||||
public Long getLongValue() {
|
||||
return longValue;
|
||||
}
|
||||
|
||||
public void setLongValue(Long longValue) {
|
||||
this.longValue = longValue;
|
||||
}
|
||||
|
||||
public LocalDate getDateValue() {
|
||||
return dateValue;
|
||||
}
|
||||
|
||||
public void setDateValue(LocalDate dateValue) {
|
||||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public String getTextValue() {
|
||||
return textValue;
|
||||
}
|
||||
|
||||
public void setTextValue(String textValue) {
|
||||
this.textValue = textValue;
|
||||
}
|
||||
|
||||
public Boolean getBooleanValue() {
|
||||
return booleanValue;
|
||||
}
|
||||
|
||||
public void setBooleanValue(Boolean booleanValue) {
|
||||
this.booleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSearchType() {
|
||||
return searchType;
|
||||
}
|
||||
|
||||
public void setSearchType(String searchType) {
|
||||
this.searchType = searchType;
|
||||
}
|
||||
|
||||
public LongRange getLongRange() {
|
||||
return longRange;
|
||||
}
|
||||
|
||||
public void setLongRange(LongRange longRange) {
|
||||
this.longRange = longRange;
|
||||
}
|
||||
|
||||
public DateRange getDateRange() {
|
||||
return dateRange;
|
||||
}
|
||||
|
||||
public void setDateRange(DateRange dateRange) {
|
||||
this.dateRange = dateRange;
|
||||
}
|
||||
|
||||
public List<String> getEnumValues() {
|
||||
return enumValues;
|
||||
}
|
||||
|
||||
public void setEnumValues(List<String> enumValues) {
|
||||
this.enumValues = enumValues;
|
||||
}
|
||||
|
||||
public Boolean getAnd() {
|
||||
return and;
|
||||
}
|
||||
|
||||
public void setAnd(Boolean and) {
|
||||
this.and = and;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package systems.archide.core.pojo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SearchQueryInput {
|
||||
|
||||
List<SearchColumn> columns;
|
||||
Boolean caseSensitiveSearch;
|
||||
|
||||
public SearchQueryInput() {
|
||||
|
||||
}
|
||||
|
||||
public List<SearchColumn> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(List<SearchColumn> columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public Boolean getCaseSensitiveSearch() {
|
||||
return caseSensitiveSearch;
|
||||
}
|
||||
|
||||
public void setCaseSensitiveSearch(Boolean caseSensitiveSearch) {
|
||||
this.caseSensitiveSearch = caseSensitiveSearch;
|
||||
}
|
||||
|
||||
public void addColumn(SearchColumn column) {
|
||||
if (columns != null)
|
||||
this.columns.add(column);
|
||||
else
|
||||
{
|
||||
this.columns = new ArrayList<>();
|
||||
this.columns.add(column);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
package systems.archide.core.repository;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.softomaton.orm.IStore;
|
||||
import com.softomaton.orm.QueryUtil;
|
||||
import com.softomaton.orm.UserContext;
|
||||
|
||||
import systems.archide.core.pojo.PreparedQuery;
|
||||
import systems.archide.core.pojo.QueryBuilder;
|
||||
import systems.archide.core.pojo.SearchQueryInput;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
|
||||
@Lazy
|
||||
@Repository
|
||||
public class VitalRecordAdvancedSearchRepository {
|
||||
private static final Logger log = LogManager.getLogger(systems.archide.core.repository.VitalRecordAdvancedSearchRepository.class);
|
||||
|
||||
IStore store;
|
||||
UserContext userContext;
|
||||
|
||||
public void setUserContext(UserContext userContext) {
|
||||
this.userContext = userContext;
|
||||
}
|
||||
|
||||
public UserContext getUserContext() {
|
||||
return this.userContext;
|
||||
}
|
||||
|
||||
public void setStore(IStore store) {
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
public IStore getStore() {
|
||||
return store;
|
||||
}
|
||||
|
||||
public List<VitalRecord> advancedSearch(SearchQueryInput input, Long limit, Long offset, String orderBy) {
|
||||
List<VitalRecord> beans = new ArrayList<VitalRecord>();
|
||||
Connection con = store.getConnection();
|
||||
QueryBuilder builder = new QueryBuilder();
|
||||
PreparedQuery preparedQuery = builder.buildQuery(input, "vital_record", limit, offset, orderBy);
|
||||
PreparedStatement ps = null;
|
||||
if (con != null) {
|
||||
try {
|
||||
ps = con.prepareStatement(preparedQuery.getQuery());
|
||||
for (int i = 0; i < preparedQuery.getParameters().size(); i++) {
|
||||
ps.setObject(i + 1, preparedQuery.getParameters().get(i));
|
||||
}
|
||||
ps.execute();
|
||||
ResultSet rs = ps.getResultSet();
|
||||
while (rs.next()) {
|
||||
VitalRecord bean = new VitalRecord();
|
||||
bean.setId((Long) rs.getObject("id"));
|
||||
bean.setBirthCountry((Integer) rs.getObject("birth_country"));
|
||||
bean.setBirthDayUnknown(rs.getBoolean("birth_day_unknown"));
|
||||
bean.setBirthMonthUnknown(rs.getBoolean("birth_month_unknown"));
|
||||
bean.setBirthPlace(rs.getString("birth_place"));
|
||||
bean.setBirthTime(rs.getObject("birth_time", LocalTime.class));
|
||||
bean.setBirthTimeUnknown(rs.getBoolean("birth_time_unknown"));
|
||||
bean.setBirthYearUnknown(rs.getBoolean("birth_year_unknown"));
|
||||
bean.setBirthdate(rs.getObject("birthdate", LocalDate.class));
|
||||
bean.setCardId((Long) rs.getObject("card_id"));
|
||||
bean.setCommonIdNumber(rs.getString("common_id_number"));
|
||||
bean.setDisability(rs.getBoolean("disability"));
|
||||
bean.setDonor(rs.getBoolean("donor"));
|
||||
bean.setDonorNotes(rs.getString("donor_notes"));
|
||||
bean.setDraft(rs.getBoolean("draft"));
|
||||
bean.setFaceId((Long) rs.getObject("face_id"));
|
||||
bean.setFatherId((Long) rs.getObject("father_id"));
|
||||
bean.setFifthname(rs.getString("fifthname"));
|
||||
bean.setFirstname(rs.getString("firstname"));
|
||||
bean.setFourthname(rs.getString("fourthname"));
|
||||
bean.setGender(QueryUtil.getNullableShort(rs, "gender"));
|
||||
bean.setInactive(rs.getBoolean("inactive"));
|
||||
bean.setIsDeleted(rs.getBoolean("is_deleted"));
|
||||
bean.setMaritalStatus(QueryUtil.getNullableShort(rs, "marital_status"));
|
||||
bean.setMarkedInactive(rs.getObject("marked_inactive", LocalDate.class));
|
||||
bean.setMotherId((Long) rs.getObject("mother_id"));
|
||||
bean.setNotes(rs.getString("notes"));
|
||||
bean.setOtherCitizenshipCsv(rs.getString("other_citizenship_csv"));
|
||||
bean.setPrimaryCitizenship(rs.getString("primary_citizenship"));
|
||||
bean.setReportedFatherName(rs.getString("reported_father_name"));
|
||||
bean.setReportedMotherName(rs.getString("reported_mother_name"));
|
||||
bean.setSecondname(rs.getString("secondname"));
|
||||
bean.setThirdname(rs.getString("thirdname"));
|
||||
bean.setTimestamp(rs.getObject("timestamp", LocalDateTime.class));
|
||||
bean.setTouched((Long) rs.getObject("touched"));
|
||||
bean.setUnknownFather(rs.getBoolean("unknown_father"));
|
||||
bean.setVoter(rs.getBoolean("voter"));
|
||||
beans.add(bean);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("find where failed", e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (ps != null)
|
||||
try {
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
|
||||
log.error("error while closing prepared statement", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (con != null) {
|
||||
try {
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
log.error("error while closing connection", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return beans;
|
||||
}
|
||||
|
||||
public long advancedSearchCount(SearchQueryInput input) {
|
||||
Connection con = store.getConnection();
|
||||
QueryBuilder builder = new QueryBuilder();
|
||||
PreparedQuery preparedQuery = builder.buildQuery(input, "vital_record");
|
||||
PreparedStatement ps = null;
|
||||
if (con != null) {
|
||||
try {
|
||||
ps = con.prepareStatement(preparedQuery.getQuery());
|
||||
for (int i = 0; i < preparedQuery.getParameters().size(); i++) {
|
||||
ps.setObject(i + 1, preparedQuery.getParameters().get(i));
|
||||
}
|
||||
ps.execute();
|
||||
ResultSet rs = ps.getResultSet();
|
||||
if (rs.next()) {
|
||||
return rs.getLong(1);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("find where failed", e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (ps != null)
|
||||
try {
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
|
||||
log.error("error while closing prepared statement", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (con != null) {
|
||||
try {
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
log.error("error while closing connection", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
410
src/main/java/systems/archide/core/service/hooks/ApplyLogic.java
Normal file
410
src/main/java/systems/archide/core/service/hooks/ApplyLogic.java
Normal file
@ -0,0 +1,410 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.AttachDigitalizationMtlbInput;
|
||||
import systems.archide.core.pojo.CivilStatusMtlb;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbAttachment;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbCreateRequest;
|
||||
import systems.archide.core.pojo.DigitalizationCreateRequest;
|
||||
import systems.archide.core.pojo.DocumentType;
|
||||
import systems.archide.core.pojo.Face;
|
||||
import systems.archide.core.pojo.GetServiceStatusRequest;
|
||||
import systems.archide.core.pojo.GetServiceStatusResponse;
|
||||
import systems.archide.core.pojo.IdMtlb;
|
||||
import systems.archide.core.pojo.IdMtlbCreateRequest;
|
||||
import systems.archide.core.pojo.IssueDocumentInput;
|
||||
import systems.archide.core.pojo.IssuedDocuments;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.pojo.Rv4DeathMtlbCreateRequest;
|
||||
import systems.archide.core.pojo.Rv4DivorceMtlbRequest;
|
||||
import systems.archide.core.pojo.Rv4IdCardMtlbRequest;
|
||||
import systems.archide.core.pojo.Rv4MarriageMtlbRequest;
|
||||
import systems.archide.core.pojo.RvFourBirthMtlbCreateRequest;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlb;
|
||||
import systems.archide.core.pojo.RvfourDeathMtlb;
|
||||
import systems.archide.core.pojo.RvfourDivorceMtlb;
|
||||
import systems.archide.core.pojo.RvfourIdCardMtlb;
|
||||
import systems.archide.core.pojo.RvfourMarriageMtlb;
|
||||
import systems.archide.core.pojo.UnionMtlb;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.CivilStatusMtlbAttachmentRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbRepository;
|
||||
import systems.archide.core.repository.FaceRepository;
|
||||
import systems.archide.core.repository.IdMtlbRepository;
|
||||
import systems.archide.core.repository.IssuedDocumentsRepository;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourDeathMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourDivorceMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourIdCardMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourMarriageMtlbRepository;
|
||||
import systems.archide.core.repository.UnionMtlbRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
import systems.archide.core.workflows.utils.MtlbEntity;
|
||||
|
||||
@Component
|
||||
public class ApplyLogic {
|
||||
|
||||
final Integer EXPIRES_YEARS = 5;
|
||||
|
||||
@Autowired
|
||||
private CivilStatusMtlbRepository civilStatusMtlbService;
|
||||
|
||||
@Autowired
|
||||
private CivilStatusMtlbAttachmentRepository civilStatusMtlbAttachmentService;
|
||||
|
||||
@Autowired
|
||||
private IdMtlbRepository idMtlbService;
|
||||
|
||||
@Autowired
|
||||
private UnionMtlbRepository unionMtlbService;
|
||||
|
||||
@Autowired
|
||||
private RvfourBirthMtlbRepository rvfourBirthMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
private RvfourDeathMtlbRepository rvfourDeathMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
private VitalRecordRepository vitalRecordService;
|
||||
|
||||
@Autowired
|
||||
private RvfourMarriageMtlbRepository rvfourMarriageMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
private RvfourDivorceMtlbRepository rvfourDivorceMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
private RvfourIdCardMtlbRepository rvfourIdCardMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
private FaceRepository faceService;
|
||||
|
||||
@Autowired
|
||||
private IssuedDocumentsRepository issuedDocumentsRepository;
|
||||
|
||||
public final String INITIATED = "INITIATED";
|
||||
|
||||
public final String FINISHED = "FINISHED";
|
||||
|
||||
public final Integer CIVIL_STATUS_MTLB_TYPE = 1;
|
||||
|
||||
public final Integer ID_MTLB_TYPE = 2;
|
||||
|
||||
public ResponseEntity<Long> createCivilStatusMtlb(CivilStatusMtlbCreateRequest request) {
|
||||
CivilStatusMtlb civilStatusMtlb = civilStatusMtlbCreateRequest2CivilStatusMtlb(request);
|
||||
civilStatusMtlb.setMtlbStatus(MtlbStatus.INITIATED);
|
||||
Long id = civilStatusMtlbService.insert(civilStatusMtlb);
|
||||
civilStatusMtlb.setId(id);
|
||||
return ResponseEntity.ok(id);
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> createIdMtlb(IdMtlbCreateRequest request) {
|
||||
IdMtlb idMtlb = idMtlbCreateRequest2IdMtlb(request);
|
||||
idMtlb.setMtlbStatus(MtlbStatus.INITIATED);
|
||||
Long id = idMtlbService.insert(idMtlb);
|
||||
return ResponseEntity.ok(id);
|
||||
}
|
||||
|
||||
public UnionMtlb createUnionMtlb(UnionMtlb request) {
|
||||
request.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
Long id = unionMtlbService.insert(request);
|
||||
request.setId(id);
|
||||
return request;
|
||||
}
|
||||
|
||||
private CivilStatusMtlb civilStatusMtlbCreateRequest2CivilStatusMtlb(
|
||||
CivilStatusMtlbCreateRequest civilStatusMtlbCreateRequest) {
|
||||
CivilStatusMtlb civilStatusMtlb = new CivilStatusMtlb();
|
||||
civilStatusMtlb.setDraft(civilStatusMtlbCreateRequest.isDraft());
|
||||
civilStatusMtlb.setFirstname(civilStatusMtlbCreateRequest.getFirstname());
|
||||
civilStatusMtlb.setSecondname(civilStatusMtlbCreateRequest.getSecondname());
|
||||
civilStatusMtlb.setThirdname(civilStatusMtlbCreateRequest.getThirdname());
|
||||
civilStatusMtlb.setFourthname(civilStatusMtlbCreateRequest.getFourthname());
|
||||
civilStatusMtlb.setFifthname(civilStatusMtlbCreateRequest.getFifthname());
|
||||
civilStatusMtlb.setMtlbStatus(MtlbStatus.INITIATED);
|
||||
civilStatusMtlb.setMtlbType(MtlbType.valueOf(civilStatusMtlbCreateRequest.getMtlbType()));
|
||||
civilStatusMtlb.setBirthdate(civilStatusMtlbCreateRequest.getBirthdate());
|
||||
civilStatusMtlb.setGender(civilStatusMtlbCreateRequest.getGender());
|
||||
civilStatusMtlb.setFace(civilStatusMtlbCreateRequest.getFace());
|
||||
civilStatusMtlb.setFaceMimeType(civilStatusMtlbCreateRequest.getFaceMimeType());
|
||||
civilStatusMtlb.setVitalRecordId(civilStatusMtlbCreateRequest.getVitalRecordId());
|
||||
civilStatusMtlb.setBirthPlace(civilStatusMtlbCreateRequest.getBirthPlace());
|
||||
civilStatusMtlb.setReportedFatherName(civilStatusMtlbCreateRequest.getReportedFatherName());
|
||||
civilStatusMtlb.setReportedMotherName(civilStatusMtlbCreateRequest.getReportedMotherName());
|
||||
civilStatusMtlb.setFatherId(civilStatusMtlbCreateRequest.getFatherId());
|
||||
civilStatusMtlb.setMotherId(civilStatusMtlbCreateRequest.getMotherId());
|
||||
civilStatusMtlb.setDeclarantId(civilStatusMtlbCreateRequest.getDeclarantId());
|
||||
civilStatusMtlb.setNotes(civilStatusMtlbCreateRequest.getNotes());
|
||||
civilStatusMtlb.setMaritalStatus(civilStatusMtlbCreateRequest.getMaritalStatus());
|
||||
return civilStatusMtlb;
|
||||
}
|
||||
|
||||
private IdMtlb idMtlbCreateRequest2IdMtlb(IdMtlbCreateRequest idMtlbCreateRequest) {
|
||||
IdMtlb idMtlb = new IdMtlb();
|
||||
idMtlb.setDraft(idMtlbCreateRequest.isDraft());
|
||||
idMtlb.setFace(idMtlbCreateRequest.getFace());
|
||||
idMtlb.setFaceMimeType(idMtlbCreateRequest.getFaceMimeType());
|
||||
idMtlb.setVitalRecordId(idMtlbCreateRequest.getVitalRecordId());
|
||||
idMtlb.setMtlbType(MtlbType.valueOf(idMtlbCreateRequest.getMtlbType()));
|
||||
return idMtlb;
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> createDigitalizationMtlb(DigitalizationCreateRequest digitalizationCreateRequest) {
|
||||
CivilStatusMtlb mtlb = new CivilStatusMtlb();
|
||||
CivilStatusMtlbAttachment mtlbAttachment = new CivilStatusMtlbAttachment();
|
||||
mtlb.setDraft(false);
|
||||
mtlb.setMtlbStatus(MtlbStatus.NOT_ASSIGNED);
|
||||
mtlb.setMtlbType(MtlbType.DIGITALIZATION);
|
||||
Long mtlbId = civilStatusMtlbService.insert(mtlb);
|
||||
mtlbAttachment.setCivilStatusMtlbId(mtlbId);
|
||||
mtlbAttachment.setFileName(digitalizationCreateRequest.getFileName());
|
||||
mtlbAttachment.setContent(digitalizationCreateRequest.getContent());
|
||||
civilStatusMtlbAttachmentService.insert(mtlbAttachment);
|
||||
return ResponseEntity.ok(mtlbId);
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> attachDigitalizationMtlb(AttachDigitalizationMtlbInput attachDigitalizationMtlbInput) {
|
||||
CivilStatusMtlb civilStatusMtlb = civilStatusMtlbService
|
||||
.findById(attachDigitalizationMtlbInput.getCivilStatusMtlbId());
|
||||
VitalRecord vr = vitalRecordService.findById(attachDigitalizationMtlbInput.getVitalRecordId());
|
||||
Long id = null;
|
||||
if (civilStatusMtlb != null && vr != null) {
|
||||
vitalRecord2CivilStatusMtlb(civilStatusMtlb, vr);
|
||||
civilStatusMtlbService.update(civilStatusMtlb);
|
||||
id = civilStatusMtlb.getId();
|
||||
}
|
||||
return ResponseEntity.ok(id);
|
||||
}
|
||||
|
||||
private void vitalRecord2CivilStatusMtlb(CivilStatusMtlb civilStatusMtlb, VitalRecord vr) {
|
||||
civilStatusMtlb.setFirstname(vr.getFirstname());
|
||||
civilStatusMtlb.setSecondname(vr.getSecondname());
|
||||
civilStatusMtlb.setThirdname(vr.getThirdname());
|
||||
civilStatusMtlb.setFourthname(vr.getFourthname());
|
||||
civilStatusMtlb.setFifthname(vr.getFifthname());
|
||||
civilStatusMtlb.setBirthdate(vr.getBirthdate());
|
||||
civilStatusMtlb.setMtlbStatus(MtlbStatus.READY_FOR_APPROVAL);
|
||||
civilStatusMtlb.setMtlbType(MtlbType.CIVIL_STATUS_CHANGE);
|
||||
civilStatusMtlb.setGender(vr.getGender());
|
||||
if (vr.getFaceId() != null) {
|
||||
Face face = faceService.findById(vr.getFaceId());
|
||||
civilStatusMtlb.setFace(face.getImage());
|
||||
}
|
||||
civilStatusMtlb.setFaceMimeType("image/png");
|
||||
civilStatusMtlb.setBirthTime(vr.getBirthTime());
|
||||
civilStatusMtlb.setNotes(vr.getNotes());
|
||||
civilStatusMtlb.setReportedFatherName(vr.getReportedFatherName());
|
||||
civilStatusMtlb.setFatherId(vr.getFatherId());
|
||||
civilStatusMtlb.setMotherId(vr.getMotherId());
|
||||
civilStatusMtlb.setReportedMotherName(vr.getReportedMotherName());
|
||||
civilStatusMtlb.setVitalRecordId(vr.getId());
|
||||
}
|
||||
|
||||
private RvfourBirthMtlb rvFourBirthMtlbCreateRequest2RvfourBirthMtlb(
|
||||
RvFourBirthMtlbCreateRequest rvFourBirthMtlbCreateRequest) {
|
||||
RvfourBirthMtlb mtlb = new RvfourBirthMtlb();
|
||||
mtlb.setAddress(rvFourBirthMtlbCreateRequest.getAddress());
|
||||
mtlb.setBirthdate(rvFourBirthMtlbCreateRequest.getBirthdate());
|
||||
mtlb.setBirthDayUnknown(rvFourBirthMtlbCreateRequest.isBirthDayUnknown());
|
||||
mtlb.setBirthMonthUnknown(rvFourBirthMtlbCreateRequest.isBirthMonthUnknown());
|
||||
mtlb.setBirthPlace(rvFourBirthMtlbCreateRequest.getBirthPlace());
|
||||
mtlb.setBirthYearUnknown(rvFourBirthMtlbCreateRequest.isBirthYearUnknown());
|
||||
mtlb.setDraft(false);
|
||||
mtlb.setEmail(rvFourBirthMtlbCreateRequest.getEmail());
|
||||
mtlb.setFace(rvFourBirthMtlbCreateRequest.getFace());
|
||||
mtlb.setMtlbStatus(MtlbStatus.INITIATED);
|
||||
mtlb.setTimestamp(rvFourBirthMtlbCreateRequest.getTimestamp());
|
||||
mtlb.setMtlbType(MtlbType.valueOf(rvFourBirthMtlbCreateRequest.getType()));
|
||||
mtlb.setFatherId(rvFourBirthMtlbCreateRequest.getFatherId());
|
||||
mtlb.setMotherId(rvFourBirthMtlbCreateRequest.getMotherId());
|
||||
mtlb.setReportedFatherName(rvFourBirthMtlbCreateRequest.getReportedFatherName());
|
||||
mtlb.setReportedMotherName(rvFourBirthMtlbCreateRequest.getReportedMotherName());
|
||||
mtlb.setFirstname(rvFourBirthMtlbCreateRequest.getFirstname());
|
||||
mtlb.setSecondname(rvFourBirthMtlbCreateRequest.getSecondname());
|
||||
mtlb.setThirdname(rvFourBirthMtlbCreateRequest.getThirdname());
|
||||
mtlb.setFourthname(rvFourBirthMtlbCreateRequest.getFourthname());
|
||||
mtlb.setFifthname(rvFourBirthMtlbCreateRequest.getFifthname());
|
||||
mtlb.setSixthname(rvFourBirthMtlbCreateRequest.getSixthname());
|
||||
mtlb.setVitalRecordId(rvFourBirthMtlbCreateRequest.getVitalRecordId());
|
||||
if (rvFourBirthMtlbCreateRequest.getBirthtime() != null)
|
||||
mtlb.setBirthtime(rvFourBirthMtlbCreateRequest.getBirthtime().toLocalTime());
|
||||
mtlb.setMultiBirth(rvFourBirthMtlbCreateRequest.isMultiBirth());
|
||||
mtlb.setOldAddress(rvFourBirthMtlbCreateRequest.getOldAddress());
|
||||
mtlb.setReligion(rvFourBirthMtlbCreateRequest.getReligion());
|
||||
mtlb.setOccupation(rvFourBirthMtlbCreateRequest.getOccupation());
|
||||
mtlb.setGender(rvFourBirthMtlbCreateRequest.getGender());
|
||||
mtlb.setAnnex(rvFourBirthMtlbCreateRequest.getAnnex());
|
||||
mtlb.setNumberOfAttachments(rvFourBirthMtlbCreateRequest.getNumberOfAttachments());
|
||||
return mtlb;
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> saveRv4BirthMtlbByVitalRecordId(RvFourBirthMtlbCreateRequest rvFourBirthMtlbCreateRequest) {
|
||||
RvfourBirthMtlb mtlb = rvfourBirthMtlbRepository
|
||||
.findByVitalRecordId(rvFourBirthMtlbCreateRequest.getVitalRecordId());
|
||||
if (mtlb != null && !MtlbType.valueOf(rvFourBirthMtlbCreateRequest.getType()).equals(MtlbType.RV4_VITAL_RECORD_HISTORY))
|
||||
return ResponseEntity.ok(mtlb.getId());
|
||||
else {
|
||||
RvfourBirthMtlb newMtlb = rvFourBirthMtlbCreateRequest2RvfourBirthMtlb(rvFourBirthMtlbCreateRequest);
|
||||
Long id = rvfourBirthMtlbRepository.insert(newMtlb);
|
||||
return ResponseEntity.ok(id);
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> saveRv4DeathMtlbByVitalRecordId(Rv4DeathMtlbCreateRequest rv4DeathMtlbCreateRequest) {
|
||||
RvfourDeathMtlb mtlb = rvfourDeathMtlbRepository
|
||||
.findByVitalRecordId(rv4DeathMtlbCreateRequest.getVitalRecordId());
|
||||
if (mtlb != null)
|
||||
return ResponseEntity.ok(mtlb.getId());
|
||||
else {
|
||||
RvfourDeathMtlb newMtlb = rvFourDeathMtlbCreateRequest2RvfourDeathMtlb(rv4DeathMtlbCreateRequest);
|
||||
return ResponseEntity.ok(rvfourDeathMtlbRepository.insert(newMtlb));
|
||||
}
|
||||
}
|
||||
|
||||
private RvfourDeathMtlb rvFourDeathMtlbCreateRequest2RvfourDeathMtlb(
|
||||
Rv4DeathMtlbCreateRequest request) {
|
||||
RvfourDeathMtlb mtlb = new RvfourDeathMtlb();
|
||||
mtlb.setAnnex(request.getAnnex());
|
||||
mtlb.setDateOfDeath(request.getDateOfDeath());
|
||||
mtlb.setDeclarantId(request.getDeclarantId());
|
||||
mtlb.setVitalRecordId(request.getVitalRecordId());
|
||||
mtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
if (request.getTimeOfDeath() != null)
|
||||
mtlb.setTimeOfDeath(request.getTimeOfDeath().toLocalTime());
|
||||
if (request.getType() != null)
|
||||
mtlb.setMtlbType(MtlbType.valueOf(request.getType()));
|
||||
mtlb.setDeathLocation(request.getDeathLocation());
|
||||
mtlb.setDeathRecordId(request.getDeathRecordId());
|
||||
return mtlb;
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> saveRv4MarraigeMtlbByUnionId(Rv4MarriageMtlbRequest rv4MarriageMtlbRequest) {
|
||||
RvfourMarriageMtlb mtlb = rvfourMarriageMtlbRepository.findById(rv4MarriageMtlbRequest.getId());
|
||||
if (mtlb != null)
|
||||
return ResponseEntity.ok(mtlb.getId());
|
||||
else {
|
||||
RvfourMarriageMtlb newMtlb = rv4MarriageMtlbRequest2RvfourMarriageMtlb(rv4MarriageMtlbRequest);
|
||||
return ResponseEntity.ok(rvfourMarriageMtlbRepository.insert(newMtlb));
|
||||
}
|
||||
}
|
||||
|
||||
private RvfourMarriageMtlb rv4MarriageMtlbRequest2RvfourMarriageMtlb(
|
||||
Rv4MarriageMtlbRequest request) {
|
||||
RvfourMarriageMtlb mtlb = new RvfourMarriageMtlb();
|
||||
mtlb.setAnnex(request.getAnnex());
|
||||
mtlb.setDateOfMarriage(request.getDateOfMarriage());
|
||||
mtlb.setHusbandId(request.getHusbandId());
|
||||
mtlb.setWifeId(request.getWifeId());
|
||||
mtlb.setId(request.getId());
|
||||
mtlb.setMarriageLocation(request.getMarriageLocation());
|
||||
mtlb.setMarriagePlace(request.getPlace());
|
||||
mtlb.setMarriageRites(request.getMarriageRites());
|
||||
mtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
mtlb.setMtlbType(MtlbType.valueOf(request.getType()));
|
||||
if (request.getTimeOfMarriage() != null)
|
||||
mtlb.setTimeOfMarriage(request.getTimeOfMarriage().toLocalTime());
|
||||
mtlb.setWitness1Id(request.getWitness1Id());
|
||||
mtlb.setWitness2Id(request.getWitness2Id());
|
||||
return mtlb;
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> saveRv4DivorceMtlbByUnionId(Rv4DivorceMtlbRequest rv4DivorceMtlbRequest) {
|
||||
RvfourDivorceMtlb mtlb = new RvfourDivorceMtlb();
|
||||
mtlb.setAnnex(rv4DivorceMtlbRequest.getAnnex());
|
||||
mtlb.setDateOfEffect(rv4DivorceMtlbRequest.getDateOfEffect());
|
||||
mtlb.setDateOfOrder(rv4DivorceMtlbRequest.getDateOfOrder());
|
||||
mtlb.setMtlbType(MtlbType.valueOf(rv4DivorceMtlbRequest.getType()));
|
||||
mtlb.setUnionRecordId(rv4DivorceMtlbRequest.getUnionRecordId());
|
||||
mtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
return ResponseEntity.ok(rvfourDivorceMtlbRepository.insert(mtlb));
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> saveRv4IdCardMtlbByIdCardNumber(Rv4IdCardMtlbRequest rv4IdCardMtlbRequest) {
|
||||
RvfourIdCardMtlb mtlb = rvfourIdCardMtlbRepository.findByIdCardNumber(rv4IdCardMtlbRequest.getIdCardNumber());
|
||||
if (mtlb != null)
|
||||
return ResponseEntity.ok(mtlb.getId());
|
||||
else {
|
||||
mtlb = new RvfourIdCardMtlb();
|
||||
mtlb.setAnnex(rv4IdCardMtlbRequest.getAnnex());
|
||||
mtlb.setCancelledDate(rv4IdCardMtlbRequest.getCancelled_date());
|
||||
mtlb.setCancelledReason(rv4IdCardMtlbRequest.getCancelled_reason());
|
||||
mtlb.setIssuedDate(rv4IdCardMtlbRequest.getIssuedDate());
|
||||
mtlb.setExpires(rv4IdCardMtlbRequest.getExpires());
|
||||
mtlb.setIdCardNumber(rv4IdCardMtlbRequest.getIdCardNumber());
|
||||
mtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
mtlb.setVitalRecordId(rv4IdCardMtlbRequest.getVitalRecordId());
|
||||
return ResponseEntity.ok(rvfourIdCardMtlbRepository.insert(mtlb));
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseEntity<String> issueDocument(IssueDocumentInput issueDocumentInput) {
|
||||
VitalRecord vr = vitalRecordService.findById(issueDocumentInput.getVitalRecordId());
|
||||
IdMtlb idMtlb = idMtlbService.findById(issueDocumentInput.getIdMtlbId());
|
||||
IssuedDocuments issuedDocument = new IssuedDocuments();
|
||||
issuedDocument.setVitalRecordId(issueDocumentInput.getVitalRecordId());
|
||||
if (issueDocumentInput.getFace() != null)
|
||||
issuedDocument.setFace(issueDocumentInput.getFace());
|
||||
issuedDocument.setDocumentType(DocumentType.valueOf(issueDocumentInput.getDocumentType()));
|
||||
String documentId = RandomStringUtils.randomAlphanumeric(12);
|
||||
issuedDocument.setDocumentId(documentId);
|
||||
issuedDocument.setIssuedDate(LocalDate.now());
|
||||
issuedDocument.setExpires(LocalDate.now().plusYears(EXPIRES_YEARS));
|
||||
String fullName="";
|
||||
if (!StringUtils.isAllBlank(vr.getFirstname()))
|
||||
fullName = vr.getFirstname();
|
||||
if (!StringUtils.isAllBlank(vr.getSecondname()))
|
||||
fullName = fullName.concat(" " + vr.getSecondname());
|
||||
if (!StringUtils.isAllBlank(vr.getThirdname()))
|
||||
fullName = fullName.concat(" " + vr.getThirdname());
|
||||
if (!StringUtils.isAllBlank(vr.getFourthname()))
|
||||
fullName = fullName.concat(" " + vr.getFourthname());
|
||||
issuedDocument.setFullName(fullName);
|
||||
/*List<IssuedDocuments> oldDocuments = issuedDocumentsRepository.find("vital_record_id='" + issueDocumentInput.getVitalRecordId() + "' ORDER BY id DESC LIMIT 1");
|
||||
if (!oldDocuments.isEmpty()) {
|
||||
IssuedDocuments oldDocument = oldDocuments.get(0);
|
||||
oldDocument.setCancelledDate(LocalDate.now());
|
||||
oldDocument.setCancelledReason("Outdated ID");
|
||||
issuedDocumentsRepository.update(oldDocument);
|
||||
}*/
|
||||
List<IssuedDocuments> oldDocuments = issuedDocumentsRepository.findByVitalRecordId(issuedDocument.getVitalRecordId());
|
||||
for (IssuedDocuments doc: oldDocuments) {
|
||||
if (doc.getCancelledDate() == null) {
|
||||
doc.setCancelledDate(LocalDate.now());
|
||||
doc.setCancelledReason("Outdated ID");
|
||||
issuedDocumentsRepository.update(doc);
|
||||
}
|
||||
}
|
||||
idMtlb.setPrinted(true);
|
||||
idMtlbService.update(idMtlb);
|
||||
Long id = issuedDocumentsRepository.insert(issuedDocument);
|
||||
vr.setCardId(id);
|
||||
vitalRecordService.update(vr);
|
||||
return ResponseEntity.ok(documentId);
|
||||
}
|
||||
|
||||
public ResponseEntity<GetServiceStatusResponse> getServiceStatus(GetServiceStatusRequest request) {
|
||||
GetServiceStatusResponse response = new GetServiceStatusResponse();
|
||||
switch (request.getType()) {
|
||||
case 1 :
|
||||
CivilStatusMtlb mtlb = civilStatusMtlbService.findById(request.getId());
|
||||
if (mtlb != null)
|
||||
response.setServiceStatus(mtlb.getMtlbStatus().name());
|
||||
break;
|
||||
case 2 :
|
||||
IdMtlb idMtlb = idMtlbService.findById(request.getId());
|
||||
if (idMtlb != null)
|
||||
response.setServiceStatus(idMtlb.getMtlbStatus().name());
|
||||
break;
|
||||
}
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.CivilRecordId;
|
||||
import systems.archide.core.pojo.CivilRecordInfo;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.FaceRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@Component
|
||||
public class CivilRecordInfoServiceLogic {
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
FaceRepository faceRepository;
|
||||
|
||||
public ResponseEntity<CivilRecordInfo> read(CivilRecordId civilRecordId) {
|
||||
VitalRecord vr = vitalRecordRepository.findById(civilRecordId.getId());
|
||||
if (vr != null) {
|
||||
CivilRecordInfo crInfo = new CivilRecordInfo();
|
||||
crInfo.setBirthdate(vr.getBirthdate());
|
||||
crInfo.setFirstname(vr.getFirstname());
|
||||
crInfo.setLastname(vr.getFourthname());
|
||||
if (vr.getFaceId() != null)
|
||||
crInfo.setFace(faceRepository.getImageById(vr.getFaceId()));
|
||||
ResponseEntity<CivilRecordInfo> response = ResponseEntity.status(HttpStatus.CREATED).body(crInfo);
|
||||
return response;
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||
}
|
||||
}
|
@ -0,0 +1,256 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.AdoptiveFathers;
|
||||
import systems.archide.core.pojo.AdoptiveMothers;
|
||||
import systems.archide.core.pojo.CivilStatusMtlb;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbAttachment;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbDeathNotificationFile;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbDocument;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbMedicalNotificationFile;
|
||||
import systems.archide.core.pojo.DeathRecord;
|
||||
import systems.archide.core.pojo.DeathRecordAttachment;
|
||||
import systems.archide.core.pojo.DeathRecordDeathNotificationFile;
|
||||
import systems.archide.core.pojo.FileStatus;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.pojo.VitalRecordAttachment;
|
||||
import systems.archide.core.pojo.VitalRecordMedicalNotificationFile;
|
||||
import systems.archide.core.repository.AdoptiveFathersRepository;
|
||||
import systems.archide.core.repository.AdoptiveMothersRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbAttachmentRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbDeathNotificationFileRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbDocumentRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbMedicalNotificationFileRepository;
|
||||
import systems.archide.core.repository.DeathRecordAttachmentRepository;
|
||||
import systems.archide.core.repository.DeathRecordDeathNotificationFileRepository;
|
||||
import systems.archide.core.repository.DeathRecordRepository;
|
||||
import systems.archide.core.repository.VitalRecordAttachmentRepository;
|
||||
import systems.archide.core.repository.VitalRecordMedicalNotificationFileRepository;
|
||||
|
||||
@Component
|
||||
public class CivilStatusMtlbDocumentLogic {
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbDocumentRepository civilStatusMtlbDocumentRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbAttachmentRepository civilStatusMtlbAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordAttachmentRepository vitalRecordAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordMedicalNotificationFileRepository vitalRecordMedicalNotificationFileRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbMedicalNotificationFileRepository civilStatusMtlbMedicalNotificationFileRepository;
|
||||
|
||||
@Autowired
|
||||
DeathRecordRepository deathRecordRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbDeathNotificationFileRepository civilStatusMtlbDeathNotificationFileRepository;
|
||||
|
||||
@Autowired
|
||||
DeathRecordDeathNotificationFileRepository deathRecordDeathNotificationFileRepository;
|
||||
|
||||
@Autowired
|
||||
DeathRecordAttachmentRepository deathRecordAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
AdoptiveFathersRepository adoptiveFathersRepository;
|
||||
|
||||
@Autowired
|
||||
AdoptiveMothersRepository adoptiveMothersRepository;
|
||||
|
||||
public Long newDocument(CivilStatusMtlbDocument document) {
|
||||
CivilStatusMtlb mtlb = new CivilStatusMtlb();
|
||||
dto2pojo(document, mtlb);
|
||||
mtlb.setMtlbStatus(MtlbStatus.INITIATED);
|
||||
mtlb.setDraft(true);
|
||||
mtlb.setMtlbType(document.getMtlbType());
|
||||
Long id = civilStatusMtlbDocumentRepository.insert(mtlb);
|
||||
if ((MtlbType.CIVIL_STATUS_CHANGE.equals(mtlb.getMtlbType()) || MtlbType.ADOPTION.equals(mtlb.getMtlbType())) && mtlb.getVitalRecordId() != null) {
|
||||
List<VitalRecordAttachment> vrAttchmentList = vitalRecordAttachmentRepository.findByVitalRecordId(mtlb.getVitalRecordId());
|
||||
for (VitalRecordAttachment a : vrAttchmentList) {
|
||||
CivilStatusMtlbAttachment attachment = new CivilStatusMtlbAttachment();
|
||||
attachment.setCivilStatusMtlbId(id);
|
||||
attachment.setContent(a.getContent());
|
||||
attachment.setDescription(a.getDescription());
|
||||
attachment.setFileName(a.getFileName());
|
||||
attachment.setFileStatus(FileStatus.DRAFT);
|
||||
attachment.setPreview(a.getPreview());
|
||||
civilStatusMtlbAttachmentRepository.insert(attachment);
|
||||
}
|
||||
|
||||
List<VitalRecordMedicalNotificationFile> vrMList = vitalRecordMedicalNotificationFileRepository.findByVitalRecordId(mtlb.getVitalRecordId());
|
||||
for (VitalRecordMedicalNotificationFile m : vrMList) {
|
||||
CivilStatusMtlbMedicalNotificationFile attachment = new CivilStatusMtlbMedicalNotificationFile();
|
||||
attachment.setCivilStatusMtlbId(id);
|
||||
attachment.setContent(m.getContent());
|
||||
attachment.setDescription(m.getDescription());
|
||||
attachment.setFileName(m.getFileName());
|
||||
attachment.setFileStatus(FileStatus.DRAFT);
|
||||
attachment.setPreview(m.getPreview());
|
||||
civilStatusMtlbMedicalNotificationFileRepository.insert(attachment);
|
||||
}
|
||||
}
|
||||
if (MtlbType.DEATH_RECORD_CHANGE.equals(mtlb.getMtlbType()) && mtlb.getVitalRecordId() != null) {
|
||||
addDeathRecordAttachmentsToMtlb(mtlb, mtlb.getVitalRecordId());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
private void addDeathRecordAttachmentsToMtlb(CivilStatusMtlb mtlb, Long vitalRecordId) {
|
||||
List<DeathRecord> deathRecordList = deathRecordRepository.findByVitalRecordId(vitalRecordId);
|
||||
if (!deathRecordList.isEmpty()) {
|
||||
DeathRecord deathRecord = deathRecordList.get(0);
|
||||
List<DeathRecordAttachment> drAttchmentList = deathRecordAttachmentRepository.findByDeathRecordId(deathRecord.getId());
|
||||
for (DeathRecordAttachment a : drAttchmentList) {
|
||||
CivilStatusMtlbAttachment attachment = new CivilStatusMtlbAttachment();
|
||||
attachment.setCivilStatusMtlbId(mtlb.getId());
|
||||
attachment.setContent(a.getContent());
|
||||
attachment.setDescription(a.getDescription());
|
||||
attachment.setFileName(a.getFileName());
|
||||
attachment.setFileStatus(FileStatus.DRAFT);
|
||||
attachment.setPreview(a.getPreview());
|
||||
civilStatusMtlbAttachmentRepository.insert(attachment);
|
||||
}
|
||||
|
||||
List<DeathRecordDeathNotificationFile> drDList = deathRecordDeathNotificationFileRepository.findByDeathRecordId(deathRecord.getId());
|
||||
if (!drDList.isEmpty())
|
||||
mtlb.setDeathNotification(true);
|
||||
for (DeathRecordDeathNotificationFile m : drDList) {
|
||||
CivilStatusMtlbDeathNotificationFile attachment = new CivilStatusMtlbDeathNotificationFile();
|
||||
attachment.setCivilStatusMtlbId(mtlb.getId());
|
||||
attachment.setContent(m.getContent());
|
||||
attachment.setDescription(m.getDescription());
|
||||
attachment.setFileName(m.getFileName());
|
||||
attachment.setFileStatus(FileStatus.DRAFT);
|
||||
attachment.setPreview(m.getPreview());
|
||||
civilStatusMtlbDeathNotificationFileRepository.insert(attachment);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Long editDocument(CivilStatusMtlbDocument document) {
|
||||
CivilStatusMtlb mtlb = civilStatusMtlbDocumentRepository.findById(document.getId());
|
||||
mtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
dto2pojo(document, mtlb);
|
||||
civilStatusMtlbDocumentRepository.update(mtlb);
|
||||
return mtlb.getId();
|
||||
}
|
||||
|
||||
private void dto2pojo(CivilStatusMtlbDocument document, CivilStatusMtlb mtlb) {
|
||||
mtlb.setUnknownFather(document.isUnknownFather());
|
||||
mtlb.setUnknownMother(document.isUnknownMother());
|
||||
mtlb.setBirthDayUnknown(document.isBirthDayUnknown());
|
||||
mtlb.setBirthCountry(document.getBirthCountry());
|
||||
mtlb.setBirthMonthUnknown(document.isBirthMonthUnknown());
|
||||
mtlb.setBirthPlace(document.getBirthPlace());
|
||||
mtlb.setBirthTime(document.getBirthTime());
|
||||
mtlb.setBirthTimeUnknown(document.isBirthTimeUnknown());
|
||||
mtlb.setBirthYearUnknown(document.isBirthYearUnknown());
|
||||
mtlb.setBirthdate(document.getBirthdate());
|
||||
mtlb.setDateOfDeath(document.getDateOfDeath());
|
||||
mtlb.setDeathDayUnknown(document.isDeathDayUnknown());
|
||||
mtlb.setDeathMonthUnknown(document.isDeathMonthUnknown());
|
||||
mtlb.setDeathTimeUnknown(document.isDeathTimeUnknown());
|
||||
mtlb.setBook(document.getBook());
|
||||
mtlb.setDeathYearUnknown(document.isDeathYearUnknown());
|
||||
mtlb.setDeclarantId(document.getDeclarantId());
|
||||
mtlb.setDeduplicationMtlbId(document.getDeduplicationMtlbId());
|
||||
mtlb.setDisability(document.isDisability());
|
||||
mtlb.setDonor(document.isDonor());
|
||||
mtlb.setDonorNotes(document.getDonorNotes());
|
||||
mtlb.setDraft(document.isDraft());
|
||||
mtlb.setFace(document.getFace());
|
||||
mtlb.setFaceMimeType(document.getFaceMimeType());
|
||||
mtlb.setFatherId(document.getFatherId());
|
||||
mtlb.setFifthname(document.getFifthname());
|
||||
mtlb.setFingersMimeType(document.getFingersMimeType());
|
||||
mtlb.setFirstname(document.getFirstname());
|
||||
mtlb.setFourthname(document.getFourthname());
|
||||
mtlb.setGender(document.getGender());
|
||||
mtlb.setLeftIndexFinger(document.getLeftIndexFinger());
|
||||
mtlb.setLeftMiddleFinger(document.getLeftMiddleFinger());
|
||||
mtlb.setLeftPinky(document.getLeftPinky());
|
||||
mtlb.setLeftRingFinger(document.getLeftRingFinger());
|
||||
mtlb.setLeftThumb(document.getLeftThumb());
|
||||
mtlb.setMaritalStatus(document.getMaritalStatus());
|
||||
mtlb.setMedicalNotification(document.isMedicalNotification());
|
||||
mtlb.setMotherId(document.getMotherId());
|
||||
mtlb.setMtlbStatusData(document.getMtlbStatusData());
|
||||
mtlb.setMtlbType(document.getMtlbType());
|
||||
mtlb.setNotes(document.getNotes());
|
||||
mtlb.setNumberOfAttachments(document.getNumberOfAttachments());
|
||||
mtlb.setOtherCitizenshipCsv(document.getOtherCitizenshipCsv());
|
||||
mtlb.setPage(document.getPage());
|
||||
mtlb.setPrimaryCitizenship(document.getPrimaryCitizenship());
|
||||
mtlb.setReportedFatherName(document.getReportedFatherName());
|
||||
mtlb.setReportedId(document.getReportedId());
|
||||
mtlb.setReportedLegacyId(document.getReportedLegacyId());
|
||||
mtlb.setReportedMotherName(document.getReportedMotherName());
|
||||
mtlb.setRightIndexFinger(document.getRightIndexFinger());
|
||||
mtlb.setRightMiddleFinger(document.getRightMiddleFinger());
|
||||
mtlb.setRightPinky(document.getRightPinky());
|
||||
mtlb.setRightRingFinger(document.getRightRingFinger());
|
||||
mtlb.setRightThumb(document.getRightThumb());
|
||||
mtlb.setSecondname(document.getSecondname());
|
||||
mtlb.setSignature(document.getSignature());
|
||||
mtlb.setSignatureMimeType(document.getSignatureMimeType());
|
||||
mtlb.setSixthname(document.getSixthname());
|
||||
mtlb.setThirdname(document.getThirdname());
|
||||
mtlb.setTimeOfDeath(document.getTimeOfDeath());
|
||||
mtlb.setTouched(document.getTouched());
|
||||
mtlb.setUploaded(document.isUploaded());
|
||||
mtlb.setUuid(document.getUuid());
|
||||
mtlb.setVitalRecordId(document.getVitalRecordId());
|
||||
mtlb.setWitness1Id(document.getWitness1Id());
|
||||
mtlb.setWitness2Id(document.getWitness2Id());
|
||||
mtlb.setYear(document.getYear());
|
||||
mtlb.setAfisId(document.getAfisId());
|
||||
mtlb.setTimeOfDeath(document.getTimeOfDeath());
|
||||
mtlb.setDeathPlace(document.getDeathPlace());
|
||||
mtlb.setTypeOfAcquisition(document.getTypeOfAcquisition());
|
||||
mtlb.setVillageOfOrigin(document.getVillageOfOrigin());
|
||||
mtlb.setBurialPlace(document.getBurialPlace());
|
||||
mtlb.setDeathNotification(document.isDeathNotification());
|
||||
mtlb.setAdoptiveFatherId(document.getAdoptiveFatherId());
|
||||
mtlb.setAdoptiveMotherId(document.getAdoptiveMotherId());
|
||||
mtlb.setVillageOfOriginAdoptive(document.getVillageOfOriginAdoptive());
|
||||
mtlb.setMarriageCertificateNumberAdoptive(document.getMarriageCertificateNumberAdoptive());
|
||||
mtlb.setCourtAdoptionNumber(document.getCourtAdoptionNumber());
|
||||
mtlb.setRegistrationLocation(document.getRegistrationLocation());
|
||||
mtlb.setMentions(document.getMentions());
|
||||
if (MtlbType.ADOPTION.equals(document.getMtlbType())) {
|
||||
mtlb.setFatherEndAdoptionDate(document.getFatherEndAdoptionDate());
|
||||
mtlb.setMotherEndAdoptionDate(document.getMotherEndAdoptionDate());
|
||||
if (document.getAdoptiveFatherId() != null) {
|
||||
AdoptiveFathers newAdoptiveFather = new AdoptiveFathers();
|
||||
newAdoptiveFather.setChildId(document.getVitalRecordId());
|
||||
newAdoptiveFather.setCivilStatusMtlbId(document.getId());
|
||||
newAdoptiveFather.setCourtAdoptionNumber(document.getCourtAdoptionNumber());
|
||||
newAdoptiveFather.setFatherAdoptionDate(document.getFatherAdoptionDate());
|
||||
newAdoptiveFather.setVitalRecordId(document.getAdoptiveFatherId());
|
||||
adoptiveFathersRepository.insert(newAdoptiveFather);
|
||||
}
|
||||
if (document.getAdoptiveMotherId() != null) {
|
||||
AdoptiveMothers newAdoptiveMother = new AdoptiveMothers();
|
||||
newAdoptiveMother.setChildId(document.getVitalRecordId());
|
||||
newAdoptiveMother.setCivilStatusMtlbId(document.getId());
|
||||
newAdoptiveMother.setCourtAdoptionNumber(document.getCourtAdoptionNumber());
|
||||
newAdoptiveMother.setMotherAdoptionDate(document.getMotherAdoptionDate());
|
||||
newAdoptiveMother.setVitalRecordId(document.getAdoptiveMotherId());
|
||||
adoptiveMothersRepository.insert(newAdoptiveMother);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.GeoData;
|
||||
import systems.archide.core.pojo.GeoDataCreateRequest;
|
||||
import systems.archide.core.pojo.Locations;
|
||||
import systems.archide.core.repository.GeoDataRepository;
|
||||
import systems.archide.core.repository.LocationsRepository;
|
||||
|
||||
@Component
|
||||
public class GeoDataServiceLogic {
|
||||
|
||||
@Autowired
|
||||
GeoDataRepository service;
|
||||
|
||||
public ResponseEntity<Long> saveByAreaId(GeoDataCreateRequest geoData) {
|
||||
GeoData location = service.findByAreaId(geoData.getAreaId());
|
||||
if (location != null)
|
||||
return ResponseEntity.ok(location.getId());
|
||||
else {
|
||||
GeoData newLocation = new GeoData();
|
||||
newLocation.setId(geoData.getId());
|
||||
newLocation.setAreaId(geoData.getAreaId());
|
||||
newLocation.setParentId(geoData.getParentId());
|
||||
newLocation.setName(geoData.getName());
|
||||
newLocation.setType(geoData.getType());
|
||||
newLocation.setDisabled(false);
|
||||
return ResponseEntity.ok(service.insert(newLocation));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.GetGlobalStateRequest;
|
||||
import systems.archide.core.pojo.GlobalState;
|
||||
import systems.archide.core.pojo.SetGlobalStateRequest;
|
||||
import systems.archide.core.repository.GlobalStateRepository;
|
||||
|
||||
@Component
|
||||
public class GlobalStateLogic {
|
||||
|
||||
@Autowired
|
||||
private GlobalStateRepository service;
|
||||
|
||||
public ResponseEntity<String> set(SetGlobalStateRequest setGlobalStateRequest) {
|
||||
GlobalState globalState = new GlobalState();
|
||||
globalState.setKey(setGlobalStateRequest.getKey());
|
||||
globalState.setValue(setGlobalStateRequest.getValue());
|
||||
service.save(globalState);
|
||||
return ResponseEntity.ok(globalState.getKey());
|
||||
}
|
||||
|
||||
public ResponseEntity<String> get(GetGlobalStateRequest getGlobalStateRequest) {
|
||||
return ResponseEntity.ok(service.getValueByKey(getGlobalStateRequest.getKey()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cocentris.spring.rest.security.SpringRestSecurityUtil;
|
||||
|
||||
import systems.archide.core.RestEndpoints;
|
||||
import systems.archide.core.pojo.GetGlobalStateRequest;
|
||||
import systems.archide.core.pojo.SetGlobalStateRequest;
|
||||
|
||||
@Component
|
||||
public class GlobalStateSecurityBusinessRules {
|
||||
|
||||
public boolean set(SetGlobalStateRequest setGlobalStateRequest, Authentication authentication) {
|
||||
HashSet<String> roles = null;
|
||||
try {
|
||||
roles = SpringRestSecurityUtil.getUserRoles(authentication);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (roles == null)
|
||||
return false;
|
||||
|
||||
if (roles.contains(RestEndpoints.RV4_MIGRATION_TOOL) && "migration".equals(setGlobalStateRequest.getKey()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean get(GetGlobalStateRequest getGlobalStateRequest, Authentication authentication) {
|
||||
HashSet<String> roles = null;
|
||||
try {
|
||||
roles = SpringRestSecurityUtil.getUserRoles(authentication);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (roles == null)
|
||||
return false;
|
||||
|
||||
if (roles.contains(RestEndpoints.RV4_MIGRATION_TOOL) && "migration".equals(getGlobalStateRequest.getKey()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.IdMtlb;
|
||||
import systems.archide.core.pojo.IdMtlbDocument;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.repository.IdMtlbRepository;
|
||||
|
||||
@Component
|
||||
public class IdMtlbDocumentLogic {
|
||||
|
||||
@Autowired
|
||||
private IdMtlbRepository idMtlbService;
|
||||
|
||||
public Long newDocument(IdMtlbDocument document) {
|
||||
IdMtlb idMtlb = new IdMtlb();
|
||||
idMtlbCreateRequest2IdMtlb(document, idMtlb);
|
||||
idMtlb.setMtlbStatus(MtlbStatus.INITIATED);
|
||||
idMtlb.setPrinted(false);
|
||||
return idMtlbService.insert(idMtlb);
|
||||
}
|
||||
|
||||
private IdMtlb idMtlbCreateRequest2IdMtlb(IdMtlbDocument document, IdMtlb idMtlb) {
|
||||
idMtlb.setDraft(document.isDraft());
|
||||
idMtlb.setFace(document.getFace());
|
||||
idMtlb.setFaceMimeType(document.getFaceMimeType());
|
||||
idMtlb.setVitalRecordId(document.getVitalRecordId());
|
||||
idMtlb.setMtlbType(document.getMtlbType());
|
||||
return idMtlb;
|
||||
}
|
||||
|
||||
public Long editDocument(IdMtlbDocument document) {
|
||||
IdMtlb idMtlb = idMtlbService.findById(document.getId());
|
||||
System.out.println(idMtlb);
|
||||
System.out.println(idMtlb.isPrinted());
|
||||
idMtlbCreateRequest2IdMtlb(document, idMtlb);
|
||||
idMtlb.setDraft(false);
|
||||
idMtlbService.update(idMtlb);
|
||||
return idMtlb.getId();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.Rv4BirthMtlbAttachment;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlbAttachment;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbAttachmentRepository;
|
||||
|
||||
@Component
|
||||
public class Rv4BirthMtlbAttachmentLogic {
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbAttachmentRepository rvfourBirthMtlbAttachmentRepository;
|
||||
|
||||
public Long create(Rv4BirthMtlbAttachment rv4BirthMtlbAttachment) {
|
||||
RvfourBirthMtlbAttachment attachment = new RvfourBirthMtlbAttachment();
|
||||
attachment.setContent(rv4BirthMtlbAttachment.getContent());
|
||||
attachment.setFileName(rv4BirthMtlbAttachment.getFileName());
|
||||
attachment.setRvfourBirthMtlbId(rv4BirthMtlbAttachment.getRv4MtlbId());
|
||||
return rvfourBirthMtlbAttachmentRepository.insert(attachment);
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> saveByRv4MtlbId(Rv4BirthMtlbAttachment rv4BirthMtlbAttachment) {
|
||||
RvfourBirthMtlbAttachment newAttachment = new RvfourBirthMtlbAttachment();
|
||||
newAttachment.setContent(rv4BirthMtlbAttachment.getContent());
|
||||
newAttachment.setFileName(rv4BirthMtlbAttachment.getFileName());
|
||||
newAttachment.setRvfourBirthMtlbId(rv4BirthMtlbAttachment.getRv4MtlbId());
|
||||
newAttachment.setDescription(rv4BirthMtlbAttachment.getDescription());
|
||||
newAttachment.setPreview(rv4BirthMtlbAttachment.getPreview());
|
||||
List<RvfourBirthMtlbAttachment> attachmentList = rvfourBirthMtlbAttachmentRepository.findByFileName(rv4BirthMtlbAttachment.getFileName());
|
||||
for (RvfourBirthMtlbAttachment attachment: attachmentList) {
|
||||
if (rv4BirthMtlbAttachment.getRv4MtlbId() == attachment.getRvfourBirthMtlbId()) {
|
||||
newAttachment.setId(attachment.getId());
|
||||
rvfourBirthMtlbAttachmentRepository.save(newAttachment);
|
||||
return ResponseEntity.ok(newAttachment.getId());
|
||||
}
|
||||
}
|
||||
return ResponseEntity.ok(rvfourBirthMtlbAttachmentRepository.insert(newAttachment));
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.pojo.UnionMtlb;
|
||||
import systems.archide.core.pojo.UnionMtlbAttachment;
|
||||
import systems.archide.core.pojo.UnionMtlbDocument;
|
||||
import systems.archide.core.pojo.UnionRecordAttachment;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.UnionMtlbAttachmentRepository;
|
||||
import systems.archide.core.repository.UnionMtlbDocumentRepository;
|
||||
import systems.archide.core.repository.UnionMtlbRepository;
|
||||
import systems.archide.core.repository.UnionRecordAttachmentRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@Component
|
||||
public class UnionMtlbDocumentLogic {
|
||||
|
||||
@Autowired
|
||||
UnionMtlbDocumentRepository service;
|
||||
|
||||
@Autowired
|
||||
private VitalRecordRepository vitalRecordService;
|
||||
|
||||
@Autowired
|
||||
UnionRecordAttachmentRepository unionRecordAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
UnionMtlbAttachmentRepository unionMtlbAttachmentRepository;
|
||||
|
||||
public Long newDocument(UnionMtlbDocument document) {
|
||||
UnionMtlb uMtlb = new UnionMtlb();
|
||||
if (MtlbType.UNION_RECORD_CHANGE.equals(document.getMtlbType()) && document.getUnionRecordId() != null)
|
||||
dto2pojo(uMtlb, document);
|
||||
uMtlb.setMtlbStatus(MtlbStatus.INITIATED);
|
||||
uMtlb.setUnionRecordId(document.getUnionRecordId());
|
||||
uMtlb.setMtlbType(document.getMtlbType());
|
||||
uMtlb.setDraft(true);
|
||||
Long id = service.insert(uMtlb);
|
||||
if (MtlbType.UNION_RECORD_CHANGE.equals(document.getMtlbType()) && document.getUnionRecordId() != null)
|
||||
addAttachments(id, document.getUnionRecordId());
|
||||
return id;
|
||||
}
|
||||
|
||||
private void addAttachments(Long mtlbId, Long unionRecordId) {
|
||||
List<UnionRecordAttachment> uaList = unionRecordAttachmentRepository.findByUnionRecordId(unionRecordId);
|
||||
for (UnionRecordAttachment ua: uaList) {
|
||||
UnionMtlbAttachment a = new UnionMtlbAttachment();
|
||||
a.setContent(ua.getContent());
|
||||
a.setDescription(ua.getDescription());
|
||||
a.setFileName(ua.getFileName());
|
||||
a.setPreview(ua.getPreview());
|
||||
a.setUnionMtlbId(mtlbId);
|
||||
unionMtlbAttachmentRepository.insert(a);
|
||||
}
|
||||
}
|
||||
|
||||
public Long editDocument(UnionMtlbDocument document) {
|
||||
UnionMtlb uMtlb = service.findById(document.getId());
|
||||
dto2pojo(uMtlb, document);
|
||||
uMtlb.setDraft(false);
|
||||
uMtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
uMtlb.setId(document.getId());
|
||||
service.update(uMtlb);
|
||||
return uMtlb.getId();
|
||||
}
|
||||
|
||||
private void dto2pojo(UnionMtlb uMtlb, UnionMtlbDocument document) {
|
||||
uMtlb.setAddress(document.getAddress());
|
||||
uMtlb.setDeclaredDate(document.getDeclaredDate());
|
||||
uMtlb.setMtlbStatusData(document.getMtlbStatusData());
|
||||
uMtlb.setMtlbType(document.getMtlbType());
|
||||
uMtlb.setNotes(document.getNotes());
|
||||
uMtlb.setPartner1BirthPlace(document.getPartner1BirthPlace());
|
||||
uMtlb.setPartner1FatherId(document.getPartner1FatherId());
|
||||
uMtlb.setPartner1FatherName(document.getPartner1FatherName());
|
||||
uMtlb.setPartner1Firstname(document.getPartner1Firstname());
|
||||
uMtlb.setPartner1IndividualMelanesianName(document.getPartner1IndividualMelanesianName());
|
||||
uMtlb.setPartner1MaritalStatus(document.getPartner1MaritalStatus());
|
||||
uMtlb.setPartner1MotherId(document.getPartner1MotherId());
|
||||
uMtlb.setPartner1MotherName(document.getPartner1MotherName());
|
||||
uMtlb.setPartner1Occupation(document.getPartner1Occupation());
|
||||
uMtlb.setPartner1ResidenceAddress(document.getPartner1ResidenceAddress());
|
||||
uMtlb.setPartner1Surname(document.getPartner1Surname());
|
||||
uMtlb.setPartner1VitalRecordId(document.getPartner1VitalRecordId());
|
||||
uMtlb.setPartner2BirthPlace(document.getPartner2BirthPlace());
|
||||
uMtlb.setPartner2FatherId(document.getPartner2FatherId());
|
||||
uMtlb.setPartner2FatherName(document.getPartner2FatherName());
|
||||
uMtlb.setPartner2Firstname(document.getPartner2Firstname());
|
||||
uMtlb.setPartner2IndividualMelanesianName(document.getPartner2IndividualMelanesianName());
|
||||
uMtlb.setPartner2MaritalStatus(document.getPartner2MaritalStatus());
|
||||
uMtlb.setPartner2MotherId(document.getPartner2MotherId());
|
||||
uMtlb.setPartner2MotherName(document.getPartner2MotherName());
|
||||
uMtlb.setPartner2Occupation(document.getPartner2Occupation());
|
||||
uMtlb.setPartner2ResidenceAddress(document.getPartner2ResidenceAddress());
|
||||
uMtlb.setPartner2Surname(document.getPartner2Surname());
|
||||
uMtlb.setPartner2VitalRecordId(document.getPartner2VitalRecordId());
|
||||
uMtlb.setPlace(document.getPlace());
|
||||
uMtlb.setRites(document.getRites());
|
||||
uMtlb.setUnionRegime(document.getUnionRegime());
|
||||
uMtlb.setWitness1BirthPlace(document.getWitness1BirthPlace());
|
||||
uMtlb.setWitness1Firstname(document.getWitness1Firstname());
|
||||
uMtlb.setWitness1Occupation(document.getWitness1Occupation());
|
||||
uMtlb.setWitness1ResidenceAddress(document.getWitness1ResidenceAddress());
|
||||
uMtlb.setWitness1Surname(document.getWitness1Surname());
|
||||
uMtlb.setWitness1VitalRecordId(document.getWitness1VitalRecordId());
|
||||
uMtlb.setWitness2BirthPlace(document.getWitness2BirthPlace());
|
||||
uMtlb.setWitness2Firstname(document.getWitness2Firstname());
|
||||
uMtlb.setWitness2Occupation(document.getWitness2Occupation());
|
||||
uMtlb.setWitness2ResidenceAddress(document.getWitness2ResidenceAddress());
|
||||
uMtlb.setWitness2Surname(document.getWitness2Surname());
|
||||
uMtlb.setWitness2VitalRecordId(document.getWitness2VitalRecordId());
|
||||
uMtlb.setTimeOfMarriage(document.getTimeOfMarriage());
|
||||
uMtlb.setDateOfOrder(document.getDateOfOrder());
|
||||
uMtlb.setDateOfEffect(document.getDateOfEffect());
|
||||
uMtlb.setAnnullmentOrder(document.getAnnullmentOrder());
|
||||
uMtlb.setUnionRecordId(document.getUnionRecordId());
|
||||
uMtlb.setCelebrant(document.getCelebrant());
|
||||
uMtlb.setPosition(document.getPosition());
|
||||
uMtlb.setOfficer(document.getOfficer());
|
||||
uMtlb.setCelebrantId(document.getCelebrantId());
|
||||
uMtlb.setDeclarantId(document.getDeclarantId());
|
||||
uMtlb.setOfficerId(document.getOfficerId());
|
||||
uMtlb.setRegistrationLocation(document.getRegistrationLocation());
|
||||
uMtlb.setMentions(document.getMentions());
|
||||
if (document.getPartner1VitalRecordId() != null) {
|
||||
VitalRecord partner1 = vitalRecordService.findById(document.getPartner1VitalRecordId());
|
||||
if (partner1 != null) {
|
||||
uMtlb.setPartner1Firstname(partner1.getFirstname());
|
||||
uMtlb.setPartner1Surname(partner1.getFourthname());
|
||||
}
|
||||
}
|
||||
if (document.getPartner2VitalRecordId() != null) {
|
||||
VitalRecord partner2 = vitalRecordService.findById(document.getPartner2VitalRecordId());
|
||||
if (partner2 != null) {
|
||||
uMtlb.setPartner2Firstname(partner2.getFirstname());
|
||||
uMtlb.setPartner2Surname(partner2.getFourthname());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,187 @@
|
||||
package systems.archide.core.service.hooks;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bouncycastle.asn1.ocsp.ResponderID;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.ResponseEntity.BodyBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.controller.search.VitalRecordOrderBy;
|
||||
import systems.archide.core.pojo.AddAddressRequest;
|
||||
import systems.archide.core.pojo.Address;
|
||||
import systems.archide.core.pojo.CountVoterInBatchRequest;
|
||||
import systems.archide.core.pojo.DeathRecord;
|
||||
import systems.archide.core.pojo.DocumentType;
|
||||
import systems.archide.core.pojo.Face;
|
||||
import systems.archide.core.pojo.GetVoterListRequest;
|
||||
import systems.archide.core.pojo.ImportVoterRequest;
|
||||
import systems.archide.core.pojo.ImportVoterResponse;
|
||||
import systems.archide.core.pojo.IssuedDocuments;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.pojo.VitalRecordHistory;
|
||||
import systems.archide.core.pojo.VoterRecord;
|
||||
import systems.archide.core.repository.AddressRepository;
|
||||
import systems.archide.core.repository.DeathRecordRepository;
|
||||
import systems.archide.core.repository.FaceRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.IssuedDocumentsRepository;
|
||||
import systems.archide.core.repository.VitalRecordHistoryRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@Component
|
||||
public class VanElectServiceLogic {
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
DeathRecordRepository deathRecordRepository;
|
||||
|
||||
@Autowired
|
||||
IssuedDocumentsRepository issuedDocumentsRepository;
|
||||
|
||||
@Autowired
|
||||
FaceRepository faceRepository;
|
||||
|
||||
@Autowired
|
||||
AddressRepository addressRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@Autowired
|
||||
VitalRecordHistoryRepository vitalRecordHistoryRepository;
|
||||
|
||||
public ResponseEntity<List<VoterRecord>> getVoterRecordList(GetVoterListRequest getVoterListRequest) {
|
||||
List<VoterRecord> voterRecordList = new ArrayList<>();
|
||||
HttpHeaders metadata = new HttpHeaders();
|
||||
ResponseEntity<List<VoterRecord>> response = null;
|
||||
long maxId = queries.getMaxVitalRecordId();
|
||||
List<VitalRecord> vitalRecordList = queries.getVoterList(getVoterListRequest.getCutOffDate(),
|
||||
getVoterListRequest.getCutOffAgeDate().toLocalDate(), getVoterListRequest.getMin(),
|
||||
getVoterListRequest.getMax());
|
||||
List<VitalRecord> vitalRecordHistoryList = queries.getVoterListFromHistory(getVoterListRequest.getCutOffDate(),
|
||||
getVoterListRequest.getCutOffAgeDate().toLocalDate(), getVoterListRequest.getMin(),
|
||||
getVoterListRequest.getMax(), getVoterListRequest.getCutOffDate());
|
||||
for (VitalRecord vr : vitalRecordList) {
|
||||
VoterRecord voter = getValideVoter(vr, getVoterListRequest);
|
||||
if (voter != null)
|
||||
voterRecordList.add(voter);
|
||||
}
|
||||
for (VitalRecord vr : vitalRecordHistoryList) {
|
||||
VoterRecord voter = getValideVoter(vr, getVoterListRequest);
|
||||
if (voter != null)
|
||||
voterRecordList.add(voter);
|
||||
}
|
||||
if (maxId < getVoterListRequest.getMax())
|
||||
metadata.add("status", "DONE");
|
||||
else
|
||||
metadata.add("status", "CONTINUE");
|
||||
response = ResponseEntity.status(HttpStatus.CREATED).headers(metadata).body(voterRecordList);
|
||||
return response;
|
||||
}
|
||||
|
||||
private VoterRecord getValideVoter(VitalRecord vr, GetVoterListRequest getVoterListRequest) {
|
||||
List<DeathRecord> drList = deathRecordRepository.findByVitalRecordId(vr.getId());
|
||||
if (!drList.isEmpty())
|
||||
return null;
|
||||
List<IssuedDocuments> issuedDocumentList = issuedDocumentsRepository.findByVitalRecordId(vr.getId());
|
||||
for (IssuedDocuments issuedDocument : issuedDocumentList) {
|
||||
if (DocumentType.ID_CARD.equals(issuedDocument.getDocumentType()) && "191".equals(vr.getPrimaryCitizenship())) {
|
||||
VoterRecord voter = new VoterRecord();
|
||||
voter.setFirstname(vr.getFirstname());
|
||||
voter.setSecondname(vr.getSecondname());
|
||||
voter.setThirdname(vr.getThirdname());
|
||||
voter.setFourthname(vr.getFourthname());
|
||||
voter.setIdCard(issuedDocument.getDocumentId());
|
||||
voter.setId(vr.getId());
|
||||
voter.setBirthdate(vr.getBirthdate());
|
||||
if (vr.getFaceId() != null) {
|
||||
Face face = faceRepository.findById(vr.getFaceId());
|
||||
voter.setFace(face.getImage());
|
||||
}
|
||||
List<Address> vrAdresses = addressRepository.findByVitalRecordId(vr.getId());
|
||||
String lastAddress = null;
|
||||
if (!vrAdresses.isEmpty())
|
||||
lastAddress = vrAdresses.get(vrAdresses.size() - 1).getAreaId();
|
||||
voter.setAddress(lastAddress);
|
||||
if (getVoterListRequest.getGeography() != null) {
|
||||
if (lastAddress != null)
|
||||
if (lastAddress.startsWith(getVoterListRequest.getGeography()))
|
||||
return voter;
|
||||
}
|
||||
else
|
||||
return voter;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> getMaxId() {
|
||||
return ResponseEntity.ok(queries.getMaxVitalRecordId());
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> countVotersInBatch(CountVoterInBatchRequest request) {
|
||||
HashSet<Long> votersInBatch = new HashSet<>();
|
||||
List<Long> mainNumberOfVoters = queries.getMainIdListInBatch(request.getCutOffDate(), request.getCutOffAgeDate().toLocalDate(),
|
||||
request.getMin(), request.getMax());
|
||||
List<Long> historyNumberOfVoters = queries.getHistoryIdListInBatch(request.getCutOffDate(), request.getCutOffAgeDate().toLocalDate(),
|
||||
request.getMin(), request.getMax(), request.getCutOffDate());
|
||||
for (Long id: mainNumberOfVoters)
|
||||
votersInBatch.add(id);
|
||||
for (Long hId: historyNumberOfVoters)
|
||||
votersInBatch.add(hId);
|
||||
return ResponseEntity.ok((long) votersInBatch.size());
|
||||
}
|
||||
|
||||
public ResponseEntity<Long> addAddress(AddAddressRequest addAddressRequest) {
|
||||
VitalRecord vr = vitalRecordRepository.findById(addAddressRequest.getVitalRecordId());
|
||||
if (vr != null) {
|
||||
Address address = new Address();
|
||||
address.setAreaId(addAddressRequest.getAddress());
|
||||
address.setVitalRecordId(vr.getId());
|
||||
addressRepository.insert(address);
|
||||
return ResponseEntity.ok(vr.getId());
|
||||
}
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
public ResponseEntity<ImportVoterResponse> importVoter(ImportVoterRequest importVoterRequest) {
|
||||
VitalRecord vr = vitalRecordRepository.findById(importVoterRequest.getVitalRecordId());
|
||||
if (vr != null) {
|
||||
ImportVoterResponse v = new ImportVoterResponse();
|
||||
v.setBirthdate(vr.getBirthdate());
|
||||
v.setFirstname(vr.getFirstname());
|
||||
v.setFourthname(vr.getFourthname());
|
||||
v.setSecondname(vr.getSecondname());
|
||||
v.setThirdname(vr.getThirdname());
|
||||
v.setId(vr.getId());
|
||||
if (vr.getFaceId() != null) {
|
||||
Face face = faceRepository.findById(vr.getFaceId());
|
||||
v.setFace(face.getImage());
|
||||
}
|
||||
List<Address> vrAdresses = addressRepository.findByVitalRecordId(vr.getId());
|
||||
List<IssuedDocuments> issuedDocumentList = issuedDocumentsRepository.findByVitalRecordId(vr.getId());
|
||||
for (IssuedDocuments issuedDocument : issuedDocumentList) {
|
||||
if (DocumentType.ID_CARD.equals(issuedDocument.getDocumentType()))
|
||||
v.setIdCard(issuedDocument.getDocumentId());
|
||||
}
|
||||
String lastAddress = null;
|
||||
if (!vrAdresses.isEmpty())
|
||||
lastAddress = vrAdresses.get(vrAdresses.size() - 1).getAreaId();
|
||||
v.setAddress(lastAddress);
|
||||
return ResponseEntity.ok(v);
|
||||
}
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
@ -0,0 +1,209 @@
|
||||
package systems.archide.core.workflows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import systems.archide.core.pojo.DocumentType;
|
||||
import systems.archide.core.pojo.GeneralStatistics;
|
||||
import systems.archide.core.pojo.GeoData;
|
||||
import systems.archide.core.pojo.IssuedDocumentsDto;
|
||||
import systems.archide.core.pojo.JobMtlb;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.ProvinceGeneralStatistics;
|
||||
import systems.archide.core.pojo.VitalRecordDto;
|
||||
import systems.archide.core.repository.GeoDataRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.IssuedDocumentsRepository;
|
||||
import systems.archide.core.repository.JobMtlbRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@Component
|
||||
public class JobMtlbSubmitted {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JobMtlbSubmitted.class);
|
||||
|
||||
private static final Short MALE = 1;
|
||||
private static final Short FEMALE = 2;
|
||||
|
||||
@Autowired
|
||||
JobMtlbRepository jobMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@Autowired
|
||||
GeoDataRepository geoDataRepository;
|
||||
|
||||
@Autowired
|
||||
IssuedDocumentsRepository issuedDocumentsRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void fromSubmittedMtlb() {
|
||||
List<JobMtlb> mtlbList = jobMtlbRepository.findByMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
for (JobMtlb mtlb : mtlbList) {
|
||||
switch (mtlb.getMtlbType()) {
|
||||
case GENERAL_STATISTICS:
|
||||
mtlb.setMtlbStatus(MtlbStatus.PROCESSING);
|
||||
jobMtlbRepository.update(mtlb);
|
||||
processGeneralStatisticsMtlb(mtlb);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processGeneralStatisticsMtlb(JobMtlb mtlb) {
|
||||
GeneralStatistics generalStatistics = new GeneralStatistics();
|
||||
IssuedDocumentsDto filter = new IssuedDocumentsDto();
|
||||
filter.addDocumentType(DocumentType.ID_CARD);
|
||||
Long issuedIdCardsNumber = issuedDocumentsRepository.countSearchByDocumentType(filter, null, null, null, null, true);
|
||||
|
||||
Long notExpiredIdCardsNumber = queries.getNotExpiredIdCardNumber();
|
||||
Long notCancelledIdCardsNumber = queries.getNotCancelledIdCardNumber();
|
||||
Long activatedIdCardsNumber = queries.getActiveIdCardNumber();
|
||||
Long distinctIndividualsIdCardsNumber = queries.getDistinctVitalRecordIdCardsNumber();
|
||||
VitalRecordDto recordFilter = new VitalRecordDto();
|
||||
recordFilter.addInactive(false);
|
||||
Long authorizedBirthRecordsNumber = vitalRecordRepository.count();
|
||||
Long livingAuthorizedBirthRecordsNumber = queries.getLivingVitalRecordNumber();
|
||||
Long livingFemalesAged18To29Number = queries.getLivingVitalRecordByGenderAndAgeRange(FEMALE, 18, 29);
|
||||
Long livingMalesAged18To29Number = queries.getLivingVitalRecordByGenderAndAgeRange(MALE, 18, 29);
|
||||
Long livingMalesAgedUnder18Number = queries.getLivingVitalRecordByGenderAndAgeRange(MALE, 0, 17);
|
||||
Long livingFemalesAgedUnder18Number = queries.getLivingVitalRecordByGenderAndAgeRange(FEMALE, 0, 17);
|
||||
Long livingMalesAged30To49Number = queries.getLivingVitalRecordByGenderAndAgeRange(MALE, 30, 49);
|
||||
Long livingFemalesAged30To49Number = queries.getLivingVitalRecordByGenderAndAgeRange(FEMALE, 30, 49);
|
||||
Long livingMalesAgedOver49Number = queries.getLivingVitalRecordByGenderAndAgeRange(MALE, 50, 120);
|
||||
Long livingFemalesAgedOver49Number = queries.getLivingVitalRecordByGenderAndAgeRange(FEMALE, 50, 120);
|
||||
Long livingPeopleWithCardsNumber = queries.getLivingVitalRecordIdCardsNumber();
|
||||
Long livingFemalesAgedUnder18WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRange(FEMALE, 0, 17);
|
||||
Long livingMalesAgedUnder18WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRange(MALE, 0, 17);
|
||||
Long livingFemalesAged18To29WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRange(FEMALE, 18, 29);
|
||||
Long livingMalesAged18To29WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRange(MALE, 18, 29);
|
||||
Long livingFemalesAged30To49WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRange(FEMALE, 30, 49);
|
||||
Long livingMalesAged30To49WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRange(MALE, 30, 49);
|
||||
Long livingFemalesAgedOver49WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRange(FEMALE, 50, 120);
|
||||
Long livingMalesAgedOver49WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRange(MALE, 50, 120);
|
||||
generalStatistics.setIssuedIdCardsNumber(issuedIdCardsNumber);
|
||||
generalStatistics.setNotExpiredIdCardsNumber(notExpiredIdCardsNumber);
|
||||
generalStatistics.setNotCancelledIdCardsNumber(notCancelledIdCardsNumber);
|
||||
generalStatistics.setActivatedIdCardsNumber(activatedIdCardsNumber);
|
||||
generalStatistics.setDistinctIndividualsIdCardsNumber(distinctIndividualsIdCardsNumber);
|
||||
generalStatistics.setAuthorizedBirthRecordsNumber(authorizedBirthRecordsNumber);
|
||||
generalStatistics.setLivingFemalesAged18To29Number(livingFemalesAged18To29Number);
|
||||
generalStatistics.setLivingMalesAged18To29Number(livingMalesAged18To29Number);
|
||||
generalStatistics.setLivingMalesAgedUnder18Number(livingMalesAgedUnder18Number);
|
||||
generalStatistics.setLivingFemalesAgedUnder18Number(livingFemalesAgedUnder18Number);
|
||||
generalStatistics.setLivingMalesAged30To49Number(livingMalesAged30To49Number);
|
||||
generalStatistics.setLivingFemalesAged30To49Number(livingFemalesAged30To49Number);
|
||||
generalStatistics.setLivingMalesAgedOver49Number(livingMalesAgedOver49Number);
|
||||
generalStatistics.setLivingFemalesAgedOver49Number(livingFemalesAgedOver49Number);
|
||||
generalStatistics.setLivingAuthorizedBirthRecordsNumber(livingAuthorizedBirthRecordsNumber);
|
||||
generalStatistics.setLivingPeopleWithCardsNumber(livingPeopleWithCardsNumber);
|
||||
generalStatistics.setLivingMalesAgedUnder18WithCardsNumber(livingMalesAgedUnder18WithCardsNumber);
|
||||
generalStatistics.setLivingFemalesAgedUnder18WithCardsNumber(livingFemalesAgedUnder18WithCardsNumber);
|
||||
generalStatistics.setLivingFemalesAged18To29WithCardsNumber(livingFemalesAged18To29WithCardsNumber);
|
||||
generalStatistics.setLivingMalesAged18To29WithCardsNumber(livingMalesAged18To29WithCardsNumber);
|
||||
generalStatistics.setLivingFemalesAged30To49WithCardsNumber(livingFemalesAged30To49WithCardsNumber);
|
||||
generalStatistics.setLivingMalesAged30To49WithCardsNumber(livingMalesAged30To49WithCardsNumber);
|
||||
generalStatistics.setLivingFemalesAgedOver49WithCardsNumber(livingFemalesAgedOver49WithCardsNumber);
|
||||
generalStatistics.setLivingMalesAgedOver49WithCardsNumber(livingMalesAgedOver49WithCardsNumber);
|
||||
List<ProvinceGeneralStatistics> provinceGeneralStatisticsList = getProvinceGeneralStatisticsList();
|
||||
generalStatistics.setProvinceGeneralStatisticsList(provinceGeneralStatisticsList);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jobContent = null;
|
||||
try {
|
||||
jobContent = objectMapper.writeValueAsString(generalStatistics);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (jobContent != null) {
|
||||
mtlb.setContent(jobContent);
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
jobMtlbRepository.update(mtlb);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ProvinceGeneralStatistics> getProvinceGeneralStatisticsList() {
|
||||
List<ProvinceGeneralStatistics> provinceGeneralStatisticsList = new ArrayList<>();
|
||||
List<GeoData> provinceList = geoDataRepository.findByType(2);
|
||||
for (GeoData province : provinceList) {
|
||||
ProvinceGeneralStatistics provinceGeneralStatistics = new ProvinceGeneralStatistics();
|
||||
provinceGeneralStatistics.setProvinceName(province.getName());
|
||||
|
||||
Long authorizedBirthRecordsNumber = queries
|
||||
.getVitalRecordByAddressNumber(province.getAreaId() + "%");
|
||||
Long livingAuthorizedBirthRecordsNumber = queries
|
||||
.getLivingVitalRecordByAddressNumber(province.getAreaId() + "%");
|
||||
Long livingFemalesAged18To29Number = queries.getLivingVitalRecordByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", FEMALE, 18, 29);
|
||||
Long livingMalesAged18To29Number = queries.getLivingVitalRecordByGenderAndAgeRangeAndAddress(province.getAreaId() + "%",MALE, 18, 29);
|
||||
Long livingMalesAgedUnder18Number = queries.getLivingVitalRecordByGenderAndAgeRangeAndAddress(province.getAreaId() + "%",MALE, 0, 17);
|
||||
Long livingFemalesAgedUnder18Number = queries.getLivingVitalRecordByGenderAndAgeRangeAndAddress(province.getAreaId() + "%",FEMALE, 0, 17);
|
||||
Long livingMalesAged30To49Number = queries.getLivingVitalRecordByGenderAndAgeRangeAndAddress(province.getAreaId() + "%",MALE, 30, 49);
|
||||
Long livingFemalesAged30To49Number = queries.getLivingVitalRecordByGenderAndAgeRangeAndAddress(province.getAreaId() + "%",FEMALE, 30, 49);
|
||||
Long livingMalesAgedOver49Number = queries.getLivingVitalRecordByGenderAndAgeRangeAndAddress(province.getAreaId() + "%",MALE, 50, 120);
|
||||
Long livingFemalesAgedOver49Number = queries.getLivingVitalRecordByGenderAndAgeRangeAndAddress(province.getAreaId() + "%",FEMALE, 50, 120);
|
||||
Long livingPeopleWithCardsNumber = queries
|
||||
.getLivingVitalRecordIdCardsByAddressNumber(province.getAreaId() + "%");
|
||||
Long livingFemalesAgedUnder18WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", FEMALE, 0, 17);
|
||||
Long livingMalesAgedUnder18WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", MALE, 0, 17);
|
||||
Long livingFemalesAged18To29WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", FEMALE, 18, 29);
|
||||
Long livingMalesAged18To29WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", MALE, 18, 29);
|
||||
Long livingFemalesAged30To49WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", FEMALE, 30, 49);
|
||||
Long livingMalesAged30To49WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", MALE, 30, 49);
|
||||
Long livingFemalesAgedOver49WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", FEMALE, 50, 120);
|
||||
Long livingMalesAgedOver49WithCardsNumber = queries
|
||||
.getLivingVitalRecordWithIdCardByGenderAndAgeRangeAndAddress(province.getAreaId() + "%", MALE, 50, 120);
|
||||
provinceGeneralStatistics.setAuthorizedBirthRecordsNumber(authorizedBirthRecordsNumber);
|
||||
provinceGeneralStatistics.setLivingFemalesAged18To29Number(livingFemalesAged18To29Number);
|
||||
provinceGeneralStatistics.setLivingMalesAged18To29Number(livingMalesAged18To29Number);
|
||||
provinceGeneralStatistics.setLivingMalesAgedUnder18Number(livingMalesAgedUnder18Number);
|
||||
provinceGeneralStatistics.setLivingFemalesAgedUnder18Number(livingFemalesAgedUnder18Number);
|
||||
provinceGeneralStatistics.setLivingMalesAged30To49Number(livingMalesAged30To49Number);
|
||||
provinceGeneralStatistics.setLivingFemalesAged30To49Number(livingFemalesAged30To49Number);
|
||||
provinceGeneralStatistics.setLivingMalesAgedOver49Number(livingMalesAgedOver49Number);
|
||||
provinceGeneralStatistics.setLivingFemalesAgedOver49Number(livingFemalesAgedOver49Number);
|
||||
provinceGeneralStatistics.setLivingAuthorizedBirthRecordsNumber(livingAuthorizedBirthRecordsNumber);
|
||||
provinceGeneralStatistics.setLivingPeopleWithCardsNumber(livingPeopleWithCardsNumber);
|
||||
provinceGeneralStatistics.setLivingMalesAgedUnder18WithCardsNumber(livingMalesAgedUnder18WithCardsNumber);
|
||||
provinceGeneralStatistics
|
||||
.setLivingFemalesAgedUnder18WithCardsNumber(livingFemalesAgedUnder18WithCardsNumber);
|
||||
provinceGeneralStatistics.setLivingFemalesAged18To29WithCardsNumber(livingFemalesAged18To29WithCardsNumber);
|
||||
provinceGeneralStatistics.setLivingMalesAged18To29WithCardsNumber(livingMalesAged18To29WithCardsNumber);
|
||||
provinceGeneralStatistics.setLivingFemalesAged30To49WithCardsNumber(livingFemalesAged30To49WithCardsNumber);
|
||||
provinceGeneralStatistics.setLivingMalesAged30To49WithCardsNumber(livingMalesAged30To49WithCardsNumber);
|
||||
provinceGeneralStatistics.setLivingFemalesAgedOver49WithCardsNumber(livingFemalesAgedOver49WithCardsNumber);
|
||||
provinceGeneralStatistics.setLivingMalesAgedOver49WithCardsNumber(livingMalesAgedOver49WithCardsNumber);
|
||||
provinceGeneralStatisticsList.add(provinceGeneralStatistics);
|
||||
}
|
||||
return provinceGeneralStatisticsList;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package systems.archide.core.workflows;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlb;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbAttachmentRepository;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbRepository;
|
||||
|
||||
@Component
|
||||
public class RvFourBirthMtlbInitiated {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RvFourBirthMtlbInitiated.class);
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbRepository rvfourBirthMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbAttachmentRepository rvfourBirthMtlbAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void fromInitiatedStatus() {
|
||||
List<RvfourBirthMtlb> mtlbList = queries.getRandomRv4BirthMtlbByMtlbStatus(MtlbStatus.INITIATED.getValue());
|
||||
if (mtlbList.size() > 0) {
|
||||
AtomicInteger completed = new AtomicInteger();
|
||||
mtlbList.parallelStream().forEach((mtlb) -> { //parallel exec for concurrent list
|
||||
if (!mtlb.isDraft()) {
|
||||
if (mtlb.getNumberOfAttachments() == null || mtlb.getNumberOfAttachments() == 0) {
|
||||
mtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
rvfourBirthMtlbRepository.update(mtlb);
|
||||
} else {
|
||||
long received = rvfourBirthMtlbAttachmentRepository
|
||||
.count("rvfour_birth_mtlb_id = " + mtlb.getId());
|
||||
if (received>=mtlb.getNumberOfAttachments()) {
|
||||
mtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
rvfourBirthMtlbRepository.update(mtlb);
|
||||
completed.getAndIncrement();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (completed.get() >0)
|
||||
log.info("{} Rv4 Birth applications completed transmission", completed);
|
||||
}
|
||||
else log.info("no newly initiated Rv4 Birth applications found");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,689 @@
|
||||
package systems.archide.core.workflows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import systems.archide.core.ErrorCodes;
|
||||
import systems.archide.core.pojo.Address;
|
||||
import systems.archide.core.pojo.AddressType;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnex;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexLogEntry;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexTag;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexUtil;
|
||||
import systems.archide.core.pojo.CivilStatusMtlb;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbAttachment;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbNote;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbTag;
|
||||
import systems.archide.core.pojo.Email;
|
||||
import systems.archide.core.pojo.Face;
|
||||
import systems.archide.core.pojo.GeoData;
|
||||
import systems.archide.core.pojo.GlobalState;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.pojo.Occupation;
|
||||
import systems.archide.core.pojo.OccupationMetadata;
|
||||
import systems.archide.core.pojo.PhoneNumber;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlb;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlbAttachment;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlbTag;
|
||||
import systems.archide.core.pojo.TypeOfAcquisition;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.pojo.VitalRecordAttachment;
|
||||
import systems.archide.core.pojo.VitalRecordHistory;
|
||||
import systems.archide.core.pojo.VitalRecordMention;
|
||||
import systems.archide.core.pojo.VitalRecordNote;
|
||||
import systems.archide.core.pojo.VitalRecordTag;
|
||||
import systems.archide.core.repository.AddressRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbAttachmentRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbNoteRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbTagRepository;
|
||||
import systems.archide.core.repository.EmailRepository;
|
||||
import systems.archide.core.repository.FaceRepository;
|
||||
import systems.archide.core.repository.GeoDataRepository;
|
||||
import systems.archide.core.repository.GlobalStateRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.OccupationMetadataRepository;
|
||||
import systems.archide.core.repository.OccupationRepository;
|
||||
import systems.archide.core.repository.PhoneNumberRepository;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbAttachmentRepository;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbTagRepository;
|
||||
import systems.archide.core.repository.VitalRecordAttachmentRepository;
|
||||
import systems.archide.core.repository.VitalRecordHistoryRepository;
|
||||
import systems.archide.core.repository.VitalRecordMentionRepository;
|
||||
import systems.archide.core.repository.VitalRecordNoteRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
import systems.archide.core.repository.VitalRecordTagRepository;
|
||||
import systems.archide.core.workflows.utils.CustomErrorCodes;
|
||||
import systems.archide.core.workflows.utils.RvFourBirthMtlbUtils;
|
||||
import systems.archide.core.workflows.utils.Utils;
|
||||
|
||||
@Component
|
||||
public class RvFourBirthMtlbSubmitted {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RvFourBirthMtlbSubmitted.class);
|
||||
|
||||
|
||||
final static String RELIGION_TAG = "Religion";
|
||||
|
||||
final static String INVALID_BIRTH_PLACE_DATA = "RV4_ERR_1";
|
||||
final static String INVALID_RESIDENCE_ADDRESS_DATA = "RV4_ERR_2";
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
FaceRepository faceRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordTagRepository vitalRecordTagRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordAttachmentRepository vitalRecordAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
AddressRepository addressRepository;
|
||||
|
||||
@Autowired
|
||||
OccupationMetadataRepository occupationMetadataRepository;
|
||||
|
||||
@Autowired
|
||||
EmailRepository emailRepository;
|
||||
|
||||
@Autowired
|
||||
PhoneNumberRepository phoneNumberRepository;
|
||||
|
||||
@Autowired
|
||||
OccupationRepository occupationRepository;
|
||||
|
||||
@Autowired
|
||||
GeoDataRepository locationsRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbRepository rvfourBirthMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbTagRepository rvfourBirthMtlbTagRepository;
|
||||
|
||||
@Autowired
|
||||
GlobalStateRepository globalStateRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordNoteRepository vitalRecordNoteRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordMentionRepository vitalRecordMentionRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbAttachmentRepository rv4BirthMtlbAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
RvFourBirthMtlbUtils rvFourBirthMtlbUtils;
|
||||
|
||||
@Autowired
|
||||
VitalRecordHistoryRepository vitalRecordHistoryRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbRepository civilStatusMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbTagRepository civilStatusMtlbTagRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbAttachmentRepository civilStatusMtlbAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbNoteRepository civilStatusMtlbNoteRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@Autowired
|
||||
Utils utils;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void fromSubmittedStatus() {
|
||||
|
||||
GlobalState migrationState = globalStateRepository.findByKey("migration");
|
||||
List<RvfourBirthMtlb> mtlbList = queries.getRandomRv4BirthMtlbByMtlbStatus(MtlbStatus.SUBMITTED.getValue());
|
||||
|
||||
if (mtlbList.size() > 0) {
|
||||
log.info("Read {} newly submitted rv4 birth applications", mtlbList.size());
|
||||
for (RvfourBirthMtlb mtlb : mtlbList) {
|
||||
if (mtlb.getVitalRecordId() != null) {
|
||||
switch (mtlb.getMtlbType()) {
|
||||
case RV4_BIRTH_VITAL_RECORD:
|
||||
createVitalRecord(mtlb, migrationState);
|
||||
break;
|
||||
case RV4_VITAL_RECORD_HISTORY:
|
||||
createHistoryRecord(mtlb);
|
||||
break;
|
||||
case RV4_BIRTH_APPLICATION:
|
||||
createBirthApplication(mtlb, migrationState);
|
||||
break;
|
||||
default:
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
}
|
||||
rvfourBirthMtlbRepository.save(mtlb);
|
||||
} else {
|
||||
mtlb.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
RvfourBirthMtlbTag tag = new RvfourBirthMtlbTag();
|
||||
tag.setRvfourBirthMtlbId(mtlb.getId());
|
||||
tag.setContent(ErrorCodes.VITAL_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
rvfourBirthMtlbTagRepository.save(tag);
|
||||
rvfourBirthMtlbRepository.save(mtlb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createBirthApplication(RvfourBirthMtlb mtlb, GlobalState migrationState) {
|
||||
CivilStatusMtlb csMtlb = new CivilStatusMtlb();
|
||||
csMtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
csMtlb.setMtlbType(MtlbType.BIRTH_REGISTRATION);
|
||||
ArrayList<CivilStatusMtlbTag> tags = new ArrayList<CivilStatusMtlbTag>();
|
||||
if (mtlb.getFatherId() != null) {
|
||||
int fatherRecordStatus = utils.checkVitalRecordStatus(mtlb.getFatherId(), migrationState);
|
||||
if (fatherRecordStatus == Utils.FOUND)
|
||||
csMtlb.setFatherId(mtlb.getFatherId());
|
||||
else if (fatherRecordStatus == Utils.UNKNOWN || fatherRecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (fatherRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
CivilStatusMtlbTag tag = null;
|
||||
tag = new CivilStatusMtlbTag();
|
||||
tag.setContent(ErrorCodes.FATHER_NOT_FOUND);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
} else if (fatherRecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
CivilStatusMtlbTag tag = null;
|
||||
tag = new CivilStatusMtlbTag();
|
||||
tag.setKey(CustomErrorCodes.RV4_FATHER_FAMILY_TREE_RECORD);
|
||||
tag.setContent(mtlb.getFatherId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
if (mtlb.getMotherId() != null) {
|
||||
int motherRecordStatus = utils.checkVitalRecordStatus(mtlb.getMotherId(), migrationState);
|
||||
if (motherRecordStatus == Utils.FOUND)
|
||||
csMtlb.setMotherId(mtlb.getMotherId());
|
||||
else if (motherRecordStatus == Utils.UNKNOWN)
|
||||
return;
|
||||
else if (motherRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
CivilStatusMtlbTag tag = null;
|
||||
tag = new CivilStatusMtlbTag();
|
||||
tag.setContent(ErrorCodes.MOTHER_NOT_FOUND);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
} else if (motherRecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
CivilStatusMtlbTag tag = null;
|
||||
tag = new CivilStatusMtlbTag();
|
||||
tag.setKey(CustomErrorCodes.RV4_MOTHER_FAMILY_TREE_RECORD);
|
||||
tag.setContent(mtlb.getMotherId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
}
|
||||
csMtlb.setFirstname(mtlb.getFirstname());
|
||||
csMtlb.setSecondname(mtlb.getSecondname());
|
||||
csMtlb.setThirdname(mtlb.getThirdname());
|
||||
csMtlb.setFourthname(mtlb.getFourthname());
|
||||
csMtlb.setFifthname(mtlb.getFifthname());
|
||||
csMtlb.setReportedFatherName(mtlb.getReportedFatherName());
|
||||
csMtlb.setReportedMotherName(mtlb.getReportedMotherName());
|
||||
csMtlb.setPrimaryCitizenship("191");
|
||||
csMtlb.setTypeOfAcquisition(TypeOfAcquisition.BY_DESCENT);
|
||||
rvFourBirthMtlbUtils.validateBiographic(mtlb);
|
||||
if (!StringUtils.isAllBlank(mtlb.getBirthPlace())) {
|
||||
GeoData location = locationsRepository.findByAreaId(mtlb.getBirthPlace());
|
||||
if (location != null)
|
||||
csMtlb.setBirthPlace(location.getAreaId());
|
||||
else {
|
||||
CivilStatusMtlbTag tag = new CivilStatusMtlbTag();
|
||||
tag.setContent(mtlb.getBirthPlace());
|
||||
tag.setType(Utils.WARNING_TAG_TYPE);
|
||||
tag.setKey(INVALID_BIRTH_PLACE_DATA);
|
||||
tags.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
csMtlb.setBirthdate(mtlb.getBirthdate());
|
||||
csMtlb.setBirthYearUnknown(mtlb.isBirthYearUnknown());
|
||||
csMtlb.setBirthMonthUnknown(mtlb.isBirthMonthUnknown());
|
||||
csMtlb.setBirthDayUnknown(mtlb.isBirthDayUnknown());
|
||||
if (mtlb.getGender() != null)
|
||||
csMtlb.setGender(mtlb.getGender().shortValue());
|
||||
csMtlb.setMaritalStatus(mtlb.getMaritalStatus());
|
||||
|
||||
Occupation occupation = null;
|
||||
if (!StringUtils.isAllBlank(mtlb.getOccupation())) {
|
||||
String legacyOccupation = mtlb.getOccupation().trim();
|
||||
occupation = new Occupation();
|
||||
List<OccupationMetadata> omList = occupationMetadataRepository.findByName(legacyOccupation);
|
||||
if (omList.size() > 0)
|
||||
occupation.setOccupationId(omList.get(0).getId());
|
||||
else {
|
||||
OccupationMetadata om = new OccupationMetadata();
|
||||
om.setName(legacyOccupation);
|
||||
occupationMetadataRepository.insert(om);
|
||||
occupation.setOccupationId(om.getId());
|
||||
}
|
||||
}
|
||||
|
||||
Email email = null;
|
||||
if (!StringUtils.isAllBlank(mtlb.getEmail())) {
|
||||
String legacyEmail = mtlb.getEmail().trim();
|
||||
email = new Email();
|
||||
email.setEmail(legacyEmail);
|
||||
}
|
||||
|
||||
PhoneNumber phoneNumber = null;
|
||||
if (!StringUtils.isAllBlank(mtlb.getPhoneNumber())) {
|
||||
String legacyPhoneNumber = mtlb.getPhoneNumber().trim();
|
||||
phoneNumber = new PhoneNumber();
|
||||
phoneNumber.setPhoneNumber(legacyPhoneNumber);
|
||||
}
|
||||
|
||||
Address address = null;
|
||||
if (!StringUtils.isAllBlank(mtlb.getAddress())) {
|
||||
CivilStatusMtlbTag tag = null;
|
||||
GeoData location =locationsRepository.findByAreaId(mtlb.getAddress());
|
||||
if (location != null) {
|
||||
address = new Address();
|
||||
address.setAddressType(AddressType.RESIDENCY);
|
||||
address.setAreaId(location.getAreaId());
|
||||
}
|
||||
else {
|
||||
tag = new CivilStatusMtlbTag();
|
||||
tag.setContent(mtlb.getBirthPlace());
|
||||
tag.setType(Utils.WARNING_TAG_TYPE);
|
||||
tag.setKey(INVALID_RESIDENCE_ADDRESS_DATA);
|
||||
tags.add(tag);
|
||||
}
|
||||
if (tag != null)
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
if (mtlb.isMultiBirth()) {
|
||||
CivilStatusMtlbTag tag = new CivilStatusMtlbTag();
|
||||
tag.setContent("Multiple Births");
|
||||
tag.setType(Utils.INFO_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
if (mtlb.getFace() != null) {
|
||||
csMtlb.setFace(mtlb.getFace());
|
||||
}
|
||||
|
||||
ArchideMtlbAnnex annex = null;
|
||||
try {
|
||||
annex = ArchideMtlbAnnexUtil.deserialize(mtlb.getAnnex());
|
||||
} catch (JsonProcessingException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (annex.getTags() != null)
|
||||
for (ArchideMtlbAnnexTag tag : annex.getTags()) {
|
||||
CivilStatusMtlbTag vt = new CivilStatusMtlbTag();
|
||||
vt.setContent(tag.getValue());
|
||||
vt.setType(tag.getType());
|
||||
vt.setKey(tag.getName());
|
||||
tags.add(vt);
|
||||
}
|
||||
|
||||
|
||||
List<RvfourBirthMtlbTag> mtlbTagList = rvfourBirthMtlbTagRepository.findByRvfourBirthMtlbId(mtlb.getId());
|
||||
for (RvfourBirthMtlbTag tag : mtlbTagList) {
|
||||
CivilStatusMtlbTag vt = new CivilStatusMtlbTag();
|
||||
vt.setContent(tag.getContent());
|
||||
vt.setType(tag.getType());
|
||||
vt.setKey(tag.getKey());
|
||||
tags.add(vt);
|
||||
}
|
||||
ArrayList<CivilStatusMtlbNote> notes = new ArrayList<>();
|
||||
for (ArchideMtlbAnnexLogEntry note : annex.getNotes()) {
|
||||
CivilStatusMtlbNote vn = new CivilStatusMtlbNote();
|
||||
vn.setAddedBy(note.getAuthor());
|
||||
vn.setContent(note.getContent());
|
||||
vn.setTimestamp(note.getTimestamp());
|
||||
notes.add(vn);
|
||||
}
|
||||
|
||||
ArrayList<CivilStatusMtlbAttachment> attachments = new ArrayList<>();
|
||||
List<RvfourBirthMtlbAttachment> mtlbAttachments = rv4BirthMtlbAttachmentRepository
|
||||
.findByRvfourBirthMtlbId(mtlb.getId());
|
||||
for (RvfourBirthMtlbAttachment mtlbAttachment: mtlbAttachments) {
|
||||
CivilStatusMtlbAttachment attachment = new CivilStatusMtlbAttachment();
|
||||
attachment.setContent(mtlbAttachment.getContent());
|
||||
attachment.setFileName(mtlbAttachment.getFileName());
|
||||
attachment.setDescription(mtlbAttachment.getDescription());
|
||||
attachment.setPreview(mtlbAttachment.getPreview());
|
||||
attachments.add(attachment);
|
||||
}
|
||||
|
||||
try {
|
||||
Long id = civilStatusMtlbRepository.insert(csMtlb);
|
||||
if (occupation != null) {
|
||||
occupation.setCivilStatusMtlbId(id);
|
||||
occupationRepository.insert(occupation);
|
||||
}
|
||||
if (email != null) {
|
||||
email.setCivilStatusMtlbId(id);
|
||||
emailRepository.insert(email);
|
||||
}
|
||||
if (phoneNumber != null) {
|
||||
phoneNumber.setCivilStatusMtlbId(id);
|
||||
phoneNumberRepository.insert(phoneNumber);
|
||||
}
|
||||
if (address != null) {
|
||||
address.setCivilStatusMtlbId(id);
|
||||
addressRepository.insert(address);
|
||||
}
|
||||
for (CivilStatusMtlbTag tag : tags) {
|
||||
tag.setCivilStatusMtlbId(id);
|
||||
civilStatusMtlbTagRepository.insert(tag);
|
||||
}
|
||||
for (CivilStatusMtlbAttachment attachment : attachments) {
|
||||
attachment.setCivilStatusMtlbId(id);
|
||||
civilStatusMtlbAttachmentRepository.insert(attachment);
|
||||
}
|
||||
for (CivilStatusMtlbNote note : notes) {
|
||||
note.setCivilStatusMtlbId(id);
|
||||
civilStatusMtlbNoteRepository.insert(note);
|
||||
}
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createHistoryRecord(RvfourBirthMtlb mtlb) {
|
||||
VitalRecordHistory vr = new VitalRecordHistory();
|
||||
vr.setId(mtlb.getVitalRecordId());
|
||||
vr.setFirstname(mtlb.getFirstname());
|
||||
vr.setSecondname(mtlb.getSecondname());
|
||||
vr.setThirdname(mtlb.getThirdname());
|
||||
vr.setFourthname(mtlb.getFourthname());
|
||||
vr.setFifthname(mtlb.getFifthname());
|
||||
vr.setReportedFatherName(mtlb.getReportedFatherName());
|
||||
vr.setReportedMotherName(mtlb.getReportedMotherName());
|
||||
vr.setFatherId(mtlb.getFatherId());
|
||||
vr.setMotherId(mtlb.getMotherId());
|
||||
if (!StringUtils.isAllBlank(mtlb.getBirthPlace())) {
|
||||
GeoData location = locationsRepository.findByAreaId(mtlb.getBirthPlace());
|
||||
if (location != null)
|
||||
vr.setBirthPlace(location.getAreaId());
|
||||
}
|
||||
vr.setTimestamp(mtlb.getTimestamp());
|
||||
vr.setBirthdate(mtlb.getBirthdate());
|
||||
vr.setBirthYearUnknown(mtlb.isBirthYearUnknown());
|
||||
vr.setBirthMonthUnknown(mtlb.isBirthMonthUnknown());
|
||||
vr.setBirthDayUnknown(mtlb.isBirthDayUnknown());
|
||||
vr.setPrimaryCitizenship("191");
|
||||
vr.setTypeOfAcquisition(TypeOfAcquisition.BY_DESCENT);
|
||||
if (mtlb.getGender() != null)
|
||||
vr.setGender(mtlb.getGender().shortValue());
|
||||
vr.setMaritalStatus(mtlb.getMaritalStatus());
|
||||
vr.setHistoryTimestamp(mtlb.getTimestamp());
|
||||
vitalRecordHistoryRepository.insert(vr);
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
}
|
||||
|
||||
private void createVitalRecord(RvfourBirthMtlb mtlb, GlobalState migrationState) {
|
||||
VitalRecord vr = new VitalRecord();
|
||||
vr.setInactive(false);
|
||||
ArrayList<VitalRecordTag> tags = new ArrayList<VitalRecordTag>();
|
||||
if (mtlb.getFatherId() != null) {
|
||||
int fatherRecordStatus = utils.checkVitalRecordStatus(mtlb.getFatherId(), migrationState);
|
||||
if (fatherRecordStatus == Utils.FOUND)
|
||||
vr.setFatherId(mtlb.getFatherId());
|
||||
else if (fatherRecordStatus == Utils.UNKNOWN || fatherRecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (fatherRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
VitalRecordTag tag = null;
|
||||
tag = new VitalRecordTag();
|
||||
tag.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
tag.setContent(ErrorCodes.FATHER_NOT_FOUND);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
} else if (fatherRecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
VitalRecordTag tag = null;
|
||||
tag = new VitalRecordTag();
|
||||
tag.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
tag.setKey(CustomErrorCodes.RV4_FATHER_FAMILY_TREE_RECORD);
|
||||
tag.setContent(mtlb.getFatherId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
if (mtlb.getMotherId() != null) {
|
||||
int motherRecordStatus = utils.checkVitalRecordStatus(mtlb.getMotherId(), migrationState);
|
||||
if (motherRecordStatus == Utils.FOUND)
|
||||
vr.setMotherId(mtlb.getMotherId());
|
||||
else if (motherRecordStatus == Utils.UNKNOWN)
|
||||
return;
|
||||
else if (motherRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
VitalRecordTag tag = null;
|
||||
tag = new VitalRecordTag();
|
||||
tag.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
tag.setContent(ErrorCodes.MOTHER_NOT_FOUND);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
} else if (motherRecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
VitalRecordTag tag = null;
|
||||
tag = new VitalRecordTag();
|
||||
tag.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
tag.setKey(CustomErrorCodes.RV4_MOTHER_FAMILY_TREE_RECORD);
|
||||
tag.setContent(mtlb.getMotherId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
}
|
||||
vr.setId(mtlb.getVitalRecordId());
|
||||
vr.setFirstname(mtlb.getFirstname());
|
||||
vr.setSecondname(mtlb.getSecondname());
|
||||
vr.setThirdname(mtlb.getThirdname());
|
||||
vr.setFourthname(mtlb.getFourthname());
|
||||
vr.setFifthname(mtlb.getFifthname());
|
||||
vr.setReportedFatherName(mtlb.getReportedFatherName());
|
||||
vr.setReportedMotherName(mtlb.getReportedMotherName());
|
||||
vr.setPrimaryCitizenship("191");
|
||||
vr.setTypeOfAcquisition(TypeOfAcquisition.BY_DESCENT);
|
||||
vr.setTimestamp(mtlb.getTimestamp());
|
||||
rvFourBirthMtlbUtils.validateBiographic(mtlb);
|
||||
if (!StringUtils.isAllBlank(mtlb.getBirthPlace())) {
|
||||
GeoData location = locationsRepository.findByAreaId(mtlb.getBirthPlace());
|
||||
if (location != null)
|
||||
vr.setBirthPlace(location.getAreaId());
|
||||
else {
|
||||
VitalRecordTag tag = new VitalRecordTag();
|
||||
tag.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
tag.setContent(mtlb.getBirthPlace());
|
||||
tag.setType(Utils.WARNING_TAG_TYPE);
|
||||
tag.setKey(INVALID_BIRTH_PLACE_DATA);
|
||||
tags.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
vr.setBirthdate(mtlb.getBirthdate());
|
||||
vr.setBirthTime(mtlb.getBirthtime());
|
||||
vr.setBirthYearUnknown(mtlb.isBirthYearUnknown());
|
||||
vr.setBirthMonthUnknown(mtlb.isBirthMonthUnknown());
|
||||
vr.setBirthDayUnknown(mtlb.isBirthDayUnknown());
|
||||
if (mtlb.getGender() != null)
|
||||
vr.setGender(mtlb.getGender().shortValue());
|
||||
vr.setMaritalStatus(mtlb.getMaritalStatus());
|
||||
|
||||
Occupation occupation = null;
|
||||
if (!StringUtils.isAllBlank(mtlb.getOccupation())) {
|
||||
String legacyOccupation = mtlb.getOccupation().trim();
|
||||
occupation = new Occupation();
|
||||
List<OccupationMetadata> omList = occupationMetadataRepository.findByName(legacyOccupation);
|
||||
if (omList.size() > 0)
|
||||
occupation.setOccupationId(omList.get(0).getId());
|
||||
else {
|
||||
OccupationMetadata om = new OccupationMetadata();
|
||||
om.setName(legacyOccupation);
|
||||
occupationMetadataRepository.insert(om);
|
||||
occupation.setOccupationId(om.getId());
|
||||
}
|
||||
occupation.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
}
|
||||
|
||||
Email email = null;
|
||||
if (!StringUtils.isAllBlank(mtlb.getEmail())) {
|
||||
String legacyEmail = mtlb.getEmail().trim();
|
||||
email = new Email();
|
||||
email.setEmail(legacyEmail);
|
||||
email.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
}
|
||||
|
||||
PhoneNumber phoneNumber = null;
|
||||
if (!StringUtils.isAllBlank(mtlb.getPhoneNumber())) {
|
||||
String legacyPhoneNumber = mtlb.getPhoneNumber().trim();
|
||||
phoneNumber = new PhoneNumber();
|
||||
phoneNumber.setPhoneNumber(legacyPhoneNumber);
|
||||
phoneNumber.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
}
|
||||
|
||||
Address address = null;
|
||||
if (!StringUtils.isAllBlank(mtlb.getAddress())) {
|
||||
VitalRecordTag tag = null;
|
||||
GeoData location =locationsRepository.findByAreaId(mtlb.getAddress());
|
||||
if (location != null) {
|
||||
address = new Address();
|
||||
address.setAddressType(AddressType.RESIDENCY);
|
||||
address.setAreaId(location.getAreaId());
|
||||
address.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
}
|
||||
else {
|
||||
tag = new VitalRecordTag();
|
||||
tag.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
tag.setContent(mtlb.getBirthPlace());
|
||||
tag.setType(Utils.WARNING_TAG_TYPE);
|
||||
tag.setKey(INVALID_RESIDENCE_ADDRESS_DATA);
|
||||
tags.add(tag);
|
||||
}
|
||||
if (tag != null)
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
if (mtlb.isMultiBirth()) {
|
||||
VitalRecordTag tag = new VitalRecordTag();
|
||||
tag.setContent("Multiple Births");
|
||||
tag.setType(Utils.INFO_TAG_TYPE);
|
||||
tag.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
Long faceId = null;
|
||||
if (mtlb.getFace() != null) {
|
||||
Face face = new Face();
|
||||
face.setImage(mtlb.getFace());
|
||||
face.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
faceId = faceRepository.insert(face);
|
||||
}
|
||||
|
||||
ArchideMtlbAnnex annex = null;
|
||||
try {
|
||||
annex = ArchideMtlbAnnexUtil.deserialize(mtlb.getAnnex());
|
||||
} catch (JsonProcessingException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (annex.getTags() != null)
|
||||
for (ArchideMtlbAnnexTag tag : annex.getTags()) {
|
||||
VitalRecordTag vt = new VitalRecordTag();
|
||||
vt.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
vt.setContent(tag.getValue());
|
||||
vt.setType(tag.getType());
|
||||
vt.setKey(tag.getName());
|
||||
tags.add(vt);
|
||||
}
|
||||
|
||||
|
||||
List<RvfourBirthMtlbTag> mtlbTagList = rvfourBirthMtlbTagRepository.findByRvfourBirthMtlbId(mtlb.getId());
|
||||
for (RvfourBirthMtlbTag tag : mtlbTagList) {
|
||||
VitalRecordTag vt = new VitalRecordTag();
|
||||
vt.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
vt.setContent(tag.getContent());
|
||||
vt.setType(tag.getType());
|
||||
vt.setKey(tag.getKey());
|
||||
tags.add(vt);
|
||||
}
|
||||
ArrayList<VitalRecordNote> notes = new ArrayList<>();
|
||||
for (ArchideMtlbAnnexLogEntry note : annex.getNotes()) {
|
||||
VitalRecordNote vn = new VitalRecordNote();
|
||||
vn.setAddedBy(note.getAuthor());
|
||||
vn.setContent(note.getContent());
|
||||
vn.setTimestamp(note.getTimestamp());
|
||||
vn.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
notes.add(vn);
|
||||
}
|
||||
|
||||
ArrayList<VitalRecordMention> mentions = new ArrayList<>();
|
||||
for (ArchideMtlbAnnexLogEntry mention : annex.getMentions()) {
|
||||
VitalRecordMention vm = new VitalRecordMention();
|
||||
vm.setAddedBy(mention.getAuthor());
|
||||
vm.setContent(mention.getContent());
|
||||
vm.setTimestamp(mention.getTimestamp());
|
||||
vm.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
mentions.add(vm);
|
||||
}
|
||||
|
||||
ArrayList<VitalRecordAttachment> attachments = new ArrayList<>();
|
||||
List<RvfourBirthMtlbAttachment> mtlbAttachments = rv4BirthMtlbAttachmentRepository
|
||||
.findByRvfourBirthMtlbId(mtlb.getId());
|
||||
for (RvfourBirthMtlbAttachment mtlbAttachment: mtlbAttachments) {
|
||||
VitalRecordAttachment attachment = new VitalRecordAttachment();
|
||||
attachment.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
attachment.setContent(mtlbAttachment.getContent());
|
||||
attachment.setFileName(mtlbAttachment.getFileName());
|
||||
attachment.setDescription(mtlbAttachment.getDescription());
|
||||
attachment.setPreview(mtlbAttachment.getPreview());
|
||||
attachments.add(attachment);
|
||||
}
|
||||
|
||||
try {
|
||||
vitalRecordRepository.insert(vr);
|
||||
if (occupation != null)
|
||||
occupationRepository.insert(occupation);
|
||||
if (email != null)
|
||||
emailRepository.insert(email);
|
||||
if (phoneNumber != null)
|
||||
phoneNumberRepository.insert(phoneNumber);
|
||||
if (address != null)
|
||||
addressRepository.insert(address);
|
||||
for (VitalRecordTag tag : tags)
|
||||
vitalRecordTagRepository.insert(tag);
|
||||
if (faceId != null) {
|
||||
vitalRecordRepository.setFaceIdById(vr.getId(), faceId);
|
||||
}
|
||||
for (VitalRecordAttachment attachment : attachments)
|
||||
vitalRecordAttachmentRepository.insert(attachment);
|
||||
for (VitalRecordNote note : notes)
|
||||
vitalRecordNoteRepository.insert(note);
|
||||
for (VitalRecordMention mention : mentions)
|
||||
vitalRecordMentionRepository.insert(mention);
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,330 @@
|
||||
package systems.archide.core.workflows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnex;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexLogEntry;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexTag;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexUtil;
|
||||
import systems.archide.core.pojo.CivilStatusMtlb;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbNote;
|
||||
import systems.archide.core.pojo.CivilStatusMtlbTag;
|
||||
import systems.archide.core.pojo.DeathRecord;
|
||||
import systems.archide.core.pojo.DeathRecordNote;
|
||||
import systems.archide.core.pojo.DeathRecordTag;
|
||||
import systems.archide.core.pojo.Face;
|
||||
import systems.archide.core.pojo.GlobalState;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlb;
|
||||
import systems.archide.core.pojo.RvfourDeathMtlb;
|
||||
import systems.archide.core.pojo.RvfourDeathMtlbTag;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.CivilStatusMtlbNoteRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbRepository;
|
||||
import systems.archide.core.repository.CivilStatusMtlbTagRepository;
|
||||
import systems.archide.core.repository.DeathRecordNoteRepository;
|
||||
import systems.archide.core.repository.DeathRecordRepository;
|
||||
import systems.archide.core.repository.DeathRecordTagRepository;
|
||||
import systems.archide.core.repository.FaceRepository;
|
||||
import systems.archide.core.repository.GlobalStateRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourDeathMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourDeathMtlbTagRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
import systems.archide.core.workflows.utils.CustomErrorCodes;
|
||||
import systems.archide.core.workflows.utils.Utils;
|
||||
|
||||
@Component
|
||||
public class RvfourDeathMtlbSubmitted {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RvFourBirthMtlbSubmitted.class);
|
||||
|
||||
@Autowired
|
||||
RvfourDeathMtlbRepository rvfourDeathMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
GlobalStateRepository globalStateRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourDeathMtlbTagRepository rvfourDeathMtlbTagRepository;
|
||||
|
||||
@Autowired
|
||||
DeathRecordNoteRepository deathRecordNoteRepository;
|
||||
|
||||
@Autowired
|
||||
DeathRecordRepository deathRecordRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbRepository rvfourBirthMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
DeathRecordTagRepository deathRecordTagRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbRepository civilStatusMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbTagRepository civilStatusMtlbTagRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbNoteRepository civilStatusMtlbNoteRepository;
|
||||
|
||||
@Autowired
|
||||
FaceRepository faceRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@Autowired
|
||||
Utils utils;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void fromSubmittedStatus() {
|
||||
GlobalState migrationState = globalStateRepository.findByKey("migration");
|
||||
List<RvfourDeathMtlb> mtlbList = queries.getRandomRv4DeathMtlbByMtlbStatus(MtlbStatus.SUBMITTED.getValue());
|
||||
if (mtlbList.size() > 0) {
|
||||
log.info("Read {} newly submitted rv4 death applications", mtlbList.size());
|
||||
for (RvfourDeathMtlb mtlb : mtlbList) {
|
||||
if (mtlb.getVitalRecordId() != null) {
|
||||
switch(mtlb.getMtlbType()) {
|
||||
case RV4_DEATH_RECORD:
|
||||
createDeathRecord(mtlb, migrationState);
|
||||
break;
|
||||
case RV4_DEATH_APPLICATION:
|
||||
createDeathApplication(mtlb, migrationState);
|
||||
break;
|
||||
case RV4_DEATH_RECORD_TRASH:
|
||||
createDeathRecordTrash(mtlb);
|
||||
break;
|
||||
}
|
||||
rvfourDeathMtlbRepository.save(mtlb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createDeathRecordTrash(RvfourDeathMtlb mtlb) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void createDeathApplication(RvfourDeathMtlb mtlb, GlobalState migrationState) {
|
||||
CivilStatusMtlb cMtlb = new CivilStatusMtlb();
|
||||
ArrayList<CivilStatusMtlbTag> tags = new ArrayList<CivilStatusMtlbTag>();
|
||||
ArrayList<CivilStatusMtlbNote> notes = new ArrayList<CivilStatusMtlbNote>();
|
||||
int recordStatus = utils.checkVitalRecordStatus(mtlb.getVitalRecordId(), migrationState);
|
||||
cMtlb.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
cMtlb.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
VitalRecord vr = null;
|
||||
if (recordStatus == Utils.FOUND) {
|
||||
vr = vitalRecordRepository.findById(mtlb.getVitalRecordId());
|
||||
}
|
||||
else if (recordStatus == Utils.UNKNOWN || recordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (recordStatus == Utils.CONFIRMED_MISSING) {
|
||||
CivilStatusMtlbTag tag = null;
|
||||
tag = new CivilStatusMtlbTag();
|
||||
tag.setContent(CustomErrorCodes.VITAL_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.WARNING_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
cMtlb.setVitalRecordId(null);
|
||||
}
|
||||
else if (recordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
CivilStatusMtlbTag tag = null;
|
||||
tag = new CivilStatusMtlbTag();
|
||||
tag.setKey(CustomErrorCodes.RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getVitalRecordId().toString());
|
||||
tag.setType(Utils.WARNING_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
RvfourBirthMtlb rvfourBirthMtlb = rvfourBirthMtlbRepository.findByVitalRecordId(mtlb.getVitalRecordId());
|
||||
if (rvfourBirthMtlb != null) {
|
||||
cMtlb.setFirstname(rvfourBirthMtlb.getFirstname());
|
||||
cMtlb.setSecondname(rvfourBirthMtlb.getSecondname());
|
||||
cMtlb.setThirdname(rvfourBirthMtlb.getThirdname());
|
||||
cMtlb.setFourthname(rvfourBirthMtlb.getFourthname());
|
||||
cMtlb.setGender(rvfourBirthMtlb.getGender());
|
||||
cMtlb.setMaritalStatus(rvfourBirthMtlb.getMaritalStatus());
|
||||
cMtlb.setReportedFatherName(rvfourBirthMtlb.getReportedFatherName());
|
||||
cMtlb.setReportedMotherName(rvfourBirthMtlb.getReportedMotherName());
|
||||
}
|
||||
cMtlb.setVitalRecordId(null);
|
||||
}
|
||||
if (vr != null) {
|
||||
cMtlb.setFirstname(vr.getFirstname());
|
||||
cMtlb.setSecondname(vr.getSecondname());
|
||||
cMtlb.setThirdname(vr.getThirdname());
|
||||
cMtlb.setFourthname(vr.getFourthname());
|
||||
cMtlb.setGender(vr.getGender());
|
||||
cMtlb.setMaritalStatus(vr.getMaritalStatus());
|
||||
if (vr.getFaceId() != null) {
|
||||
Face face = faceRepository.findById(vr.getFaceId());
|
||||
cMtlb.setFace(face.getImage());
|
||||
}
|
||||
cMtlb.setReportedFatherName(vr.getReportedFatherName());
|
||||
cMtlb.setReportedMotherName(vr.getReportedMotherName());
|
||||
}
|
||||
cMtlb.setMtlbType(MtlbType.DEATH_REGISTRATION);
|
||||
cMtlb.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
cMtlb.setTimeOfDeath(mtlb.getTimeOfDeath());
|
||||
cMtlb.setDateOfDeath(mtlb.getDateOfDeath());
|
||||
cMtlb.setDeclarantId(mtlb.getDeclarantId());
|
||||
cMtlb.setDeathPlace(mtlb.getDeathLocation());
|
||||
Long id = civilStatusMtlbRepository.insert(cMtlb);
|
||||
if (id != null)
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
ArchideMtlbAnnex annex = null;
|
||||
try {
|
||||
annex = ArchideMtlbAnnexUtil.deserialize(mtlb.getAnnex());
|
||||
} catch (JsonProcessingException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (annex.getTags() != null)
|
||||
for (ArchideMtlbAnnexTag tag : annex.getTags()) {
|
||||
CivilStatusMtlbTag cTag = new CivilStatusMtlbTag();
|
||||
cTag.setCivilStatusMtlbId(id);
|
||||
cTag.setContent(tag.getValue());
|
||||
cTag.setType(tag.getType());
|
||||
cTag.setKey(tag.getName());
|
||||
tags.add(cTag);
|
||||
}
|
||||
for (CivilStatusMtlbTag tag: tags) {
|
||||
tag.setCivilStatusMtlbId(id);
|
||||
civilStatusMtlbTagRepository.insert(tag);
|
||||
}
|
||||
if (annex.getNotes() != null)
|
||||
for (ArchideMtlbAnnexLogEntry note : annex.getNotes()) {
|
||||
CivilStatusMtlbNote cNote = new CivilStatusMtlbNote();
|
||||
cNote.setContent(note.getContent());
|
||||
cNote.setAddedBy(note.getAuthor());
|
||||
cNote.setTimestamp(note.getTimestamp());
|
||||
notes.add(cNote);
|
||||
}
|
||||
for (CivilStatusMtlbNote note: notes) {
|
||||
note.setCivilStatusMtlbId(id);
|
||||
civilStatusMtlbNoteRepository.insert(note);
|
||||
}
|
||||
}
|
||||
|
||||
private void createDeathRecord(RvfourDeathMtlb mtlb, GlobalState migrationState) {
|
||||
DeathRecord dr = new DeathRecord();
|
||||
ArrayList<DeathRecordTag> tags = new ArrayList<DeathRecordTag>();
|
||||
int recordStatus = utils.checkVitalRecordStatus(mtlb.getVitalRecordId(), migrationState);
|
||||
dr.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
VitalRecord vr = null;
|
||||
if (recordStatus == Utils.FOUND) {
|
||||
vr = vitalRecordRepository.findById(mtlb.getVitalRecordId());
|
||||
}
|
||||
else if (recordStatus == Utils.UNKNOWN || recordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (recordStatus == Utils.CONFIRMED_MISSING) {
|
||||
DeathRecordTag tag = null;
|
||||
tag = new DeathRecordTag();
|
||||
tag.setDeathRecordId(mtlb.getDeathRecordId());
|
||||
tag.setContent(CustomErrorCodes.VITAL_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.WARNING_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
dr.setVitalRecordId(null);
|
||||
}
|
||||
else if (recordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
DeathRecordTag tag = null;
|
||||
tag = new DeathRecordTag();
|
||||
tag.setDeathRecordId(mtlb.getDeathRecordId());
|
||||
tag.setKey(CustomErrorCodes.RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getVitalRecordId().toString());
|
||||
tag.setType(Utils.WARNING_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
RvfourBirthMtlb rvfourBirthMtlb = rvfourBirthMtlbRepository.findByVitalRecordId(mtlb.getVitalRecordId());
|
||||
if (rvfourBirthMtlb != null) {
|
||||
dr.setFirstname(rvfourBirthMtlb.getFirstname());
|
||||
dr.setSecondname(rvfourBirthMtlb.getSecondname());
|
||||
dr.setThirdname(rvfourBirthMtlb.getThirdname());
|
||||
dr.setFourthname(rvfourBirthMtlb.getFourthname());
|
||||
dr.setGender(rvfourBirthMtlb.getGender());
|
||||
dr.setMaritalStatus(rvfourBirthMtlb.getMaritalStatus());
|
||||
dr.setReportedFatherName(rvfourBirthMtlb.getReportedFatherName());
|
||||
dr.setReportedMotherName(rvfourBirthMtlb.getReportedMotherName());
|
||||
}
|
||||
dr.setVitalRecordId(null);
|
||||
}
|
||||
if (vr != null) {
|
||||
dr.setFirstname(vr.getFirstname());
|
||||
dr.setSecondname(vr.getSecondname());
|
||||
dr.setThirdname(vr.getThirdname());
|
||||
dr.setFourthname(vr.getFourthname());
|
||||
dr.setGender(vr.getGender());
|
||||
dr.setMaritalStatus(vr.getMaritalStatus());
|
||||
dr.setFaceId(vr.getFaceId());
|
||||
dr.setReportedFatherName(vr.getReportedFatherName());
|
||||
dr.setReportedMotherName(vr.getReportedMotherName());
|
||||
}
|
||||
dr.setId(mtlb.getDeathRecordId());
|
||||
dr.setTimeOfDeath(mtlb.getTimeOfDeath());
|
||||
dr.setDateOfDeath(mtlb.getDateOfDeath());
|
||||
dr.setDraft(false);
|
||||
dr.setDeathLocation(mtlb.getDeathLocation());
|
||||
dr.setDeathPlace(mtlb.getDeathLocation());
|
||||
ArchideMtlbAnnex annex = null;
|
||||
try {
|
||||
annex = ArchideMtlbAnnexUtil.deserialize(mtlb.getAnnex());
|
||||
} catch (JsonProcessingException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (annex.getTags() != null)
|
||||
for (ArchideMtlbAnnexTag tag : annex.getTags()) {
|
||||
DeathRecordTag drTag = new DeathRecordTag();
|
||||
drTag.setDeathRecordId(mtlb.getDeathRecordId());
|
||||
drTag.setContent(tag.getValue());
|
||||
drTag.setType(tag.getType());
|
||||
drTag.setKey(tag.getName());
|
||||
tags.add(drTag);
|
||||
}
|
||||
|
||||
|
||||
List<RvfourDeathMtlbTag> mtlbTagList = rvfourDeathMtlbTagRepository.findByRvfourDeathMtlbId(mtlb.getId());
|
||||
for (RvfourDeathMtlbTag tag : mtlbTagList) {
|
||||
DeathRecordTag vt = new DeathRecordTag();
|
||||
vt.setDeathRecordId(mtlb.getDeathRecordId());
|
||||
vt.setContent(tag.getContent());
|
||||
vt.setType(tag.getType());
|
||||
vt.setKey(tag.getKey());
|
||||
tags.add(vt);
|
||||
}
|
||||
ArrayList<DeathRecordNote> notes = new ArrayList<>();
|
||||
for (ArchideMtlbAnnexLogEntry note : annex.getNotes()) {
|
||||
DeathRecordNote vn = new DeathRecordNote();
|
||||
vn.setAddedBy(note.getAuthor());
|
||||
vn.setContent(note.getContent());
|
||||
vn.setTimestamp(note.getTimestamp());
|
||||
vn.setDeathRecordId(mtlb.getDeathRecordId());
|
||||
notes.add(vn);
|
||||
}
|
||||
try {
|
||||
for (DeathRecordTag tag : tags)
|
||||
deathRecordTagRepository.insert(tag);
|
||||
Long id = deathRecordRepository.insert(dr);
|
||||
if (id != null)
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
for (DeathRecordNote note : notes)
|
||||
deathRecordNoteRepository.insert(note);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
package systems.archide.core.workflows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnex;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexLogEntry;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexTag;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexUtil;
|
||||
import systems.archide.core.pojo.GlobalState;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.pojo.RvfourDivorceMtlb;
|
||||
import systems.archide.core.pojo.UnionMtlb;
|
||||
import systems.archide.core.pojo.UnionMtlbTag;
|
||||
import systems.archide.core.pojo.UnionRecord;
|
||||
import systems.archide.core.pojo.UnionRecordMention;
|
||||
import systems.archide.core.pojo.UnionRecordTag;
|
||||
import systems.archide.core.repository.GlobalStateRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.RvfourDivorceMtlbRepository;
|
||||
import systems.archide.core.repository.UnionMtlbRepository;
|
||||
import systems.archide.core.repository.UnionMtlbTagRepository;
|
||||
import systems.archide.core.repository.UnionRecordMentionRepository;
|
||||
import systems.archide.core.repository.UnionRecordRepository;
|
||||
import systems.archide.core.repository.UnionRecordTagRepository;
|
||||
import systems.archide.core.workflows.utils.CustomErrorCodes;
|
||||
import systems.archide.core.workflows.utils.Utils;
|
||||
|
||||
@Component
|
||||
public class RvfourDivorceMtlbSubmitted {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RvfourMarriageMtlbSubmitted.class);
|
||||
|
||||
@Autowired
|
||||
GlobalStateRepository globalStateRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourDivorceMtlbRepository rvfourDivorceMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
UnionRecordRepository unionRecordRepository;
|
||||
|
||||
@Autowired
|
||||
UnionRecordMentionRepository unionRecordMentionRepository;
|
||||
|
||||
@Autowired
|
||||
UnionRecordTagRepository unionRecordTagRepository;
|
||||
|
||||
@Autowired
|
||||
UnionMtlbRepository unionMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
UnionMtlbTagRepository unionMtlbTagRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@Autowired
|
||||
Utils utils;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void fromSubmittedStatus() {
|
||||
GlobalState migrationState = globalStateRepository.findByKey("migration");
|
||||
List<RvfourDivorceMtlb> mtlbList = queries.getRandomRv4DivorceMtlbByMtlbStatus(MtlbStatus.SUBMITTED.getValue());
|
||||
if (mtlbList.size() > 0) {
|
||||
log.info("Read {} newly submitted rv4 divorce applications", mtlbList.size());
|
||||
for (RvfourDivorceMtlb mtlb : mtlbList) {
|
||||
switch (mtlb.getMtlbType()) {
|
||||
case RV4_UNION_RECORD:
|
||||
createUnionRecord(mtlb, migrationState);
|
||||
break;
|
||||
case RV4_DIVORCE_APPLICATION:
|
||||
createDivorceApplication(mtlb, migrationState);
|
||||
break;
|
||||
case RV4_UNION_RECORD_TRASH:
|
||||
createUnionRecordTrash(mtlb);
|
||||
break;
|
||||
}
|
||||
rvfourDivorceMtlbRepository.save(mtlb);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createUnionRecordTrash(RvfourDivorceMtlb mtlb) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void createDivorceApplication(RvfourDivorceMtlb mtlb, GlobalState migrationState) {
|
||||
UnionMtlb um = new UnionMtlb();
|
||||
ArrayList<UnionMtlbTag> tags = new ArrayList<UnionMtlbTag>();
|
||||
um.setDraft(false);
|
||||
um.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
um.setMtlbType(MtlbType.DIVORCE);
|
||||
int unionRecordStatus = utils.checkVitalRecordStatus(mtlb.getUnionRecordId(), migrationState);
|
||||
UnionRecord ur = null;
|
||||
if (unionRecordStatus == Utils.FOUND)
|
||||
ur = unionRecordRepository.findById(mtlb.getUnionRecordId());
|
||||
else if (unionRecordStatus == Utils.UNKNOWN || unionRecordStatus == Utils.FOUND_BUT_UNION_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (unionRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setContent(CustomErrorCodes.UNION_RECORD_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
um.setDateOfEffect(mtlb.getDateOfEffect());
|
||||
um.setDateOfOrder(mtlb.getDateOfOrder());
|
||||
if (ur != null) {
|
||||
um.setPartner1VitalRecordId(ur.getPartner1VitalRecordId());
|
||||
um.setPartner2VitalRecordId(ur.getPartner2VitalRecordId());
|
||||
um.setPartner1Firstname(ur.getPartner1Firstname());
|
||||
um.setPartner2Firstname(ur.getPartner2Firstname());
|
||||
um.setPartner1Surname(ur.getPartner1Surname());
|
||||
um.setPartner2Surname(ur.getPartner2Surname());
|
||||
}
|
||||
ArchideMtlbAnnex annex = null;
|
||||
try {
|
||||
if (mtlb.getAnnex() != null)
|
||||
annex = ArchideMtlbAnnexUtil.deserialize(mtlb.getAnnex());
|
||||
} catch (JsonProcessingException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (annex != null) {
|
||||
for (ArchideMtlbAnnexTag tag : annex.getTags()) {
|
||||
UnionMtlbTag umTag = new UnionMtlbTag();
|
||||
umTag.setContent(tag.getValue());
|
||||
umTag.setType(tag.getType());
|
||||
umTag.setKey(tag.getName());
|
||||
tags.add(umTag);
|
||||
}
|
||||
if (annex.getMentions() != null)
|
||||
for (ArchideMtlbAnnexLogEntry mention : annex.getMentions()) {
|
||||
if ("Annulment Order".equals(mention.getAuthor()))
|
||||
um.setAnnullmentOrder(mention.getContent());
|
||||
}
|
||||
}
|
||||
try {
|
||||
Long id = unionMtlbRepository.insert(um);
|
||||
for (UnionMtlbTag tag : tags) {
|
||||
tag.setUnionMtlbId(id);
|
||||
unionMtlbTagRepository.insert(tag);
|
||||
}
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createUnionRecord(RvfourDivorceMtlb mtlb, GlobalState migrationState) {
|
||||
ArrayList<UnionRecordTag> tags = new ArrayList<UnionRecordTag>();
|
||||
int unionRecordStatus = utils.checkVitalRecordStatus(mtlb.getUnionRecordId(), migrationState);
|
||||
UnionRecord ur = null;
|
||||
if (unionRecordStatus == Utils.FOUND)
|
||||
ur = unionRecordRepository.findById(mtlb.getUnionRecordId());
|
||||
else if (unionRecordStatus == Utils.UNKNOWN || unionRecordStatus == Utils.FOUND_BUT_UNION_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (unionRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
ur = new UnionRecord();
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getUnionRecordId());
|
||||
tag.setContent(CustomErrorCodes.UNION_RECORD_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
ur.setId(mtlb.getUnionRecordId());
|
||||
ur.setDateOfEffect(mtlb.getDateOfEffect());
|
||||
ur.setDateOfOrder(mtlb.getDateOfOrder());
|
||||
}
|
||||
ArchideMtlbAnnex annex = null;
|
||||
ArrayList<UnionRecordMention> mentions = new ArrayList<>();
|
||||
if (mtlb.getAnnex() != null)
|
||||
try {
|
||||
annex = ArchideMtlbAnnexUtil.deserialize(mtlb.getAnnex());
|
||||
} catch (JsonProcessingException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (annex != null) {
|
||||
if (annex.getTags() != null)
|
||||
for (ArchideMtlbAnnexTag tag : annex.getTags()) {
|
||||
UnionRecordTag urTag = new UnionRecordTag();
|
||||
urTag.setUnionRecordId(mtlb.getUnionRecordId());
|
||||
urTag.setContent(tag.getValue());
|
||||
urTag.setType(tag.getType());
|
||||
urTag.setKey(tag.getName());
|
||||
tags.add(urTag);
|
||||
}
|
||||
for (ArchideMtlbAnnexLogEntry mention : annex.getMentions()) {
|
||||
UnionRecordMention vm = new UnionRecordMention();
|
||||
vm.setAddedBy(mention.getAuthor());
|
||||
vm.setContent(mention.getContent());
|
||||
vm.setTimestamp(mention.getTimestamp());
|
||||
vm.setUnionRecordId(mtlb.getUnionRecordId());
|
||||
mentions.add(vm);
|
||||
if ("Annulment Order".equals(mention.getAuthor()))
|
||||
ur.setAnnulmentOrder(mention.getContent());
|
||||
}
|
||||
}
|
||||
try {
|
||||
unionRecordRepository.save(ur);
|
||||
for (UnionRecordMention mention : mentions)
|
||||
unionRecordMentionRepository.insert(mention);
|
||||
for (UnionRecordTag tag : tags)
|
||||
unionRecordTagRepository.insert(tag);
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package systems.archide.core.workflows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.DeathRecordNote;
|
||||
import systems.archide.core.pojo.DeathRecordTag;
|
||||
import systems.archide.core.pojo.DocumentType;
|
||||
import systems.archide.core.pojo.Face;
|
||||
import systems.archide.core.pojo.GlobalState;
|
||||
import systems.archide.core.pojo.IssuedDocuments;
|
||||
import systems.archide.core.pojo.IssuedDocumentsTag;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlb;
|
||||
import systems.archide.core.pojo.RvfourIdCardMtlb;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.FaceRepository;
|
||||
import systems.archide.core.repository.GlobalStateRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.IssuedDocumentsRepository;
|
||||
import systems.archide.core.repository.IssuedDocumentsTagRepository;
|
||||
import systems.archide.core.repository.RvfourIdCardMtlbRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
import systems.archide.core.workflows.utils.CustomErrorCodes;
|
||||
import systems.archide.core.workflows.utils.Utils;
|
||||
|
||||
@Component
|
||||
public class RvfourIdCardMtlbSubmitted {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RvfourIdCardMtlbSubmitted.class);
|
||||
|
||||
@Autowired
|
||||
GlobalStateRepository globalStateRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourIdCardMtlbRepository rvfourIdCardMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
IssuedDocumentsRepository issuedDocumentsRepository;
|
||||
|
||||
@Autowired
|
||||
IssuedDocumentsTagRepository issuedDocumentsTagRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
FaceRepository faceRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@Autowired
|
||||
Utils utils;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void fromSubmittedStatus() {
|
||||
GlobalState migrationState = globalStateRepository.findByKey("migration");
|
||||
List<RvfourIdCardMtlb> mtlbList = queries.getRandomRv4IdCardMtlbByMtlbStatus(MtlbStatus.SUBMITTED.getValue());
|
||||
if (mtlbList.size() > 0) {
|
||||
log.info("Read {} newly submitted rv4 ID Card applications", mtlbList.size());
|
||||
for (RvfourIdCardMtlb mtlb : mtlbList) {
|
||||
createIssuedDocument(mtlb, migrationState);
|
||||
rvfourIdCardMtlbRepository.save(mtlb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createIssuedDocument(RvfourIdCardMtlb mtlb, GlobalState migrationState) {
|
||||
IssuedDocuments document = new IssuedDocuments();
|
||||
ArrayList<IssuedDocumentsTag> tags = new ArrayList<IssuedDocumentsTag>();
|
||||
int personRecordStatus = utils.checkVitalRecordStatus(mtlb.getVitalRecordId(), migrationState);
|
||||
if (personRecordStatus == Utils.UNKNOWN || personRecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (personRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
IssuedDocumentsTag tag = null;
|
||||
tag = new IssuedDocumentsTag();
|
||||
tag.setContent(CustomErrorCodes.VITAL_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
else if (personRecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
IssuedDocumentsTag tag = null;
|
||||
tag = new IssuedDocumentsTag();
|
||||
tag.setKey(CustomErrorCodes.RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getVitalRecordId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
if (personRecordStatus == Utils.FOUND) {
|
||||
List<Face> faceList = faceRepository.findByVitalRecordId(mtlb.getVitalRecordId());
|
||||
VitalRecord vr = vitalRecordRepository.findById(mtlb.getVitalRecordId());
|
||||
if (!faceList.isEmpty())
|
||||
document.setFace(faceList.get(faceList.size() - 1).getImage());
|
||||
else {
|
||||
IssuedDocumentsTag tag = null;
|
||||
tag = new IssuedDocumentsTag();
|
||||
tag.setContent(CustomErrorCodes.NO_PICTURE_FOUND);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
String fullName="";
|
||||
if (!StringUtils.isAllBlank(vr.getFirstname()))
|
||||
fullName = vr.getFirstname();
|
||||
if (!StringUtils.isAllBlank(vr.getSecondname()))
|
||||
fullName = fullName.concat(" " + vr.getSecondname());
|
||||
if (!StringUtils.isAllBlank(vr.getThirdname()))
|
||||
fullName = fullName.concat(" " + vr.getThirdname());
|
||||
if (!StringUtils.isAllBlank(vr.getFourthname()))
|
||||
fullName = fullName.concat(" " + vr.getFourthname());
|
||||
document.setFullName(fullName);
|
||||
}
|
||||
document.setCancelledDate(mtlb.getCancelledDate());
|
||||
document.setCancelledReason(mtlb.getCancelledReason());
|
||||
document.setDocumentId(mtlb.getIdCardNumber());
|
||||
document.setDocumentType(DocumentType.ID_CARD);
|
||||
document.setExpires(mtlb.getExpires());
|
||||
document.setIssuedDate(mtlb.getIssuedDate());
|
||||
document.setVitalRecordId(mtlb.getVitalRecordId());
|
||||
|
||||
try {
|
||||
Long id = issuedDocumentsRepository.insert(document);
|
||||
for (IssuedDocumentsTag tag : tags) {
|
||||
tag.setIssuedDocumentsId(id);
|
||||
issuedDocumentsTagRepository.insert(tag);
|
||||
}
|
||||
if (personRecordStatus == Utils.FOUND) {
|
||||
VitalRecord vitalRecord = vitalRecordRepository.findById(mtlb.getVitalRecordId());
|
||||
vitalRecord.setCardId(id);
|
||||
vitalRecordRepository.save(vitalRecord);
|
||||
}
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,440 @@
|
||||
package systems.archide.core.workflows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnex;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexLogEntry;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexTag;
|
||||
import systems.archide.core.pojo.ArchideMtlbAnnexUtil;
|
||||
import systems.archide.core.pojo.GlobalState;
|
||||
import systems.archide.core.pojo.MtlbStatus;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlb;
|
||||
import systems.archide.core.pojo.RvfourMarriageMtlb;
|
||||
import systems.archide.core.pojo.UnionMtlb;
|
||||
import systems.archide.core.pojo.UnionMtlbTag;
|
||||
import systems.archide.core.pojo.UnionRecord;
|
||||
import systems.archide.core.pojo.UnionRecordMention;
|
||||
import systems.archide.core.pojo.UnionRecordTag;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.GlobalStateRepository;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourMarriageMtlbRepository;
|
||||
import systems.archide.core.repository.UnionMtlbRepository;
|
||||
import systems.archide.core.repository.UnionMtlbTagRepository;
|
||||
import systems.archide.core.repository.UnionRecordMentionRepository;
|
||||
import systems.archide.core.repository.UnionRecordRepository;
|
||||
import systems.archide.core.repository.UnionRecordTagRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
import systems.archide.core.workflows.utils.CustomErrorCodes;
|
||||
import systems.archide.core.workflows.utils.Utils;
|
||||
|
||||
@Component
|
||||
public class RvfourMarriageMtlbSubmitted {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RvfourMarriageMtlbSubmitted.class);
|
||||
|
||||
@Autowired
|
||||
GlobalStateRepository globalStateRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourMarriageMtlbRepository rvfourMarriageMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
UnionRecordTagRepository unionRecordTagRepository;
|
||||
|
||||
@Autowired
|
||||
UnionRecordRepository unionRecordRepository;
|
||||
|
||||
@Autowired
|
||||
UnionRecordMentionRepository unionRecordMentionRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbRepository rvfourBirthMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
UnionMtlbRepository unionMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
UnionMtlbTagRepository unionMtlbTagRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries queries;
|
||||
|
||||
@Autowired
|
||||
Utils utils;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void fromSubmittedStatus() {
|
||||
GlobalState migrationState = globalStateRepository.findByKey("migration");
|
||||
List<RvfourMarriageMtlb> mtlbList = queries.getRandomRv4MarriageMtlbByMtlbStatus(MtlbStatus.SUBMITTED.getValue());
|
||||
if (mtlbList.size() > 0) {
|
||||
log.info("Read {} newly submitted rv4 marriage applications", mtlbList.size());
|
||||
for (RvfourMarriageMtlb mtlb : mtlbList) {
|
||||
switch (mtlb.getMtlbType()) {
|
||||
case RV4_UNION_RECORD:
|
||||
createUnionRecord(mtlb, migrationState);
|
||||
break;
|
||||
case RV4_MARRIAGE_APPLICATION:
|
||||
createMarriageApplication(mtlb, migrationState);
|
||||
break;
|
||||
case RV4_UNION_RECORD_TRASH:
|
||||
createUnionRecordTrash(mtlb);
|
||||
break;
|
||||
}
|
||||
rvfourMarriageMtlbRepository.save(mtlb);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createUnionRecordTrash(RvfourMarriageMtlb mtlb) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void createMarriageApplication(RvfourMarriageMtlb mtlb, GlobalState migrationState) {
|
||||
UnionMtlb um = new UnionMtlb();
|
||||
ArrayList<UnionMtlbTag> tags = new ArrayList<UnionMtlbTag>();
|
||||
um.setDraft(false);
|
||||
um.setMtlbStatus(MtlbStatus.SUBMITTED);
|
||||
um.setMtlbType(MtlbType.MARRIAGE);
|
||||
int hrecordStatus = utils.checkVitalRecordStatus(mtlb.getHusbandId(), migrationState);
|
||||
VitalRecord hvr = null;
|
||||
if (hrecordStatus == Utils.FOUND) {
|
||||
hvr = vitalRecordRepository.findById(mtlb.getHusbandId());
|
||||
um.setPartner1Firstname(hvr.getFirstname());
|
||||
um.setPartner1Surname(hvr.getFourthname());
|
||||
}
|
||||
else if (hrecordStatus == Utils.UNKNOWN || hrecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (hrecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setContent(CustomErrorCodes.HUSBAND_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
else if (hrecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setKey(CustomErrorCodes.HUSBAND_RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getHusbandId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
RvfourBirthMtlb rvfourBirthMtlb = rvfourBirthMtlbRepository.findByVitalRecordId(mtlb.getHusbandId());
|
||||
if (rvfourBirthMtlb != null) {
|
||||
um.setPartner1Firstname(rvfourBirthMtlb.getFirstname());
|
||||
um.setPartner1Surname(rvfourBirthMtlb.getFourthname());
|
||||
}
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
int wifeRecordStatus = utils.checkVitalRecordStatus(mtlb.getWifeId(), migrationState);
|
||||
VitalRecord wvr = null;
|
||||
if (wifeRecordStatus == Utils.FOUND) {
|
||||
wvr = vitalRecordRepository.findById(mtlb.getWifeId());
|
||||
um.setPartner2Firstname(wvr.getFirstname());
|
||||
um.setPartner2Surname(wvr.getFourthname());
|
||||
}
|
||||
else if (wifeRecordStatus == Utils.UNKNOWN || wifeRecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (wifeRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setContent(CustomErrorCodes.WIFE_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
else if (wifeRecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setKey(CustomErrorCodes.Wife_RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getWifeId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
RvfourBirthMtlb rvfourBirthMtlb = rvfourBirthMtlbRepository.findByVitalRecordId(mtlb.getWifeId());
|
||||
if (rvfourBirthMtlb != null) {
|
||||
um.setPartner2Firstname(rvfourBirthMtlb.getFirstname());
|
||||
um.setPartner2Surname(rvfourBirthMtlb.getFourthname());
|
||||
}
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
int witness1RecordStatus = utils.checkVitalRecordStatus(mtlb.getWitness1Id(), migrationState);
|
||||
if (witness1RecordStatus == Utils.UNKNOWN || witness1RecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (witness1RecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setContent(CustomErrorCodes.WITNESS1_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
else if (witness1RecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setKey(CustomErrorCodes.WITNESS1_RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getWitness1Id().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
int witness2RecordStatus = utils.checkVitalRecordStatus(mtlb.getWitness2Id(), migrationState);
|
||||
if (witness2RecordStatus == Utils.UNKNOWN || witness2RecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (witness2RecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setContent(CustomErrorCodes.WITNESS2_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
else if (witness2RecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
UnionMtlbTag tag = null;
|
||||
tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setKey(CustomErrorCodes.WITNESS2_RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getWitness2Id().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
um.setId(mtlb.getId());
|
||||
um.setAddress(mtlb.getMarriageLocation());
|
||||
um.setPlace(mtlb.getMarriagePlace());
|
||||
um.setPartner1VitalRecordId(mtlb.getHusbandId());
|
||||
um.setPartner2VitalRecordId(mtlb.getWifeId());
|
||||
um.setDeclaredDate(mtlb.getDateOfMarriage());
|
||||
um.setWitness1VitalRecordId(mtlb.getWitness1Id());
|
||||
um.setWitness2VitalRecordId(mtlb.getWitness2Id());
|
||||
um.setRites(mtlb.getMarriageRites());
|
||||
um.setTimeOfMarriage(mtlb.getTimeOfMarriage());
|
||||
if (hvr != null && wvr != null) {
|
||||
if (hvr.getGender() == 2 && wvr.getGender() == 1) {
|
||||
um.setPartner1VitalRecordId(wvr.getId());
|
||||
um.setPartner2VitalRecordId(hvr.getId());
|
||||
} else if (hvr.getGender() == wvr.getGender()) {
|
||||
UnionMtlbTag tag = new UnionMtlbTag();
|
||||
tag.setUnionMtlbId(mtlb.getId());
|
||||
tag.setContent(hvr.getId() + " : " + wvr.getId());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tag.setKey(CustomErrorCodes.SAME_SEX_MARRIAGE);
|
||||
tags.add(tag);
|
||||
um.setMtlbStatus(MtlbStatus.MANUAL_CHECK);
|
||||
}
|
||||
}
|
||||
ArchideMtlbAnnex annex = null;
|
||||
try {
|
||||
annex = ArchideMtlbAnnexUtil.deserialize(mtlb.getAnnex());
|
||||
} catch (JsonProcessingException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (annex.getTags() != null)
|
||||
for (ArchideMtlbAnnexTag tag : annex.getTags()) {
|
||||
UnionMtlbTag umTag = new UnionMtlbTag();
|
||||
umTag.setUnionMtlbId(mtlb.getId());
|
||||
umTag.setContent(tag.getValue());
|
||||
umTag.setType(tag.getType());
|
||||
umTag.setKey(tag.getName());
|
||||
tags.add(umTag);
|
||||
}
|
||||
try {
|
||||
unionMtlbRepository.insert(um);
|
||||
for (UnionMtlbTag tag : tags)
|
||||
unionMtlbTagRepository.insert(tag);
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createUnionRecord(RvfourMarriageMtlb mtlb, GlobalState migrationState) {
|
||||
UnionRecord ur = new UnionRecord();
|
||||
ArrayList<UnionRecordTag> tags = new ArrayList<UnionRecordTag>();
|
||||
|
||||
int hrecordStatus = utils.checkVitalRecordStatus(mtlb.getHusbandId(), migrationState);
|
||||
VitalRecord hvr = null;
|
||||
if (hrecordStatus == Utils.FOUND) {
|
||||
hvr = vitalRecordRepository.findById(mtlb.getHusbandId());
|
||||
ur.setPartner1Firstname(hvr.getFirstname());
|
||||
ur.setPartner1Surname(hvr.getFourthname());
|
||||
}
|
||||
else if (hrecordStatus == Utils.UNKNOWN || hrecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (hrecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getId());
|
||||
tag.setContent(CustomErrorCodes.HUSBAND_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
else if (hrecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getId());
|
||||
tag.setKey(CustomErrorCodes.HUSBAND_RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getHusbandId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
RvfourBirthMtlb rvfourBirthMtlb = rvfourBirthMtlbRepository.findByVitalRecordId(mtlb.getHusbandId());
|
||||
if (rvfourBirthMtlb != null) {
|
||||
ur.setPartner1Firstname(rvfourBirthMtlb.getFirstname());
|
||||
ur.setPartner1Surname(rvfourBirthMtlb.getFourthname());
|
||||
}
|
||||
}
|
||||
int wifeRecordStatus = utils.checkVitalRecordStatus(mtlb.getWifeId(), migrationState);
|
||||
VitalRecord wvr = null;
|
||||
if (wifeRecordStatus == Utils.FOUND) {
|
||||
wvr = vitalRecordRepository.findById(mtlb.getWifeId());
|
||||
ur.setPartner2Firstname(wvr.getFirstname());
|
||||
ur.setPartner2Surname(wvr.getFourthname());
|
||||
}
|
||||
else if (wifeRecordStatus == Utils.UNKNOWN || wifeRecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (wifeRecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getId());
|
||||
tag.setContent(CustomErrorCodes.WIFE_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
else if (wifeRecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getId());
|
||||
tag.setKey(CustomErrorCodes.Wife_RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getWifeId().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
RvfourBirthMtlb rvfourBirthMtlb = rvfourBirthMtlbRepository.findByVitalRecordId(mtlb.getWifeId());
|
||||
if (rvfourBirthMtlb != null) {
|
||||
ur.setPartner2Firstname(rvfourBirthMtlb.getFirstname());
|
||||
ur.setPartner2Surname(rvfourBirthMtlb.getFourthname());
|
||||
}
|
||||
}
|
||||
int witness1RecordStatus = utils.checkVitalRecordStatus(mtlb.getWitness1Id(), migrationState);
|
||||
if (witness1RecordStatus == Utils.UNKNOWN || witness1RecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (witness1RecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getId());
|
||||
tag.setContent(CustomErrorCodes.WITNESS1_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
else if (witness1RecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getId());
|
||||
tag.setKey(CustomErrorCodes.WITNESS1_RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getWitness1Id().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
int witness2RecordStatus = utils.checkVitalRecordStatus(mtlb.getWitness2Id(), migrationState);
|
||||
if (witness2RecordStatus == Utils.UNKNOWN || witness2RecordStatus == Utils.FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET)
|
||||
return;
|
||||
else if (witness2RecordStatus == Utils.CONFIRMED_MISSING) {
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getId());
|
||||
tag.setContent(CustomErrorCodes.WITNESS2_RECORD_ID_MISSING);
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
else if (witness2RecordStatus == Utils.FOUND_AS_FAMILY_TREE_RECORD) {
|
||||
UnionRecordTag tag = null;
|
||||
tag = new UnionRecordTag();
|
||||
tag.setUnionRecordId(mtlb.getId());
|
||||
tag.setKey(CustomErrorCodes.WITNESS2_RECORD_FOUND_IN_FAMILY_TREE);
|
||||
tag.setContent(mtlb.getWitness2Id().toString());
|
||||
tag.setType(Utils.ERROR_TAG_TYPE);
|
||||
tags.add(tag);
|
||||
}
|
||||
ur.setId(mtlb.getId());
|
||||
ur.setAddress(mtlb.getMarriageLocation());
|
||||
ur.setPlace(mtlb.getMarriagePlace());
|
||||
ur.setPartner1VitalRecordId(mtlb.getHusbandId());
|
||||
ur.setPartner2VitalRecordId(mtlb.getWifeId());
|
||||
ur.setDateOfMarriage(mtlb.getDateOfMarriage());
|
||||
ur.setFirstWitnessId(mtlb.getWitness1Id());
|
||||
ur.setSecondWitnessId(mtlb.getWitness2Id());
|
||||
ur.setRites(mtlb.getMarriageRites());
|
||||
ur.setTimeOfMarriage(mtlb.getTimeOfMarriage());
|
||||
if (hvr != null && wvr != null) {
|
||||
if (hvr.getGender() == 2 && wvr.getGender() == 1) {
|
||||
ur.setPartner1VitalRecordId(wvr.getId());
|
||||
ur.setPartner2VitalRecordId(hvr.getId());
|
||||
} else if (hvr.getGender() == wvr.getGender()) {
|
||||
UnionRecordTag urTag = new UnionRecordTag();
|
||||
urTag.setUnionRecordId(mtlb.getId());
|
||||
urTag.setContent(hvr.getId() + " : " + wvr.getId());
|
||||
urTag.setType(Utils.ERROR_TAG_TYPE);
|
||||
urTag.setKey(CustomErrorCodes.SAME_SEX_MARRIAGE);
|
||||
tags.add(urTag);
|
||||
}
|
||||
}
|
||||
ArchideMtlbAnnex annex = null;
|
||||
try {
|
||||
annex = ArchideMtlbAnnexUtil.deserialize(mtlb.getAnnex());
|
||||
} catch (JsonProcessingException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (annex.getTags() != null)
|
||||
for (ArchideMtlbAnnexTag tag : annex.getTags()) {
|
||||
UnionRecordTag urTag = new UnionRecordTag();
|
||||
urTag.setUnionRecordId(mtlb.getId());
|
||||
urTag.setContent(tag.getValue());
|
||||
urTag.setType(tag.getType());
|
||||
urTag.setKey(tag.getName());
|
||||
tags.add(urTag);
|
||||
}
|
||||
ArrayList<UnionRecordMention> mentions = new ArrayList<>();
|
||||
for (ArchideMtlbAnnexLogEntry mention : annex.getMentions()) {
|
||||
UnionRecordMention vm = new UnionRecordMention();
|
||||
vm.setAddedBy(mention.getAuthor());
|
||||
vm.setContent(mention.getContent());
|
||||
vm.setTimestamp(mention.getTimestamp());
|
||||
vm.setUnionRecordId(mtlb.getId());
|
||||
mentions.add(vm);
|
||||
}
|
||||
try {
|
||||
unionRecordRepository.insert(ur);
|
||||
for (UnionRecordMention mention : mentions)
|
||||
unionRecordMentionRepository.insert(mention);
|
||||
for (UnionRecordTag tag : tags)
|
||||
unionRecordTagRepository.insert(tag);
|
||||
mtlb.setMtlbStatus(MtlbStatus.ARCHIVED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package systems.archide.core.workflows.utils;
|
||||
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
|
||||
public class AgeCalculator {
|
||||
|
||||
public static int calculateAge(LocalDate birthDate, LocalDate currentDate) {
|
||||
if ((birthDate != null) && (currentDate != null)) {
|
||||
return Period.between(birthDate, currentDate).getYears();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,470 @@
|
||||
package systems.archide.core.workflows.utils;
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import systems.archide.core.ErrorCodes;
|
||||
import systems.archide.core.pojo.*;
|
||||
import systems.archide.core.repository.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class CivilStatusMtlbUtils {
|
||||
|
||||
final String ERROR_TAG_TYPE = "ERROR";
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries customQueries;
|
||||
@Autowired
|
||||
CivilStatusMtlbRepository civilStatusMtlbRepository;
|
||||
@Autowired
|
||||
CivilStatusMtlbTagRepository civilStatusMtlbTagRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbAttachmentRepository civilStatusMtlbAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordMedicalNotificationFileRepository vitalRecordMedicalNotificationFileRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbMedicalNotificationFileRepository civilStatusMtlbMedicalNotificationFileRepository;
|
||||
|
||||
@Autowired
|
||||
AddressRepository addressRepository;
|
||||
|
||||
@Autowired
|
||||
EmailRepository emailRepository;
|
||||
|
||||
@Autowired
|
||||
PhoneNumberRepository phoneNumberRepository;
|
||||
|
||||
@Autowired
|
||||
FaceRepository faceRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordAttachmentRepository vitalRecordAttachmentRepository;
|
||||
|
||||
@Autowired
|
||||
DigitalizationQueueRepository digitalizationQueueRepository;
|
||||
|
||||
@Autowired
|
||||
CivilStatusMtlbNoteRepository civilStatusMtlbNoteRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordNoteRepository vitalRecordNoteRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordHistoryRepository vitalRecordHistoryRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordTagRepository vitalRecordTagRepository;
|
||||
|
||||
@Autowired
|
||||
VitalRecordTagHistoryRepository vitalRecordTagHistoryRepository;
|
||||
|
||||
public boolean mtlbWithoutFingerprints(CivilStatusMtlb mtlb) {
|
||||
return mtlb.getRightThumb() == null && mtlb.getRightIndexFinger() == null && mtlb.getRightMiddleFinger() == null
|
||||
&& mtlb.getRightRingFinger() == null && mtlb.getRightPinky() == null && mtlb.getLeftThumb() == null
|
||||
&& mtlb.getLeftIndexFinger() == null && mtlb.getLeftMiddleFinger() == null
|
||||
&& mtlb.getLeftRingFinger() == null && mtlb.getLeftPinky() == null;
|
||||
}
|
||||
|
||||
public boolean validateBiographic(CivilStatusMtlb mtlb) {
|
||||
boolean validName = validateName(mtlb);
|
||||
boolean validGenderAndBirthDate = validateGenderAndBirthDate(mtlb);
|
||||
boolean validAddress = validateAddress(mtlb);
|
||||
boolean validMedicalNotification = validateMedicalNotification(mtlb);
|
||||
boolean validFatherAndMother = validateFatherAndMother(mtlb);
|
||||
return validName && validGenderAndBirthDate && validAddress && validMedicalNotification && validFatherAndMother;
|
||||
}
|
||||
|
||||
private boolean validateFatherAndMother(CivilStatusMtlb mtlb) {
|
||||
boolean valid = true;
|
||||
if (mtlb.getMotherId() != null
|
||||
|| (mtlb.getReportedMotherName() != null && !mtlb.getReportedMotherName().isEmpty())) {
|
||||
if (mtlb.getMotherId() != null) {
|
||||
VitalRecord motherRecord = vitalRecordRepository.findById(mtlb.getMotherId());
|
||||
if (motherRecord == null) {
|
||||
createErrorTag(ErrorCodes.MOTHER_NOT_FOUND, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
} else if (!mtlb.isUnknownMother()) {
|
||||
createErrorTag(ErrorCodes.MOTHER_NOT_FOUND, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (mtlb.getFatherId() != null
|
||||
|| (mtlb.getReportedFatherName() != null && !mtlb.getReportedFatherName().isEmpty())) {
|
||||
if (mtlb.getFatherId() != null) {
|
||||
VitalRecord fatherRecord = vitalRecordRepository.findById(mtlb.getFatherId());
|
||||
if (fatherRecord == null) {
|
||||
createErrorTag(ErrorCodes.FATHER_NOT_FOUND, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
} else if (!mtlb.isUnknownFather()) {
|
||||
createErrorTag(ErrorCodes.FATHER_NOT_FOUND, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
private boolean validateMedicalNotification(CivilStatusMtlb mtlb) {
|
||||
if (!mtlb.isMedicalNotification() || mtlb.isMedicalNotification() == null) {
|
||||
if (mtlb.getWitness1Id() == null || mtlb.getWitness2Id() == null) {
|
||||
createErrorTag(ErrorCodes.WITNESSES_MISSING, mtlb.getId());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
boolean attachmentExists = checkAttachments(mtlb);
|
||||
if (!attachmentExists)
|
||||
if (mtlb.getWitness1Id() == null || mtlb.getWitness2Id() == null) {
|
||||
createErrorTag(ErrorCodes.WITNESSES_MISSING, mtlb.getId());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkAttachments(CivilStatusMtlb mtlb) {
|
||||
List<CivilStatusMtlbMedicalNotificationFile> attachmentList = civilStatusMtlbMedicalNotificationFileRepository
|
||||
.findByCivilStatusMtlbId(mtlb.getId());
|
||||
if (attachmentList.isEmpty())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean validateAddress(CivilStatusMtlb mtlb) {
|
||||
List<Address> addressList = addressRepository.findByCivilStatusMtlbId(mtlb.getId());
|
||||
if (addressList.isEmpty()) {
|
||||
createErrorTag(ErrorCodes.ADDRESS_MISSING, mtlb.getId());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean validateGenderAndBirthDate(CivilStatusMtlb mtlb) {
|
||||
boolean valid = true;
|
||||
if (mtlb.getGender() == null) {
|
||||
createErrorTag(ErrorCodes.GENDER_MISSING, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (mtlb.getBirthdate() == null) {
|
||||
createErrorTag(ErrorCodes.BIRTH_DATE_MISSING, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
private boolean validateName(CivilStatusMtlb mtlb) {
|
||||
boolean valid = true;
|
||||
if (StringUtils.isAllBlank(mtlb.getFirstname())) {
|
||||
createErrorTag(ErrorCodes.FIRST_NAME_MISSING, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (StringUtils.isAllBlank(mtlb.getFourthname())) {
|
||||
createErrorTag(ErrorCodes.FAMILY_NAME_MISSING, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
String match = "^[A-Z<>-<2D>][A-Za-z<>-<2D>]{2,14}$";
|
||||
String middleNameMatch = "^[A-Z<>-<2D>][A-Za-z<>-<2D>]{2,28}$";
|
||||
if (mtlb.getFirstname() != null)
|
||||
if (!mtlb.getFirstname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.FIRST_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (mtlb.getSecondname() != null)
|
||||
if (!mtlb.getSecondname().matches(middleNameMatch)) {
|
||||
createErrorTag(ErrorCodes.SECOND_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (mtlb.getThirdname() != null)
|
||||
if (!mtlb.getThirdname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.THIRD_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (mtlb.getFourthname() != null)
|
||||
if (!mtlb.getFourthname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.FAMILY_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (mtlb.getFifthname() != null)
|
||||
if (!mtlb.getFifthname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.MARRIAGE_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void createErrorTag(String errorCode, Long mtlbId) {
|
||||
CivilStatusMtlbTag tag = new CivilStatusMtlbTag();
|
||||
tag.setContent(errorCode);
|
||||
tag.setType(ERROR_TAG_TYPE);
|
||||
tag.setCivilStatusMtlbId(mtlbId);
|
||||
civilStatusMtlbTagRepository.insert(tag);
|
||||
}
|
||||
|
||||
public void createErrorTag(String errorCode, Long mtlbId, String type) {
|
||||
CivilStatusMtlbTag tag = new CivilStatusMtlbTag();
|
||||
tag.setContent(errorCode);
|
||||
tag.setType(type);
|
||||
tag.setCivilStatusMtlbId(mtlbId);
|
||||
civilStatusMtlbTagRepository.insert(tag);
|
||||
}
|
||||
|
||||
public boolean validateNoExistingCivilStatusMtlbFirstNameAndFourthName(CivilStatusMtlb mtlb) {
|
||||
List<CivilStatusMtlb> civilMtlIdList = customQueries
|
||||
.findCivilStatusMtlbByFirstnameAndFourthname(mtlb.getFirstname(), mtlb.getFourthname(), mtlb.getId());
|
||||
if (civilMtlIdList.isEmpty())
|
||||
return true;
|
||||
else
|
||||
createErrorTag(ErrorCodes.BIRTH_APPLICATION_FIRSTNAME_FOURTHNAME_DUPLICATED, mtlb.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean validateNoExistingVitalRecordFirstNameAndFourthName(CivilStatusMtlb mtlb) {
|
||||
List<VitalRecord> vitalRecordIdList = customQueries.findVitalRecordByFirstnameAndFourthname(mtlb.getFirstname(),
|
||||
mtlb.getFourthname(), mtlb.getId());
|
||||
if (vitalRecordIdList.isEmpty())
|
||||
return true;
|
||||
else
|
||||
createErrorTag(ErrorCodes.BIRTH_VITALRECORD_FIRSTNAME_FOURTHNAME_DUPLICATED, mtlb.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean validateNoExistingCivilStatusMtlbOrVitalRecordFirstNameAndFourthName(CivilStatusMtlb mtlb) {
|
||||
return validateNoExistingCivilStatusMtlbFirstNameAndFourthName(mtlb)
|
||||
&& validateNoExistingVitalRecordFirstNameAndFourthName(mtlb);
|
||||
}
|
||||
|
||||
public boolean validateNoExistingSimilarBReq(CivilStatusMtlb mtlb) {
|
||||
List<CivilStatusMtlb> civilMtlIdList = customQueries.findCivilStatusMtlbByBirthdateAndMotherIdAndType(
|
||||
mtlb.getMotherId(), mtlb.getMtlbType().getValue(), mtlb.getBirthdate(), mtlb.getId());
|
||||
List<VitalRecord> vitalRecordIdList = customQueries.findVitalRecordByBirthdateAndMotherId(mtlb.getMotherId(),
|
||||
mtlb.getBirthdate(), mtlb.getId());
|
||||
if (civilMtlIdList.isEmpty() && vitalRecordIdList.isEmpty())
|
||||
return true;
|
||||
if (!civilMtlIdList.isEmpty())
|
||||
createErrorTag(ErrorCodes.BIRTH_APPLICATION_DUPLICATED, mtlb.getId());
|
||||
if (!vitalRecordIdList.isEmpty())
|
||||
createErrorTag(ErrorCodes.BIRTH_VITALRECORD_DUPLICATED, mtlb.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
public Long saveFace(byte[] image, Long vitalRecordId) {
|
||||
Face face = new Face();
|
||||
face.setImage(image);
|
||||
face.setVitalRecordId(vitalRecordId);
|
||||
return faceRepository.insert(face);
|
||||
}
|
||||
|
||||
public Long createVitalRecordFromCivilStatusMtlb(CivilStatusMtlb mtlb) {
|
||||
VitalRecord vitalRecord = new VitalRecord();
|
||||
mtlbToVitalRecord(mtlb, vitalRecord);
|
||||
return vitalRecordRepository.insert(vitalRecord);
|
||||
}
|
||||
|
||||
public void addFace2VitalRecord(Long faceId, Long vitalRecordId) {
|
||||
VitalRecord vitalRecord = vitalRecordRepository.findById(vitalRecordId);
|
||||
vitalRecord.setFaceId(faceId);
|
||||
vitalRecordRepository.update(vitalRecord);
|
||||
}
|
||||
|
||||
public void saveAttachments(Long mtlbId, Long vitalRecordId) {
|
||||
List<CivilStatusMtlbAttachment> civilStatusMtlbAttachments = civilStatusMtlbAttachmentRepository
|
||||
.findByCivilStatusMtlbId(mtlbId);
|
||||
for (CivilStatusMtlbAttachment civilStatusMtlbAttachment : civilStatusMtlbAttachments) {
|
||||
VitalRecordAttachment vitalRecordAttachment = new VitalRecordAttachment();
|
||||
vitalRecordAttachment.setFileName(civilStatusMtlbAttachment.getFileName());
|
||||
vitalRecordAttachment.setContent(civilStatusMtlbAttachment.getContent());
|
||||
vitalRecordAttachment.setVitalRecordId(vitalRecordId);
|
||||
vitalRecordAttachment.setPreview(civilStatusMtlbAttachment.getPreview());
|
||||
vitalRecordAttachment.setDescription(civilStatusMtlbAttachment.getDescription());
|
||||
vitalRecordAttachmentRepository.insert(vitalRecordAttachment);
|
||||
}
|
||||
List<CivilStatusMtlbMedicalNotificationFile> medicalNotifList = civilStatusMtlbMedicalNotificationFileRepository
|
||||
.findByCivilStatusMtlbId(mtlbId);
|
||||
for (CivilStatusMtlbMedicalNotificationFile m : medicalNotifList) {
|
||||
VitalRecordMedicalNotificationFile vitalRecordMedicalNotif = new VitalRecordMedicalNotificationFile();
|
||||
vitalRecordMedicalNotif.setFileName(m.getFileName());
|
||||
vitalRecordMedicalNotif.setContent(m.getContent());
|
||||
vitalRecordMedicalNotif.setVitalRecordId(vitalRecordId);
|
||||
vitalRecordMedicalNotif.setDescription(m.getDescription());
|
||||
vitalRecordMedicalNotif.setPreview(m.getPreview());
|
||||
vitalRecordMedicalNotificationFileRepository.insert(vitalRecordMedicalNotif);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveVitalRecordAdminInfo(Long civilStatusMtlbId, Long vitalRecordId) {
|
||||
List<Address> addressList = addressRepository.findByCivilStatusMtlbId(civilStatusMtlbId);
|
||||
List<Email> emailList = emailRepository.findByCivilStatusMtlbId(civilStatusMtlbId);
|
||||
List<PhoneNumber> phoneNumberList = phoneNumberRepository.findByCivilStatusMtlbId(civilStatusMtlbId);
|
||||
for (Address address : addressList) {
|
||||
address.setVitalRecordId(vitalRecordId);
|
||||
addressRepository.update(address);
|
||||
}
|
||||
for (Email email : emailList) {
|
||||
email.setVitalRecordId(vitalRecordId);
|
||||
emailRepository.update(email);
|
||||
}
|
||||
for (PhoneNumber phone : phoneNumberList) {
|
||||
phone.setVitalRecordId(vitalRecordId);
|
||||
phoneNumberRepository.update(phone);
|
||||
}
|
||||
}
|
||||
|
||||
public Long saveDeathRecordFace(byte[] image, Long deathRecordId) {
|
||||
Face face = new Face();
|
||||
face.setImage(image);
|
||||
face.setDeathRecordId(deathRecordId);
|
||||
return faceRepository.insert(face);
|
||||
}
|
||||
|
||||
|
||||
public void deleteDigitalizationFromQueue(Long mtlbId) {
|
||||
List<CivilStatusMtlbAttachment> civilStatusMtlbAttachments = civilStatusMtlbAttachmentRepository
|
||||
.findByCivilStatusMtlbId(mtlbId);
|
||||
for (CivilStatusMtlbAttachment civilStatusMtlbAttachment : civilStatusMtlbAttachments) {
|
||||
List<DigitalizationQueue> digitalizationQueues = digitalizationQueueRepository
|
||||
.findByFileName(civilStatusMtlbAttachment.getFileName());
|
||||
for (DigitalizationQueue digitalizationQueue : digitalizationQueues)
|
||||
digitalizationQueueRepository.deleteById(digitalizationQueue.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void mtlbToVitalRecord(CivilStatusMtlb mtlb, VitalRecord vitalRecord) {
|
||||
vitalRecord.setFirstname(mtlb.getFirstname());
|
||||
vitalRecord.setSecondname(mtlb.getSecondname());
|
||||
vitalRecord.setThirdname(mtlb.getThirdname());
|
||||
vitalRecord.setFourthname(mtlb.getFourthname());
|
||||
vitalRecord.setFifthname(mtlb.getFifthname());
|
||||
vitalRecord.setBirthdate(mtlb.getBirthdate());
|
||||
vitalRecord.setBirthPlace(mtlb.getBirthPlace());
|
||||
vitalRecord.setBirthCountry(mtlb.getBirthCountry());
|
||||
vitalRecord.setBirthDayUnknown(mtlb.isBirthDayUnknown());
|
||||
vitalRecord.setBirthMonthUnknown(mtlb.isBirthMonthUnknown());
|
||||
vitalRecord.setBirthYearUnknown(mtlb.isBirthYearUnknown());
|
||||
vitalRecord.setGender(mtlb.getGender());
|
||||
vitalRecord.setDisability(mtlb.isDisability());
|
||||
vitalRecord.setMaritalStatus(mtlb.getMaritalStatus());
|
||||
vitalRecord.setNotes(mtlb.getNotes());
|
||||
vitalRecord.setPrimaryCitizenship(mtlb.getPrimaryCitizenship());
|
||||
vitalRecord.setOtherCitizenshipCsv(mtlb.getOtherCitizenshipCsv());
|
||||
vitalRecord.setFatherId(mtlb.getFatherId());
|
||||
vitalRecord.setMotherId(mtlb.getMotherId());
|
||||
vitalRecord.setReportedFatherName(mtlb.getReportedFatherName());
|
||||
vitalRecord.setReportedMotherName(mtlb.getReportedMotherName());
|
||||
vitalRecord.setInactive(false);
|
||||
vitalRecord.setTypeOfAcquisition(mtlb.getTypeOfAcquisition());
|
||||
vitalRecord.setVillageOfOrigin(mtlb.getVillageOfOrigin());
|
||||
vitalRecord.setUnknownFather(mtlb.isUnknownFather());
|
||||
vitalRecord.setUnknownMother(mtlb.isUnknownMother());
|
||||
vitalRecord.setBirthTime(mtlb.getBirthTime());
|
||||
vitalRecord.setTimestamp(LocalDateTime.now());
|
||||
vitalRecord.setAdoptiveFatherId(mtlb.getAdoptiveFatherId());
|
||||
vitalRecord.setAdoptiveMotherId(mtlb.getAdoptiveMotherId());
|
||||
vitalRecord.setMarriageCertificateNumberAdoptive(mtlb.getMarriageCertificateNumberAdoptive());
|
||||
vitalRecord.setCourtAdoptionNumber(mtlb.getCourtAdoptionNumber());
|
||||
vitalRecord.setVillageOfOriginAdoptive(mtlb.getVillageOfOriginAdoptive());
|
||||
vitalRecord.setDeclarantId(mtlb.getDeclarantId());
|
||||
vitalRecord.setWitness1Id(mtlb.getWitness1Id());
|
||||
vitalRecord.setWitness2Id(mtlb.getWitness2Id());
|
||||
vitalRecord.setRegistrationLocation(mtlb.getRegistrationLocation());
|
||||
vitalRecord.setMentions(mtlb.getMentions());
|
||||
}
|
||||
|
||||
public void updateVitalRecordFromCivilStatusMtlb(CivilStatusMtlb mtlb, VitalRecord vitalRecord) {
|
||||
saveHistory(vitalRecord);
|
||||
mtlbToVitalRecord(mtlb, vitalRecord);
|
||||
vitalRecordRepository.update(vitalRecord);
|
||||
}
|
||||
|
||||
private void saveHistory(VitalRecord vitalRecord) {
|
||||
VitalRecordHistory history = new VitalRecordHistory();
|
||||
history.setFirstname(vitalRecord.getFirstname());
|
||||
history.setFifthname(vitalRecord.getFifthname());
|
||||
history.setSecondname(vitalRecord.getSecondname());
|
||||
history.setThirdname(vitalRecord.getThirdname());
|
||||
history.setFourthname(vitalRecord.getFourthname());
|
||||
history.setBirthdate(vitalRecord.getBirthdate());
|
||||
history.setBirthPlace(vitalRecord.getBirthPlace());
|
||||
history.setBirthCountry(vitalRecord.getBirthCountry());
|
||||
history.setBirthDayUnknown(vitalRecord.isBirthDayUnknown());
|
||||
history.setBirthMonthUnknown(vitalRecord.isBirthMonthUnknown());
|
||||
history.setBirthYearUnknown(vitalRecord.isBirthYearUnknown());
|
||||
history.setGender(vitalRecord.getGender());
|
||||
history.setDisability(vitalRecord.isDisability());
|
||||
history.setMaritalStatus(vitalRecord.getMaritalStatus());
|
||||
history.setNotes(vitalRecord.getNotes());
|
||||
history.setPrimaryCitizenship(vitalRecord.getPrimaryCitizenship());
|
||||
history.setOtherCitizenshipCsv(vitalRecord.getOtherCitizenshipCsv());
|
||||
history.setFatherId(vitalRecord.getFatherId());
|
||||
history.setMotherId(vitalRecord.getMotherId());
|
||||
history.setReportedFatherName(vitalRecord.getReportedFatherName());
|
||||
history.setReportedMotherName(vitalRecord.getReportedMotherName());
|
||||
history.setInactive(false);
|
||||
history.setHistoryTimestamp(LocalDateTime.now());
|
||||
history.setTimestamp(vitalRecord.getTimestamp());
|
||||
history.setId(vitalRecord.getId());
|
||||
history.setAdoptiveFatherId(vitalRecord.getAdoptiveFatherId());
|
||||
history.setAdoptiveMotherId(vitalRecord.getAdoptiveMotherId());
|
||||
history.setVillageOfOriginAdoptive(vitalRecord.getVillageOfOriginAdoptive());
|
||||
history.setMarriageCertificateNumberAdoptive(vitalRecord.getMarriageCertificateNumberAdoptive());
|
||||
history.setCourtAdoptionNumber(vitalRecord.getCourtAdoptionNumber());
|
||||
history.setDeclarantId(vitalRecord.getDeclarantId());
|
||||
history.setWitness1Id(vitalRecord.getWitness1Id());
|
||||
history.setWitness2Id(vitalRecord.getWitness2Id());
|
||||
vitalRecordHistoryRepository.insert(history);
|
||||
}
|
||||
|
||||
public void saveNotes(Long id, Long vitalRecordId) {
|
||||
List<CivilStatusMtlbNote> cnoteList = civilStatusMtlbNoteRepository.findByCivilStatusMtlbId(id);
|
||||
for (CivilStatusMtlbNote cnote : cnoteList) {
|
||||
VitalRecordNote vnote = new VitalRecordNote();
|
||||
vnote.setAddedBy(cnote.getAddedBy());
|
||||
vnote.setContent(cnote.getContent());
|
||||
vnote.setTimestamp(cnote.getTimestamp());
|
||||
vnote.setVitalRecordId(vitalRecordId);
|
||||
vitalRecordNoteRepository.insert(vnote);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deleteRecordAttachments(Long vitalRecordId) {
|
||||
List<VitalRecordAttachment> attachmentList = vitalRecordAttachmentRepository.findByVitalRecordId(vitalRecordId);
|
||||
List<VitalRecordMedicalNotificationFile> medicalNotificationFileList = vitalRecordMedicalNotificationFileRepository.findByVitalRecordId(vitalRecordId);
|
||||
for (VitalRecordAttachment a : attachmentList)
|
||||
vitalRecordAttachmentRepository.purge(a);
|
||||
for (VitalRecordMedicalNotificationFile f : medicalNotificationFileList)
|
||||
vitalRecordMedicalNotificationFileRepository.delete(f);
|
||||
}
|
||||
|
||||
public void saveVitalRecordHistoryTags(Long id) {
|
||||
List<VitalRecordTag> recordTags = vitalRecordTagRepository.findByVitalRecordId(id);
|
||||
if (!recordTags.isEmpty()) {
|
||||
for (VitalRecordTag tag : recordTags) {
|
||||
VitalRecordTagHistory htag = new VitalRecordTagHistory();
|
||||
htag.setContent(tag.getContent());
|
||||
htag.setKey(tag.getKey());
|
||||
htag.setId(tag.getId());
|
||||
htag.setType(tag.getType());
|
||||
htag.setVitalRecordId(tag.getVitalRecordId());
|
||||
vitalRecordTagHistoryRepository.insert(htag);
|
||||
vitalRecordTagRepository.purgeById(tag.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package systems.archide.core.workflows.utils;
|
||||
|
||||
import systems.archide.core.ErrorCodes;
|
||||
|
||||
public class CustomErrorCodes extends ErrorCodes{
|
||||
|
||||
public static final String RV4_FATHER_FAMILY_TREE_RECORD = "E20";
|
||||
public static final String RV4_MOTHER_FAMILY_TREE_RECORD = "E21";
|
||||
public static final String RECORD_FOUND_IN_FAMILY_TREE = "E22";
|
||||
public static final String HUSBAND_RECORD_FOUND_IN_FAMILY_TREE = "E25";
|
||||
public static final String Wife_RECORD_FOUND_IN_FAMILY_TREE = "E27";
|
||||
public static final String WITNESS1_RECORD_FOUND_IN_FAMILY_TREE = "E29";
|
||||
public static final String WITNESS2_RECORD_FOUND_IN_FAMILY_TREE = "E31";
|
||||
public static final String UNION_RECORD_MISSING = "E70";
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package systems.archide.core.workflows.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum MtlbEntity {
|
||||
|
||||
CIVIL_STATUS_MTLB(1),
|
||||
|
||||
ID_MTLB(2),
|
||||
|
||||
UNION_MTLB(3);
|
||||
|
||||
private java.lang.Integer value;
|
||||
|
||||
MtlbEntity(java.lang.Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public java.lang.Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
private static final Map<java.lang.Integer, MtlbEntity> toTypeMap = new HashMap<>();
|
||||
static {
|
||||
for (MtlbEntity type : MtlbEntity.values()) {
|
||||
toTypeMap.put(type.value, type);
|
||||
}
|
||||
}
|
||||
|
||||
public static MtlbEntity fromValue(java.lang.Integer val) {
|
||||
if (val == null)
|
||||
return null;
|
||||
MtlbEntity mtlbEntity = toTypeMap.get(java.lang.Integer.valueOf(val));
|
||||
if (mtlbEntity == null)
|
||||
throw new RuntimeException("Invalid value for MtlbEntity: " + val);
|
||||
return mtlbEntity;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package systems.archide.core.workflows.utils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.ErrorCodes;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlb;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlbTag;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.IdcoreCustomQueries;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbTagRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@Component
|
||||
public class RvFourBirthMtlbUtils {
|
||||
|
||||
final String ERROR_TAG_TYPE = "ERROR";
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
IdcoreCustomQueries customQueries;
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbTagRepository rvfourBirthMtlbTagRepository;
|
||||
|
||||
public boolean validateBiographic(RvfourBirthMtlb mtlb) {
|
||||
boolean validName = validateName(mtlb);
|
||||
boolean validGenderAndBirthDate = validateGenderAndBirthDate(mtlb);
|
||||
return validName && validGenderAndBirthDate;
|
||||
}
|
||||
|
||||
|
||||
private boolean validateGenderAndBirthDate(RvfourBirthMtlb mtlb) {
|
||||
boolean valid = true;
|
||||
if (mtlb.getGender() == null) {
|
||||
createErrorTag(ErrorCodes.GENDER_MISSING, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (mtlb.getBirthdate() == null) {
|
||||
createErrorTag(ErrorCodes.BIRTH_DATE_MISSING, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
private boolean validateName(RvfourBirthMtlb mtlb) {
|
||||
boolean valid = true;
|
||||
if (StringUtils.isAllBlank(mtlb.getFirstname())) {
|
||||
createErrorTag(ErrorCodes.FIRST_NAME_MISSING, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (StringUtils.isAllBlank(mtlb.getFourthname())) {
|
||||
createErrorTag(ErrorCodes.FAMILY_NAME_MISSING, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
String match = "^[aA-zZ<7A>-<2D>]{4,14}$";
|
||||
if (!StringUtils.isAllBlank(mtlb.getFirstname()))
|
||||
if (!mtlb.getFirstname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.FIRST_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (!StringUtils.isAllBlank(mtlb.getSecondname()))
|
||||
if (!mtlb.getSecondname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.SECOND_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (!StringUtils.isAllBlank(mtlb.getThirdname()))
|
||||
if (!mtlb.getThirdname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.THIRD_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (!StringUtils.isAllBlank(mtlb.getFourthname()))
|
||||
if (!mtlb.getFourthname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.FAMILY_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
if (!StringUtils.isAllBlank(mtlb.getFifthname()))
|
||||
if (!mtlb.getFifthname().matches(match)) {
|
||||
createErrorTag(ErrorCodes.MARRIAGE_NAME_CHAR_RULES, mtlb.getId());
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void createErrorTag(String errorCode, Long mtlbId) {
|
||||
RvfourBirthMtlbTag tag = new RvfourBirthMtlbTag();
|
||||
tag.setContent(errorCode);
|
||||
tag.setType(ERROR_TAG_TYPE);
|
||||
tag.setRvfourBirthMtlbId(mtlbId);
|
||||
rvfourBirthMtlbTagRepository.insert(tag);
|
||||
}
|
||||
|
||||
public void createErrorTag(String errorCode, Long mtlbId, String type) {
|
||||
RvfourBirthMtlbTag tag = new RvfourBirthMtlbTag();
|
||||
tag.setContent(errorCode);
|
||||
tag.setType(type);
|
||||
tag.setRvfourBirthMtlbId(mtlbId);
|
||||
rvfourBirthMtlbTagRepository.insert(tag);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package systems.archide.core.workflows.utils;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class ServicesStatusManager {
|
||||
|
||||
public static void publishStatus(String key, String message, String service) {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
|
||||
// Your Centrifugo API endpoint
|
||||
String centrifugoEndpoint = "http://localhost:8000/api/";
|
||||
|
||||
// Your Centrifugo API key
|
||||
String apiKey = "9ce8f014-b367-4162-b20b-495ed14ab1be";
|
||||
|
||||
// Channel to publish the message
|
||||
String channel = service;
|
||||
|
||||
// Data to be sent to the SPA via Centrifugo
|
||||
String dataToSend = "{\"channel\": \"" + channel + "\", \"data\": {\"value\": {\"key\": \"" + key + "\", \"value\": \"" + message + "\"}}}";
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, dataToSend);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(centrifugoEndpoint + "publish") // Publish API endpoint
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "apikey " + apiKey)
|
||||
.post(body)
|
||||
.build();
|
||||
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
System.out.println(response.body().string());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package systems.archide.core.workflows.utils;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import systems.archide.core.pojo.GlobalState;
|
||||
import systems.archide.core.pojo.MtlbType;
|
||||
import systems.archide.core.pojo.RvfourBirthMtlb;
|
||||
import systems.archide.core.pojo.RvfourMarriageMtlb;
|
||||
import systems.archide.core.pojo.UnionRecord;
|
||||
import systems.archide.core.pojo.VitalRecord;
|
||||
import systems.archide.core.repository.RvfourBirthMtlbRepository;
|
||||
import systems.archide.core.repository.RvfourMarriageMtlbRepository;
|
||||
import systems.archide.core.repository.UnionRecordRepository;
|
||||
import systems.archide.core.repository.VitalRecordRepository;
|
||||
|
||||
@Component
|
||||
public class Utils {
|
||||
|
||||
public final static String INFO_TAG_TYPE = "INFO";
|
||||
public final static String WARNING_TAG_TYPE = "WARNING";
|
||||
public final static String ERROR_TAG_TYPE = "ERROR";
|
||||
|
||||
public final static int FOUND = 0;
|
||||
public final static int UNKNOWN = 1;
|
||||
public final static int CONFIRMED_MISSING = 2;
|
||||
public final static int FOUND_AS_FAMILY_TREE_RECORD = 3;
|
||||
public final static int FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET = 4;
|
||||
public static final int FOUND_BUT_UNION_RECORD_NOT_CREATED_YET = 5;
|
||||
|
||||
@Autowired
|
||||
VitalRecordRepository vitalRecordRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourBirthMtlbRepository rvfourBirthMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
RvfourMarriageMtlbRepository rvfourMarriageMtlbRepository;
|
||||
|
||||
@Autowired
|
||||
UnionRecordRepository unionRecordRepository;
|
||||
|
||||
public int checkVitalRecordStatus(Long id, GlobalState migrationState) {
|
||||
VitalRecord vitalRecord = vitalRecordRepository.findById(id);
|
||||
if (vitalRecord != null)
|
||||
return FOUND;
|
||||
RvfourBirthMtlb mtlb = rvfourBirthMtlbRepository.findByVitalRecordId(id);
|
||||
if (mtlb == null) {
|
||||
if (!"FINISHED".equals(migrationState.getValue()))
|
||||
return UNKNOWN;
|
||||
else
|
||||
return CONFIRMED_MISSING;
|
||||
} else {
|
||||
if (mtlb.getMtlbType() == MtlbType.RV4_BIRTH_VITAL_RECORD)
|
||||
return FOUND_BUT_VITAL_RECORD_NOT_CREATED_YET;
|
||||
else
|
||||
return FOUND_AS_FAMILY_TREE_RECORD;
|
||||
}
|
||||
}
|
||||
|
||||
public int checkUnionRecordStatus(Long id, GlobalState migrationState) {
|
||||
UnionRecord unionRecord = unionRecordRepository.findById(id);
|
||||
if (unionRecord != null)
|
||||
return FOUND;
|
||||
RvfourMarriageMtlb mtlb = rvfourMarriageMtlbRepository.findById(id);
|
||||
if (mtlb == null) {
|
||||
if (!"FINISHED".equals(migrationState.getValue()))
|
||||
return UNKNOWN;
|
||||
else
|
||||
return CONFIRMED_MISSING;
|
||||
} else {
|
||||
if (mtlb.getMtlbType() == MtlbType.RV4_UNION_RECORD)
|
||||
return FOUND_BUT_UNION_RECORD_NOT_CREATED_YET;
|
||||
else
|
||||
return CONFIRMED_MISSING;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
syntax = "proto3";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "AdjuticationServiceProto";
|
||||
option java_package = "systems.archide.core.proto";
|
||||
package adjutication_service;
|
||||
|
||||
service AdjuticationService {
|
||||
rpc readAdjutication (IdMtlbMessage) returns (ProbeInformationOutput) {}
|
||||
}
|
||||
|
||||
message ProbeInformationOutput {
|
||||
optional int64 vitalRecordId = 1;
|
||||
optional int64 fingerprintsId = 2;
|
||||
optional int64 probeAfisId = 3;
|
||||
optional int64 faceId = 4;
|
||||
}
|
||||
|
||||
message IdMtlbMessage {
|
||||
optional int64 mtlbId = 1;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
syntax = "proto3";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "CivilStatusAdjuticationServiceProto";
|
||||
option java_package = "systems.archide.core.proto";
|
||||
package civil_status_adjutication_service;
|
||||
|
||||
service CivilStatusAdjuticationService {
|
||||
rpc adjuticate (CivilStatusAdjuticationMessage) returns (CivilStatusMtlbIdMessage) {}
|
||||
}
|
||||
|
||||
message CivilStatusAdjuticationMessage {
|
||||
optional int64 mtlbId = 1;
|
||||
optional int64 probeAfisId = 2;
|
||||
optional bool duplicated = 3;
|
||||
}
|
||||
|
||||
message CivilStatusMtlbIdMessage {
|
||||
optional int64 mtlbId = 1;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "DigitalizationAdjuticationServiceProto";
|
||||
option java_package = "systems.archide.core.proto";
|
||||
package digitalization_adjutication_service;
|
||||
|
||||
service DigitalizationAdjuticationService {
|
||||
rpc adjuticate (DigitalizationAdjuticationMessage) returns (AdjudicationVitalRecordIdMessage) {}
|
||||
}
|
||||
|
||||
message DigitalizationAdjuticationMessage {
|
||||
optional int64 vitalRecordId = 1;
|
||||
optional int64 fileId = 2;
|
||||
}
|
||||
|
||||
message AdjudicationVitalRecordIdMessage {
|
||||
optional int64 vitalRecordId = 1;
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
syntax = "proto3";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "IdCardVerificationProto";
|
||||
option java_package = "systems.archide.core.proto";
|
||||
|
||||
import "MaritalStatus.proto";
|
||||
import "Gender.proto";
|
||||
import "IdCardVerificationOutcome.proto";
|
||||
|
||||
package id_card_verification_service;
|
||||
service IdCardVerificationService {
|
||||
rpc verify (IdCardVerificationRequest) returns (IdCardVerificationResponse) {}
|
||||
}
|
||||
|
||||
message IdCardVerificationRequest {
|
||||
int64 cardId = 1;
|
||||
optional bytes encryptedCode = 2;
|
||||
}
|
||||
|
||||
message IdCardVerificationResponse {
|
||||
|
||||
IdCardVerificationOutcome verified = 1;
|
||||
optional int64 cardId = 2;
|
||||
optional int64 vitalRecordId = 3;
|
||||
optional bytes faceImage = 4;
|
||||
optional bool birthDayUnknown = 5;
|
||||
optional bool birthMonthUnknown = 6;
|
||||
optional bool birthYearUnknown = 7;
|
||||
optional int64 birthdate = 8;
|
||||
optional string birthPlace = 9;
|
||||
optional string birthCountry = 10;
|
||||
optional string firstname = 11;
|
||||
optional string secondname = 12;
|
||||
optional string thirdname = 13;
|
||||
optional string fourthname = 14;
|
||||
optional Gender gender = 15;
|
||||
optional MaritalStatus maritalStatus = 16;
|
||||
optional int32 primaryCitizenship = 17;
|
||||
optional string otherCitizenshipCsv = 18;
|
||||
optional int64 fatherVitalRecordId = 19;
|
||||
optional int64 motherVitalRecordId = 20;
|
||||
optional bool disability = 21;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "IdMtlbAdjuticationServiceProto";
|
||||
option java_package = "systems.archide.core.proto";
|
||||
package id_mtlb_adjutication_service;
|
||||
|
||||
service IdMtlbAdjuticationService {
|
||||
rpc adjuticate (IdMtlbAdjuticationMessage) returns (IdMtlbIdMessage) {}
|
||||
}
|
||||
|
||||
message IdMtlbAdjuticationMessage {
|
||||
optional int64 mtlbId = 1;
|
||||
optional int64 probeAfisId = 2;
|
||||
optional bool duplicated = 3;
|
||||
}
|
||||
message IdMtlbIdMessage {
|
||||
optional int64 mtlbId = 1;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "VitalRecordVerificationProto";
|
||||
option java_package = "systems.archide.core.proto";
|
||||
|
||||
package vital_record_verification_service;
|
||||
service VitalRecordVerificationService {
|
||||
rpc findVitalRecordByFirstNameAndBirthDate (VitalRecordVerificationRequest) returns (VitalRecordIdVerificationResponse) {}
|
||||
}
|
||||
|
||||
message VitalRecordVerificationRequest {
|
||||
optional string firstname = 1;
|
||||
int64 birthdate = 2;
|
||||
}
|
||||
|
||||
message VitalRecordIdVerificationResponse {
|
||||
repeated int64 id = 1;
|
||||
}
|
3
src/main/resources/idcore.properties
Normal file
3
src/main/resources/idcore.properties
Normal file
@ -0,0 +1,3 @@
|
||||
db.url=jdbc:postgresql://localhost/idcore
|
||||
db.username=idcore
|
||||
db.password=idcore
|
3
src/main/resources/keycloak.properties
Normal file
3
src/main/resources/keycloak.properties
Normal file
@ -0,0 +1,3 @@
|
||||
db.url=jdbc:postgresql://localhost/keycloak
|
||||
db.username=keycloak
|
||||
db.password=keycloak
|
7
src/templates/LocalConstants.java
Normal file
7
src/templates/LocalConstants.java
Normal file
@ -0,0 +1,7 @@
|
||||
package systems.archide.core;
|
||||
|
||||
public class LocalConstants {
|
||||
|
||||
public final static String PERSONS_FILES_PREFIX = "{{rv4_images_path}}";
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user