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
27e0f42b
Commit
27e0f42b
authored
Nov 11, 2016
by
Raimbek Egemberdiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advanced search one
parent
c4a7691e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
33 deletions
+44
-33
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
+35
-24
src/main/java/kz/arta/synergy/api/asforms/converter/AsFormConverter.java
...z/arta/synergy/api/asforms/converter/AsFormConverter.java
+1
-1
src/main/java/kz/arta/synergy/api/asforms/converter/DefaultAsFormConverter.java
...synergy/api/asforms/converter/DefaultAsFormConverter.java
+2
-2
src/main/java/kz/arta/synergy/api/asforms/converter/components/TableConverter.java
...ergy/api/asforms/converter/components/TableConverter.java
+6
-6
No files found.
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
View file @
27e0f42b
...
...
@@ -4,8 +4,8 @@ import kz.arta.synergy.api.JsonUtils;
import
kz.arta.synergy.api.Query
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.RestHttpQuery
;
import
kz.arta.synergy.api.asforms.converter.As
f
FormConverter
;
import
kz.arta.synergy.api.asforms.converter.DefaultAs
f
FormConverter
;
import
kz.arta.synergy.api.asforms.converter.AsFormConverter
;
import
kz.arta.synergy.api.asforms.converter.DefaultAsFormConverter
;
import
kz.arta.synergy.api.asforms.pojo.AdvancedSearchParams
;
import
kz.arta.synergy.api.asforms.pojo.AdvancedSearchResult
;
import
kz.arta.synergy.api.asforms.pojo.AsForm
;
...
...
@@ -22,7 +22,7 @@ import java.util.List;
public
class
AsFormService
{
private
RestHttpQuery
restHttpQuery
;
private
As
fFormConverter
asf
FormConverter
;
private
As
FormConverter
as
FormConverter
;
private
AsFormService
(
QueryContext
context
)
{
this
.
restHttpQuery
=
new
RestHttpQuery
(
context
);
...
...
@@ -30,10 +30,24 @@ public class AsFormService {
public
static
AsFormService
newInstance
(
QueryContext
context
)
{
AsFormService
asFormService
=
new
AsFormService
(
context
);
asFormService
.
as
fFormConverter
=
new
DefaultAsf
FormConverter
();
asFormService
.
as
FormConverter
=
new
DefaultAs
FormConverter
();
return
asFormService
;
}
public
RestHttpQuery
getRestHttpQuery
()
{
return
restHttpQuery
;
}
public
AsFormService
setRestHttpQuery
(
RestHttpQuery
restHttpQuery
)
{
this
.
restHttpQuery
=
restHttpQuery
;
return
this
;
}
public
AsFormService
setFormConverter
(
AsFormConverter
converter
)
{
this
.
asFormConverter
=
converter
;
return
this
;
}
public
List
<
AdvancedSearchResult
>
advancedSearch
(
AdvancedSearchParams
searchParams
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
methodPost
()
...
...
@@ -47,38 +61,35 @@ public class AsFormService {
public
List
<
AdvancedSearchResult
>
advancedSearch
(
String
formId
,
String
key
,
String
value
)
throws
IOException
{
return
advancedSearch
(
AdvancedSearchParams
.
build
(
String
.
format
(
"where uuid='%s' and %s='%s'"
,
formId
,
key
,
value
),
key
String
.
format
(
"where uuid='%s' and %s='%s'"
,
formId
,
key
,
value
),
key
));
}
public
<
T
extends
AsForm
>
T
fetch
(
Class
<
T
>
formClass
,
String
dataUUID
)
throws
IOException
{
String
data
=
restHttpQuery
.
doQuery
(
Query
.
newInstance
().
url
(
"/rest/api/asforms/data/"
+
dataUUID
));
return
asfFormConverter
.
toAsForm
(
formClass
,
JsonUtils
.
read
(
data
,
AsFormWrapper
.
class
));
public
<
T
extends
AsForm
>
T
getData
(
Class
<
T
>
formClass
,
String
dataUUID
)
throws
IOException
{
return
asFormConverter
.
toAsForm
(
formClass
,
getData
(
dataUUID
));
}
public
<
T
extends
AsForm
>
String
save
(
T
asForm
)
throws
IOException
{
AsFormWrapper
asFormWrapper
=
asfFormConverter
.
toAsfData
(
asForm
);
public
AsFormWrapper
getData
(
String
dataUUID
)
throws
IOException
{
String
data
=
restHttpQuery
.
doQuery
(
Query
.
newInstance
().
url
(
"/rest/api/asforms/data/"
+
dataUUID
));
return
JsonUtils
.
read
(
data
,
AsFormWrapper
.
class
);
}
public
String
saveData
(
AsFormWrapper
asFormWrapper
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
methodPost
()
.
url
(
"/rest/api/asforms/data/save"
)
.
formParam
(
"formUUID"
,
asForm
.
getForm
())
.
formParam
(
"uuid"
,
asForm
.
getUuid
())
.
formParam
(
"data"
,
"\"data\":"
+
JsonUtils
.
toJson
(
asFormWrapper
.
getData
()));
.
methodPost
()
.
url
(
"/rest/api/asforms/data/save"
)
.
formParam
(
"formUUID"
,
asFormWrapper
.
getForm
())
.
formParam
(
"uuid"
,
asFormWrapper
.
getUuid
())
.
formParam
(
"data"
,
"\"data\":"
+
JsonUtils
.
toJson
(
asFormWrapper
.
getData
()));
return
restHttpQuery
.
doQuery
(
query
);
}
public
<
T
extends
AsForm
>
AsFormWrapper
toAsfData
(
T
asForm
)
{
return
asfFormConverter
.
toAsfData
(
asForm
);
}
public
RestHttpQuery
getRestHttpQuery
()
{
return
restHttpQuery
;
public
<
T
extends
AsForm
>
String
saveData
(
T
asForm
)
throws
IOException
{
return
saveData
(
asFormConverter
.
toAsfData
(
asForm
));
}
public
AsFormService
setRestHttpQuery
(
RestHttpQuery
restHttpQuery
)
{
this
.
restHttpQuery
=
restHttpQuery
;
return
this
;
public
<
T
extends
AsForm
>
AsFormWrapper
toAsfData
(
T
asForm
)
{
return
asFormConverter
.
toAsfData
(
asForm
);
}
}
src/main/java/kz/arta/synergy/api/asforms/converter/As
f
FormConverter.java
→
src/main/java/kz/arta/synergy/api/asforms/converter/AsFormConverter.java
View file @
27e0f42b
...
...
@@ -11,7 +11,7 @@ import java.lang.annotation.Annotation;
* @author raimbek
* @since 11.11.2016
*/
public
interface
As
f
FormConverter
{
public
interface
AsFormConverter
{
<
T
extends
AsForm
>
AsFormWrapper
toAsfData
(
T
asForm
);
...
...
src/main/java/kz/arta/synergy/api/asforms/converter/DefaultAs
f
FormConverter.java
→
src/main/java/kz/arta/synergy/api/asforms/converter/DefaultAsFormConverter.java
View file @
27e0f42b
...
...
@@ -17,11 +17,11 @@ import java.util.Map;
* @author raimbek
* @since 11.11.2016
*/
public
class
DefaultAs
fFormConverter
implements
Asf
FormConverter
{
public
class
DefaultAs
FormConverter
implements
As
FormConverter
{
Map
<
Class
<?
extends
Annotation
>,
ComponentConverter
>
componentConverters
=
new
HashMap
<>();
public
DefaultAs
f
FormConverter
()
{
public
DefaultAsFormConverter
()
{
registerConverter
(
Cmp
.
class
,
new
CommonConverter
());
registerConverter
(
TextBox
.
class
,
new
TextBoxConverter
());
registerConverter
(
NumericInput
.
class
,
new
NumericInputConverter
());
...
...
src/main/java/kz/arta/synergy/api/asforms/converter/components/TableConverter.java
View file @
27e0f42b
...
...
@@ -2,7 +2,7 @@ package kz.arta.synergy.api.asforms.converter.components;
import
kz.arta.synergy.api.asforms.AsfTableUtil
;
import
kz.arta.synergy.api.asforms.annotations.Table
;
import
kz.arta.synergy.api.asforms.converter.As
f
FormConverter
;
import
kz.arta.synergy.api.asforms.converter.AsFormConverter
;
import
kz.arta.synergy.api.asforms.exceptions.UnsupportedFieldTypeException
;
import
kz.arta.synergy.api.asforms.pojo.AsFormData
;
import
kz.arta.synergy.api.asforms.pojo.AsFormDataContainer
;
...
...
@@ -20,10 +20,10 @@ import java.util.Set;
*/
public
class
TableConverter
extends
AbstractComponentConverter
{
private
As
fFormConverter
asf
FormConverter
;
private
As
FormConverter
as
FormConverter
;
public
TableConverter
(
As
fFormConverter
asf
FormConverter
)
{
this
.
as
fFormConverter
=
asf
FormConverter
;
public
TableConverter
(
As
FormConverter
as
FormConverter
)
{
this
.
as
FormConverter
=
as
FormConverter
;
}
@Override
...
...
@@ -72,7 +72,7 @@ public class TableConverter extends AbstractComponentConverter {
field
.
setAccessible
(
true
);
List
tableList
=
(
List
)
field
.
get
(
asForm
);
for
(
int
bIndex
=
1
;
bIndex
<=
tableList
.
size
();
bIndex
++)
{
AsFormDataContainer
asFormDataContainer
=
as
f
FormConverter
.
toAsfData
(
tableList
.
get
(
bIndex
-
1
),
String
.
valueOf
(
bIndex
));
AsFormDataContainer
asFormDataContainer
=
asFormConverter
.
toAsfData
(
tableList
.
get
(
bIndex
-
1
),
String
.
valueOf
(
bIndex
));
for
(
AsFormData
asFormData
:
asFormDataContainer
.
getData
())
{
tableData
.
addData
(
asFormData
);
}
...
...
@@ -90,7 +90,7 @@ public class TableConverter extends AbstractComponentConverter {
List
table
=
new
ArrayList
<>();
Set
<
String
>
indexes
=
AsfTableUtil
.
tableBIndexes
(
tableData
);
for
(
String
index
:
indexes
)
{
table
.
add
(
as
f
FormConverter
.
toAsForm
(
genericType
,
tableData
,
index
));
table
.
add
(
asFormConverter
.
toAsForm
(
genericType
,
tableData
,
index
));
}
return
table
;
}
...
...
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