Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
45
Issues
45
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
b2d9a268
Commit
b2d9a268
authored
Aug 28, 2014
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved filters to model.filters package
parent
98e0f20f
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
324 additions
and
203 deletions
+324
-203
src/main/java/org/genesys2/server/model/filters/AutocompleteFilter.java
...org/genesys2/server/model/filters/AutocompleteFilter.java
+31
-0
src/main/java/org/genesys2/server/model/filters/BasicFilter.java
...n/java/org/genesys2/server/model/filters/BasicFilter.java
+80
-0
src/main/java/org/genesys2/server/model/filters/CodedMethodFilter.java
.../org/genesys2/server/model/filters/CodedMethodFilter.java
+33
-0
src/main/java/org/genesys2/server/model/filters/GenesysFilter.java
...java/org/genesys2/server/model/filters/GenesysFilter.java
+30
-0
src/main/java/org/genesys2/server/model/filters/I18nListFilter.java
...ava/org/genesys2/server/model/filters/I18nListFilter.java
+43
-0
src/main/java/org/genesys2/server/model/filters/MethodFilter.java
.../java/org/genesys2/server/model/filters/MethodFilter.java
+41
-0
src/main/java/org/genesys2/server/model/filters/ValueName.java
...ain/java/org/genesys2/server/model/filters/ValueName.java
+30
-0
src/main/java/org/genesys2/server/service/GenesysFilterService.java
...ava/org/genesys2/server/service/GenesysFilterService.java
+1
-13
src/main/java/org/genesys2/server/service/impl/GenesysFilterServiceImpl.java
...enesys2/server/service/impl/GenesysFilterServiceImpl.java
+32
-187
src/main/java/org/genesys2/server/servlet/controller/ExplorerController.java
...enesys2/server/servlet/controller/ExplorerController.java
+3
-3
No files found.
src/main/java/org/genesys2/server/model/filters/AutocompleteFilter.java
0 → 100644
View file @
b2d9a268
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.model.filters
;
public
class
AutocompleteFilter
extends
BasicFilter
{
private
final
String
autocompleteUrl
;
public
AutocompleteFilter
(
String
name
,
String
autocompleteUrl
)
{
super
(
name
,
DataType
.
STRING
,
FilterType
.
AUTOCOMPLETE
);
this
.
autocompleteUrl
=
autocompleteUrl
;
}
public
String
getAutocompleteUrl
()
{
return
autocompleteUrl
;
}
}
\ No newline at end of file
src/main/java/org/genesys2/server/model/filters/BasicFilter.java
0 → 100644
View file @
b2d9a268
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.model.filters
;
public
class
BasicFilter
implements
GenesysFilter
{
private
final
String
name
;
private
final
DataType
dataType
;
private
FilterType
filterType
;
private
final
Integer
maxLength
;
public
boolean
isCore
()
{
return
true
;
}
public
BasicFilter
(
String
name
,
DataType
type
)
{
this
.
name
=
name
;
this
.
dataType
=
type
;
if
(
this
.
dataType
==
DataType
.
NUMERIC
)
{
this
.
filterType
=
FilterType
.
RANGE
;
}
else
{
this
.
filterType
=
FilterType
.
EXACT
;
}
this
.
maxLength
=
null
;
}
public
BasicFilter
(
String
name
,
DataType
type
,
FilterType
filterType
)
{
this
.
name
=
name
;
this
.
dataType
=
type
;
this
.
filterType
=
filterType
;
this
.
maxLength
=
null
;
}
public
BasicFilter
(
String
name
,
DataType
type
,
int
i
)
{
this
.
name
=
name
;
this
.
dataType
=
type
;
if
(
this
.
dataType
==
DataType
.
NUMERIC
)
{
this
.
filterType
=
FilterType
.
RANGE
;
}
else
{
this
.
filterType
=
FilterType
.
EXACT
;
}
this
.
maxLength
=
i
;
}
@Override
public
String
getKey
()
{
return
name
;
}
public
String
getName
()
{
return
name
;
}
public
DataType
getDataType
()
{
return
dataType
;
}
public
FilterType
getFilterType
()
{
return
filterType
;
}
public
Integer
getMaxLength
()
{
return
maxLength
;
}
}
\ No newline at end of file
src/main/java/org/genesys2/server/model/filters/CodedMethodFilter.java
0 → 100644
View file @
b2d9a268
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.model.filters
;
import
java.util.Collections
;
import
java.util.List
;
public
class
CodedMethodFilter
extends
MethodFilter
{
private
final
List
<
ValueName
<?>>
options
;
public
CodedMethodFilter
(
String
name
,
String
title
,
DataType
dataType
,
List
<
ValueName
<?>>
options
)
{
super
(
name
,
title
,
dataType
,
FilterType
.
LIST
);
this
.
options
=
Collections
.
unmodifiableList
(
options
);
}
public
List
<
ValueName
<?>>
getOptions
()
{
return
options
;
}
}
\ No newline at end of file
src/main/java/org/genesys2/server/model/filters/GenesysFilter.java
0 → 100644
View file @
b2d9a268
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.model.filters
;
public
interface
GenesysFilter
{
public
String
getKey
();
public
enum
DataType
{
FIXEDSTRING
,
STRING
,
NUMERIC
,
BOOLEAN
}
public
enum
FilterType
{
EXACT
,
RANGE
,
LIST
,
AUTOCOMPLETE
,
I18NLIST
}
}
\ No newline at end of file
src/main/java/org/genesys2/server/model/filters/I18nListFilter.java
0 → 100644
View file @
b2d9a268
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.model.filters
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.apache.commons.collections4.list.UnmodifiableList
;
public
class
I18nListFilter
<
T
>
extends
BasicFilter
{
private
List
<
ValueName
<
T
>>
options
=
new
ArrayList
<
ValueName
<
T
>>();
public
I18nListFilter
(
String
name
,
DataType
dataType
)
{
super
(
name
,
dataType
,
FilterType
.
I18NLIST
);
}
public
GenesysFilter
build
(
String
prefix
,
@SuppressWarnings
(
"unchecked"
)
T
...
options
)
{
final
List
<
ValueName
<
T
>>
opts
=
new
ArrayList
<
ValueName
<
T
>>();
for
(
final
T
opt
:
options
)
{
opts
.
add
(
new
ValueName
<
T
>(
opt
,
prefix
+
"."
+
opt
));
}
this
.
options
=
new
UnmodifiableList
<
ValueName
<
T
>>(
opts
);
return
this
;
}
public
List
<
ValueName
<
T
>>
getOptions
()
{
return
options
;
}
}
\ No newline at end of file
src/main/java/org/genesys2/server/model/filters/MethodFilter.java
0 → 100644
View file @
b2d9a268
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.model.filters
;
public
class
MethodFilter
extends
BasicFilter
{
private
final
String
title
;
@Override
public
boolean
isCore
()
{
return
false
;
}
public
MethodFilter
(
String
name
,
String
title
,
DataType
dataType
)
{
super
(
name
,
dataType
);
this
.
title
=
title
;
}
public
MethodFilter
(
String
name
,
String
title
,
DataType
dataType
,
FilterType
filterType
)
{
super
(
name
,
dataType
,
filterType
);
this
.
title
=
title
;
}
public
String
getTitle
()
{
return
title
;
}
}
\ No newline at end of file
src/main/java/org/genesys2/server/model/filters/ValueName.java
0 → 100644
View file @
b2d9a268
package
org.genesys2.server.model.filters
;
public
class
ValueName
<
T
>
{
private
final
T
value
;
private
final
String
name
;
private
Long
count
;
public
ValueName
(
T
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
ValueName
(
T
value
,
String
name
,
Long
count
)
{
this
.
value
=
value
;
this
.
name
=
name
;
this
.
count
=
count
;
}
public
T
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
public
Long
getCount
()
{
return
count
;
}
}
\ No newline at end of file
src/main/java/org/genesys2/server/service/GenesysFilterService.java
View file @
b2d9a268
...
...
@@ -18,6 +18,7 @@ package org.genesys2.server.service;
import
java.util.List
;
import
org.genesys2.server.model.filters.GenesysFilter
;
import
org.genesys2.server.model.genesys.Accession
;
import
org.genesys2.server.service.impl.GenesysFilterServiceImpl.LabelValue
;
import
org.springframework.data.domain.Page
;
...
...
@@ -35,19 +36,6 @@ public interface GenesysFilterService {
List
<
GenesysFilter
>
listAvailableFilters
();
public
static
interface
GenesysFilter
{
public
String
getKey
();
public
enum
DataType
{
FIXEDSTRING
,
STRING
,
NUMERIC
,
BOOLEAN
}
public
enum
FilterType
{
EXACT
,
RANGE
,
LIST
,
AUTOCOMPLETE
,
I18NLIST
}
}
List
<
GenesysFilter
>
selectFilters
(
String
[]
selectedFilters
);
List
<
LabelValue
<
String
>>
autocomplete
(
String
filter
,
String
ac
,
ObjectNode
jsonTree
);
...
...
src/main/java/org/genesys2/server/service/impl/GenesysFilterServiceImpl.java
View file @
b2d9a268
This diff is collapsed.
Click to expand it.
src/main/java/org/genesys2/server/servlet/controller/ExplorerController.java
View file @
b2d9a268
...
...
@@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletResponse;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.genesys2.server.model.filters.GenesysFilter
;
import
org.genesys2.server.model.genesys.Accession
;
import
org.genesys2.server.model.genesys.Method
;
import
org.genesys2.server.model.genesys.Parameter
;
...
...
@@ -37,7 +38,6 @@ import org.genesys2.server.model.genesys.ParameterCategory;
import
org.genesys2.server.model.impl.Crop
;
import
org.genesys2.server.service.CropService
;
import
org.genesys2.server.service.GenesysFilterService
;
import
org.genesys2.server.service.GenesysFilterService.GenesysFilter
;
import
org.genesys2.server.service.FilterConstants
;
import
org.genesys2.server.service.GenesysService
;
import
org.genesys2.server.service.InstituteService
;
...
...
@@ -151,7 +151,7 @@ public class ExplorerController extends BaseController {
_logger
.
error
(
"Invalid JSON for filters"
,
e
);
}
final
List
<
GenesysFilter
Service
.
GenesysFilter
>
currentFilters
=
filterService
.
selectFilters
(
selectedFilters
);
final
List
<
GenesysFilter
>
currentFilters
=
filterService
.
selectFilters
(
selectedFilters
);
final
List
<
GenesysFilter
>
availableFilters
=
filterService
.
listAvailableFilters
();
_logger
.
debug
(
"Filtering by: "
+
jsonFilter
);
...
...
@@ -191,7 +191,7 @@ public class ExplorerController extends BaseController {
public
String
getAdditionalFilters
(
ModelMap
model
,
@RequestParam
(
value
=
"filter"
,
required
=
true
,
defaultValue
=
""
)
String
[]
selectedFilters
)
throws
IOException
{
final
List
<
GenesysFilter
Service
.
GenesysFilter
>
additionalFilters
=
filterService
.
selectFilters
(
selectedFilters
);
final
List
<
GenesysFilter
>
additionalFilters
=
filterService
.
selectFilters
(
selectedFilters
);
model
.
addAttribute
(
"additionalFilters"
,
additionalFilters
);
if
(
ArrayUtils
.
contains
(
selectedFilters
,
"crops"
))
{
...
...
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