CitationApiServiceImpl.java
/*
* Copyright 2024 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.genesys.server.api.v2.facade.impl;
import java.util.List;
import java.util.UUID;
import org.genesys.server.api.v2.EntityUuidAndVersion;
import org.genesys.server.api.v2.facade.CitationApiService;
import org.genesys.server.api.v2.model.bib.CitationDTO;
import org.genesys.server.exception.SearchException;
import org.genesys.server.model.Partner;
import org.genesys.server.model.bib.Citation;
import org.genesys.server.model.filters.CitationFilter;
import org.genesys.server.service.CitationService;
import org.genesys.server.service.worker.dupe.CitationDuplicateFinder;
import org.genesys.server.service.worker.dupe.DuplicateFinder.Hit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@Service
@Validated
public class CitationApiServiceImpl extends APIFilteredServiceFacadeImpl<CitationService, CitationDTO, Citation, CitationFilter> implements CitationApiService {
@Autowired
private CitationDuplicateFinder citationDuplicateFinder;
@Override
protected Citation convert(CitationDTO source) {
return mapper.map(source);
}
@Override
protected CitationDTO convert(Citation source) {
return mapper.map(source);
}
@Override
public CitationDTO get(UUID uuid) {
return convert(service.get(uuid));
}
@Override
public Page<CitationDTO> listMyCitations(CitationFilter filter, Pageable pageRequest) throws SearchException {
return service.listMyCitations(filter, pageRequest).map(mapper::map);
}
@Override
public List<Hit<CitationDTO>> findSimilar(CitationDTO citation, CitationFilter filter) {
return mapper.map(citationDuplicateFinder.findSimilar(convert(citation), filter), x -> x.map(this::convert));
}
@Override
public Citation approveCitation(EntityUuidAndVersion ref) {
return service.approveCitation(service.get(ref));
}
@Override
public Citation rejectCitation(EntityUuidAndVersion ref) {
return service.rejectCitation(service.get(ref));
}
@Override
public Citation reviewCitation(EntityUuidAndVersion ref) {
return service.reviewCitation(service.get(ref));
}
@Override
public List<String> getCollections(Partner owner) {
return service.getCollections(owner);
}
@Override
public List<String> getCollections(CitationFilter filter) {
return service.getCollections(filter);
}
}