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
8020154f
Commit
8020154f
authored
Nov 14, 2016
by
Raimbek Egemberdiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
рефакторинг импорта платежей
parent
b4b09319
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
2 deletions
+84
-2
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
+3
-2
src/main/java/kz/arta/synergy/api/asforms/annotations/Radio.java
...n/java/kz/arta/synergy/api/asforms/annotations/Radio.java
+23
-0
src/main/java/kz/arta/synergy/api/asforms/converter/DefaultAsFormConverter.java
...synergy/api/asforms/converter/DefaultAsFormConverter.java
+1
-0
src/main/java/kz/arta/synergy/api/asforms/converter/components/RadioConverter.java
...ergy/api/asforms/converter/components/RadioConverter.java
+57
-0
No files found.
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
View file @
8020154f
...
...
@@ -142,7 +142,8 @@ public class AsFormService {
}
public
<
T
extends
AsForm
>
String
saveData
(
T
asForm
)
throws
IOException
{
return
saveData
(
asFormConverter
.
toAsfData
(
asForm
));
AsFormWrapper
asFormWrapper
=
asFormConverter
.
toAsfData
(
asForm
);
return
saveData
(
asFormWrapper
);
}
public
<
T
extends
AsForm
>
AsFormWrapper
toAsfData
(
T
asForm
)
{
...
...
src/main/java/kz/arta/synergy/api/asforms/annotations/Radio.java
0 → 100644
View file @
8020154f
package
kz.arta.synergy.api.asforms.annotations
;
import
kz.arta.synergy.api.asforms.pojo.DefaultListBoxDictionary
;
import
kz.arta.synergy.api.asforms.pojo.ListBoxDictionary
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* @author raimbek
* @since 09.11.2016
*/
@Target
(
ElementType
.
FIELD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Radio
{
String
id
()
default
""
;
Class
<?
extends
ListBoxDictionary
>
dictionary
()
default
DefaultListBoxDictionary
.
class
;
}
src/main/java/kz/arta/synergy/api/asforms/converter/DefaultAsFormConverter.java
View file @
8020154f
...
...
@@ -31,6 +31,7 @@ public class DefaultAsFormConverter implements AsFormConverter {
registerConverter
(
ListBox
.
class
,
new
ListBoxConverter
());
registerConverter
(
Table
.
class
,
new
TableConverter
(
this
));
registerConverter
(
DateCmp
.
class
,
new
DateConverter
());
registerConverter
(
Radio
.
class
,
new
RadioConverter
());
}
@Override
...
...
src/main/java/kz/arta/synergy/api/asforms/converter/components/RadioConverter.java
0 → 100644
View file @
8020154f
package
kz.arta.synergy.api.asforms.converter.components
;
import
kz.arta.synergy.api.asforms.annotations.Radio
;
import
kz.arta.synergy.api.asforms.pojo.AsFormData
;
import
kz.arta.synergy.api.asforms.pojo.ComponentTypes
;
import
kz.arta.synergy.api.asforms.pojo.ListBoxDictionary
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Field
;
/**
* @author raimbek
* @since 11.11.2016
*/
public
class
RadioConverter
extends
AbstractComponentConverter
{
@Override
public
<
T
>
AsFormData
toAsfData
(
T
asForm
,
Field
field
,
Annotation
annotation
,
String
index
)
throws
IllegalAccessException
{
field
.
setAccessible
(
true
);
String
cmpId
=
getCmpId
(
field
,
annotation
,
index
);
AsFormData
asFormData
=
AsFormData
.
create
(
cmpId
,
getType
(
annotation
));
Object
valueObject
=
field
.
get
(
asForm
);
if
(
valueObject
instanceof
AsFormData
)
{
AsFormData
asFormDataObject
=
(
AsFormData
)
valueObject
;
asFormDataObject
.
setId
(
cmpId
);
asFormDataObject
.
setType
(
getType
(
annotation
));
return
asFormDataObject
;
}
else
{
String
value
=
String
.
valueOf
(
valueObject
);
try
{
ListBoxDictionary
listBoxDictionary
=
((
Radio
)
annotation
).
dictionary
().
newInstance
();
if
(
hasKeyValueAnnotation
(
field
))
{
asFormData
.
setKey
(
value
);
asFormData
.
setValue
(
listBoxDictionary
.
getValue
(
value
));
}
else
{
asFormData
.
setValue
(
value
);
asFormData
.
setKey
(
listBoxDictionary
.
getValue
(
value
));
}
}
catch
(
InstantiationException
e
)
{
e
.
printStackTrace
();
}
}
return
asFormData
;
}
@Override
public
String
getType
(
Annotation
annotation
)
{
return
ComponentTypes
.
RADIO
;
}
@Override
public
String
getCmpId
(
Annotation
annotation
)
{
return
((
Radio
)
annotation
).
id
();
}
}
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