Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
c2cd8802
Commit
c2cd8802
authored
Jun 27, 2014
by
igoshin
Committed by
Matija Obreza
Jul 03, 2014
Browse files
#12579 enabled ajax call for additional filters
parent
65b7522c
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/servlet/controller/ExplorerController.java
View file @
c2cd8802
...
...
@@ -16,6 +16,7 @@
package
org.genesys2.server.servlet.controller
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -38,6 +39,7 @@ import org.springframework.data.domain.PageRequest;
import
org.springframework.data.domain.Sort
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -275,7 +277,7 @@ public class ExplorerController extends BaseController {
@RequestMapping
(
"/explore"
)
public
String
viewFiltered
(
ModelMap
model
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"filter"
,
required
=
true
,
defaultValue
=
"{}"
)
String
jsonFilter
,
@RequestParam
(
value
=
"pick"
,
required
=
false
)
String
jsonPick
)
{
@RequestParam
(
value
=
"pick"
,
required
=
false
,
defaultValue
=
"[]"
)
String
jsonPick
)
{
String
[]
selectedFilters
=
new
String
[
0
];
...
...
@@ -316,7 +318,7 @@ public class ExplorerController extends BaseController {
model
.
addAttribute
(
"filters"
,
filters
);
model
.
addAttribute
(
"pick"
,
pick
);
model
.
addAttribute
(
"
jsonPick
"
,
jsonTree
.
toString
()
)
;
jsonPick
=
jsonTree
.
toString
();
_logger
.
info
(
"Clean jsonPick: "
+
jsonTree
);
}
catch
(
IOException
e
)
{
_logger
.
error
(
"Invalid JSON for pick"
,
e
);
...
...
@@ -330,7 +332,6 @@ public class ExplorerController extends BaseController {
_logger
.
debug
(
jsonTree
.
toString
());
if
(
model
.
containsAttribute
(
"crop"
))
{
// jsonTree.remove("crop");
model
.
addAttribute
(
"jsonFilter"
,
jsonTree
.
toString
());
// Replace any other crop filters...
...
...
@@ -350,20 +351,71 @@ public class ExplorerController extends BaseController {
_logger
.
info
(
"Got: "
+
accessions
);
List
<
GenesysFilterService
.
GenesysFilter
>
additionalFilters
=
filterService
.
selectFilters
(
crop
,
selectedFilters
);
List
<
GenesysFilterService
.
GenesysFilter
>
availableFilters
=
filterService
.
listAvailableFilters
();
List
<
GenesysFilterService
.
GenesysFilter
>
allFilters
=
new
ArrayList
<>();
allFilters
.
addAll
(
availableFilters
);
allFilters
.
addAll
(
additionalFilters
);
model
.
addAttribute
(
"crops"
,
cropService
.
list
(
getLocale
()));
model
.
addAttribute
(
"pagedData"
,
accessions
);
model
.
addAttribute
(
"jsonPick"
,
jsonPick
);
model
.
addAttribute
(
"pagedData"
,
accessions
);
model
.
addAttribute
(
"availableFilters"
,
availableFilters
);
model
.
addAttribute
(
"additionalFilters"
,
additionalFilters
);
model
.
addAttribute
(
"allFilters"
,
allFilters
);
return
"/accession/explore_new"
;
}
@RequestMapping
(
value
=
"/additional-filter"
,
method
=
RequestMethod
.
GET
)
public
String
getAdditionalFilters
(
ModelMap
model
,
@RequestParam
(
value
=
"filter"
,
required
=
true
,
defaultValue
=
"{}"
)
String
jsonFilter
,
@RequestParam
(
value
=
"shortName"
,
required
=
true
)
String
shortName
,
@RequestParam
(
value
=
"pick"
,
required
=
true
)
String
filterPick
)
throws
IOException
{
Crop
crop
=
cropService
.
getCrop
(
shortName
);
if
(
crop
==
null
)
{
throw
new
ResourceNotFoundException
(
"No crop "
+
shortName
);
}
String
[]
selectedFilters
=
new
String
[
0
];
Map
<
String
,
List
<
String
>>
filters
=
mapper
.
readValue
(
jsonFilter
,
Map
.
class
);
Map
<
String
,
String
>
pick
=
new
HashMap
<>();
for
(
String
key
:
filters
.
keySet
())
{
pick
.
put
(
key
,
key
);
}
if
(
StringUtils
.
isNotBlank
(
filterPick
))
{
selectedFilters
=
mapper
.
readValue
(
filterPick
,
selectedFilters
.
getClass
());
}
List
<
GenesysFilterService
.
GenesysFilter
>
additionalFilters
=
filterService
.
selectFilters
(
crop
,
selectedFilters
);
model
.
addAttribute
(
"filters"
,
filters
);
model
.
addAttribute
(
"pick"
,
pick
);
model
.
addAttribute
(
"additionalFilters"
,
additionalFilters
);
return
"/accession/additional-filter"
;
}
@RequestMapping
(
value
=
"/modal"
,
method
=
RequestMethod
.
GET
)
public
String
getModelWindow
(
ModelMap
model
,
@RequestParam
(
value
=
"shortName"
,
required
=
true
)
String
shortName
,
@RequestParam
(
value
=
"pick"
,
required
=
false
,
defaultValue
=
"[]"
)
String
jsonPick
)
{
Crop
crop
=
cropService
.
getCrop
(
shortName
);
if
(
crop
!=
null
)
{
List
<
ParameterCategory
>
categories
=
traitService
.
listCategories
();
Map
<
ParameterCategory
,
List
<
Parameter
>>
descriptors
=
traitService
.
mapTraits
(
crop
,
categories
);
Map
<
Long
,
List
<
Method
>>
methods
=
traitService
.
mapMethods
(
crop
);
model
.
addAttribute
(
"crop"
,
crop
);
model
.
addAttribute
(
"categories"
,
categories
);
model
.
addAttribute
(
"descriptors"
,
descriptors
);
model
.
addAttribute
(
"methods"
,
methods
);
}
model
.
addAttribute
(
"jsonPick"
,
jsonPick
);
return
"/accession/modal"
;
}
private
String
[]
convertToPickString
(
List
<
ParameterCategory
>
categories
,
Map
<
ParameterCategory
,
List
<
Parameter
>>
descriptors
,
Map
<
Long
,
List
<
Method
>>
methods
)
{
List
<
String
>
s
=
new
ArrayList
<>();
...
...
src/main/webapp/WEB-INF/jsp/accession/additional-filter.jsp
0 → 100644
View file @
c2cd8802
<%@ page
contentType=
"charset=UTF-8"
pageEncoding=
"UTF-8"
language=
"java"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"security"
uri=
"http://www.springframework.org/security/tags"
%>
<%@ taglib
prefix=
"spring"
uri=
"http://www.springframework.org/tags"
%>
<%@ taglib
prefix=
"fmt"
uri=
"http://java.sun.com/jsp/jstl/fmt"
%>
<%@ taglib
prefix=
"fn"
uri=
"http://java.sun.com/jsp/jstl/functions"
%>
<c:forEach
items=
"
${
additionalFilters
}
"
var=
"filter"
>
<c:set
var=
"normalizedKey"
value=
"
${
fn:
replace
(
filter
.
key
,
':'
,
'_'
)
}
"
/>
<c:set
var=
"filterKey"
value=
"
${
filter
.
key
}
"
/>
<div
class=
"clearfix filter-block"
style=
"display:${pick[filterKey] eq filterKey ? '' : 'none'}"
id=
"${normalizedKey}_filter"
key=
"${normalizedKey}"
>
<div
class=
"col-lg-3"
>
<c:if
test=
"
${
not
filter
.
core
}
"
>
<a
href=
"
<c:url
value=
"/descriptors/${filter.key}"
/>
"
><c:out
value=
"
${
filter
.
title
}
"
/></a>
</c:if>
<c:if
test=
"
${
filter
.
core
}
"
>
<spring:message
code=
"filter.${filter.name}"
/>
</c:if>
</div>
<div
class=
"col-lg-5 filter-new"
style=
"display:none"
>
<c:choose>
<c:when
test=
"
${
filter
.
filterType
==
'LIST'
}
"
>
<div
class=
""
>
<c:forEach
items=
"
${
filter
.
options
}
"
var=
"option"
>
<div>
<label>
<input
class=
"filter-list"
id=
"${option.value}_input"
${
fn:contains
(
filters
[
filter.key
],
option.value
)?'
checked
'
:
''}
norm-key=
"${normalizedKey}"
i-key=
"${normalizedKey}${option.value}"
type=
"checkbox"
value=
"${option.value}"
/>
<spring:message
code=
"
${
option
.
name
}
"
/>
</label>
</div>
</c:forEach>
</div>
<div
style=
"margin-top: 3px"
>
<button
class=
"btn btn-primary apply"
><spring:message
code=
"filter.apply"
/></button>
</div>
</c:when>
<c:when
test=
"
${
filter
.
filterType
==
'I18NLIST'
}
"
>
<div
class=
""
>
<c:forEach
items=
"
${
filter
.
options
}
"
var=
"option"
>
<div>
<label>
<input
class=
"filter-list"
id=
"${option.value}_input"
${
fn:contains
(
filters
[
filter.key
],
option.value
)?'
checked
'
:
''}
norm-key=
"${normalizedKey}"
i-key=
"${normalizedKey}${option.value}"
type=
"checkbox"
value=
"${option.value}"
/>
<spring:message
code=
"
${
option
.
name
}
"
/>
</label>
</div>
</c:forEach>
<div
style=
"margin-top: 3px"
>
<button
class=
"btn btn-primary apply"
><spring:message
code=
"filter.apply"
/></button>
</div>
</div>
</c:when>
<c:when
test=
"
${
filter
.
filterType
==
'AUTOCOMPLETE'
}
"
>
<div
class=
"ui-front"
>
<div
class=
"form-group input-group"
>
<span
class=
"input-group-btn"
>
<input
id=
"${normalizedKey}_input"
class=
"span2 form-control autocomplete-filter"
x-source=
"${filter.autocompleteUrl}"
type=
"text"
/>
<button
class=
"btn notimportant filter-auto"
norm-key=
"${normalizedKey}"
>
+
</button>
</span>
</div>
<div
style=
"margin-top: 3px"
>
<button
class=
"btn btn-primary apply"
><spring:message
code=
"filter.apply"
/></button>
</div>
</div>
</c:when>
<c:when
test=
"
${
filter
.
dataType
==
'NUMERIC'
}
"
>
<div
class=
"form-group input-group"
>
<span
class=
"input-group-btn"
>
<input
id=
"${normalizedKey}_input_1"
class=
"span5 form-control"
type=
"text"
/>
<input
id=
"${normalizedKey}_input_2"
class=
"span5 form-control"
type=
"text"
/>
<button
class=
"btn notimportant filter-range"
norm-key=
"${normalizedKey}"
>
+
</button>
</span>
</div>
<div
style=
"margin-top: 3px"
>
<button
class=
"btn btn-primary apply"
><spring:message
code=
"filter.apply"
/></button>
</div>
</c:when>
<c:when
test=
"
${
filter
.
dataType
==
'BOOLEAN'
}
"
>
<div
class=
""
>
<div><label><input
type=
"checkbox"
${
fn:contains
(
filters
[
filter.key
],
'
true
')?'
checked
'
:
''}
class=
"filter-bool"
i-key=
"${normalizedKey}true"
id=
"${normalizedKey}"
value=
"true"
/><spring:message
code=
"boolean.true"
/></label></div>
<div><label><input
type=
"checkbox"
${
fn:contains
(
filters
[
filter.key
],
'
false
')?'
checked
'
:
''}
class=
"filter-bool"
i-key=
"${normalizedKey}false"
id=
"${normalizedKey}"
value=
"false"
/><spring:message
code=
"boolean.false"
/></label></div>
<div><label><input
type=
"checkbox"
${
fn:contains
(
filters
[
filter.key
],
'
null
')?'
checked
'
:
''}
class=
"filter-bool"
i-key=
"${normalizedKey}null"
id=
"${normalizedKey}"
value=
"null"
/><spring:message
code=
"boolean.null"
/></label></div>
</div>
<div
style=
"margin-top: 3px"
>
<button
class=
"btn btn-primary apply"
><spring:message
code=
"filter.apply"
/></button>
</div>
</c:when>
<c:otherwise>
<div
class=
"ui-front"
>
<div
class=
"form-group input-group"
>
<span
class=
"input-group-btn"
>
<input
class=
"span2 form-control"
id=
"${normalizedKey}_input"
type=
"text"
/>
<button
class=
"btn notimportant filter-auto"
norm-key=
"${normalizedKey}"
>
+
</button>
</span>
</div>
<div
style=
"margin-top: 3px"
>
<button
class=
"btn btn-primary apply"
><spring:message
code=
"filter.apply"
/></button>
</div>
</div>
</c:otherwise>
</c:choose>
</div>
<div>
<a
href=
"#"
style=
"float: right"
class=
"close-fil glyphicon glyphicon-remove"
></a>
<a
href=
"#"
style=
"float: right"
class=
"edit-fil glyphicon glyphicon-pencil"
></a>
</div>
<div
class=
"col-lg-4 filter-values"
id=
"${normalizedKey}_value"
>
<c:forEach
items=
"
${
filters
[
filter
.
key
]
}
"
var=
"value"
>
<c:set
var=
"string"
value=
"
${
value
}
"
/>
<c:if
test=
"
${
fn:
contains
(
value
,
'range'
)
}
"
>
<c:set
var=
"string"
value=
"
${
fn:
replace
(
value
,
'{range=['
,
'Between '
)
}
"
/>
<c:set
var=
"string"
value=
"
${
fn:
replace
(
string
,
','
,
' and '
)
}
"
/>
<c:set
var=
"string"
value=
"
${
fn:
replace
(
string
,
']}'
,
''
)
}
"
/>
</c:if>
<c:if
test=
"
${
fn:
contains
(
value
,
'min'
)
}
"
>
<c:set
var=
"string"
value=
"
${
fn:
replace
(
value
,
'{min='
,
'More than '
)
}
"
/>
<c:set
var=
"string"
value=
"
${
fn:
replace
(
string
,
'}'
,
''
)
}
"
/>
</c:if>
<c:if
test=
"
${
fn:
contains
(
value
,
'max'
)
}
"
>
<c:set
var=
"string"
value=
"
${
fn:
replace
(
value
,
'{max='
,
'Less than '
)
}
"
/>
<c:set
var=
"string"
value=
"
${
fn:
replace
(
string
,
'}'
,
''
)
}
"
/>
</c:if>
<div
class=
"filtval complex"
x-key=
"${normalizedKey}${value}"
id=
"${normalizedKey}"
>
${string}
</div>
</c:forEach>
</div>
</div>
</c:forEach>
src/main/webapp/WEB-INF/jsp/accession/explore_new.jsp
View file @
c2cd8802
This diff is collapsed.
Click to expand it.
src/main/webapp/WEB-INF/jsp/accession/modal.jsp
0 → 100644
View file @
c2cd8802
<%@ page
contentType=
"charset=UTF-8"
pageEncoding=
"UTF-8"
language=
"java"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"security"
uri=
"http://www.springframework.org/security/tags"
%>
<%@ taglib
prefix=
"spring"
uri=
"http://www.springframework.org/tags"
%>
<%@ taglib
prefix=
"fmt"
uri=
"http://java.sun.com/jsp/jstl/fmt"
%>
<%@ taglib
prefix=
"fn"
uri=
"http://java.sun.com/jsp/jstl/functions"
%>
<div
class=
"modal-header"
>
<h4
class=
"modal-title"
id=
"myModalLabel"
><spring:message
code=
"filter.additional"
/></h4>
</div>
<div
class=
"modal-body"
style=
"overflow: auto;height: 200px"
>
<c:forEach
items=
"
${
categories
}
"
var=
"category"
>
<c:if
test=
"
${
descriptors
[
category
].
size
()
gt
0
}
"
>
<h2><c:out
value=
"
${
crop
.
getName
(
pageContext
.
request
.
locale
)
}
:"
/>
<c:out
value=
"
${
category
.
getName
(
pageContext
.
request
.
locale
)
}
"
/></h2>
<c:forEach
items=
"
${
descriptors
[
category
]
}
"
var=
"descriptor"
>
<c:if
test=
"
${
methods
[
descriptor
.
id
].
size
()
gt
0
}
"
>
<div
class=
"row filter-block"
>
<div
class=
"col-lg-3"
>
<div
dir=
"ltr"
><c:out
value=
"
${
descriptor
.
title
}
"
/></div>
</div>
<div
class=
"col-lg-9"
>
<c:forEach
items=
"
${
methods
[
descriptor
.
id
]
}
"
var=
"method"
>
<c:set
value=
"gm:${method.id}"
var=
"gm_value"
/>
<div><label><input
class=
"additional"
${
fn:contains
(
jsonPick
,
gm_value
)?'
checked
'
:
''}
id=
"gm_${method.id}_id"
type=
"checkbox"
style=
"margin-right: 1em;"
value=
"gm:${method.id}"
/><span
dir=
"ltr"
><c:out
value=
"
${
method
.
method
}
"
/></span></label></div>
</c:forEach>
</div>
</div>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
><spring:message
code=
"filter.apply"
/></button>
</div>
\ No newline at end of file
Write
Preview
Supports
Markdown
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