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
e204aeb0
Commit
e204aeb0
authored
Nov 14, 2016
by
Raimbek Egemberdiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
рефакторинг импорта завершена
parent
10a8de6e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
74 additions
and
28 deletions
+74
-28
src/main/java/kz/arta/synergy/api/Query.java
src/main/java/kz/arta/synergy/api/Query.java
+6
-2
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
+8
-6
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/AbstractComponentConverter.java
...orms/converter/components/AbstractComponentConverter.java
+12
-16
src/main/java/kz/arta/synergy/api/asforms/pojo/AdvancedSearchParams.java
...z/arta/synergy/api/asforms/pojo/AdvancedSearchParams.java
+9
-0
src/main/java/kz/arta/synergy/api/asforms/pojo/AsForm.java
src/main/java/kz/arta/synergy/api/asforms/pojo/AsForm.java
+9
-0
src/main/java/kz/arta/synergy/api/asforms/pojo/AsFormData.java
...ain/java/kz/arta/synergy/api/asforms/pojo/AsFormData.java
+19
-0
src/main/java/kz/arta/synergy/api/asforms/pojo/SearchIndexResult.java
...a/kz/arta/synergy/api/asforms/pojo/SearchIndexResult.java
+2
-0
src/main/java/kz/arta/synergy/api/services/RegistryService.java
...in/java/kz/arta/synergy/api/services/RegistryService.java
+8
-4
No files found.
src/main/java/kz/arta/synergy/api/Query.java
View file @
e204aeb0
...
...
@@ -34,12 +34,16 @@ public class Query {
}
public
Query
queryParam
(
String
key
,
String
value
)
{
queryParams
.
put
(
key
,
value
);
if
(
value
!=
null
)
{
queryParams
.
put
(
key
,
value
);
}
return
this
;
}
public
Query
formParam
(
String
key
,
String
value
)
{
formParams
.
put
(
key
,
value
);
if
(
value
!=
null
)
{
formParams
.
put
(
key
,
value
);
}
return
this
;
}
...
...
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
View file @
e204aeb0
...
...
@@ -85,22 +85,24 @@ public class AsFormService {
));
}
public
List
<
AdvancedSearchResult
>
advancedSearchOne
(
String
formId
,
String
key
,
String
value
)
throws
IOException
{
return
advancedSearchOne
(
formId
,
key
,
value
);
public
AdvancedSearchResult
advancedSearchOne
(
String
formId
,
String
key
,
String
value
)
throws
IOException
,
FormRecordNotFound
,
FoundTooManyRecords
{
return
advancedSearchOne
(
AdvancedSearchParams
.
build
(
String
.
format
(
"where uuid='%s' and %s='%s'"
,
formId
,
key
,
value
),
key
));
}
public
SearchIndexResult
searchIndex
(
SearchIndexParamsBuilder
builder
)
throws
IOException
{
Query
query
=
Query
.
newInstance
().
url
(
"/rest/api/asforms/search_index?"
+
builder
.
build
());
String
respon
c
e
=
restHttpQuery
.
doQuery
(
query
);
return
JsonUtils
.
read
(
respon
c
e
,
SearchIndexResult
.
class
);
String
respon
s
e
=
restHttpQuery
.
doQuery
(
query
);
return
JsonUtils
.
read
(
respon
s
e
,
SearchIndexResult
.
class
);
}
public
RegistryRecord
searchIndexOne
(
SearchIndexParamsBuilder
builder
)
throws
IOException
,
FormRecordNotFound
,
FoundTooManyRecords
{
SearchIndexResult
result
=
searchIndex
(
builder
);
if
(
result
==
null
||
result
.
getCount
()
==
0
)
{
throw
new
FormRecordNotFound
();
throw
new
FormRecordNotFound
(
builder
.
build
()
);
}
else
if
(
result
.
getCount
()
>
1
)
{
throw
new
FoundTooManyRecords
();
throw
new
FoundTooManyRecords
(
builder
.
build
()
);
}
return
result
.
getRecords
().
get
(
0
);
}
...
...
src/main/java/kz/arta/synergy/api/asforms/converter/DefaultAsFormConverter.java
View file @
e204aeb0
...
...
@@ -30,6 +30,7 @@ public class DefaultAsFormConverter implements AsFormConverter {
registerConverter
(
Entity
.
class
,
new
EntityConverter
());
registerConverter
(
ListBox
.
class
,
new
ListBoxConverter
());
registerConverter
(
Table
.
class
,
new
TableConverter
(
this
));
registerConverter
(
DateCmp
.
class
,
new
DateConverter
());
}
@Override
...
...
src/main/java/kz/arta/synergy/api/asforms/converter/components/AbstractComponentConverter.java
View file @
e204aeb0
...
...
@@ -48,34 +48,22 @@ public abstract class AbstractComponentConverter implements ComponentConverter {
}
else
if
(
field
.
getType
().
isAssignableFrom
(
Integer
.
class
))
{
// int
String
value
=
getValueForClassField
(
field
,
asfData
,
cmpId
);
if
(
value
==
null
)
{
value
=
"0"
;
}
String
value
=
getNumberValueForField
(
asfData
,
field
,
cmpId
);
field
.
set
(
asFormObject
,
Integer
.
parseInt
(
value
));
}
else
if
(
field
.
getType
().
isAssignableFrom
(
BigInteger
.
class
))
{
// int
String
value
=
getValueForClassField
(
field
,
asfData
,
cmpId
);
if
(
value
==
null
)
{
value
=
"0"
;
}
String
value
=
getNumberValueForField
(
asfData
,
field
,
cmpId
);
field
.
set
(
asFormObject
,
new
BigInteger
(
value
));
}
else
if
(
field
.
getType
().
isAssignableFrom
(
Double
.
class
))
{
// double
String
value
=
getValueForClassField
(
field
,
asfData
,
cmpId
);
if
(
value
==
null
)
{
value
=
"0"
;
}
String
value
=
getNumberValueForField
(
asfData
,
field
,
cmpId
);
field
.
set
(
asFormObject
,
Double
.
parseDouble
(
value
));
}
else
if
(
field
.
getType
().
isAssignableFrom
(
BigDecimal
.
class
))
{
// double
String
value
=
getValueForClassField
(
field
,
asfData
,
cmpId
);
if
(
value
==
null
)
{
value
=
"0"
;
}
String
value
=
getNumberValueForField
(
asfData
,
field
,
cmpId
);
field
.
set
(
asFormObject
,
new
BigDecimal
(
value
));
}
else
if
(
field
.
getType
().
isAssignableFrom
(
AsFormData
.
class
))
{
...
...
@@ -125,6 +113,14 @@ public abstract class AbstractComponentConverter implements ComponentConverter {
return
asfData
.
getValue
(
cmpId
);
}
private
String
getNumberValueForField
(
AsFormDataContainer
asfData
,
Field
field
,
String
cmpId
)
{
String
value
=
getValueForClassField
(
field
,
asfData
,
cmpId
);
if
(
Strings
.
isNullOrEmpty
(
value
))
{
value
=
"0"
;
}
return
value
.
trim
().
replaceAll
(
" "
,
""
);
}
protected
boolean
hasKeyValueAnnotation
(
Field
field
)
{
boolean
fetchKey
=
false
;
Annotation
[]
declaredAnnotations
=
field
.
getDeclaredAnnotations
();
...
...
src/main/java/kz/arta/synergy/api/asforms/pojo/AdvancedSearchParams.java
View file @
e204aeb0
...
...
@@ -17,6 +17,7 @@ public class AdvancedSearchParams {
private
String
query
;
private
List
<
String
>
parameters
=
new
ArrayList
<
String
>();
private
boolean
searchInRegistry
=
true
;
private
boolean
showDeleted
=
false
;
private
int
startRecord
=
0
;
private
int
recordsCount
=
100
;
private
List
<
List
<
String
>>
dynParams
=
new
ArrayList
<
List
<
String
>>();
...
...
@@ -78,4 +79,12 @@ public class AdvancedSearchParams {
public
void
setDynParams
(
List
<
List
<
String
>>
dynParams
)
{
this
.
dynParams
=
dynParams
;
}
public
boolean
isShowDeleted
()
{
return
showDeleted
;
}
public
void
setShowDeleted
(
boolean
showDeleted
)
{
this
.
showDeleted
=
showDeleted
;
}
}
src/main/java/kz/arta/synergy/api/asforms/pojo/AsForm.java
View file @
e204aeb0
...
...
@@ -15,6 +15,7 @@ public class AsForm {
private
String
uuid
;
private
String
form
;
private
String
modified
;
private
String
documentId
;
public
AsForm
()
{
}
...
...
@@ -50,4 +51,12 @@ public class AsForm {
public
void
setModified
(
String
modified
)
{
this
.
modified
=
modified
;
}
public
void
setDocumentId
(
String
documentId
)
{
this
.
documentId
=
documentId
;
}
public
String
getDocumentId
()
{
return
documentId
;
}
}
src/main/java/kz/arta/synergy/api/asforms/pojo/AsFormData.java
View file @
e204aeb0
...
...
@@ -122,4 +122,23 @@ public class AsFormData extends AsFormDataContainer {
asFormData
.
setType
(
type
);
return
asFormData
;
}
public
static
AsFormData
createOnlyWithValue
(
String
value
)
{
AsFormData
asFormData
=
new
AsFormData
();
asFormData
.
setValue
(
value
);
return
asFormData
;
}
public
static
AsFormData
createOnlyWithKey
(
String
key
)
{
AsFormData
asFormData
=
new
AsFormData
();
asFormData
.
setKey
(
key
);
return
asFormData
;
}
public
static
AsFormData
createByValueAndKey
(
String
key
,
String
value
)
{
AsFormData
asFormData
=
new
AsFormData
();
asFormData
.
setKey
(
key
);
asFormData
.
setValue
(
value
);
return
asFormData
;
}
}
src/main/java/kz/arta/synergy/api/asforms/pojo/SearchIndexResult.java
View file @
e204aeb0
package
kz.arta.synergy.api.asforms.pojo
;
import
org.codehaus.jackson.annotate.JsonIgnoreProperties
;
import
org.codehaus.jackson.annotate.JsonProperty
;
import
java.util.List
;
...
...
@@ -8,6 +9,7 @@ import java.util.List;
public
class
SearchIndexResult
{
private
int
count
;
@JsonProperty
(
"data"
)
private
List
<
RegistryRecord
>
records
;
public
SearchIndexResult
()
{
...
...
src/main/java/kz/arta/synergy/api/services/RegistryService.java
View file @
e204aeb0
...
...
@@ -4,6 +4,7 @@ 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.pojo.RegistryRecord
;
import
java.io.IOException
;
...
...
@@ -24,15 +25,18 @@ public class RegistryService {
return
new
RegistryService
(
context
);
}
public
String
createRegistryRecord
(
String
registryID
)
throws
IOException
{
public
RegistryRecord
createRegistryRecord
(
String
registryID
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
url
(
"/rest/api/registry/create_doc"
)
.
queryParam
(
"registryID"
,
registryID
);
String
response
=
restHttpQuery
.
doQuery
(
query
);
return
JsonUtils
.
read
Tree
(
response
).
get
(
"dataUUID"
).
getTextValue
(
);
return
JsonUtils
.
read
(
response
,
RegistryRecord
.
class
);
}
public
void
activateRecord
(
String
dataUUID
)
{
public
String
activateRecord
(
String
dataUUID
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
url
(
"/rest/api/registry/activate_doc"
)
.
queryParam
(
"dataUUID"
,
dataUUID
);
return
restHttpQuery
.
doQuery
(
query
);
}
}
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