Commit 858fab48 by Jorem Magcawas

Merge branch 'feature-WG-161' into 'development-encoding'

Merge Latest to Development Encoding See merge request !40
parents b1efb58a beb57d7d
......@@ -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="/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="/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>
</wb-module>
</project-modules>
......@@ -39,7 +39,7 @@ var HIGH_LIGHT_SCHEMA = "./src/highlight/dbSchema_anno.xlsx"
//this determines if the images will be retrieved from the gfs
var DOMAIN = "http://35.169.23.0:8080"
var CONTEXTROOT = "gfs-explorer-ws"
var GFS_URL = "http://35.169.23.0:8080" + "/WebGde/svc/gfs-rest"
var FOLDER_URL = DOMAIN + "/" + CONTEXTROOT + "/svc/gfs-rest/get-folder?parentPath=/Users/"
var DOWNLOAD_URL = DOMAIN + "/" + CONTEXTROOT + "/svc/gfs-rest/get-download-link"
var IS_RETRIEVE_FROM_GFS = "N"
......@@ -54,5 +54,7 @@ var ENCODING_PASS = "PASS1"
var NEXT_NODE = "Complete"
var EXCEPTION_NODE = "Exception"
var REASON_LIST = "Reason1,Reason2,Reason3,Reason4"
//KEYCLOAK CONFIG
const REDIRECT_URL = 'http://auth-server/auth/realms/GFS/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri';
......@@ -230,6 +230,7 @@
</body>
<!--body onload-->
<script src="./src/BPO/gfsService.js"></script>
<script src="./src/BPO/bpoService.js"></script>
<script src="./src/BPO/getElement.js"></script>
<script src="./src/BPO/returnElement.js"></script>
......@@ -255,14 +256,14 @@
function() {
localStorage.setItem("prev", "1");
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click()
fieldForm.querySelector('input[type="submit"]').click();
}
);
document.addEventListener("keydown", (e) => {
if (e.key === "F12") {
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click()
fieldForm.querySelector('input[type="submit"]').click();
}
})
......
let urlGetIfExisting = GFS_URL + "/" + "get-if-existing";
let urlGetXml = GFS_URL + "/" + "get-xml";
let urlWriteXml = GFS_URL + "/" + "write-xml";
let urlUpdateEob = GFS_URL + "/" + "update-eob";
let urlUpdateException = GFS_URL + "/" + "update-exception";
let urlWriteMetrics = GFS_URL + "/" + "write-metrics";
\ No newline at end of file
......@@ -10,7 +10,45 @@ async function rejectElement() {
},
body: JSON.stringify(load)
});
if (response.status == 200) {
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");
......@@ -45,12 +83,12 @@ function createRejectWindow(){
screenMain.id = 'parent_Window';
screenMain.style.display = 'none';
document.body.appendChild(screenMain);
var resList = REASON_LIST.split(",");
//checkbox&label
screenMain.appendChild(checkLabelComponent('Reason 1','Reason 1','check1'));
screenMain.appendChild(checkLabelComponent('Reason 2','Reason 1','check2'));
screenMain.appendChild(checkLabelComponent('Reason 3','Reason 1','check3'));
screenMain.appendChild(checkLabelComponent('Reason 4','Reason 1','check4'));
for(let i = 0; i < resList.length; i++){
screenMain.appendChild(checkLabelComponent(resList[i],resList[i],"check" + (i + 1)));
}
screenMain.appendChild(checkLabelComponent('Others','','check5'));
screenMain.appendChild(createMessageBox('text-area'));
screenMain.appendChild(okCancelButton());
......@@ -132,6 +170,27 @@ function okCancelButton(){
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,
......@@ -153,8 +212,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);
......@@ -165,7 +224,7 @@ function createMessageBox(id){
var mssgBox = document.createElement('textarea');
mssgBox.name = "rejectRadio";
mssgBox.maxLength = "1000";
mssgBox.cols = "24";
mssgBox.cols = "20";
mssgBox.rows = "5";
mssgBox.id = id;
mssgBox.disabled = true;
......@@ -198,7 +257,7 @@ function createMessageBox(id){
async function updateXMLException(xmlData){
let response = await fetch('http://35.169.23.0:8080/WebGde/svc/gfs-rest/update-exception', {
let response = await fetch(urlUpdateException, {
method: "POST",
headers: {
'Content-Type':'application/json'
......@@ -206,7 +265,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`);
......
async function returnElementBPO(elementId) {
let response = await fetch(getUrlReturnElement(elementId), {method: "POST"});
if (response.status == 200) {
await loadWaitingElement();
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();
console.log('Element Returned');
alert('Element Returned');
}else{
alert(`Error ${response.status}: Returning element`);
logoutKeycloak();
}
return response.status;
}
async function returnElementLogout(elementId) {
let response = await fetch(getUrlReturnElement(elementId), {method: "POST"});
if (response.status == 200) {
console.log('Element Returned');
if (response.status == 200) {
saveExceptionToXml();//save xml
alert('Element Returned');
}else{
alert(`Error ${response.status}: Returning element`);
logoutKeycloak();
......
......@@ -69,12 +69,12 @@ const startMetricCapture = () => {
console.log(`key: ${key.key}; key_strokes: ${key_strokes}; time_spent: ${((Date.now() - time_start) / 1000) - time_pause_spent}`) // for demonstration purposes
}
window.onclick = (event) => {
if (event.path[0].id == 'pause') {
pauseMetricCapture();
document.getElementById("pause").addEventListener('click',
function() {
pauseMetricCapture();
disableTiffButtons();
}
}
}
);
showMetricCapture();
}
......@@ -157,7 +157,7 @@ const saveMetrics = async (metrics, eoe_ts) => {
"eoe_ts" : eoe_ts
};
fetch('http://35.169.23.0:8080/WebGde/svc/gfs-rest/write-mertrics/', {
fetch(urlWriteMetrics, {
method: 'POST',
headers: {
'Content-Type':'application/json'
......
......@@ -182,9 +182,8 @@ 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"));
const TIFFimg = document.getElementById(sessionStorage.getItem("TiffViewer_current"));
if (TIFFimg) {
var TIFFimg = document.getElementById(sessionStorage.getItem("TiffViewer_current"));
if (TIFFimg != null) {
//waits until width and height has been assigned
var sizeObserver = new window.ResizeObserver(entries => {
......
......@@ -110,67 +110,84 @@ function TIFFViewer(xhr, TiffViewerImageName) {
const TiffViewer_detailcont = document.createElement("div");
TiffViewer_detailcont.id = "TiffViewerDetailscontainer";
TiffViewer_detailcont.classList.add("TiffViewercontainer");
const TiffViewer_filedetail = document.createElement('p');
TiffViewer_filedetail.id = "TiffViewerImageName";
TiffViewer_filedetail.style.display = "none";
TiffViewer_filedetail.innerHTML = "Filename: ";
const TiffViewer_pagedetail = document.createElement('p');
TiffViewer_pagedetail.id = "TiffViewer_PageCount";
TiffViewer_pagedetail.style.display = "none";
TiffViewer_pagedetail.innerHTML = "Page: ";
const TiffViewer_filecont = document.createElement("div");
TiffViewer_filecont.id = "TiffViewer_FileContainer";
TiffViewer_filecont.classList.add("TiffViewercontainer");
const TiffViewer_scrncont = document.createElement("div");
TiffViewer_scrncont.id = "TiffViewer_Screen";
const TiffViewer_imgcont = document.createElement("div");
TiffViewer_imgcont.id = "TiffViewer_ImageContainer"
const TiffViewer_btncont = document.createElement("div");
TiffViewer_btncont.id = "TiffViewer_ButtonContainer";
TiffViewer_btncont.classList.add("TiffViewercontainer");
const TiffViewer_hflip = document.createElement("button");
TiffViewer_hflip.id = "TiffViewer_FlipX";
TiffViewer_hflip.classList.add("TiffViewer_ButtonClass");
TiffViewer_hflip.innerHTML = "fh";
const TiffViewer_vflip = document.createElement("button");
TiffViewer_vflip.id = "TiffViewer_FlipY";
TiffViewer_vflip.classList.add("TiffViewer_ButtonClass");
TiffViewer_vflip.innerHTML = "fv";
const TiffViewer_Rrotate = document.createElement("button");
TiffViewer_Rrotate.id = "TiffViewer_RotateR";
TiffViewer_Rrotate.classList.add("TiffViewer_ButtonClass");
TiffViewer_Rrotate.innerHTML = "rr";
const TiffViewer_Lrotate = document.createElement("button");
TiffViewer_Lrotate.id = "TiffViewer_RotateL";
TiffViewer_Lrotate.classList.add("TiffViewer_ButtonClass");
TiffViewer_Lrotate.innerHTML = "rl";
const TiffViewer_Pzoom = document.createElement("button");
TiffViewer_Pzoom.id = "TiffViewer_ZoomP";
TiffViewer_Pzoom.classList.add("TiffViewer_ButtonClass");
TiffViewer_Pzoom.innerHTML = "+";
const TiffViewer_Mzoom = document.createElement("button");
TiffViewer_Mzoom.id = "TiffViewer_ZoomM";
TiffViewer_Mzoom.classList.add("TiffViewer_ButtonClass");
TiffViewer_Mzoom.innerHTML = "-";
const TiffViewer_Pbtn = document.createElement("button");
TiffViewer_Pbtn.id = "TiffViewer_PrevButton";
TiffViewer_Pbtn.classList.add("TiffViewer_ButtonClass");
TiffViewer_Pbtn.innerHTML = "<";
TiffViewer_Pbtn.style.display = "none";
const TiffViewer_Nbtn = document.createElement("button");
TiffViewer_Nbtn.id = "TiffViewer_NextButton";
TiffViewer_Nbtn.classList.add("TiffViewer_ButtonClass");
TiffViewer_Nbtn.innerHTML = ">";
TiffViewer_Nbtn.style.display = "none";
const TiffViewer_Fscrn = document.createElement("button");
TiffViewer_Fscrn.id = "TiffViewer_FullscreenButton";
TiffViewer_Fscrn.classList.add("TiffViewer_ButtonClass");
TiffViewer_Fscrn.innerHTML = "fs";
const TiffViewer_Fit = document.createElement("button");
TiffViewer_Fit.id = "TiffViewer_FitButton";
TiffViewer_Fit.classList.add("TiffViewer_ButtonClass");
TiffViewer_Fit.innerHTML = "fc";
TiffViewer_Fit.style.display = "none";
const zoom = document.createElement("div");
zoom.style.position = "absolute";
zoom.style.right = -30;
......@@ -213,29 +230,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;
......@@ -257,18 +275,30 @@ function TIFFViewer(xhr, TiffViewerImageName) {
} else if (setheight > 800 && setwidth <= 1000) {
img.style = "width: 800;";
changed = true;
}
} else{
img.style = `width: {setwidth}; height: {setheight}`;
changed = true;
}
if (changed) {
setwidth = parseInt(img.style.width, 10);
setheight = parseInt(img.style.height, 10);
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));
wpercent = (parseInt(setwidth, 10) * (10 / 100));
hzoom.push(parseInt(setheight, 10));
wzoom.push(parseInt(setwidth, 10));
TiffViewer_scrn.style = `width: ${setwidth}; height: ${setheight};`;
document.getElementById("TiffViewer_FileContainer").style = `width: ${setwidth}; height: ${setheight};`;
TiffViewer_ImageContainer.style = `width: ${setwidth}; height: ${setheight};`;
......@@ -282,7 +312,13 @@ 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) {
......@@ -606,12 +642,12 @@ function TIFFViewer(xhr, TiffViewerImageName) {
var FitText = fitB.textContent || fitB.innerHTML;
if (FitText !== "Fit Content") {
if (FitText !== "fc") {
setheight = changedheight;
setwidth = changedwidth;
wzoom[TiffViewer_current - 1] = changedwidth;
hzoom[TiffViewer_current - 1] = changedheight;
fitB.innerHTML = "Fit Content";
fitB.innerHTML = "fc";
}
if (flippedX[TiffViewer_current - 1] != 1) {
......@@ -681,5 +717,4 @@ function TIFFViewer(xhr, TiffViewerImageName) {
});
initHighlight();
}
......@@ -22,7 +22,7 @@
* errors - list of errors found during validation
*/
// const validateInput = (fieldName, value, schema) => {
const validateInput = (fieldID, value, section) => {
const validateInput = (fieldID, value) => {
try {
const { valid, error } = validateSchema()
......@@ -66,17 +66,10 @@ const validateInput = (fieldID, value, section) => {
const getValidation = (fieldID) => {
// const { SECTION } = schema
const { ACCOUNTING_DOCUMENTS } = schema
const { SECTION1 } = ACCOUNTING_DOCUMENTS
const { BANK_APPLICATION_FORMS } = schema
const { SECTION2 } = BANK_APPLICATION_FORMS
const { HR_FILES } = schema
const { SECTION3 } = HR_FILES
let section = schema[sessionStorage.getItem("currentDoctype")][sessionStorage.getItem("currentSection")];
try{
if (Object.keys(SECTION1).includes(fieldID)) return SECTION1[fieldID].validation;
if (Object.keys(SECTION2).includes(fieldID)) return SECTION2[fieldID].validation;
if (Object.keys(SECTION3).includes(fieldID)) return SECTION3[fieldID].validation;
if (Object.keys(section).includes(fieldID)) return section[fieldID].validation;
return null;
} catch(err) {
......
const validateSchema = () => {
const { ACCOUNTING_DOCUMENTS } = schema
const validate = schema[sessionStorage.getItem("currentDoctype")]
if(!ACCOUNTING_DOCUMENTS) return { valid: false, error: 'SECTION is missing!' }
if(!validate) return { valid: false, error: 'SECTION is missing!' }
return { valid: true }
}
\ No newline at end of file
......@@ -3,8 +3,13 @@ html {
}
*{
-webkit-font-smoothing: auto;
font-size: 13px;
font-family: Helvetica, sans-serif;
letter-spacing: 0.1em;
text-rendering: optimizeLegibility;
font-weight: normal;
font-family: OpenSans, sans-serif;
font-style: normal;
}
button:hover{
......@@ -23,18 +28,18 @@ button:hover{
left: 0;
top: 0;
/* position: relative; */
overflow-y: hidden;
overflow-x: hidden;
}
/* For the right pane */
.sidebar {
.sidebar {
grid-area: sidebar;
display: flex;
position: sticky;
flex-direction: column;
background-color: #A1C3E2;
max-height: 100vh;
right: 0;
background-image: linear-gradient(to bottom, #23569f, #00a8c0);
}
......@@ -85,11 +90,11 @@ button:hover{
flex: 1;
max-height: 100vh;
display: inline-block;
overflow-y: scroll;
overflow-y: auto;
}
#fields>div {
background-color:E3E2E2;
background-color:white;
}
......@@ -216,7 +221,6 @@ textarea{
}
#refreshBtn {
background-color: #13B2EB;
padding: 10px;
color:white;
}
......@@ -403,7 +407,7 @@ body>div>button {
/* Modal Content */
.TiffModalContent {
position: relative;
background-color: #E3E2E2;
background-color: white;
margin: auto;
padding: 0 5 5 5;
/* border: 1px solid #888;
......@@ -489,8 +493,12 @@ body>div>button {
}
#TiffViewer_FileContainer{
border: 1px solid #446397;
border: 1px solid #ccc;
overflow: hidden;
display: flex;
position: relative;
justify-content: center;
align-items: center;
}
......@@ -587,7 +595,7 @@ select {
#parent_Window{
height: 244px;
width: 200px;
border: 1px solid;
border: 1px solid #ccc;
position: absolute;
top: calc(50% - 122px);
transform: translate(0, -50%);
......@@ -603,7 +611,7 @@ select {
}
#checkBoxCont>label{
border: 1px solid;
line-height: 20px;
padding: 2px;
width: 174px;
height: 20px;
......@@ -623,7 +631,7 @@ select {
}
#text-area{
margin-left: 3px;
margin-left: 32px;
margin-bottom: 3px;
}
......
......@@ -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;
......@@ -95,7 +95,7 @@ public class XMLUtil {
Result result = new StreamResult(xml.getOutputDir());
transformer.transform(source, result);
return new String(Files.readAllBytes(Paths.get(xml.getOutputDir())));
}
......@@ -133,42 +133,74 @@ public class XMLUtil {
document.getElementsByTagName("proc_duration").item(0).setTextContent(
String.valueOf(Double.valueOf(xmlLastProcDuration) + Double.valueOf(xml.getProcDuration())));
NodeList xmlRecords = document.getElementsByTagName("record");
Node xmlLastRecord = xmlRecords.item(xmlRecords.getLength() - 1);
String lastRecordNo = xmlLastRecord.getAttributes().getNamedItem("no").getNodeValue();
Element xmlRecord = document.createElement("record");
xmlRecord.setAttribute("no", String.valueOf(Integer.valueOf(lastRecordNo) + 1));
xmlRecord.setAttribute("total_subrec", String.valueOf(xml.getTotalSubRec()));
xmlRecord.setAttribute("max_subrec", String.valueOf(xml.getMaxSubRec()));
Element imagename = document.createElement("imagename");
imagename.appendChild(document.createTextNode(xml.getImageName()));
Element doctype = document.createElement("doctype");
doctype.appendChild(document.createTextNode(xml.getDoctype()));
Element section = document.createElement("section");
section.appendChild(document.createTextNode(xml.getSection()));
xmlRecord.appendChild(imagename);
xmlRecord.appendChild(doctype);
xmlRecord.appendChild(section);
Element xmlSubRecord = document.createElement("sub-record");
xmlSubRecord.setAttribute("no", String.valueOf(Integer.valueOf(xml.getSubRecordNo())));
xmlSubRecord.setAttribute("eor", String.valueOf(xml.getEor()));
xml.getFields().forEach((key, value) -> {
Element xmlField = document.createElement("field");
Element valueField = document.createElement("value");
valueField.appendChild(document.createTextNode(value));
xmlField.setAttribute("no", key);
xmlField.appendChild(valueField);
xmlSubRecord.appendChild(xmlField);
});
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);
}
xmlRecord.appendChild(xmlSubRecord);
root.appendChild(xmlRecord);
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();
Element xmlRecord = document.createElement("record");
xmlRecord.setAttribute("no", String.valueOf(Integer.valueOf(lastRecordNo) + 1));
xmlRecord.setAttribute("total_subrec", String.valueOf(xml.getTotalSubRec()));
xmlRecord.setAttribute("max_subrec", String.valueOf(xml.getMaxSubRec()));
Element imagename = document.createElement("imagename");
imagename.appendChild(document.createTextNode(xml.getImageName()));
Element doctype = document.createElement("doctype");
doctype.appendChild(document.createTextNode(xml.getDoctype()));
Element section = document.createElement("section");
section.appendChild(document.createTextNode(xml.getSection()));
xmlRecord.appendChild(imagename);
xmlRecord.appendChild(doctype);
xmlRecord.appendChild(section);
Element xmlSubRecord = document.createElement("sub-record");
xmlSubRecord.setAttribute("no", String.valueOf(Integer.valueOf(xml.getSubRecordNo())));
xmlSubRecord.setAttribute("eor", String.valueOf(xml.getEor()));
xml.getFields().forEach((key, value) -> {
Element xmlField = document.createElement("field");
Element valueField = document.createElement("value");
valueField.appendChild(document.createTextNode(value));
xmlField.setAttribute("no", key);
xmlField.appendChild(valueField);
xmlSubRecord.appendChild(xmlField);
});
xmlRecord.appendChild(xmlSubRecord);
root.appendChild(xmlRecord);
}
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
......@@ -226,10 +258,10 @@ public class XMLUtil {
StreamResult result = new StreamResult(xml.getOutputDir());
transformer.transform(source, result);
}
public static void updateExceptionRmrk(XMLContents xml)
throws ParserConfigurationException,SAXException, IOException, TransformerException {
public static void updateExceptionRmrk(XMLContents xml)
throws ParserConfigurationException, SAXException, IOException, TransformerException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xml.getOutputDir());
......@@ -247,8 +279,7 @@ public class XMLUtil {
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(xml.getOutputDir());
transformer.transform(source, result);
}
}
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