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
fdd8570f
Commit
fdd8570f
authored
Jan 29, 2017
by
Mikhail Gashenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JsonNode: (draft10) successful push data to user's card
parent
1ccf1eb2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
39 deletions
+68
-39
APIFormsServiceSave.java
.../synergy/api/rest/sample/asforms/APIFormsServiceSave.java
+3
-1
AsNode.java
src/main/java/kz/arta/synergy/astdev/custom_bp/AsNode.java
+32
-22
Main.java
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
+33
-16
No files found.
src/main/java/kz/arta/synergy/api/rest/sample/asforms/APIFormsServiceSave.java
View file @
fdd8570f
...
...
@@ -10,6 +10,7 @@ import java.io.InputStream;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
javax.xml.bind.DatatypeConverter
;
/**
...
...
@@ -68,6 +69,7 @@ public class APIFormsServiceSave {
connection
.
setRequestProperty
(
"Accept"
,
"application/json; charset=utf-8"
);
connection
.
setRequestProperty
(
"Authorization"
,
"Basic "
+
encoded
);
connection
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
connection
.
setUseCaches
(
true
);
connection
.
setDoInput
(
true
);
connection
.
setDoOutput
(
true
);
...
...
@@ -81,7 +83,7 @@ public class APIFormsServiceSave {
request
.
writeBytes
(
"parentID="
+
parentID
);
}
request
.
writeBytes
(
"&"
);
request
.
writeBytes
(
"data="
+
data
);
request
.
writeBytes
(
"data="
+
URLEncoder
.
encode
(
data
,
"UTF-8"
)
);
request
.
flush
();
request
.
close
();
...
...
src/main/java/kz/arta/synergy/astdev/custom_bp/AsNode.java
View file @
fdd8570f
...
...
@@ -2,7 +2,7 @@ package kz.arta.synergy.astdev.custom_bp;
import
java.util.List
;
import
org.codehaus.jackson.annotate.JsonProperty
;
import
org.codehaus.jackson.node.ObjectNode
;
//
import org.codehaus.jackson.node.ObjectNode;
/**
*
...
...
@@ -20,16 +20,18 @@ public class AsNode {
private
String
value
;
@JsonProperty
(
"key"
)
private
String
key
;
@JsonProperty
(
"data"
)
private
List
<
AsNode
>
data
;
@JsonProperty
(
"formatVersion"
)
private
String
formatVersion
;
@JsonProperty
(
"manualTags"
)
private
ObjectNode
manualTags
;
//
@JsonProperty("formatVersion")
//
private String formatVersion;
//
@JsonProperty("manualTags")
//
private ObjectNode manualTags;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
@@ -37,6 +39,7 @@ public class AsNode {
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
...
...
@@ -44,6 +47,7 @@ public class AsNode {
public
String
getLabel
()
{
return
label
;
}
public
void
setLabel
(
String
label
)
{
this
.
label
=
label
;
}
...
...
@@ -51,13 +55,15 @@ public class AsNode {
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
//
// public void setKey(String key) {
// this.key = key;
// }
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
...
...
@@ -65,22 +71,25 @@ public class AsNode {
public
List
<
AsNode
>
getData
()
{
return
data
;
}
public
void
setData
(
List
<
AsNode
>
data
)
{
this
.
data
=
data
;
}
public
String
getFormatVersion
()
{
return
formatVersion
;
}
public
void
setFormatVersion
(
String
formatVersion
)
{
this
.
formatVersion
=
formatVersion
;
}
public
ObjectNode
getManualTags
()
{
return
manualTags
;
}
public
void
setManualTags
(
ObjectNode
manualTags
)
{
this
.
manualTags
=
manualTags
;
}
// public String getFormatVersion() {
// return formatVersion;
// }
//
// public void setFormatVersion(String formatVersion) {
// this.formatVersion = formatVersion;
// }
//
// public ObjectNode getManualTags() {
// return manualTags;
// }
//
// public void setManualTags(ObjectNode manualTags) {
// this.manualTags = manualTags;
// }
}
}
\ No newline at end of file
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
View file @
fdd8570f
...
...
@@ -23,6 +23,7 @@ import javax.naming.NameNotFoundException;
import
javax.naming.directory.AttributeModificationException
;
import
javax.xml.bind.DatatypeConverter
;
import
kz.arta.synergy.api.rest.sample.asforms.APIFormsServiceSave
;
import
org.codehaus.jackson.map.DeserializationConfig
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.codehaus.jackson.map.annotate.JsonSerialize
;
import
org.codehaus.jackson.type.TypeReference
;
...
...
@@ -101,6 +102,13 @@ public class Main implements MessageListener {
}
}
// Configure ObjectMapper
OBJECT_MAPPER
.
configure
(
DeserializationConfig
.
Feature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
// SOURCE FORM: Получение данных исходной формы (той, по которой запущен маршрут)
URL
sourceFormURL
=
new
URL
(
SYNERGY_ADDRESS
+
"/rest/api/asforms/data/"
+
SOURCE_FORM_DATA_UUID
);
String
sourceFormDataAsString
=
synergyApiGetString
(
sourceFormURL
);
...
...
@@ -115,14 +123,23 @@ public class Main implements MessageListener {
}
sourceFormData
=
OBJECT_MAPPER
.
readValue
(
SourceRootDataNode
,
new
TypeReference
<
List
<
AsNode
>>()
{});
// map content of single root 'data' node
// TARGET FORM: Получение ID пользователя указанного в форме
String
userID
=
getComponentValueByID
(
this
.
sourceFormData
,
"user1"
,
fields
.
KEY
);
// По ID пользователя указанного в карточке и ID формы получаем DataUUID целевой карточки (ID for work: "04f7809d-f44c-4a2d-950d-6aa8e6c3fea1")
String
userCardData
UUID
=
getCardDataUUID
(
userID
,
TARGET_FORM_UUID
);
TARGET_FORM_DATA_
UUID
=
getCardDataUUID
(
userID
,
TARGET_FORM_UUID
);
// Получение данных целевой карточки по dataUUID
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
);
URL
targetFormURL
=
new
URL
(
SYNERGY_ADDRESS
+
"/rest/api/asforms/data/"
+
TARGET_FORM_DATA_UUID
);
String
targetFormDataAsString
=
synergyApiGetString
(
targetFormURL
);
JsonNode
TargetRootNode
=
OBJECT_MAPPER
.
readTree
(
targetFormDataAsString
);
if
(
TargetRootNode
.
isNull
())
{
throw
new
AttributeModificationException
(
"GMP: Passed data has no JSON content"
);
}
...
...
@@ -143,17 +160,14 @@ public class Main implements MessageListener {
// String t32b1, t30b1, t28b1;
// first table
String
b2b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"b2-b1-b1"
,
fields
.
KEY
);
String
b4b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"b4-b1-b1"
,
fields
.
KEY
);
String
b2b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"b2-b1-b1"
,
fields
.
VALUE
);
String
b4b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"b4-b1-b1"
,
fields
.
VALUE
);
if
(!
b2b1
.
isEmpty
()
&&
!
b4b1
.
isEmpty
())
{
updateFieldValue
(
this
.
targetFormData
,
"start-b1"
,
fields
.
KEY
,
b2b1
);
updateFieldValue
(
this
.
targetFormData
,
"finish-b1"
,
fields
.
KEY
,
b4b1
);
updateFieldValue
(
this
.
targetFormData
,
"start-b1"
,
fields
.
VALUE
,
b2b1
);
updateFieldValue
(
this
.
targetFormData
,
"finish-b1"
,
fields
.
VALUE
,
b4b1
);
updateTargetForm
();
unlockRoute
();
return
;
}
// Second table
...
...
@@ -173,20 +187,24 @@ public class Main implements MessageListener {
// }
// Разблокировка маршрута
unlockRoute
();
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
finally
{
unlockRoute
();
}
}
private
void
updateTargetForm
()
throws
IOException
{
private
void
updateTargetForm
()
throws
IOException
,
Exception
{
// SERIALIZATION
OBJECT_MAPPER
.
setSerializationInclusion
(
JsonSerialize
.
Inclusion
.
NON_NULL
);
String
serialData
=
OBJECT_MAPPER
.
writeValueAsString
(
targetFormData
);
APIFormsServiceSave
saver
=
new
APIFormsServiceSave
(
LOGIN
,
PASSWORD
,
SYNERGY_ADDRESS
,
TARGET_FORM_UUID
,
TARGET_FORM_DATA_UUID
,
"\"data\": "
+
serialData
);
// String login, String password, String address, String formUUID, String uuid, String data
APIFormsServiceSave
saver
=
new
APIFormsServiceSave
(
LOGIN
,
PASSWORD
,
SYNERGY_ADDRESS
,
TARGET_FORM_UUID
,
TARGET_FORM_DATA_UUID
,
"\"data\": "
+
serialData
);
saver
.
save
();
}
/**
...
...
@@ -239,8 +257,7 @@ public class Main implements MessageListener {
targetNode
.
setLabel
(
newFieldValue
);
break
;
case
KEY:
targetNode
.
setKey
(
newFieldValue
);
break
;
throw
new
AttributeModificationException
(
"GMP: Modification of \"key\" attribute is forbidden according to specification"
);
case
VALUE:
targetNode
.
setValue
(
newFieldValue
);
break
;
...
...
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