PathogenGeographyMapServiceImpl.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 java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.gringlobal.api.MultiOp;
import org.gringlobal.model.community.PathogenGeographyMap;
import org.gringlobal.persistence.community.PathogenGeographyMapRepository;
import org.gringlobal.service.PathogenGeographyMapService;
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
@Validated
public class PathogenGeographyMapServiceImpl extends CRUDService2Impl<PathogenGeographyMap, PathogenGeographyMapRepository> implements PathogenGeographyMapService {

	@Override
	@Transactional
	@PreAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Pathogen', 'WRITE')")
	public PathogenGeographyMap create(PathogenGeographyMap source) {
		PathogenGeographyMap saved = new PathogenGeographyMap();
		saved.apply(source);
		return repository.save(saved);
	}

	@Override
	@Transactional
	@PreAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Pathogen', 'WRITE')")
	public PathogenGeographyMap createFast(PathogenGeographyMap source) {
		return super.createFast(source);
	}

	@Override
	@Transactional
	@PreAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Pathogen', 'WRITE')")
	public PathogenGeographyMap update(PathogenGeographyMap input, PathogenGeographyMap target) {
		target.apply(input);
		return _lazyLoad(repository.save(target));
	}

	@Override
	@Transactional
	@PreAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Pathogen', 'WRITE')")
	public PathogenGeographyMap updateFast(@NotNull @Valid PathogenGeographyMap updated, PathogenGeographyMap target) {
		target.apply(updated);
		return repository.save(target);
	}

	@Override
	@Transactional
	@PreAuthorize("hasAuthority('GROUP_ADMINS') or @ggceSec.actionAllowed('Pathogen', 'WRITE')")
	public PathogenGeographyMap remove(PathogenGeographyMap entity) {
		return super.remove(entity);
	}

}