Search in sources :

Example 16 with SQLQuery

use of org.hibernate.SQLQuery in project arquivoProject by fader-azevedo.

the class DBConnector method getPastaInfoToolTip.

public Tooltip getPastaInfoToolTip(String codigo) {
    Pasta ps = (Pasta) getEstOrPratOrPastByCodigo(codigo, Pasta.class);
    List<Pauta> dataPauta = null;
    String datac = new SimpleDateFormat("dd/MM/yyyy HH:mm").format(ps.getDataCriacao());
    Usuario user = (Usuario) buscarPorId(Usuario.class, ps.getUsuario());
    try {
        sessao = HibernateUtil.getSessionFactory().openSession();
        sessao.beginTransaction();
        SQLQuery query2 = sessao.createSQLQuery("SELECT * FROM  Pauta WHERE  idpasta =?").addEntity(Pauta.class);
        dataPauta = query2.setString(0, ps.getIdpasta() + "%").list();
        sessao.getTransaction().commit();
        sessao.close();
    } catch (HibernateException e) {
        alertErro("Erro ao buscar dados " + e);
    }
    Tooltip tooltip = new Tooltip();
    tooltip.setText("Documentos   : " + dataPauta.size() + "\n" + "Data Criada    : " + datac + "\n" + "Criada Por      : " + user.getNome() + " " + user.getApelido());
    MaterialIconView icon = new MaterialIconView(MaterialIcon.INFO, "50");
    icon.setFill(Paint.valueOf("#75B4C9"));
    tooltip.setGraphic(icon);
    return tooltip;
}
Also used : HibernateException(org.hibernate.HibernateException) Tooltip(javafx.scene.control.Tooltip) MaterialIconView(de.jensd.fx.glyphs.materialicons.MaterialIconView) SQLQuery(org.hibernate.SQLQuery) SimpleDateFormat(java.text.SimpleDateFormat)

Example 17 with SQLQuery

use of org.hibernate.SQLQuery in project arquivoProject by fader-azevedo.

the class ListaDocumentoController method scrollBtnPauta.

