Search in sources :

Example 6 with Organization

use of com.odysseusinc.arachne.portal.model.Organization in project ArachneCentralAPI by OHDSI.

the class OrganizationServiceImpl method update.

@Override
@Transactional
@PreAuthorize("hasPermission(#organization, 'Organization', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).UPDATE_ORGANIZATION)")
@PostAuthorize("@ArachnePermissionEvaluator.addPermissions(principal, returnObject )")
public Organization update(Organization organization) {
    final Organization exist = getByName(organization.getName());
    final String name = organization.getName();
    if (Objects.nonNull(name)) {
        exist.setName(name);
    }
    final Organization saved = organizationRepository.save(exist);
    logger.info("{} updated", saved);
    return saved;
}
Also used : Organization(com.odysseusinc.arachne.portal.model.Organization) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Organization

use of com.odysseusinc.arachne.portal.model.Organization in project ArachneCentralAPI by OHDSI.

the class OrganizationServiceImpl method create.

@Override
@Transactional
@PreAuthorize("hasPermission(#organization, T(com.odysseusinc.arachne.portal.security.ArachnePermission).CREATE_ORGANIZATION)")
public Organization create(Organization organization) throws ValidationException {
    final String name = organization.getName();
    if (StringUtils.isEmpty(name)) {
        throw new ValidationException("Organization must have name");
    }
    organization.setId(null);
    final Organization saved = organizationRepository.save(organization);
    logger.info("{} created", saved);
    return saved;
}
Also used : ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) Organization(com.odysseusinc.arachne.portal.model.Organization) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Organization (com.odysseusinc.arachne.portal.model.Organization)7 ApiOperation (io.swagger.annotations.ApiOperation)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Transactional (org.springframework.transaction.annotation.Transactional)2 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)1 PostAuthorize (org.springframework.security.access.prepost.PostAuthorize)1