2016-08-26 10 views
0

Spring Data RESTを使用して、JavaモデルのRDF/XMLおよびJSON-LD表現を提供するにはどうすればよいですか@RepositoryRestResourceを使用しますか?SpringデータレストでのJavaモデルのRDF/XMLおよびJSON-LD表現の提供?

私はコンテントネゴシエーションについて読むだけ@Controllerアノテーションで例を発見し、これが私のコードである@RepositoryRestResource

使用したとき、私は説明を必要としました。

マイエンティティclasss

package ec.edu.utpl.gestiondatos.tesis.entities; 

import java.io.Serializable; 
import java.math.BigDecimal; 
import java.math.BigInteger; 
import java.util.Date; 
import javax.persistence.Basic; 
import javax.persistence.Column; 
import javax.persistence.Entity; 
import javax.persistence.Id; 
import javax.persistence.Lob; 
import javax.persistence.NamedQueries; 
import javax.persistence.NamedQuery; 
import javax.persistence.Table; 
import javax.persistence.Temporal; 
import javax.persistence.TemporalType; 
import javax.validation.constraints.NotNull; 
import javax.validation.constraints.Size; 
import javax.xml.bind.annotation.XmlRootElement; 

/** 
* 
* @author Efren 
*/ 
@Entity 
@Table(name = "TDI_DOCENTE") 
@XmlRootElement 
@NamedQueries({ 
    @NamedQuery(name = "TdiDocente.findAll", query = "SELECT t FROM TdiDocente t")}) 
public class TdiDocente implements Serializable { 

