Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web-ui
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WEBGDE-Components
web-ui
Commits
3e4bdca3
Commit
3e4bdca3
authored
Nov 20, 2023
by
Owen Ryan Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XML parsing logic update
parent
a7b591e6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
23 deletions
+49
-23
XML_Saver.js
...e/WebContent/WebGde-Widgets/Submit/XMLWriter/XML_Saver.js
+6
-1
config.js
WebGde/WebContent/WebGde-Widgets/Submit/config.js
+2
-1
SubRecord.java
...ain/java/com/svi/webgde/restservice/object/SubRecord.java
+10
-1
XMLUtil.java
...c/main/java/com/svi/webgde/restservice/utils/XMLUtil.java
+31
-20
No files found.
WebGde/WebContent/WebGde-Widgets/Submit/XMLWriter/XML_Saver.js
View file @
3e4bdca3
...
@@ -18,7 +18,12 @@ export async function WriteForm(e,metrics,doctype,section) {
...
@@ -18,7 +18,12 @@ export async function WriteForm(e,metrics,doctype,section) {
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
if
(
Nodes
[
i
].
style
.
display
===
'none'
&&
!
Nodes
[
i
].
classList
.
contains
(
'hidden'
))
continue
let
fid
=
Nodes
[
i
].
id
;
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
// Skip the textbox in checklist and radiolist
if
(
Nodes
[
i
].
classList
.
contains
(
'radioOther'
)
||
Nodes
[
i
].
classList
.
contains
(
'checkboxOther'
))
continue
;
if
(
Nodes
[
i
].
classList
.
contains
(
'radioOther'
)
||
Nodes
[
i
].
classList
.
contains
(
'checkboxOther'
))
continue
;
// Skip elements of type "button", "submit", and files
// Skip elements of type "button", "submit", and files
...
...
WebGde/WebContent/WebGde-Widgets/Submit/config.js
View file @
3e4bdca3
...
@@ -2,5 +2,5 @@ export const PROJECT_CODE = "PROJCODE01";
...
@@ -2,5 +2,5 @@ export const PROJECT_CODE = "PROJCODE01";
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
=
"
E:/Coding/Mobile GDE
Elements"
;
export
const
TEMPORARY_FOLDER
=
"
C:/Users/oang/Desktop/Mobile GDE/
Elements"
;
export
const
GFS_ROOT_FOLDER
=
"/Users"
;
export
const
GFS_ROOT_FOLDER
=
"/Users"
;
\ No newline at end of file
WebGde/src/main/java/com/svi/webgde/restservice/object/SubRecord.java
View file @
3e4bdca3
...
@@ -41,7 +41,16 @@ public class SubRecord {
...
@@ -41,7 +41,16 @@ public class SubRecord {
*/
*/
public
void
arrangeFields
(
String
orderPipeDelimited
)
{
public
void
arrangeFields
(
String
orderPipeDelimited
)
{
List
<
Field
>
sortedFields
=
fields
.
stream
()
List
<
Field
>
sortedFields
=
fields
.
stream
()
.
sorted
(
Comparator
.
comparingInt
(
f
->
getOrder
(
f
.
getNo
(),
orderPipeDelimited
)))
.
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
());
.
collect
(
Collectors
.
toList
());
// Update the fields list with the sorted order
// Update the fields list with the sorted order
...
...
WebGde/src/main/java/com/svi/webgde/restservice/utils/XMLUtil.java
View file @
3e4bdca3
...
@@ -81,10 +81,11 @@ public class XMLUtil {
...
@@ -81,10 +81,11 @@ public class XMLUtil {
OutputXML
output
=
new
OutputXML
(
header
,
record
);
OutputXML
output
=
new
OutputXML
(
header
,
record
);
//SAXParserFactory spf = SAXParserFactory.newInstance();
// SAXParserFactory spf = SAXParserFactory.newInstance();
//SAXParser sp = spf.newSAXParser();
// SAXParser sp = spf.newSAXParser();
//Source source = new SAXSource(sp.getXMLReader(),
// Source source = new SAXSource(sp.getXMLReader(),
//new InputSource(new StringReader(xs.toXML(output).replaceAll("(?<![^\\W_])[ ](?![^\\W_])", " "))));
// new InputSource(new StringReader(xs.toXML(output).replaceAll("(?<![^\\W_])[
// ](?![^\\W_])", " "))));
DocumentBuilderFactory
factory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilderFactory
factory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
...
@@ -348,26 +349,28 @@ public class XMLUtil {
...
@@ -348,26 +349,28 @@ public class XMLUtil {
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
Document
document
=
builder
.
parse
(
xml
.
getOutputDir
());
Document
document
=
builder
.
parse
(
xml
.
getOutputDir
());
Node
imagename
=
document
.
getElementsByTagName
(
"imagename"
).
item
(
0
);
Element
record
=
(
Element
)
document
.
getElementsByTagName
(
"record"
).
item
(
0
);
Node
xmlSubRecord
=
imagename
.
getParentNode
().
getLastChild
().
getPreviousSibling
();
if
(
record
!=
null
)
{
Map
<
String
,
String
>
fields
=
new
HashMap
<>();
records
.
put
(
"DocType"
,
getElementTextByTagName
(
record
,
"doctype"
));
records
.
put
(
"Section"
,
getElementTextByTagName
(
record
,
"section"
));
records
.
put
(
"DocType"
,
imagename
.
getParentNode
().
getFirstChild
().
getNextSibling
().
getNextSibling
()
Map
<
String
,
String
>
fields
=
new
HashMap
<>();
.
getNextSibling
().
getTextContent
());
records
.
put
(
"Section"
,
imagename
.
getParentNode
().
getFirstChild
().
getNextSibling
().
getNextSibling
()
.
getNextSibling
().
getNextSibling
().
getNextSibling
().
getTextContent
());
records
.
put
(
"fields"
,
fields
);
records
.
put
(
"fields"
,
fields
);
for
(
int
i
=
0
;
i
<
xmlSubRecord
.
getChildNodes
().
getLength
();
i
++)
{
Element
subRecord
=
(
Element
)
record
.
getElementsByTagName
(
"sub-record"
).
item
(
0
);
if
(
xmlSubRecord
.
getChildNodes
().
item
(
i
).
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
if
(
subRecord
!=
null
)
{
for
(
int
j
=
0
;
j
<
xmlSubRecord
.
getChildNodes
().
item
(
i
).
getChildNodes
().
getLength
();
j
++)
{
NodeList
fieldList
=
subRecord
.
getElementsByTagName
(
"field"
);
if
(
xmlSubRecord
.
getChildNodes
().
item
(
i
).
getChildNodes
().
item
(
j
)
for
(
int
j
=
0
;
j
<
fieldList
.
getLength
();
j
++)
{
.
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
Element
field
=
(
Element
)
fieldList
.
item
(
j
);
fields
.
put
(
String
noAttributeValue
=
field
.
getAttribute
(
"no"
);
xmlSubRecord
.
getChildNodes
().
item
(
i
).
getAttributes
().
getNamedItem
(
"no"
).
getNodeValue
(),
String
textContentValue
=
field
.
getElementsByTagName
(
"value"
).
item
(
0
).
getTextContent
();
xmlSubRecord
.
getChildNodes
().
item
(
i
).
getChildNodes
().
item
(
j
).
getTextContent
());
records
.
put
(
"fields"
,
fields
);
if
(
"1"
.
equals
(
noAttributeValue
))
{
// Replace the value of "DocType" with the text content
records
.
put
(
"DocType"
,
textContentValue
);
}
}
fields
.
put
(
noAttributeValue
,
textContentValue
);
}
}
}
}
}
}
...
@@ -375,4 +378,12 @@ public class XMLUtil {
...
@@ -375,4 +378,12 @@ public class XMLUtil {
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
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment