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
f20f72d2
Commit
f20f72d2
authored
Jan 25, 2017
by
everdarkgreen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
assignment bug
parent
a5d60174
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
32 deletions
+67
-32
Main.java
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
+67
-32
No files found.
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
View file @
f20f72d2
...
...
@@ -9,6 +9,7 @@ import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import
com.fasterxml.jackson.core.JsonFactory
;
import
com.fasterxml.jackson.core.JsonParser
;
import
com.fasterxml.jackson.core.JsonToken
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -27,9 +28,10 @@ import javax.ejb.MessageDriven;
@ActivationConfigProperty
(
propertyName
=
"destination"
,
propertyValue
=
"java:jboss/queues/Integration/CustomBP"
),
@ActivationConfigProperty
(
propertyName
=
"reconnectAttempts"
,
propertyValue
=
"32"
),
@ActivationConfigProperty
(
propertyName
=
"reconnectInterval"
,
propertyValue
=
"4000"
),
@ActivationConfigProperty
(
propertyName
=
"acknowledgeMode"
,
propertyValue
=
"Auto-acknowledge"
)
})
@ActivationConfigProperty
(
propertyName
=
"acknowledgeMode"
,
propertyValue
=
"Auto-acknowledge"
)})
public
class
Main
implements
MessageListener
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Main
.
class
);
@Override
...
...
@@ -37,16 +39,15 @@ public class Main implements MessageListener {
LOGGER
.
error
(
"CWM work starts"
);
String
dataUUID
=
null
;
String
executionID
=
null
;
String
documentID
=
null
;
String
dataUUID
=
null
;
// идентификатор данных по форме записи реестра
String
executionID
=
null
;
// идентификатор блокирующего процесса
String
documentID
=
null
;
// идентификатор документа реестра
if
(!(
message
instanceof
TextMessage
))
{
return
;
}
try
{
JsonFactory
factory
=
new
JsonFactory
();
JsonParser
parser
=
factory
.
createParser
(((
TextMessage
)
message
).
getText
());
JsonToken
token
=
null
;
...
...
@@ -72,55 +73,89 @@ public class Main implements MessageListener {
}
}
// Выполнение каких-либо действий
//
// Получение данных исходной формы
URL
getFormDataURL
=
new
URL
(
"http://127.0.0.1:8080/Synergy/rest/api/asforms/data/"
+
dataUUID
);
JsonParser
sourceFormData
=
synergyApiGet
(
getFormDataURL
);
// Получение значений текущих дат исходной формы
String
b2b1
,
b4b1
,
b5b1
;
String
t4b1
,
t6b1
,
t2b1
;
String
t10b1
,
t12b1
,
t8b1
;
String
t18b1
,
t20b1
,
t16b1
;
String
t26b1
,
t24b1
,
t22b1
;
String
t32b1
,
t30b1
,
t28b1
;
b2b1
=
getDateKeyByFieldName
(
sourceFormData
,
"b2-b1"
);
b4b1
=
getDateKeyByFieldName
(
sourceFormData
,
"b4-b1"
);
LOGGER
.
info
(
getDateKeyByFieldName
(
sourceFormData
,
"b2-b1"
));
// Получение данных целевой карточки
// Разблокировка маршрута
String
address
=
"http://127.0.0.1:8080/Synergy"
;
String
login
=
"1"
;
String
password
=
"1"
;
String
signal
=
"got_agree"
;
boolean
isSuccess
=
false
;
URL
url
=
new
URL
(
address
+
"/rest/api/processes/signal?signal="
+
signal
+
"&executionID="
+
executionID
+
"¶m1=resolution&value1=signal_is_"
+
signal
);
synergyApiGet
(
url
);
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
private
String
getDateKeyByFieldName
(
final
JsonParser
formJson
,
final
String
fieldName
)
{
String
value
=
new
String
();
try
{
URL
url
=
new
URL
(
address
+
"/rest/api/processes/signal?signal="
+
signal
+
"&executionID="
+
executionID
+
"¶m1=resolution&value1=signal_is_"
+
signal
);
while
(!
formJson
.
isClosed
())
{
if
(
JsonToken
.
FIELD_NAME
.
equals
(
formJson
.
nextToken
()))
{
if
(
"id"
.
equals
(
formJson
.
getCurrentName
())
&&
fieldName
.
equals
(
formJson
.
nextTextValue
()))
{
formJson
.
nextToken
();
formJson
.
nextToken
();
formJson
.
nextToken
();
LOGGER
.
info
(
fieldName
+
": "
+
formJson
.
nextTextValue
());
value
=
formJson
.
nextTextValue
();
break
;
}
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
}
}
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
return
value
;
}
private
static
JsonParser
synergyApiGet
(
final
URL
requestURL
)
{
String
login
=
"Ипатьев"
;
String
password
=
"1"
;
try
{
String
output
;
HttpURLConnection
conn
=
(
HttpURLConnection
)
requestURL
.
openConnection
();
conn
.
setRequestMethod
(
"GET"
);
conn
.
setRequestProperty
(
"Accept"
,
"application/json; charset=utf-8"
);
String
encoded
=
Base64
.
encode
((
login
+
":"
+
password
).
getBytes
());
conn
.
setRequestProperty
(
"Authorization"
,
"Basic "
+
encoded
);
String
output
;
StringBuffer
result
=
new
StringBuffer
();
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
((
conn
.
getInputStream
())));
StringBuilder
result
=
new
StringBuilder
();
while
((
output
=
br
.
readLine
())
!=
null
)
{
result
.
append
(
output
);
}
conn
.
disconnect
();
factory
=
new
JsonFactory
();
parser
=
factory
.
createParser
(
result
.
toString
());
token
=
null
;
while
((
token
=
parser
.
nextToken
())
!=
null
)
{
if
(
token
==
JsonToken
.
FIELD_NAME
)
{
String
fieldName
=
parser
.
getText
();
token
=
parser
.
nextToken
();
if
(
fieldName
.
equals
(
"errorCode"
)
&&
parser
.
getText
().
equals
(
"0"
))
{
isSuccess
=
true
;
}
}
}
JsonFactory
factory
=
new
JsonFactory
();
return
factory
.
createParser
(
result
.
toString
());
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
return
null
;
}
}
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