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
b9143e5b
Commit
b9143e5b
authored
Feb 20, 2017
by
Raimbek Egemberdiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dictionary delete and add
parent
1d957d44
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
1 deletion
+156
-1
src/main/java/kz/arta/synergy/api/dictionaries/DictionaryService.java
...a/kz/arta/synergy/api/dictionaries/DictionaryService.java
+23
-0
src/main/java/kz/arta/synergy/api/dictionaries/pojo/Dictionary.java
...ava/kz/arta/synergy/api/dictionaries/pojo/Dictionary.java
+19
-0
src/main/java/kz/arta/synergy/api/dictionaries/pojo/DictionaryColumn.java
.../arta/synergy/api/dictionaries/pojo/DictionaryColumn.java
+19
-0
src/main/java/kz/arta/synergy/api/dictionaries/pojo/DictionaryItem.java
...kz/arta/synergy/api/dictionaries/pojo/DictionaryItem.java
+16
-0
src/main/java/kz/arta/synergy/api/dictionaries/pojo/DictionaryItemValue.java
...ta/synergy/api/dictionaries/pojo/DictionaryItemValue.java
+28
-1
src/main/java/kz/arta/synergy/api/dictionaries/pojo/DictionaryRecord.java
.../arta/synergy/api/dictionaries/pojo/DictionaryRecord.java
+51
-0
No files found.
src/main/java/kz/arta/synergy/api/dictionaries/DictionaryService.java
View file @
b9143e5b
...
@@ -10,6 +10,7 @@ import kz.arta.synergy.api.dictionaries.annotations.DictionaryColumn;
...
@@ -10,6 +10,7 @@ import kz.arta.synergy.api.dictionaries.annotations.DictionaryColumn;
import
kz.arta.synergy.api.dictionaries.pojo.Dictionary
;
import
kz.arta.synergy.api.dictionaries.pojo.Dictionary
;
import
kz.arta.synergy.api.dictionaries.pojo.DictionaryItem
;
import
kz.arta.synergy.api.dictionaries.pojo.DictionaryItem
;
import
kz.arta.synergy.api.dictionaries.pojo.DictionaryItemValue
;
import
kz.arta.synergy.api.dictionaries.pojo.DictionaryItemValue
;
import
kz.arta.synergy.api.dictionaries.pojo.DictionaryRecord
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
...
@@ -42,6 +43,28 @@ public class DictionaryService {
...
@@ -42,6 +43,28 @@ public class DictionaryService {
return
JsonUtils
.
read
(
restHttpQuery
.
doQuery
(
query
),
Dictionary
.
class
);
return
JsonUtils
.
read
(
restHttpQuery
.
doQuery
(
query
),
Dictionary
.
class
);
}
}
public
String
deleteDictionaryItem
(
final
String
code
,
final
String
itemId
)
throws
IOException
{
HashMap
<
String
,
String
>
data
=
new
HashMap
<
String
,
String
>()
{{
put
(
"dictCode"
,
code
);
put
(
"itemID"
,
itemId
);
}};
Query
query
=
Query
.
newInstance
()
.
methodPost
()
.
url
(
"/rest/api/dictionary/record/remove"
)
.
header
(
"Content-Type"
,
"application/json; charset=utf-8"
)
.
body
(
JsonUtils
.
toJson
(
data
));
return
restHttpQuery
.
doQuery
(
query
);
}
public
String
addRecord
(
DictionaryRecord
dictionaryRecord
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
methodPost
()
.
url
(
"/rest/api/dictionary/record/add"
)
.
header
(
"Content-Type"
,
"application/json; charset=utf-8"
)
.
body
(
JsonUtils
.
toJson
(
dictionaryRecord
));
return
restHttpQuery
.
doQuery
(
query
);
}
public
<
T
>
List
<
T
>
getDictionary
(
Class
<
T
>
dictionaryType
)
throws
DictionaryConvertException
{
public
<
T
>
List
<
T
>
getDictionary
(
Class
<
T
>
dictionaryType
)
throws
DictionaryConvertException
{
try
{
try
{
ArrayList
<
T
>
dictionaryList
=
new
ArrayList
<>();
ArrayList
<
T
>
dictionaryList
=
new
ArrayList
<>();
...
...
src/main/java/kz/arta/synergy/api/dictionaries/pojo/Dictionary.java
View file @
b9143e5b
...
@@ -3,6 +3,7 @@ package kz.arta.synergy.api.dictionaries.pojo;
...
@@ -3,6 +3,7 @@ package kz.arta.synergy.api.dictionaries.pojo;
import
kz.arta.synergy.api.asforms.utils.Strings
;
import
kz.arta.synergy.api.asforms.utils.Strings
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -59,6 +60,15 @@ public class Dictionary {
...
@@ -59,6 +60,15 @@ public class Dictionary {
return
null
;
return
null
;
}
}
public
String
findColumnCodeById
(
String
columnID
)
{
for
(
DictionaryColumn
column
:
columns
)
{
if
(!
Strings
.
isNullOrEmpty
(
column
.
getColumnID
())
&&
column
.
getColumnID
().
equals
(
columnID
))
{
return
column
.
getCode
();
}
}
return
null
;
}
public
String
findItemID
(
String
columnID
,
String
value
)
{
public
String
findItemID
(
String
columnID
,
String
value
)
{
for
(
DictionaryItem
item
:
getItems
())
{
for
(
DictionaryItem
item
:
getItems
())
{
for
(
DictionaryItemValue
itemValue
:
item
.
getValues
())
{
for
(
DictionaryItemValue
itemValue
:
item
.
getValues
())
{
...
@@ -83,4 +93,13 @@ public class Dictionary {
...
@@ -83,4 +93,13 @@ public class Dictionary {
}
}
return
""
;
return
""
;
}
}
public
DictionaryItem
findItem
(
DictionaryItem
srcDictItem
)
{
for
(
DictionaryItem
dictionaryItem
:
getItems
())
{
if
(
dictionaryItem
.
equals
(
srcDictItem
))
{
return
dictionaryItem
;
}
}
return
null
;
}
}
}
src/main/java/kz/arta/synergy/api/dictionaries/pojo/DictionaryColumn.java
View file @
b9143e5b
...
@@ -26,4 +26,23 @@ public class DictionaryColumn {
...
@@ -26,4 +26,23 @@ public class DictionaryColumn {
public
void
setCode
(
String
code
)
{
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
this
.
code
=
code
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
DictionaryColumn
column
=
(
DictionaryColumn
)
o
;
if
(
columnID
!=
null
?
!
columnID
.
equals
(
column
.
columnID
)
:
column
.
columnID
!=
null
)
return
false
;
return
!(
code
!=
null
?
!
code
.
equals
(
column
.
code
)
:
column
.
code
!=
null
);
}
@Override
public
int
hashCode
()
{
int
result
=
columnID
!=
null
?
columnID
.
hashCode
()
:
0
;
result
=
31
*
result
+
(
code
!=
null
?
code
.
hashCode
()
:
0
);
return
result
;
}
}
}
src/main/java/kz/arta/synergy/api/dictionaries/pojo/DictionaryItem.java
View file @
b9143e5b
...
@@ -28,4 +28,20 @@ public class DictionaryItem {
...
@@ -28,4 +28,20 @@ public class DictionaryItem {
public
void
setValues
(
List
<
DictionaryItemValue
>
values
)
{
public
void
setValues
(
List
<
DictionaryItemValue
>
values
)
{
this
.
values
=
values
;
this
.
values
=
values
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
DictionaryItem
that
=
(
DictionaryItem
)
o
;
return
!(
values
!=
null
?
!
values
.
equals
(
that
.
values
)
:
that
.
values
!=
null
);
}
@Override
public
int
hashCode
()
{
return
values
!=
null
?
values
.
hashCode
()
:
0
;
}
}
}
src/main/java/kz/arta/synergy/api/dictionaries/pojo/DictionaryItemValue.java
View file @
b9143e5b
...
@@ -4,7 +4,7 @@ package kz.arta.synergy.api.dictionaries.pojo;
...
@@ -4,7 +4,7 @@ package kz.arta.synergy.api.dictionaries.pojo;
* @author raimbek
* @author raimbek
* @since 26.04.2016
* @since 26.04.2016
*/
*/
public
class
DictionaryItemValue
{
public
class
DictionaryItemValue
implements
Comparable
<
DictionaryItemValue
>
{
private
String
columnID
;
private
String
columnID
;
private
String
value
;
private
String
value
;
...
@@ -26,4 +26,31 @@ public class DictionaryItemValue {
...
@@ -26,4 +26,31 @@ public class DictionaryItemValue {
public
void
setValue
(
String
value
)
{
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
this
.
value
=
value
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
DictionaryItemValue
itemValue
=
(
DictionaryItemValue
)
o
;
if
(
columnID
!=
null
?
!
columnID
.
equals
(
itemValue
.
columnID
)
:
itemValue
.
columnID
!=
null
)
return
false
;
return
!(
value
!=
null
?
!
value
.
equals
(
itemValue
.
value
)
:
itemValue
.
value
!=
null
);
}
@Override
public
int
hashCode
()
{
int
result
=
columnID
!=
null
?
columnID
.
hashCode
()
:
0
;
result
=
31
*
result
+
(
value
!=
null
?
value
.
hashCode
()
:
0
);
return
result
;
}
@Override
public
int
compareTo
(
DictionaryItemValue
o
)
{
if
(
o
==
null
)
{
return
0
;
}
return
o
.
getColumnID
().
compareTo
(
this
.
columnID
);
}
}
}
src/main/java/kz/arta/synergy/api/dictionaries/pojo/DictionaryRecord.java
0 → 100644
View file @
b9143e5b
package
kz.arta.synergy.api.dictionaries.pojo
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author raimbek
* @since 17.02.2017
*/
public
class
DictionaryRecord
{
private
String
dictCode
;
private
String
itemID
;
public
static
class
Column
{
public
String
code
;
public
String
value
;
public
String
valueKZ
;
public
String
valueRU
;
public
String
valueEN
;
}
private
List
<
Column
>
columns
=
new
ArrayList
<>();
public
String
getDictCode
()
{
return
dictCode
;
}
public
void
setDictCode
(
String
dictCode
)
{
this
.
dictCode
=
dictCode
;
}
public
String
getItemID
()
{
return
itemID
;
}
public
void
setItemID
(
String
itemID
)
{
this
.
itemID
=
itemID
;
}
public
List
<
Column
>
getColumns
()
{
return
columns
;
}
public
void
setColumns
(
List
<
Column
>
columns
)
{
this
.
columns
=
columns
;
}
public
void
addColumn
(
Column
column
)
{
columns
.
add
(
column
);
}
}
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