    private static final long serialVersionUID = -8846422129143878578L; 
    // @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation 
    @Id 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "DO_ID") 
    private BigDecimal doId; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 13) 
    @Column(name = "DO_IDENTIFICACION") 
    private String doIdentificacion; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 100) 
    @Column(name = "DO_APELLIDO_PATERNO") 
    private String doApellidoPaterno; 
    @Size(max = 100) 
    @Column(name = "DO_APELLIDO_MATERNO") 
    private String doApellidoMaterno; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 100) 
    @Column(name = "DO_PRIMER_NOMBRE") 
    private String doPrimerNombre; 
    @Size(max = 100) 
    @Column(name = "DO_SEGUNDO_NOMBRE") 
    private String doSegundoNombre; 
    @Column(name = "DO_FECHA_NACIMIENTO") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFechaNacimiento; 
    @Column(name = "DO_EQU_ID_NSGA") 
    private BigInteger doEquIdNsga; 
    @Column(name = "DO_EQU_ID_SGA") 
    private BigInteger doEquIdSga; 
    @Column(name = "DO_EQU_ID_SICA") 
    private BigInteger doEquIdSica; 
    @Column(name = "DO_EQU_ID_EVA") 
    private BigInteger doEquIdEva; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 2) 
    @Column(name = "DO_GENERO") 
    private String doGenero; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "DO_FECHA_CREACION") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFechaCreacion; 
    @Column(name = "DO_FECHA_ACTUALIZACION") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFechaActualizacion; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 1) 
    @Column(name = "DO_ACTIVO") 
    private String doActivo; 
    @Size(max = 120) 
    @Column(name = "DO_CORREO_PRI") 
    private String doCorreoPri; 
    @Size(max = 120) 
    @Column(name = "DO_CORREO_SEC") 
    private String doCorreoSec; 
    @Size(max = 30) 
    @Column(name = "DO_TELEFONO_DOM") 
    private String doTelefonoDom; 
    @Size(max = 30) 
    @Column(name = "DO_CELULAR_PRI") 
    private String doCelularPri; 
    @Size(max = 30) 
    @Column(name = "DO_CELULAR_SEC") 
    private String doCelularSec; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 1) 
    @Column(name = "DO_PROMETEO") 
    private String doPrometeo; 
    @Column(name = "DO_EQU_ID_CITTES") 
    private BigInteger doEquIdCittes; 
    @Column(name = "DO_EQU_ID_NSGA2") 
    private BigInteger doEquIdNsga2; 
    @Size(max = 15) 
    @Column(name = "DO_IDENTIFICACION_RRHH") 
    private String doIdentificacionRrhh; 
    @Size(max = 1) 
    @Column(name = "DO_VALIDADO_RRHH") 
    private String doValidadoRrhh; 
    @Size(max = 20) 
    @Column(name = "DO_EXTENSION") 
    private String doExtension; 
    @Column(name = "DO_TECNICO_DOCENTE") 
    private Character doTecnicoDocente; 
    @Column(name = "DO_FECHA_INGRESO") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFechaIngreso; 
    @Column(name = "DO_FECHA_SALIDA") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFechaSalida; 
    @Size(max = 50) 
    @Column(name = "USUARIO_APEX_CREA") 
    private String usuarioApexCrea; 
    @Size(max = 50) 
    @Column(name = "USUARIO_APEX_ACTUALIZA") 
    private String usuarioApexActualiza; 
    @Size(max = 80) 
    @Column(name = "DO_CORREO_PERSONAL") 
    private String doCorreoPersonal; 
    @Size(max = 1) 
    @Column(name = "DO_ES_ADMINISTRATIVO") 
    private String doEsAdministrativo; 
    @Column(name = "DO_ID_TIPO_SANGRE") 
    private BigInteger doIdTipoSangre; 
    @Column(name = "DO_EQU_ID_RR_HH") 
    private BigInteger doEquIdRrHh; 
    @Size(max = 25) 
    @Column(name = "DO_IDENTIFICACION_NOMINA") 
    private String doIdentificacionNomina; 
    @Size(max = 1) 
    @Column(name = "DO_REPETIDO_NSGA") 
    private String doRepetidoNsga; 
    @Size(max = 100) 
    @Column(name = "DO_OBSERVACIONES_REPETIDO") 
    private String doObservacionesRepetido; 
    @Column(name = "DO_EQUI_ID_NOMINA") 
    private BigInteger doEquiIdNomina; 
    @Column(name = "DO_EQUI_ID_REGISTRO") 
    private BigInteger doEquiIdRegistro; 
    @Column(name = "DO_CANTON_NACIMIENTO") 
    private BigInteger doCantonNacimiento; 
    @Column(name = "DO_PROVINCIA_NACIMIENTO") 
    private BigInteger doProvinciaNacimiento; 
    @Column(name = "DO_TIPO_DISCAPACIDAD") 
    private BigInteger doTipoDiscapacidad; 
    @Column(name = "DO_PORCENTAJE_DISCAPACIDAD") 
    private BigInteger doPorcentajeDiscapacidad; 
    @Size(max = 25) 
    @Column(name = "DO_NUMERO_CARNET_CONADIS") 
    private String doNumeroCarnetConadis; 
    @Size(max = 250) 
    @Column(name = "DO_OBSERVACION") 
    private String doObservacion; 
    @Size(max = 15) 
    @Column(name = "DO_IDENTIFICACION_NSGA") 
    private String doIdentificacionNsga; 
    @Lob 
    @Column(name = "DO_FOTO") 
    private Serializable doFoto; 
    @Size(max = 255) 
    @Column(name = "DO_FOTO_MIMETYPE") 
    private String doFotoMimetype; 
    @Size(max = 255) 
    @Column(name = "DO_FOTO_FILENAME") 
    private String doFotoFilename; 
    @Column(name = "DO_FOTO_LAST_UPDATE") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFotoLastUpdate; 
    @Column(name = "DO_EQU_ID_NSGA3") 
    private BigInteger doEquIdNsga3; 
    @Column(name = "DO_FECHA_INICIO_ADENDA") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFechaInicioAdenda; 
    @Column(name = "DO_FECHA_FIN_ADENDA") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFechaFinAdenda; 
    @Column(name = "DO_FECHA_VALIDACION_RRHH") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date doFechaValidacionRrhh; 

    public TdiDocente() { 
    } 

    public TdiDocente(BigDecimal doId) { 
     this.doId = doId; 
    } 

    public TdiDocente(BigDecimal doId, String doIdentificacion, String doApellidoPaterno, String doPrimerNombre, String doGenero, Date doFechaCreacion, String doActivo, String doPrometeo) { 
     this.doId = doId; 
     this.doIdentificacion = doIdentificacion; 
     this.doApellidoPaterno = doApellidoPaterno; 
     this.doPrimerNombre = doPrimerNombre; 
     this.doGenero = doGenero; 
     this.doFechaCreacion = doFechaCreacion; 
     this.doActivo = doActivo; 
     this.doPrometeo = doPrometeo; 
    } 

    public BigDecimal getDoId() { 
     return doId; 
    } 

    public void setDoId(BigDecimal doId) { 
     this.doId = doId; 
    } 

    public String getDoIdentificacion() { 
     return doIdentificacion; 
    } 

    public void setDoIdentificacion(String doIdentificacion) { 
     this.doIdentificacion = doIdentificacion; 
    } 

    public String getDoApellidoPaterno() { 
     return doApellidoPaterno; 
    } 

    public void setDoApellidoPaterno(String doApellidoPaterno) { 
     this.doApellidoPaterno = doApellidoPaterno; 
    } 

    public String getDoApellidoMaterno() { 
     return doApellidoMaterno; 
    } 

    public void setDoApellidoMaterno(String doApellidoMaterno) { 
     this.doApellidoMaterno = doApellidoMaterno; 
    } 

    public String getDoPrimerNombre() { 
     return doPrimerNombre; 
    } 

    public void setDoPrimerNombre(String doPrimerNombre) { 
     this.doPrimerNombre = doPrimerNombre; 
    } 

    public String getDoSegundoNombre() { 
     return doSegundoNombre; 
    } 

    public void setDoSegundoNombre(String doSegundoNombre) { 
     this.doSegundoNombre = doSegundoNombre; 
    } 

    public Date getDoFechaNacimiento() { 
     return doFechaNacimiento; 
    } 

    public void setDoFechaNacimiento(Date doFechaNacimiento) { 
     this.doFechaNacimiento = doFechaNacimiento; 
    } 

    public BigInteger getDoEquIdNsga() { 
     return doEquIdNsga; 
    } 

    public void setDoEquIdNsga(BigInteger doEquIdNsga) { 
     this.doEquIdNsga = doEquIdNsga; 
    } 

    public BigInteger getDoEquIdSga() { 
     return doEquIdSga; 
    } 

    public void setDoEquIdSga(BigInteger doEquIdSga) { 
     this.doEquIdSga = doEquIdSga; 
    } 

    public BigInteger getDoEquIdSica() { 
     return doEquIdSica; 
    } 

    public void setDoEquIdSica(BigInteger doEquIdSica) { 
     this.doEquIdSica = doEquIdSica; 
    } 

    public BigInteger getDoEquIdEva() { 
     return doEquIdEva; 
    } 

    public void setDoEquIdEva(BigInteger doEquIdEva) { 
     this.doEquIdEva = doEquIdEva; 
    } 

    public String getDoGenero() { 
     return doGenero; 
    } 

    public void setDoGenero(String doGenero) { 
     this.doGenero = doGenero; 
    } 

    public Date getDoFechaCreacion() { 
     return doFechaCreacion; 
    } 

    public void setDoFechaCreacion(Date doFechaCreacion) { 
     this.doFechaCreacion = doFechaCreacion; 
    } 

    public Date getDoFechaActualizacion() { 
     return doFechaActualizacion; 
    } 

    public void setDoFechaActualizacion(Date doFechaActualizacion) { 
     this.doFechaActualizacion = doFechaActualizacion; 
    } 

    public String getDoActivo() { 
     return doActivo; 
    } 

    public void setDoActivo(String doActivo) { 
     this.doActivo = doActivo; 
    } 

    public String getDoCorreoPri() { 
     return doCorreoPri; 
    } 

    public void setDoCorreoPri(String doCorreoPri) { 
     this.doCorreoPri = doCorreoPri; 
    } 

    public String getDoCorreoSec() { 
     return doCorreoSec; 
    } 

    public void setDoCorreoSec(String doCorreoSec) { 
     this.doCorreoSec = doCorreoSec; 
    } 

    public String getDoTelefonoDom() { 
     return doTelefonoDom; 
    } 

    public void setDoTelefonoDom(String doTelefonoDom) { 
     this.doTelefonoDom = doTelefonoDom; 
    } 

    public String getDoCelularPri() { 
     return doCelularPri; 
    } 

    public void setDoCelularPri(String doCelularPri) { 
     this.doCelularPri = doCelularPri; 
    } 

    public String getDoCelularSec() { 
     return doCelularSec; 
    } 

    public void setDoCelularSec(String doCelularSec) { 
     this.doCelularSec = doCelularSec; 
    } 

    public String getDoPrometeo() { 
     return doPrometeo; 
    } 

    public void setDoPrometeo(String doPrometeo) { 
     this.doPrometeo = doPrometeo; 
    } 

    public BigInteger getDoEquIdCittes() { 
     return doEquIdCittes; 
    } 

    public void setDoEquIdCittes(BigInteger doEquIdCittes) { 
     this.doEquIdCittes = doEquIdCittes; 
    } 

    public BigInteger getDoEquIdNsga2() { 
     return doEquIdNsga2; 
    } 

    public void setDoEquIdNsga2(BigInteger doEquIdNsga2) { 
     this.doEquIdNsga2 = doEquIdNsga2; 
    } 

    public String getDoIdentificacionRrhh() { 
     return doIdentificacionRrhh; 
    } 

    public void setDoIdentificacionRrhh(String doIdentificacionRrhh) { 
     this.doIdentificacionRrhh = doIdentificacionRrhh; 
    } 

    public String getDoValidadoRrhh() { 
     return doValidadoRrhh; 
    } 

    public void setDoValidadoRrhh(String doValidadoRrhh) { 
     this.doValidadoRrhh = doValidadoRrhh; 
    } 

    public String getDoExtension() { 
     return doExtension; 
    } 

    public void setDoExtension(String doExtension) { 
     this.doExtension = doExtension; 
    } 

    public Character getDoTecnicoDocente() { 
     return doTecnicoDocente; 
    } 

    public void setDoTecnicoDocente(Character doTecnicoDocente) { 
     this.doTecnicoDocente = doTecnicoDocente; 
    } 

    public Date getDoFechaIngreso() { 
     return doFechaIngreso; 
    } 

    public void setDoFechaIngreso(Date doFechaIngreso) { 
     this.doFechaIngreso = doFechaIngreso; 
    } 

    public Date getDoFechaSalida() { 
     return doFechaSalida; 
    } 

    public void setDoFechaSalida(Date doFechaSalida) { 
     this.doFechaSalida = doFechaSalida; 
    } 

    public String getUsuarioApexCrea() { 
     return usuarioApexCrea; 
    } 

    public void setUsuarioApexCrea(String usuarioApexCrea) { 
     this.usuarioApexCrea = usuarioApexCrea; 
    } 

    public String getUsuarioApexActualiza() { 
     return usuarioApexActualiza; 
    } 

    public void setUsuarioApexActualiza(String usuarioApexActualiza) { 
     this.usuarioApexActualiza = usuarioApexActualiza; 
    } 

    public String getDoCorreoPersonal() { 
     return doCorreoPersonal; 
    } 

    public void setDoCorreoPersonal(String doCorreoPersonal) { 
     this.doCorreoPersonal = doCorreoPersonal; 
    } 

    public String getDoEsAdministrativo() { 
     return doEsAdministrativo; 
    } 

    public void setDoEsAdministrativo(String doEsAdministrativo) { 
     this.doEsAdministrativo = doEsAdministrativo; 
    } 

    public BigInteger getDoIdTipoSangre() { 
     return doIdTipoSangre; 
    } 

    public void setDoIdTipoSangre(BigInteger doIdTipoSangre) { 
     this.doIdTipoSangre = doIdTipoSangre; 
    } 

    public BigInteger getDoEquIdRrHh() { 
     return doEquIdRrHh; 
    } 

    public void setDoEquIdRrHh(BigInteger doEquIdRrHh) { 
     this.doEquIdRrHh = doEquIdRrHh; 
    } 

    public String getDoIdentificacionNomina() { 
     return doIdentificacionNomina; 
    } 

    public void setDoIdentificacionNomina(String doIdentificacionNomina) { 
     this.doIdentificacionNomina = doIdentificacionNomina; 
    } 

    public String getDoRepetidoNsga() { 
     return doRepetidoNsga; 
    } 

    public void setDoRepetidoNsga(String doRepetidoNsga) { 
     this.doRepetidoNsga = doRepetidoNsga; 
    } 

    public String getDoObservacionesRepetido() { 
     return doObservacionesRepetido; 
    } 

    public void setDoObservacionesRepetido(String doObservacionesRepetido) { 
     this.doObservacionesRepetido = doObservacionesRepetido; 
    } 

    public BigInteger getDoEquiIdNomina() { 
     return doEquiIdNomina; 
    } 

    public void setDoEquiIdNomina(BigInteger doEquiIdNomina) { 
     this.doEquiIdNomina = doEquiIdNomina; 
    } 

    public BigInteger getDoEquiIdRegistro() { 
     return doEquiIdRegistro; 
    } 

    public void setDoEquiIdRegistro(BigInteger doEquiIdRegistro) { 
     this.doEquiIdRegistro = doEquiIdRegistro; 
    } 

    public BigInteger getDoCantonNacimiento() { 
     return doCantonNacimiento; 
    } 

    public void setDoCantonNacimiento(BigInteger doCantonNacimiento) { 
     this.doCantonNacimiento = doCantonNacimiento; 
    } 

    public BigInteger getDoProvinciaNacimiento() { 
     return doProvinciaNacimiento; 
    } 

    public void setDoProvinciaNacimiento(BigInteger doProvinciaNacimiento) { 
     this.doProvinciaNacimiento = doProvinciaNacimiento; 
    } 

    public BigInteger getDoTipoDiscapacidad() { 
     return doTipoDiscapacidad; 
    } 

    public void setDoTipoDiscapacidad(BigInteger doTipoDiscapacidad) { 
     this.doTipoDiscapacidad = doTipoDiscapacidad; 
    } 

    public BigInteger getDoPorcentajeDiscapacidad() { 
     return doPorcentajeDiscapacidad; 
    } 

    public void setDoPorcentajeDiscapacidad(BigInteger doPorcentajeDiscapacidad) { 
     this.doPorcentajeDiscapacidad = doPorcentajeDiscapacidad; 
    } 

    public String getDoNumeroCarnetConadis() { 
     return doNumeroCarnetConadis; 
    } 

    public void setDoNumeroCarnetConadis(String doNumeroCarnetConadis) { 
     this.doNumeroCarnetConadis = doNumeroCarnetConadis; 
    } 

    public String getDoObservacion() { 
     return doObservacion; 
    } 

    public void setDoObservacion(String doObservacion) { 
     this.doObservacion = doObservacion; 
    } 

    public String getDoIdentificacionNsga() { 
     return doIdentificacionNsga; 
    } 

    public void setDoIdentificacionNsga(String doIdentificacionNsga) { 
     this.doIdentificacionNsga = doIdentificacionNsga; 
    } 

    public Serializable getDoFoto() { 
     return doFoto; 
    } 

    public void setDoFoto(Serializable doFoto) { 
     this.doFoto = doFoto; 
    } 

    public String getDoFotoMimetype() { 
     return doFotoMimetype; 
    } 

    public void setDoFotoMimetype(String doFotoMimetype) { 
     this.doFotoMimetype = doFotoMimetype; 
    } 

    public String getDoFotoFilename() { 
     return doFotoFilename; 
    } 

    public void setDoFotoFilename(String doFotoFilename) { 
     this.doFotoFilename = doFotoFilename; 
    } 

    public Date getDoFotoLastUpdate() { 
     return doFotoLastUpdate; 
    } 

    public void setDoFotoLastUpdate(Date doFotoLastUpdate) { 
     this.doFotoLastUpdate = doFotoLastUpdate; 
    } 

    public BigInteger getDoEquIdNsga3() { 
     return doEquIdNsga3; 
    } 

    public void setDoEquIdNsga3(BigInteger doEquIdNsga3) { 
     this.doEquIdNsga3 = doEquIdNsga3; 
    } 

    public Date getDoFechaInicioAdenda() { 
     return doFechaInicioAdenda; 
    } 

    public void setDoFechaInicioAdenda(Date doFechaInicioAdenda) { 
     this.doFechaInicioAdenda = doFechaInicioAdenda; 
    } 

    public Date getDoFechaFinAdenda() { 
     return doFechaFinAdenda; 
    } 

    public void setDoFechaFinAdenda(Date doFechaFinAdenda) { 
     this.doFechaFinAdenda = doFechaFinAdenda; 
    } 

    public Date getDoFechaValidacionRrhh() { 
     return doFechaValidacionRrhh; 
    } 

    public void setDoFechaValidacionRrhh(Date doFechaValidacionRrhh) { 
     this.doFechaValidacionRrhh = doFechaValidacionRrhh; 
    } 

    @Override 
    public int hashCode() { 
     int hash = 0; 
     hash += (doId != null ? doId.hashCode() : 0); 
     return hash; 
    } 

    @Override 
    public boolean equals(Object object) { 
     // TODO: Warning - this method won't work in the case the id fields are not set 
     if (!(object instanceof TdiDocente)) { 
      return false; 
     } 
     TdiDocente other = (TdiDocente) object; 
     if ((this.doId == null && other.doId != null) || (this.doId != null && !this.doId.equals(other.doId))) { 
      return false; 
     } 
     return true; 
    } 

    @Override 
    public String toString() { 
     return "ec.edu.utpl.gestiondatos.tesis.entities.TdiDocente[ doId=" + doId + " ]"; 
    } 

} 

