diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java
index 93964426..73ae3edc 100644
--- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java
+++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java
@@ -3,6 +3,7 @@ package siprp.higiene.gestao.postos;
import static com.evolute.utils.strings.UnicodeLatin1Map.aacute;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
+import static com.evolute.utils.strings.UnicodeLatin1Map.eacute;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
@@ -10,11 +11,14 @@ import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.swing.BorderFactory;
+import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -58,6 +62,8 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
public final LeafButton buttonPostoEditar = LeafIconButton.createDefaultEditButton();
public final LeafButton buttonPostoRemover = LeafIconButton.createDefaultRemoveButton();
+
+ private final JCheckBox checkGenerico = new JCheckBox( "Gen"+eacute+"rico" );
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
@@ -97,7 +103,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
setLayout( layout );
layout = new TableLayout( new double[] {
- TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL
+ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL
}, new double[] {
TableLayout.MINIMUM
} );
@@ -133,6 +139,8 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
panel.add( buttonPostoRemover );
panelButtons.add( panel, new TableLayoutConstraints( 1, 0 ) );
+ panelButtons.add( checkGenerico, new TableLayoutConstraints(2,0));
+
panelTree.add( scroll, new TableLayoutConstraints( 0, 0 ) );
add( panelButtons, new TableLayoutConstraints( 0, 0 ) );
@@ -146,7 +154,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
@Override
public void valueChanged( TreeSelectionEvent e )
{
- setEnabled();
+ setSelected();
}
} );
buttonAreaCriar.addActionListener( new ActionListener()
@@ -197,6 +205,25 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
removerPosto();
}
} );
+ checkGenerico.addItemListener( new ItemListener()
+ {
+ @Override
+ public void itemStateChanged( ItemEvent e )
+ {
+ HsPosto posto = getSelectedPosto();
+ if( posto != null )
+ {
+ posto.setIsPrincipal( checkGenerico.isSelected() );
+ try
+ {
+ posto.save();
+ } catch( Exception e1 )
+ {
+ e1.printStackTrace();
+ }
+ }
+ }
+ } );
}
private void criarArea()
@@ -357,7 +384,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
return result;
}
- private void setEnabled()
+ private void setSelected()
{
TreePath path = tree.getSelectionPath();
TreeNode node = path == null ? null : (TreeNode) path.getLastPathComponent();
@@ -369,6 +396,14 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
buttonAreaRemover.setEnabled( areaSelected );
buttonAreaCriar.setEnabled( empresa != null );
buttonAreaEditar.setEnabled( areaSelected );
+ checkGenerico.setEnabled( postoSelected );
+ boolean generico = false;
+ if( postoSelected && node != null)
+ {
+ HsPosto posto = (HsPosto) ((PostoNode) node).getUserObject();
+ generico = posto != null && (posto.getIsPrincipal() ==null ? false : posto.getIsPrincipal() );
+ }
+ checkGenerico.setSelected(generico);
}
public void refresh()
@@ -383,7 +418,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
addArea( area );
}
}
- setEnabled();
+ setSelected();
TreeTools.refreshTree( tree, root, false );
}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java
index 083ee31d..0fe24b01 100644
--- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java
+++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java
@@ -315,6 +315,17 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
if( JOptionPane.YES_OPTION == ret )
{
HigieneSegurancaLogic.reverterRelatorio(relatorio);
+ if( relatorio != null )
+ {
+ try
+ {
+ relatorio.save();
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
setRelatorio( relatorio, false );
}
}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java
index c3b69382..42a0fa61 100644
--- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java
+++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java
@@ -141,7 +141,6 @@ public class VerAreasRelatorioPanel extends JPanel
{
TreeTools.merge( root, HigieneSegurancaLogic.getAreasRelatorioTree( relatorio ) );
}
-// TreeTools.sort( root );
TreeTools.refreshTree( tree, root, false );
}
diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java
index e0dbe07e..dc1a901d 100644
--- a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java
+++ b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java
@@ -24,6 +24,7 @@ import siprp.update.updates.V10_9_To_V11_0;
import siprp.update.updates.V11_0_To_V11_1;
import siprp.update.updates.V11_1_To_V11_2;
import siprp.update.updates.V11_2_To_V11_3;
+import siprp.update.updates.V11_3_To_V11_4;
import siprp.update.updates.V6_1_To_V7_0;
import siprp.update.updates.V7_0_To_V7_2;
import siprp.update.updates.V7_2_To_V7_4;
@@ -92,7 +93,8 @@ public class UpdateList
new V10_5_To_V10_6(), new V10_6_To_V10_7(),
new V10_7_To_V10_8(), new V10_8_To_V10_9(),
new V10_9_To_V11_0(), new V11_0_To_V11_1(),
- new V11_1_To_V11_2(), new V11_2_To_V11_3()
+ new V11_1_To_V11_2(), new V11_2_To_V11_3(),
+ new V11_3_To_V11_4()
};
protected static Executer EXECUTER;
diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V11_2_To_V11_3.java b/trunk/SIPRPSoft/src/siprp/update/updates/V11_2_To_V11_3.java
index 67ebdf9d..1fabac5c 100644
--- a/trunk/SIPRPSoft/src/siprp/update/updates/V11_2_To_V11_3.java
+++ b/trunk/SIPRPSoft/src/siprp/update/updates/V11_2_To_V11_3.java
@@ -41,7 +41,7 @@ public class V11_2_To_V11_3 implements siprp.update.Update
"alter table hs_relatorio_area add column ordem int4; " +
"alter table hs_area add column ordem int4; " +
"alter table hs_relatorio_posto_risco add column ordem int4; " +
- "alter table hs_posto_risco add column ordem int4; "
+ "alter table hs_posto_risco add column ordem int4; "
);
executer.executeQuery( update );
new Importador( executer ).importar();
diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V11_3_To_V11_4.java b/trunk/SIPRPSoft/src/siprp/update/updates/V11_3_To_V11_4.java
new file mode 100644
index 00000000..db480647
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/update/updates/V11_3_To_V11_4.java
@@ -0,0 +1,51 @@
+package siprp.update.updates;
+
+import siprp.higiene.gestao.importacao.Importador;
+
+import com.evolute.utils.Singleton;
+import com.evolute.utils.db.DBManager;
+import com.evolute.utils.db.Executer;
+
+public class V11_3_To_V11_4 implements siprp.update.Update
+{
+
+ public V11_3_To_V11_4()
+ {
+ }
+
+ public String []listChanges()
+ {
+ return new String[]{
+ "Higiene e seguranca: restruturacao"
+ };
+ }
+
+ public double getStartVersion()
+ {
+ return 11.3;
+ }
+
+ public double getEndVersion()
+ {
+ return 11.4;
+ }
+
+ public void doUpdate() throws Exception
+ {
+ DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
+ Executer executer = dbm.getSharedExecuter();
+ com.evolute.utils.sql.Update update =
+ new com.evolute.utils.sql.Update(
+ "alter table hs_legislacao_estabelecimento add column ordem int4; " +
+ "alter table hs_relatorio_legislacao add column ordem int4; "
+ );
+ executer.executeQuery( update );
+ new Importador( executer ).importar();
+ }
+
+ public String toString()
+ {
+ return "v" + getStartVersion() + " para v" + getEndVersion();
+ }
+
+}
diff --git a/trunk/common/src/SIPRPMap.map.xml b/trunk/common/src/SIPRPMap.map.xml
index 7a4359e5..2bad8c45 100644
--- a/trunk/common/src/SIPRPMap.map.xml
+++ b/trunk/common/src/SIPRPMap.map.xml
@@ -254,6 +254,7 @@
+
@@ -366,6 +367,7 @@
+
ORACLE
hs_relatorio_legislacao_id_seq
@@ -985,6 +987,7 @@
+
@@ -1048,6 +1051,7 @@
+
@@ -1970,17 +1974,17 @@
-
-
+
+
-
+
-
+
diff --git a/trunk/common/src/leaf/ui/TreeTools.java b/trunk/common/src/leaf/ui/TreeTools.java
index 6f944e94..1b5373f9 100644
--- a/trunk/common/src/leaf/ui/TreeTools.java
+++ b/trunk/common/src/leaf/ui/TreeTools.java
@@ -25,6 +25,10 @@ public class TreeTools
{
return o2 == null ? 0 : -1;
}
+ else if( (o1 instanceof Comparable ) && (o2 instanceof Comparable))
+ {
+ return ((Comparable)o1).compareTo( (Comparable) o2 );
+ }
else
{
return o2 == null ? 1 : StringPlainer.convertString( o1.toString() ).compareTo( StringPlainer.convertString( o2.toString() ) );
@@ -157,7 +161,7 @@ public class TreeTools
}
}
- public static void sort( DefaultMutableTreeNode result )
+ public static void sort( DefaultMutableTreeNode result, boolean useDefaultComparator )
{
if( result != null )
{
@@ -167,7 +171,10 @@ public class TreeTools
children.add( (DefaultMutableTreeNode) result.getChildAt( i ) );
}
result.removeAllChildren();
- Collections.sort( children, comparator );
+ if( useDefaultComparator )
+ {
+ Collections.sort( children, comparator );
+ }
for( DefaultMutableTreeNode child : children )
{
sort( child );
@@ -175,6 +182,10 @@ public class TreeTools
}
}
}
+ public static void sort( DefaultMutableTreeNode result )
+ {
+ sort( result, true );
+ }
public static void sort( DefaultMutableTreeNode result, Comparator comparator )
{
diff --git a/trunk/common/src/siprp/database/cayenne/objects/BaseObject.java b/trunk/common/src/siprp/database/cayenne/objects/BaseObject.java
index 1be56ffd..889ccea4 100644
--- a/trunk/common/src/siprp/database/cayenne/objects/BaseObject.java
+++ b/trunk/common/src/siprp/database/cayenne/objects/BaseObject.java
@@ -89,18 +89,20 @@ public class BaseObject extends CayenneDataObject implements Comparable areas = relatorio.getHsRelatorioArea();
+ for( HsRelatorioArea area : areas )
{
AreaRelatorioNode areaNode = new AreaRelatorioNode(area);
for( HsRelatorioPosto posto : area.getHsRelatorioPostoArray() )
@@ -196,7 +198,8 @@ public class HigieneSegurancaLogic
reverterNormalizacao( relatorio, estabelecimento );
}
}
- } catch( Exception e )
+ }
+ catch( Exception e )
{
LeafDialog.error(e);
}
@@ -230,6 +233,7 @@ public class HigieneSegurancaLogic
{
rArea = new HsRelatorioArea();
rArea.setDescription( area.getDescription() );
+ rArea.setOrder( area.getOrder() );
rArea.setToHsRelatorio( relatorio );
areasInserted.put(area,rArea);
}
@@ -248,6 +252,7 @@ public class HigieneSegurancaLogic
HsRelatorioPostoRisco rPostoRisco = new HsRelatorioPostoRisco();
rPostoRisco.setToHsRelatorioPosto( rPosto );
rPostoRisco.setToHsRelatorioRisco( rRelatorioRisco );
+ rPostoRisco.setOrder( postoRisco.getOrder() );
for( HsRiscoMedida riscoMedida : postoRisco.getToHsRisco().getHsRiscoMedidaArray() )
{
HsRelatorioMedida rMedida = new HsRelatorioMedida();
@@ -264,14 +269,16 @@ public class HigieneSegurancaLogic
private static void reverterLegislacao( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception
{
- for(HsRelatorioLegislacao legislacao : relatorio.getHsRelatorioLegislacaoArray())
+ int legislacaoSize = relatorio.getHsRelatorioLegislacaoArray().size();
+ for(int i = 0; i < legislacaoSize; ++i )
{
- legislacao.delete();
+ relatorio.getHsRelatorioLegislacaoArray().get( 0 ).delete();
}
for( HsLegislacaoEstabelecimento rel : estabelecimento.getHsLegislacaoEstabelecimentoArray() )
{
HsLegislacao legislacao = rel.getToHsLegislacao();
HsRelatorioLegislacao relatorioLegislacao = criarRelatorioLegislacao( relatorio, legislacao );
+ relatorioLegislacao.setOrdem( rel.getOrdem() );
relatorioLegislacao.save();
}
}
@@ -292,9 +299,10 @@ public class HigieneSegurancaLogic
private static void reverterNormalizacao( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception
{
- for(HsRelatorioNormalizacao normalizacao : relatorio.getHsRelatorioNormalizacaoArray() )
+ int normalizacaoSize = relatorio.getHsRelatorioNormalizacaoArray().size();
+ for(int i = 0; i < normalizacaoSize; ++i )
{
- normalizacao.delete();
+ relatorio.getHsRelatorioNormalizacaoArray().get( 0 ).delete();
}
for( HsNormalizacaoEstabelecimento rel : estabelecimento.getHsNormalizacaoEstabelecimentoArray() )
{
@@ -527,54 +535,37 @@ public class HigieneSegurancaLogic
DefaultMutableTreeNode result = new DefaultMutableTreeNode();
DefaultMutableTreeNode geral = new DefaultMutableTreeNode( "Legisla" + ccedil + atilde + "o de aplica" + ccedil + atilde + "o geral" );
DefaultMutableTreeNode especifica = new DefaultMutableTreeNode( "Legisla" + ccedil + atilde + "o espec" + iacute + "fica" );
- for( HsLegislacao legislacao : planoProvider.getAllLegislacaoGeral() )
+ if( estabelecimento != null )
{
- if( estabelecimento == null || hasEstabelecimento( legislacao, estabelecimento ) )
+ for( HsLegislacaoEstabelecimento rel : estabelecimento.getHsLegislacaoEstabelecimentoArray() )
{
- DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( legislacao );
- geral.add( legislacaoNode );
- }
- }
- for( HsLegislacaoCategoria categoria : planoProvider.getAllLegislacaoCategorias( ) )
- {
- boolean addCategory = false;
- DefaultMutableTreeNode categoriaNode = new DefaultMutableTreeNode( categoria );
- for( HsLegislacao legislacao : categoria.getHsLegislacaoArray() )
- {
- if( estabelecimento == null || hasEstabelecimento( legislacao, estabelecimento ) )
+ HsLegislacao legislacao = rel.getToHsLegislacao();
+ if( legislacao != null )
{
- DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( legislacao );
- categoriaNode.add( legislacaoNode );
- addCategory = true;
+ HsLegislacaoCategoria categoria = legislacao.getToHsLegislacaoCategoria();
+ if( categoria == null )
+ {
+ DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( rel.getToHsLegislacao() );
+ geral.add( legislacaoNode );
+ }
+ else
+ {
+ DefaultMutableTreeNode categoriaNode = TreeTools.findNodeWithUserObject( categoria, especifica );
+ if( categoriaNode == null )
+ {
+ categoriaNode = new DefaultMutableTreeNode(categoria);
+ especifica.add(categoriaNode);
+ }
+ DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( rel.getToHsLegislacao() );
+ categoriaNode.add( legislacaoNode );
+ }
}
-
- }
- if( addCategory)
- {
- especifica.add( categoriaNode );
}
}
result.add( geral );
result.add( especifica );
return result;
}
-
- private static boolean hasEstabelecimento( HsLegislacao legislacao, Estabelecimentos estabelecimento )
- {
- boolean result = false;
- if( legislacao != null && estabelecimento != null )
- {
- for( HsLegislacaoEstabelecimento rel : legislacao.getHsLegislacaoEstabelecimentoArray() )
- {
- result = estabelecimento.equals( rel.getToHsEstabelecimento());
- if( result )
- {
- break;
- }
- }
- }
- return result;
- }
public static DefaultMutableTreeNode getEquipamentosTree()
{