Commit 9096c908 by Owen Ryan Ang

added formatting for date/time stamp. added deviceID to output

parent a035e517
...@@ -14,7 +14,7 @@ export async function returnElementBPO(elementId) { ...@@ -14,7 +14,7 @@ export async function returnElementBPO(elementId) {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeEnd", humanReadableTime); sessionStorage.setItem("timeEnd", humanReadableTime);
......
//Data Input Field Config //Data Input Field Config
export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/REG-INP.json"; export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/OTS.json";
// export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/dev_schema.json"; // export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/dev_schema.json";
export var IGNORE_CHAR_LIMIT = true; export var IGNORE_CHAR_LIMIT = true;
//DBLookup Webservice URL //DBLookup Webservice URL
......
...@@ -2614,7 +2614,7 @@ export async function clearForm() { ...@@ -2614,7 +2614,7 @@ export async function clearForm() {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime); sessionStorage.setItem("timeStart", humanReadableTime);
......
...@@ -3,8 +3,8 @@ import { createInfoModal } from "../genericPopup/genericPopup"; ...@@ -3,8 +3,8 @@ import { createInfoModal } from "../genericPopup/genericPopup";
// export const submitForm = (e) => { // export const submitForm = (e) => {
try { try {
console.log("submit"); console.log("submit");
global_end_time = new Date().toLocaleString(); global_end_time = new Date().toLocaleString('en-US');
let eoe_ts = new Date().toLocaleString(); let eoe_ts = new Date().toLocaleString('en-US');
const Form = Settings.SrcElement(e); const Form = Settings.SrcElement(e);
const { elements } = Form const { elements } = Form
let error = false let error = false
......
...@@ -286,7 +286,7 @@ const validateReturnAlphabet = (validation, value) => { ...@@ -286,7 +286,7 @@ const validateReturnAlphabet = (validation, value) => {
*/ */
const validateNumeric = (validation, value) => { const validateNumeric = (validation, value) => {
// Adjusted pattern to allow digits, plus, parenthesis, hyphen, and space // Adjusted pattern to allow digits, plus, parenthesis, hyphen, and space
const PATTERN_NUMERIC = /[^0-9+\-(). ]/g; const PATTERN_NUMERIC = /[^0-9+\-(). ]/g;
let errors = []; let errors = [];
const { mandatory, fieldLength } = validation; const { mandatory, fieldLength } = validation;
......
...@@ -366,7 +366,7 @@ export class ElementListWidget { ...@@ -366,7 +366,7 @@ export class ElementListWidget {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime); sessionStorage.setItem("timeStart", humanReadableTime);
......
...@@ -458,7 +458,7 @@ export class ElementListWidget { ...@@ -458,7 +458,7 @@ export class ElementListWidget {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime); sessionStorage.setItem("timeStart", humanReadableTime);
......
...@@ -2,5 +2,5 @@ export const PROJECT_CODE = "DSQC"; ...@@ -2,5 +2,5 @@ export const PROJECT_CODE = "DSQC";
export const ENCODING_PASS = "PASS1"; export const ENCODING_PASS = "PASS1";
export const GFS_URL = "http://107.20.193.188/gfs-explorer-ws/svc/gfs-rest/"; export const GFS_URL = "http://107.20.193.188/gfs-explorer-ws/svc/gfs-rest/";
export const TEMPORARY_FOLDER = "C:/Users/oang/Desktop/Mobile GDE/Elements"; export const TEMPORARY_FOLDER = "/home/OTS_ELEMENTS";
export const GFS_ROOT_FOLDER = "/Users"; export const GFS_ROOT_FOLDER = "/Users";
\ No newline at end of file
...@@ -18,7 +18,7 @@ export const submitForm = async () => { ...@@ -18,7 +18,7 @@ export const submitForm = async () => {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeEnd", humanReadableTime); sessionStorage.setItem("timeEnd", humanReadableTime);
......
...@@ -34,7 +34,7 @@ export const startMetricCapture = () => { ...@@ -34,7 +34,7 @@ export const startMetricCapture = () => {
key_strokes = 0 key_strokes = 0
time_start = Date.now() time_start = Date.now()
if (global_start_time == 0) { if (global_start_time == 0) {
global_start_time = new Date().toLocaleString(); global_start_time = new Date().toLocaleString('en-US');
} }
time_pause_spent = 0 time_pause_spent = 0
...@@ -328,7 +328,7 @@ const startMetricCapture = () => { ...@@ -328,7 +328,7 @@ const startMetricCapture = () => {
key_strokes = 0 key_strokes = 0
time_start = Date.now() time_start = Date.now()
if (global_start_time == 0) { if (global_start_time == 0) {
global_start_time = new Date().toLocaleString(); global_start_time = new Date().toLocaleString('en-US');
} }
time_pause_spent = 0 time_pause_spent = 0
......
...@@ -23,14 +23,14 @@ export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen, ...@@ -23,14 +23,14 @@ export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen,
export const OUTPUT_FILE_EXTENSION = ".DTA" export const OUTPUT_FILE_EXTENSION = ".DTA"
//BPO CONFIG //BPO CONFIG
export const IS_RETRIEVE_FROM_BPO = "Y" export const IS_RETRIEVE_FROM_BPO = "N"
export let BPO_URL = DOMAIN + "bpo/"; export let BPO_URL = DOMAIN + "bpo/";
export let CURRENT_NODE = "" export let CURRENT_NODE = ""
export const ENCODING_PASS = "PASS1" export const ENCODING_PASS = "PASS1"
export const PROD_OUTPUT_UNIT = "INSPECTION" export const PROD_OUTPUT_UNIT = "INSPECTION"
export const NEXT_NODE = "INSPECTED" export const NEXT_NODE = "INSPECTED"
export const EXCEPTION_NODE = "CANCELLED" export const EXCEPTION_NODE = "CANCELLED"
export const SHOW_ELEMENT_LIST_VIEWER = "Y" export const SHOW_ELEMENT_LIST_VIEWER = "N"
export const ADD_NEW_OPTION = "N" export const ADD_NEW_OPTION = "N"
export const DISPLAYED_DETAILS = "inspectionType|businessAddress" //pipe-delimited export const DISPLAYED_DETAILS = "inspectionType|businessAddress" //pipe-delimited
export const USERID_FIELD = "inspectorUsername" export const USERID_FIELD = "inspectorUsername"
......
...@@ -43,7 +43,7 @@ async function initializeWebGDE() { ...@@ -43,7 +43,7 @@ async function initializeWebGDE() {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime); sessionStorage.setItem("timeStart", humanReadableTime);
......
...@@ -25,4 +25,4 @@ PASSWORD=p455w0rd ...@@ -25,4 +25,4 @@ PASSWORD=p455w0rd
[SSO CONFIG] [SSO CONFIG]
PUBKEY = C:/Users/oang/git/web-ui-mobile2/WebContent/WEB-INF/config/sso/pubkey.pem PUBKEY = /home/payara5/Control Folder Live/SSO-QC/key/pub.pem
\ No newline at end of file \ No newline at end of file
import { resetGDE } from "../../script.js"; import { resetGDE } from "../../script.js";
import { submitElementToSqLite } from "../DataInputWidget/AndroidInterface/androidInterface.js"; import { getDeviceId, submitElementToSqLite } from "../DataInputWidget/AndroidInterface/androidInterface.js";
import { SCHEMA_FILE_PATH } from "../DataInputWidget/config.js"; import { SCHEMA_FILE_PATH } from "../DataInputWidget/config.js";
import { validateInput } from "../DataInputWidget/validateInput.js"; import { validateInput } from "../DataInputWidget/validateInput.js";
import { goBackToElementListViewer } from "../ElementListWidget/ElementListWidget.js"; import { goBackToElementListViewer } from "../ElementListWidget/ElementListWidget.js";
...@@ -311,32 +311,45 @@ function saveExceptionToXml(){ ...@@ -311,32 +311,45 @@ function saveExceptionToXml(){
continue; continue;
} }
} }
let xmlData = {
"projCode": PROJECT_CODE,
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE_PATH,
"totalRec": 1,
"maxRec": "1",
"totalKeystroke": 0,
"procTime": "",
"procDuration": 0,
"eob": "",
"exceptionRemark": selected,
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": "",
"subRecordNo": "1",
"eor": "N",
"fields": {},
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + (ENCODING_PASS == "PASS1" ? elementId + ".DTA" : elementId + ".DTB"),
"doctype": doctype,
"section": section
}
return updateXMLException(xmlData); var Frm= document.getElementById("fields");
var Nodes=Frm.elements;
let fields = {};
for (var i = 0; i < Nodes.length; i++) {
var element = Nodes[i];
if (element.classList.contains('deviceid')){
let fid = Nodes[i].id;
let key = Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid;
fields[key] = Nodes[i].value;
}
}
let xmlData = {
"projCode": PROJECT_CODE,
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE_PATH,
"totalRec": 1,
"maxRec": "1",
"totalKeystroke": 0,
"procTime": "",
"procDuration": 0,
"eob": "",
"exceptionRemark": selected,
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": "",
"subRecordNo": "1",
"eor": "N",
"fields": fields,
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + (ENCODING_PASS == "PASS1" ? elementId + ".DTA" : elementId + ".DTB"),
"doctype": doctype,
"section": section
}
return updateXMLException(xmlData);
// return false; // return false;
} }
......
...@@ -14,7 +14,7 @@ export async function returnElementBPO(elementId) { ...@@ -14,7 +14,7 @@ export async function returnElementBPO(elementId) {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeEnd", humanReadableTime); sessionStorage.setItem("timeEnd", humanReadableTime);
......
//Data Input Field Config //Data Input Field Config
export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/REG-INP.json"; export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/REG-INP.json";
export var FETCH_FROM_DB = true; // export var SCHEMA_FILE_PATH = "./WebGde-Widgets/sample_schema/dev_schema.json";
export var IGNORE_CHAR_LIMIT = true; export var IGNORE_CHAR_LIMIT = true;
//DBLookup Webservice URL //DBLookup Webservice URL
export var DB_URL = "http://localhost:8080/WebGde/svc/gfs-rest/db-lookup" export var DB_URL = "http://localhost:8080/WebGde/svc/gfs-rest/db-lookup"
\ No newline at end of file
...@@ -2466,6 +2466,12 @@ export async function populateFields(inputFieldData) { ...@@ -2466,6 +2466,12 @@ export async function populateFields(inputFieldData) {
console.log("key = " + key + ", value =" + v); console.log("key = " + key + ", value =" + v);
//console.log("validation: " + schema[doctype][section][key].validation.collection); //console.log("validation: " + schema[doctype][section][key].validation.collection);
if (v === "null") {
v = "";
} else if (v == null && schema[doctype][section][key].validation.collection === 'numeric') {
v = 0;
}
fields["field" + k] = v; fields["field" + k] = v;
if (schema[doctype][section][key].hidden) { if (schema[doctype][section][key].hidden) {
...@@ -2614,7 +2620,7 @@ export async function clearForm() { ...@@ -2614,7 +2620,7 @@ export async function clearForm() {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime); sessionStorage.setItem("timeStart", humanReadableTime);
......
...@@ -3,8 +3,8 @@ import { createInfoModal } from "../genericPopup/genericPopup"; ...@@ -3,8 +3,8 @@ import { createInfoModal } from "../genericPopup/genericPopup";
// export const submitForm = (e) => { // export const submitForm = (e) => {
try { try {
console.log("submit"); console.log("submit");
global_end_time = new Date().toLocaleString(); global_end_time = new Date().toLocaleString('en-US');
let eoe_ts = new Date().toLocaleString(); let eoe_ts = new Date().toLocaleString('en-US');
const Form = Settings.SrcElement(e); const Form = Settings.SrcElement(e);
const { elements } = Form const { elements } = Form
let error = false let error = false
......
...@@ -286,7 +286,7 @@ const validateReturnAlphabet = (validation, value) => { ...@@ -286,7 +286,7 @@ const validateReturnAlphabet = (validation, value) => {
*/ */
const validateNumeric = (validation, value) => { const validateNumeric = (validation, value) => {
// Adjusted pattern to allow digits, plus, parenthesis, hyphen, and space // Adjusted pattern to allow digits, plus, parenthesis, hyphen, and space
const PATTERN_NUMERIC = /[^0-9+\-(). ]/g; const PATTERN_NUMERIC = /[^0-9+\-(). ]/g;
let errors = []; let errors = [];
const { mandatory, fieldLength } = validation; const { mandatory, fieldLength } = validation;
......
...@@ -366,7 +366,7 @@ export class ElementListWidget { ...@@ -366,7 +366,7 @@ export class ElementListWidget {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime); sessionStorage.setItem("timeStart", humanReadableTime);
......
...@@ -458,7 +458,7 @@ export class ElementListWidget { ...@@ -458,7 +458,7 @@ export class ElementListWidget {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime); sessionStorage.setItem("timeStart", humanReadableTime);
......
...@@ -18,7 +18,7 @@ export const submitForm = async () => { ...@@ -18,7 +18,7 @@ export const submitForm = async () => {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeEnd", humanReadableTime); sessionStorage.setItem("timeEnd", humanReadableTime);
......
...@@ -34,7 +34,7 @@ export const startMetricCapture = () => { ...@@ -34,7 +34,7 @@ export const startMetricCapture = () => {
key_strokes = 0 key_strokes = 0
time_start = Date.now() time_start = Date.now()
if (global_start_time == 0) { if (global_start_time == 0) {
global_start_time = new Date().toLocaleString(); global_start_time = new Date().toLocaleString('en-US');
} }
time_pause_spent = 0 time_pause_spent = 0
...@@ -328,7 +328,7 @@ const startMetricCapture = () => { ...@@ -328,7 +328,7 @@ const startMetricCapture = () => {
key_strokes = 0 key_strokes = 0
time_start = Date.now() time_start = Date.now()
if (global_start_time == 0) { if (global_start_time == 0) {
global_start_time = new Date().toLocaleString(); global_start_time = new Date().toLocaleString('en-US');
} }
time_pause_spent = 0 time_pause_spent = 0
......
...@@ -27,7 +27,7 @@ export const IS_RETRIEVE_FROM_BPO = "Y" ...@@ -27,7 +27,7 @@ export const IS_RETRIEVE_FROM_BPO = "Y"
export let BPO_URL = DOMAIN + "bpo/"; export let BPO_URL = DOMAIN + "bpo/";
export let CURRENT_NODE = "" export let CURRENT_NODE = ""
export const ENCODING_PASS = "PASS1" export const ENCODING_PASS = "PASS1"
export const PROD_OUTPUT_UNIT = "INSPECTION" export const PROD_OUTPUT_UNIT = "DOC"
export const NEXT_NODE = "INSPECTED" export const NEXT_NODE = "INSPECTED"
export const EXCEPTION_NODE = "CANCELLED" export const EXCEPTION_NODE = "CANCELLED"
export const SHOW_ELEMENT_LIST_VIEWER = "Y" export const SHOW_ELEMENT_LIST_VIEWER = "Y"
......
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
"fieldLabel" : "Business Permit No.", "fieldLabel" : "Business Permit No.",
"aka" : "field7", "aka" : "field7",
"validation" : { "validation" : {
"fieldLength" : 10.0, "fieldLength" : 30.0,
"collection" : "numeric", "collection" : "alphanumeric",
"mandatory" : true "mandatory" : true
}, },
"readOnly" : true "readOnly" : true
......
{
"_attributes": {
"readOnly":false,
"docTypeHidden":true,
"sectionHidden":true
},
"DOCUMENT": {
"Section": {
"del_receipt1": {
"fieldLabel": "Delivery Receipt Page 1",
"aka": "field2",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"del_receipt2": {
"fieldLabel": "Delivery Receipt Page 2",
"aka": "field3",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"del_receipt3": {
"fieldLabel": "Delivery Receipt Page 3",
"aka": "field4",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"buyer_info": {
"fieldLabel": "Buyer Information Sheet",
"aka": "field5",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"ltms1": {
"fieldLabel": "LTMS Page 1",
"aka": "field6",
"validation": {
"fieldLength": 1.0,
"collection": "file-upload",
"validDate": "",
"mandatory": false
}
},
"ltms2": {
"fieldLabel": "LTMS Page 2",
"aka": "field7",
"validation": {
"fieldLength": 1.0,
"collection": "file-upload",
"validDate": "",
"mandatory": false
}
},
"sales_invoice": {
"fieldLabel": "Sales Invoice",
"aka": "field8",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"ctpl": {
"fieldLabel": "CTPL",
"aka": "field9",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"affidavit": {
"fieldLabel": "Affidavit of Sidecar Attachment",
"aka": "field10",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"loan_form1": {
"fieldLabel": "Loan Application Form Page 1",
"aka": "field11",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"loan_form2": {
"fieldLabel": "Loan Application Form Page 2",
"aka": "field12",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
},
"loan_form3": {
"fieldLabel": "Loan Application Form Page 3",
"aka": "field13",
"validation": {
"fieldLength": 1.0,
"collection": "image-capture",
"validDate": "",
"mandatory": false
}
}
}
}
}
...@@ -43,7 +43,7 @@ async function initializeWebGDE() { ...@@ -43,7 +43,7 @@ async function initializeWebGDE() {
// Get current timestamp // Get current timestamp
const currentTimeStamp = Date.now(); const currentTimeStamp = Date.now();
const currentDate = new Date(currentTimeStamp); const currentDate = new Date(currentTimeStamp);
const humanReadableTime = currentDate.toLocaleString(); const humanReadableTime = currentDate.toLocaleString('en-US');
// Save to session storage // Save to session storage
sessionStorage.setItem("timeStart", humanReadableTime); sessionStorage.setItem("timeStart", humanReadableTime);
......
...@@ -294,6 +294,57 @@ public class XMLUtil { ...@@ -294,6 +294,57 @@ public class XMLUtil {
Document document = builder.parse(xml.getOutputDir()); Document document = builder.parse(xml.getOutputDir());
document.getElementsByTagName("exception_remark").item(0).setTextContent(xml.getExceptionRemark()); document.getElementsByTagName("exception_remark").item(0).setTextContent(xml.getExceptionRemark());
document.getElementsByTagName("userid").item(0).setTextContent(xml.getUserId());
// Get the fields map from the XMLContents object
Map<String, String> fields = xml.getFields();
// Get the list of field elements
NodeList fieldNodes = document.getElementsByTagName("field");
// Track which field numbers already exist in the XML
Map<String, Element> existingFields = new HashMap<>();
for (int i = 0; i < fieldNodes.getLength(); i++) {
Element fieldElement = (Element) fieldNodes.item(i);
String fieldNumber = fieldElement.getAttribute("no");
existingFields.put(fieldNumber, fieldElement);
}
// Get the parent node where new fields should be appended (e.g., sub-record)
Node subRecordNode = document.getElementsByTagName("sub-record").item(0);
// Iterate through the fields map
for (Map.Entry<String, String> entry : fields.entrySet()) {
String fieldNumber = entry.getKey();
String fieldValue = entry.getValue();
// Check if the field already exists
if (existingFields.containsKey(fieldNumber)) {
// Field exists, update the value
Element fieldElement = existingFields.get(fieldNumber);
NodeList valueNodes = fieldElement.getElementsByTagName("value");
if (valueNodes.getLength() > 0) {
valueNodes.item(0).setTextContent(fieldValue);
} else {
// If <value> element doesn't exist, create it
Element valueElement = document.createElement("value");
valueElement.setTextContent(fieldValue);
fieldElement.appendChild(valueElement);
}
} else {
// Field doesn't exist, create and append it
Element newFieldElement = document.createElement("field");
newFieldElement.setAttribute("no", fieldNumber);
Element valueElement = document.createElement("value");
valueElement.setTextContent(fieldValue);
newFieldElement.appendChild(valueElement);
// Append the new field to the sub-record node
subRecordNode.appendChild(newFieldElement);
}
}
TransformerFactory transformerFactory = TransformerFactory.newInstance(); TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(); Transformer transformer = transformerFactory.newTransformer();
......
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