|  |  | @ -81,12 +81,47 @@ public class AnalisesDataProvider { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return c; |  |  |  |         return c; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public Controle getControloByAno(Integer ano) throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Controle c = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Statement st = createStatement(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String sql = "SELECT * FROM controle WHERE analise_year = " + ano; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         ResultSet rs = st.executeQuery(sql); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if(rs.isBeforeFirst()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             rs.first(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             c = new Controle(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             c.setId(new Integer( rs.getInt("id") )); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             c.setAnalise_year( new Integer( rs.getInt( "analise_year" ) )); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             c.setLast_analise_nr( new Integer( rs.getInt( "last_analise_nr" ) ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return c; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public Controle createAnoNumeracao(Integer ano) throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Controle c = new Controle(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Integer newId = getMaxControleId(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         c.setId(newId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         c.setAnalise_year(ano); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         c.setLast_analise_nr(new Integer(0)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Statement st = createStatement(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String sql = "INSERT INTO controle (id, analise_year, last_analise_nr) VALUES ("; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         sql += c.getId() + ", "; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         sql += c.getAnalise_year() + ", "; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         sql += c.getLast_analise_nr() + ")"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         st.execute(sql); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return c; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void updateControle( Controle c ) throws Exception |  |  |  |     public void updateControle( Controle c ) throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  |     { |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |         Statement st = createStatement();     |  |  |  |         Statement st = createStatement();     | 
			
		
	
		
		
			
				
					
					|  |  |  | 	String sql = "UPDATE controle SET analise_year = " + c.getAnalise_year() + ", "; |  |  |  | 	String sql = "UPDATE controle SET analise_year = " + c.getAnalise_year() + ", "; | 
			
		
	
		
		
			
				
					
					|  |  |  |         sql += "last_analise_nr = " + c.getLast_analise_nr() + " "; |  |  |  |         sql += "last_analise_nr = " + c.getLast_analise_nr() + " "; | 
			
		
	
		
		
			
				
					
					|  |  |  |         sql += "WHERE id = 1"; |  |  |  |         sql += "WHERE id = " + c.getId(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	st.execute(sql);                                            |  |  |  | 	st.execute(sql);                                            | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
	
		
		
			
				
					|  |  | @ -1227,6 +1262,27 @@ public class AnalisesDataProvider { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	st.execute(sql);                                    |  |  |  | 	st.execute(sql);                                    | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public Integer getMaxControleId() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Statement st = createStatement(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         String sql = "SELECT max(controle.id)+1 AS MAXCONTROLEID FROM controle"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         try | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ResultSet rs = st.executeQuery(sql); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             rs.first(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             Integer newId = new Integer(rs.getInt("MAXCONTROLEID")); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if(newId.intValue() == 0 ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 newId = new Integer(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return newId; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         catch(Exception ex) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return new Integer(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     public Integer getMaxAnaliseId() |  |  |  |     public Integer getMaxAnaliseId() | 
			
		
	
		
		
			
				
					
					|  |  |  |     { |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |         Statement st = createStatement(); |  |  |  |         Statement st = createStatement(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -1251,7 +1307,7 @@ public class AnalisesDataProvider { | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |      public AnaliseAcidente createAnalise(AnaliseAcidente a) throws Exception |  |  |  |      public AnaliseAcidente createAnalise(AnaliseAcidente a) throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  |     { |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |         Controle c = getControle(); |  |  |  |         //Controle c = getControle();
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         Statement st = createStatement(); |  |  |  |         Statement st = createStatement(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         Integer newId = getMaxAnaliseId(); |  |  |  |         Integer newId = getMaxAnaliseId(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -1262,6 +1318,11 @@ public class AnalisesDataProvider { | 
			
		
	
		
		
			
				
					
					|  |  |  |         //cal.setTime(now);        
 |  |  |  |         //cal.setTime(now);        
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         cal.setTime(data_acidente); |  |  |  |         cal.setTime(data_acidente); | 
			
		
	
		
		
			
				
					
					|  |  |  |         int ano = cal.get(Calendar.YEAR); |  |  |  |         int ano = cal.get(Calendar.YEAR); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Controle c = getControloByAno(new Integer(ano)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if(c == null) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             c = createAnoNumeracao(new Integer(ano)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | //        if(c.getAnalise_year().intValue() != ano)
 |  |  |  | //        if(c.getAnalise_year().intValue() != ano)
 | 
			
		
	
		
		
			
				
					
					|  |  |  | //        {
 |  |  |  | //        {
 | 
			
		
	
		
		
			
				
					
					|  |  |  | //            c.setAnalise_year(new Integer(ano));
 |  |  |  | //            c.setAnalise_year(new Integer(ano));
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -1675,6 +1736,8 @@ public class AnalisesDataProvider { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return newId;         |  |  |  |         return newId;         | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void updateMedida(Medida m) throws Exception |  |  |  |     public void updateMedida(Medida m) throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  |     { |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |         Statement st = createStatement();     |  |  |  |         Statement st = createStatement();     | 
			
		
	
	
		
		
			
				
					|  |  | 
 |