rodrigo 2013-03-01 19:06:07 +00:00
parent 621b3d7e21
commit 73740b7b78
4 changed files with 219 additions and 217 deletions

View File

@ -101,7 +101,7 @@
<classpathentry kind="lib" path="/LibreriasAdmVenta/jasperreports-4.5.0.jar"/> <classpathentry kind="lib" path="/LibreriasAdmVenta/jasperreports-4.5.0.jar"/>
<classpathentry kind="lib" path="/LibreriasAdmVenta/jfreechart-1.0.12.jar"/> <classpathentry kind="lib" path="/LibreriasAdmVenta/jfreechart-1.0.12.jar"/>
<classpathentry kind="lib" path="/LibreriasAdmVenta/poi-3.8-20120326.jar"/> <classpathentry kind="lib" path="/LibreriasAdmVenta/poi-3.8-20120326.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6">
<attributes> <attributes>
<attribute name="owner.project.facets" value="java"/> <attribute name="owner.project.facets" value="java"/>
</attributes> </attributes>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<faceted-project> <faceted-project>
<runtime name="JBoss 6.x Runtime"/> <runtime name="JBoss 6.0 Runtime"/>
<fixed facet="jst.utility"/> <fixed facet="jst.utility"/>
<fixed facet="java"/> <fixed facet="java"/>
<installed facet="java" version="1.6"/> <installed facet="java" version="1.6"/>

View File

