Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form th:action="${modelo.id>0}? @{/costos/admin/modelo/modificar}:@{/costos/admin/modelo}" method="post" th:object="${modelo}">
- <div class="row">
- <div class="col-xs-12 col-sm-8">
- <label >Modelo</label>
- <input type="hidden" th:field="*{id}">
- <div class="input-group">
- <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
- <input class="form-control input-lg" type="text" th:field="*{modelo}">
- </div>
- <div class="alert alert-danger" th:if="${#fields.hasErrors('modelo')}" th:errors="*{modelo}" ></div>
- </div>
- <div class="col-xs-12 col-sm-4">
- <label >Categoria</label>
- <select class="form-control input-lg" th:field="*{categoria}">
- <option th:each="cat:${categorias}"
- th:value="${cat.id}"
- th:text="${cat.categoria}"> </option>
- </select>
- </div>
- </div>
- <br>
- <div class="row">
- <div class="col-xs-12 text-right">
- <a type="button" class="btn btn-danger BOTON_LIMPIAR" href="/index"> <span class=" glyphicon glyphicon-remove"></span> Cancelar</a>
- <button type="submit" class="btn btn-success"> <span class="glyphicon glyphicon-floppy-save"></span> <span th:text="${modelo.id>0}? @{Modificar}:@{Guardar}"></span></button>
- </div>
- </div>
- </form>
- @Entity
- @Table(name = "modelo")
- @XmlRootElement
- @NamedQueries({
- @NamedQuery(name = "Modelo.findAll", query = "SELECT m FROM Modelo m")
- , @NamedQuery(name = "Modelo.findById", query = "SELECT m FROM Modelo m WHERE m.id = :id")
- , @NamedQuery(name = "Modelo.findByModelo", query = "SELECT m FROM Modelo m WHERE m.modelo = :modelo")
- , @NamedQuery(name = "Modelo.findByIdTamano", query = "SELECT m FROM Modelo m WHERE m.idTamano = :idTamano")
- , @NamedQuery(name = "Modelo.findByEspesorPastilla", query = "SELECT m FROM Modelo m WHERE m.espesorPastilla = :espesorPastilla")
- , @NamedQuery(name = "Modelo.findByEspesorBoton", query = "SELECT m FROM Modelo m WHERE m.espesorBoton = :espesorBoton")
- , @NamedQuery(name = "Modelo.findByLineasOMm", query = "SELECT m FROM Modelo m WHERE m.lineasOMm = :lineasOMm")
- , @NamedQuery(name = "Modelo.findByCentroOFrente", query = "SELECT m FROM Modelo m WHERE m.centroOFrente = :centroOFrente")
- , @NamedQuery(name = "Modelo.findByDiametroEspalda", query = "SELECT m FROM Modelo m WHERE m.diametroEspalda = :diametroEspalda")
- , @NamedQuery(name = "Modelo.findByRectificado", query = "SELECT m FROM Modelo m WHERE m.rectificado = :rectificado")
- , @NamedQuery(name = "Modelo.findByVelocidad", query = "SELECT m FROM Modelo m WHERE m.velocidad = :velocidad")
- , @NamedQuery(name = "Modelo.findByMaterialEfecto", query = "SELECT m FROM Modelo m WHERE m.materialEfecto = :materialEfecto")
- , @NamedQuery(name = "Modelo.findByFotoCelda", query = "SELECT m FROM Modelo m WHERE m.fotoCelda = :fotoCelda")
- , @NamedQuery(name = "Modelo.findByInclinacion", query = "SELECT m FROM Modelo m WHERE m.inclinacion = :inclinacion")
- , @NamedQuery(name = "Modelo.findByDiametroPata", query = "SELECT m FROM Modelo m WHERE m.diametroPata = :diametroPata")
- , @NamedQuery(name = "Modelo.findByEspesorPata", query = "SELECT m FROM Modelo m WHERE m.espesorPata = :espesorPata")
- , @NamedQuery(name = "Modelo.findByAlturaPata", query = "SELECT m FROM Modelo m WHERE m.alturaPata = :alturaPata")
- , @NamedQuery(name = "Modelo.findByObservaciones", query = "SELECT m FROM Modelo m WHERE m.observaciones = :observaciones")
- , @NamedQuery(name = "Modelo.findByCavidadDiametro", query = "SELECT m FROM Modelo m WHERE m.cavidadDiametro = :cavidadDiametro")
- , @NamedQuery(name = "Modelo.findByCavidadProfundidad", query = "SELECT m FROM Modelo m WHERE m.cavidadProfundidad = :cavidadProfundidad")
- , @NamedQuery(name = "Modelo.findByFigura", query = "SELECT m FROM Modelo m WHERE m.figura = :figura")})
- public class Modelo implements Serializable {
- @Basic(optional = false)
- @NotNull()
- @Size(min = 1, max = 20)
- @Column(name = "modelo")
- private String modelo;
- @Size(max = 50)
- @Column(name = "materialEfecto")
- private String materialEfecto;
- @Size(max = 20)
- @Column(name = "fotoCelda")
- private String fotoCelda;
- @Size(max = 20)
- @Column(name = "inclinacion")
- private String inclinacion;
- @Size(max = 400)
- @Column(name = "Observaciones")
- private String observaciones;
- @Size(max = 50)
- @Column(name = "figura")
- private String figura;
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Basic(optional = false)
- @Column(name = "id")
- private Integer id;
- @Column(name = "idTamano")
- private Integer idTamano;
- // @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
- @Column(name = "espesorPastilla")
- private Float espesorPastilla;
- @Column(name = "espesorBoton")
- private Float espesorBoton;
- @Column(name = "lineasOMm")
- private Float lineasOMm;
- @Column(name = "centroOFrente")
- private Float centroOFrente;
- @Column(name = "diametroEspalda")
- private Float diametroEspalda;
- @Column(name = "rectificado")
- private Boolean rectificado;
- @Column(name = "velocidad")
- private Integer velocidad;
- @Column(name = "diametroPata")
- private Float diametroPata;
- @Column(name = "espesorPata")
- private Float espesorPata;
- @Column(name = "alturaPata")
- private Float alturaPata;
- @Column(name = "cavidadDiametro")
- private Float cavidadDiametro;
- @Column(name = "cavidadProfundidad")
- private Float cavidadProfundidad;
- @JoinTable(name = "relacionmodelos", joinColumns = {
- @JoinColumn(name = "idModelo", referencedColumnName = "id")}, inverseJoinColumns = {
- @JoinColumn(name = "idModeloRelacionado", referencedColumnName = "id")})
- @ManyToMany
- private Collection<Modelo> modeloCollection;
- @ManyToMany(mappedBy = "modeloCollection")
- private Collection<Modelo> modeloCollection1;
- @JoinColumn(name = "idcategoria_producto", referencedColumnName = "id")
- @ManyToOne
- private CategoriaProducto categoria;
- @JoinColumn(name = "agujas", referencedColumnName = "id")
- @ManyToOne
- private Refaccion agujas;
- @JoinColumn(name = "guia", referencedColumnName = "id")
- @ManyToOne
- private Refaccion guia;
- public Modelo() {
- }
- public Modelo(Integer id) {
- this.id = id;
- }
- public Modelo(Integer id, String modelo) {
- this.id = id;
- this.modelo = modelo;
- }
- public Integer getId() {
- return id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- public Integer getIdTamano() {
- return idTamano;
- }
- public void setIdTamano(Integer idTamano) {
- this.idTamano = idTamano;
- }
- public Float getEspesorPastilla() {
- return espesorPastilla;
- }
- public void setEspesorPastilla(Float espesorPastilla) {
- this.espesorPastilla = espesorPastilla;
- }
- public Float getEspesorBoton() {
- return espesorBoton;
- }
- public void setEspesorBoton(Float espesorBoton) {
- this.espesorBoton = espesorBoton;
- }
- public Float getLineasOMm() {
- return lineasOMm;
- }
- public void setLineasOMm(Float lineasOMm) {
- this.lineasOMm = lineasOMm;
- }
- public Float getCentroOFrente() {
- return centroOFrente;
- }
- public void setCentroOFrente(Float centroOFrente) {
- this.centroOFrente = centroOFrente;
- }
- public Float getDiametroEspalda() {
- return diametroEspalda;
- }
- public void setDiametroEspalda(Float diametroEspalda) {
- this.diametroEspalda = diametroEspalda;
- }
- public Boolean getRectificado() {
- return rectificado;
- }
- public void setRectificado(Boolean rectificado) {
- this.rectificado = rectificado;
- }
- public Integer getVelocidad() {
- return velocidad;
- }
- public void setVelocidad(Integer velocidad) {
- this.velocidad = velocidad;
- }
- public Float getDiametroPata() {
- return diametroPata;
- }
- public void setDiametroPata(Float diametroPata) {
- this.diametroPata = diametroPata;
- }
- public Float getEspesorPata() {
- return espesorPata;
- }
- public void setEspesorPata(Float espesorPata) {
- this.espesorPata = espesorPata;
- }
- public Float getAlturaPata() {
- return alturaPata;
- }
- public void setAlturaPata(Float alturaPata) {
- this.alturaPata = alturaPata;
- }
- public Float getCavidadDiametro() {
- return cavidadDiametro;
- }
- public void setCavidadDiametro(Float cavidadDiametro) {
- this.cavidadDiametro = cavidadDiametro;
- }
- public Float getCavidadProfundidad() {
- return cavidadProfundidad;
- }
- public void setCavidadProfundidad(Float cavidadProfundidad) {
- this.cavidadProfundidad = cavidadProfundidad;
- }
- @XmlTransient
- public Collection<Modelo> getModeloCollection() {
- return modeloCollection;
- }
- public void setModeloCollection(Collection<Modelo> modeloCollection) {
- this.modeloCollection = modeloCollection;
- }
- @XmlTransient
- public Collection<Modelo> getModeloCollection1() {
- return modeloCollection1;
- }
- public void setModeloCollection1(Collection<Modelo> modeloCollection1) {
- this.modeloCollection1 = modeloCollection1;
- }
- public CategoriaProducto getCategoria() {
- return categoria;
- }
- public void setCategoria(CategoriaProducto categoria) {
- this.categoria = categoria;
- }
- public Refaccion getAgujas() {
- return agujas;
- }
- public void setAgujas(Refaccion agujas) {
- this.agujas = agujas;
- }
- public Refaccion getGuia() {
- return guia;
- }
- public void setGuia(Refaccion guia) {
- this.guia = guia;
- }
- @Override
- public int hashCode() {
- int hash = 0;
- hash += (id != null ? id.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 Modelo)) {
- return false;
- }
- Modelo other = (Modelo) object;
- if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
- return false;
- }
- return true;
- }
- @Override
- public String toString() {
- return "Modelo{" + "id=" + id + ", modelo=" + modelo + ", idTamano=" + idTamano + ", espesorPastilla=" + espesorPastilla + ", espesorBoton=" + espesorBoton + ", lineasOMm=" + lineasOMm + ", centroOFrente=" + centroOFrente + ", diametroEspalda=" + diametroEspalda + ", rectificado=" + rectificado + ", velocidad=" + velocidad + ", materialEfecto=" + materialEfecto + ", fotoCelda=" + fotoCelda + ", inclinacion=" + inclinacion + ", diametroPata=" + diametroPata + ", espesorPata=" + espesorPata + ", alturaPata=" + alturaPata + ", observaciones=" + observaciones + ", cavidadDiametro=" + cavidadDiametro + ", cavidadProfundidad=" + cavidadProfundidad + ", figura=" + figura + ", modeloCollection=" + modeloCollection + ", modeloCollection1=" + modeloCollection1 + ", categoria=" + categoria + ", agujas=" + agujas + ", guia=" + guia + '}';
- }
- public String getModelo() {
- return modelo;
- }
- public void setModelo(String modelo) {
- this.modelo = modelo;
- }
- public String getMaterialEfecto() {
- return materialEfecto;
- }
- public void setMaterialEfecto(String materialEfecto) {
- this.materialEfecto = materialEfecto;
- }
- public String getFotoCelda() {
- return fotoCelda;
- }
- public void setFotoCelda(String fotoCelda) {
- this.fotoCelda = fotoCelda;
- }
- public String getInclinacion() {
- return inclinacion;
- }
- public void setInclinacion(String inclinacion) {
- this.inclinacion = inclinacion;
- }
- public String getObservaciones() {
- return observaciones;
- }
- public void setObservaciones(String observaciones) {
- this.observaciones = observaciones;
- }
- public String getFigura() {
- return figura;
- }
- public void setFigura(String figura) {
- this.figura = figura;
- }
- }
- @RequestMapping(value="admin/modelo", method = RequestMethod.POST)
- public ModelAndView nuevoModelo(
- @Valid Modelo modelo
- ,BindingResult br
- ){
- ModelAndView mav = new ModelAndView();
- //COMPROBAMOS SI EL MODELO EXISTE
- if (modeloService.modeloExist(modelo.getModelo())) {
- br.rejectValue("modelo", "error.modelo", "Ya hay un modelo con ese nombre");
- }
- if (br.hasErrors()) {
- mav.setViewName("costos/modelo");
- }else{
- //GRABAMOS EL MODELO
- if (modeloService.saveModelo(modelo)) {
- mav.addObject("success", "Se registro el modelo con exito.");
- mav.addObject("modelo", new Modelo());
- } else {
- mav.addObject("Error", "Algo paso y no se pudo guardar el modelo");
- }
- }
- mav.addObject("modelo", new Modelo());
- mav.setViewName("costos/modelo");
- mav.addAllObjects(gds.costos_modelo(gds.getUser()));
- return mav;
- }
- @RequestMapping(value="admin/modelo/modificar/{id}", method = RequestMethod.GET)
- public ModelAndView nuevoModelo(
- @PathVariable("id") int id){
- ModelAndView mav = new ModelAndView();
- if (modeloService.modeloExist(id)) {
- mav.addObject("modelo", modeloService.findModeloById(id));
- }else{
- mav.addObject("error", "El modelo no existe: "+id);
- mav.addObject("user", new Modelo());
- }
- //RECUERDA QUE EL SUBMIT DEL FORM SE CAMBIA SI EL ID ES 0, OSEA QUE
- // NO HAY ID.;
- mav.setViewName("costos/modelo");
- mav.addAllObjects(gds.costos_modelo(gds.getUser()));
- return mav;
- }
Add Comment
Please, Sign In to add comment