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
ae930ecb
Commit
ae930ecb
authored
Jan 26, 2017
by
everdarkgreen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JsonNode: added getting card data
parent
ce41fc8a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
23 deletions
+47
-23
Main.java
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
+47
-23
No files found.
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
View file @
ae930ecb
...
...
@@ -22,10 +22,12 @@ import java.io.InputStreamReader;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.Iterator
;
import
java.util.List
;
import
javax.ejb.ActivationConfigProperty
;
import
javax.ejb.MessageDriven
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.codehaus.jackson.node.ArrayNode
;
import
org.codehaus.jackson.type.TypeReference
;
@MessageDriven
(
name
=
"CustomBP"
,
activationConfig
=
{
@ActivationConfigProperty
(
propertyName
=
"destinationType"
,
propertyValue
=
"javax.jms.Queue"
),
...
...
@@ -35,22 +37,19 @@ import org.codehaus.jackson.node.ArrayNode;
@ActivationConfigProperty
(
propertyName
=
"acknowledgeMode"
,
propertyValue
=
"Auto-acknowledge"
)})
public
class
Main
implements
MessageListener
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Main
.
class
);
private
static
enum
fieldType
{
DATE
,
TEXTBOX
,
USER
}
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Main
.
class
);
private
String
dataUUID
=
null
;
// идентификатор данных по форме записи реестра
private
String
executionID
=
null
;
// идентификатор блокирующего процесса
private
String
documentID
=
null
;
// идентификатор документа реестра
@Override
public
void
onMessage
(
Message
message
)
{
LOGGER
.
error
(
"CWM work starts"
);
String
dataUUID
=
null
;
// идентификатор данных по форме записи реестра
String
executionID
=
null
;
// идентификатор блокирующего процесса
String
documentID
=
null
;
// идентификатор документа реестра
if
(!(
message
instanceof
TextMessage
))
{
return
;
}
...
...
@@ -81,17 +80,20 @@ public class Main implements MessageListener {
}
}
// Получение ID пользователя
// Получение данных исходной формы
URL
sourceFormURL
=
new
URL
(
"http://127.0.0.1:8080/Synergy/rest/api/asforms/data/"
+
dataUUID
);
// JsonParser sourceFormData = synergyApiGet(sourceFormURL);
String
sourceFormData
=
synergyApiGetString
(
sourceFormURL
);
// Получение ID пользователя
String
userID
=
getComponentValueByID
(
sourceFormData
,
"user1"
,
fieldType
.
USER
);
// По ID пользователя DataUUID целевой карточки
String
userCardDataUUID
=
findDataUuidByUserID
(
userID
,
"04f7809d-f44c-4a2d-950d-6aa8e6c3fea1"
);
// Получение данных целевой карточки по dataUUID
URL
targetFormURL
=
new
URL
(
"http://127.0.0.1:8080/Synergy/rest/api/asforms/data/"
+
userCardDataUUID
);
String
targetFormData
=
synergyApiGetString
(
sourceFormURL
);
// Получение значений текущих дат исходной формы
String
b2b1
,
b4b1
,
b5b1
;
...
...
@@ -107,25 +109,47 @@ public class Main implements MessageListener {
b5b1
=
getComponentValueByID
(
sourceFormData
,
"b5-b1"
,
fieldType
.
TEXTBOX
);
t4b1
=
getComponentValueByID
(
sourceFormData
,
"b2-b1"
,
fieldType
.
DATE
);
// Получение данных целевой карточки
// URL targetFormURL = new URL("http://127.0.0.1:8080/Synergy/rest/api/asforms/data/")
// String targetFormData = synergyApiGetString(sourceFormURL)
// Разблокировка маршрута""
// Разблокировка маршрута
unlockRoute
();
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
// private void postDataToCard()
private
void
unlockRoute
()
{
try
{
String
address
=
"http://127.0.0.1:8080/Synergy"
;
String
signal
=
"got_agree"
;
URL
url
=
new
URL
(
address
+
"/rest/api/processes/signal?signal="
+
signal
+
"&executionID="
+
executionID
+
"¶m1=resolution&value1=signal_is_"
+
signal
);
URL
url
=
new
URL
(
address
+
"/rest/api/processes/signal?signal="
+
signal
+
"&executionID="
+
this
.
executionID
+
"¶m1=resolution&value1=signal_is_"
+
signal
);
synergyApiGet
(
url
);
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
private
static
String
findDataUuidByUserID
(
String
userID
,
String
formUUID
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
URL
url
=
new
URL
(
"http://127.0.0.1:8080/Synergy/rest/api/personalrecord/forms/"
+
userID
);
String
res
=
synergyApiGetString
(
url
);
List
<
Card
>
cardsList
=
mapper
.
readValue
(
res
,
new
TypeReference
<
List
<
Card
>>(){});
for
(
Card
c
:
cardsList
)
{
if
(
formUUID
.
equals
(
c
.
getFormUUID
()))
{
return
c
.
getDataUUID
();
}
}
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
return
new
String
();
}
private
static
String
searchInNode
(
Iterator
<
JsonNode
>
iter
,
String
fieldName
,
fieldType
ft
)
{
String
result
=
new
String
();
// different form's component keeps data in different places
...
...
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