LocationReservationServiceImpl.java
/*
* Copyright 2022 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.gringlobal.service.impl;
import org.gringlobal.model.community.LocationReservation;
import org.gringlobal.persistence.community.LocationReservationRepository;
import org.gringlobal.service.LocationReservationService;
import org.gringlobal.service.filter.LocationReservationFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@Service
@Transactional(readOnly = true)
@Validated
public class LocationReservationServiceImpl extends FilteredCRUDService2Impl<LocationReservation, LocationReservationFilter, LocationReservationRepository>
implements LocationReservationService {
public static final Logger LOG = LoggerFactory.getLogger(LocationReservationServiceImpl.class);
@Override
@Transactional
@PostAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Location', 'WRITE', returnObject.location.site)")
public LocationReservation create(LocationReservation source) {
LocationReservation saved = new LocationReservation();
saved.apply(source);
return repository.save(source);
}
@Override
@Transactional
@PostAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Location', 'WRITE', returnObject.location.site)")
public LocationReservation createFast(LocationReservation source) {
return super.createFast(source);
}
@Override
@Transactional
@PostAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Location', 'WRITE', returnObject.location.site)")
public LocationReservation update(LocationReservation input, LocationReservation target) {
return _lazyLoad(updateFast(input, target));
}
@Override
@Transactional
@PostAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Location', 'WRITE', returnObject.location.site)")
public LocationReservation updateFast(LocationReservation updated, LocationReservation target) {
target.apply(updated);
return repository.save(target);
}
@Override
@Transactional
@PreAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Location', 'WRITE', #entity.site)")
public LocationReservation remove(LocationReservation entity) {
return super.remove(entity);
}
}