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
6ebd14df
Commit
6ebd14df
authored
Jan 30, 2017
by
everdarkgreen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JsonNode: (draft13) adding headers to empty card
parent
cdeba25a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
17 deletions
+71
-17
nbactions.xml
nbactions.xml
+1
-1
.gitignore
src/main/.gitignore
+0
-1
Main.java
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
+42
-15
table_header.json
src/main/resources/table_header.json
+28
-0
No files found.
nbactions.xml
View file @
6ebd14df
...
...
@@ -7,7 +7,7 @@
</packagings>
<goals>
<goal>
install
</goal>
<goal>
checkstyle:check
</goal>
</goals>
</action>
</actions>
src/main/.gitignore
View file @
6ebd14df
/resources/
src/main/java/kz/arta/synergy/astdev/custom_bp/Main.java
View file @
6ebd14df
...
...
@@ -12,7 +12,9 @@ import javax.jms.Message;
import
javax.jms.MessageListener
;
import
javax.jms.TextMessage
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
...
...
@@ -25,6 +27,7 @@ import javax.ejb.ActivationConfigProperty;
import
javax.ejb.MessageDriven
;
import
javax.naming.NameNotFoundException
;
import
javax.naming.directory.AttributeModificationException
;
import
javax.servlet.ServletContext
;
import
javax.xml.bind.DatatypeConverter
;
import
kz.arta.synergy.api.rest.sample.asforms.APIFormsServiceSave
;
import
org.codehaus.jackson.map.DeserializationConfig
;
...
...
@@ -60,7 +63,8 @@ public class Main implements MessageListener {
private
static
final
String
LOGIN
=
"Ипатьев"
;
private
static
final
String
PASSWORD
=
"1"
;
private
final
String
TARGET_FORM_UUID
=
"fb44d99d-1579-4ac3-884a-01a6d4f71f9c"
;
// private final String TARGET_FORM_UUID = "fb44d99d-1579-4ac3-884a-01a6d4f71f9c"; // home
private
final
String
TARGET_FORM_UUID
=
"04f7809d-f44c-4a2d-950d-6aa8e6c3fea1"
;
// work
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
;
...
...
@@ -111,6 +115,8 @@ public class Main implements MessageListener {
// Configure ObjectMapper
OBJECT_MAPPER
.
configure
(
DeserializationConfig
.
Feature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
constructTableHeader
();
// SOURCE FORM: Получение данных исходной формы (той, по которой запущен маршрут)
URL
sourceFormURL
=
new
URL
(
SYNERGY_ADDRESS
+
"/rest/api/asforms/data/"
+
SOURCE_FORM_DATA_UUID
);
String
sourceFormDataAsString
=
synergyApiGetString
(
sourceFormURL
);
...
...
@@ -126,6 +132,9 @@ public class Main implements MessageListener {
// TARGET FORM: Получение ID пользователя указанного в форме
String
userID
=
getComponentValueByID
(
this
.
sourceFormData
,
"user1"
,
FieldType
.
KEY
);
if
(
userID
==
null
)
{
throw
new
Exception
(
"User in not specified in the order (value of \"user1\" field is not found)"
);
}
// По ID пользователя указанного в карточке и ID формы получаем DataUUID целевой карточки (ID for work: "04f7809d-f44c-4a2d-950d-6aa8e6c3fea1")
TARGET_FORM_DATA_UUID
=
getCardDataUUID
(
userID
,
TARGET_FORM_UUID
);
// Получение данных целевой карточки по dataUUID
...
...
@@ -143,45 +152,58 @@ public class Main implements MessageListener {
targetFormData
=
OBJECT_MAPPER
.
readValue
(
TargetRootDataNode
,
new
TypeReference
<
List
<
AsNode
>>()
{});
// common vacation period
String
dateStart
=
getComponentValueByID
(
this
.
sourceFormData
,
"date_start"
,
FieldType
.
KEY
);
String
dateFinish
=
getComponentValueByID
(
this
.
sourceFormData
,
"date_finish"
,
FieldType
.
KEY
);
if
(
dateStart
==
null
||
dateFinish
==
null
)
{
String
vacStart
=
getComponentValueByID
(
this
.
sourceFormData
,
"date_start"
,
FieldType
.
KEY
);
String
vacEnd
=
getComponentValueByID
(
this
.
sourceFormData
,
"date_finish"
,
FieldType
.
KEY
);
String
days
=
getComponentValueByID
(
this
.
sourceFormData
,
"days"
,
FieldType
.
VALUE
);
if
(
vacStart
==
null
||
vacEnd
==
null
)
{
throw
new
Exception
(
"Vacation period is not specified"
);
}
// first table
// first table
- periods
String
b2b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"b2-b1"
,
FieldType
.
KEY
);
String
b4b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"b4-b1"
,
FieldType
.
KEY
);
// first table - num of days
String
b5b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"b5-b1"
,
FieldType
.
VALUE
);
if
(
notNull
(
b2b1
,
b4b1
))
{
// отображается key
constructNewTableRow
(
b2b1
,
b4b1
,
dateStart
,
dateFinish
);
constructNewTableRow
(
vacStart
,
vacEnd
,
b2b1
,
b4b1
,
b5b1
);
updateTargetForm
();
return
;
}
// second table - periods
String
t4b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t4-b1"
,
FieldType
.
KEY
);
String
t6b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t6-b1"
,
FieldType
.
KEY
);
String
t10b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t10-b1"
,
FieldType
.
KEY
);
String
t12b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t12-b1"
,
FieldType
.
KEY
);
// second table - num of days
String
t2b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t2-b1"
,
FieldType
.
VALUE
);
String
t8b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t8-b1"
,
FieldType
.
VALUE
);
if
(
notNull
(
t4b1
,
t6b1
,
t10b1
,
t12b1
))
{
constructNewTableRow
(
t4b1
,
t6b1
,
dateStart
,
dateFinish
);
constructNewTableRow
(
t10b1
,
t12b1
,
dateStart
,
dateFinish
);
constructNewTableRow
(
vacStart
,
vacEnd
,
t4b1
,
t6b1
,
t2b1
);
constructNewTableRow
(
vacStart
,
vacEnd
,
t10b1
,
t12b1
,
t8b1
);
updateTargetForm
();
return
;
}
// third table - periods
String
t18b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t18-b1"
,
FieldType
.
KEY
);
String
t20b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t20-b1"
,
FieldType
.
KEY
);
String
t24b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t24-b1"
,
FieldType
.
KEY
);
String
t26b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t26-b1"
,
FieldType
.
KEY
);
String
t30b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t30-b1"
,
FieldType
.
KEY
);
String
t32b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t32-b1"
,
FieldType
.
KEY
);
// third table - num of days
String
t16b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t16-b1"
,
FieldType
.
VALUE
);
String
t22b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t22-b1"
,
FieldType
.
VALUE
);
String
t28b1
=
getComponentValueByID
(
this
.
sourceFormData
,
"t28-b1"
,
FieldType
.
VALUE
);
if
(
notNull
(
t18b1
,
t20b1
,
t24b1
,
t26b1
,
t30b1
,
t32b1
))
{
constructNewTableRow
(
t18b1
,
t20b1
,
dateStart
,
dateFinish
);
constructNewTableRow
(
t24b1
,
t26b1
,
dateStart
,
dateFinish
);
constructNewTableRow
(
t30b1
,
t32b1
,
dateStart
,
dateFinish
);
constructNewTableRow
(
vacStart
,
vacEnd
,
t18b1
,
t20b1
,
t16b1
);
constructNewTableRow
(
vacStart
,
vacEnd
,
t24b1
,
t26b1
,
t22b1
);
constructNewTableRow
(
vacStart
,
vacEnd
,
t30b1
,
t32b1
,
t28b1
);
updateTargetForm
();
return
;
}
...
...
@@ -193,6 +215,12 @@ public class Main implements MessageListener {
}
}
private
List
<
AsNode
>
constructTableHeader
()
throws
IOException
{
InputStream
inputStream
=
getClass
().
getClassLoader
().
getResourceAsStream
(
"table_header.json"
);
List
<
AsNode
>
l
=
OBJECT_MAPPER
.
readValue
(
inputStream
,
new
TypeReference
<
List
<
AsNode
>>()
{});
return
l
;
}
private
static
boolean
notNull
(
Object
...
args
)
{
for
(
Object
arg
:
args
)
{
if
(
arg
==
null
)
{
...
...
@@ -202,7 +230,7 @@ public class Main implements MessageListener {
return
true
;
}
private
void
constructNewTableRow
(
String
vacStart
,
String
vacEnd
,
String
perStart
,
String
perEnd
)
throws
Exception
{
private
void
constructNewTableRow
(
String
vacStart
,
String
vacEnd
,
String
perStart
,
String
perEnd
,
String
numDays
)
throws
Exception
{
AsNode
tableNode
=
findNode
(
targetFormData
,
"table"
);
if
(
tableNode
!=
null
)
{
List
<
AsNode
>
tableDataNodesList
=
tableNode
.
getData
();
...
...
@@ -231,13 +259,12 @@ public class Main implements MessageListener {
n3
.
setId
(
"days-b"
+
tablesCounter
);
n3
.
setType
(
"textbox"
);
n3
.
setLabel
(
" "
);
// n3.setValue(Integer.toString(dateDiffToDays(b2b1, b4b1)));
n3
.
setValue
(
""
);
n3
.
setValue
(
numDays
);
n4
.
setId
(
"matpom-b"
+
tablesCounter
);
n4
.
setType
(
"listbox"
);
n4
.
setValue
(
""
);
n4
.
setKey
(
"
1"
);
n4
.
setKey
(
"
"
);
// TODO: Update or not update?
n5
.
setId
(
"period_start-b"
+
tablesCounter
);
n5
.
setType
(
"date"
);
...
...
src/main/resources/table_header.json
0 → 100644
View file @
6ebd14df
[
{
"id"
:
"cmp-9s7zv2"
,
"type"
:
"label"
,
"label"
:
"Дата начала "
},
{
"id"
:
"cmp-lvooqn"
,
"type"
:
"label"
,
"label"
:
"Дата завершения "
},
{
"id"
:
"cmp-dcqvt9"
,
"type"
:
"label"
,
"label"
:
"Количество дней"
},
{
"id"
:
"cmp-828sd4"
,
"type"
:
"label"
,
"label"
:
"с выплатой материальной помощи"
},
{
"id"
:
"jgj"
,
"type"
:
"label"
,
"label"
:
"Дата начала периода"
},
{
"id"
:
"pejgjk"
,
"type"
:
"label"
,
"label"
:
"Дата завершения периода"
}
]
\ No newline at end of file
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