Skip to content

Commit

Permalink
#426 - API REST
Browse files Browse the repository at this point in the history
- Creación del servicio de Usuarios
  • Loading branch information
slromero-indra committed May 9, 2018
1 parent af9081d commit eb0a7e0
Show file tree
Hide file tree
Showing 6 changed files with 566 additions and 14 deletions.
211 changes: 211 additions & 0 deletions moduls/apirest/src/es/caib/rolsac/apirest/v1/model/Usuaris.java
@@ -0,0 +1,211 @@
package es.caib.rolsac.apirest.v1.model;

import java.io.IOException;

import javax.xml.bind.annotation.XmlRootElement;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import es.caib.rolsac.apirest.v1.utiles.Constantes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
* Usuarios: se define la estructura de la entidad 'Usuarios'
*
* @author Indra
*
* Listado de Funciones de la entidad 'Usuarios':
*/
@XmlRootElement
@ApiModel(value = Constantes.ENTIDAD_USUARIOS, description = Constantes.TXT_DEFINICION_CLASE
+ Constantes.ENTIDAD_USUARIOS)
public class Usuaris extends EntidadBase {

/** email **/
@ApiModelProperty(value = "email", required = false)
private long email;

/** codigo **/
@ApiModelProperty(value = "codigo", required = false)
private long codigo;

/** Codigo nombre. **/
@ApiModelProperty(value = "nombre", required = false)
private String nombre;

/** observaciones. **/
@ApiModelProperty(value = "observaciones", required = false)
private String observaciones;

/** idioma **/
@ApiModelProperty(value = "password", required = false)
private String password;

/** nombre. **/
@ApiModelProperty(value = "perfil", required = false)
private String perfil;

/** palabrasclave. **/
@ApiModelProperty(value = "username", required = false)
private String username;

// -- LINKS--//
// (Esta entidad no hace referencia a otras entidades)

public Usuaris(org.ibit.rol.sac.model.Usuario elem, String urlBase,
String idioma, boolean hateoasEnabled) {
super(elem, urlBase, idioma, hateoasEnabled);
}

public Usuaris() {
super();
}

@Override
public void generaLinks(String urlBase) {

}

public static Usuaris valueOf(final String json) {
final ObjectMapper objectMapper = new ObjectMapper();
final TypeReference<Usuaris> typeRef = new TypeReference<Usuaris>() {
};
Usuaris obj;
try {
obj = (Usuaris) objectMapper.readValue(json, typeRef);
} catch (final IOException e) {
// TODO PENDIENTE
throw new RuntimeException(e);
}
return obj;
}

public String toJson() {
try {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, false);
return objectMapper.writeValueAsString(this);
} catch (final JsonProcessingException e) {
// TODO PENDIENTE
throw new RuntimeException(e);
}
}

/**
* @return the email
*/
public long getEmail() {
return email;
}

/**
* @param email the email to set
*/
public void setEmail(long email) {
this.email = email;
}

@Override
public void setId(Long codigo) {
this.codigo = codigo;
}

/**
* @return the codigo
*/
public long getCodigo() {
return codigo;
}

/**
* @param codigo the codigo to set
*/
public void setCodigo(long codigo) {
this.codigo = codigo;
}

/**
* @return the nombre
*/
public String getNombre() {
return nombre;
}

/**
* @param nombre the nombre to set
*/
public void setNombre(String nombre) {
this.nombre = nombre;
}

/**
* @return the observaciones
*/
public String getObservaciones() {
return observaciones;
}

/**
* @param observaciones the observaciones to set
*/
public void setObservaciones(String observaciones) {
this.observaciones = observaciones;
}

/**
* @return the password
*/
public String getPassword() {
return password;
}

/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}

/**
* @return the perfil
*/
public String getPerfil() {
return perfil;
}

/**
* @param perfil the perfil to set
*/
public void setPerfil(String perfil) {
this.perfil = perfil;
}

/**
* @return the username
*/
public String getUsername() {
return username;
}

/**
* @param username the username to set
*/
public void setUsername(String username) {
this.username = username;
}

@Override
protected void addSetersInvalidos() {
// TODO Auto-generated method stub

}





}
@@ -0,0 +1,90 @@
package es.caib.rolsac.apirest.v1.model.filtros;

import java.io.IOException;

import javax.xml.bind.annotation.XmlRootElement;

import org.ibit.rol.sac.model.filtro.FiltroGenerico;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import es.caib.rolsac.apirest.v1.utiles.Constantes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
* FiltroUsuarios.
*
* @author Indra
*
* Filtro (donde se definen los filtros a usar):
*/
@XmlRootElement
@ApiModel(value = "Filtro Usuarios", description = "Filtro propio de la entidad " + Constantes.ENTIDAD_USUARIOS)
public class FiltroUsuarios {

public static final String SAMPLE = "{\"codigoUA\":\"0\"}";


/** codigoAgrupacioFetVital. **/
@ApiModelProperty(value = "Código UA", required = false)
private Integer codigoUA;


public static FiltroUsuarios valueOf(final String json) {
final ObjectMapper objectMapper = new ObjectMapper();
final TypeReference<FiltroUsuarios> typeRef = new TypeReference<FiltroUsuarios>() {
};
FiltroUsuarios obj;
try {
obj = (FiltroUsuarios) objectMapper.readValue(json, typeRef);
} catch (final IOException e) {
// TODO PENDIENTE
throw new RuntimeException(e);
}
return obj;
}


public FiltroGenerico toFiltroGenerico() {
FiltroGenerico fg = new FiltroGenerico();
if(this.codigoUA!= null) {
fg.addFiltro(FiltroGenerico.FILTRO_USUARIOS_UA, this.codigoUA+"");
}

return fg;
}


public String toJson() {
try {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, false);
return objectMapper.writeValueAsString(this);
} catch (final JsonProcessingException e) {
// TODO PENDIENTE
throw new RuntimeException(e);
}
}


/**
* @return the codigoUA
*/
public Integer getCodigoUA() {
return codigoUA;
}


/**
* @param codigoUA the codigoUA to set
*/
public void setCodigoUA(Integer codigoUA) {
this.codigoUA = codigoUA;
}


}
@@ -0,0 +1,41 @@
package es.caib.rolsac.apirest.v1.model.respuestas;

import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

import es.caib.rolsac.apirest.v1.model.Usuaris;
import es.caib.rolsac.apirest.v1.utiles.Constantes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
* RespuestaUsuarios
*
* @author Indra
*
*Respuesta, (respuesta de la entidad, tiene una parte común y un listado de elementos de entidad):
*
*/

@XmlRootElement
@ApiModel(value = Constantes.TXT_RESPUESTA + Constantes.ENTIDAD_USUARIOS, description = Constantes.TXT_RESPUESTA + Constantes.ENTIDAD_USUARIOS)
public class RespuestaUsuarios extends RespuestaBase{
/** Resultado. **/
@ApiModelProperty(value = "Listado con los objetos de resultado", required = false)
private List<Usuaris> resultado;
public RespuestaUsuarios(String status, String mensaje, Integer numeroElementos,
List<Usuaris> resultado) {
super(status, mensaje, numeroElementos);
this.resultado=resultado;
};
public RespuestaUsuarios() {
super();
}
public List<Usuaris> getResultado() {
return resultado;
}
public void setResultado(List<Usuaris> resultado) {
this.resultado = resultado;
}
}

0 comments on commit eb0a7e0

Please sign in to comment.