NameGroupServiceImpl.java
/*
* Copyright 2020 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 lombok.extern.slf4j.Slf4j;
import org.gringlobal.custom.elasticsearch.SearchException;
import org.gringlobal.model.NameGroup;
import org.gringlobal.persistence.NameGroupRepository;
import org.gringlobal.service.NameGroupService;
import org.gringlobal.service.filter.NameGroupFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @author Maxym Borodenko
*/
@Service
@Transactional(readOnly = true)
@Slf4j
public class NameGroupServiceImpl extends FilteredCRUDServiceImpl<NameGroup, NameGroupFilter, NameGroupRepository> implements NameGroupService {
@Override
@Transactional
public NameGroup create(NameGroup source) {
log.debug("Create NameGroup. Input data {}", source);
NameGroup nameGroup = new NameGroup();
nameGroup.apply(source);
NameGroup saved = repository.save(nameGroup);
saved.lazyLoad();
return saved;
}
@Override
@Transactional
public NameGroup update(NameGroup input, NameGroup target) {
log.debug("Update NameGroup. Input data {}", input);
target.apply(input);
NameGroup saved = repository.save(target);
saved.lazyLoad();
return saved;
}
@Override
public Page<NameGroup> list(NameGroupFilter filter, Pageable page) throws SearchException {
return super.list(NameGroup.class, filter, page);
}
}