MaintenancePolicyServiceImpl.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.InventoryMaintenancePolicy;
- import org.gringlobal.persistence.InventoryMaintenancePolicyRepository;
- import org.gringlobal.service.MaintenancePolicyService;
- import org.gringlobal.service.filter.InventoryMaintenancePolicyFilter;
- 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 MaintenancePolicyServiceImpl extends FilteredCRUDServiceImpl<InventoryMaintenancePolicy, InventoryMaintenancePolicyFilter, InventoryMaintenancePolicyRepository> implements MaintenancePolicyService {
- @Override
- @Transactional
- public InventoryMaintenancePolicy update(final InventoryMaintenancePolicy input, InventoryMaintenancePolicy target) {
- log.debug("Update maintenance policy. Input data {}", input);
- target.apply(input);
- InventoryMaintenancePolicy saved = repository.save(target);
- return _lazyLoad(saved);
- }
- @Override
- @Transactional
- public InventoryMaintenancePolicy create(final InventoryMaintenancePolicy source) {
- log.debug("Create maintenance policy. Input data {}", source);
- InventoryMaintenancePolicy maintenancePolicy = new InventoryMaintenancePolicy();
- maintenancePolicy.apply(source);
- InventoryMaintenancePolicy saved = repository.save(maintenancePolicy);
- saved.lazyLoad();
- return saved;
- }
- @Override
- public Page<InventoryMaintenancePolicy> list(InventoryMaintenancePolicyFilter filter, Pageable page) throws SearchException {
- return super.list(InventoryMaintenancePolicy.class, filter, page);
- }
- }