public void scrollBtnPauta(String codigoEstante, String codigoPratileira, String codigoPasta) {
    GridPane gr = new GridPane();
    gr.setHgap(12);
    gr.setVgap(16);
    gr.setPadding(new Insets(5, 5, 5, 5));
    sessao = HibernateUtil.getSessionFactory().openSession();
    sessao.beginTransaction();
    List<Pauta> dataPauta = null;
    List<Exame> dataExame = null;
    if (!codigoEstante.equalsIgnoreCase("") && !codigoEstante.equalsIgnoreCase("") && !codigoPasta.equals("")) {
        codigoEstanteLb.setText(codigoEstante);
        codigoPratileiraLb.setText(codigoPratileira);
        codigoPastaLb.setText(codigoPasta);
        codigoEstanteLb.getStyleClass().add("lbCamiho");
        codigoPratileiraLb.getStyleClass().add("lbCamiho");
        codigoPastaLb.getStyleClass().add("lbCamiho");
        MaterialDesignIconView iconEstant = new MaterialDesignIconView(MaterialDesignIcon.BOOK, "20");
        boxCaminho.getChildren().add(iconEstant);
        boxCaminho.getChildren().add(codigoEstanteLb);
        OctIconView iconNext = new OctIconView(OctIcon.CHEVRON_RIGHT, "20");
        iconNext.setFill(Paint.valueOf("#0078D7"));
        boxCaminho.getChildren().add(iconNext);
        MaterialDesignIconView iconPrat = new MaterialDesignIconView(MaterialDesignIcon.LIBRARY_BOOKS, "20");
        boxCaminho.getChildren().add(iconPrat);
        boxCaminho.getChildren().add(codigoPratileiraLb);
        OctIconView iconNext2 = new OctIconView(OctIcon.CHEVRON_RIGHT, "20");
        iconNext2.setFill(Paint.valueOf("#0078D7"));
        boxCaminho.getChildren().add(iconNext2);
        MaterialDesignIconView iconPasta = new MaterialDesignIconView(MaterialDesignIcon.FOLDER, "20");
        boxCaminho.getChildren().add(iconPasta);
        boxCaminho.getChildren().add(codigoPastaLb);
        Pasta es = (Pasta) db.getEstOrPratOrPastByCodigo(codigoPasta, Pasta.class);
        int idPasta = es.getIdpasta();
        SQLQuery query = sessao.createSQLQuery("SELECT * FROM  Pauta WHERE  idpasta =?").addEntity(Pauta.class);
        dataPauta = query.setString(0, idPasta + "%").list();
    } else {
        verificador = true;
        this.lbInfo.setVisible(false);
        dataPauta = sessao.createCriteria(Pauta.class).list();
        sessao.getTransaction().commit();
    }
    int numColunas = 0;
    int numLinha = 0;
    for (Pauta obj : dataPauta) {
        JFXButton button = new JFXButton(obj.getScan());
        MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.FILE_EXCEL, "40");
        icon.setFill(Paint.valueOf("#A17878"));
        button.setGraphic(icon);
        button.setContentDisplay(ContentDisplay.TOP);
        button.setPrefSize(99, 96);
        button.setButtonType(JFXButton.ButtonType.RAISED);
        button.setDefaultButton(true);
        button.setContextMenu(this.rightClik(button));
        if (numColunas < 6) {
            gr.add(button, numColunas, numLinha);
            numColunas += 1;
        } else {
            numColunas = 0;
            numLinha += 1;
            gr.add(button, numColunas, numLinha);
            numColunas += 1;
        }
    }
    ScrollPane scroll = new ScrollPane(gr);
    scroll.setStyle("-fx-background-color:transparent;");
    scroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scroll.setPrefSize(680, 331);
    scroll.setPadding(new Insets(2, 0, 0, 2));
    if (dataPauta.isEmpty()) {
        lbInfo.setVisible(true);
    } else {
        pnButoes.getChildren().add(scroll);
    }
}
Also used : Exame(model.Exame) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Pauta(model.Pauta) OctIconView(de.jensd.fx.glyphs.octicons.OctIconView) JFXButton(com.jfoenix.controls.JFXButton) SQLQuery(org.hibernate.SQLQuery) Paint(javafx.scene.paint.Paint) ScrollPane(javafx.scene.control.ScrollPane) Pasta(model.Pasta) MaterialDesignIconView(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView)

Example 18 with SQLQuery

use of org.hibernate.SQLQuery in project arquivoProject by fader-azevedo.

the class ListaPastaController method scrollBtnPasta.

