git-svn-id: https://svn.coded.pt/svn/SIPRP@1522 bb69d46d-e84e-40c8-a05a-06db0d633741

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Diogo Neves 15 years ago
parent 58e860b8be
commit f14d42689f

@ -67,7 +67,7 @@ public class Db
public Connection connect() throws Exception
{
Class.forName("org.postgresql.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, User, Pass);
// connection = DriverManager.getConnection(connectionURL, User, Pass);
connection = DriverManager.getConnection(connectionURL, User, Pass);
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);

@ -17,13 +17,26 @@ import java.sql.Statement;
*/
public class DbRelatorios
{
// String connectionURL = "jdbc:postgresql://evoserver:5432/siprp_20100813"; //testes
String connectionURL = "jdbc:postgresql://localhost:5436/siprp"; //real
//production
private String server = "localhost";
private int port = 5436;
private String db_name = "siprp";
private String User = "postgres";
private String Pass = null;
//tests
// private String server = "evoserver";
// private int port = 5432;
// private String db_name = "siprp_20100813";
// private String User = "postgres";
// private String Pass = null;
private String connectionURL = "jdbc:postgresql://" + server + ":" + port + "/" + db_name;
// String connectionURL = "jdbc:postgresql://evoserver:5432/siprp_20100813"; //testes
// String connectionURL = "jdbc:postgresql://localhost:5436/siprp"; //real
String User = "postgres";
String Pass = null;
Connection connection = null;
private Connection connection = null;
public Connection connect() throws Exception
{
@ -32,7 +45,7 @@ public class DbRelatorios
//ApplicationBean1 application = JSFUtils.getApplicationBean(fc);
//if(application.getConnection() == null)
//{
connection = DriverManager.getConnection(connectionURL, User, Pass);
connection = DriverManager.getConnection( connectionURL, User, Pass );
//application.setConnection(connection);
//}
@ -59,16 +72,16 @@ public class DbRelatorios
////FacesContext fc = FacesContext.getCurrentInstance();
////ApplicationBean1 application = JSFUtils.getApplicationBean(fc);
////connection = application.getConnection();
Statement st;
Statement st = null;
try
{
st = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
return st;
st = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
}
catch(Exception ex)
catch ( Exception ex )
{
System.out.println( "\nDbRelatorios . createStatement() : " + ex.getMessage() );
ErrorLogger.logException( ex );
return null;
}
return st;
}
}

@ -19,14 +19,26 @@ import com.evolute.utils.error.ErrorLogger;
*/
public class DblocalRelatorios
{
// String connectionURL = "jdbc:postgresql://evoserver/siprp_local_3_20100813"; //testes local_3
String connectionURL = "jdbc:postgresql://localhost:5436/siprp_local_3";
//production
private String server = "localhost";
private int port = 5436;
private String db_name = "siprp_local_3";
private String User = "postgres";
private String Pass = null;
//tests
// private String server = "evoserver";
// private int port = 5432;
// private String db_name = "siprp_local_3_20100813";
// private String User = "postgres";
// private String Pass = null;
private String connectionURL = "jdbc:postgresql://" + server + ":" + port + "/" + db_name;
// String connectionURL = "jdbc:postgresql://evoserver/siprp_local_3_20100813"; //testes local_3
// String connectionURL = "jdbc:postgresql://localhost:5436/siprp_local_3";
String User = "postgres";
String Pass = null;
Connection connection = null;
private Connection connection = null;
public Connection connect() throws Exception
{

@ -25,9 +25,10 @@ import utils.Utils;
*
* @author lluis
*/
public class CreatePlanosDataProvider {
DbRelatorios db;
DblocalRelatorios dblocal;
public class CreatePlanosDataProvider
{
private DbRelatorios db;
private DblocalRelatorios dblocal;
public CreatePlanosDataProvider()
{
@ -38,8 +39,9 @@ public class CreatePlanosDataProvider {
dblocal = new DblocalRelatorios();
dblocal.connect();
}
catch(Exception ex)
catch ( Exception ex )
{
System.out.println( "CreatePlanosDataProvider . () : " + ex.getMessage() );
ErrorLogger.logException( ex );
}
}
@ -635,15 +637,43 @@ public class CreatePlanosDataProvider {
}
protected Statement createStatement()
private Statement createStatement()
{
return db.createStatement();
Statement st = null;
try
{
if ( db == null )
{
db = new DbRelatorios();
db.connect();
}
protected Statement createLocalStatement()
st = db.createStatement();
}
catch ( Exception e )
{
System.out.println( "\nCreatePlanosDataProvider . createStatement() : db was null ! error connecting : " + e.getMessage() );
ErrorLogger.logException( e );
}
return st;
}
return dblocal.createStatement();
private Statement createLocalStatement()
{
Statement st = null;
try
{
if ( dblocal == null )
{
dblocal = new DblocalRelatorios();
dblocal.connect();
}
st = dblocal.createStatement();
}
catch ( Exception e )
{
System.out.println( "\nCreatePlanosDataProvider . createLocalStatement() : dblocal was null ! error connecting : " + e.getMessage() );
ErrorLogger.logException( e );
}
return st;
}
}

@ -85,6 +85,7 @@ public class EvoBaseProvider
UnicodeChecker.setUseDoubleSlash( true );
Insert.setDefaultKeyRetriever( PostgresqlAutoKeyRetriever.RETRIEVER );
dbManager = manager;
System.out.println( "\nDBManager : " + dbManager );
Singleton.setInstance( Singleton.DEFAULT_DBMANAGER, dbManager );
}
@ -116,6 +117,6 @@ public class EvoBaseProvider
init();
}
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
return dbm.getSharedExecuter( clazz );
return dbm.getSharedExecuter( this );
}
}