@ -22,138 +22,139 @@ import javax.persistence.TemporalType;
import javax.persistence.SequenceGenerator; import javax.persistence.SequenceGenerator;
/** /**
* *
* @author Administrador * @author Administrador
*/ */
@Entity @Entity
@SequenceGenerator(name = "CATEGORIA_SEQ", sequenceName = "CATEGORIA_SEQ", allocationSize = 1) @SequenceGenerator(name = "CATEGORIA_SEQ", sequenceName = "CATEGORIA_SEQ", allocationSize = 1)
@Table(name = "CATEGORIA") @Table(name = "CATEGORIA")
public class Categoria implements Serializable { public class Categoria implements Serializable {
public static Integer CATEGORIA_NORMAL = 1;
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CATEGORIA_SEQ")
@Column(name = "CATEGORIA_ID")
private Integer categoriaId;
@Column(name = "DESCCATEGORIA")
private String desccategoria;
@Column(name = "ACTIVO")
private Boolean activo;
// CAmpos retirados
// @Column(name = "INDVENDEINTERNET")
// private Boolean vendeInternet;
// @Column(name = "INDVENDEAGENCIAWEB")
// private Boolean vendeAgenciaWeb;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIO_ID")
private Integer usuarioId;
@OneToMany(mappedBy = "categoria", cascade = CascadeType.ALL)
private List<CategoriaDescuento> categoriaDescuentoList;
@OneToMany(mappedBy = "categoria", cascade = CascadeType.ALL)
private List<ReservacionCategoria> reservacionCategoriaList;
private static final long serialVersionUID = 1L; public Categoria() {
@Id }
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CATEGORIA_SEQ")
@Column(name = "CATEGORIA_ID")
private Integer categoriaId;
@Column(name = "DESCCATEGORIA")
private String desccategoria;
@Column(name = "ACTIVO")
private Boolean activo;
//CAmpos retirados
// @Column(name = "INDVENDEINTERNET")
// private Boolean vendeInternet;
// @Column(name = "INDVENDEAGENCIAWEB")
// private Boolean vendeAgenciaWeb;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIO_ID")
private Integer usuarioId;
@OneToMany(mappedBy = "categoria", cascade = CascadeType.ALL)
private List<CategoriaDescuento> categoriaDescuentoList;
@OneToMany(mappedBy = "categoria", cascade = CascadeType.ALL)
private List<ReservacionCategoria> reservacionCategoriaList;
public Categoria() { public Categoria(Integer categoriaId) {
} this.categoriaId = categoriaId;
}
public Categoria(Integer categoriaId) { public Integer getCategoriaId() {
this.categoriaId = categoriaId; return categoriaId;
} }
public Integer getCategoriaId() { public void setCategoriaId(Integer categoriaId) {
return categoriaId; this.categoriaId = categoriaId;
} }
public void setCategoriaId(Integer categoriaId) { public String getDesccategoria() {
this.categoriaId = categoriaId; return desccategoria;
} }
public String getDesccategoria() { public void setDesccategoria(String desccategoria) {
return desccategoria; this.desccategoria = desccategoria;
} }
public void setDesccategoria(String desccategoria) { public Boolean getActivo() {
this.desccategoria = desccategoria; return activo;
} }
public Boolean getActivo() { public void setActivo(Boolean activo) {
return activo; this.activo = activo;
} }
public void setActivo(Boolean activo) { public Date getFecmodif() {
this.activo = activo; return fecmodif;
} }
public Date getFecmodif() { public void setFecmodif(Date fecmodif) {
return fecmodif; this.fecmodif = fecmodif;
} }
public void setFecmodif(Date fecmodif) { public Integer getUsuarioId() {
this.fecmodif = fecmodif; return usuarioId;
} }
public Integer getUsuarioId() { public void setUsuarioId(Integer usuarioId) {
return usuarioId; this.usuarioId = usuarioId;
} }
public void setUsuarioId(Integer usuarioId) { public List<CategoriaDescuento> getCategoriaDescuentoList() {
this.usuarioId = usuarioId; // return categoriaDescuentoList;
} List<CategoriaDescuento> rcList = new ArrayList<CategoriaDescuento>();
for (CategoriaDescuento rc : this.categoriaDescuentoList) {
if (rc.getActivo() == Boolean.TRUE) {
rcList.add(rc);
}
}
return rcList;
}
public List<CategoriaDescuento> getCategoriaDescuentoList() { public void setCategoriaDescuentoList(List<CategoriaDescuento> categoriaDescuentoList) {
//return categoriaDescuentoList; this.categoriaDescuentoList = categoriaDescuentoList;
List<CategoriaDescuento> rcList = new ArrayList<CategoriaDescuento>(); }
for (CategoriaDescuento rc : this.categoriaDescuentoList) {
if (rc.getActivo() == Boolean.TRUE) {
rcList.add(rc);
}
}
return rcList;
}
public void setCategoriaDescuentoList(List<CategoriaDescuento> categoriaDescuentoList) { public List<ReservacionCategoria> getReservacionCategoriaList() {
this.categoriaDescuentoList = categoriaDescuentoList; // return reservacionCategoriaList;
} List<ReservacionCategoria> rcList = new ArrayList<ReservacionCategoria>();
for (ReservacionCategoria rc : this.reservacionCategoriaList) {
if (rc.getActivo() == Boolean.TRUE) {
rcList.add(rc);
}
}
return rcList;
}
public List<ReservacionCategoria> getReservacionCategoriaList() { public void setReservacionCategoriaList(List<ReservacionCategoria> reservacionCategoriaList) {
//return reservacionCategoriaList; this.reservacionCategoriaList = reservacionCategoriaList;
List<ReservacionCategoria> rcList = new ArrayList<ReservacionCategoria>(); }
for (ReservacionCategoria rc : this.reservacionCategoriaList) {
if (rc.getActivo() == Boolean.TRUE) {
rcList.add(rc);
}
}
return rcList;
}
public void setReservacionCategoriaList(List<ReservacionCategoria> reservacionCategoriaList) { @Override
this.reservacionCategoriaList = reservacionCategoriaList; public int hashCode() {
} int hash = 0;
hash += (categoriaId != null ? categoriaId.hashCode() : 0);
return hash;
}
@Override @Override
public int hashCode() { public boolean equals(Object object) {
int hash = 0; // TODO: Warning - this method won't work in the case the id fields are
hash += (categoriaId != null ? categoriaId.hashCode() : 0); // not set
return hash; if (!(object instanceof Categoria)) {
} return false;
}
Categoria other = (Categoria) object;
if ((this.categoriaId == null && other.categoriaId != null) || (this.categoriaId != null && !this.categoriaId.equals(other.categoriaId))) {
return false;
}
return true;
}
@Override @Override
public boolean equals(Object object) { public String toString() {
// TODO: Warning - this method won't work in the case the id fields are not set return this.getDesccategoria();
if (!(object instanceof Categoria)) { }
return false;
}
Categoria other = (Categoria) object;
if ((this.categoriaId == null && other.categoriaId != null) || (this.categoriaId != null && !this.categoriaId.equals(other.categoriaId))) {
return false;
}
return true;
}
@Override
public String toString() {
return this.getDesccategoria();
}
} }