public void scrollBtnPasta(String codigoEstante, String codigoPratileira) {
    GridPane gr = new GridPane();
    gr.setHgap(12);
    gr.setVgap(16);
    gr.setPadding(new Insets(5, 5, 5, 5));
    sessao = HibernateUtil.getSessionFactory().openSession();
    sessao.beginTransaction();
    List<Pasta> data = null;
    if (!codigoEstante.equalsIgnoreCase("") && !codigoEstante.equalsIgnoreCase("")) {
        codigoEstanteLb.setText(codigoEstante);
        codigoPratileiraLb.setText(codigoPratileira);
        codigoEstanteLb.getStyleClass().add("lbCamiho");
        codigoPratileiraLb.getStyleClass().add("lbCamiho");
        MaterialDesignIconView iconEstant = new MaterialDesignIconView(MaterialDesignIcon.BOOK, "20");
        boxCaminho.getChildren().add(iconEstant);
        boxCaminho.getChildren().add(codigoEstanteLb);
        OctIconView iconNext = new OctIconView(OctIcon.CHEVRON_RIGHT, "20");
        iconNext.setFill(Paint.valueOf("#0078D7"));
        boxCaminho.getChildren().add(iconNext);
        MaterialDesignIconView iconPrat = new MaterialDesignIconView(MaterialDesignIcon.LIBRARY_BOOKS, "20");
        boxCaminho.getChildren().add(iconPrat);
        boxCaminho.getChildren().add(codigoPratileiraLb);
        Pratileira es = (Pratileira) db.getEstOrPratOrPastByCodigo(codigoPratileira, Pratileira.class);
        int idPratileira = es.getIdpratileira();
        SQLQuery query = sessao.createSQLQuery("SELECT * FROM  Pasta WHERE  idpratileira =?").addEntity(Pasta.class);
        data = query.setString(0, idPratileira + "%").list();
    } else {
        b = true;
        this.lbInfo.setVisible(false);
        data = sessao.createCriteria(Pasta.class).list();
        sessao.getTransaction().commit();
    }
    int numColunas = 0;
    int numLinha = 0;
    for (Pasta obj : data) {
        JFXButton button = new JFXButton(obj.getCodigo());
        MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.FOLDER, "40");
        icon.setFill(Paint.valueOf("#A17878"));
        button.setGraphic(icon);
        button.setContentDisplay(ContentDisplay.TOP);
        button.setPrefSize(99, 96);
        button.setButtonType(JFXButton.ButtonType.RAISED);
        button.setDefaultButton(true);
        button.setTooltip(db.getPastaInfoToolTip(obj.getCodigo()));
        if (numColunas < 6) {
            gr.add(button, numColunas, numLinha);
            numColunas += 1;
        } else {
            numColunas = 0;
            numLinha += 1;
            gr.add(button, numColunas, numLinha);
            numColunas += 1;
        }
        button.setOnAction(bb -> {
            playThis(button);
        });
    }
    ScrollPane scroll = new ScrollPane(gr);
    scroll.setStyle("-fx-background-color:transparent;");
    scroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scroll.setPrefSize(680, 331);
    scroll.setPadding(new Insets(2, 0, 0, 2));
    if (data.isEmpty()) {
        lbInfo.setVisible(true);
    } else {
        pnButoes.getChildren().add(scroll);
    }
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Pratileira(model.Pratileira) OctIconView(de.jensd.fx.glyphs.octicons.OctIconView) ScrollPane(javafx.scene.control.ScrollPane) Pasta(model.Pasta) JFXButton(com.jfoenix.controls.JFXButton) SQLQuery(org.hibernate.SQLQuery) MaterialDesignIconView(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView) Paint(javafx.scene.paint.Paint)

Example 19 with SQLQuery

use of org.hibernate.SQLQuery in project arquivoProject by fader-azevedo.

the class ListaPratileiraController method scrollBtnPratileira.

public void scrollBtnPratileira(String codigoEstante) {
    GridPane gr = new GridPane();
    gr.setHgap(12);
    gr.setVgap(16);
    gr.setPadding(new Insets(5, 5, 5, 5));
    sessao = HibernateUtil.getSessionFactory().openSession();
    sessao.beginTransaction();
    List<Pratileira> data = null;
    if (!codigoEstante.equalsIgnoreCase("")) {
        codigoEstanteLb.setText(codigoEstante);
        codigoEstanteLb.getStyleClass().add("lbCamiho");
        MaterialDesignIconView iconEstante = new MaterialDesignIconView(MaterialDesignIcon.BOOK, "20");
        boxCaminho.getChildren().add(iconEstante);
        boxCaminho.getChildren().add(codigoEstanteLb);
        Estante es = (Estante) db.getEstOrPratOrPastByCodigo(codigoEstante, Estante.class);
        int idEstante = es.getIdestante();
        SQLQuery query = sessao.createSQLQuery("SELECT * FROM  Pratileira WHERE  idestante =?").addEntity(Pratileira.class);
        data = query.setString(0, idEstante + "%").list();
    } else {
        // Qunado clica directamente na pratileira
        b = true;
        this.lbInfo.setVisible(false);
        data = sessao.createCriteria(Pratileira.class).list();
        sessao.getTransaction().commit();
    }
    int numColunas = 0;
    int numLinha = 0;
    for (Pratileira prat : data) {
        JFXButton button = new JFXButton(prat.getCodigo());
        MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.LIBRARY_BOOKS, "40");
        icon.setFill(Paint.valueOf("#A17878"));
        button.setGraphic(icon);
        button.setContentDisplay(ContentDisplay.TOP);
        button.setPrefSize(99, 96);
        button.setButtonType(JFXButton.ButtonType.RAISED);
        button.setDefaultButton(true);
        button.setTooltip(db.tooltipPratileira(prat.getCodigo()));
        if (numColunas < 6) {
            gr.add(button, numColunas, numLinha);
            numColunas += 1;
        } else {
            numColunas = 0;
            numLinha += 1;
            gr.add(button, numColunas, numLinha);
            numColunas += 1;
        }
        button.setOnAction(e -> {
            playThis(button);
        });
    }
    ScrollPane scroll = new ScrollPane(gr);
    scroll.setStyle("-fx-background-color:transparent;");
    scroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scroll.setPrefSize(680, 331);
    scroll.setPadding(new Insets(2, 0, 0, 2));
    if (data.isEmpty()) {
        lbInfo.setVisible(true);
    } else {
        pnButoes.getChildren().add(scroll);
    }
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Pratileira(model.Pratileira) ScrollPane(javafx.scene.control.ScrollPane) JFXButton(com.jfoenix.controls.JFXButton) SQLQuery(org.hibernate.SQLQuery) MaterialDesignIconView(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView) Paint(javafx.scene.paint.Paint) Estante(model.Estante)

