Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synergy-api-util
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Raimbek Egemberdiev
synergy-api-util
Commits
88291365
Commit
88291365
authored
Nov 25, 2016
by
Raimbek Egemberdiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
метод getFormDefinitionExt
parent
f2e65a2e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
550 additions
and
0 deletions
+550
-0
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
+10
-0
src/main/java/kz/arta/synergy/api/asforms/pojo/AsFormDefinition.java
...va/kz/arta/synergy/api/asforms/pojo/AsFormDefinition.java
+127
-0
src/main/java/kz/arta/synergy/api/asforms/pojo/AsFormProperty.java
...java/kz/arta/synergy/api/asforms/pojo/AsFormProperty.java
+83
-0
src/test/java/kz/arta/synergy/api/asforms/AsFormServiceTest.java
...t/java/kz/arta/synergy/api/asforms/AsFormServiceTest.java
+1
-0
src/test/java/kz/arta/synergy/api/asforms/AsFormsServiceGetExtTest.java
...kz/arta/synergy/api/asforms/AsFormsServiceGetExtTest.java
+35
-0
src/test/resources/data/form-ext.json
src/test/resources/data/form-ext.json
+294
-0
No files found.
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
View file @
88291365
...
...
@@ -158,4 +158,14 @@ public class AsFormService {
return
restHttpQuery
.
doQueryAndReturnBytes
(
query
);
}
public
AsFormDefinition
getFormDefinitionExt
(
String
formId
,
String
formCode
,
String
version
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
url
(
"/rest/api/asforms/form_ext"
)
.
queryParam
(
"formID"
,
formId
)
.
queryParam
(
"formCode"
,
formCode
)
.
queryParam
(
"version"
,
version
);
String
result
=
restHttpQuery
.
doQuery
(
query
);
return
JsonUtils
.
read
(
result
,
AsFormDefinition
.
class
);
}
}
src/main/java/kz/arta/synergy/api/asforms/pojo/AsFormDefinition.java
0 → 100644
View file @
88291365
package
kz.arta.synergy.api.asforms.pojo
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
org.codehaus.jackson.annotate.JsonIgnoreProperties
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author raimbek
* @since 25.11.2016
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AsFormDefinition
{
private
String
uuid
;
private
String
version
;
private
String
typeform
;
private
String
name
;
private
String
nameru
;
private
String
namekz
;
private
String
code
;
private
String
description
;
private
String
type
;
private
Map
<
String
,
String
>
config
;
private
List
<
AsFormProperty
>
properties
;
public
String
getUuid
()
{
return
uuid
;
}
public
void
setUuid
(
String
uuid
)
{
this
.
uuid
=
uuid
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getTypeform
()
{
return
typeform
;
}
public
void
setTypeform
(
String
typeform
)
{
this
.
typeform
=
typeform
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getNameru
()
{
return
nameru
;
}
public
void
setNameru
(
String
nameru
)
{
this
.
nameru
=
nameru
;
}
public
String
getNamekz
()
{
return
namekz
;
}
public
void
setNamekz
(
String
namekz
)
{
this
.
namekz
=
namekz
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Map
<
String
,
String
>
getConfig
()
{
return
config
;
}
public
void
setConfig
(
Map
<
String
,
String
>
config
)
{
this
.
config
=
config
;
}
public
List
<
AsFormProperty
>
getProperties
()
{
return
properties
;
}
public
void
setProperties
(
List
<
AsFormProperty
>
properties
)
{
this
.
properties
=
properties
;
}
public
boolean
hasCmp
(
String
id
)
{
for
(
AsFormProperty
property
:
properties
)
{
if
(
property
.
getId
().
equals
(
id
))
{
return
true
;
}
if
(
property
.
hasCmp
(
id
))
{
return
true
;
}
}
return
false
;
}
}
src/main/java/kz/arta/synergy/api/asforms/pojo/AsFormProperty.java
0 → 100644
View file @
88291365
package
kz.arta.synergy.api.asforms.pojo
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
org.codehaus.jackson.annotate.JsonIgnoreProperties
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author raimbek
* @since 25.11.2016
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AsFormProperty
{
private
String
id
;
private
String
type
;
private
String
label
;
private
Map
<
String
,
Object
>
config
;
private
Map
<
String
,
String
>
style
;
private
List
<
AsFormProperty
>
properties
=
new
ArrayList
<>();
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getLabel
()
{
return
label
;
}
public
void
setLabel
(
String
label
)
{
this
.
label
=
label
;
}
public
Map
<
String
,
Object
>
getConfig
()
{
return
config
;
}
public
void
setConfig
(
Map
<
String
,
Object
>
config
)
{
this
.
config
=
config
;
}
public
Map
<
String
,
String
>
getStyle
()
{
return
style
;
}
public
void
setStyle
(
Map
<
String
,
String
>
style
)
{
this
.
style
=
style
;
}
public
List
<
AsFormProperty
>
getProperties
()
{
return
properties
;
}
public
void
setProperties
(
List
<
AsFormProperty
>
properties
)
{
this
.
properties
=
properties
;
}
public
boolean
hasCmp
(
String
id
)
{
for
(
AsFormProperty
property
:
properties
)
{
if
(
property
.
getId
().
equals
(
id
))
{
return
true
;
}
if
(
property
.
hasCmp
(
id
))
{
return
true
;
}
}
return
false
;
}
}
src/test/java/kz/arta/synergy/api/asforms/AsFormServiceTest.java
View file @
88291365
...
...
@@ -115,4 +115,5 @@ public class AsFormServiceTest {
AsFormData
tableCmp
=
asFormWrapper
.
getData
(
"table_cmp"
);
Assert
.
assertEquals
(
tableCmp
.
getData
().
size
(),
4
);
}
}
src/test/java/kz/arta/synergy/api/asforms/AsFormsServiceGetExtTest.java
0 → 100644
View file @
88291365
package
kz.arta.synergy.api.asforms
;
import
com.google.common.base.Charsets
;
import
com.google.common.io.Resources
;
import
kz.arta.synergy.api.Query
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.RestHttpQuery
;
import
kz.arta.synergy.api.asforms.pojo.AsFormDefinition
;
import
org.mockito.Mockito
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.net.URL
;
/**
* @author raimbek
* @since 25.11.2016
*/
public
class
AsFormsServiceGetExtTest
{
@Test
public
void
testGetFormDefinitionExt
()
throws
Exception
{
URL
url
=
Resources
.
getResource
(
"data/form-ext.json"
);
String
formExtJson
=
Resources
.
toString
(
url
,
Charsets
.
UTF_8
);
RestHttpQuery
restHttpQueryMock
=
Mockito
.
mock
(
RestHttpQuery
.
class
);
Mockito
.
when
(
restHttpQueryMock
.
doQuery
(
Mockito
.
any
(
Query
.
class
))).
thenReturn
(
formExtJson
);
AsFormService
asFormService
=
AsFormService
.
newInstance
(
new
QueryContext
(
"localhost"
)).
setRestHttpQuery
(
restHttpQueryMock
);
AsFormDefinition
formDefinition
=
asFormService
.
getFormDefinitionExt
(
null
,
null
,
null
);
Assert
.
assertTrue
(
formDefinition
.
hasCmp
(
"avtor"
));
Assert
.
assertFalse
(
formDefinition
.
hasCmp
(
"not-cmp"
));
}
}
src/test/resources/data/form-ext.json
0 → 100644
View file @
88291365
{
"uuid"
:
"d339c65f-20af-4e09-8175-8232470af558"
,
"version"
:
1
,
"typeform"
:
"0"
,
"name"
:
"Реестр поручений"
,
"nameru"
:
"Реестр поручений"
,
"namekz"
:
"Реестр поручений"
,
"code"
:
"Реестр_поручений"
,
"description"
:
null
,
"type"
:
"form"
,
"config"
:
{},
"properties"
:
[
{
"id"
:
"cmp-ysik8x"
,
"type"
:
"table"
,
"config"
:
{},
"properties"
:
[
{
"id"
:
"cmp-i8anf4"
,
"type"
:
"label"
,
"config"
:
{},
"label"
:
"Автор:"
,
"style"
:
{
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
},
{
"id"
:
"avtor"
,
"type"
:
"entity"
,
"config"
:
{
"entity"
:
"users"
,
"read-only"
:
true
,
"fill-with-current"
:
true
,
"script"
:
""
,
"customNameFormats"
:
{
"ru"
:
"${l} ${f.short}.${p.short.dot}"
,
"kz"
:
"${l} ${f.short}.${p.short.dot}"
,
"en"
:
"${l} ${f.short}.${p.short.dot}"
}
},
"style"
:
{
"width"
:
"200"
,
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
}
],
"layout"
:
{
"columns"
:
4
,
"rows"
:
1
,
"components"
:
[
{
"id"
:
"cmp-i8anf4"
,
"column"
:
2
,
"row"
:
0
},
{
"id"
:
"avtor"
,
"column"
:
3
,
"row"
:
0
}
]
},
"style"
:
{
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
},
{
"id"
:
"cmp-pjaioc"
,
"type"
:
"table"
,
"config"
:
{},
"properties"
:
[
{
"id"
:
"cmp-1f7nnj"
,
"type"
:
"label"
,
"config"
:
{},
"label"
:
"Поручение"
,
"style"
:
{
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
,
"bold"
:
true
}
},
{
"id"
:
"task"
,
"type"
:
"textarea"
,
"config"
:
{},
"style"
:
{
"width"
:
"400"
,
"height"
:
"60"
,
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
},
{
"id"
:
"cmp-houxfj"
,
"type"
:
"label"
,
"config"
:
{},
"label"
:
"Ответственный"
,
"style"
:
{
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
,
"bold"
:
true
}
},
{
"id"
:
"user"
,
"type"
:
"entity"
,
"config"
:
{
"entity"
:
"users"
,
"read-only"
:
false
,
"customNameFormats"
:
{
"ru"
:
"${l} ${f} ${p}"
,
"kz"
:
"${l} ${f} ${p}"
,
"en"
:
"${l} ${f} ${p}"
},
"script"
:
""
},
"style"
:
{
"width"
:
"400"
,
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
}
],
"layout"
:
{
"columns"
:
2
,
"rows"
:
2
,
"config"
:
[
{
"column"
:
0
,
"width"
:
"300"
}
],
"components"
:
[
{
"id"
:
"cmp-1f7nnj"
,
"column"
:
0
,
"row"
:
0
},
{
"id"
:
"task"
,
"column"
:
1
,
"row"
:
0
},
{
"id"
:
"cmp-houxfj"
,
"column"
:
0
,
"row"
:
1
},
{
"id"
:
"user"
,
"column"
:
1
,
"row"
:
1
}
]
},
"style"
:
{
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
},
{
"id"
:
"cmp-6euqrr"
,
"type"
:
"label"
,
"config"
:
{},
"label"
:
" "
,
"style"
:
{
"height"
:
"15"
,
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
},
{
"id"
:
"cmp-h7st94"
,
"type"
:
"table"
,
"config"
:
{},
"properties"
:
[
{
"id"
:
"cmp-txmcm4"
,
"type"
:
"label"
,
"config"
:
{},
"label"
:
"Ссылка на проект"
,
"style"
:
{
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
,
"bold"
:
true
}
},
{
"id"
:
"project"
,
"type"
:
"projectlink"
,
"config"
:
{},
"style"
:
{
"width"
:
"400"
,
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
}
],
"layout"
:
{
"columns"
:
2
,
"rows"
:
1
,
"config"
:
[
{
"column"
:
0
,
"width"
:
"300"
}
],
"components"
:
[
{
"id"
:
"cmp-txmcm4"
,
"column"
:
0
,
"row"
:
0
},
{
"id"
:
"project"
,
"column"
:
1
,
"row"
:
0
}
]
},
"style"
:
{
"align"
:
"left"
,
"font"
:
"Arial"
,
"fontsize"
:
"12"
}
}
],
"data"
:
[
{
"id"
:
"avtor"
,
"type"
:
"entity"
,
"formatVersion"
:
"V1"
},
{
"id"
:
"user"
,
"type"
:
"entity"
,
"formatVersion"
:
"V1"
},
{
"id"
:
"project"
,
"default"
:
"{
\"
valueID
\"
:null,
\"
value
\"
:null}"
}
],
"datasources"
:
[],
"pointers"
:
[],
"collations"
:
[],
"layout"
:
{
"totalPages"
:
1
,
"pages"
:
[
{
"page"
:
1
,
"columns"
:
1
,
"rows"
:
5
,
"components"
:
[
{
"id"
:
"cmp-ysik8x"
,
"column"
:
0
,
"row"
:
0
},
{
"id"
:
"cmp-pjaioc"
,
"column"
:
0
,
"row"
:
2
},
{
"id"
:
"cmp-6euqrr"
,
"column"
:
0
,
"row"
:
3
},
{
"id"
:
"cmp-h7st94"
,
"column"
:
0
,
"row"
:
4
}
]
}
]
}
}
\ 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