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
Show 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;
...
@@ -4,8 +4,8 @@ import kz.arta.synergy.api.JsonUtils;
import
kz.arta.synergy.api.Query
;
import
kz.arta.synergy.api.Query
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.RestHttpQuery
;
import
kz.arta.synergy.api.RestHttpQuery
;
import
kz.arta.synergy.api.asforms.converter.As
f
FormConverter
;
import
kz.arta.synergy.api.asforms.converter.AsFormConverter
;
import
kz.arta.synergy.api.asforms.converter.DefaultAs
f
FormConverter
;
import
kz.arta.synergy.api.asforms.converter.DefaultAsFormConverter
;
import
kz.arta.synergy.api.asforms.pojo.AdvancedSearchParams
;
import
kz.arta.synergy.api.asforms.pojo.AdvancedSearchParams
;
import
kz.arta.synergy.api.asforms.pojo.AdvancedSearchResult
;
import
kz.arta.synergy.api.asforms.pojo.AdvancedSearchResult
;
import
kz.arta.synergy.api.asforms.pojo.AsForm
;
import
kz.arta.synergy.api.asforms.pojo.AsForm
;
...
@@ -22,7 +22,7 @@ import java.util.List;
...
@@ -22,7 +22,7 @@ import java.util.List;
public
class
AsFormService
{
public
class
AsFormService
{
private
RestHttpQuery
restHttpQuery
;
private
RestHttpQuery
restHttpQuery
;
private
As
fFormConverter
asf
FormConverter
;
private
As
FormConverter
as
FormConverter
;
private
AsFormService
(
QueryContext
context
)
{
private
AsFormService
(
QueryContext
context
)
{
this
.
restHttpQuery
=
new
RestHttpQuery
(
context
);
this
.
restHttpQuery
=
new
RestHttpQuery
(
context
);
...
@@ -30,10 +30,24 @@ public class AsFormService {
...
@@ -30,10 +30,24 @@ public class AsFormService {
public
static
AsFormService
newInstance
(
QueryContext
context
)
{
public
static
AsFormService
newInstance
(
QueryContext
context
)
{
AsFormService
asFormService
=
new
AsFormService
(
context
);
AsFormService
asFormService
=
new
AsFormService
(
context
);
asFormService
.
as
fFormConverter
=
new
DefaultAsf
FormConverter
();
asFormService
.
as
FormConverter
=
new
DefaultAs
FormConverter
();
return
asFormService
;
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
{
public
List
<
AdvancedSearchResult
>
advancedSearch
(
AdvancedSearchParams
searchParams
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
Query
query
=
Query
.
newInstance
()
.
methodPost
()
.
methodPost
()
...
@@ -51,34 +65,31 @@ public class AsFormService {
...
@@ -51,34 +65,31 @@ public class AsFormService {
));
));
}
}
public
<
T
extends
AsForm
>
T
fetch
(
Class
<
T
>
formClass
,
String
dataUUID
)
throws
IOException
{
public
<
T
extends
AsForm
>
T
getData
(
Class
<
T
>
formClass
,
String
dataUUID
)
throws
IOException
{
String
data
=
restHttpQuery
.
doQuery
(
Query
.
newInstance
().
url
(
"/rest/api/asforms/data/"
+
dataUUID
));
return
asFormConverter
.
toAsForm
(
formClass
,
getData
(
dataUUID
));
return
asfFormConverter
.
toAsForm
(
formClass
,
JsonUtils
.
read
(
data
,
AsFormWrapper
.
class
));
}
}
public
<
T
extends
AsForm
>
String
save
(
T
asForm
)
throws
IOException
{
public
AsFormWrapper
getData
(
String
dataUUID
)
throws
IOException
{
AsFormWrapper
asFormWrapper
=
asfFormConverter
.
toAsfData
(
asForm
);
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
()
Query
query
=
Query
.
newInstance
()
.
methodPost
()
.
methodPost
()
.
url
(
"/rest/api/asforms/data/save"
)
.
url
(
"/rest/api/asforms/data/save"
)
.
formParam
(
"formUUID"
,
asForm
.
getForm
())
.
formParam
(
"formUUID"
,
asFormWrapper
.
getForm
())
.
formParam
(
"uuid"
,
asForm
.
getUuid
())
.
formParam
(
"uuid"
,
asFormWrapper
.
getUuid
())
.
formParam
(
"data"
,
"\"data\":"
+
JsonUtils
.
toJson
(
asFormWrapper
.
getData
()));
.
formParam
(
"data"
,
"\"data\":"
+
JsonUtils
.
toJson
(
asFormWrapper
.
getData
()));
return
restHttpQuery
.
doQuery
(
query
);
return
restHttpQuery
.
doQuery
(
query
);
}
}
public
<
T
extends
AsForm
>
AsFormWrapper
toAsfData
(
T
asForm
)
{
public
<
T
extends
AsForm
>
String
saveData
(
T
asForm
)
throws
IOException
{
return
asfFormConverter
.
toAsfData
(
asForm
);
return
saveData
(
asFormConverter
.
toAsfData
(
asForm
));
}
public
RestHttpQuery
getRestHttpQuery
()
{
return
restHttpQuery
;
}
}
public
AsFormService
setRestHttpQuery
(
RestHttpQuery
restHttpQuery
)
{
public
<
T
extends
AsForm
>
AsFormWrapper
toAsfData
(
T
asForm
)
{
this
.
restHttpQuery
=
restHttpQuery
;
return
asFormConverter
.
toAsfData
(
asForm
);
return
this
;
}
}
}
}
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;
...
@@ -11,7 +11,7 @@ import java.lang.annotation.Annotation;
* @author raimbek
* @author raimbek
* @since 11.11.2016
* @since 11.11.2016
*/
*/
public
interface
As
f
FormConverter
{
public
interface
AsFormConverter
{
<
T
extends
AsForm
>
AsFormWrapper
toAsfData
(
T
asForm
);
<
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;
...
@@ -17,11 +17,11 @@ import java.util.Map;
* @author raimbek
* @author raimbek
* @since 11.11.2016
* @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
<>();
Map
<
Class
<?
extends
Annotation
>,
ComponentConverter
>
componentConverters
=
new
HashMap
<>();
public
DefaultAs
f
FormConverter
()
{
public
DefaultAsFormConverter
()
{
registerConverter
(
Cmp
.
class
,
new
CommonConverter
());
registerConverter
(
Cmp
.
class
,
new
CommonConverter
());
registerConverter
(
TextBox
.
class
,
new
TextBoxConverter
());
registerConverter
(
TextBox
.
class
,
new
TextBoxConverter
());
registerConverter
(
NumericInput
.
class
,
new
NumericInputConverter
());
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;
...
@@ -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.AsfTableUtil
;
import
kz.arta.synergy.api.asforms.annotations.Table
;
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.exceptions.UnsupportedFieldTypeException
;
import
kz.arta.synergy.api.asforms.pojo.AsFormData
;
import
kz.arta.synergy.api.asforms.pojo.AsFormData
;
import
kz.arta.synergy.api.asforms.pojo.AsFormDataContainer
;
import
kz.arta.synergy.api.asforms.pojo.AsFormDataContainer
;
...
@@ -20,10 +20,10 @@ import java.util.Set;
...
@@ -20,10 +20,10 @@ import java.util.Set;
*/
*/
public
class
TableConverter
extends
AbstractComponentConverter
{
public
class
TableConverter
extends
AbstractComponentConverter
{
private
As
fFormConverter
asf
FormConverter
;
private
As
FormConverter
as
FormConverter
;
public
TableConverter
(
As
fFormConverter
asf
FormConverter
)
{
public
TableConverter
(
As
FormConverter
as
FormConverter
)
{
this
.
as
fFormConverter
=
asf
FormConverter
;
this
.
as
FormConverter
=
as
FormConverter
;
}
}
@Override
@Override
...
@@ -72,7 +72,7 @@ public class TableConverter extends AbstractComponentConverter {
...
@@ -72,7 +72,7 @@ public class TableConverter extends AbstractComponentConverter {
field
.
setAccessible
(
true
);
field
.
setAccessible
(
true
);
List
tableList
=
(
List
)
field
.
get
(
asForm
);
List
tableList
=
(
List
)
field
.
get
(
asForm
);
for
(
int
bIndex
=
1
;
bIndex
<=
tableList
.
size
();
bIndex
++)
{
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
())
{
for
(
AsFormData
asFormData
:
asFormDataContainer
.
getData
())
{
tableData
.
addData
(
asFormData
);
tableData
.
addData
(
asFormData
);
}
}
...
@@ -90,7 +90,7 @@ public class TableConverter extends AbstractComponentConverter {
...
@@ -90,7 +90,7 @@ public class TableConverter extends AbstractComponentConverter {
List
table
=
new
ArrayList
<>();
List
table
=
new
ArrayList
<>();
Set
<
String
>
indexes
=
AsfTableUtil
.
tableBIndexes
(
tableData
);
Set
<
String
>
indexes
=
AsfTableUtil
.
tableBIndexes
(
tableData
);
for
(
String
index
:
indexes
)
{
for
(
String
index
:
indexes
)
{
table
.
add
(
as
f
FormConverter
.
toAsForm
(
genericType
,
tableData
,
index
));
table
.
add
(
asFormConverter
.
toAsForm
(
genericType
,
tableData
,
index
));
}
}
return
table
;
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