Example 20 with SQLQuery

use of org.hibernate.SQLQuery in project hibernate-orm by hibernate.

the class SQLLoaderTest method testEmbeddedCompositeProperties.

@Test
public void testEmbeddedCompositeProperties() throws HibernateException, SQLException {
    Session session = openSession();
    session.beginTransaction();
    Single s = new Single();
    s.setId("my id");
    s.setString("string 1");
    session.save(s);
    session.getTransaction().commit();
    session = openSession();
    session.beginTransaction();
    SQLQuery query = session.createSQLQuery("select {sing.*} from Single {sing}").addEntity("sing", Single.class);
    List list = query.list();
    assertTrue(list.size() == 1);
    session.clear();
    query = session.createSQLQuery("select {sing.*} from Single {sing} where sing.id = ?").addEntity("sing", Single.class);
    query.setString(0, "my id");
    list = query.list();
    assertTrue(list.size() == 1);
    session.clear();
    query = session.createSQLQuery("select s.id as {sing.id}, s.string_ as {sing.string}, s.prop as {sing.prop} from Single s where s.id = ?").addEntity("sing", Single.class);
    query.setString(0, "my id");
    list = query.list();
    assertTrue(list.size() == 1);
    session.clear();
    query = session.createSQLQuery("select s.id as {sing.id}, s.string_ as {sing.string}, s.prop as {sing.prop} from Single s where s.id = ?").addEntity("sing", Single.class);
    query.setString(0, "my id");
    list = query.list();
    assertTrue(list.size() == 1);
    session.getTransaction().commit();
    session.close();
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) SQLQuery(org.hibernate.SQLQuery) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

SQLQuery (org.hibernate.SQLQuery)35 Session (org.hibernate.Session)22 Test (org.junit.Test)13 List (java.util.List)6 Paint (javafx.scene.paint.Paint)5 HibernateException (org.hibernate.HibernateException)4 JFXButton (com.jfoenix.controls.JFXButton)3 MaterialDesignIconView (de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView)3 MaterialIconView (de.jensd.fx.glyphs.materialicons.MaterialIconView)3 BigInteger (java.math.BigInteger)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ArrayList (java.util.ArrayList)3 Insets (javafx.geometry.Insets)3 ScrollPane (javafx.scene.control.ScrollPane)3 Tooltip (javafx.scene.control.Tooltip)3 GridPane (javafx.scene.layout.GridPane)3 Book (com.iluwatar.cqrs.dto.Book)2 OctIconView (de.jensd.fx.glyphs.octicons.OctIconView)2 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2