そして、これはあなたがその後、ごまのRIOフレームワークを使用することができ、RDFにあなたの持続豆をオンにするPintoを使用することができ

package ec.edu.utpl.gestiondatos.tesis.repositories; 

import java.util.List; 

import ec.edu.utpl.gestiondatos.tesis.entities.TdiDocente; 
import org.springframework.data.repository.CrudRepository; 
import org.springframework.data.repository.query.Param; 
import org.springframework.data.rest.core.annotation.RepositoryRestResource; 

@RepositoryRestResource 
public interface TdiDocenteRepository extends CrudRepository<TdiDocente, Long> { 

    List<TdiDocente> findBydoIdentificacion(@Param("doIdentificacion") String doIdentificacion); 
} 
+0

の作者です(JSON-LDは、RDFのシリアライゼーションであることに注意してください。)あなたはRDF/XMLを意味していますか? – unor

+0

はい、私は次のようにシリアル化します:produce = {"application/xml"、 "application/rdf + xml"、 "application/ld + json"}そしてWebサービスのURLでは、 :?format = jsonまたはformat = rdf。 –

答えて

1

私のリポジトリでありますJSON-LDを含む任意のRDFシリアライゼーションとして書くことができます。

免責事項:私はピント

+0

、次にSpring Data Rest Frameworkとどのように統合できますか? –

+0

ジャンパーを使用してBeanをJSONにシリアル化するのとまったく同じ方法です。 – Michael

関連する問題