Commit d6bd16cc by Jorem Magcawas

Merge branch 'feature-merge-branch' into 'feature-UI_construction'

# Conflicts: # WebGde/WebContent/src/tiffViewer/tiffViewer.js # WebGde/WebContent/style.css
parents 3af64547 8f42e223
......@@ -26,7 +26,23 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
......
......@@ -34,4 +34,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
<filteredResources>
<filter>
<id>1675315043043</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
......@@ -7,5 +7,6 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="WebGde-0.0.1-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/annotations"/>
<property name="java-output-path" value="/WebGde/build/classes"/>
<property name="context-root" value="WebGde"/>
</wb-module>
</project-modules>
async function initGetElement() {
const elements = [...(await getWorkload())].reverse();
for(const element of elements) {
for (const element of elements) {
const retElement = await getReturnedElement(element);
if (retElement.errorCode == 0) {
......@@ -10,10 +10,9 @@ async function initGetElement() {
const xml = await isXMLExisting(retElement.element);
if (xml.isExisting) {
const xmlString = await [...xml.data].join('').replace('\t','');
const xmlString = await [...xml.data].join('').replace('\t', '');
const lastImage = getXmlLastImage(xmlString);
console.log('xmlString:' + xmlString);
sessionStorage.setItem('section', getXmlSection(xmlString));
sessionStorage.setItem('doctype', getXmlDocType(xmlString));
......@@ -71,25 +70,41 @@ async function isLSTExisting(element) {
const response = await fetch(urlGetIfExisting, {
method: "POST",
headers: {
'Content-Type':'application/json'
'Content-Type': 'application/json'
},
body: JSON.stringify({ "filePath": `${element.fileLocation}/${element.elementId}.lst` })
body: JSON.stringify({
"filePath": `${element.fileLocation}/${element.elementId}.lst`
})
});
return await response.json();
}
//var folderLoc = `${element.fileLocation}` + "worker1" + "/" + "element1";
//getFolderLst(folderLoc);
// const response = await fetch()
//var folderLoc = `${element.fileLocation}` + "worker1" + "/" + "element1";
//getFolderLst(folderLoc);
// const response = await fetch()
async function isXMLExisting(element) {
const response = await fetch(urlGetIfExisting, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"filePath": `${element.fileLocation}/${element.elementId}.${ENCODING_PASS == "PASS1" ? "DTA" : "DTB"}`
})
});
return await response.json();
}
async function getFieldXml(element) {
const response = await fetch(urlGetXml, {
method: "POST",
headers: {
'Content-Type':'application/json'
'Content-Type': 'application/json'
},
body: JSON.stringify({ "filePath": `${element.fileLocation}/${element.elementId}.${ENCODING_PASS == "PASS1" ? "DTA" : "DTB"}` })
body: JSON.stringify({
"filePath": `${element.fileLocation}/${element.elementId}.${ENCODING_PASS == "PASS1" ? "DTA" : "DTB"}`
})
});
return await response.json();
}
......@@ -99,7 +114,9 @@ function formatDirectory(dir) {
}
async function returnElement(element) {
let response = await fetch(getUrlReturnElement(element.elementId), {method: "POST"});
let response = await fetch(getUrlReturnElement(element.elementId), {
method: "POST"
});
if (response.status != 200) {
alert(`Error ${response.status}: Returning element`)
......@@ -194,12 +211,12 @@ async function createOutputXml(fields, metrics, doctype, section) {
let response = await fetch(urlWriteXml, {
method: "POST",
headers: {
'Content-Type':'application/json'
'Content-Type': 'application/json'
},
body: JSON.stringify(xmlData)
});
/*if (localStorage.getItem("complete") == 1) {*/
if (localStorage.getItem("complete") == 1) {
if (completenessCheck(await response.text())) {
let response = await fetch(urlUpdateEob, {
method: "POST",
......@@ -210,7 +227,7 @@ async function createOutputXml(fields, metrics, doctype, section) {
});
await completeToNextNode(elementId);
}
/* }*/
}
}
......@@ -253,7 +270,7 @@ async function completeToNextNode(elementId) {
}
function getFolderLst(url){
function getFolderLst(url) {
const promise = fetch(url, {
method: 'GET',
headers: {
......@@ -261,8 +278,8 @@ function getFolderLst(url){
// 'Content-Type': 'application/x-www-form-urlencoded',
}
})
.then(function (response) {
if(response.status === 200){
.then(function(response) {
if (response.status === 200) {
response.json().then(function(data) {
let temp = data.folderContent;
// temp.forEach(function(obj){
......@@ -277,7 +294,7 @@ function getFolderLst(url){
overlay.id = "containerModal" + i;
overlay.style.display = 'none';
container.append(overlay);
if(temp[i].name.includes(contain)){//contains
if (temp[i].name.includes(contain)) { //contains
console.log(temp[i].name);
}
// getFiles(DOWNLOAD_URL,temp[i].fileId,overlay,temp[i].name);
......@@ -287,25 +304,27 @@ function getFolderLst(url){
var currDislplay = document.getElementById("containerModal" + sessionStorage.getItem('gfsCounter'));
currDislplay.style.display = 'block';
});
}else{
} else {
console.log("Error");
}
})
.catch(function (error) {
.catch(function(error) {
console.log('Request failed', error);
});
return promise;
}
async function getFileLst(url,id,overlay,filename){
async function getFileLst(url, id, overlay, filename) {
console.log(url);
var myObject = {fileId : id};
var myObject = {
fileId: id
};
fetch(url, {
method: 'POST',
headers: {
'Authorization': sessionStorage.getItem('token'),
'Content-Type':'application/json'
'Content-Type': 'application/json'
},
body: JSON.stringify(myObject)
})
......@@ -316,7 +335,7 @@ async function getFileLst(url,id,overlay,filename){
fileReader.onload = function() {
console.log(this.result);
var fileReader = new FileReader();
fileReader.onload = function () {
fileReader.onload = function() {
// File_Name = filename;
console.log(filename);
// tiffViewerTest(this.result, overlay, filename);
......@@ -328,7 +347,7 @@ async function getFileLst(url,id,overlay,filename){
});
})
.catch(function (error) {
.catch(function(error) {
console.log('Request failed', error);
});
}
......@@ -342,16 +361,39 @@ function getBlobService(url, func) {
})
.then(function(response) {
switch (response.status) {
case 200: response.blob().then(function(data) { func(data); }); break;
case 460: createInfoPopup("Error 460", "User does not exist."); break;
case 403: removeOverlay(); createInfoPopup("We are so sorry...", "Permission Denied: You don't have access here."); break;
case 464: createInfoPopup("Error 464", "No folder was retrieved."); break;
case 463: createInfoPopup("Error 463", "The folder name you entered already exists."); break;
case 462: createInfoPopup("Error 462", "No file was retrieved."); break;
case 461: createInfoPopup("Error 461", "File already exists."); break;
case 465: createInfoPopup("Error 465", "Source not found"); break;
case 500: removeOverlay(); createInfoPopup("It's not you. It's us... So sorry.", "Error 500: Please contact the support team so we can fix this immediately."); break;
default: break;
case 200:
response.blob().then(function(data) {
func(data);
});
break;
case 460:
createInfoPopup("Error 460", "User does not exist.");
break;
case 403:
removeOverlay();
createInfoPopup("We are so sorry...", "Permission Denied: You don't have access here.");
break;
case 464:
createInfoPopup("Error 464", "No folder was retrieved.");
break;
case 463:
createInfoPopup("Error 463", "The folder name you entered already exists.");
break;
case 462:
createInfoPopup("Error 462", "No file was retrieved.");
break;
case 461:
createInfoPopup("Error 461", "File already exists.");
break;
case 465:
createInfoPopup("Error 465", "Source not found");
break;
case 500:
removeOverlay();
createInfoPopup("It's not you. It's us... So sorry.", "Error 500: Please contact the support team so we can fix this immediately.");
break;
default:
break;
}
})
.catch(function(error) {
......@@ -359,7 +401,5 @@ function getBlobService(url, func) {
createInfoPopup("Whoops!", "We encountered some problems with your request. Rest assured we're working on this and it'll be okay soon.");
});
return promise;
}
\ No newline at end of file
......@@ -11,6 +11,44 @@ async function rejectElement() {
body: JSON.stringify(load)
});
if (response.status == 200) {
const indexedDB =
window.indexedDB ||
window.mozIndexedDB ||
window.webkitIndexedDB ||
window.msIndexedDB ||
window.shimIndexedDB;
const request = indexedDB.open("ImageDatabase", 1);
request.onsuccess = function () {
const db = request.result;
const delRequest = db.transaction("image", 'readwrite')
.objectStore("image")
.clear();
};
[...document.getElementsByClassName("TiffModalContent")].forEach(el => {
while (el.children[1].hasChildNodes()) {
el.children[1].removeChild(el.children[1].firstChild);
}
while (el.children[2].hasChildNodes()) {
el.children[2].removeChild(el.children[2].firstChild);
}
while (el.children[3].hasChildNodes()) {
el.children[3].removeChild(el.children[3].firstChild);
}
});
[...document.getElementsByClassName("bar")].forEach(el => {
el.style.removeProperty('display');
});
document.getElementById("counter").innerHTML = "";
clearTimeout(interval);
sessionStorage.removeItem("section");
sessionStorage.removeItem("doctype");
isCanvasNotCreated = true;
localStorage.clear();
Current_page = 0;
await initGetElement();
init();
alert("Element Rejected");
......@@ -207,6 +245,27 @@ function saveExceptionToXml(){
var selected = document.querySelector('input[name="rejectRadio"]:checked').value;
var elementId = sessionStorage.getItem("element_id");
let doctype;
let section;
// Validate all elements again
for(let element of document.getElementById("fields").elements) {
if (element.style.display === 'none') continue
const { id, value,type } = element
const { valid } = validateInput(id, value)
// Skip submit button
if(type==='submit') continue
if(id==='DocType') {
doctype = element.options[element.selectedIndex].text;
continue;
}
if(id==='Section') {
section = element.options[element.selectedIndex].text;
continue;
}
}
let xmlData = {
"projCode": PROJECT_CODE,
"userId": sessionStorage.getItem("user_id"),
......@@ -227,8 +286,8 @@ function saveExceptionToXml(){
"eor": "",
"fields": {},
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + (ENCODING_PASS == "PASS1" ? elementId + ".DTA" : elementId + ".DTB"),
"doctype": "",
"section": ""
"doctype": doctype,
"section": section
}
updateXMLException(xmlData);
......@@ -280,7 +339,7 @@ async function updateXMLException(xmlData){
body: JSON.stringify(xmlData)
});
if (response.status == 200) {
alert("Exception Updated");
console.log("Exception Updated");
}
else{
alert(`Error ${response.status}: Xml Update`);
......
......@@ -3,6 +3,44 @@ async function returnElementBPO(elementId) {
if (response.status == 200) {
saveExceptionToXml();
const indexedDB =
window.indexedDB ||
window.mozIndexedDB ||
window.webkitIndexedDB ||
window.msIndexedDB ||
window.shimIndexedDB;
const request = indexedDB.open("ImageDatabase", 1);
request.onsuccess = function () {
const db = request.result;
const delRequest = db.transaction("image", 'readwrite')
.objectStore("image")
.clear();
};
[...document.getElementsByClassName("TiffModalContent")].forEach(el => {
while (el.children[1].hasChildNodes()) {
el.children[1].removeChild(el.children[1].firstChild);
}
while (el.children[2].hasChildNodes()) {
el.children[2].removeChild(el.children[2].firstChild);
}
while (el.children[3].hasChildNodes()) {
el.children[3].removeChild(el.children[3].firstChild);
}
});
[...document.getElementsByClassName("bar")].forEach(el => {
el.style.removeProperty('display');
});
document.getElementById("counter").innerHTML = "";
clearTimeout(interval);
sessionStorage.removeItem("section");
sessionStorage.removeItem("doctype");
isCanvasNotCreated = true;
localStorage.clear();
Current_page = 0;
await loadWaitingElement();
init();
alert('Element Returned');
......
......@@ -3,23 +3,16 @@ var File_Path;
var gfsFileName;
async function accessFile() {
var button = 0;
var size = 0;
let file_url = [];
const elStatus = document.getElementById('status');
function status(text) {
elStatus.innerHTML = text;
}
const progressBar = document.getElementById('progressBar');
const elProgress = document.getElementById('progress');
function progress({ loaded, total }) {
// elProgress.innerHTML = Math.round(loaded * .000001) + " mb of " + Math.round(total * .000001);
progressBar.value = Math.round(loaded / total * 100);
}
const indexedDB =
window.indexedDB ||
window.mozIndexedDB ||
......@@ -44,14 +37,6 @@ async function accessFile() {
store.createIndex("image_address", ["address"], { unique: false });
};
request.onsuccess = function () {
const db = request.result;
const delRequest = db.transaction("image", 'readwrite')
.objectStore("image")
.clear();
}
async function main(img) {
const request = indexedDB.open("ImageDatabase", 1);
request.onsuccess = async function () {
......
......@@ -27,11 +27,31 @@ const displayFields = async (parentID) => {
clearFields(parentID) // make sure input fields are clear
await fetchSchema()
await fetchSchema();
console.log(schema);
createDocTypeDropdown('DocType', div, schema)
createSection('Section', div)
/* Object.keys(schema).forEach(function(key) {
let doctypes = schema[key];
const { valid, error } = validateSchema(key)
if(!valid){
div.textContent = error
div.style.color = '#ff3333'
}
for (let key in doctypes) {
if (doctypes.hasOwnProperty(key)) {
console.log(key + ": " + doctypes[key]); //sections on doctypes
let section = doctypes[key];
console.log(section);
div = deconstruct(section, div, key)
}
}
});*/
const { ACCOUNTING_DOCUMENTS } = schema
//getDocType = DOC_TYPE1 ;
......@@ -51,10 +71,6 @@ const displayFields = async (parentID) => {
const { SECTION3 } = HR_FILES
div = deconstruct(SECTION3, div, 'SECTION3')
if(!valid){
div.textContent = error
div.style.color = '#ff3333'
}
const submit = document.createElement('input')
submit.classList.add("submitButtons");
......@@ -221,6 +237,7 @@ const inputString = (key, validation) => {
let input = document.createElement('input')
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.setAttribute('type', 'text')
input.setAttribute('autocomplete', 'off')
input.addEventListener('focusout', handleInput)
......@@ -283,6 +300,7 @@ const inputNumeric = (key, validation) => {
const input = document.createElement('input')
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.setAttribute('type', 'text')
input.setAttribute('autocomplete', 'off')
input.setAttribute('pattern', '[0-9/-]+')
......@@ -313,6 +331,7 @@ const inputDate = (key, validation) => {
const input = document.createElement('input')
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.setAttribute('type', 'date')
input.addEventListener('focusout', handleInput)
......@@ -339,6 +358,7 @@ const inputDropdown = (key, validation) => {
const { mandatory, options } = validation
const input = document.createElement('select')
input.setAttribute('id', `${key}`)
input.setAttribute('name', `${key}`)
input.classList.add('dropdown-input')
input.addEventListener('focusout', handleInput)
......@@ -607,22 +627,23 @@ const createSection = (fieldLabel, div) => {
}
function saveForm(index){
const form = document.querySelector("#fields");
const inputs = form.querySelectorAll("input,textarea");
const values = {};
let formValues = {
name : document.getElementById("Name").value,
subject : document.getElementById("Subject").value,
docNo : document.getElementById("Document_No").value,
date : document.getElementById("Date").value,
accountNo : document.getElementById("Account_No").value,
empNo : document.getElementById("Employee_No").value,
inputs.forEach(input => {
if(input.value != ''){
values[input.name] = input.value;
}
});
index--;
var formArray = JSON.parse(sessionStorage.getItem('formArray'));
//formArray.push(formValues);
if(typeof formArray[index] !== 'undefined') {
formArray.splice(index, 1, formValues)
formArray.splice(index, 1, values)
} else {
formArray.splice(index, 0, formValues)
formArray.splice(index, 0, values)
}
sessionStorage.setItem('formArray', JSON.stringify(formArray));
......@@ -637,36 +658,13 @@ function populateForm(index){
var formArray = JSON.parse(sessionStorage.getItem('formArray'));
var name = document.getElementById("Name");
var subject = document.getElementById("Subject");
var docNo = document.getElementById("Document_No");
var date = document.getElementById("Date");
var accountNo = document.getElementById("Account_No");
var empNo = document.getElementById("Employee_No");
if (formArray[index].name != null) {
name.value = formArray[index].name;
}
if (formArray[index].subject != null) {
subject.value = formArray[index].subject;
}
if (formArray[index].docNo != null) {
docNo.value = formArray[index].docNo;
if (formArray[index] != null) {
var currForm = formArray[index];
for (let field in currForm) {
document.getElementById(field).value = currForm[field];
}
if (formArray[index].date != null) {
date.value = formArray[index].date;
}
if (formArray[index].accountNo != null) {
accountNo.value = formArray[index].accountNo;
}
if (formArray[index].empNo != null) {
empNo.value = formArray[index].empNo;
}
}
\ No newline at end of file
......@@ -182,8 +182,6 @@ function initHighlight() {
//waits until TIFF image is loaded, since its size is based on the displayed TIFF image
const observer = new MutationObserver(function (mutations, mutationInstance) {
console.log(sessionStorage.getItem("TiffViewer_current"));
var TIFFimg = document.getElementById(sessionStorage.getItem("TiffViewer_current"));
if (TIFFimg != null) {
//waits until width and height has been assigned
......
......@@ -316,29 +316,30 @@ function TIFFViewer(xhr, TiffViewerImageName) {
document.getElementById('TestTIFFDisplay').src = tiff.toCanvas().toDataURL();
//creating blank image containers for each page and setting TIFF data as image source
for (var i = 0; i < TiffViewer_pages; ++i) {
for (var i = 1; i <= TiffViewer_pages; i++) {
var img = document.createElement('img');
img.id = `IMG${i + 1}`;
if (i != 0) {
img.id = `IMG${i}`;
if (i != 1) {
img.style.display = "none";
wzoom[TiffViewer_current - 1] = changedwidth; /*ADDED: to fit large TIFF files*/
hzoom[TiffViewer_current - 1] = changedheight;
Edited();
}
img.classList.add("TiffViewer_imgclass");
document.getElementById('TiffViewer_ImageContainer').append(img);
tiff.setDirectory(i);
img.classList.add("TiffViewer_imgclass");
tiff.setDirectory(i - 1);
var canvas = tiff.toCanvas().toDataURL();
document.getElementById(`IMG${i + 1}`).src = canvas;
document.getElementById(`IMG${i}`).src = canvas;
}
//setting the style per page
for (var j = 1; j <= TiffViewer_pages; ++j) {
for (var j = 1; j <= TiffViewer_pages; j++) {
var img = document.getElementById("IMG" + j);
getMeta(canvas, function (width, height) {
wzoom[TiffViewer_current - 1] = changedwidth; /*ADDED: to fit large TIFF files*/
hzoom[TiffViewer_current - 1] = changedheight;
Edited(); origheight = height;
Edited();
origheight = height;
origwidth = width;
setwidth = width;
setheight = height;
......@@ -360,18 +361,23 @@ function TIFFViewer(xhr, TiffViewerImageName) {
} else if (setheight > 800 && setwidth <= 1000) {
img.style = "width: 800;";
changed = true;
}
if(setheight < 800 && setwidth < 1000){
} else{
img.style = `width: {setwidth}; height: {setheight}`;
changed = true;
}
if (changed) {
if(TiffViewer_pages > 1){
hpercent = (parseInt(setheight, 10) * (10 / 100));
wpercent = (parseInt(setwidth, 10) * (10 / 100));
}
setwidth = parseInt(img.style.width, 10);
setheight = parseInt(img.style.height, 10);
document.getElementById("TiffViewer_FitButton").style.display = "inherit";
}
changedheight = setheight;
changedwidth = setwidth;
hpercent = (parseInt(setheight, 10) * (10 / 100));
......@@ -393,6 +399,12 @@ function TIFFViewer(xhr, TiffViewerImageName) {
}
if(TiffViewer_pages > 1){
for (var j = 1; j <= TiffViewer_pages; j++) {
var img = document.getElementById("IMG" + j).style.display = "none";
}
}
//getting the metadata of each TIFF page
function getMeta(url, callback) {
......@@ -792,6 +804,3 @@ function TIFFViewer(xhr, TiffViewerImageName) {
initHighlight();
}
......@@ -85,8 +85,7 @@ button:hover{
padding: 0;
left: 0;
top: 0;
position: relative;
overflow-y: hidden;
/* position: relative; */
overflow-x: hidden;
}
......@@ -161,7 +160,7 @@ button:hover{
flex: 1;
max-height: 100vh;
display: inline-block;
overflow-y: scroll;
overflow-y: auto;
}
#fields>div {
......
......@@ -141,7 +141,7 @@ public class GDEWebServices {
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/write-mertrics")
@Path("/write-metrics")
public Response writeCSVMetrics(JsonObject jsonObject) {
SimpleDateFormat isoFormat = new SimpleDateFormat("MM-dd-yyyy");
......
......@@ -2,12 +2,12 @@ package com.svi.webgde.restservice.utils;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
......@@ -133,6 +133,37 @@ public class XMLUtil {
document.getElementsByTagName("proc_duration").item(0).setTextContent(
String.valueOf(Double.valueOf(xmlLastProcDuration) + Double.valueOf(xml.getProcDuration())));
Map<String, Integer> imagenames = new HashMap<>();
for (int i = 0; i < document.getElementsByTagName("imagename").getLength(); i++) {
imagenames.put(document.getElementsByTagName("imagename").item(i).getTextContent(), i);
}
if (imagenames.containsKey(xml.getImageName())) {
Node imagename = document.getElementsByTagName("imagename").item(imagenames.get(xml.getImageName()));
Node xmlSubRecord = imagename.getParentNode().getLastChild().getPreviousSibling();
// xml.getFields().forEach((key, value) -> {
for (Map.Entry<String, String> entry : xml.getFields().entrySet()) {
for (int i = 0; i < xmlSubRecord.getChildNodes().getLength(); i++) {
String key = entry.getKey();
String value = entry.getValue();
if (xmlSubRecord.getChildNodes().item(i).getNodeType() == Node.ELEMENT_NODE) {
if (xmlSubRecord.getChildNodes().item(i).getAttributes().getNamedItem("no").getNodeValue()
.equals(key)) {
for (int j = 0; j < xmlSubRecord.getChildNodes().item(i).getChildNodes().getLength(); j++) {
if (xmlSubRecord.getChildNodes().item(i).getChildNodes().item(j)
.getNodeType() == Node.ELEMENT_NODE) {
xmlSubRecord.getChildNodes().item(i).getChildNodes().item(j).setTextContent(value);
}
}
}
}
}
}
// });
} else {
NodeList xmlRecords = document.getElementsByTagName("record");
Node xmlLastRecord = xmlRecords.item(xmlRecords.getLength() - 1);
String lastRecordNo = xmlLastRecord.getAttributes().getNamedItem("no").getNodeValue();
......@@ -169,6 +200,7 @@ public class XMLUtil {
xmlRecord.appendChild(xmlSubRecord);
root.appendChild(xmlRecord);
}
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
......@@ -228,7 +260,7 @@ public class XMLUtil {
}
public static void updateExceptionRmrk(XMLContents xml)
throws ParserConfigurationException,SAXException, IOException, TransformerException {
throws ParserConfigurationException, SAXException, IOException, TransformerException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
......@@ -250,5 +282,4 @@ public class XMLUtil {
}
}
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