View File

@ -24,137 +24,138 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
/** /**
* *
* @author Administrador * @author Administrador
*/ */
@Service("categoriaCtrlService") @Service("categoriaCtrlService")
public class CategoriaCtrlServiceImpl implements CategoriaCtrlService { public class CategoriaCtrlServiceImpl implements CategoriaCtrlService {
public static final int CATEGORIA_ADULTO = 1; public static final int CATEGORIA_ADULTO = 1;
@Autowired @Autowired
private CategoriaCtrlDAO categoriaCtrlDAO; private CategoriaCtrlDAO categoriaCtrlDAO;
@Autowired @Autowired
private CategoriaDAO categoriaDAO; private CategoriaDAO categoriaDAO;
public List<CategoriaCtrl> obtenerTodos() { public List<CategoriaCtrl> obtenerTodos() {
return categoriaCtrlDAO.obtenerTodos(); return categoriaCtrlDAO.obtenerTodos();
} }
public CategoriaCtrl obtenerID(Integer id) { public CategoriaCtrl obtenerID(Integer id) {
return categoriaCtrlDAO.obtenerID(id); return categoriaCtrlDAO.obtenerID(id);
} }
@Transactional @Transactional
public CategoriaCtrl suscribir(CategoriaCtrl entidad) { public CategoriaCtrl suscribir(CategoriaCtrl entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE); entidad.setActivo(Boolean.TRUE);
checarCategoriaAdulto(entidad); checarCategoriaAdulto(entidad);
return categoriaCtrlDAO.suscribir(entidad); return categoriaCtrlDAO.suscribir(entidad);
} }
/** /**
* Verifica se existe la categoria adulto. Sino existe, la adicciona. * Verifica se existe la categoria adulto. Sino existe, la adicciona.
* @param categoriaCtrl *
*/ * @param categoriaCtrl
private void checarCategoriaAdulto(CategoriaCtrl categoriaCtrl) { */
boolean existeAdulto = false; private void checarCategoriaAdulto(CategoriaCtrl categoriaCtrl) {
List<CategoriaDescuento> lsCategorias = new ArrayList<CategoriaDescuento>(); boolean existeAdulto = false;
lsCategorias.addAll(categoriaCtrl.getCategoriaDescuentoList()); List<CategoriaDescuento> lsCategorias = new ArrayList<CategoriaDescuento>();
lsCategorias.addAll(categoriaCtrl.getCategoriaDescuentoList());
for (CategoriaDescuento cd : categoriaCtrl.getCategoriaDescuentoList()) {
if (cd.getCategoria().getCategoriaId().equals(CATEGORIA_ADULTO)) {
existeAdulto = true;
}
}
if (!existeAdulto) {
CategoriaDescuento categoriaDescuentoAdulto = this.getCategoriaDescuentoAdulto(categoriaCtrl);
lsCategorias.add(categoriaDescuentoAdulto);
}
categoriaCtrl.setCategoriaDescuentoList(lsCategorias);
}
@Transactional for (CategoriaDescuento cd : categoriaCtrl.getCategoriaDescuentoList()) {
public CategoriaCtrl actualizacion(CategoriaCtrl entidad) { if (cd.getCategoria().getCategoriaId().equals(CATEGORIA_ADULTO)) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); existeAdulto = true;
entidad.setFecmodif(Calendar.getInstance().getTime()); }
entidad.setActivo(Boolean.TRUE); }
if (!existeAdulto) {
CategoriaDescuento categoriaDescuentoAdulto = this.getCategoriaDescuentoAdulto(categoriaCtrl);
lsCategorias.add(categoriaDescuentoAdulto);
}
categoriaCtrl.setCategoriaDescuentoList(lsCategorias);
}
return categoriaCtrlDAO.actualizacion(entidad); @Transactional
} public CategoriaCtrl actualizacion(CategoriaCtrl entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
@Transactional return categoriaCtrlDAO.actualizacion(entidad);
public void borrar(CategoriaCtrl entidad) { }
for (CategoriaClase cc : entidad.getCategoriaClaseList()) { @Transactional
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); public void borrar(CategoriaCtrl entidad) {
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
for (CategoriaCorrida cc : entidad.getCategoriaCorridaList()) {
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
for (CategoriaDescuento cc : entidad.getCategoriaDescuentoList()) {
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
for (CategoriaMarca cc : entidad.getCategoriaMarcaList()) {
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
for (CategoriaMercado cc : entidad.getCategoriaMercadoList()) {
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); for (CategoriaClase cc : entidad.getCategoriaClaseList()) {
entidad.setFecmodif(Calendar.getInstance().getTime()); cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setActivo(Boolean.FALSE); cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
for (CategoriaCorrida cc : entidad.getCategoriaCorridaList()) {
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
for (CategoriaDescuento cc : entidad.getCategoriaDescuentoList()) {
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
for (CategoriaMarca cc : entidad.getCategoriaMarcaList()) {
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
for (CategoriaMercado cc : entidad.getCategoriaMercadoList()) {
cc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cc.setFecmodif(Calendar.getInstance().getTime());
cc.setActivo(Boolean.FALSE);
}
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.FALSE);
categoriaCtrlDAO.actualizacion(entidad); categoriaCtrlDAO.actualizacion(entidad);
} }
private CategoriaDescuento getCategoriaDescuentoAdulto(CategoriaCtrl categoriaCtrl) { private CategoriaDescuento getCategoriaDescuentoAdulto(CategoriaCtrl categoriaCtrl) {
CategoriaDescuento cd = new CategoriaDescuento(); CategoriaDescuento cd = new CategoriaDescuento();
cd.setActivo(Boolean.TRUE); cd.setActivo(Boolean.TRUE);
cd.setCantautorizada(50); cd.setCantautorizada(50);
cd.setCategoria(categoriaDAO.obtenerID(CATEGORIA_ADULTO)); cd.setCategoria(categoriaDAO.obtenerID(CATEGORIA_ADULTO));
cd.setDescuentoimporte(BigDecimal.ZERO); cd.setDescuentoimporte(BigDecimal.ZERO);
cd.setDescuentoporc(BigDecimal.ZERO); cd.setDescuentoporc(BigDecimal.ZERO);
CategoriaPeriodo cp = new CategoriaPeriodo(); CategoriaPeriodo cp = new CategoriaPeriodo();
cp.setActivo(Boolean.TRUE); cp.setActivo(Boolean.TRUE);
cp.setCategoriaDescuento(cd); cp.setCategoriaDescuento(cd);
Calendar datFin = Calendar.getInstance(); Calendar datFin = Calendar.getInstance();
datFin.set(2300, 11, 31); datFin.set(2300, 11, 31);
Calendar datInicio = Calendar.getInstance(); Calendar datInicio = Calendar.getInstance();
datInicio.set(2000, 11, 31); datInicio.set(2000, 11, 31);
cp.setFecfin(datFin.getTime()); cp.setFecfin(datFin.getTime());
cp.setFecinicio(datInicio.getTime()); cp.setFecinicio(datInicio.getTime());
cp.setFecmodif(new java.util.Date()); cp.setFecmodif(new java.util.Date());
cp.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); cp.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
List<CategoriaPeriodo> lsCatPeriodo = new ArrayList<CategoriaPeriodo>(); List<CategoriaPeriodo> lsCatPeriodo = new ArrayList<CategoriaPeriodo>();
lsCatPeriodo.add(cp); lsCatPeriodo.add(cp);
cd.setCategoriaPeriodoList(lsCatPeriodo); cd.setCategoriaPeriodoList(lsCatPeriodo);
cd.setCategoriaCtrl(categoriaCtrl); cd.setCategoriaCtrl(categoriaCtrl);
cd.setFecmodif(new java.util.Date()); cd.setFecmodif(new java.util.Date());
cd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); cd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
cd.setIndAplicaFeriado(CategoriaDescuento.DisponibilidadeFeriado.GERARSEMPRE.valor());
return cd;
} return cd;
}
} }