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
15
Issues
15
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
ebf42a71
Commit
ebf42a71
authored
Mar 19, 2014
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX REST upsert handles "inTrust" property
parent
50c0b09c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
94 additions
and
0 deletions
+94
-0
src/main/java/org/genesys2/server/model/impl/FaoInstitute.java
...ain/java/org/genesys2/server/model/impl/FaoInstitute.java
+4
-0
src/main/java/org/genesys2/server/persistence/domain/FaoInstituteRepository.java
...ys2/server/persistence/domain/FaoInstituteRepository.java
+3
-0
src/main/java/org/genesys2/server/service/InstituteService.java
...in/java/org/genesys2/server/service/InstituteService.java
+3
-0
src/main/java/org/genesys2/server/service/UserService.java
src/main/java/org/genesys2/server/service/UserService.java
+1
-0
src/main/java/org/genesys2/server/service/impl/BatchRESTServiceImpl.java
...rg/genesys2/server/service/impl/BatchRESTServiceImpl.java
+9
-0
src/main/java/org/genesys2/server/service/impl/InstituteServiceImpl.java
...rg/genesys2/server/service/impl/InstituteServiceImpl.java
+20
-0
src/main/java/org/genesys2/server/servlet/controller/rest/UserController.java
...nesys2/server/servlet/controller/rest/UserController.java
+12
-0
src/main/java/org/genesys2/server/servlet/controller/rest/serialization/FaoInstituteSerializer.java
...controller/rest/serialization/FaoInstituteSerializer.java
+42
-0
No files found.
src/main/java/org/genesys2/server/model/impl/FaoInstitute.java
View file @
ebf42a71
...
...
@@ -33,6 +33,7 @@ import org.genesys2.server.lucene.genesys.FaoInstituteBridge;
import
org.genesys2.server.model.AclAwareModel
;
import
org.genesys2.server.model.BusinessModel
;
import
org.genesys2.server.model.EntityId
;
import
org.genesys2.server.servlet.controller.rest.serialization.FaoInstituteSerializer
;
import
org.hibernate.annotations.Index
;
import
org.hibernate.search.annotations.Boost
;
import
org.hibernate.search.annotations.ClassBridge
;
...
...
@@ -40,11 +41,14 @@ import org.hibernate.search.annotations.Field;
import
org.hibernate.search.annotations.Indexed
;
import
org.hibernate.search.annotations.Store
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
@Entity
@Table
(
name
=
"faoinstitute"
,
uniqueConstraints
=
@UniqueConstraint
(
columnNames
=
{
"code"
}))
@org
.
hibernate
.
annotations
.
Table
(
appliesTo
=
"faoinstitute"
,
indexes
=
{
@Index
(
columnNames
=
{
"code"
},
name
=
"code_FAOINSTITUTE"
)
})
@Indexed
@ClassBridge
(
name
=
"body"
,
boost
=
@Boost
(
1.3f
),
impl
=
FaoInstituteBridge
.
class
)
@JsonSerialize
(
using
=
FaoInstituteSerializer
.
class
)
public
class
FaoInstitute
extends
BusinessModel
implements
GeoReferencedEntity
,
AclAwareModel
,
EntityId
{
/**
...
...
src/main/java/org/genesys2/server/persistence/domain/FaoInstituteRepository.java
View file @
ebf42a71
...
...
@@ -51,5 +51,8 @@ public interface FaoInstituteRepository extends JpaRepository<FaoInstitute, Long
@Query
(
"from FaoInstitute fi where fi.pgrActivity=true"
)
Page
<
FaoInstitute
>
listInstitutes
(
Pageable
pageable
);
@Query
(
"from FaoInstitute fi where fi.id in ( ?1 )"
)
List
<
FaoInstitute
>
findByIds
(
List
<
Long
>
oids
,
Sort
sort
);
}
src/main/java/org/genesys2/server/service/InstituteService.java
View file @
ebf42a71
...
...
@@ -27,6 +27,7 @@ import org.genesys2.server.model.impl.Organization;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
/**
* @author mobreza
...
...
@@ -61,4 +62,6 @@ public interface InstituteService {
void
delete
(
String
instCode
);
List
<
FaoInstitute
>
listMyInstitutes
(
Sort
sort
);
}
src/main/java/org/genesys2/server/service/UserService.java
View file @
ebf42a71
...
...
@@ -80,4 +80,5 @@ public interface UserService {
void
addVettedUserRole
(
String
uuid
);
void
updateRoles
(
User
user
,
List
<
String
>
selectedRoles
);
}
src/main/java/org/genesys2/server/service/impl/BatchRESTServiceImpl.java
View file @
ebf42a71
...
...
@@ -160,6 +160,15 @@ public class BatchRESTServiceImpl implements BatchRESTService {
updated
=
true
;
}
}
value
=
accnJson
.
get
(
"inTrust"
);
if
(
value
!=
null
)
{
Boolean
inTrust
=
value
.
isNull
()
?
null
:
value
.
asBoolean
();
if
(!
areEqual
(
inTrust
,
accession
.
getInTrust
()))
{
accession
.
setInTrust
(
inTrust
);
updated
=
true
;
}
}
value
=
accnJson
.
get
(
"available"
);
if
(
value
!=
null
)
{
Boolean
availability
=
value
.
isNull
()
?
null
:
value
.
asBoolean
();
...
...
src/main/java/org/genesys2/server/service/impl/InstituteServiceImpl.java
View file @
ebf42a71
...
...
@@ -35,8 +35,11 @@ import org.genesys2.server.persistence.domain.FaoInstituteRepository;
import
org.genesys2.server.persistence.domain.FaoInstituteSettingRepository
;
import
org.genesys2.server.persistence.domain.GenesysLowlevelRepository
;
import
org.genesys2.server.persistence.domain.OrganizationRepository
;
import
org.genesys2.server.security.AuthUserDetails
;
import
org.genesys2.server.service.AclService
;
import
org.genesys2.server.service.ContentService
;
import
org.genesys2.server.service.InstituteService
;
import
org.genesys2.spring.SecurityContextUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
...
...
@@ -44,6 +47,7 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort.Direction
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.acls.domain.BasePermission
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -74,6 +78,10 @@ public class InstituteServiceImpl implements InstituteService {
@Autowired
private
OrganizationRepository
organizationRepository
;
@Autowired
private
AclService
aclService
;
@Override
public
Page
<
FaoInstitute
>
list
(
Pageable
pageable
)
{
return
instituteRepository
.
listInstitutes
(
pageable
);
...
...
@@ -189,4 +197,16 @@ public class InstituteServiceImpl implements InstituteService {
instituteRepository
.
delete
(
institute
);
}
}
@Override
@PreAuthorize
(
"isAuthenticated()"
)
public
List
<
FaoInstitute
>
listMyInstitutes
(
Sort
sort
)
{
AuthUserDetails
user
=
SecurityContextUtil
.
getAuthUser
();
List
<
Long
>
oids
=
aclService
.
listIdentitiesForSid
(
FaoInstitute
.
class
,
user
,
BasePermission
.
WRITE
);
LOG
.
info
(
"Got "
+
oids
.
size
()
+
" elements for "
+
user
.
getUsername
());
if
(
oids
.
size
()
==
0
)
return
null
;
return
instituteRepository
.
findByIds
(
oids
,
sort
);
}
}
src/main/java/org/genesys2/server/servlet/controller/rest/UserController.java
View file @
ebf42a71
...
...
@@ -29,9 +29,11 @@ import org.apache.commons.logging.LogFactory;
import
org.genesys2.server.ServiceEndpoints
;
import
org.genesys2.server.exception.AuthorizationException
;
import
org.genesys2.server.model.impl.User
;
import
org.genesys2.server.service.InstituteService
;
import
org.genesys2.server.service.TeamService
;
import
org.genesys2.server.service.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.http.MediaType
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -52,6 +54,9 @@ public class UserController extends RestController {
@Autowired
protected
TeamService
teamService
;
@Autowired
protected
InstituteService
instituteService
;
/**
* Returns logged in user's profile
...
...
@@ -64,6 +69,13 @@ public class UserController extends RestController {
User
user
=
userService
.
getMe
();
return
OAuth2Cleanup
.
clean
(
user
);
}
@RequestMapping
(
value
=
"/me/institutes"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
@ResponseBody
Object
listInstitutes
()
{
return
instituteService
.
listMyInstitutes
(
new
Sort
(
"code"
));
}
@RequestMapping
(
value
=
"/me/teams"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
@ResponseBody
...
...
src/main/java/org/genesys2/server/servlet/controller/rest/serialization/FaoInstituteSerializer.java
0 → 100644
View file @
ebf42a71
/**
* 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.servlet.controller.rest.serialization
;
import
java.io.IOException
;
import
org.genesys2.server.model.impl.FaoInstitute
;
import
com.fasterxml.jackson.core.JsonGenerator
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.JsonSerializer
;
import
com.fasterxml.jackson.databind.SerializerProvider
;
public
class
FaoInstituteSerializer
extends
JsonSerializer
<
FaoInstitute
>
{
@Override
public
void
serialize
(
FaoInstitute
institute
,
JsonGenerator
jgen
,
SerializerProvider
sp
)
throws
IOException
,
JsonProcessingException
{
if
(
institute
==
null
)
{
jgen
.
writeNull
();
}
else
{
jgen
.
writeStartObject
();
jgen
.
writeObjectField
(
"instCode"
,
institute
.
getCode
());
jgen
.
writeObjectField
(
"name"
,
institute
.
getFullName
());
jgen
.
writeEndObject
();
}
}
}
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