List of usage examples for java.sql ResultSet getShort
short getShort(String columnLabel) throws SQLException;
ResultSet
object as a short
in the Java programming language. From source file:eionet.meta.dao.mysql.VocabularyFolderDAOImpl.java
/** * {@inheritDoc}//from ww w. j a v a 2 s . c o m */ @Override public List<VocabularyFolder> getVocabularyFolders(String userName) { Map<String, Object> params = new HashMap<String, Object>(); StringBuilder sql = new StringBuilder(); sql.append( "select v.VOCABULARY_ID, v.IDENTIFIER, v.LABEL, v.REG_STATUS, v.WORKING_COPY, v.BASE_URI, v.VOCABULARY_TYPE, "); sql.append("v.WORKING_USER, v.DATE_MODIFIED, v.USER_MODIFIED, v.CHECKEDOUT_COPY_ID, v.CONTINUITY_ID, "); sql.append("v.CONCEPT_IDENTIFIER_NUMERIC, "); sql.append("f.ID, f.IDENTIFIER, f.LABEL, v.NOTATIONS_EQUAL_IDENTIFIERS "); sql.append("from VOCABULARY v "); sql.append("left join VOCABULARY_SET f on f.ID=v.FOLDER_ID "); sql.append("where "); if (StringUtils.isBlank(userName)) { sql.append("v.WORKING_COPY=FALSE "); } else { sql.append("(v.WORKING_COPY=FALSE or v.WORKING_USER=:workingUser) "); params.put("workingUser", userName); } sql.append("order by f.IDENTIFIER, v.IDENTIFIER "); List<VocabularyFolder> items = getNamedParameterJdbcTemplate().query(sql.toString(), params, new RowMapper<VocabularyFolder>() { @Override public VocabularyFolder mapRow(ResultSet rs, int rowNum) throws SQLException { VocabularyFolder vf = new VocabularyFolder(); vf.setId(rs.getInt("v.VOCABULARY_ID")); vf.setIdentifier(rs.getString("v.IDENTIFIER")); vf.setLabel(rs.getString("v.LABEL")); vf.setRegStatus(RegStatus.fromString(rs.getString("v.REG_STATUS"))); vf.setType(VocabularyType.valueOf(rs.getString("v.VOCABULARY_TYPE"))); vf.setWorkingCopy(rs.getBoolean("v.WORKING_COPY")); vf.setWorkingUser(rs.getString("v.WORKING_USER")); vf.setDateModified(rs.getTimestamp("v.DATE_MODIFIED")); vf.setUserModified(rs.getString("v.USER_MODIFIED")); vf.setCheckedOutCopyId(rs.getInt("v.CHECKEDOUT_COPY_ID")); vf.setContinuityId(rs.getString("v.CONTINUITY_ID")); vf.setNumericConceptIdentifiers(rs.getBoolean("v.CONCEPT_IDENTIFIER_NUMERIC")); vf.setNotationsEqualIdentifiers(rs.getBoolean("NOTATIONS_EQUAL_IDENTIFIERS")); vf.setBaseUri(rs.getString("v.BASE_URI")); vf.setFolderId(rs.getShort("f.ID")); vf.setFolderName(rs.getString("f.IDENTIFIER")); vf.setFolderLabel(rs.getString("f.LABEL")); return vf; } }); return items; }
From source file:eionet.meta.dao.mysql.VocabularyFolderDAOImpl.java
/** * {@inheritDoc}/*from w ww . j a va2 s .c o m*/ */ @Override public List<VocabularyFolder> getVocabularyFolders(int folderId, String userName) { Map<String, Object> params = new HashMap<String, Object>(); params.put("folderId", folderId); StringBuilder sql = new StringBuilder(); sql.append( "select v.VOCABULARY_ID, v.IDENTIFIER, v.LABEL, v.REG_STATUS, v.WORKING_COPY, v.BASE_URI, v.VOCABULARY_TYPE, "); sql.append("v.WORKING_USER, v.DATE_MODIFIED, v.USER_MODIFIED, v.CHECKEDOUT_COPY_ID, v.CONTINUITY_ID, "); sql.append("v.CONCEPT_IDENTIFIER_NUMERIC, "); sql.append("f.ID, f.IDENTIFIER, f.LABEL, v.NOTATIONS_EQUAL_IDENTIFIERS "); sql.append("from VOCABULARY v "); sql.append("left join VOCABULARY_SET f on f.ID=v.FOLDER_ID "); sql.append("where "); if (StringUtils.isBlank(userName)) { sql.append("v.WORKING_COPY=FALSE "); } else { sql.append("(v.WORKING_COPY=FALSE or v.WORKING_USER=:workingUser) "); params.put("workingUser", userName); } sql.append("and v.FOLDER_ID=:folderId "); sql.append("order by f.IDENTIFIER, v.IDENTIFIER "); List<VocabularyFolder> items = getNamedParameterJdbcTemplate().query(sql.toString(), params, new RowMapper<VocabularyFolder>() { @Override public VocabularyFolder mapRow(ResultSet rs, int rowNum) throws SQLException { VocabularyFolder vf = new VocabularyFolder(); vf.setId(rs.getInt("v.VOCABULARY_ID")); vf.setIdentifier(rs.getString("v.IDENTIFIER")); vf.setLabel(rs.getString("v.LABEL")); vf.setRegStatus(RegStatus.fromString(rs.getString("v.REG_STATUS"))); vf.setType(VocabularyType.valueOf(rs.getString("v.VOCABULARY_TYPE"))); vf.setWorkingCopy(rs.getBoolean("v.WORKING_COPY")); vf.setWorkingUser(rs.getString("v.WORKING_USER")); vf.setDateModified(rs.getTimestamp("v.DATE_MODIFIED")); vf.setUserModified(rs.getString("v.USER_MODIFIED")); vf.setCheckedOutCopyId(rs.getInt("v.CHECKEDOUT_COPY_ID")); vf.setContinuityId(rs.getString("v.CONTINUITY_ID")); vf.setNumericConceptIdentifiers(rs.getBoolean("v.CONCEPT_IDENTIFIER_NUMERIC")); vf.setNotationsEqualIdentifiers(rs.getBoolean("NOTATIONS_EQUAL_IDENTIFIERS")); vf.setBaseUri(rs.getString("v.BASE_URI")); vf.setFolderId(rs.getShort("f.ID")); vf.setFolderName(rs.getString("f.IDENTIFIER")); vf.setFolderLabel(rs.getString("f.LABEL")); return vf; } }); return items; }
From source file:eionet.meta.dao.mysql.VocabularyFolderDAOImpl.java
/** * {@inheritDoc}/*from w w w.java 2 s.co m*/ */ @Override public List<VocabularyFolder> getVocabularyFolderVersions(String continuityId, int vocabularyFolderId, String userName) { Map<String, Object> params = new HashMap<String, Object>(); params.put("continuityId", continuityId); params.put("vocabularyFolderId", vocabularyFolderId); StringBuilder sql = new StringBuilder(); sql.append( "select v.VOCABULARY_ID, v.IDENTIFIER, v.LABEL, v.REG_STATUS, v.WORKING_COPY, v.BASE_URI, v.VOCABULARY_TYPE, "); sql.append("v.WORKING_USER, v.DATE_MODIFIED, v.USER_MODIFIED, v.CHECKEDOUT_COPY_ID, v.CONTINUITY_ID, "); sql.append("v.CONCEPT_IDENTIFIER_NUMERIC, "); sql.append("f.ID, f.IDENTIFIER, f.LABEL, v.NOTATIONS_EQUAL_IDENTIFIERS "); sql.append("from VOCABULARY v "); sql.append("left join VOCABULARY_SET f on f.ID=v.FOLDER_ID "); sql.append("where v.CONTINUITY_ID = :continuityId and v.VOCABULARY_ID != :vocabularyFolderId "); if (StringUtils.isBlank(userName)) { sql.append("and v.WORKING_COPY=FALSE "); } else { sql.append("and (v.WORKING_COPY=FALSE or v.WORKING_USER=:workingUser) "); params.put("workingUser", userName); } List<VocabularyFolder> items = getNamedParameterJdbcTemplate().query(sql.toString(), params, new RowMapper<VocabularyFolder>() { @Override public VocabularyFolder mapRow(ResultSet rs, int rowNum) throws SQLException { VocabularyFolder vf = new VocabularyFolder(); vf.setId(rs.getInt("v.VOCABULARY_ID")); vf.setIdentifier(rs.getString("v.IDENTIFIER")); vf.setLabel(rs.getString("v.LABEL")); vf.setRegStatus(RegStatus.fromString(rs.getString("v.REG_STATUS"))); vf.setType(VocabularyType.valueOf(rs.getString("v.VOCABULARY_TYPE"))); vf.setWorkingCopy(rs.getBoolean("v.WORKING_COPY")); vf.setWorkingUser(rs.getString("v.WORKING_USER")); vf.setDateModified(rs.getTimestamp("v.DATE_MODIFIED")); vf.setUserModified(rs.getString("v.USER_MODIFIED")); vf.setCheckedOutCopyId(rs.getInt("v.CHECKEDOUT_COPY_ID")); vf.setContinuityId(rs.getString("v.CONTINUITY_ID")); vf.setNumericConceptIdentifiers(rs.getBoolean("v.CONCEPT_IDENTIFIER_NUMERIC")); vf.setNotationsEqualIdentifiers(rs.getBoolean("NOTATIONS_EQUAL_IDENTIFIERS")); vf.setBaseUri(rs.getString("v.BASE_URI")); vf.setFolderId(rs.getShort("f.ID")); vf.setFolderName(rs.getString("f.IDENTIFIER")); vf.setFolderLabel(rs.getString("f.LABEL")); return vf; } }); return items; }
From source file:com.mimp.hibernate.HiberNna.java
public ArrayList<Nna> ListaNnaSeguimiento(String clasificacion) { Session session = sessionFactory.getCurrentSession(); final String clasif = clasificacion; final ArrayList<Nna> allNna = new ArrayList(); final ArrayList<Nna> allNnaAux = new ArrayList(); final ArrayList<Nna> allNnaFinal = new ArrayList(); Work work = new Work() { @Override// w ww .ja v a2s.c o m public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; Nna tempnna; Designacion desig; EstudioCaso est; String hql = "{call HN_GET_NNA_SEG(?)}"; CallableStatement statement = connection.prepareCall(hql); statement.registerOutParameter(1, OracleTypes.CURSOR); statement.execute(); temp = (ResultSet) statement.getObject(1); while (temp.next()) { tempnna = new Nna(); tempnna.setIdnna(temp.getLong(1)); tempnna.setNombre(temp.getString(2)); tempnna.setApellidoP(temp.getString(3)); tempnna.setApellidoM(temp.getString(4)); tempnna.setSexo(temp.getString(5)); tempnna.setFechaNacimiento(temp.getDate(6)); tempnna.setEdadAnhos(temp.getShort(7)); tempnna.setEdadMeses(temp.getShort(8)); tempnna.setActaNacimiento(temp.getShort(9)); tempnna.setCondicionSalud(temp.getString(10)); tempnna.setDepartamentoNacimiento(temp.getString(11)); tempnna.setProvinciaNacimiento(temp.getString(12)); tempnna.setDistritoNacimiento(temp.getString(13)); tempnna.setPaisNacimiento(temp.getString(14)); tempnna.setLugarNac(temp.getString(15)); tempnna.setFechaResolAbandono(temp.getDate(16)); tempnna.setFechaResolConsentida(temp.getDate(17)); tempnna.setClasificacion(temp.getString(18)); tempnna.setIncesto(temp.getShort(19)); tempnna.setMental(temp.getShort(20)); tempnna.setEpilepsia(temp.getShort(21)); tempnna.setAbuso(temp.getShort(22)); tempnna.setSifilis(temp.getShort(23)); tempnna.setSeguiMedico(temp.getShort(24)); tempnna.setOperacion(temp.getShort(25)); tempnna.setHiperactivo(temp.getShort(26)); tempnna.setEspecial(temp.getShort(27)); tempnna.setEnfermo(temp.getShort(28)); tempnna.setMayor(temp.getShort(29)); tempnna.setAdolescente(temp.getShort(30)); tempnna.setHermano(temp.getShort(31)); tempnna.setNn(temp.getShort(32)); tempnna.setObservaciones(temp.getString(33)); tempnna.setNResolAband(temp.getString(34)); tempnna.setNResolCons(temp.getString(35)); try { expnna = getExpNna(temp.getLong(1)); if (expnna.getIdexpedienteNna() != 0) { Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>(); listexp.add(expnna); tempnna.setExpedienteNnas(listexp); } } catch (Exception e) { } allNnaAux.add(tempnna); } statement.close(); temp.close(); //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO for (Nna auxnna : allNnaAux) { Set<Designacion> listDesig = new HashSet<Designacion>(); String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, auxnna.getIdnna()); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); while (rs2.next()) { desig = new Designacion(); desig.setIddesignacion(rs2.getLong(1)); desig.setNDesignacion(rs2.getString(5)); desig.setPrioridad(rs2.getLong(6)); desig.setFechaPropuesta(rs2.getDate(7)); desig.setFechaConsejo(rs2.getDate(8)); desig.setAceptacionConsejo(rs2.getShort(9)); desig.setTipoPropuesta(rs2.getString(10)); desig.setObs(rs2.getString(11)); listDesig.add(desig); } auxnna.setDesignacions(listDesig); allNna.add(auxnna); statement2.close(); rs2.close(); } for (Nna auxnna : allNna) { if (auxnna.getClasificacion().equals("prioritario")) { Set<EstudioCaso> listEst = new HashSet<EstudioCaso>(); String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, auxnna.getIdnna()); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); while (rs3.next()) { est = new EstudioCaso(); est.setIdestudioCaso(rs3.getLong(1)); est.setOrden(rs3.getString(4)); est.setFechaEstudio(rs3.getDate(5)); est.setFechaSolAdop(rs3.getDate(6)); est.setResultado(rs3.getString(7)); est.setPrioridad(rs3.getLong(8)); est.setNSolicitud(rs3.getLong(9)); listEst.add(est); } auxnna.setEstudioCasos(listEst); statement3.close(); rs3.close(); } allNnaFinal.add(auxnna); } //METODO BUBBLESORT PARA ORDENAR POR CODIGO if (clasif.equals("prioritario")) { Nna auxnna2; int n = allNnaFinal.size(); for (int i = 0; i < n - 1; i++) { for (int j = i; j < n - 1; j++) { if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) { if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } else { String apellidoPrev = ""; String apellidoNext = ""; try { apellidoPrev = allNnaFinal.get(i).getApellidoP(); if (apellidoPrev == null) { apellidoPrev = ""; } } catch (Exception ex) { apellidoPrev = ""; } try { apellidoNext = allNnaFinal.get(j + 1).getApellidoP(); if (apellidoNext == null) { apellidoNext = ""; } } catch (Exception ex) { apellidoNext = ""; } if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } else { Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas(); Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas(); if (!listExp2.isEmpty()) { for (ExpedienteNna exp1 : listExp1) { for (ExpedienteNna exp2 : listExp2) { String codant = exp1.getCodigoReferencia(); String codpost = exp2.getCodigoReferencia(); if (codant == null) { codant = ""; } if (codpost == null) { codpost = ""; } if (codant.compareToIgnoreCase(codpost) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } } } } } } } }; session.doWork(work); return allNnaFinal; }
From source file:com.mimp.hibernate.HiberNna.java
public ArrayList<Nna> ListaNna(String clasificacion) { Session session = sessionFactory.getCurrentSession(); final String clasif = clasificacion; final ArrayList<Nna> allNna = new ArrayList(); final ArrayList<Nna> allNnaAux = new ArrayList(); final ArrayList<Nna> allNnaFinal = new ArrayList(); Work work = new Work() { @Override//from w ww . j av a 2 s. co m public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; Nna tempnna; Designacion desig; EstudioCaso est; String hql = "{call HN_GET_NNA_CLAS(?,?)}"; CallableStatement statement = connection.prepareCall(hql); statement.setString(1, clasif); statement.registerOutParameter(2, OracleTypes.CURSOR); statement.execute(); temp = (ResultSet) statement.getObject(2); while (temp.next()) { tempnna = new Nna(); tempnna.setIdnna(temp.getLong(1)); tempnna.setNombre(temp.getString(2)); tempnna.setApellidoP(temp.getString(3)); tempnna.setApellidoM(temp.getString(4)); tempnna.setSexo(temp.getString(5)); tempnna.setFechaNacimiento(temp.getDate(6)); tempnna.setEdadAnhos(temp.getShort(7)); tempnna.setEdadMeses(temp.getShort(8)); tempnna.setActaNacimiento(temp.getShort(9)); tempnna.setCondicionSalud(temp.getString(10)); tempnna.setDepartamentoNacimiento(temp.getString(11)); tempnna.setProvinciaNacimiento(temp.getString(12)); tempnna.setDistritoNacimiento(temp.getString(13)); tempnna.setPaisNacimiento(temp.getString(14)); tempnna.setLugarNac(temp.getString(15)); tempnna.setFechaResolAbandono(temp.getDate(16)); tempnna.setFechaResolConsentida(temp.getDate(17)); tempnna.setClasificacion(temp.getString(18)); tempnna.setIncesto(temp.getShort(19)); tempnna.setMental(temp.getShort(20)); tempnna.setEpilepsia(temp.getShort(21)); tempnna.setAbuso(temp.getShort(22)); tempnna.setSifilis(temp.getShort(23)); tempnna.setSeguiMedico(temp.getShort(24)); tempnna.setOperacion(temp.getShort(25)); tempnna.setHiperactivo(temp.getShort(26)); tempnna.setEspecial(temp.getShort(27)); tempnna.setEnfermo(temp.getShort(28)); tempnna.setMayor(temp.getShort(29)); tempnna.setAdolescente(temp.getShort(30)); tempnna.setHermano(temp.getShort(31)); tempnna.setNn(temp.getShort(32)); tempnna.setObservaciones(temp.getString(33)); tempnna.setNResolAband(temp.getString(34)); tempnna.setNResolCons(temp.getString(35)); try { expnna = getExpNna(temp.getLong(1)); if (expnna.getIdexpedienteNna() != 0) { Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>(); listexp.add(expnna); tempnna.setExpedienteNnas(listexp); } } catch (Exception e) { } allNnaAux.add(tempnna); } statement.close(); temp.close(); //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO for (Nna auxnna : allNnaAux) { Set<Designacion> listDesig = new HashSet<Designacion>(); String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, auxnna.getIdnna()); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); while (rs2.next()) { desig = new Designacion(); desig.setIddesignacion(rs2.getLong(1)); desig.setNDesignacion(rs2.getString(5)); desig.setPrioridad(rs2.getLong(6)); desig.setFechaPropuesta(rs2.getDate(7)); desig.setFechaConsejo(rs2.getDate(8)); desig.setAceptacionConsejo(rs2.getShort(9)); desig.setTipoPropuesta(rs2.getString(10)); desig.setObs(rs2.getString(11)); listDesig.add(desig); } auxnna.setDesignacions(listDesig); allNna.add(auxnna); statement2.close(); rs2.close(); } for (Nna auxnna : allNna) { if (auxnna.getClasificacion().equals("prioritario")) { Set<EstudioCaso> listEst = new HashSet<EstudioCaso>(); String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, auxnna.getIdnna()); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); while (rs3.next()) { est = new EstudioCaso(); est.setIdestudioCaso(rs3.getLong(1)); est.setOrden(rs3.getString(4)); est.setFechaEstudio(rs3.getDate(5)); est.setFechaSolAdop(rs3.getDate(6)); est.setResultado(rs3.getString(7)); est.setPrioridad(rs3.getLong(8)); est.setNSolicitud(rs3.getLong(9)); listEst.add(est); } auxnna.setEstudioCasos(listEst); statement3.close(); rs3.close(); } allNnaFinal.add(auxnna); } //METODO BUBBLESORT PARA ORDENAR POR CODIGO if (clasif.equals("prioritario")) { Nna auxnna2; int n = allNnaFinal.size(); for (int i = 0; i < n - 1; i++) { for (int j = i; j < n - 1; j++) { if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) { if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } else { String apellidoPrev = ""; String apellidoNext = ""; try { apellidoPrev = allNnaFinal.get(i).getApellidoP(); if (apellidoPrev == null) { apellidoPrev = ""; } } catch (Exception ex) { apellidoPrev = ""; } try { apellidoNext = allNnaFinal.get(j + 1).getApellidoP(); if (apellidoNext == null) { apellidoNext = ""; } } catch (Exception ex) { apellidoNext = ""; } if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } else { Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas(); Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas(); if (!listExp2.isEmpty()) { for (ExpedienteNna exp1 : listExp1) { for (ExpedienteNna exp2 : listExp2) { String codant = exp1.getCodigoReferencia(); String codpost = exp2.getCodigoReferencia(); if (codant == null) { codant = ""; } if (codpost == null) { codpost = ""; } if (codant.compareToIgnoreCase(codpost) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } } } } } } } }; session.doWork(work); return allNnaFinal; }
From source file:com.mimp.hibernate.HiberNna.java
public ArrayList<Nna> ListaNnaPrioritarios(String clasificacion) { Session session = sessionFactory.getCurrentSession(); final String clasif = clasificacion; final ArrayList<Nna> allNna = new ArrayList(); final ArrayList<Nna> allNnaAux = new ArrayList(); final ArrayList<Nna> allNnaFinal = new ArrayList(); Work work = new Work() { @Override// w w w.j a va2 s .c om public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; Nna tempnna; Designacion desig; EstudioCaso est; String hql = "{call HN_GET_NNA_PRIO(?)}"; CallableStatement statement = connection.prepareCall(hql); statement.registerOutParameter(1, OracleTypes.CURSOR); statement.execute(); temp = (ResultSet) statement.getObject(1); while (temp.next()) { tempnna = new Nna(); tempnna.setIdnna(temp.getLong(1)); tempnna.setNombre(temp.getString(2)); tempnna.setApellidoP(temp.getString(3)); tempnna.setApellidoM(temp.getString(4)); tempnna.setSexo(temp.getString(5)); tempnna.setFechaNacimiento(temp.getDate(6)); tempnna.setEdadAnhos(temp.getShort(7)); tempnna.setEdadMeses(temp.getShort(8)); tempnna.setActaNacimiento(temp.getShort(9)); tempnna.setCondicionSalud(temp.getString(10)); tempnna.setDepartamentoNacimiento(temp.getString(11)); tempnna.setProvinciaNacimiento(temp.getString(12)); tempnna.setDistritoNacimiento(temp.getString(13)); tempnna.setPaisNacimiento(temp.getString(14)); tempnna.setLugarNac(temp.getString(15)); tempnna.setFechaResolAbandono(temp.getDate(16)); tempnna.setFechaResolConsentida(temp.getDate(17)); tempnna.setClasificacion(temp.getString(18)); tempnna.setIncesto(temp.getShort(19)); tempnna.setMental(temp.getShort(20)); tempnna.setEpilepsia(temp.getShort(21)); tempnna.setAbuso(temp.getShort(22)); tempnna.setSifilis(temp.getShort(23)); tempnna.setSeguiMedico(temp.getShort(24)); tempnna.setOperacion(temp.getShort(25)); tempnna.setHiperactivo(temp.getShort(26)); tempnna.setEspecial(temp.getShort(27)); tempnna.setEnfermo(temp.getShort(28)); tempnna.setMayor(temp.getShort(29)); tempnna.setAdolescente(temp.getShort(30)); tempnna.setHermano(temp.getShort(31)); tempnna.setNn(temp.getShort(32)); tempnna.setObservaciones(temp.getString(33)); tempnna.setNResolAband(temp.getString(34)); tempnna.setNResolCons(temp.getString(35)); try { expnna = getExpNna(temp.getLong(1)); if (expnna.getIdexpedienteNna() != 0) { Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>(); listexp.add(expnna); tempnna.setExpedienteNnas(listexp); } } catch (Exception e) { } allNnaAux.add(tempnna); } statement.close(); temp.close(); //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO for (Nna auxnna : allNnaAux) { Set<Designacion> listDesig = new HashSet<Designacion>(); String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, auxnna.getIdnna()); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); while (rs2.next()) { desig = new Designacion(); desig.setIddesignacion(rs2.getLong(1)); desig.setNDesignacion(rs2.getString(5)); desig.setPrioridad(rs2.getLong(6)); desig.setFechaPropuesta(rs2.getDate(7)); desig.setFechaConsejo(rs2.getDate(8)); desig.setAceptacionConsejo(rs2.getShort(9)); desig.setTipoPropuesta(rs2.getString(10)); desig.setObs(rs2.getString(11)); listDesig.add(desig); } auxnna.setDesignacions(listDesig); allNna.add(auxnna); statement2.close(); rs2.close(); } for (Nna auxnna : allNna) { if (auxnna.getClasificacion().equals("prioritario")) { Set<EstudioCaso> listEst = new HashSet<EstudioCaso>(); String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, auxnna.getIdnna()); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); while (rs3.next()) { est = new EstudioCaso(); est.setIdestudioCaso(rs3.getLong(1)); est.setOrden(rs3.getString(4)); est.setFechaEstudio(rs3.getDate(5)); est.setFechaSolAdop(rs3.getDate(6)); est.setResultado(rs3.getString(7)); est.setPrioridad(rs3.getLong(8)); est.setNSolicitud(rs3.getLong(9)); listEst.add(est); } auxnna.setEstudioCasos(listEst); statement3.close(); rs3.close(); } allNnaFinal.add(auxnna); } //METODO BUBBLESORT PARA ORDENAR POR CODIGO if (clasif.equals("prioritario")) { Nna auxnna2; int n = allNnaFinal.size(); for (int i = 0; i < n - 1; i++) { for (int j = i; j < n - 1; j++) { if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) { if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } else { String apellidoPrev = ""; String apellidoNext = ""; try { apellidoPrev = allNnaFinal.get(i).getApellidoP(); if (apellidoPrev == null) { apellidoPrev = ""; } } catch (Exception ex) { apellidoPrev = ""; } try { apellidoNext = allNnaFinal.get(j + 1).getApellidoP(); if (apellidoNext == null) { apellidoNext = ""; } } catch (Exception ex) { apellidoNext = ""; } if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } else { Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas(); Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas(); if (!listExp2.isEmpty()) { for (ExpedienteNna exp1 : listExp1) { for (ExpedienteNna exp2 : listExp2) { String codant = exp1.getCodigoReferencia(); String codpost = exp2.getCodigoReferencia(); if (codant == null) { codant = ""; } if (codpost == null) { codpost = ""; } if (codant.compareToIgnoreCase(codpost) > 0) { auxnna2 = allNnaFinal.get(i); allNnaFinal.set(i, allNnaFinal.get(j + 1)); allNnaFinal.set(j + 1, auxnna2); } } } } } } } } } }; session.doWork(work); return allNnaFinal; }
From source file:com.github.woonsan.jdbc.jcr.impl.JcrJdbcResultSetTest.java
private void assertWrongValueFormatColumn(final ResultSet rs) throws Exception { assertFalse(rs.getBoolean(2));/* ww w . ja va2 s . c o m*/ assertFalse(rs.getBoolean("ename")); try { rs.getShort(2); fail(); } catch (SQLException ignore) { } try { rs.getShort("ename"); fail(); } catch (SQLException ignore) { } try { rs.getInt(2); fail(); } catch (SQLException ignore) { } try { rs.getInt("ename"); fail(); } catch (SQLException ignore) { } try { rs.getLong(2); fail(); } catch (SQLException ignore) { } try { rs.getLong("ename"); fail(); } catch (SQLException ignore) { } try { rs.getFloat(2); fail(); } catch (SQLException ignore) { } try { rs.getFloat("ename"); fail(); } catch (SQLException ignore) { } try { rs.getDouble(2); fail(); } catch (SQLException ignore) { } try { rs.getDouble("ename"); fail(); } catch (SQLException ignore) { } try { rs.getBigDecimal(2); fail(); } catch (SQLException ignore) { } try { rs.getBigDecimal("ename"); fail(); } catch (SQLException ignore) { } try { rs.getBytes(2); fail(); } catch (SQLException ignore) { } try { rs.getBytes("ename"); fail(); } catch (SQLException ignore) { } try { rs.getDate(2); fail(); } catch (SQLException ignore) { } try { rs.getDate("ename"); fail(); } catch (SQLException ignore) { } try { rs.getDate(2, Calendar.getInstance()); fail(); } catch (SQLException ignore) { } try { rs.getDate("ename", Calendar.getInstance()); fail(); } catch (SQLException ignore) { } try { rs.getTime(2); fail(); } catch (SQLException ignore) { } try { rs.getTime("ename"); fail(); } catch (SQLException ignore) { } try { rs.getTime(2, Calendar.getInstance()); fail(); } catch (SQLException ignore) { } try { rs.getTime("ename", Calendar.getInstance()); fail(); } catch (SQLException ignore) { } try { rs.getTimestamp(2); fail(); } catch (SQLException ignore) { } try { rs.getTimestamp("ename"); fail(); } catch (SQLException ignore) { } try { rs.getTimestamp(2, Calendar.getInstance()); fail(); } catch (SQLException ignore) { } try { rs.getTimestamp("ename", Calendar.getInstance()); fail(); } catch (SQLException ignore) { } try { rs.getAsciiStream(2); fail(); } catch (SQLException ignore) { } try { rs.getAsciiStream("ename"); fail(); } catch (SQLException ignore) { } try { rs.getBinaryStream(2); fail(); } catch (SQLException ignore) { } try { rs.getBinaryStream("ename"); fail(); } catch (SQLException ignore) { } try { rs.getCharacterStream(2); fail(); } catch (SQLException ignore) { } try { rs.getCharacterStream("ename"); fail(); } catch (SQLException ignore) { } }
From source file:com.liferay.portal.upgrade.util.Table.java
public Object getValue(ResultSet rs, String name, Integer type) throws Exception { Object value = null;//from w w w . j ava2 s . co m int t = type.intValue(); if (t == Types.BIGINT) { try { value = GetterUtil.getLong(rs.getLong(name)); } catch (SQLException e) { value = GetterUtil.getLong(rs.getString(name)); } } else if (t == Types.BOOLEAN) { value = GetterUtil.getBoolean(rs.getBoolean(name)); } else if (t == Types.CLOB) { try { Clob clob = rs.getClob(name); if (clob == null) { value = StringPool.BLANK; } else { UnsyncBufferedReader unsyncBufferedReader = new UnsyncBufferedReader(clob.getCharacterStream()); StringBundler sb = new StringBundler(); String line = null; while ((line = unsyncBufferedReader.readLine()) != null) { if (sb.length() != 0) { sb.append(SAFE_NEWLINE_CHARACTER); } sb.append(line); } value = sb.toString(); } } catch (Exception e) { // If the database doesn't allow CLOB types for the column // value, then try retrieving it as a String value = GetterUtil.getString(rs.getString(name)); } } else if (t == Types.DOUBLE) { value = GetterUtil.getDouble(rs.getDouble(name)); } else if (t == Types.FLOAT) { value = GetterUtil.getFloat(rs.getFloat(name)); } else if (t == Types.INTEGER) { value = GetterUtil.getInteger(rs.getInt(name)); } else if (t == Types.SMALLINT) { value = GetterUtil.getShort(rs.getShort(name)); } else if (t == Types.TIMESTAMP) { try { value = rs.getTimestamp(name); } catch (Exception e) { } if (value == null) { value = StringPool.NULL; } } else if (t == Types.VARCHAR) { value = GetterUtil.getString(rs.getString(name)); } else { throw new UpgradeException("Upgrade code using unsupported class type " + type); } return value; }
From source file:com.draagon.meta.manager.db.driver.GenericSQLDriver.java
protected void parseField(Object o, MetaField f, ResultSet rs, int j) throws SQLException { switch (f.getType()) { case MetaField.BOOLEAN: { boolean bv = rs.getBoolean(j); if (rs.wasNull()) { f.setBoolean(o, null);/*from w ww. j a v a 2s . c om*/ } else { f.setBoolean(o, new Boolean(bv)); } } break; case MetaField.BYTE: { byte bv = rs.getByte(j); if (rs.wasNull()) { f.setByte(o, null); } else { f.setByte(o, new Byte(bv)); } } break; case MetaField.SHORT: { short sv = rs.getShort(j); if (rs.wasNull()) { f.setShort(o, null); } else { f.setShort(o, new Short(sv)); } } break; case MetaField.INT: { int iv = rs.getInt(j); if (rs.wasNull()) { f.setInt(o, null); } else { f.setInt(o, new Integer(iv)); } } break; case MetaField.DATE: { Timestamp tv = rs.getTimestamp(j); if (rs.wasNull()) { f.setDate(o, null); } else { f.setDate(o, new java.util.Date(tv.getTime())); } } break; case MetaField.LONG: { long lv = rs.getLong(j); if (rs.wasNull()) { f.setLong(o, null); } else { f.setLong(o, new Long(lv)); } } break; case MetaField.FLOAT: { float fv = rs.getFloat(j); if (rs.wasNull()) { f.setFloat(o, null); } else { f.setFloat(o, new Float(fv)); } } break; case MetaField.DOUBLE: { double dv = rs.getDouble(j); if (rs.wasNull()) { f.setDouble(o, null); } else { f.setDouble(o, new Double(dv)); } } break; case MetaField.STRING: f.setString(o, rs.getString(j)); break; case MetaField.OBJECT: f.setObject(o, rs.getObject(j)); break; } }
From source file:com.funambol.foundation.items.dao.PIMCalendarDAO.java
/** * Creates a CalendarWrapper object of Calendar type from a ResultSet. * * @param wrapperId the UID of the wrapper object to be returned * @param rs the result of the execution of a proper SQL SELECT statement on * the fnbl_PIM_CALENDAR table, with the cursor before its first row * @return a newly created CalendarWrapper initialized with the fields in * the result set//from ww w . ja v a 2 s .c o m * @throws Exception * @throws NotFoundException */ protected static CalendarWrapper createCalendar(String wrapperId, ResultSet rs) throws NotFoundException, Exception { if (!rs.next()) { throw new NotFoundException("No calendar found."); } ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); RecurrencePattern rp = null; String column = null; String uid = null; String userId = null; short recurrenceType = -1; int interval = 0; short monthOfYear = 0; short dayOfMonth = 0; short dayOfWeekMask = 0; short instance = 0; String startDatePattern = null; String endDatePattern = null; int occurrences = -1; boolean noEndDate = false; boolean aDay = false; Reminder r = null; Date replyTime = null; Date dstart = null; Date dend = null; Date completed = null; Date reminderTime = null; uid = String.valueOf(rs.getLong(SQL_FIELD_ID)); userId = rs.getString(SQL_FIELD_USERID); Calendar cal = new Calendar(); r = new Reminder(); CalendarContent c; boolean isAnEvent = true; for (int i = 1; i <= columnCount; i++) { if (SQL_FIELD_TYPE.equalsIgnoreCase(rsmd.getColumnName(i))) { if (rs.getShort(i) == CALENDAR_TASK_TYPE) { isAnEvent = false; } break; } } if (isAnEvent) { c = new Event(); cal.setEvent((Event) c); } else { c = new Task(); cal.setTask((Task) c); } c.setReminder(r); CalendarWrapper cw = new CalendarWrapper(wrapperId, userId, cal); for (int i = 1; i <= columnCount; i++) { column = rsmd.getColumnName(i); if (SQL_FIELD_ID.equalsIgnoreCase(column)) { // Does nothing: field already set at construction time } else if (SQL_FIELD_LAST_UPDATE.equalsIgnoreCase(column)) { cw.setLastUpdate(new Timestamp(rs.getLong(i))); } else if (SQL_FIELD_USERID.equalsIgnoreCase(column)) { // Does nothing: field already set at construction time } else if (SQL_FIELD_STATUS.equalsIgnoreCase(column)) { cw.setStatus(rs.getString(i).charAt(0)); } else if (SQL_FIELD_ALL_DAY.equalsIgnoreCase(column)) { String allDay = null; allDay = rs.getString(i); if (allDay != null && allDay.length() > 0) { if (allDay.charAt(0) == '1') { aDay = true; c.setAllDay(Boolean.TRUE); } else if (allDay.charAt(0) == '0') { c.setAllDay(Boolean.FALSE); } } } else if (SQL_FIELD_BODY.equalsIgnoreCase(column)) { c.getDescription().setPropertyValue(rs.getString(i)); } else if (SQL_FIELD_BUSY_STATUS.equalsIgnoreCase(column)) { short bs = rs.getShort(i); if (rs.wasNull()) { c.setBusyStatus(null); } else { c.setBusyStatus(new Short(bs)); } } else if (SQL_FIELD_CATEGORIES.equalsIgnoreCase(column)) { c.getCategories().setPropertyValue(rs.getString(i)); } else if (SQL_FIELD_COMPANIES.equalsIgnoreCase(column)) { c.getOrganizer().setPropertyValue(rs.getString(i)); } else if (SQL_FIELD_DURATION.equalsIgnoreCase(column)) { c.getDuration().setPropertyValue(rs.getString(i)); } else if (SQL_FIELD_DATE_END.equalsIgnoreCase(column)) { if (rs.getTimestamp(i) != null) { dend = new Date(rs.getTimestamp(i).getTime()); } } else if (SQL_FIELD_IMPORTANCE.equalsIgnoreCase(column)) { c.getPriority().setPropertyValue(rs.getString(i)); } else if (SQL_FIELD_LOCATION.equalsIgnoreCase(column)) { c.getLocation().setPropertyValue(rs.getString(i)); } else if (SQL_FIELD_MEETING_STATUS.equalsIgnoreCase(column)) { short meetingStatus = rs.getShort(i); if (!rs.wasNull()) { if (c instanceof Task) { c.getStatus().setPropertyValue(Short.toString(meetingStatus)); } else { c.setMeetingStatus(new Short(meetingStatus)); } } } else if (SQL_FIELD_MILEAGE.equalsIgnoreCase(column)) { String mileage = null; mileage = rs.getString(i); if (mileage != null && mileage.length() > 0 && !("null".equals(mileage))) { c.setMileage(Integer.valueOf(mileage)); } } else if (SQL_FIELD_REMINDER_TIME.equalsIgnoreCase(column)) { if (rs.getTimestamp(i) != null) { reminderTime = new Date(rs.getTimestamp(i).getTime()); } } else if (SQL_FIELD_REMINDER_REPEAT_COUNT.equalsIgnoreCase(column)) { r.setRepeatCount(rs.getInt(i)); } else if (SQL_FIELD_REMINDER.equalsIgnoreCase(column)) { String reminder = null; reminder = rs.getString(i); if (reminder != null && reminder.length() > 0) { r.setActive(reminder.charAt(0) == '1'); } else { r.setActive(false); } } else if (SQL_FIELD_REMINDER_SOUND_FILE.equalsIgnoreCase(column)) { r.setSoundFile(rs.getString(i)); } else if (SQL_FIELD_REMINDER_OPTIONS.equalsIgnoreCase(column)) { r.setOptions(rs.getInt(i)); } else if (SQL_FIELD_REPLY_TIME.equalsIgnoreCase(column)) { if (rs.getTimestamp(i) != null) { replyTime = new Date(rs.getTimestamp(i).getTime()); } } else if (SQL_FIELD_SENSITIVITY.equalsIgnoreCase(column)) { Short sensitivity = rs.getShort(i); if (sensitivity == null) { c.getAccessClass().setPropertyValue(new Short((short) 0)); } else { c.getAccessClass().setPropertyValue(sensitivity); } } else if (SQL_FIELD_DATE_START.equalsIgnoreCase(column)) { if (rs.getTimestamp(i) != null) { dstart = new Date(rs.getTimestamp(i).getTime()); } } else if (SQL_FIELD_SUBJECT.equalsIgnoreCase(column)) { c.getSummary().setPropertyValue(rs.getString(i)); } else if (SQL_FIELD_RECURRENCE_TYPE.equalsIgnoreCase(column)) { recurrenceType = rs.getShort(i); } else if (SQL_FIELD_INTERVAL.equalsIgnoreCase(column)) { interval = rs.getInt(i); } else if (SQL_FIELD_MONTH_OF_YEAR.equalsIgnoreCase(column)) { monthOfYear = rs.getShort(i); } else if (SQL_FIELD_DAY_OF_MONTH.equalsIgnoreCase(column)) { dayOfMonth = rs.getShort(i); } else if (SQL_FIELD_DAY_OF_WEEK_MASK.equalsIgnoreCase(column)) { String dayOfWeekMaskStr = rs.getString(i); if (dayOfWeekMaskStr != null && dayOfWeekMaskStr.length() > 0) { dayOfWeekMask = Short.parseShort(dayOfWeekMaskStr); } } else if (SQL_FIELD_INSTANCE.equalsIgnoreCase(column)) { instance = rs.getShort(i); } else if (SQL_FIELD_START_DATE_PATTERN.equalsIgnoreCase(column)) { startDatePattern = rs.getString(i); } else if (SQL_FIELD_NO_END_DATE.equalsIgnoreCase(column)) { String noEndDateStr = null; noEndDateStr = rs.getString(i); if (noEndDateStr != null && noEndDateStr.length() > 0) { if (noEndDateStr.charAt(0) == '1') { noEndDate = true; } else if (noEndDateStr.charAt(0) == '0') { noEndDate = false; } } } else if (SQL_FIELD_END_DATE_PATTERN.equalsIgnoreCase(column)) { endDatePattern = rs.getString(i); } else if (SQL_FIELD_OCCURRENCES.equalsIgnoreCase(column)) { occurrences = rs.getShort(i); } else if (SQL_FIELD_TYPE.equalsIgnoreCase(column)) { // Already handled } else if (SQL_FIELD_COMPLETED.equalsIgnoreCase(column)) { if (rs.getTimestamp(i) != null) { completed = new Date(rs.getTimestamp(i).getTime()); } } else if (SQL_FIELD_PERCENT_COMPLETE.equalsIgnoreCase(column)) { if (c instanceof Task) { short percentage = rs.getShort(i); ((Task) c).getPercentComplete().setPropertyValue(String.valueOf(percentage)); if (percentage == 100) { ((Task) c).getComplete().setPropertyValue(Boolean.TRUE); } else { ((Task) c).getComplete().setPropertyValue(Boolean.FALSE); } } } else if (SQL_FIELD_FOLDER.equalsIgnoreCase(column)) { c.getFolder().setPropertyValue(rs.getString(i)); } else if (SQL_FIELD_START_DATE_TIME_ZONE.equalsIgnoreCase(column)) { c.getDtStart().setTimeZone(rs.getString(i)); // @todo Set the same time zone for other non-UTC and // non-all-day date-time properties } else if (SQL_FIELD_END_DATE_TIME_ZONE.equalsIgnoreCase(column)) { c.getDtEnd().setTimeZone(rs.getString(i)); } else if (SQL_FIELD_REMINDER_TIME_ZONE.equalsIgnoreCase(column)) { c.getReminder().setTimeZone(rs.getString(i)); } // Unhandled columns are just ignored } if (dstart != null) { c.getDtStart().setPropertyValue(getStringFromDate(aDay, dstart)); } if (dend != null) { c.getDtEnd().setPropertyValue(getStringFromDate(aDay, dend)); } if (replyTime != null && (c instanceof Event)) { ((Event) c).getReplyTime().setPropertyValue(getStringFromDate(aDay, // @todo or false? replyTime)); } if (completed != null && (c instanceof Task)) { ((Task) c).getDateCompleted().setPropertyValue(getStringFromDate(aDay, completed)); } if (reminderTime != null) { // // Also the reminder time follows the start and end dates convention // relative to the all day format: if the all day flag is on then it // has to be interpreted as a local time (else in UTC). // r.setTime(getStringFromDate(aDay, reminderTime)); if (dstart != null) { r.setMinutes((int) ((dstart.getTime() - reminderTime.getTime()) / (60000))); // 60 seconds in a minutes * // 1000 millis in a second = 60000 } else { r.setMinutes(0); } } switch (recurrenceType) { case RecurrencePattern.TYPE_DAILY: rp = RecurrencePattern.getDailyRecurrencePattern(interval, startDatePattern, endDatePattern, noEndDate, occurrences, dayOfWeekMask); c.setRecurrencePattern(rp); break; case RecurrencePattern.TYPE_WEEKLY: rp = RecurrencePattern.getWeeklyRecurrencePattern(interval, dayOfWeekMask, startDatePattern, endDatePattern, noEndDate, occurrences); c.setRecurrencePattern(rp); break; case RecurrencePattern.TYPE_MONTHLY: rp = RecurrencePattern.getMonthlyRecurrencePattern(interval, dayOfMonth, startDatePattern, endDatePattern, noEndDate, occurrences); c.setRecurrencePattern(rp); break; case RecurrencePattern.TYPE_MONTH_NTH: rp = RecurrencePattern.getMonthNthRecurrencePattern(interval, dayOfWeekMask, instance, startDatePattern, endDatePattern, noEndDate, occurrences); c.setRecurrencePattern(rp); break; case RecurrencePattern.TYPE_YEARLY: rp = RecurrencePattern.getYearlyRecurrencePattern(interval, dayOfMonth, monthOfYear, startDatePattern, endDatePattern, noEndDate, occurrences); c.setRecurrencePattern(rp); break; case RecurrencePattern.TYPE_YEAR_NTH: rp = RecurrencePattern.getYearNthRecurrencePattern(interval, dayOfWeekMask, monthOfYear, instance, startDatePattern, endDatePattern, noEndDate, occurrences); c.setRecurrencePattern(rp); break; default: // // ignore any unknown recurrence pattern type // break; } // // Set timezone in the RecurrencePattern using the dtStart timezone. // Note: the tasks could have only the due date (or neither that) // if (rp != null) { if (!isAnEvent && dend != null) { rp.setTimeZone(c.getDtEnd().getTimeZone()); } else { rp.setTimeZone(c.getDtStart().getTimeZone()); } c.setRecurrencePattern(rp); } return cw; }