Commit 94bd47ba by Owen Ryan Ang

Merge branch 'feature-doctype-update' into 'development-mobile'

Feature doctype update See merge request !76
parents 52c263e4 f7d141dc
......@@ -167,7 +167,7 @@ export class BPO {
async getMobileFieldData() {
let elementId = sessionStorage.getItem("element_id");
let xmlData = {
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + (ENCODING_PASS == "PASS1" ? elementId + ".DTA" : elementId + ".DTB")
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + elementId + ".DFC"
}
let response = await fetch(urlGetMobileFields, {
......
//Data Input Field Config
export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/schema_sqa.json";
// export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/HR Speed Test schema.json";
export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/Navotas 2.json";
//DBLookup Webservice URL
export var DB_URL = "http://localhost:8080/WebGde/svc/gfs-rest/db-lookup"
\ No newline at end of file
......@@ -15,6 +15,7 @@ let newOption;
export let schema;
export async function generateFields(inputSchema, containerId) {
window.populateFields = populateFields;
schema = inputSchema;
let divContainer = document.getElementById(containerId);
......@@ -197,10 +198,8 @@ export async function generateFields(inputSchema, containerId) {
$(document).ready(function() {
$('form:first *:input[type!=hidden]:first').focus(); // Run code
});
}
}
......@@ -242,6 +241,32 @@ const noValidation = (key) => {
* @returns
* created input field element
*/
const inputHidden = (key, validation) => {
try {
const input = document.createElement('textarea');
input.setAttribute('rows', 5);
input.setAttribute('id', key);
input.setAttribute('name', key);
input.setAttribute('cols', 30);
input.setAttribute('autocomplete', 'off');
input.setAttribute('inputMode', validation.collection === 'email' ? 'email' : 'text');
input.addEventListener('focusout', handleInput);
return input;
} catch (err) {
throw err;
}
}
/**
*
* @param {*} key
* will serve as id of input field
* @param {*} validation
* validation of field from schema
* @returns
* created input field element
*/
const inputString = (key, validation) => {
try {
const {
......@@ -1829,21 +1854,37 @@ const deconstruct = async (section, container, classAttribute) => {
fieldLabel, hidden
} = section[key]
// Create hidden input for fields with hidden="y"
// if (hidden && hidden.toLowerCase() === "y") {
// const hiddenInput = document.createElement('input');
// hiddenInput.setAttribute('type', 'hidden');
// hiddenInput.setAttribute('name', key);
// hiddenInput.setAttribute('value', ''); // Set the value as needed
const validation = getValidation(key, schema)
// // Append the hidden input to the container
// container.appendChild(hiddenInput);
if (hidden) {
const hiddenField = document.createElement('div') // will contain input field and label
hiddenField.setAttribute('class', 'fieldContainer ' + classAttribute)
container.appendChild(hiddenField)
// // Skip creating other visible input elements for hidden fields
// continue;
// }
const labelContainer = document.createElement('div') // name beside input field
labelContainer.setAttribute('class', 'labelContainer ' + classAttribute)
hiddenField.appendChild(labelContainer)
const validation = getValidation(key, schema)
const label = document.createElement('label')
label.textContent = fieldLabel ? fieldLabel : `Missing label`
label.style.color = fieldLabel ? '#000000' : '#ff3333'
labelContainer.appendChild(label)
const inputContainer = document.createElement('div') // input field
inputContainer.setAttribute('class', 'inputContainer ' + classAttribute)
hiddenField.appendChild(inputContainer)
// default hiddeninputs to String
const hiddenInput = inputHidden(key, schema);
hiddenInput.setAttribute('class', classAttribute)
inputContainer.appendChild(hiddenInput);
hiddenField.style.display = 'none'; // Hide the input
hiddenField.classList.add('hidden'); // Add 'hidden' class
continue;
}
const newField = document.createElement('div') // will contain input field and label
newField.setAttribute('class', 'fieldContainer ' + classAttribute)
......@@ -1924,10 +1965,6 @@ const deconstruct = async (section, container, classAttribute) => {
}
input.setAttribute('class', classAttribute)
inputContainer.appendChild(input)
if (hidden && hidden.toLowerCase() === 'y') {
newField.style.display = 'none'; // Hide the input
newField.classList.add('hidden'); // Add 'hidden' class
}
}
//keys na drop down
......@@ -2226,10 +2263,15 @@ export async function populateFields() {
for (let key of Object.keys(schema[doctype][section])) {
if (schema[doctype][section][key].aka == "field" + k) {
//console.log("key = " + key);
console.log("key = " + key + +", value ="+v);
//console.log("validation: " + schema[doctype][section][key].validation.collection);
fields["field" + k] = v;
if (schema[doctype][section][key].hidden){
document.getElementById(key).value = v;
continue;
}
if(schema[doctype][section][key].validation.collection === 'radiolist'){
//retrieve the radio button value from the XML
......
......@@ -22,6 +22,10 @@ export const validateInput = (fieldID, value) => {
if(!validation) return { valid: false, error: [`FieldName: '${fieldID}' not in schema`] }
// Skip validation for hidden fields
if (isFieldHidden(fieldID)){
return { valid: true };
}
switch(validation.collection) {
case 'email':
return validateEmail(validation, value)
......@@ -429,4 +433,15 @@ export const checkValidValues = (fieldID, value) => {
} catch(err) {
return { isValidValue: false, errMsg: [err]}
}
}
\ No newline at end of file
}
function isFieldHidden(key) {
for (const docType in schema) {
for (const section in schema[docType]) {
if (schema[docType][section][key] && schema[docType][section][key].hidden) {
return true;
}
}
}
return false;
}
\ No newline at end of file
......@@ -15,10 +15,15 @@ export async function WriteForm(e,metrics,doctype,section) {
// localStorage.setItem("submit", "1");
let fields = {};
for (var i=0;i<Nodes.length;i++) {
for (var i=0;i<Nodes.length;i++) {
if (Nodes[i].style.display === 'none' && !Nodes[i].classList.contains('hidden')) continue
let fid = Nodes[i].id;
if (fid == 'DocType' || fid == 'Section' || fid == '' || fid == "submitButton") continue
// Add doctype as field1
if (fid === 'DocType') {
fields['1'] = Nodes[i].value;
continue;
}
if (fid == 'Section' || fid == '' || fid == "submitButton") continue
// Skip the textbox in checklist and radiolist
if (Nodes[i].classList.contains('radioOther') || Nodes[i].classList.contains('checkboxOther')) continue;
// Skip elements of type "button", "submit", and files
......@@ -73,8 +78,11 @@ export async function WriteForm(e,metrics,doctype,section) {
}
fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = Nodes[i].value;
}
let fieldOrder = extractAkaValues(schema, doctype, section);
console.log(fieldOrder);
let response = await createOutputXml(fields, myArray, doctype, section);
let response = await createOutputXml(fields, myArray, doctype, section, fieldOrder);
return response;
}
catch(Err) {
......@@ -83,17 +91,36 @@ export async function WriteForm(e,metrics,doctype,section) {
return false;
}
async function createOutputXml(fields, metrics, doctype, section) {
function extractAkaValues(json, doctype, section) {
const akaValues = [];
function recursiveExtract(obj) {
for (const key in obj) {
if (typeof obj[key] === 'object') {
recursiveExtract(obj[key]);
} else if (key === 'aka') {
akaValues.push(obj[key].replace('field', ''));
}
}
}
recursiveExtract(json[doctype][section]);
return akaValues.join('|');
}
async function createOutputXml(fields, metrics, doctype, section, fieldOrder) {
let response = null;
if (IS_RETRIEVE_FROM_BPO == "Y") {
response = await createBPOXML(fields, metrics, doctype, section);
response = await createBPOXML(fields, metrics, doctype, section, fieldOrder);
} else{
response = await createNonBPOXML(fields, metrics, doctype, section);
response = await createNonBPOXML(fields, metrics, doctype, section, fieldOrder);
}
return response;
}
async function createNonBPOXML(fields, metrics, doctype, section){
async function createNonBPOXML(fields, metrics, doctype, section, fieldOrder){
console.log(fields);
let fileExt = "";
switch(ENCODING_PASS){
case "PASS1":
......@@ -137,7 +164,8 @@ async function createNonBPOXML(fields, metrics, doctype, section){
"fields": fields,
"outputDir": TEMPORARY_FOLDER + "/" + fileNameOnly + "/" + fileName,
"doctype": doctype,
"section": section
"section": section,
"fieldOrder" : fieldOrder
}
let response = await fetch(urlWriteXml, {
......@@ -151,7 +179,7 @@ async function createNonBPOXML(fields, metrics, doctype, section){
return response;
}
async function createBPOXML(fields, metrics, doctype, section){
async function createBPOXML(fields, metrics, doctype, section, fieldOrder){
let elementId = sessionStorage.getItem("element_id");
let filePaths = JSON.parse(sessionStorage.getItem("dir_files"));
......@@ -174,9 +202,10 @@ async function createBPOXML(fields, metrics, doctype, section){
"subRecordNo": "1",
"eor": "N",
"fields": fields,
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + (ENCODING_PASS == "PASS1" ? elementId + ".DTA" : elementId + ".DTB"),
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + elementId + ".DVR",
"doctype": doctype,
"section": section
"section": section,
"fieldOrder" : fieldOrder
}
let response = await fetch(urlWriteXml, {
......
......@@ -21,7 +21,7 @@ export const IS_RETRIEVE_FROM_GFS = "N"
export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen,ScrollLock,Pause,PageUp,PageDown,Insert,Delete,Control"
//BPO CONFIG
export const IS_RETRIEVE_FROM_BPO = "Y"
export const IS_RETRIEVE_FROM_BPO = "N"
// export const BPO_URL = "http://35.171.20.94:8080/bpo-sqa/"
// export const CURRENT_NODE = "Web GDE"
export let BPO_URL = DOMAIN + "bpo/";
......@@ -30,7 +30,7 @@ export let CURRENT_NODE = ""
export const ENCODING_PASS = "PASS1"
export const NEXT_NODE = "Complete"
export const EXCEPTION_NODE = "Exception"
export const SHOW_ELEMENT_LIST_VIEWER = "Y"
export const SHOW_ELEMENT_LIST_VIEWER = "N"
export const ADD_NEW_OPTION = "N"
export const DISPLAYED_DETAILS = "Address" //pipe-delimited
......
{
"RESIDENT REGISTRATION FORM" : {
"NAVOTAS" : {
"registration_no" : {
"fieldLabel" : "Registration Number",
"aka" : "field2",
"validation" : {
"fieldLength" : 15.0,
"collection" : "alphanumeric",
"invalidchar" : "`~!@#&$%^*_={}[]:;/\"|\\<>",
"mandatory" : false
},
"hidden" : true
},
"date_of_submission" : {
"fieldLabel" : "Date of Submission",
"aka" : "field3",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"hidden" : true
},
"cert_data_consent_auth" : {
"fieldLabel" : "Certification, Data Privacy Consent, and Authorization",
"aka" : "field4",
"validation" : {
"fieldLength" : 12.0,
"collection" : "radiolist",
"items" : [ "Authorized", "Unauthorized" ],
"mandatory" : false
},
"hidden" : true
},
"signature_resident" : {
"fieldLabel" : "Signature over Printed Name (Resident)",
"aka" : "field5",
"validation" : {
"fieldLength" : 8.0,
"collection" : "radiolist",
"items" : [ "Signed", "Unsigned" ],
"mandatory" : false
},
"hidden" : true
},
"signature_lgu" : {
"fieldLabel" : "Signature over Printed Name (LGU Personnel)",
"aka" : "field6",
"validation" : {
"fieldLength" : 8.0,
"collection" : "radiolist",
"items" : [ "Signed", "Unsigned" ],
"mandatory" : false
},
"hidden" : true
},
"last_name" : {
"fieldLabel" : "Last Name",
"aka" : "field7",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"invalidchar" : "`~!@#&$%^*_={}[]:;/\"|\\<>0123456789",
"mandatory" : false
},
"hidden" : true
},
"first_name" : {
"fieldLabel" : "First Name",
"aka" : "field8",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"middle_name" : {
"fieldLabel" : "Middle Name",
"aka" : "field9",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"suffix" : {
"fieldLabel" : "Suffix",
"aka" : "field10",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"gender" : {
"fieldLabel" : "Gender",
"aka" : "field11",
"validation" : {
"fieldLength" : 6.0,
"collection" : "dropdown",
"options" : [ "Male", "Female" ],
"mandatory" : false
},
"hidden" : true
},
"birthdate" : {
"fieldLabel" : "Date of Birth (mm/dd/yyyy)",
"aka" : "field12",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"hidden" : true
},
"birthplace" : {
"fieldLabel" : "Place of Birth",
"aka" : "field13",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"civil_status" : {
"fieldLabel" : "Civil Status",
"aka" : "field14",
"validation" : {
"fieldLength" : 25.0,
"collection" : "dropdown",
"options" : [ "Single", "Separated", "Cohabitation (live-in)", "Married", "Widow/er" ],
"mandatory" : false
},
"hidden" : true
},
"citizen_type" : {
"fieldLabel" : "Citizen Type",
"aka" : "field15",
"validation" : {
"fieldLength" : 25.0,
"collection" : "checklist",
"items" : [ "Registered Voter", "Living in Navotas", "Working in Navotas" ],
"invalidchar" : "`~!@#&$%^*_={}[]:;/\"|\\<>0123456789",
"mandatory" : false
},
"hidden" : true
},
"social_status" : {
"fieldLabel" : "Social Status",
"aka" : "field16",
"validation" : {
"fieldLength" : 25.0,
"collection" : "checklist",
"items" : [ "General Population", "4Ps", "PWD", "Senior Citizen", "Solo Parent" ],
"mandatory" : false
},
"hidden" : true
},
"highest_educ" : {
"fieldLabel" : "Highest Educational Attainment",
"aka" : "field17",
"validation" : {
"fieldLength" : 25.0,
"collection" : "dropdown",
"options" : [ "None", "Kindergarten", "Elementary", "Jr. High School", "Sr. high School", "College", "Vocational", "Post Graduate" ],
"mandatory" : false
},
"hidden" : true
},
"nationality" : {
"fieldLabel" : "Nationality",
"aka" : "field18",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"blood_type" : {
"fieldLabel" : "Blood Type",
"aka" : "field19",
"validation" : {
"fieldLength" : 3.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"ethnic_origin" : {
"fieldLabel" : "Ethnic Origin",
"aka" : "field20",
"validation" : {
"fieldLength" : 20.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"religion" : {
"fieldLabel" : "Religion",
"aka" : "field21",
"validation" : {
"fieldLength" : 20.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"known_languages" : {
"fieldLabel" : "Known Language/s",
"aka" : "field22",
"validation" : {
"fieldLength" : 30.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"bldg_info" : {
"fieldLabel" : "Room/Floor/Unit no./Bldg. name",
"aka" : "field23",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"house_no" : {
"fieldLabel" : "House no/Lot & Blk no",
"aka" : "field24",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"street_name" : {
"fieldLabel" : "Street Name",
"aka" : "field25",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"subd_vill" : {
"fieldLabel" : "Subdivision/Village",
"aka" : "field26",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"barangay" : {
"fieldLabel" : "Barangay",
"aka" : "field27",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"city" : {
"fieldLabel" : "City",
"aka" : "field28",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"province" : {
"fieldLabel" : "Province",
"aka" : "field29",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"zipcode" : {
"fieldLabel" : "Zip Code",
"aka" : "field30",
"validation" : {
"fieldLength" : 4.0,
"collection" : "numeric",
"mandatory" : false
},
"hidden" : true
},
"mobile_no" : {
"fieldLabel" : "Mobile Number",
"aka" : "field31",
"validation" : {
"fieldLength" : 15.0,
"collection" : "numeric",
"mandatory" : false
},
"hidden" : true
},
"email_add" : {
"fieldLabel" : "Email Address",
"aka" : "field32",
"validation" : {
"fieldLength" : 25.0,
"collection" : "email",
"mandatory" : false
},
"hidden" : true
},
"messenger_name" : {
"fieldLabel" : "Messenger Name",
"aka" : "field33",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"source_of_income" : {
"fieldLabel" : "Source of Income",
"aka" : "field34",
"validation" : {
"fieldLength" : 15.0,
"collection" : "checklist",
"items" : [ "Business", "Commission", "Pension", "Salary", "Others" ],
"mandatory" : false
},
"hidden" : true
},
"employment_status" : {
"fieldLabel" : "Employment Status",
"aka" : "field35",
"validation" : {
"fieldLength" : 15.0,
"collection" : "dropdown",
"options" : [ "Employed", "Unemployed", "Self-employed" ],
"mandatory" : false
},
"hidden" : true
},
"employment_category" : {
"fieldLabel" : "Employment Category",
"aka" : "field36",
"validation" : {
"fieldLength" : 20.0,
"collection" : "dropdown",
"options" : [ "Permanent/Regular", "Seasonal", "Casual", "Emergency" ],
"mandatory" : false
},
"hidden" : true
},
"employment_type" : {
"fieldLabel" : "Employment Type",
"aka" : "field37",
"validation" : {
"fieldLength" : 10.0,
"collection" : "radiolist",
"items" : [ "Government", "Private" ],
"mandatory" : false
},
"hidden" : true
},
"occupation" : {
"fieldLabel" : "Occupation",
"aka" : "field38",
"validation" : {
"fieldLength" : 50.0,
"collection" : "dropdown",
"options" : [ "Manager", "Professional", "Technician and Associate Professional", "Clerical Support Workers", "Service and Sale Workers", "Skilled Agricultural", "Forestry", "and Fishery Workers", "Craft and Related Trade Workers", "Paint and Machine Operators and Assemblers", "Elementary Occupations", "Armed Forces Occupation", "Others (Please Specify)" ],
"mandatory" : false
},
"hidden" : true
},
"monthly_income" : {
"fieldLabel" : "Monthly Income",
"aka" : "field39",
"validation" : {
"fieldLength" : 20.0,
"collection" : "dropdown",
"options" : [ "60k and above", "50k - 60k", "40k - 50k", "30k - 40k", "20k - 30k", "10k - 20k", "5k - 10k", "1k - 5k", "below 1k" ],
"mandatory" : false
},
"hidden" : true
},
"employer_buss_name" : {
"fieldLabel" : "Employer / Business Name",
"aka" : "field40",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"emp_bldg_info" : {
"fieldLabel" : "Room/Floor/Unit no./Bldg. name",
"aka" : "field41",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"emp_house_no" : {
"fieldLabel" : "House no/Lot & Blk no",
"aka" : "field42",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"emp_street_name" : {
"fieldLabel" : "Street Name",
"aka" : "field43",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"emp_subd_vill" : {
"fieldLabel" : "Subdivision/Village",
"aka" : "field44",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"emp_barangay" : {
"fieldLabel" : "Barangay",
"aka" : "field45",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"emp_city" : {
"fieldLabel" : "City",
"aka" : "field46",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"emp_province" : {
"fieldLabel" : "Province",
"aka" : "field47",
"validation" : {
"fieldLength" : 25.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"emp_zipcode" : {
"fieldLabel" : "Zip Code",
"aka" : "field48",
"validation" : {
"fieldLength" : 4.0,
"collection" : "numeric",
"mandatory" : false
},
"childof" : "source_of_income",
"parentvalue" : [ "Business", "Salary" ],
"hidden" : true
},
"contact_person_lastname" : {
"fieldLabel" : "Contact Person - Last Name",
"aka" : "field49",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"contact_person_firstname" : {
"fieldLabel" : "Contact Person - First Name",
"aka" : "field50",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"contact_person_middlename" : {
"fieldLabel" : "Contact Person - Middle Name",
"aka" : "field51",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"contact_person_suffix" : {
"fieldLabel" : "Contact Person - Suffix",
"aka" : "field52",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"contact_person_relationship" : {
"fieldLabel" : "Relationship",
"aka" : "field53",
"validation" : {
"fieldLength" : 15.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"hidden" : true
},
"contact_person_number" : {
"fieldLabel" : "Contact Number",
"aka" : "field54",
"validation" : {
"fieldLength" : 15.0,
"collection" : "numeric",
"mandatory" : false
},
"hidden" : true
},
"principal_to_be_insured" : {
"fieldLabel" : "I'm the Principal to be Insured?",
"aka" : "field55",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"hidden" : true
},
"father_lastname" : {
"fieldLabel" : "Father - Last Name",
"aka" : "field56",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"father_firstname" : {
"fieldLabel" : "Father - First Name",
"aka" : "field57",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"father_middlename" : {
"fieldLabel" : "Father - Middle Name",
"aka" : "field58",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"father_suffix" : {
"fieldLabel" : "Father - Suffix",
"aka" : "field59",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"father_birthdate" : {
"fieldLabel" : "Father - Date of Birth",
"aka" : "field60",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"father_gender" : {
"fieldLabel" : "Father - Gender",
"aka" : "field61",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"father_same_residence" : {
"fieldLabel" : "Father - Same Residence?",
"aka" : "field62",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"father_dependent" : {
"fieldLabel" : "Father - Dependent?",
"aka" : "field63",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"mother_lastname" : {
"fieldLabel" : "Mother - Last Name",
"aka" : "field64",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"mother_firstname" : {
"fieldLabel" : "Mother - First Name",
"aka" : "field65",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"mother_middlename" : {
"fieldLabel" : "Mother - Middle Name",
"aka" : "field66",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"mother_suffix" : {
"fieldLabel" : "Mother - Suffix",
"aka" : "field67",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"mother_birthdate" : {
"fieldLabel" : "Mother - Date of Birth",
"aka" : "field68",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"mother_gender" : {
"fieldLabel" : "Mother - Gender",
"aka" : "field69",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"mother_same_residence" : {
"fieldLabel" : "Mother - Same Residence?",
"aka" : "field70",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"mother_dependent" : {
"fieldLabel" : "Mother - Dependent?",
"aka" : "field71",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"spouse_lastname" : {
"fieldLabel" : "Spouse - Last Name",
"aka" : "field72",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"spouse_firstname" : {
"fieldLabel" : "Spouse - First Name",
"aka" : "field73",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"spouse_middlename" : {
"fieldLabel" : "Spouse - Middle Name",
"aka" : "field74",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"spouse_suffix" : {
"fieldLabel" : "Spouse - Suffix",
"aka" : "field75",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"spouse_birthdate" : {
"fieldLabel" : "Spouse - Date of Birth",
"aka" : "field76",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"spouse_gender" : {
"fieldLabel" : "Spouse - Gender",
"aka" : "field77",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"spouse_same_residence" : {
"fieldLabel" : "Spouse - Same Residence?",
"aka" : "field78",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"spouse_dependent" : {
"fieldLabel" : "Spouse - Dependent?",
"aka" : "field79",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"child_no" : {
"fieldLabel" : "Number of Children",
"aka" : "field80",
"validation" : {
"fieldLength" : 1.0,
"collection" : "dropdown",
"options" : [ "0", "1", "2", "3", "4", "5" ],
"mandatory" : false
},
"childof" : "principal_to_be_insured",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"child1_lastname" : {
"fieldLabel" : "Child1 - Last Name",
"aka" : "field81",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"child1_firstname" : {
"fieldLabel" : "Child1 - First Name",
"aka" : "field82",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"child1_middlename" : {
"fieldLabel" : "Child1 - Middle Name",
"aka" : "field83",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"child1_suffix" : {
"fieldLabel" : "Child1 - Suffix",
"aka" : "field84",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"child1_birthdate" : {
"fieldLabel" : "Child1 - Date of Birth",
"aka" : "field85",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"child1_gender" : {
"fieldLabel" : "Child1 - Gender",
"aka" : "field86",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"child1_same_residence" : {
"fieldLabel" : "Child1 - Same Residence?",
"aka" : "field87",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"child1_dependent" : {
"fieldLabel" : "Child1 - Dependent?",
"aka" : "field88",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"child2_lastname" : {
"fieldLabel" : "Child2 - Last Name",
"aka" : "field89",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"child2_firstname" : {
"fieldLabel" : "Child2 - First Name",
"aka" : "field90",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"child2_middlename" : {
"fieldLabel" : "Child2 - Middle Name",
"aka" : "field91",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"child2_suffix" : {
"fieldLabel" : "Child2 - Suffix",
"aka" : "field92",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"child2_birthdate" : {
"fieldLabel" : "Child2 - Date of Birth",
"aka" : "field93",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"child2_gender" : {
"fieldLabel" : "Child2 - Gender",
"aka" : "field94",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"child2_same_residence" : {
"fieldLabel" : "Child2 - Same Residence?",
"aka" : "field95",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"child2_dependent" : {
"fieldLabel" : "Child2 - Dependent?",
"aka" : "field96",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"child3_lastname" : {
"fieldLabel" : "Child3 - Last Name",
"aka" : "field97",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"child3_firstname" : {
"fieldLabel" : "Child3 - First Name",
"aka" : "field98",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"child3_middlename" : {
"fieldLabel" : "Child3 - Middle Name",
"aka" : "field99",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"child3_suffix" : {
"fieldLabel" : "Child3 - Suffix",
"aka" : "field100",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"child3_birthdate" : {
"fieldLabel" : "Child3 - Date of Birth",
"aka" : "field101",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"child3_gender" : {
"fieldLabel" : "Child3 - Gender",
"aka" : "field102",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"child3_same_residence" : {
"fieldLabel" : "Child3 - Same Residence?",
"aka" : "field103",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"child3_dependent" : {
"fieldLabel" : "Child3 - Dependent?",
"aka" : "field104",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"child4_lastname" : {
"fieldLabel" : "Child4 - Last Name",
"aka" : "field105",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"child4_firstname" : {
"fieldLabel" : "Child4 - First Name",
"aka" : "field106",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"child4_middlename" : {
"fieldLabel" : "Child4 - Middle Name",
"aka" : "field107",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"child4_suffix" : {
"fieldLabel" : "Child4 - Suffix",
"aka" : "field108",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"child4_birthdate" : {
"fieldLabel" : "Child4 - Date of Birth",
"aka" : "field109",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"child4_gender" : {
"fieldLabel" : "Child4 - Gender",
"aka" : "field110",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"child4_same_residence" : {
"fieldLabel" : "Child4 - Same Residence?",
"aka" : "field111",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"child4_dependent" : {
"fieldLabel" : "Child4 - Dependent?",
"aka" : "field112",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"child5_lastname" : {
"fieldLabel" : "Child5 - Last Name",
"aka" : "field113",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"child5_firstname" : {
"fieldLabel" : "Child5 - First Name",
"aka" : "field114",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"child5_middlename" : {
"fieldLabel" : "Child5 - Middle Name",
"aka" : "field115",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"child5_suffix" : {
"fieldLabel" : "Child5 - Suffix",
"aka" : "field116",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"child5_birthdate" : {
"fieldLabel" : "Child5 - Date of Birth",
"aka" : "field117",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"child5_gender" : {
"fieldLabel" : "Child5 - Gender",
"aka" : "field118",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"child5_same_residence" : {
"fieldLabel" : "Child5 - Same Residence?",
"aka" : "field119",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"child5_dependent" : {
"fieldLabel" : "Child5 - Dependent?",
"aka" : "field120",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "child_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"head_of_household" : {
"fieldLabel" : "I'm Head of the Household",
"aka" : "field121",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"hidden" : true
},
"hoh_lastname" : {
"fieldLabel" : "Head of Household - Last Name",
"aka" : "field122",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "head_of_household",
"parentvalue" : [ "No" ],
"hidden" : true
},
"hoh_firstname" : {
"fieldLabel" : "Head of Household - First Name",
"aka" : "field123",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "head_of_household",
"parentvalue" : [ "No" ],
"hidden" : true
},
"hoh_middlename" : {
"fieldLabel" : "Head of Household - Middle Name",
"aka" : "field124",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "head_of_household",
"parentvalue" : [ "No" ],
"hidden" : true
},
"hoh_suffix" : {
"fieldLabel" : "Head of Household - Suffix",
"aka" : "field125",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "head_of_household",
"parentvalue" : [ "No" ],
"hidden" : true
},
"hoh_birthdate" : {
"fieldLabel" : "Head of Household - Date of Birth",
"aka" : "field126",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "head_of_household",
"parentvalue" : [ "No" ],
"hidden" : true
},
"hoh_gender" : {
"fieldLabel" : "Head of Household - Gender",
"aka" : "field127",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "head_of_household",
"parentvalue" : [ "No" ],
"hidden" : true
},
"hoh_relationship_to_hoh" : {
"fieldLabel" : "Relationship to Head of Household",
"aka" : "field128",
"validation" : {
"fieldLength" : 15.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "head_of_household",
"parentvalue" : [ "No" ],
"hidden" : true
},
"hoh_member_no" : {
"fieldLabel" : "Household Members",
"aka" : "field129",
"validation" : {
"fieldLength" : 1.0,
"collection" : "dropdown",
"options" : [ "0", "1", "2", "3", "4", "5" ],
"mandatory" : false
},
"childof" : "head_of_household",
"parentvalue" : [ "Yes" ],
"hidden" : true
},
"hh_member1_lastname" : {
"fieldLabel" : "Household Member1 - Last Name",
"aka" : "field130",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member1_firstname" : {
"fieldLabel" : "Household Member1 - First Name",
"aka" : "field131",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member1_middlename" : {
"fieldLabel" : "Household Member1 - Middle Name",
"aka" : "field132",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member1_suffix" : {
"fieldLabel" : "Household Member1 - Suffix",
"aka" : "field133",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member1_birthdate" : {
"fieldLabel" : "Household Member1 - Date of Birth",
"aka" : "field134",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member1_gender" : {
"fieldLabel" : "Household Member1 - Gender",
"aka" : "field135",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member1_relationship_to_hoh" : {
"fieldLabel" : "Household Member1 - Relationship to Head of Household",
"aka" : "field136",
"validation" : {
"fieldLength" : 15.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member1_dependent" : {
"fieldLabel" : "Household Member1 - Dependent?",
"aka" : "field137",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "1", "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member2_lastname" : {
"fieldLabel" : "Household Member2 - Last Name",
"aka" : "field138",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member2_firstname" : {
"fieldLabel" : "Household Member2 - First Name",
"aka" : "field139",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member2_middlename" : {
"fieldLabel" : "Household Member2 - Middle Name",
"aka" : "field140",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member2_suffix" : {
"fieldLabel" : "Household Member2 - Suffix",
"aka" : "field141",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member2_birthdate" : {
"fieldLabel" : "Household Member2 - Date of Birth",
"aka" : "field142",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member2_gender" : {
"fieldLabel" : "Household Member2 - Gender",
"aka" : "field143",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member2_relationship_to_hoh" : {
"fieldLabel" : "Household Member2 - Relationship to Head of Household",
"aka" : "field144",
"validation" : {
"fieldLength" : 15.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member2_dependent" : {
"fieldLabel" : "Household Member2 - Dependent?",
"aka" : "field145",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "2", "3", "4", "5" ],
"hidden" : true
},
"hh_member3_lastname" : {
"fieldLabel" : "Household Member3 - Last Name",
"aka" : "field146",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"hh_member3_firstname" : {
"fieldLabel" : "Household Member3 - First Name",
"aka" : "field147",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"hh_member3_middlename" : {
"fieldLabel" : "Household Member3 - Middle Name",
"aka" : "field148",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"hh_member3_suffix" : {
"fieldLabel" : "Household Member3 - Suffix",
"aka" : "field149",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"hh_member3_birthdate" : {
"fieldLabel" : "Household Member3 - Date of Birth",
"aka" : "field150",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"hh_member3_gender" : {
"fieldLabel" : "Household Member3 - Gender",
"aka" : "field151",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"hh_member3_relationship_to_hoh" : {
"fieldLabel" : "Household Member3 - Relationship to Head of Household",
"aka" : "field152",
"validation" : {
"fieldLength" : 15.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"hh_member3_dependent" : {
"fieldLabel" : "Household Member3 - Dependent?",
"aka" : "field153",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "3", "4", "5" ],
"hidden" : true
},
"hh_member4_lastname" : {
"fieldLabel" : "Household Member4 - Last Name",
"aka" : "field154",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"hh_member4_firstname" : {
"fieldLabel" : "Household Member4 - First Name",
"aka" : "field155",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"hh_member4_middlename" : {
"fieldLabel" : "Household Member4 - Middle Name",
"aka" : "field156",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"hh_member4_suffix" : {
"fieldLabel" : "Household Member4 - Suffix",
"aka" : "field157",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"hh_member4_birthdate" : {
"fieldLabel" : "Household Member4 - Date of Birth",
"aka" : "field158",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"hh_member4_gender" : {
"fieldLabel" : "Household Member4 - Gender",
"aka" : "field159",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"hh_member4_relationship_to_hoh" : {
"fieldLabel" : "Household Member4 - Relationship to Head of Household",
"aka" : "field160",
"validation" : {
"fieldLength" : 15.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"hh_member4_dependent" : {
"fieldLabel" : "Household Member4 - Dependent?",
"aka" : "field161",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "4", "5" ],
"hidden" : true
},
"hh_member5_lastname" : {
"fieldLabel" : "Household Member5 - Last Name",
"aka" : "field162",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"hh_member5_firstname" : {
"fieldLabel" : "Household Member5 - First Name",
"aka" : "field163",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"hh_member5_middlename" : {
"fieldLabel" : "Household Member5 - Middle Name",
"aka" : "field164",
"validation" : {
"fieldLength" : 50.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"hh_member5_suffix" : {
"fieldLabel" : "Household Member5 - Suffix",
"aka" : "field165",
"validation" : {
"fieldLength" : 5.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"hh_member5_birthdate" : {
"fieldLabel" : "Household Member5 - Date of Birth",
"aka" : "field166",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"hh_member5_gender" : {
"fieldLabel" : "Household Member5 - Gender",
"aka" : "field167",
"validation" : {
"fieldLength" : 6.0,
"collection" : "radiolist",
"items" : [ "Male", "Female" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"hh_member5_relationship_to_hoh" : {
"fieldLabel" : "Household Member5 - Relationship to Head of Household",
"aka" : "field168",
"validation" : {
"fieldLength" : 15.0,
"collection" : "alphanumeric",
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"hh_member5_dependent" : {
"fieldLabel" : "Household Member5 - Dependent?",
"aka" : "field169",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : false
},
"childof" : "hoh_member_no",
"parentvalue" : [ "5" ],
"hidden" : true
},
"ver_question1" : {
"fieldLabel" : "Verification Question 1",
"aka" : "field170",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question2" : {
"fieldLabel" : "Verification Question 2",
"aka" : "field171",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question4" : {
"fieldLabel" : "Verification Question 4",
"aka" : "field173",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question3" : {
"fieldLabel" : "Verification Question 3",
"aka" : "field172",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question5" : {
"fieldLabel" : "Verification Question 5",
"aka" : "field174",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question6" : {
"fieldLabel" : "Verification Question 6",
"aka" : "field175",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question7" : {
"fieldLabel" : "Verification Question 7",
"aka" : "field176",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question8" : {
"fieldLabel" : "Verification Question 8",
"aka" : "field177",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question9" : {
"fieldLabel" : "Verification Question 9",
"aka" : "field178",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question10" : {
"fieldLabel" : "Verification Question 10",
"aka" : "field179",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question11" : {
"fieldLabel" : "Verification Question 11",
"aka" : "field180",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question12" : {
"fieldLabel" : "Verification Question 12",
"aka" : "field181",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question13" : {
"fieldLabel" : "Verification Question 13",
"aka" : "field182",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question14" : {
"fieldLabel" : "Verification Question 14",
"aka" : "field183",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_question15" : {
"fieldLabel" : "Verification Question 15",
"aka" : "field184",
"validation" : {
"fieldLength" : 3.0,
"collection" : "radiolist",
"items" : [ "Yes", "No" ],
"mandatory" : true
}
},
"ver_geotag" : {
"fieldLabel" : "Verification - Geotag",
"aka" : "field185",
"validation" : {
"fieldLength" : 1.0,
"collection" : "geotag",
"mandatory" : false
}
},
"ver_supp_selfie" : {
"fieldLabel" : "Verification - Selfie",
"aka" : "field186",
"validation" : {
"fieldLength" : 1.0,
"collection" : "image-capture",
"mandatory" : false
}
},
"ver_supp_proof_of_residency" : {
"fieldLabel" : "Verification - Proof of Residency",
"aka" : "field187",
"validation" : {
"fieldLength" : 1.0,
"collection" : "image-capture",
"mandatory" : false
}
},
"ver_supp_resident_pic" : {
"fieldLabel" : "Verification - Resident Picture",
"aka" : "field188",
"validation" : {
"fieldLength" : 1.0,
"collection" : "image-capture",
"mandatory" : false
}
},
"ver_supp_other1" : {
"fieldLabel" : "Verification - Other Supporting Docs1",
"aka" : "field189",
"validation" : {
"fieldLength" : 1.0,
"collection" : "alphanumeric",
"mandatory" : false
}
},
"ver_supp_other2" : {
"fieldLabel" : "Verification - Other Supporting Docs2",
"aka" : "field190",
"validation" : {
"fieldLength" : 1.0,
"collection" : "alphanumeric",
"mandatory" : false
}
},
"ver_supp_other3" : {
"fieldLabel" : "Verification - Other Supporting Docs3",
"aka" : "field191",
"validation" : {
"fieldLength" : 1.0,
"collection" : "alphanumeric",
"mandatory" : false
}
},
"verification_status" : {
"fieldLabel" : "Verification Status - Verified or Reject",
"aka" : "field192",
"validation" : {
"fieldLength" : 8.0,
"collection" : "radiolist",
"items" : [ "VERIFIED", "REJECTED" ],
"mandatory" : true
}
},
"verification_date" : {
"fieldLabel" : "Verification Date",
"aka" : "field193",
"validation" : {
"fieldLength" : 10.0,
"collection" : "datepicker",
"mandatory" : true
}
},
"verification_time" : {
"fieldLabel" : "Verification Time",
"aka" : "field194",
"validation" : {
"fieldLength" : 10.0,
"collection" : "timepicker",
"mandatory" : true
}
}
}
}
}
\ No newline at end of file
......@@ -24,4 +24,8 @@ public class Field {
this.no = no;
this.value = value;
}
public String getNo() {
return this.no;
}
}
......@@ -36,4 +36,8 @@ public class Record {
this.section = xml.getSection();
this.subRecord = new SubRecord(xml);
}
public SubRecord getSubRecord() {
return this.subRecord;
}
}
package com.svi.webgde.restservice.object;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.svi.webgde.restservice.utils.XMLUtil;
import com.thoughtworks.xstream.annotations.XStreamAlias;
......@@ -31,4 +33,46 @@ public class SubRecord {
this.eor = xml.getEor();
this.fields = XMLUtil.generateFields(xml);
}
/**
* Arrange the contents of the fields list based on the order specified in the pipe-delimited string.
*
* @param orderPipeDelimited Pipe-delimited string specifying the order.
*/
public void arrangeFields(String orderPipeDelimited) {
List<Field> sortedFields = fields.stream()
.sorted((f1, f2) -> {
if ("1".equals(f1.getNo())) {
return -1; // f1 comes before f2
} else if ("1".equals(f2.getNo())) {
return 1; // f2 comes before f1
} else {
return Integer.compare(getOrder(f1.getNo(), orderPipeDelimited),
getOrder(f2.getNo(), orderPipeDelimited));
}
})
.collect(Collectors.toList());
// Update the fields list with the sorted order
fields.clear();
fields.addAll(sortedFields);
}
/**
* Helper method to get the order of a field based on the pipe-delimited string.
*
* @param fieldNo The field number to get the order for.
* @param orderPipeDelimited The pipe-delimited string specifying the order.
* @return The order of the field.
*/
private int getOrder(String fieldNo, String orderPipeDelimited) {
String[] orderArray = orderPipeDelimited.split("\\|");
for (int i = 0; i < orderArray.length; i++) {
if (orderArray[i].equals(fieldNo)) {
return i;
}
}
// Default to a high value if not found (end of the list)
return orderArray.length;
}
}
package com.svi.webgde.restservice.object;
import java.util.LinkedHashMap;
import java.util.Map;
public class XMLContents {
......@@ -21,10 +22,19 @@ public class XMLContents {
private String imageName;
private int subRecordNo;
private String eor;
private Map<String, String> fields;
private Map<String, String> fields = new LinkedHashMap<>();;
private String outputDir;
private String doctype;
private String section;
private String fieldOrder;
public String getFieldOrder() {
return fieldOrder;
}
public void setFieldOrder(String fieldOrder) {
this.fieldOrder = fieldOrder;
}
public String getProjCode() {
return projCode;
......@@ -193,4 +203,5 @@ public class XMLContents {
public void setSection(String section) {
this.section = section;
}
}
......@@ -20,7 +20,10 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
......@@ -67,29 +70,41 @@ public class XMLUtil {
*/
public static String generateXML(XMLContents xml) throws TransformerException, ParserConfigurationException,
SAXException, IOException, XPathExpressionException {
XStream xs = new XStream(new DomDriver("ISO-8859-1", new XmlFriendlyNameCoder("_-", "_")));
XStream xs = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_")));
xs.alias(xml.getProjCode(), OutputXML.class);
xs.processAnnotations(Record.class);
Header header = new Header(xml);
Record record = new Record(xml);
record.getSubRecord().arrangeFields(xml.getFieldOrder());
OutputXML output = new OutputXML(header, record);
// SAXParserFactory spf = SAXParserFactory.newInstance();
// SAXParser sp = spf.newSAXParser();
// Source source = new SAXSource(sp.getXMLReader(),
// new InputSource(new StringReader(xs.toXML(output).replaceAll("(?<![^\\W_])[ ](?![^\\W_])", " "))));
// SAXParserFactory spf = SAXParserFactory.newInstance();
// SAXParser sp = spf.newSAXParser();
// Source source = new SAXSource(sp.getXMLReader(),
// new InputSource(new StringReader(xs.toXML(output).replaceAll("(?<![^\\W_])[
// ](?![^\\W_])", " "))));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(
new InputSource(new StringReader(xs.toXML(output).replaceAll("(?<![^\\W_])[ ](?![^\\W_])", " "))));
// Generate list of all empty Nodes, them remove them
XPath xp = XPathFactory.newInstance().newXPath();
NodeList nl = (NodeList) xp.evaluate("//text()[normalize-space(.)='']", document, XPathConstants.NODESET);
for (int i = 0; i < nl.getLength(); ++i) { // note the position of the '++'
Node node = nl.item(i);
node.getParentNode().removeChild(node);
}
DOMSource source = new DOMSource(document);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.STANDALONE, "no");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
......@@ -334,31 +349,41 @@ public class XMLUtil {
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xml.getOutputDir());
Node imagename = document.getElementsByTagName("imagename").item(0);
Node xmlSubRecord = imagename.getParentNode().getLastChild().getPreviousSibling();
Map<String, String> fields = new HashMap<>();
records.put("DocType", imagename.getParentNode().getFirstChild().getNextSibling().getNextSibling()
.getNextSibling().getTextContent());
records.put("Section", imagename.getParentNode().getFirstChild().getNextSibling().getNextSibling()
.getNextSibling().getNextSibling().getNextSibling().getTextContent());
records.put("fields", fields);
for (int i = 0; i < xmlSubRecord.getChildNodes().getLength(); i++) {
if (xmlSubRecord.getChildNodes().item(i).getNodeType() == Node.ELEMENT_NODE) {
for (int j = 0; j < xmlSubRecord.getChildNodes().item(i).getChildNodes().getLength(); j++) {
if (xmlSubRecord.getChildNodes().item(i).getChildNodes().item(j)
.getNodeType() == Node.ELEMENT_NODE) {
fields.put(
xmlSubRecord.getChildNodes().item(i).getAttributes().getNamedItem("no").getNodeValue(),
xmlSubRecord.getChildNodes().item(i).getChildNodes().item(j).getTextContent());
records.put("fields", fields);
}
}
}
}
Element record = (Element) document.getElementsByTagName("record").item(0);
if (record != null) {
records.put("DocType", getElementTextByTagName(record, "doctype"));
records.put("Section", getElementTextByTagName(record, "section"));
Map<String, String> fields = new HashMap<>();
records.put("fields", fields);
Element subRecord = (Element) record.getElementsByTagName("sub-record").item(0);
if (subRecord != null) {
NodeList fieldList = subRecord.getElementsByTagName("field");
for (int j = 0; j < fieldList.getLength(); j++) {
Element field = (Element) fieldList.item(j);
String noAttributeValue = field.getAttribute("no");
String textContentValue = field.getElementsByTagName("value").item(0).getTextContent();
if ("1".equals(noAttributeValue)) {
// Replace the value of "DocType" with the text content
records.put("DocType", textContentValue);
}
fields.put(noAttributeValue, textContentValue);
}
}
}
return records;
}
return records;
private static String getElementTextByTagName(Element parentElement, String tagName) {
NodeList elements = parentElement.getElementsByTagName(tagName);
if (elements.getLength() > 0) {
return elements.item(0).getTextContent();
}
return null; // or an appropriate default value
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment