SourceDescObservationService.java
/*
* Copyright 2026 Global Crop Diversity Trust
* Licensed under the Apache License, Version 2.0
* See LICENSE file in project root folder or http://www.apache.org/licenses/LICENSE-2.0
*/
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;
}
}