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
8752f1bf
Commit
8752f1bf
authored
Nov 20, 2015
by
Alexander Basov
Committed by
Matija Obreza
Nov 30, 2015
Browse files
Feature #26151 Specifying columns to include in accession list /explore
parent
b3d9dc34
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/model/json/Api1Constants.java
View file @
8752f1bf
...
...
@@ -21,6 +21,8 @@ package org.genesys2.server.model.json;
*/
public
interface
Api1Constants
{
public
static
interface
Accession
{
public
static
final
String
CROPE_NAME
=
"cropName"
;
/**
* WIEWS code of accession holding institute.
*/
...
...
@@ -183,10 +185,12 @@ public interface Api1Constants {
*/
public
static
final
String
ACCEURL
=
"acceUrl"
;
public
static
final
String
SCIENTIFIC_NAME
=
"scientificName"
;
}
public
static
interface
Collecting
{
public
static
final
String
MISSION_ID
=
"collectingMissionID"
;
/**
* Corresponds to COLLDATE
*/
...
...
@@ -230,6 +234,7 @@ public interface Api1Constants {
public
static
interface
Geo
{
public
static
final
String
LATITUDE_LONGITUDE
=
"latitudeAndLongitude"
;
/**
* Latitude
*/
...
...
src/main/java/org/genesys2/server/service/GenesysService.java
View file @
8752f1bf
...
...
@@ -57,17 +57,20 @@ import org.springframework.data.domain.Pageable;
public
interface
GenesysService
{
/**
* Return the number of active ({@link Accession#historic} == false) accession records
* Return the number of active ({@link Accession#historic} == false)
* accession records
*/
long
countByInstitute
(
FaoInstitute
institute
);
/**
* Return the number of active ({@link Accession#historic} == false) accession records
* Return the number of active ({@link Accession#historic} == false)
* accession records
*/
long
countByOrigin
(
Country
country
);
/**
* Return the number of active ({@link Accession#historic} == false) accession records
* Return the number of active ({@link Accession#historic} == false)
* accession records
*/
long
countByLocation
(
Country
country
);
...
...
@@ -131,7 +134,7 @@ public interface GenesysService {
void
updateAccessionInstitueRefs
();
List
<
Accession
>
saveAccessions
(
FaoInstitute
institute
,
List
<
Accession
>
matching
);
List
<
SvalbardData
>
saveSvalbards
(
List
<
SvalbardData
>
svalbards
);
long
countAvailableForDistribution
(
Set
<
Long
>
accessionIds
);
...
...
@@ -139,7 +142,7 @@ public interface GenesysService {
Set
<
Long
>
filterAvailableForDistribution
(
Set
<
Long
>
accessionIds
);
AccessionData
saveAccession
(
AccessionData
accession
);
List
<
Accession
>
saveAccessions
(
Iterable
<
Accession
>
accession
);
void
updateAccessionCount
(
FaoInstitute
institute
);
...
...
@@ -171,7 +174,7 @@ public interface GenesysService {
List
<
AccessionGeo
>
listAccessionsGeo
(
Set
<
Long
>
copy
);
List
<
AccessionHistoric
>
removeAccessions
(
FaoInstitute
institute
,
List
<
Accession
>
toDelete
);
void
setInSvalbard
(
List
<
Accession
>
matching
);
void
addAccessions
(
List
<
Accession
>
accessions
);
...
...
@@ -210,6 +213,10 @@ public interface GenesysService {
List
<
Long
>
listAccessionsIds
(
Taxonomy2
taxonomy
);
List
<
String
>
columnsForDisplay
();
List
<
String
>
defaultViewColumns
();
public
static
class
AllStuff
{
public
AllStuff
(
long
id
)
{
this
.
id
=
id
;
...
...
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
View file @
8752f1bf
...
...
@@ -72,6 +72,7 @@ import org.genesys2.server.model.impl.Country;
import
org.genesys2.server.model.impl.Crop
;
import
org.genesys2.server.model.impl.FaoInstitute
;
import
org.genesys2.server.model.impl.Organization
;
import
org.genesys2.server.model.json.Api1Constants
;
import
org.genesys2.server.persistence.domain.AccessionAliasRepository
;
import
org.genesys2.server.persistence.domain.AccessionBreedingRepository
;
import
org.genesys2.server.persistence.domain.AccessionCollectRepository
;
...
...
@@ -1068,8 +1069,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
zos
.
putNextEntry
(
metaEntry
);
final
BufferedWriter
osw
=
new
BufferedWriter
(
new
OutputStreamWriter
(
zos
));
osw
.
write
(
"<?xml version='1.0' encoding='utf-8'?>\n"
);
osw
.
write
(
"<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n"
);
osw
.
write
(
"<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n"
);
osw
.
write
(
"<core encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\""\" ignoreHeaderLines=\"0\">\n"
);
osw
.
write
(
"\t<files><location>core.csv</location></files>\n"
);
osw
.
write
(
"\t<id index=\"0\" />\n"
);
...
...
@@ -1336,8 +1336,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
zos
.
putNextEntry
(
metaEntry
);
final
BufferedWriter
osw
=
new
BufferedWriter
(
new
OutputStreamWriter
(
zos
));
osw
.
write
(
"<?xml version='1.0' encoding='utf-8'?>\n"
);
osw
.
write
(
"<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n"
);
osw
.
write
(
"<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n"
);
osw
.
write
(
"<core encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\""\" ignoreHeaderLines=\"0\">\n"
);
osw
.
write
(
"\t<files><location>core.csv</location></files>\n"
);
osw
.
write
(
"\t<id index=\"0\" />\n"
);
...
...
@@ -1349,8 +1348,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
for
(
int
i
=
0
;
i
<
metadataMethods
.
size
();
i
++)
{
final
Method
method
=
metadataMethods
.
get
(
i
);
osw
.
write
(
"<extension encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\""\" ignoreHeaderLines=\"0\">\n"
);
osw
.
write
(
"<extension encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\""\" ignoreHeaderLines=\"0\">\n"
);
osw
.
write
(
"\t<files><location>"
);
osw
.
write
(
method
.
getFieldName
().
toLowerCase
());
osw
.
write
(
".csv</location></files>\n"
);
...
...
@@ -1531,6 +1529,29 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return
toRemove
;
}
@Override
public
List
<
String
>
columnsForDisplay
()
{
List
<
String
>
columnList
=
new
ArrayList
<>();
columnList
.
add
(
Api1Constants
.
Accession
.
GENUS
);
columnList
.
add
(
Api1Constants
.
Accession
.
SPECIES
);
columnList
.
add
(
Api1Constants
.
Accession
.
SUBTAXA
);
columnList
.
add
(
Api1Constants
.
Accession
.
CROPE_NAME
);
columnList
.
add
(
Api1Constants
.
Geo
.
LATITUDE_LONGITUDE
);
columnList
.
add
(
Api1Constants
.
Collecting
.
MISSION_ID
);
return
columnList
;
}
@Override
public
List
<
String
>
defaultViewColumns
()
{
List
<
String
>
columnList
=
new
ArrayList
<>();
columnList
.
add
(
Api1Constants
.
Accession
.
ACCENUMB
);
columnList
.
add
(
Api1Constants
.
Accession
.
SCIENTIFIC_NAME
);
columnList
.
add
(
Api1Constants
.
Accession
.
ORIGCTY
);
columnList
.
add
(
Api1Constants
.
Accession
.
SAMPSTAT
);
columnList
.
add
(
Api1Constants
.
Accession
.
INSTCODE
);
return
columnList
;
}
@Override
public
List
<
Long
>
listAccessionsIds
(
Taxonomy2
taxonomy
)
{
return
accessionRepository
.
listAccessionsIds
(
taxonomy
);
...
...
src/main/java/org/genesys2/server/servlet/controller/ExplorerController.java
View file @
8752f1bf
/**
* Copyright 2015 Global Crop Diversity Trust
*
*
<p/>
* 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
*
*
<p/>
* http://www.apache.org/licenses/LICENSE-2.0
*
<p/>
* 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.
...
...
@@ -25,10 +25,13 @@ import java.io.IOException;
import
java.io.OutputStream
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
javax.imageio.ImageIO
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.ArrayUtils
;
...
...
@@ -65,6 +68,7 @@ import org.springframework.http.MediaType;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -142,15 +146,31 @@ public class ExplorerController extends BaseController {
/**
* Browse all
*
*
* @param model
* @param page
* @return
* @throws IOException
*/
@RequestMapping
(
"/explore"
)
public
String
viewFiltered
(
ModelMap
model
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"filter"
,
required
=
true
,
defaultValue
=
"{}"
)
String
jsonFilter
)
throws
IOException
{
public
String
viewFiltered
(
HttpServletResponse
response
,
ModelMap
model
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"filter"
,
required
=
true
,
defaultValue
=
"{}"
)
String
jsonFilter
,
@RequestParam
(
value
=
"columns"
,
required
=
true
,
defaultValue
=
""
)
String
columns
,
@CookieValue
(
value
=
"columns"
,
defaultValue
=
""
)
String
cookieColumns
)
throws
IOException
{
if
(
columns
!=
null
&&
!
columns
.
isEmpty
())
{
String
columnsForCookie
=
""
;
for
(
String
clmn
:
Arrays
.
asList
(
columns
.
split
(
","
)))
{
columnsForCookie
+=
clmn
+
","
;
}
columnsForCookie
=
!
columnsForCookie
.
isEmpty
()
&&
columnsForCookie
.
substring
(
columnsForCookie
.
length
()
-
1
).
equals
(
","
)
?
columnsForCookie
.
substring
(
0
,
columnsForCookie
.
length
()
-
1
)
:
columnsForCookie
;
Cookie
cookie
=
new
Cookie
(
"columns"
,
columnsForCookie
);
response
.
addCookie
(
cookie
);
model
.
addAttribute
(
"selectedColumns"
,
columnsForCookie
.
isEmpty
()
?
Collections
.
emptyList
()
:
Arrays
.
asList
(
columnsForCookie
.
split
(
","
)));
}
else
if
(!
cookieColumns
.
isEmpty
())
{
model
.
addAttribute
(
"selectedColumns"
,
Arrays
.
asList
(
cookieColumns
.
split
(
","
)));
}
String
[]
selectedFilters
=
null
;
...
...
@@ -187,6 +207,8 @@ public class ExplorerController extends BaseController {
_logger
.
info
(
"Got: "
+
accessions
);
model
.
addAttribute
(
"defaultColumns"
,
genesysService
.
defaultViewColumns
());
model
.
addAttribute
(
"availableColumns"
,
genesysService
.
columnsForDisplay
());
model
.
addAttribute
(
"crops"
,
cropService
.
list
(
getLocale
()));
model
.
addAttribute
(
"pagedData"
,
accessions
);
model
.
addAttribute
(
"appliedFilters"
,
appliedFilters
);
...
...
@@ -198,7 +220,7 @@ public class ExplorerController extends BaseController {
/**
* Browse all using Elasticsearch
*
*
* @param model
* @param page
* @return
...
...
@@ -401,7 +423,7 @@ public class ExplorerController extends BaseController {
/**
* Change color of the tile
*
*
* @param color
* @param imageBytes
* @return
...
...
@@ -477,8 +499,8 @@ public class ExplorerController extends BaseController {
}
@RequestMapping
(
value
=
"/explore/overview"
)
public
String
overview
(
ModelMap
model
,
@RequestParam
(
value
=
"filter"
,
required
=
false
,
defaultValue
=
"{}"
)
String
jsonFilter
)
throws
IOException
,
SearchException
{
public
String
overview
(
ModelMap
model
,
@RequestParam
(
value
=
"filter"
,
required
=
false
,
defaultValue
=
"{}"
)
String
jsonFilter
)
throws
IOException
,
SearchException
{
AppliedFilters
appliedFilters
=
mapper
.
readValue
(
jsonFilter
,
AppliedFilters
.
class
);
String
[]
selectedFilters
=
appliedFilters
.
getFilterNames
();
...
...
@@ -538,12 +560,13 @@ public class ExplorerController extends BaseController {
@RequestMapping
(
value
=
"/explore/shorten-url"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ResponseBody
public
Object
getBriefURL
(
@RequestParam
(
value
=
"filter"
,
required
=
false
,
defaultValue
=
""
)
String
jsonFilter
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
)
throws
IOException
,
URISyntaxException
{
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
,
@CookieValue
(
value
=
"columns"
)
String
columns
)
throws
IOException
,
URISyntaxException
{
AppliedFilters
appliedFilters
=
mapper
.
readValue
(
jsonFilter
,
AppliedFilters
.
class
);
URI
longUrl
=
new
URIBuilder
(
baseUrl
).
setPath
(
"/explore"
).
addParameter
(
"filter"
,
appliedFilters
.
toString
())
.
addParameter
(
"page"
,
Integer
.
toString
(
page
))
.
build
();
URI
longUrl
=
new
URIBuilder
(
baseUrl
).
setPath
(
"/explore"
).
addParameter
(
"filter"
,
appliedFilters
.
toString
())
.
addParameter
(
"page"
,
Integer
.
toString
(
page
)).
addParameter
(
"columns"
,
columns
)
.
build
();
final
String
shortenedUrl
=
urlShortenerService
.
shortenUrl
(
longUrl
.
toURL
());
...
...
src/main/java/org/genesys2/server/servlet/controller/JspHelper.java
View file @
8752f1bf
...
...
@@ -17,11 +17,13 @@
package
org.genesys2.server.servlet.controller
;
import
java.text.DateFormatSymbols
;
import
java.util.List
;
import
java.util.Locale
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.math.RandomUtils
;
import
org.genesys2.server.exception.UserException
;
import
org.genesys2.server.model.genesys.Accession
;
import
org.genesys2.server.model.impl.Country
;
import
org.genesys2.server.model.impl.Crop
;
import
org.genesys2.server.model.impl.User
;
...
...
@@ -38,23 +40,23 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public
class
JspHelper
{
private
static
final
String
regExpr
=
"[^\\w]+"
;
private
static
final
String
regExpr
=
"[^\\w]+"
;
private
static
final
String
delimiter
=
"-"
;
@Autowired
private
static
final
String
delimiter
=
"-"
;
@Autowired
private
UserService
userService
;
@Autowired
@Autowired
private
GeoService
geoService
;
@Autowired
@Autowired
private
CropService
cropService
;
@Autowired
@Autowired
private
ObjectMapper
objectMapper
;
@Autowired
@Autowired
private
HtmlConverter
htmlConverter
;
public
String
userFullName
(
Long
userId
)
{
...
...
@@ -84,6 +86,10 @@ public class JspHelper {
return
cropService
.
getCrop
(
shortName
);
}
public
List
<
Crop
>
getCropsByAccession
(
Accession
accession
)
{
return
cropService
.
getCrops
(
accession
.
getTaxonomy
());
}
public
String
toJson
(
Object
object
)
throws
JsonProcessingException
{
return
objectMapper
.
writer
().
writeValueAsString
(
object
);
}
...
...
src/main/resources/content/language.properties
View file @
8752f1bf
...
...
@@ -332,6 +332,7 @@ accession.availability.false=Not available
accession.historic.true
=
Historic
accession.historic.false
=
Active
accession.acceUrl
=
Additional accession URL
accession.scientificName
=
Scientific name
accession.page.profile.title
=
Accession profile: {0}
accession.page.resolve.title
=
Multiple accessions found
...
...
@@ -369,6 +370,7 @@ selection.add-many.button=Add to selection list
savedmaps
=
Remember current map
savedmaps.list
=
Map list
savedmaps.save
=
Remember map
taxonomy.subtaxa
=
Subtaxa
filter.enter.title
=
Enter filter title
filters.page.title
=
Data filters
...
...
@@ -423,6 +425,20 @@ filter.internal.message.more=More than {0}
filter.internal.message.less
=
Less than {0}
filter.lists
=
Listed on accession list
columns.add
=
View
columns.applay
=
Applay
columns.genus
=
Genus
columns.species
=
Species
columns.subtaxa
=
Subtaxa
columns.cropName
=
Crop name
columns.latitudeAndLongitude
=
Latitude & Longitude
columns.collectingMissionID
=
Collecting mission ID
columns.acceNumb
=
Accession number
columns.scientificName
=
Scientific name
columns.orgCty
=
Country of origin
columns.sampStat
=
Biological status of accession
columns.instCode
=
Holding institute
search.page.title
=
Full-text Search
search.no-results
=
No matches found for your query.
...
...
src/main/webapp/WEB-INF/jsp/accession/explore.jsp
View file @
8752f1bf
This diff is collapsed.
Click to expand it.
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