Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bp_custom
Overview
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mikhail Gashenko
bp_custom
Commits
f58d6c80
Commit
f58d6c80
authored
Jan 27, 2017
by
everdarkgreen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JsonNode: (draft3) node value update
parent
a36982f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
Main.java
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
+17
-9
No files found.
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
View file @
f58d6c80
...
...
@@ -106,12 +106,12 @@ public class Main implements MessageListener {
// String t32b1, t30b1, t28b1;
// first table
String
b2b1
=
getComponentValueByID
(
sourceFormData
,
"b2-b1"
,
fieldType
.
DATE
);
String
b4b1
=
getComponentValueByID
(
sourceFormData
,
"b4-b1"
,
fieldType
.
DATE
);
String
b2b1
=
getComponentValueByID
(
sourceFormData
,
"b2-b1
-b1
"
,
fieldType
.
DATE
);
String
b4b1
=
getComponentValueByID
(
sourceFormData
,
"b4-b1
-b1
"
,
fieldType
.
DATE
);
if
(!
b2b1
.
isEmpty
()
&&
!
b4b1
.
isEmpty
())
{
setComponentValueByID
(
targetFormData
,
"
b2-b1
-b1"
,
"key"
,
b2b1
);
setComponentValueByID
(
targetFormData
,
"
b4-b1
-b1"
,
"key"
,
b4b1
);
setComponentValueByID
(
targetFormData
,
"
start
-b1"
,
"key"
,
b2b1
);
setComponentValueByID
(
targetFormData
,
"
finish
-b1"
,
"key"
,
b4b1
);
unlockRoute
();
return
;
...
...
@@ -147,8 +147,10 @@ public class Main implements MessageListener {
try
{
JsonNode
rootNode
=
mapper
.
readTree
(
targetJsonAsString
);
// getting first level (root) 'data' node, there may be only two levels
ArrayNode
rootDN
=
(
ArrayNode
)
rootNode
.
get
(
"data"
);
Iterator
<
JsonNode
>
rootDNIterator
=
rootDN
.
getElements
();
Iterator
<
JsonNode
>
rootDNIterator
=
rootDN
.
getElements
();
// all objects of first 'data'
// searching for field value in root 'data' node and setting new value if found
JsonNode
node
=
searchInNode2
(
rootDNIterator
,
componentID
,
fieldName
);
...
...
@@ -158,19 +160,25 @@ public class Main implements MessageListener {
return
;
}
Iterator
<
JsonNode
>
rootDNIterator2
=
rootDN
.
getElements
();
// 'reset' iterator (create new one)
// root 'data' value does not contain the expected value, search in second (last possible) 'data'
Iterator
<
JsonNode
>
rootDNIterator2
=
rootDN
.
getElements
();
// all objects of first 'data'
while
(
rootDNIterator2
.
hasNext
())
{
ArrayNode
childNode
=
(
ArrayNode
)
rootDNIterator2
.
next
().
get
(
"data"
);
// get next 'data'
Iterator
<
JsonNode
>
childDNIterator
=
childNode
.
getElements
();
node
=
searchInNode2
(
childDNIterator
,
componentID
,
fieldName
);
if
(
childNode
!=
null
)
{
Iterator
<
JsonNode
>
childDNIterator
=
childNode
.
getElements
();
node
=
searchInNode2
(
childDNIterator
,
componentID
,
fieldName
);
}
}
if
(
node
!=
null
)
{
setValueInNode
(
node
,
componentID
,
newFieldValue
,
componentID
);
}
else
{
throw
new
InvalidAttributesException
(
"GMP: Target form field cannot be updated"
);
}
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
"GMP: Invalid card data"
);
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
...
...
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