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
10a8de6e
Commit
10a8de6e
authored
Nov 13, 2016
by
Raimbek Egemberdiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
organization form
parent
c0765907
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
2 deletions
+54
-2
src/main/java/kz/arta/synergy/api/asforms/annotations/ListBox.java
...java/kz/arta/synergy/api/asforms/annotations/ListBox.java
+6
-1
src/main/java/kz/arta/synergy/api/asforms/converter/components/ListBoxConverter.java
...gy/api/asforms/converter/components/ListBoxConverter.java
+35
-1
src/main/java/kz/arta/synergy/api/asforms/pojo/DefaultListBoxDictionary.java
...ta/synergy/api/asforms/pojo/DefaultListBoxDictionary.java
+8
-0
src/main/java/kz/arta/synergy/api/asforms/pojo/ListBoxDictionary.java
...a/kz/arta/synergy/api/asforms/pojo/ListBoxDictionary.java
+5
-0
No files found.
src/main/java/kz/arta/synergy/api/asforms/annotations/ListBox.java
View file @
10a8de6e
package
kz.arta.synergy.api.asforms.annotations
;
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.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
...
@@ -13,6 +16,8 @@ import java.lang.annotation.Target;
...
@@ -13,6 +16,8 @@ import java.lang.annotation.Target;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
ListBox
{
public
@interface
ListBox
{
String
value
()
default
""
;
String
id
()
default
""
;
Class
<?
extends
ListBoxDictionary
>
dictionary
()
default
DefaultListBoxDictionary
.
class
;
}
}
src/main/java/kz/arta/synergy/api/asforms/converter/components/ListBoxConverter.java
View file @
10a8de6e
package
kz.arta.synergy.api.asforms.converter.components
;
package
kz.arta.synergy.api.asforms.converter.components
;
import
kz.arta.synergy.api.asforms.annotations.ListBox
;
import
kz.arta.synergy.api.asforms.annotations.ListBox
;
import
kz.arta.synergy.api.asforms.pojo.AsFormData
;
import
kz.arta.synergy.api.asforms.pojo.ComponentTypes
;
import
kz.arta.synergy.api.asforms.pojo.ComponentTypes
;
import
kz.arta.synergy.api.asforms.pojo.ListBoxDictionary
;
import
java.lang.annotation.Annotation
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Field
;
/**
/**
* @author raimbek
* @author raimbek
...
@@ -11,6 +14,37 @@ import java.lang.annotation.Annotation;
...
@@ -11,6 +14,37 @@ import java.lang.annotation.Annotation;
*/
*/
public
class
ListBoxConverter
extends
AbstractComponentConverter
{
public
class
ListBoxConverter
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
=
((
ListBox
)
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
@Override
public
String
getType
(
Annotation
annotation
)
{
public
String
getType
(
Annotation
annotation
)
{
return
ComponentTypes
.
LISTBOX
;
return
ComponentTypes
.
LISTBOX
;
...
@@ -18,6 +52,6 @@ public class ListBoxConverter extends AbstractComponentConverter {
...
@@ -18,6 +52,6 @@ public class ListBoxConverter extends AbstractComponentConverter {
@Override
@Override
public
String
getCmpId
(
Annotation
annotation
)
{
public
String
getCmpId
(
Annotation
annotation
)
{
return
((
ListBox
)
annotation
).
value
();
return
((
ListBox
)
annotation
).
id
();
}
}
}
}
src/main/java/kz/arta/synergy/api/asforms/pojo/DefaultListBoxDictionary.java
0 → 100644
View file @
10a8de6e
package
kz.arta.synergy.api.asforms.pojo
;
public
class
DefaultListBoxDictionary
implements
ListBoxDictionary
{
@Override
public
String
getValue
(
String
key
)
{
throw
new
UnsupportedOperationException
();
}
}
src/main/java/kz/arta/synergy/api/asforms/pojo/ListBoxDictionary.java
0 → 100644
View file @
10a8de6e
package
kz.arta.synergy.api.asforms.pojo
;
public
interface
ListBoxDictionary
{
String
getValue
(
String
key
);
}
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