SourceDescObservationService.java
/*
* Copyright 2021 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;
import java.io.Serializable;
import org.gringlobal.custom.elasticsearch.SearchException;
import org.gringlobal.model.SourceDescObservation;
import org.gringlobal.service.SourceDescriptorCodeTranslationService.TranslatedSourceDescriptorCode;
import org.gringlobal.service.SourceDescriptorTranslationService.TranslatedSourceDescriptor;
import org.gringlobal.service.filter.SourceDescObservationFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
/**
* The Interface SourceDescObservationService.
*/
public interface SourceDescObservationService extends FilteredCRUDService2<SourceDescObservation, SourceDescObservationFilter> {
TranslatedSourceDescObservation getTranslated(long id);
@Transactional(readOnly = true)
Page<TranslatedSourceDescObservation> listTranslated(SourceDescObservationFilter filter, Pageable page) throws SearchException;
@JsonIdentityInfo(scope = TranslatedSourceDescObservation.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public static class TranslatedSourceDescObservation implements Serializable {
private static final long serialVersionUID = -7141159760583224986L;
/**
* Primarily here for JSON serialization and @JsonIdentityInfo annotation.
*
* @return original entity ID
*/
@JsonProperty("id")
public Long getId() {
return observation.getId();
}
@JsonUnwrapped
@JsonIgnoreProperties({ "sourceDescriptor", "sourceDescriptorCode" })
public SourceDescObservation observation;
@JsonProperty("sourceDescriptor") // rename
public TranslatedSourceDescriptor translatedSourceDescriptor;
@JsonProperty("sourceDescriptorCode") // rename
public TranslatedSourceDescriptorCode translatedSourceDescriptorCode;
}
}