@ -5,11 +5,13 @@
package db.providers;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.db.Executer;
import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Update;
import com.evolute.utils.strings.StringPlainer;
import db.entidades.Area;
@ -287,10 +289,10 @@ public class PlanosDataProvider extends GenericDataProvider{
new Assignment( new Field( "verificacao_siprp" ), r.getVerificacao_siprp() )
}, where );
System.out.println( "SQL UPDATE RISCO : " + upd.toString() );
ErrorLogger.log( "SAVE : PlanosDataProvider.updateRisco( " + r.getId() + " ) : " + upd.toString() );
ErrorLogger.log( "\nSAVE : PlanosDataProvider.updateRisco( " + r.getId() + " ) : " + upd.toString() );
Executer executer = EvoBaseProvider.getInstance().getExecuter();
executer.executeQuery( upd );
System.out.println( "\n\tUPDATE RISCO SUCCESS !" );
// Statement st = createStatement();
// String sql = "";
@ -801,6 +803,7 @@ public class PlanosDataProvider extends GenericDataProvider{
// return list;
// }
private ArrayList getFullPlanos(ResultSet rs) throws Exception
{
ArrayList list = new ArrayList();
@ -875,7 +878,6 @@ public class PlanosDataProvider extends GenericDataProvider{
{
List<Risco> riscos = new ArrayList<Risco>();
Statement st = createStatement();
// String sql = "SELECT * FROM plano_riscos WHERE area_id = " + a.getId() + " ORDER BY valor DESC";
String sql = "SELECT plano_riscos.*, coalesce(valor,-1) as ordem_valor FROM plano_riscos " +
"WHERE area_id = " + a.getId() + " ORDER BY ordem_valor DESC, area_id, risco_id;";
ResultSet rs = st.executeQuery(sql);
@ -888,27 +890,10 @@ public class PlanosDataProvider extends GenericDataProvider{
Risco r = new Risco();
r.setId( new Integer(rs.getInt("id")) );
r.setArea_id(new Integer( rs.getInt("area_id") ));
r.setDescricao(Utils.unicodeToHTML(rs.getString("descricao")));
//// r.setResponsavel_execucao(rs.getString("responsavel_execucao"));
// r.setRecursos_necessarios(rs.getString("recursos_necessarios"));
// java.sql.Date sqlDataInicio = rs.getDate("data_inicio");
// if(sqlDataInicio != null)
// {
// r.setData_inicio(new java.util.Date(sqlDataInicio.getTime()));
// }
//
// java.sql.Date sqlDataFim = rs.getDate("data_fim");
// if(sqlDataFim != null)
// {
// r.setData_fim(new java.util.Date(sqlDataFim.getTime()));
// }
//r.setValores(getValoresByRisco(r));
r.setResponsavel_execucao(rs.getString("responsavel_execucao"));
r.setPor(rs.getString("por"));
r.setRecursos_necessarios(rs.getString("recursos_necessarios"));
r.setDescricao( Utils.unicodeToHTML(rs.getString( "descricao" ) ) );
r.setResponsavel_execucao( Utils.unicodeToHTML( rs.getString("responsavel_execucao") ) );
r.setPor( rs.getString( "por" ) );
r.setRecursos_necessarios( Utils.unicodeToHTML( rs.getString("recursos_necessarios") ) );
java.sql.Date sqlDataInicio = rs.getDate("data_inicio");
if(sqlDataInicio != null)
{
@ -920,14 +905,17 @@ public class PlanosDataProvider extends GenericDataProvider{
{
r.setData_fim(new java.util.Date(sqlDataFim.getTime()));
}
r.setParecer_dl(rs.getString("parecer_dl"));
r.setParecer_dns(rs.getString("parecer_dns"));
r.setVerificacao_siprp(rs.getString("verificacao_siprp"));
r.setParecer_dl( Utils.unicodeToHTML( rs.getString("parecer_dl") ) );
r.setParecer_dns( Utils.unicodeToHTML( rs.getString("parecer_dns") ) );
// r.setVerificacao_siprp(rs.getString("verificacao_siprp"));
r.setVerificacao_siprp( Utils.unicodeToHTML( rs.getString( "verificacao_siprp" ) ) );
r.setMedidas(getMedidasByRisco(r));
Object valorObject = rs.getObject("valor");
r.setValor( valorObject == null ? null : (Integer) valorObject );
riscos.add(r);
}while(rs.next());
}
while ( rs.next() );
}
return riscos;
}

@ -9,7 +9,7 @@ import db.entidades.Area;
import db.entidades.PlanoActuacao;
import db.entidades.Risco;
import db.entidades.Valor;
import java.util.HashMap;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Vector;
@ -17,7 +17,8 @@ import java.util.Vector;
*
* @author lluis
*/
public class Pagination {
public class Pagination implements Serializable
{
private int TOTAL_PAGINAS;
//private HashMap<Integer, Risco> riscosHash = new HashMap();
private Vector<Risco> riscosVector = new Vector();

Loading…
Cancel
Save