Example usage for java.sql ResultSet getDate

List of usage examples for java.sql ResultSet getDate

Introduction

In this page you can find the example usage for java.sql ResultSet getDate.

Prototype

java.sql.Date getDate(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.

Usage

From source file:com.github.woonsan.jdbc.jcr.impl.JcrJdbcResultSetTest.java

@SuppressWarnings("deprecation")
private void assertNonExistingColumn(final ResultSet rs) throws Exception {
    int nonExistingColIndex = Integer.MAX_VALUE;
    String nonExistingColName = "col" + nonExistingColIndex;

    try {/*w w  w . j ava 2 s .co  m*/
        rs.getString(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getString(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBoolean(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBoolean(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getByte(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getByte(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getShort(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getShort(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getInt(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getInt(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getLong(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getLong(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getFloat(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getFloat(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDouble(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDouble(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBigDecimal(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBigDecimal(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBigDecimal(nonExistingColIndex, 1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBigDecimal(nonExistingColName, 1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBytes(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBytes(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDate(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDate(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDate(nonExistingColIndex, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDate(nonExistingColName, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTime(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTime(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTime(nonExistingColIndex, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTime(nonExistingColName, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTimestamp(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTimestamp(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTimestamp(nonExistingColIndex, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTimestamp(nonExistingColName, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getAsciiStream(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getAsciiStream(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getUnicodeStream(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getUnicodeStream(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBinaryStream(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBinaryStream(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getCharacterStream(nonExistingColIndex);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getCharacterStream(nonExistingColName);
        fail();
    } catch (SQLException ignore) {
    }

}

From source file:org.apache.openjpa.jdbc.sql.DBDictionary.java

/**
 * Convert the specified column of the SQL ResultSet to the proper
 * java type.//from  ww  w  . j  a  v  a  2  s . c  om
 */
public java.sql.Date getDate(ResultSet rs, int column, Calendar cal) throws SQLException {
    if (cal == null)
        return rs.getDate(column);
    return rs.getDate(column, cal);
}

From source file:edu.harvard.i2b2.ontology.dao.GetCodeInfoDao.java

public List findCodeInfo(final VocabRequestType vocabType, final List categories, ProjectType projectInfo)
        throws DataAccessException, I2B2Exception {
    DataSource ds = null;//from  ww w.  j  av a 2s.  c o m
    try {
        ds = OntologyUtil.getInstance().getDataSource("java:OntologyLocalDS");
    } catch (I2B2Exception e2) {
        log.error(e2.getMessage());
        throw e2;
    }

    SimpleJdbcTemplate jt = new SimpleJdbcTemplate(ds);

    // find return parameters
    String parameters = DEFAULT;
    if (vocabType.getType().equals("core")) {
        parameters = CORE;
    } else if (vocabType.getType().equals("all")) {
        parameters = ALL;
    }
    if (vocabType.isBlob() == true)
        parameters = parameters + BLOB;

    //extract table code
    String tableCd = vocabType.getCategory();
    //      log.info(tableCd);

    // table code to table name conversion
    // Get metadata schema name from properties file.
    String metadataSchema = "";
    try {
        metadataSchema = OntologyUtil.getInstance().getMetaDataSchemaName();
    } catch (I2B2Exception e1) {
        log.error(e1.getMessage());
        throw e1;
    }

    List tableNames = null;
    if (tableCd != null) {
        // table code to table name conversion
        String tableSql = "select distinct(c_table_name) from " + metadataSchema
                + "table_access where c_table_cd = ? ";
        ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() {
            public String mapRow(ResultSet rs, int rowNum) throws SQLException {
                String name = (rs.getString("c_table_name"));
                return name;
            }
        };
        tableNames = jt.query(tableSql, map, tableCd);
    } else { // tableCd is null, so query all tables user has access to
        String whereClause = "where ";
        Iterator it = categories.iterator();
        while (it.hasNext()) {
            ConceptType entry = null;
            if (whereClause.equals("where ")) {
                entry = (ConceptType) it.next();
                whereClause = whereClause + " c_table_cd = '" + StringUtil.getTableCd(entry.getKey()) + "' ";
            } else {
                entry = (ConceptType) it.next();
                whereClause = whereClause + " or " + " c_table_cd = '" + StringUtil.getTableCd(entry.getKey())
                        + "' ";
            }
        }
        String tableSql = "select distinct(c_table_name) from " + metadataSchema + "table_access "
                + whereClause;

        ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() {
            public String mapRow(ResultSet rs, int rowNum) throws SQLException {
                String name = (rs.getString("c_table_name"));
                return name;
            }
        };

        try {
            tableNames = jt.query(tableSql, map);
        } catch (DataAccessException e) {
            log.error(e.getMessage());
            throw e;
        }
    }

    String hidden = "";
    if (vocabType.isHiddens() == false)
        hidden = " and c_visualattributes not like '_H%'";

    String synonym = "";
    if (vocabType.isSynonyms() == false)
        synonym = " and c_synonym_cd = 'N'";

    String codeInfoSql = null;
    if (tableNames != null) {
        Iterator it = tableNames.iterator();
        String table = (String) it.next();
        String tableCdSql = ", (select distinct(c_table_cd) from " + metadataSchema
                + "TABLE_ACCESS where c_table_name = '" + table + "') as tableCd";
        String basecode = " '" + vocabType.getMatchStr().getValue() + "' ";
        codeInfoSql = "select " + parameters + tableCdSql + " from " + metadataSchema + table
                + " where upper(c_basecode) =  " + basecode.toUpperCase() + hidden + synonym;
        ;
        while (it.hasNext()) {
            table = (String) it.next();
            tableCdSql = ", (select distinct(c_table_cd) from " + metadataSchema
                    + "TABLE_ACCESS where c_table_name = '" + table + "') as tableCd";
            codeInfoSql = codeInfoSql + " union select " + parameters + tableCdSql + " from " + metadataSchema
                    + table + " where upper(c_basecode) =  " + basecode.toUpperCase() + hidden + synonym;
        }
        codeInfoSql = codeInfoSql + " order by c_name ";
    } else
        return null;

    log.debug(codeInfoSql);
    final boolean obfuscatedUserFlag = Roles.getInstance().isRoleOfuscated(projectInfo);

    ParameterizedRowMapper<ExpandedConceptType> mapper = new ParameterizedRowMapper<ExpandedConceptType>() {
        public ExpandedConceptType mapRow(ResultSet rs, int rowNum) throws SQLException {
            ExpandedConceptType entry = new ExpandedConceptType();
            //TODO fix this for all/+blob

            entry.setName(rs.getString("c_name"));
            entry.setTableCd(rs.getString("tablecd"));
            if (vocabType.getType().equals("core")) {
                entry.setKey(rs.getString("c_fullname"));
                entry.setBasecode(rs.getString("c_basecode"));
                entry.setLevel(rs.getInt("c_hlevel"));
                entry.setSynonymCd(rs.getString("c_synonym_cd"));
                entry.setVisualattributes(rs.getString("c_visualattributes"));
                Integer totalNum = rs.getInt("c_totalnum");
                if (obfuscatedUserFlag == false) {
                    entry.setTotalnum(totalNum);
                }
                entry.setFacttablecolumn(rs.getString("c_facttablecolumn"));
                entry.setTablename(rs.getString("c_tablename"));
                entry.setColumnname(rs.getString("c_columnname"));
                entry.setColumndatatype(rs.getString("c_columndatatype"));
                entry.setOperator(rs.getString("c_operator"));
                entry.setDimcode(rs.getString("c_dimcode"));
                entry.setTooltip(rs.getString("c_tooltip"));

            }

            if ((vocabType.getType().equals("all"))) {
                DTOFactory factory = new DTOFactory();
                // make sure date isnt null before converting to XMLGregorianCalendar
                Date date = rs.getDate("update_date");
                if (date == null)
                    entry.setUpdateDate(null);
                else
                    entry.setUpdateDate(factory.getXMLGregorianCalendar(date.getTime()));

                date = rs.getDate("download_date");
                if (date == null)
                    entry.setDownloadDate(null);
                else
                    entry.setDownloadDate(factory.getXMLGregorianCalendar(date.getTime()));

                date = rs.getDate("import_date");
                if (date == null)
                    entry.setImportDate(null);
                else
                    entry.setImportDate(factory.getXMLGregorianCalendar(date.getTime()));

                entry.setSourcesystemCd(rs.getString("sourcesystem_cd"));
                entry.setValuetypeCd(rs.getString("valuetype_cd"));
            }

            return entry;
        }
    };

    List queryResult = null;
    try {
        if (tableNames != null)
            queryResult = jt.query(codeInfoSql, mapper);
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        throw e;
    }
    log.debug("result size = " + queryResult.size());

    if (queryResult != null) {
        if (parameters != DEFAULT) {
            //             fix the key so it equals "\\tableCd\fullname"
            //  in all cases but default
            Iterator it = queryResult.iterator();
            while (it.hasNext()) {
                ExpandedConceptType entry = (ExpandedConceptType) it.next();
                entry.setKey("\\\\" + entry.getTableCd() + entry.getKey());
            }
        }

        // Cant gather clobs when you perform unions....
        //  So you have to loop through all the results and gather clobs         
        if (vocabType.isBlob() == true) {
            Iterator itr = queryResult.iterator();
            while (itr.hasNext()) {
                ConceptType child = (ConceptType) itr.next();
                Iterator it = tableNames.iterator();
                while (it.hasNext()) {
                    String clobSql = "select c_metadataxml, c_comment from " + metadataSchema
                            + (String) it.next() + " where c_name = ? and " + synonym;
                    ParameterizedRowMapper<ConceptType> map = new ParameterizedRowMapper<ConceptType>() {
                        public ConceptType mapRow(ResultSet rs, int rowNum) throws SQLException {
                            ConceptType concept = new ConceptType();
                            try {
                                if (rs.getClob("c_metadataxml") == null) {
                                    concept.setMetadataxml(null);
                                } else {
                                    String c_xml = JDBCUtil.getClobString(rs.getClob("c_metadataxml"));
                                    if ((c_xml != null) && (c_xml.trim().length() > 0)
                                            && (!c_xml.equals("(null)"))) {
                                        SAXBuilder parser = new SAXBuilder();
                                        java.io.StringReader xmlStringReader = new java.io.StringReader(c_xml);
                                        Element rootElement = null;
                                        try {
                                            org.jdom.Document metadataDoc = parser.build(xmlStringReader);
                                            org.jdom.output.DOMOutputter out = new DOMOutputter();
                                            Document doc = out.output(metadataDoc);
                                            rootElement = doc.getDocumentElement();
                                        } catch (JDOMException e) {
                                            log.error(e.getMessage());
                                            concept.setMetadataxml(null);
                                        }
                                        if (rootElement != null) {
                                            XmlValueType xml = new XmlValueType();
                                            xml.getAny().add(rootElement);
                                            concept.setMetadataxml(xml);
                                        }
                                    } else {
                                        concept.setMetadataxml(null);
                                    }
                                }
                            } catch (IOException e) {
                                log.error(e.getMessage());
                                concept.setMetadataxml(null);
                            }
                            try {
                                if (rs.getClob("c_comment") == null) {
                                    concept.setComment(null);
                                } else {
                                    concept.setComment(JDBCUtil.getClobString(rs.getClob("c_comment")));
                                }

                            } catch (IOException e) {
                                log.error(e.getMessage());
                                concept.setComment(null);
                            }
                            return concept;
                        }

                    };
                    List clobResult = null;
                    try {
                        clobResult = jt.query(clobSql, map, child.getName(), child.getTooltip());
                    } catch (DataAccessException e) {
                        log.error(e.getMessage());
                        throw e;
                    }
                    if (clobResult != null) {
                        if ((((ConceptType) (clobResult.get(0))).getMetadataxml() != null)
                                || (((ConceptType) (clobResult.get(0))).getComment() != null)) {

                            child.setMetadataxml(((ConceptType) (clobResult.get(0))).getMetadataxml());
                            child.setComment(((ConceptType) (clobResult.get(0))).getComment());
                            break;
                        }
                    } else {
                        child.setMetadataxml(null);
                        child.setComment(null);
                    }
                }
            }
        }
    }
    return queryResult;

}

From source file:ProcessRequest.java

public void parseQueryResults(ResultSet rs, String table, OutputStream os, boolean append)
        throws SQLException, JSONException, IOException {
    //JSONArray resultJSONArray = new JSONArray();
    ResultSetMetaData rsmd = rs.getMetaData();
    int columns = rsmd.getColumnCount();
    rs.last();/* www  . j  a v  a 2s  .co m*/
    int rows = rs.getRow();
    os.write(new String("total rows: " + rows).getBytes());
    rs.first();
    int rowCount = 0;
    while (rs.next()) {
        if (!rs.isFirst() || append) {
            os.write(new String(",\n").getBytes());
            os.write(new String("" + rowCount).getBytes());
        }
        if (rowCount >= 69)
            System.out.println("break point");
        rowCount++;
        JSONObject result = new JSONObject();
        JSONObject resultMeta = new JSONObject();
        resultMeta.put("table", table);
        result.put("metadata", resultMeta);
        for (int i = 1; i <= columns; i++) {
            //out.println("<td>"+rs.getString(i)+"</td>");
            int type = rsmd.getColumnType(i);
            //result.put(rsmd.getColumnName(i), rs.get)
            switch (type) {
            case Types.BIT:
                result.put(rsmd.getColumnName(i), rs.getBoolean(i));
                break;
            case Types.TINYINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.SMALLINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.INTEGER:
                //System.out.println(rsmd.getColumnName(i) + "  type: "+type);
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.BIGINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.FLOAT:
                result.put(rsmd.getColumnName(i), rs.getFloat(i));
                break;
            case Types.REAL:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.DOUBLE:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.NUMERIC:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.DECIMAL:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.CHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.VARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.LONGVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.DATE: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }
            case Types.TIME: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }
            case Types.TIMESTAMP: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }
            case Types.BINARY:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.VARBINARY:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.LONGVARBINARY:
                result.put(rsmd.getColumnName(i), rs.getLong(i));
                break;
            case Types.NULL:
                result.put(rsmd.getColumnName(i), "");
                break;
            case Types.BOOLEAN:
                result.put(rsmd.getColumnName(i), rs.getBoolean(i));
                break;
            case Types.ROWID:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.NCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.NVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.LONGNVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.SQLXML:
            case Types.NCLOB:
            case Types.DATALINK:
            case Types.REF:
            case Types.OTHER:
            case Types.JAVA_OBJECT:
            case Types.DISTINCT:
            case Types.STRUCT:
            case Types.ARRAY:
            case Types.BLOB:
            case Types.CLOB:
            default:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            }
        }
        //if(table.equals("Ticket"))
        //System.out.println(result.toString(5));
        //if(result.getInt("TicketNumber")==126868)
        //   System.out.println("break point");
        //resultJSONArray.put(result);
        os.write(result.toString(5).getBytes());
    }
    //return resultJSONArray;
}

From source file:edu.harvard.i2b2.ontology.dao.GetTermInfoDao.java

public List findByFullname(final GetTermInfoType termInfoType, List categories, ProjectType projectInfo,
        final String dbType) throws DataAccessException {
    DataSource ds = null;//  w w w .  j  a va  2s. c o  m
    try {
        ds = OntologyUtil.getInstance().getDataSource("java:OntologyLocalDS");
    } catch (I2B2Exception e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    SimpleJdbcTemplate jt = new SimpleJdbcTemplate(ds);

    // find return parameters
    String parameters = DEFAULT;
    if (termInfoType.getType().equals("core")) {
        parameters = CORE;
    } else if (termInfoType.getType().equals("all")) {
        parameters = ALL;
    }
    if (termInfoType.isBlob() == true)
        parameters = parameters + BLOB;

    //extract table code
    String tableCd = StringUtil.getTableCd(termInfoType.getSelf());

    // table code to table name conversion
    // Get metadata schema name from properties file.
    String metadataSchema = "";
    try {
        metadataSchema = OntologyUtil.getInstance().getMetaDataSchemaName();
    } catch (I2B2Exception e1) {
        log.error(e1.getMessage());
    }

    // table code to table name conversion
    String tableSql = "select distinct(c_table_name) from " + metadataSchema
            + "table_access where c_table_cd = ? ";
    ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() {
        public String mapRow(ResultSet rs, int rowNum) throws SQLException {
            String name = (rs.getString("c_table_name"));
            return name;
        }
    };

    String tableName = jt.queryForObject(tableSql, map, tableCd);

    String path = StringUtil.getPath(termInfoType.getSelf());

    //         if(path.equals("\\Providers"))
    //            path="\\RPDR\\Providers";

    String searchPath = path;

    String hidden = "";
    if (termInfoType.isHiddens() == false)
        hidden = " and c_visualattributes not like '_H%'";

    String synonym = "";
    if (termInfoType.isSynonyms() == false)
        synonym = " and c_synonym_cd = 'N'";

    String sql = "select " + parameters + " from " + metadataSchema + tableName + " where c_fullname like ? ";
    sql = sql + hidden + synonym + " order by c_name ";

    //   log.info(sql + path + level);
    final boolean obfuscatedUserFlag = Roles.getInstance().isRoleOfuscated(projectInfo);

    ParameterizedRowMapper<ConceptType> mapper = new ParameterizedRowMapper<ConceptType>() {
        public ConceptType mapRow(ResultSet rs, int rowNum) throws SQLException {
            ConceptType self = new ConceptType();
            self.setName(rs.getString("c_name"));
            self.setBasecode(rs.getString("c_basecode"));
            self.setLevel(rs.getInt("c_hlevel"));
            self.setKey(rs.getString("c_fullname"));
            self.setSynonymCd(rs.getString("c_synonym_cd"));
            self.setVisualattributes(rs.getString("c_visualattributes"));

            Integer totalNum = rs.getInt("c_totalnum");
            if (obfuscatedUserFlag == false) {
                self.setTotalnum(totalNum);
            }
            self.setFacttablecolumn(rs.getString("c_facttablecolumn"));
            self.setTablename(rs.getString("c_tablename"));
            self.setColumnname(rs.getString("c_columnname"));
            self.setColumndatatype(rs.getString("c_columndatatype"));
            self.setOperator(rs.getString("c_operator"));
            self.setDimcode(rs.getString("c_dimcode"));
            self.setTooltip(rs.getString("c_tooltip"));
            if (termInfoType.isBlob() == true) {
                if (rs.getClob("c_comment") == null)
                    self.setComment(null);
                else {
                    try {
                        if (dbType.equals("POSTGRESQL"))
                            self.setComment(rs.getString("c_comment"));
                        else
                            self.setComment(JDBCUtil.getClobString(rs.getClob("c_comment")));
                    } catch (IOException e1) {
                        log.error(e1.getMessage());
                        self.setComment(null);
                    }
                }
                if (rs.getClob("c_metadataxml") == null) {
                    self.setMetadataxml(null);
                } else {
                    String c_xml = null;
                    try {
                        if (dbType.equals("POSTGRESQL"))
                            c_xml = rs.getString("c_metadataxml");
                        else
                            c_xml = JDBCUtil.getClobString(rs.getClob("c_metadataxml"));
                    } catch (IOException e1) {
                        log.error(e1.getMessage());
                        self.setMetadataxml(null);
                    }
                    if ((c_xml != null) && (c_xml.trim().length() > 0) && (!c_xml.equals("(null)"))) {
                        SAXBuilder parser = new SAXBuilder();
                        java.io.StringReader xmlStringReader = new java.io.StringReader(c_xml);
                        Element rootElement = null;
                        try {
                            org.jdom.Document metadataDoc = parser.build(xmlStringReader);
                            org.jdom.output.DOMOutputter out = new DOMOutputter();
                            Document doc = out.output(metadataDoc);
                            rootElement = doc.getDocumentElement();
                        } catch (JDOMException e) {
                            log.error(e.getMessage());
                            self.setMetadataxml(null);
                        } catch (IOException e1) {
                            log.error(e1.getMessage());
                            self.setMetadataxml(null);
                        }
                        if (rootElement != null) {
                            XmlValueType xml = new XmlValueType();
                            xml.getAny().add(rootElement);
                            self.setMetadataxml(xml);
                        }

                    } else {
                        self.setMetadataxml(null);
                    }
                }
            }
            if ((termInfoType.getType().equals("all"))) {
                DTOFactory factory = new DTOFactory();
                // make sure date isnt null before converting to XMLGregorianCalendar
                Date date = rs.getDate("update_date");
                if (date == null)
                    self.setUpdateDate(null);
                else
                    self.setUpdateDate(factory.getXMLGregorianCalendar(date.getTime()));

                date = rs.getDate("download_date");
                if (date == null)
                    self.setDownloadDate(null);
                else
                    self.setDownloadDate(factory.getXMLGregorianCalendar(date.getTime()));

                date = rs.getDate("import_date");
                if (date == null)
                    self.setImportDate(null);
                else
                    self.setImportDate(factory.getXMLGregorianCalendar(date.getTime()));

                self.setSourcesystemCd(rs.getString("sourcesystem_cd"));
                self.setValuetypeCd(rs.getString("valuetype_cd"));
            }
            return self;
        }
    };

    //   log.info(sql + " " + path + " " + level);

    List queryResult = null;
    try {
        queryResult = jt.query(sql, mapper, searchPath);
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        throw e;
    }
    log.debug("result size = " + queryResult.size());

    //Fix the key so it equals "\\tableCd\fullname"
    if (queryResult != null) {
        Iterator itr = queryResult.iterator();
        while (itr.hasNext()) {
            ConceptType self = (ConceptType) itr.next();
            self.setKey("\\\\" + tableCd + self.getKey());
        }
    }
    return queryResult;
}

From source file:com.wso2telco.dep.reportingservice.dao.BillingDAO.java

/**
 * Gets the error response codes for histogram.
 *
 * @param fromDate the from date/*w w w.ja  v a  2  s  . c  o  m*/
 * @param toDate the to date
 * @param subscriber the subscriber
 * @param operator the operator
 * @param applicationId the application id
 * @param api the api
 * @return the error response codes for histogram
 * @throws Exception the exception
 */
public List<String[]> getErrorResponseCodesForHistogram(String fromDate, String toDate, String subscriber,
        String operator, int applicationId, String api) throws Exception {
    String consumerKey = null;
    if (subscriber.equals("__ALL__")) {
        subscriber = "%";
    }
    if (operator.equals("__ALL__")) {
        operator = "%";
    }
    if (applicationId == 0) {
        consumerKey = "%";
    } else {
        consumerKey = apiManagerDAO.getConsumerKeyByApplication(applicationId);
    }
    if (api.equals("__ALL__")) {
        api = "%";
    }

    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet results = null;
    StringBuilder sql = new StringBuilder();

    sql.append("select a.exceptionId, a.Date, IFNULL(b.HITS,0) HITS ")
            .append("from (select IFNULL(aa.exceptionId, 'SVC1000') exceptionId, a.Date from ")
            .append(ReportingTable.SB_API_RESPONSE_SUMMARY.getTObject())
            .append(" aa cross join (select DATE(?) - INTERVAL (a.a + (10 * b.a) + (100 * c.a)) DAY as Date ")
            .append("from (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as a ")
            .append("cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as b ")
            .append("cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c ) a ")
            .append("where a.Date between ? and ? AND aa.responseCode NOT IN ('200' , '201', '202', '204') group by a.date, exceptionId) a ")
            .append("left join (SELECT IFNULL(exceptionId,'SVC1000') exceptionId, SUM(response_count) HITS, time FROM ")
            .append(ReportingTable.SB_API_RESPONSE_SUMMARY.getTObject())
            .append(" WHERE DATE(time) between DATE(?) and DATE(?) AND operatorId LIKE ? AND userId LIKE ? AND API LIKE ? AND consumerKey LIKE ? ")
            .append("AND responseCode NOT IN ('200' , '201', '202', '204') ")
            .append("GROUP BY exceptionId, DATE(time)) b on (a.Date = DATE(b.time) and a.exceptionId = b.exceptionId)");

    List<String[]> api_response_codes = new ArrayList<String[]>();

    try {
        conn = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB);
        ps = conn.prepareStatement(sql.toString());
        ps.setString(1, toDate);
        ps.setString(2, fromDate);
        ps.setString(3, toDate);
        ps.setString(4, fromDate);
        ps.setString(5, toDate);
        ps.setString(6, operator);
        ps.setString(7, subscriber);
        ps.setString(8, api);
        ps.setString(9, consumerKey);
        log.debug("getErrorResponseCodesForHistogram");
        results = ps.executeQuery();
        while (results.next()) {
            String[] temp = { results.getString(1), results.getDate(2).toString(), results.getString(3) };
            api_response_codes.add(temp);
        }
    } catch (Exception e) {
        handleException("getErrorResponseCodesForHistogram", e);
    } finally {
        DbUtils.closeAllConnections(ps, conn, results);
    }
    return api_response_codes;
}

From source file:edu.harvard.i2b2.ontology.dao.GetChildrenDao.java

public List findChildrenByParent(final GetChildrenType childrenType, final List categories,
        final ProjectType projectInfo) throws DataAccessException {

    DataSource ds = null;//from   w ww. jav  a 2  s .c  o m
    try {
        ds = OntologyUtil.getInstance().getDataSource("java:OntologyLocalDS");
    } catch (I2B2Exception e2) {
        log.error(e2.getMessage());
    }

    SimpleJdbcTemplate jt = new SimpleJdbcTemplate(ds);

    // find return parameters
    String parameters = DEFAULT;
    if (childrenType.getType().equals("core")) {
        parameters = CORE;
    } else if (childrenType.getType().equals("all")) {
        parameters = ALL;
    }
    if (childrenType.isBlob() == true)
        parameters = parameters + BLOB;

    //extract table code
    String tableCd = StringUtil.getTableCd(childrenType.getParent());

    // table code to table name conversion
    // Get metadata schema name from properties file.
    String metadataSchema = "";
    try {
        metadataSchema = OntologyUtil.getInstance().getMetaDataSchemaName();
    } catch (I2B2Exception e1) {
        log.error(e1.getMessage());
    }

    String tableSql = "select distinct(c_table_name) from " + metadataSchema
            + "table_access where c_table_cd = ? ";
    ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() {
        public String mapRow(ResultSet rs, int rowNum) throws SQLException {
            String name = (rs.getString("c_table_name"));
            return name;
        }
    };

    String tableName = jt.queryForObject(tableSql, map, tableCd);
    String path = StringUtil.getPath(childrenType.getParent());
    String searchPath = path + "%";

    // Lookup to get chlevel + 1 ---  dont allow synonyms so we only get one result back

    String levelSql = "select c_hlevel from " + metadataSchema + tableName
            + " where c_fullname like ?  and c_synonym_cd = 'N'";

    int level = 0;
    try {
        level = jt.queryForInt(levelSql, path);
    } catch (DataAccessException e1) {
        // should only get 1 result back  (path == c_fullname which should be unique)
        log.error(e1.getMessage());
        throw e1;
    }

    String hidden = "";
    if (childrenType.isHiddens() == false)
        hidden = " and c_visualattributes not like '_H%'";

    String synonym = "";
    if (childrenType.isSynonyms() == false)
        synonym = " and c_synonym_cd = 'N'";

    String sql = "select " + parameters + " from " + metadataSchema + tableName
            + " where c_fullname like ? and c_hlevel = ? ";
    sql = sql + hidden + synonym + " order by c_name ";

    //   log.info(sql + path + level);
    final boolean obfuscatedUserFlag = Roles.getInstance().isRoleOfuscated(projectInfo);

    ParameterizedRowMapper<ConceptType> mapper = new ParameterizedRowMapper<ConceptType>() {
        public ConceptType mapRow(ResultSet rs, int rowNum) throws SQLException {
            ConceptType child = new ConceptType();
            child.setName(rs.getString("c_name"));
            child.setBasecode(rs.getString("c_basecode"));
            child.setLevel(rs.getInt("c_hlevel"));
            child.setKey(rs.getString("c_fullname"));
            child.setSynonymCd(rs.getString("c_synonym_cd"));
            child.setVisualattributes(rs.getString("c_visualattributes"));
            Integer totalNum = rs.getInt("c_totalnum");
            if (obfuscatedUserFlag == false) {
                child.setTotalnum(totalNum);
            }
            child.setFacttablecolumn(rs.getString("c_facttablecolumn"));
            child.setTablename(rs.getString("c_tablename"));
            child.setColumnname(rs.getString("c_columnname"));
            child.setColumndatatype(rs.getString("c_columndatatype"));
            child.setOperator(rs.getString("c_operator"));
            child.setDimcode(rs.getString("c_dimcode"));
            child.setTooltip(rs.getString("c_tooltip"));
            if (childrenType.isBlob() == true) {
                try {
                    if (rs.getClob("c_comment") == null)
                        child.setComment(null);
                    else
                        child.setComment(JDBCUtil.getClobString(rs.getClob("c_comment")));
                } catch (IOException e) {
                    log.error(e.getMessage());
                    child.setComment(null);
                }

                if (rs.getClob("c_metadataxml") == null) {
                    child.setMetadataxml(null);
                } else {
                    String c_xml = null;
                    try {
                        c_xml = JDBCUtil.getClobString(rs.getClob("c_metadataxml"));
                    } catch (IOException e) {
                        log.error(e.getMessage());
                        child.setMetadataxml(null);
                    }
                    if ((c_xml != null) && (c_xml.trim().length() > 0) && (!c_xml.equals("(null)"))) {
                        SAXBuilder parser = new SAXBuilder();
                        java.io.StringReader xmlStringReader = new java.io.StringReader(c_xml);
                        Element rootElement = null;
                        try {
                            org.jdom.Document metadataDoc = parser.build(xmlStringReader);
                            org.jdom.output.DOMOutputter out = new DOMOutputter();
                            Document doc = out.output(metadataDoc);
                            rootElement = doc.getDocumentElement();
                        } catch (JDOMException e) {
                            log.error(e.getMessage());
                            child.setMetadataxml(null);
                        } catch (IOException e1) {
                            log.error(e1.getMessage());
                            child.setMetadataxml(null);
                        }
                        if (rootElement != null) {
                            XmlValueType xml = new XmlValueType();
                            xml.getAny().add(rootElement);
                            child.setMetadataxml(xml);
                        }
                    } else {
                        child.setMetadataxml(null);
                    }
                }

            }
            if ((childrenType.getType().equals("all"))) {
                DTOFactory factory = new DTOFactory();
                // make sure date isnt null before converting to XMLGregorianCalendar
                Date date = rs.getDate("update_date");
                if (date == null)
                    child.setUpdateDate(null);
                else
                    child.setUpdateDate(factory.getXMLGregorianCalendar(date.getTime()));

                date = rs.getDate("download_date");
                if (date == null)
                    child.setDownloadDate(null);
                else
                    child.setDownloadDate(factory.getXMLGregorianCalendar(date.getTime()));

                date = rs.getDate("import_date");
                if (date == null)
                    child.setImportDate(null);
                else
                    child.setImportDate(factory.getXMLGregorianCalendar(date.getTime()));

                child.setSourcesystemCd(rs.getString("sourcesystem_cd"));
                child.setValuetypeCd(rs.getString("valuetype_cd"));
            }
            return child;
        }
    };

    //log.info(sql + " " + path + " " + level);

    List queryResult = null;
    try {
        queryResult = jt.query(sql, mapper, searchPath, (level + 1));
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        throw e;
    }
    log.debug("result size = " + queryResult.size());

    //      Fix the key so it equals "\\tableCd\fullname"
    if (queryResult != null) {
        Iterator it = queryResult.iterator();
        while (it.hasNext()) {
            ConceptType child = (ConceptType) it.next();
            child.setKey("\\\\" + tableCd + child.getKey());
        }
    }

    return queryResult;
    // tested statement with aqua data studio   verified output from above against this. 
    // select  c_fullname, c_name, c_synonym_cd, c_visualattributes  from metadata.testrpdr 
    // where c_fullname like '\RPDR\Diagnoses\Circulatory system (390-459)\Arterial vascular disease (440-447)\(446) Polyarteritis nodosa and al%' 
    // and c_hlevel = 5  and c_visualattributes not like '_H%' and c_synonym_cd = 'N'

    // verified both with and without hiddens and synonyms.

    // clob test   level = 4
    //   <parent>\\testrpdr\RPDR\HealthHistory\PHY\Health Maintenance\Mammogram\Mammogram - Deferred</parent> 
}

From source file:com.mimp.hibernate.HiberEtapa.java

public ArrayList<EstudioCaso> listaExpedientesDeEstudio(String orden) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//from   w  ww  .  ja  v  a 2s  .  c  om

    final String identificador = orden;
    final ArrayList<EstudioCaso> listaEstudios = new ArrayList();

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call HE_ESTUDIO_EXPFAM(?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setString(1, identificador);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.execute();

            ResultSet rs = (ResultSet) statement.getObject(2);

            while (rs.next()) {
                EstudioCaso estTemp = new EstudioCaso();
                ExpedienteFamilia tempExp = new ExpedienteFamilia();
                estTemp.setIdestudioCaso(rs.getLong("IDESTUDIO_CASO"));
                tempExp.setIdexpedienteFamilia(rs.getLong("IDEXPEDIENTE_FAMILIA"));
                estTemp.setOrden(rs.getString("ORDEN"));
                estTemp.setFechaEstudio(rs.getDate("FECHA_ESTUDIO"));
                estTemp.setFechaSolAdop(rs.getDate("FECHA_SOL_ADOP"));
                estTemp.setResultado(rs.getString("RESULTADO"));
                estTemp.setPrioridad(rs.getLong("PRIORIDAD"));
                estTemp.setNSolicitud(rs.getLong("N_SOLICITUD"));
                String hql2 = "{call HE_GET_EXPEDIENTE_FAMILIA(?, ?)}";
                CallableStatement statement2 = connection.prepareCall(hql2);
                statement2.setLong(1, rs.getLong("IDEXPEDIENTE_FAMILIA"));
                statement2.registerOutParameter(2, OracleTypes.CURSOR);
                statement2.execute();
                ResultSet rs2 = (ResultSet) statement2.getObject(2);
                if (rs2.next()) {
                    tempExp.setExpediente(rs2.getString(5));
                }
                rs2.close();
                statement2.close();
                estTemp.setExpedienteFamilia(tempExp);
                listaEstudios.add(estTemp);
            }
            rs.close();
            statement.close();
        }
    };

    session.doWork(work);

    return listaEstudios;
}

From source file:com.mimp.hibernate.HiberEtapa.java

public Evaluacion getLegal(long id) {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();//  www.ja v a 2s.c o m
    final Long idE = id;
    final Evaluacion tempEval = new Evaluacion();

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call HE_GET_LEGAL(?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setLong(1, idE);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.execute();

            ResultSet rs = (ResultSet) statement.getObject(2);

            if (rs.next()) {
                ExpedienteFamilia tempEF = new ExpedienteFamilia();
                Personal temPersonal = new Personal();
                Set<Resolucion> listaRe = new HashSet<Resolucion>();

                tempEval.setIdevaluacion(rs.getLong("IDEVALUACION"));
                tempEval.setTipo(rs.getString("TIPO"));
                tempEval.setFechaAsignacion(rs.getDate("FECHA_ASIGNACION"));
                tempEval.setResultado(rs.getString("RESULTADO"));
                tempEval.setFechaResultado(rs.getDate("FECHA_RESULTADO"));
                tempEval.setObservacion(rs.getString("OBSERVACION"));
                tempEval.setSustento(rs.getString("SUSTENTO"));
                tempEval.setNDesignacion(rs.getString("N_DESIGNACION"));
                tempEval.setNumEval(rs.getString("NUM_EVAL"));

                tempEF.setIdexpedienteFamilia(rs.getLong("IDEXPEDIENTE_FAMILIA"));
                tempEF.setExpediente(rs.getString("EXPEDIENTE"));
                tempEF.setHt(rs.getString("HT"));
                tempEF.setNumeroExpediente(rs.getString("NUMERO_EXPEDIENTE"));
                tempEF.setFechaIngresoDga(rs.getDate("FECHA_INGRESO_DGA"));
                tempEF.setEstado(rs.getString("ESTADO"));
                tempEF.setTupa(rs.getDate("TUPA"));
                tempEF.setNacionalidad(rs.getString("NACIONALIDAD"));
                tempEF.setRnsa(rs.getShort("RNSA"));
                tempEF.setRnaa(rs.getShort("RNAA"));
                tempEF.setTipoFamilia(rs.getString("TIPO_FAMILIA"));
                tempEF.setTipoListaEspera(rs.getString("TIPO_LISTA_ESPERA"));
                tempEF.setHtFicha(rs.getString("HTFICHA"));
                tempEF.setnFicha(rs.getString("NFICHA"));
                tempEF.setFechaIngresoFicha(rs.getDate("FECHA_INGRESO_FICHA"));

                temPersonal.setIdpersonal(rs.getLong("IDPERSONAL"));

                tempEval.setPersonal(temPersonal);
                tempEval.setExpedienteFamilia(tempEF);

                String hql2 = "{call HE_LISTA_RESOL_LEGAL(?,?)}";
                CallableStatement statement2 = connection.prepareCall(hql2);
                statement2.setLong(1, tempEval.getIdevaluacion());
                statement2.registerOutParameter(2, OracleTypes.CURSOR);
                statement2.execute();

                ResultSet rs2 = (ResultSet) statement2.getObject(2);

                while (rs2.next()) {
                    Resolucion tempRe = new Resolucion();
                    tempRe.setIdresolucion(rs2.getLong("IDRESOLUCION"));
                    tempRe.setTipo(rs2.getString("TIPO"));
                    tempRe.setNumero(rs2.getString("NUMERO"));
                    tempRe.setFechaResol(rs2.getDate("FECHA_RESOL"));
                    tempRe.setFechaNotificacion(rs2.getDate("FECHA_NOTIFICACION"));
                    tempRe.setEvaluacion(tempEval);
                    listaRe.add(tempRe);

                }
                rs2.close();
                statement2.close();

                tempEval.setResolucions(listaRe);

            }
            rs.close();
            statement.close();
        }
    };

    session.doWork(work);

    return tempEval;

}

From source file:com.mimp.hibernate.HiberEtapa.java

public ArrayList<ExpedienteFamilia> getListaEspera() {

    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();/*from  w ww . j  a  v  a  2s.  c o  m*/

    final ArrayList<ExpedienteFamilia> allEspera = new ArrayList();

    Work work = new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {

            String hql = "{call HE_GET_LISTA_ESPERA(?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.registerOutParameter(1, OracleTypes.CURSOR);
            statement.execute();

            temp_expediente = (ResultSet) statement.getObject(1);

            while (temp_expediente.next()) {
                ExpedienteFamilia expFamilia = new ExpedienteFamilia();
                Familia fam = new Familia();
                Unidad unidad = new Unidad();
                Personal personal = new Personal();

                expFamilia.setIdexpedienteFamilia(temp_expediente.getLong(1));
                if (temp_expediente.getLong(2) != 0) {

                    String hql2 = "{call HE_GETFAMILIA(?, ?)}";
                    CallableStatement statement2 = connection.prepareCall(hql2);
                    statement2.setLong(1, temp_expediente.getLong(2));
                    statement2.registerOutParameter(2, OracleTypes.CURSOR);
                    statement2.execute();
                    temp2 = (ResultSet) statement2.getObject(2);
                    while (temp2.next()) {
                        fam.setIdfamilia(temp2.getLong(1));
                        expFamilia.setFamilia(fam);
                    }
                    temp2.close();
                    statement2.close();
                }
                if (temp_expediente.getLong(3) != 0) {

                    String hql3 = "{call HE_GET_UNIDAD(?, ?)}";
                    CallableStatement statement3 = connection.prepareCall(hql3);
                    statement3.setLong(1, temp_expediente.getLong(3));
                    statement3.registerOutParameter(2, OracleTypes.CURSOR);
                    statement3.execute();
                    temp2 = (ResultSet) statement3.getObject(2);
                    while (temp2.next()) {
                        unidad.setIdunidad(temp2.getLong(1));
                        unidad.setDepartamento(temp2.getString("DEPARTAMENTO"));
                        expFamilia.setUnidad(unidad);
                    }
                    temp2.close();
                    statement3.close();
                }
                expFamilia.setNumero(temp_expediente.getLong(4));
                expFamilia.setExpediente(temp_expediente.getString(5));
                expFamilia.setHt(temp_expediente.getString(6));
                expFamilia.setNumeroExpediente(temp_expediente.getString(7));
                expFamilia.setFechaIngresoDga(temp_expediente.getDate(8));
                expFamilia.setEstado(temp_expediente.getString(9));
                expFamilia.setTupa(temp_expediente.getDate(10));
                expFamilia.setNacionalidad(temp_expediente.getString(11));
                expFamilia.setRnsa(temp_expediente.getShort(12));
                expFamilia.setRnaa(temp_expediente.getShort(13));
                expFamilia.setTipoFamilia(temp_expediente.getString(14));
                expFamilia.setTipoListaEspera(temp_expediente.getString(15));
                expFamilia.setHtFicha(temp_expediente.getString(16));
                expFamilia.setnFicha(temp_expediente.getString(17));
                expFamilia.setFechaIngresoFicha(temp_expediente.getDate(18));

                Set<Evaluacion> listaEv = new HashSet<Evaluacion>();

                String hql2 = "{call HE_GET_LISTA_EVALUACIONES(?,?)}";
                CallableStatement statement2 = connection.prepareCall(hql2);
                statement2.setLong(1, expFamilia.getIdexpedienteFamilia());
                statement2.registerOutParameter(2, OracleTypes.CURSOR);
                statement2.execute();

                ResultSet rs2 = (ResultSet) statement2.getObject(2);

                while (rs2.next()) {
                    Evaluacion tempEval = new Evaluacion();
                    tempEval.setIdevaluacion(rs2.getLong("IDEVALUACION"));
                    tempEval.setExpedienteFamilia(expFamilia);

                    tempEval.setTipo(rs2.getString("TIPO"));
                    tempEval.setFechaAsignacion(rs2.getDate("FECHA_ASIGNACION"));
                    tempEval.setResultado(rs2.getString("RESULTADO"));
                    tempEval.setFechaResultado(rs2.getDate("FECHA_RESULTADO"));
                    tempEval.setObservacion(rs2.getString("OBSERVACION"));
                    tempEval.setSustento(rs2.getString("SUSTENTO"));
                    tempEval.setNDesignacion(rs2.getString("N_DESIGNACION"));
                    tempEval.setNumEval(rs2.getString("NUM_EVAL"));
                    Set<Resolucion> listaRe = new HashSet<Resolucion>();

                    if (tempEval.getTipo().equals("legal")) {

                        String hql3 = "{call HE_GET_RESOLUCION_APTA(?,?)}";
                        CallableStatement statement3 = connection.prepareCall(hql3);
                        statement3.setLong(1, tempEval.getIdevaluacion());
                        statement3.registerOutParameter(2, OracleTypes.CURSOR);
                        statement3.execute();

                        ResultSet rs3 = (ResultSet) statement3.getObject(2);

                        if (rs3.next()) {
                            Resolucion tempResol = new Resolucion();
                            tempResol.setIdresolucion(rs3.getLong("IDRESOLUCION"));
                            tempResol.setTipo(rs3.getString("TIPO"));
                            tempResol.setNumero(rs3.getString("NUMERO"));
                            tempResol.setFechaResol(rs3.getDate("FECHA_RESOL"));
                            tempResol.setFechaNotificacion(rs3.getDate("FECHA_NOTIFICACION"));
                            tempResol.setEvaluacion(tempEval);

                            listaRe.add(tempResol);

                        }
                        rs3.close();
                        statement3.close();

                    }

                    tempEval.setResolucions(listaRe);
                    listaEv.add(tempEval);

                }
                rs2.close();
                statement2.close();

                expFamilia.setEvaluacions(listaEv);
                allEspera.add(expFamilia);
            }
            temp_expediente.close();
            statement.close();
        }
    };

    session.doWork(work);

    return allEspera;
}