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
1ccf1eb2
Commit
1ccf1eb2
authored
Jan 29, 2017
by
Mikhail Gashenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JsonNode: (draft9) added custom serializer!
parent
600694cc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
APIFormsServiceSave.java
.../synergy/api/rest/sample/asforms/APIFormsServiceSave.java
+3
-3
Main.java
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
+22
-22
No files found.
src/main/java/kz/arta/synergy/api/rest/sample/asforms/APIFormsServiceSave.java
View file @
1ccf1eb2
package
kz
.
arta
.
synergy
.
api
.
rest
.
sample
.
asforms
;
import
com.sun.org.apache.xerces.internal.impl.dv.util.Base64
;
import
org.codehaus.jackson.JsonFactory
;
import
org.codehaus.jackson.JsonParser
;
import
org.codehaus.jackson.JsonToken
;
...
...
@@ -11,6 +10,7 @@ import java.io.InputStream;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
javax.xml.bind.DatatypeConverter
;
/**
*
...
...
@@ -58,7 +58,7 @@ public class APIFormsServiceSave {
this
.
formUUID
=
formUUID
;
this
.
uuid
=
uuid
;
this
.
data
=
data
;
encoded
=
Base64
.
encode
((
login
+
":"
+
password
).
getBytes
());
this
.
encoded
=
DatatypeConverter
.
printBase64Binary
((
login
+
":"
+
password
).
getBytes
());
}
public
void
save
()
throws
Exception
{
...
...
@@ -87,7 +87,7 @@ public class APIFormsServiceSave {
InputStream
is
=
connection
.
getInputStream
();
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
is
));
StringBu
ffer
response
=
new
StringBuff
er
();
StringBu
ilder
response
=
new
StringBuild
er
();
String
line
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
...
...
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
View file @
1ccf1eb2
...
...
@@ -41,7 +41,7 @@ import org.codehaus.jackson.type.TypeReference;
public
class
Main
implements
MessageListener
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Main
.
class
);
private
static
final
ObjectMapper
OBJECTMAPPER
=
new
ObjectMapper
();
private
static
final
ObjectMapper
OBJECT
_
MAPPER
=
new
ObjectMapper
();
private
static
enum
fieldType
{
DATE
,
TEXTBOX
,
USER
...
...
@@ -55,10 +55,10 @@ public class Main implements MessageListener {
private
static
final
String
LOGIN
=
"111111"
;
private
static
final
String
PASSWORD
=
"1"
;
private
final
String
TARGET
FORM
UUID
=
"fb44d99d-1579-4ac3-884a-01a6d4f71f9c"
;
private
final
String
SYNERGYADDRESS
=
"http://127.0.0.1:8080/Synergy"
;
private
String
SOURCE
FORMDATA
UUID
=
null
;
// идентификатор данных по форме записи реестра
private
String
TARGET
FORMDATA
UUID
=
null
;
private
final
String
TARGET
_FORM_
UUID
=
"fb44d99d-1579-4ac3-884a-01a6d4f71f9c"
;
private
final
String
SYNERGY
_
ADDRESS
=
"http://127.0.0.1:8080/Synergy"
;
private
String
SOURCE
_FORM_DATA_
UUID
=
null
;
// идентификатор данных по форме записи реестра
private
String
TARGET
_FORM_DATA_
UUID
=
null
;
@JsonSerialize
(
using
=
AsNodeSerializer
.
class
)
private
List
<
AsNode
>
sourceFormData
=
null
;
...
...
@@ -87,7 +87,7 @@ public class Main implements MessageListener {
String
value
=
parser
.
getText
();
switch
(
fieldName
)
{
case
"dataUUID"
:
SOURCE
FORMDATA
UUID
=
value
;
SOURCE
_FORM_DATA_
UUID
=
value
;
break
;
case
"executionID"
:
executionID
=
value
;
...
...
@@ -101,11 +101,11 @@ public class Main implements MessageListener {
}
}
// Получение данных исходной формы (той, по которой запущен маршрут)
URL
sourceFormURL
=
new
URL
(
SYNERGY
ADDRESS
+
"/rest/api/asforms/data/"
+
SOURCEFORMDATA
UUID
);
//
SOURCE FORM:
Получение данных исходной формы (той, по которой запущен маршрут)
URL
sourceFormURL
=
new
URL
(
SYNERGY
_ADDRESS
+
"/rest/api/asforms/data/"
+
SOURCE_FORM_DATA_
UUID
);
String
sourceFormDataAsString
=
synergyApiGetString
(
sourceFormURL
);
JsonNode
SourceRootNode
=
OBJECTMAPPER
.
readTree
(
sourceFormDataAsString
);
// read the whole tree
JsonNode
SourceRootNode
=
OBJECT
_
MAPPER
.
readTree
(
sourceFormDataAsString
);
// read the whole tree
if
(
SourceRootNode
.
isNull
())
{
throw
new
AttributeModificationException
(
"GMP: Passed data has no JSON content"
);
}
...
...
@@ -113,16 +113,16 @@ public class Main implements MessageListener {
if
(
SourceRootDataNode
==
null
)
{
throw
new
AttributeModificationException
(
"GMP: Invalid form data, root \"data\" node does not exists"
);
}
sourceFormData
=
OBJECTMAPPER
.
readValue
(
SourceRootDataNode
,
new
TypeReference
<
List
<
AsNode
>>()
{});
// map content of single root 'data' node
sourceFormData
=
OBJECT
_
MAPPER
.
readValue
(
SourceRootDataNode
,
new
TypeReference
<
List
<
AsNode
>>()
{});
// map content of single root 'data' node
// Получение ID пользователя указанного в форме
String
userID
=
getComponentValueByID
(
this
.
sourceFormData
,
"user1"
,
fields
.
KEY
);
// TODO: Pass JsonNode, not String
//
TARGET FORM:
Получение ID пользователя указанного в форме
String
userID
=
getComponentValueByID
(
this
.
sourceFormData
,
"user1"
,
fields
.
KEY
);
// По ID пользователя указанного в карточке и ID формы получаем DataUUID целевой карточки (ID for work: "04f7809d-f44c-4a2d-950d-6aa8e6c3fea1")
String
userCardDataUUID
=
getCardDataUUID
(
userID
,
TARGET
FORM
UUID
);
String
userCardDataUUID
=
getCardDataUUID
(
userID
,
TARGET
_FORM_
UUID
);
// Получение данных целевой карточки по dataUUID
URL
targetFormURL
=
new
URL
(
SYNERGYADDRESS
+
"/rest/api/asforms/data/"
+
userCardDataUUID
);
TARGET
FORMDATA
UUID
=
synergyApiGetString
(
targetFormURL
);
JsonNode
TargetRootNode
=
OBJECT
MAPPER
.
readTree
(
TARGETFORMDATA
UUID
);
URL
targetFormURL
=
new
URL
(
SYNERGY
_
ADDRESS
+
"/rest/api/asforms/data/"
+
userCardDataUUID
);
TARGET
_FORM_DATA_
UUID
=
synergyApiGetString
(
targetFormURL
);
JsonNode
TargetRootNode
=
OBJECT
_MAPPER
.
readTree
(
TARGET_FORM_DATA_
UUID
);
if
(
TargetRootNode
.
isNull
())
{
throw
new
AttributeModificationException
(
"GMP: Passed data has no JSON content"
);
}
...
...
@@ -130,7 +130,7 @@ public class Main implements MessageListener {
if
(
TargetRootDataNode
==
null
)
{
throw
new
AttributeModificationException
(
"GMP: Invalid form data, root \"data\" node does not exists"
);
}
targetFormData
=
OBJECTMAPPER
.
readValue
(
TargetRootDataNode
,
new
TypeReference
<
List
<
AsNode
>>()
{});
targetFormData
=
OBJECT
_
MAPPER
.
readValue
(
TargetRootDataNode
,
new
TypeReference
<
List
<
AsNode
>>()
{});
// Получение значений текущих дат исходной формы
String
b5b1
;
...
...
@@ -150,7 +150,7 @@ public class Main implements MessageListener {
updateFieldValue
(
this
.
targetFormData
,
"start-b1"
,
fields
.
KEY
,
b2b1
);
updateFieldValue
(
this
.
targetFormData
,
"finish-b1"
,
fields
.
KEY
,
b4b1
);
update
UserCard
();
update
TargetForm
();
unlockRoute
();
return
;
...
...
@@ -181,12 +181,12 @@ public class Main implements MessageListener {
}
private
void
update
UserCard
()
throws
IOException
{
private
void
update
TargetForm
()
throws
IOException
{
// SERIALIZATION
OBJECTMAPPER
.
setSerializationInclusion
(
JsonSerialize
.
Inclusion
.
NON_NULL
);
String
serialData
=
OBJECTMAPPER
.
writeValueAsString
(
targetFormData
);
OBJECT
_
MAPPER
.
setSerializationInclusion
(
JsonSerialize
.
Inclusion
.
NON_NULL
);
String
serialData
=
OBJECT
_
MAPPER
.
writeValueAsString
(
targetFormData
);
APIFormsServiceSave
saver
=
new
APIFormsServiceSave
(
LOGIN
,
PASSWORD
,
SYNERGY
ADDRESS
,
TARGETFORMUUID
,
TARGETFORMDATAUUID
,
serialData
);
APIFormsServiceSave
saver
=
new
APIFormsServiceSave
(
LOGIN
,
PASSWORD
,
SYNERGY
_ADDRESS
,
TARGET_FORM_UUID
,
TARGET_FORM_DATA_UUID
,
"\"data\": "
+
serialData
);
}
/**
...
...
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