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
7518f111
Commit
7518f111
authored
Nov 02, 2015
by
Alexander Basov
Browse files
Feature #26085
Project pages in Genesys
parent
f537ff97
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/model/impl/Project.java
0 → 100644
View file @
7518f111
package
org.genesys2.server.model.impl
;
import
org.genesys2.server.model.AclAwareModel
;
import
org.genesys2.server.model.VersionedAuditedModel
;
import
javax.persistence.*
;
import
java.util.List
;
import
java.util.UUID
;
@Entity
@Table
(
name
=
"project"
)
public
class
Project
extends
VersionedAuditedModel
implements
AclAwareModel
{
@Column
(
length
=
200
,
nullable
=
false
)
private
String
name
;
@Column
(
length
=
200
,
nullable
=
true
)
private
String
url
;
@Column
(
length
=
50
,
nullable
=
false
,
unique
=
true
)
private
String
code
;
@OneToMany
(
fetch
=
FetchType
.
LAZY
,
targetEntity
=
AccessionList
.
class
)
private
List
<
UUID
>
accessionLists
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
List
<
UUID
>
getAccessionLists
()
{
return
accessionLists
;
}
public
void
setAccessionLists
(
List
<
UUID
>
accessionLists
)
{
this
.
accessionLists
=
accessionLists
;
}
}
src/main/java/org/genesys2/server/persistence/domain/ProjectRepository.java
0 → 100644
View file @
7518f111
package
org.genesys2.server.persistence.domain
;
import
org.genesys2.server.model.impl.Project
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
ProjectRepository
extends
JpaRepository
<
Project
,
Long
>{
Project
findByCode
(
String
code
);
List
<
Project
>
findByName
(
String
name
);
}
src/main/java/org/genesys2/server/service/ProjectService.java
0 → 100644
View file @
7518f111
package
org.genesys2.server.service
;
import
org.genesys2.server.model.impl.Project
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
java.util.List
;
import
java.util.Locale
;
public
interface
ProjectService
{
Page
<
Project
>
list
(
Pageable
p
);
Project
getProjectById
(
Long
id
);
Project
getProjectByCode
(
String
code
);
List
<
Project
>
getAllProjects
();
List
<
Project
>
getProjectsByName
(
String
name
);
void
saveProject
(
Project
project
);
void
deleteProject
(
Project
project
);
void
updateBlurp
(
Project
project
,
String
textBody
,
String
summary
,
Locale
locale
);
}
src/main/java/org/genesys2/server/service/impl/ProjectServiceImpl.java
0 → 100644
View file @
7518f111
package
org.genesys2.server.service.impl
;
import
org.genesys2.server.model.impl.Project
;
import
org.genesys2.server.persistence.domain.ProjectRepository
;
import
org.genesys2.server.service.ContentService
;
import
org.genesys2.server.service.ProjectService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Locale
;
@Service
@Transactional
public
class
ProjectServiceImpl
implements
ProjectService
{
@Autowired
ProjectRepository
projectRepository
;
@Autowired
ContentService
contentService
;
@Override
public
Page
<
Project
>
list
(
Pageable
p
)
{
return
projectRepository
.
findAll
(
p
);
}
@Override
public
Project
getProjectById
(
Long
id
)
{
return
projectRepository
.
findOne
(
id
);
}
@Override
public
Project
getProjectByCode
(
String
code
)
{
return
projectRepository
.
findByCode
(
code
);
}
@Override
public
List
<
Project
>
getAllProjects
()
{
return
projectRepository
.
findAll
();
}
@Override
public
List
<
Project
>
getProjectsByName
(
String
name
)
{
return
projectRepository
.
findByName
(
name
);
}
@Override
public
void
saveProject
(
Project
project
)
{
projectRepository
.
save
(
project
);
}
@Override
public
void
deleteProject
(
Project
project
)
{
projectRepository
.
delete
(
project
);
}
@Override
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER') or hasPermission(#crop, 'ADMINISTRATION')"
)
@Transactional
(
readOnly
=
false
)
public
void
updateBlurp
(
Project
project
,
String
textBody
,
String
summary
,
Locale
locale
)
{
contentService
.
updateArticle
(
project
,
"blurp"
,
null
,
textBody
,
summary
,
locale
);
}
}
src/main/java/org/genesys2/server/servlet/controller/ProjectController.java
0 → 100644
View file @
7518f111
package
org.genesys2.server.servlet.controller
;
import
org.genesys2.server.model.impl.Project
;
import
org.genesys2.server.service.ContentService
;
import
org.genesys2.server.service.ProjectService
;
import
org.genesys2.spring.ResourceNotFoundException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.Locale
;
@Controller
@RequestMapping
(
"/project"
)
public
class
ProjectController
extends
BaseController
{
@Autowired
private
ProjectService
projectService
;
@Autowired
ContentService
contentService
;
@RequestMapping
({
"/"
,
""
})
public
String
projects
(){
return
"redirect:/project/list"
;
}
@RequestMapping
(
"/list"
)
public
String
listProjects
(
ModelMap
modelMap
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
){
Page
<
Project
>
projects
=
projectService
.
list
(
new
PageRequest
(
page
-
1
,
20
,
new
Sort
(
"name"
)));
modelMap
.
addAttribute
(
"pagedData"
,
projects
);
return
"/project/index"
;
}
@RequestMapping
(
"/{code}"
)
public
String
viewProject
(
ModelMap
modelMap
,
@PathVariable
(
value
=
"code"
)
String
code
){
Project
project
=
projectService
.
getProjectByCode
(
code
);
modelMap
.
addAttribute
(
"blurp"
,
contentService
.
getArticle
(
project
,
"blurp"
,
getLocale
()));
modelMap
.
addAttribute
(
"project"
,
project
);
return
"/project/view"
;
}
@RequestMapping
(
"/edit/{code}"
)
public
String
editProject
(
ModelMap
modelMap
,
@PathVariable
(
value
=
"code"
)
String
code
){
viewProject
(
modelMap
,
code
);
return
"/project/edit"
;
}
@RequestMapping
(
"/{code}/update"
)
public
String
update
(
ModelMap
modelMap
,
@PathVariable
(
value
=
"code"
)
String
code
,
@RequestParam
(
"blurp"
)
String
aboutBody
,
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
){
_logger
.
debug
(
"Updating project "
+
code
);
final
Project
project
=
projectService
.
getProjectByCode
(
code
);
if
(
project
==
null
)
{
throw
new
ResourceNotFoundException
();
}
projectService
.
updateBlurp
(
project
,
aboutBody
,
summary
,
getLocale
());
return
"redirect:/project/"
+
code
;
}
protected
Locale
getLocale
()
{
return
LocaleContextHolder
.
getLocale
();
}
}
src/main/resources/content/language.properties
View file @
7518f111
...
...
@@ -156,6 +156,10 @@ country.replaced-by=Country code is replaced by: {0}
country.is-itpgrfa-contractingParty
=
{0} is party to the International Treaty on Plant Genetic Resources for Food and Agriculture (ITPGRFA).
select-country
=
Select country
project.page.list.title
=
WIEWS Projects
project.page.profile.title
=
WIEWS {0}
project.summary
=
Summary (HTML metadata)
faoInstitutes.page.list.title
=
WIEWS Institutes
faoInstitutes.page.profile.title
=
WIEWS {0}
faoInstitutes.stat.accessionCount
=
Accessions in Genesys:
...
...
src/main/webapp/WEB-INF/jsp/project/edit.jsp
0 → 100644
View file @
7518f111
<!DOCTYPE html>
<%@include
file=
"/WEB-INF/jsp/init.jsp"
%>
<html>
<head>
<title><spring:message
code=
"project.page.profile.title"
arguments=
"
${
project
.
name
}
"
argumentSeparator=
"|"
/></title>
</head>
<body>
<form
role=
"form"
class=
"form-horizontal"
action=
"
<c:url
value=
"/project/${project.code}/update"
/>
"
method=
"post"
>
<div
class=
"form-group"
>
<label
for=
"blurp-body"
class=
"col-lg-12 control-label"
><spring:message
code=
"blurp.blurp-body"
/></label>
<div
class=
"controls col-lg-12"
>
<textarea
id=
"blurp-body"
name=
"blurp"
class=
"span9 required html-editor"
>
<c:out
value=
"
${
blurp
.
body
}
"
/>
</textarea>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"project-summary"
class=
"col-lg-12 control-label"
><spring:message
code=
"project.summary"
/></label>
<div
class=
"controls col-lg-12"
>
<textarea
id=
"project-summary"
name=
"summary"
class=
"span9 required html-editor"
>
<c:out
value=
"
${
blurp
.
summary
}
"
/>
</textarea>
</div>
</div>
<input
type=
"submit"
value=
"
<spring:message
code=
"save"
/>
"
class=
"btn btn-primary"
/>
<a
href=
"
<c:url
value=
"/project/${project.code}"
/>
"
class=
"btn btn-default"
>
<spring:message
code=
"cancel"
/>
</a>
<!-- CSRF protection -->
<input
type=
"hidden"
name=
"${_csrf.parameterName}"
value=
"${_csrf.token}"
/>
</form>
<content
tag=
"javascript"
>
<script
type=
"text/javascript"
>
<local:tinyMCE
selector=
".html-editor"
/>
</script>
</content>
</body>
</html>
src/main/webapp/WEB-INF/jsp/project/index.jsp
0 → 100644
View file @
7518f111
<!DOCTYPE html>
<%@include
file=
"/WEB-INF/jsp/init.jsp"
%>
<html>
<head>
<title><spring:message
code=
"project.page.list.title"
/></title>
</head>
<body>
<h1>
<spring:message
code=
"project.page.list.title"
/>
</h1>
<div
class=
"main-col-header clearfix"
>
<div
class=
"nav-header"
>
<local:paginate
page=
"
${
pagedData
}
"
/>
</div>
</div>
<ul
class=
"funny-list"
>
<c:forEach
items=
"
${
pagedData
.
content
}
"
var=
"project"
varStatus=
"status"
>
<li
class=
"clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"
>
<a
class=
"show pull-left"
href=
"
<c:url
value=
"/project/${project.code}"
/>
"
>
<b><c:out
value=
"
${
project
.
code
}
"
/></b>
<c:out
value=
"
${
project
.
name
}
"
/>
</a>
</li>
</c:forEach>
</ul>
</body>
</html>
src/main/webapp/WEB-INF/jsp/project/view.jsp
0 → 100644
View file @
7518f111
<!DOCTYPE html>
<%@include
file=
"/WEB-INF/jsp/init.jsp"
%>
<html>
<head>
<title><c:out
value=
"
${
project
.
name
}
"
/></title>
<meta
name=
"description"
content=
"
<c:out
value=
"
${
jspHelper
.
htmlToText
(
blurp
.
summary
)
}
"
/>
"
/>
</head>
<body>
<c:if
test=
"
${
project
eq
null
}
"
>
<div
class=
"alert alert-error"
>
<spring:message
code=
"data.error.404"
/>
</div>
</c:if>
<security:authorize
access=
"hasRole('ADMINISTRATOR') or hasPermission(#crop, 'ADMINISTRATION')"
>
<a
href=
"
<c:url
value=
"/acl/${project.getClass().name}/${project.id}/permissions"
><c:param
name=
"back"
><c:url
value=
"/project/${project.code}"
/></c:param></c:url>
"
class=
"close"
>
<spring:message
code=
"edit-acl"
/>
</a>
</security:authorize>
<security:authorize
access=
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER') or hasPermission(#crop, 'ADMINISTRATION')"
>
<a
href=
"
<c:url
value=
"/project/edit/${project.code}"
/>
"
class=
"close"
>
<spring:message
code=
"edit"
/>
</a>
</security:authorize>
<c:if
test=
"
${
blurp
ne
null
}
"
>
<%@include
file=
"/WEB-INF/jsp/content/include/blurp-display.jsp"
%>
</c:if>
</body>
</html>
src/main/webapp/WEB-INF/jsp/wiews/index.jsp
View file @
7518f111
<!DOCTYPE html>
<%@include
file=
"/WEB-INF/jsp/init.jsp"
%>
<%@include
file=
"/WEB-INF/jsp/init.jsp"
%>
<html>
<head>
<title><spring:message
code=
"faoInstitutes.page.list.title"
/></title>
<title><spring:message
code=
"faoInstitutes.page.list.title"
/></title>
</head>
<body>
<h1>
<spring:message
code=
"faoInstitutes.page.list.title"
/>
</h1>
<h1>
<spring:message
code=
"faoInstitutes.page.list.title"
/>
</h1>
<div
class=
"main-col-header clearfix"
>
<div
class=
"nav-header"
>
<div>
<c:if
test=
"
${
activeOnly
eq
true
}
"
>
<a
href=
"
<c:url
value=
"/wiews/active/map"
/>
"
><spring:message
code=
"maps.view-map"
/></a>
<a
href=
"
<c:url
value=
"/wiews/"
/>
"
><spring:message
code=
"faoInstitutes.viewAll"
/></a>
</c:if>
<c:if
test=
"
${
activeOnly
ne
true
}
"
>
<a
href=
"
<c:url
value=
"/wiews/active"
/>
"
><spring:message
code=
"faoInstitutes.viewActiveOnly"
/></a>
</c:if>
</div>
<local:paginate
page=
"
${
pagedData
}
"
/>
</div>
</div>
<div
class=
"main-col-header clearfix"
>
<div
class=
"nav-header"
>
<div>
<c:if
test=
"
${
activeOnly
eq
true
}
"
>
<a
href=
"
<c:url
value=
"/wiews/active/map"
/>
"
><spring:message
code=
"maps.view-map"
/></a>
<a
href=
"
<c:url
value=
"/wiews/"
/>
"
><spring:message
code=
"faoInstitutes.viewAll"
/></a>
</c:if>
<c:if
test=
"
${
activeOnly
ne
true
}
"
>
<a
href=
"
<c:url
value=
"/wiews/active"
/>
"
><spring:message
code=
"faoInstitutes.viewActiveOnly"
/></a>
</c:if>
</div>
<local:paginate
page=
"
${
pagedData
}
"
/>
</div>
</div>
<ul
class=
"funny-list"
>
<c:forEach
items=
"
${
pagedData
.
content
}
"
var=
"faoInstitute"
varStatus=
"status"
>
<li
class=
"clearfix ${status.count % 2 == 0 ? 'even' : 'odd'} ${faoInstitute.current ? '' : 'not-current'}"
><a
class=
"show pull-left"
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}"
/>
"
><b><c:out
value=
"
${
faoInstitute
.
code
}
"
/></b>
<c:out
value=
"
${
faoInstitute
.
fullName
}
"
/></a>
<div
class=
"pull-right"
><spring:message
code=
"faoInstitute.accessionCount"
arguments=
"
${
faoInstitute
.
accessionCount
}
"
/></div></li>
</c:forEach>
</ul>
<ul
class=
"funny-list"
>
<c:forEach
items=
"
${
pagedData
.
content
}
"
var=
"faoInstitute"
varStatus=
"status"
>
<li
class=
"clearfix ${status.count % 2 == 0 ? 'even' : 'odd'} ${faoInstitute.current ? '' : 'not-current'}"
><a
class=
"show pull-left"
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}"
/>
"
><b><c:out
value=
"
${
faoInstitute
.
code
}
"
/></b>
<c:out
value=
"
${
faoInstitute
.
fullName
}
"
/></a>
<div
class=
"pull-right"
><spring:message
code=
"faoInstitute.accessionCount"
arguments=
"
${
faoInstitute
.
accessionCount
}
"
/></div>
</li>
</c:forEach>
</ul>
</body>
</html>
\ 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