Skip to content
GitLab
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
eae0fbb4
Commit
eae0fbb4
authored
Jan 20, 2016
by
Alexander Basov
Browse files
Feature #28105 Adding accession lists to Projects
parent
7defbdc2
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/persistence/domain/AccessionListRepository.java
View file @
eae0fbb4
...
...
@@ -50,5 +50,9 @@ public interface AccessionListRepository extends JpaRepository<AccessionList, Lo
@Query
(
nativeQuery
=
true
,
value
=
"select count(acceid) from accelistitems where listid = ?1"
)
int
sizeOf
(
AccessionList
list
);
@Query
(
"from AccessionList al where al.shared=1 order by al.title asc"
)
List
<
AccessionList
>
findShared
();
@Query
(
"select uuid from AccessionList al where al.title=?1"
)
UUID
getUUIDByTitle
(
String
title
);
}
src/main/java/org/genesys2/server/service/AccessionListService.java
View file @
eae0fbb4
...
...
@@ -55,5 +55,7 @@ public interface AccessionListService {
int
sizeOf
(
AccessionList
accessionList
);
List
<
AccessionList
>
findShared
();
UUID
getUUIDByTitle
(
String
title
);
}
\ No newline at end of file
src/main/java/org/genesys2/server/service/impl/AccessionListServiceImpl.java
View file @
eae0fbb4
...
...
@@ -167,4 +167,16 @@ public class AccessionListServiceImpl implements AccessionListService {
public
int
sizeOf
(
AccessionList
list
)
{
return
accessionListRepository
.
sizeOf
(
list
);
}
@Override
@PreAuthorize
(
"isAuthenticated()"
)
public
List
<
AccessionList
>
findShared
()
{
return
accessionListRepository
.
findShared
();
}
@Override
@PreAuthorize
(
"isAuthenticated()"
)
public
UUID
getUUIDByTitle
(
String
title
)
{
return
accessionListRepository
.
getUUIDByTitle
(
title
);
}
}
src/main/java/org/genesys2/server/servlet/controller/ProjectController.java
View file @
eae0fbb4
...
...
@@ -16,8 +16,15 @@
package
org.genesys2.server.servlet.controller
;
import
java.util.UUID
;
import
java.util.Set
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
org.apache.commons.lang.StringUtils
;
import
org.genesys2.server.model.impl.AccessionList
;
import
org.genesys2.server.model.impl.Project
;
import
org.genesys2.server.service.AccessionListService
;
import
org.genesys2.server.service.ContentService
;
...
...
@@ -34,6 +41,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
@Controller
@RequestMapping
(
"/project"
)
...
...
@@ -90,7 +98,8 @@ public class ProjectController extends BaseController {
@RequestMapping
(
"/update-project"
)
public
String
update
(
ModelMap
modelMap
,
@ModelAttribute
(
"project"
)
Project
p
,
@RequestParam
(
"blurp"
)
String
aboutBody
,
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
)
{
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
,
@RequestParam
(
value
=
"accessionListTitle"
,
required
=
false
)
List
<
String
>
titles
)
{
_logger
.
debug
(
"Updating project "
+
p
.
getCode
());
Project
project
=
null
;
...
...
@@ -105,7 +114,13 @@ public class ProjectController extends BaseController {
project
.
setCode
(
p
.
getCode
());
project
.
setUrl
(
p
.
getUrl
());
project
.
setName
(
p
.
getName
());
project
.
setAccessionLists
(
p
.
getAccessionLists
());
Set
<
String
>
titlesWithoutDuplicates
=
new
LinkedHashSet
<
String
>(
titles
);
List
<
UUID
>
projectAccessionLists
=
new
ArrayList
<
UUID
>();
for
(
String
title:
titlesWithoutDuplicates
)
{
projectAccessionLists
.
add
(
accessionListService
.
getUUIDByTitle
(
title
));
}
project
.
setAccessionLists
(
projectAccessionLists
);
projectService
.
saveProject
(
project
);
projectService
.
updateBlurp
(
project
,
aboutBody
,
summary
,
getLocale
());
...
...
@@ -113,6 +128,22 @@ public class ProjectController extends BaseController {
return
"redirect:/project/"
+
p
.
getCode
();
}
@ResponseBody
@RequestMapping
(
"/get-autocomplete"
)
public
String
getAutocompletedListName
(
@RequestParam
String
prefix
)
{
if
(!
prefix
.
equals
(
""
))
{
List
<
AccessionList
>
sharedLists
=
accessionListService
.
findShared
();
for
(
AccessionList
list
:
sharedLists
)
{
String
title
=
list
.
getTitle
();
if
(
title
.
startsWith
(
prefix
)
&&
!
title
.
equals
(
prefix
))
{
return
title
.
substring
(
prefix
.
length
());
}
}
}
return
StringUtils
.
EMPTY
;
}
protected
Locale
getLocale
()
{
return
LocaleContextHolder
.
getLocale
();
}
...
...
src/main/webapp/WEB-INF/jsp/project/edit.jsp
View file @
eae0fbb4
...
...
@@ -74,13 +74,16 @@
<spring:message
code=
"project.accessionLists"
/>
</label>
<div
class=
"controls col-lg-9"
>
<c:forEach
items=
"
${
project
.
accessionLists
}
"
var=
"accessionList"
>
<c:forEach
items=
"
${
accessionLists
}
"
var=
"accessionList"
>
<div>
<input
type=
"text"
name=
"accessionList
s
"
class=
"form-control"
value=
"${accessionList
}
"
/>
<input
type=
"text"
name=
"accessionList
Title
"
class=
"form-control"
value=
"${accessionList
.title}"
placeholder=
"List title
"
/>
</div>
</c:forEach>
<div
id=
"extraLists"
>
<input
type=
"text"
id=
"extraList"
name=
"accessionListTitle"
class=
"form-control"
value=
""
placeholder=
"List title"
/>
</div>
<div>
<
input
type=
"text"
name=
"accessionLists"
class=
"form-control"
value=
""
placeholder=
"u-u-i-d"
/
>
<
button
id=
"addBtn"
class=
"btn btn-default"
>
+
</button
>
</div>
</div>
</div>
...
...
@@ -95,6 +98,51 @@
<content
tag=
"javascript"
>
<script
type=
"text/javascript"
>
<local:tinyMCE
selector=
".html-editor"
/>
function
setHandlers
(
input
)
{
var
del
=
false
;
input
.
on
(
"
keydown
"
,
function
(
e
)
{
del
=
e
.
which
==
8
||
e
.
which
==
46
;
});
input
.
on
(
"
input
"
,
function
()
{
if
(
del
)
return
;
$
.
ajax
({
url
:
'
<c:url
value=
"/project/get-autocomplete"
/>
'
,
data
:
{
prefix
:
input
.
val
()},
success
:
function
(
suffix
)
{
var
prefix
=
input
.
val
();
input
.
val
(
prefix
+
suffix
);
var
text
=
input
.
get
(
0
);
if
(
typeof
text
.
selectionStart
!=
"
undefined
"
)
{
text
.
selectionStart
=
prefix
.
length
;
text
.
selectionEnd
=
prefix
.
length
+
suffix
.
length
;
}
else
if
(
document
.
selection
&&
document
.
selection
.
createRange
)
{
text
.
select
();
var
range
=
document
.
selection
.
createRange
();
range
.
collapse
(
true
);
range
.
moveEnd
(
"
character
"
,
prefix
.
length
+
suffix
.
length
);
range
.
moveStart
(
"
character
"
,
prefix
.
length
);
range
.
select
();
}
}
});
})
}
$
(
"
input[name='accessionListTitle']
"
).
each
(
function
()
{
setHandlers
(
$
(
this
));
});
var
extraList
=
$
(
"
#extraList
"
);
extraList
.
removeAttr
(
"
id
"
);
$
(
document
).
ready
(
function
()
{
$
(
"
#addBtn
"
).
on
(
"
click
"
,
function
(
e
)
{
e
.
preventDefault
();
var
copy
=
extraList
.
clone
();
copy
.
val
(
""
);
setHandlers
(
copy
);
$
(
"
#extraLists
"
).
append
(
copy
);
});
});
</script>
</content>
</body>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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