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

lxbfYeaa
Tiago Simão 17 years ago
parent 08b9f2c410
commit 88ce661100

@ -23,6 +23,8 @@ import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsPosto; import siprp.database.cayenne.objects.HsPosto;
import siprp.database.cayenne.objects.HsPostoEstabelecimento; import siprp.database.cayenne.objects.HsPostoEstabelecimento;
import siprp.logic.HigieneSegurancaLogic; import siprp.logic.HigieneSegurancaLogic;
import siprp.logic.node.AreaNode;
import siprp.logic.node.PostoNode;
public class AdicionarAreasPanel extends JPanel public class AdicionarAreasPanel extends JPanel
{ {

@ -30,6 +30,8 @@ import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.HsArea; import siprp.database.cayenne.objects.HsArea;
import siprp.database.cayenne.objects.HsPosto; import siprp.database.cayenne.objects.HsPosto;
import siprp.logic.node.AreaNode;
import siprp.logic.node.PostoNode;
public class GerirAreasPanel extends JPanel public class GerirAreasPanel extends JPanel
{ {

@ -27,6 +27,7 @@ import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRisco; import siprp.database.cayenne.objects.HsRisco;
import siprp.database.cayenne.objects.HsRiscoEmpresa; import siprp.database.cayenne.objects.HsRiscoEmpresa;
import siprp.logic.HigieneSegurancaLogic; import siprp.logic.HigieneSegurancaLogic;
import siprp.logic.node.NodeRisco;
public class AdicionarRiscosPanel extends JPanel public class AdicionarRiscosPanel extends JPanel
{ {

@ -116,7 +116,7 @@ public class AdicionarRiscosRelatorioPanel extends JPanel
public void refresh() public void refresh()
{ {
root.removeAllChildren(); root.removeAllChildren();
if( posto != null ) if( posto != null )
{ {
for( HsRelatorioPostoRisco rel : posto.getHsRelatorioPostoRiscoArray() ) for( HsRelatorioPostoRisco rel : posto.getHsRelatorioPostoRiscoArray() )

@ -183,17 +183,32 @@ public class GerirMedidaRelatorioPanel extends JPanel
private void setEnabled() private void setEnabled()
{ {
boolean medidaChanged = false; if( isEnabled() )
boolean requesitoChanged = false; {
if( relacao != null ) boolean medidaChanged = false;
boolean requesitoChanged = false;
if( relacao != null )
{
medidaChanged = !fieldTextMedida.getText().equals( relacao.getToHsRelatorioMedida().getDescription() );
requesitoChanged = !fieldTextRequisitosLegais.getText().equals( relacao.getToHsRelatorioMedida().getRequesitosLegais() );
}
fieldTextMedida.setEnabled( relacao != null );
fieldTextRequisitosLegais.setEnabled( relacao != null );
buttonSaveMedida.setEnabled( medidaChanged );
buttonSaveRequesito.setEnabled( requesitoChanged );
buttonRevertMedida.setEnabled( medidaChanged );
buttonRevertRequesito.setEnabled( requesitoChanged );
}
else
{ {
medidaChanged = !fieldTextMedida.getText().equals( relacao.getToHsRelatorioMedida().getDescription() ); buttonSaveMedida.setEnabled( false );
requesitoChanged = !fieldTextRequisitosLegais.getText().equals( relacao.getToHsRelatorioMedida().getRequesitosLegais() ); buttonSaveRequesito.setEnabled( false );
buttonRevertMedida.setEnabled( false );
buttonRevertRequesito.setEnabled( false );
fieldTextRequisitosLegais.setEnabled( false );
fieldTextMedida.setEnabled( false );
} }
buttonSaveMedida.setEnabled( medidaChanged );
buttonSaveRequesito.setEnabled( requesitoChanged );
buttonRevertMedida.setEnabled( medidaChanged );
buttonRevertRequesito.setEnabled( requesitoChanged );
} }
private void savePlano() private void savePlano()

@ -166,54 +166,67 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
private void setEnabled() private void setEnabled()
{ {
textProbabilidade.setEnabled( valoresRisco != null && radioValorQuantitativo.isSelected() ); if( isEnabled() )
textSeveridade.setEnabled( valoresRisco != null && radioValorQuantitativo.isSelected() );
radioValorQualitativo.setEnabled( valoresRisco != null );
radioValorQuantitativo.setEnabled( valoresRisco != null );
comboValorQualitativo.setEnabled( valoresRisco != null && radioValorQualitativo.isSelected() );
if( valoresRisco != null )
{ {
boolean changes = false; textProbabilidade.setEnabled( valoresRisco != null && radioValorQuantitativo.isSelected() );
boolean wasQual = valoresRisco.getToHsRelatorioRiscoValorQualitativo() != null; textSeveridade.setEnabled( valoresRisco != null && radioValorQuantitativo.isSelected() );
boolean isQual = radioValorQualitativo.isSelected(); radioValorQualitativo.setEnabled( valoresRisco != null );
if(!isQual) radioValorQuantitativo.setEnabled( valoresRisco != null );
comboValorQualitativo.setEnabled( valoresRisco != null && radioValorQualitativo.isSelected() );
if( valoresRisco != null )
{ {
changes = wasQual; boolean changes = false;
if(!changes) boolean wasQual = valoresRisco.getToHsRelatorioRiscoValorQualitativo() != null;
{ boolean isQual = radioValorQualitativo.isSelected();
boolean probChanged = false; if(!isQual)
boolean sevChanged = false; {
String prob = textProbabilidade.getText(); changes = wasQual;
String sev = textSeveridade.getText(); if(!changes)
if( prob == null ) {
{ boolean probChanged = false;
probChanged = valoresRisco.getProbabilidade() != null; boolean sevChanged = false;
} String prob = textProbabilidade.getText();
else String sev = textSeveridade.getText();
{ if( prob == null )
probChanged = !prob.equals(valoresRisco.getProbabilidade() == null ? "" : valoresRisco.getProbabilidade() + ""); {
} probChanged = valoresRisco.getProbabilidade() != null;
if( sev == null ) }
{ else
sevChanged = valoresRisco.getSeveridade() != null; {
} probChanged = !prob.equals(valoresRisco.getProbabilidade() == null ? "" : valoresRisco.getProbabilidade() + "");
else }
{ if( sev == null )
sevChanged = !sev.equals(valoresRisco.getSeveridade() == null ? "" : valoresRisco.getSeveridade() + "" ); {
sevChanged = valoresRisco.getSeveridade() != null;
}
else
{
sevChanged = !sev.equals(valoresRisco.getSeveridade() == null ? "" : valoresRisco.getSeveridade() + "" );
}
changes = probChanged || sevChanged;
} }
changes = probChanged || sevChanged;
} }
} else
else {
{ changes = !wasQual;
changes = !wasQual; if(!changes)
if(!changes) {
{ changes = !comboValorQualitativo.getSelectedItem().equals( valoresRisco.getToHsRelatorioRiscoValorQualitativo() );
changes = !comboValorQualitativo.getSelectedItem().equals( valoresRisco.getToHsRelatorioRiscoValorQualitativo() ); }
} }
buttonSave.setEnabled( changes );
buttonRevert.setEnabled( changes );
} }
buttonSave.setEnabled( changes ); }
buttonRevert.setEnabled( changes ); else
{
buttonRevert.setEnabled( false );
buttonSave.setEnabled( false );
radioValorQualitativo.setEnabled( false );
radioValorQuantitativo.setEnabled( false );
comboValorQualitativo.setEnabled( false );
textProbabilidade.setEnabled( false );
textSeveridade.setEnabled( false );
} }
} }

@ -12,6 +12,7 @@ import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Date;
import java.util.EventObject; import java.util.EventObject;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -41,6 +42,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png"; private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png";
private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png"; private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png";
private static final String ICON_NAME_SUBMIT = "siprp/higiene/relatorio/submit.png";
private final JCalendarPanel dataRelatorio = new JCalendarPanel( null ); private final JCalendarPanel dataRelatorio = new JCalendarPanel( null );
@ -61,6 +63,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE ); private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE );
private final LeafIconButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT ); private final LeafIconButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT );
private final LeafIconButton buttonSubmit = LeafIconButton.createButton( "Submeter plano de actua" + ccedil + atilde + "o", ICON_NAME_SUBMIT );
private final AdicionarEquipamentosPanel panelEquipamentos = new AdicionarEquipamentosPanel(); private final AdicionarEquipamentosPanel panelEquipamentos = new AdicionarEquipamentosPanel();
@ -130,8 +133,22 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
panelAcompanhantes.add( fieldNome3, new TableLayoutConstraints( 1, 2 ) ); panelAcompanhantes.add( fieldNome3, new TableLayoutConstraints( 1, 2 ) );
panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 2 ) ); panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 2 ) );
panelAcompanhantes.add( fieldFuncao3, new TableLayoutConstraints( 3, 2 ) ); panelAcompanhantes.add( fieldFuncao3, new TableLayoutConstraints( 3, 2 ) );
add( buttonSave, new TableLayoutConstraints( 0, 0 ) );
add( buttonRevert, new TableLayoutConstraints( 1, 0 ) ); TableLayout layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM
}, new double[] {
TableLayout.MINIMUM
} );
layout.setVGap( 5 );
layout.setHGap( 5 );
JPanel panel = new JPanel();
panel.setLayout( layout );
panel.add( buttonSave, new TableLayoutConstraints( 0, 0 ) );
panel.add( buttonRevert, new TableLayoutConstraints( 1, 0 ) );
panel.add( buttonSubmit, new TableLayoutConstraints( 3, 0 ) );
add( panel, new TableLayoutConstraints( 0, 0, 7, 0 ) );
add( new JLabel( "Data do relat" + oacute + "rio" ), new TableLayoutConstraints( 0, 1, 2, 1 ) ); add( new JLabel( "Data do relat" + oacute + "rio" ), new TableLayoutConstraints( 0, 1, 2, 1 ) );
add( dataRelatorio, new TableLayoutConstraints( 3, 1 ) ); add( dataRelatorio, new TableLayoutConstraints( 3, 1 ) );
add( new JLabel( "Avalia" + ccedil + atilde + "o" ), new TableLayoutConstraints( 4, 1 ) ); add( new JLabel( "Avalia" + ccedil + atilde + "o" ), new TableLayoutConstraints( 4, 1 ) );
@ -146,7 +163,6 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private void setupListeners() private void setupListeners()
{ {
fieldTecnico.addCaretListener( this );
fieldFuncao1.addCaretListener( this ); fieldFuncao1.addCaretListener( this );
fieldFuncao2.addCaretListener( this ); fieldFuncao2.addCaretListener( this );
fieldFuncao3.addCaretListener( this ); fieldFuncao3.addCaretListener( this );
@ -172,6 +188,24 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
revert(); revert();
} }
} ); } );
buttonSubmit.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
submit();
}
} );
}
private void submit()
{
if( relatorio != null )
{
relatorio.setIsSubmetido( new Date() );
relatorio.save();
refresh();
}
} }
private void save() private void save()
@ -180,15 +214,15 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
{ {
relatorio.setData( dataRelatorio.getDate() ); relatorio.setData( dataRelatorio.getDate() );
relatorio.setAvaliacaoInicial( radioInicial.isSelected() ); relatorio.setAvaliacaoInicial( radioInicial.isSelected() );
MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento(); // MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento();
if( marcacao != null ) // if( marcacao != null )
{ // {
MarcacoesTecnicosHst tecnico = marcacao.getToMarcacoesTecnicosHst(); // MarcacoesTecnicosHst tecnico = marcacao.getToMarcacoesTecnicosHst();
if( tecnico != null ) // if( tecnico != null )
{ // {
tecnico.setNome( fieldTecnico.getText() ); // tecnico.setNome( fieldTecnico.getText() );
} // }
} // }
} }
relatorio.setAcompanhante1( fieldNome1.getText() ); relatorio.setAcompanhante1( fieldNome1.getText() );
relatorio.setAcompanhante2( fieldNome2.getText() ); relatorio.setAcompanhante2( fieldNome2.getText() );
@ -197,6 +231,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
relatorio.setFuncaoAcompanhante1(fieldFuncao1.getText()); relatorio.setFuncaoAcompanhante1(fieldFuncao1.getText());
relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText()); relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText());
relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText()); relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText());
relatorio.save();
refresh(); refresh();
buttonRevert.setEnabled( false ); buttonRevert.setEnabled( false );
buttonSave.setEnabled( false ); buttonSave.setEnabled( false );
@ -249,13 +284,14 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
dataRelatorio.setEnabled( enabled ); dataRelatorio.setEnabled( enabled );
radioInicial.setEnabled( enabled );; radioInicial.setEnabled( enabled );;
radioPeriodica.setEnabled( enabled ); radioPeriodica.setEnabled( enabled );
fieldTecnico.setEnabled( enabled ); fieldTecnico.setEnabled( false );
fieldNome1.setEnabled( enabled ); fieldNome1.setEnabled( enabled );
fieldNome2.setEnabled( enabled ); fieldNome2.setEnabled( enabled );
fieldNome3.setEnabled( enabled ); fieldNome3.setEnabled( enabled );
fieldFuncao1.setEnabled( enabled ); fieldFuncao1.setEnabled( enabled );
fieldFuncao2.setEnabled( enabled ); fieldFuncao2.setEnabled( enabled );
fieldFuncao3.setEnabled( enabled ); fieldFuncao3.setEnabled( enabled );
buttonSubmit.setEnabled( enabled );
} }
public void setRelatorio( HsRelatorio relatorio ) public void setRelatorio( HsRelatorio relatorio )

@ -1,31 +1,34 @@
package siprp.higiene.relatorio; package siprp.higiene.relatorio;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; import static com.evolute.utils.strings.UnicodeLatin1Map.*;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints; import info.clearthought.layout.TableLayoutConstraints;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import com.evolute.utils.ui.image.ImagePanel;
import leaf.ui.LeafButton; import leaf.ui.LeafButton;
import leaf.ui.LeafIconButton;
import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioMedida;
import siprp.database.cayenne.objects.HsRelatorioPosto; import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRelatorioPostoMedida; import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco; import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.logic.HigieneSegurancaLogic;
public class PlanoActuacaoPanel extends JPanel public class PlanoActuacaoPanel extends JPanel
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png";
private static final String RISCO_PANEL = "RISCO_PANEL"; private static final String RISCO_PANEL = "RISCO_PANEL";
private static final String MEDIDA_PANEL = "MEDIDA_PANEL"; private static final String MEDIDA_PANEL = "MEDIDA_PANEL";
@ -46,7 +49,9 @@ public class PlanoActuacaoPanel extends JPanel
private final CardLayout cards = new CardLayout(); private final CardLayout cards = new CardLayout();
private final LeafButton submeterButton = new LeafButton( "Submeter plano de actua" + ccedil + atilde + "o" ); private final LeafButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT );
private HsRelatorio relatorio = null;
public PlanoActuacaoPanel() public PlanoActuacaoPanel()
{ {
@ -97,6 +102,27 @@ public class PlanoActuacaoPanel extends JPanel
} }
} }
} ); } );
buttonRevert.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
revert();
}
} );
}
private void revert()
{
if( relatorio != null )
{
int ret = JOptionPane.showConfirmDialog( this, "Todas as altera" + ccedil + otilde + "es ao plano de actua" + ccedil + atilde + "o ser" + atilde + "o perdidas\nTem a certeza?","Carregar configura"+ccedil+atilde+"o actual ",JOptionPane.YES_NO_OPTION);
if( JOptionPane.YES_OPTION == ret )
{
HigieneSegurancaLogic.reverterRelatorio(relatorio);
setRelatorio( relatorio );
}
}
} }
private void startupComponents() private void startupComponents()
@ -108,7 +134,7 @@ public class PlanoActuacaoPanel extends JPanel
private void startupLayout() private void startupLayout()
{ {
TableLayout layout = new TableLayout( TableLayout layout = new TableLayout(
new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.FILL }, new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL } new double[]{ TableLayout.MINIMUM, TableLayout.FILL }
); );
layout.setHGap( 5 ); layout.setHGap( 5 );
@ -122,17 +148,27 @@ public class PlanoActuacaoPanel extends JPanel
valoresPanel.add( valoresRisco, RISCO_PANEL); valoresPanel.add( valoresRisco, RISCO_PANEL);
valoresPanel.add( valoresMedida, MEDIDA_PANEL ); valoresPanel.add( valoresMedida, MEDIDA_PANEL );
valoresPanel.add( emptyPanel, EMPTY_PANEL ); valoresPanel.add( emptyPanel, EMPTY_PANEL );
add(areas,new TableLayoutConstraints(0,0,0,1)); add(buttonRevert,new TableLayoutConstraints(0,0));
add(riscos,new TableLayoutConstraints(1,0,1,1)); add(areas,new TableLayoutConstraints(1,0,1,1));
add(valoresPanel,new TableLayoutConstraints(2,0,2,1)); add(riscos,new TableLayoutConstraints(2,0,2,1));
add(valoresPanel,new TableLayoutConstraints(3,0,3,1));
} }
private void setEnabled()
{
buttonRevert.setEnabled( relatorio != null && relatorio.getIsSubmetido() == null );
}
public void setRelatorio( HsRelatorio relatorio ) public void setRelatorio( HsRelatorio relatorio )
{ {
this.relatorio = relatorio;
areas.setRelatorio( relatorio ); areas.setRelatorio( relatorio );
riscos.setPosto( null ); riscos.setPosto( null );
valoresRisco.setRelatorioPostoRisco( null ); valoresRisco.setRelatorioPostoRisco( null );
valoresRisco.setEnabled( relatorio != null && relatorio.getIsSubmetido() == null );
valoresMedida.setMedida( null ); valoresMedida.setMedida( null );
valoresMedida.setEnabled( relatorio != null && relatorio.getIsSubmetido() == null );
setEnabled( );
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

@ -1836,31 +1836,31 @@
<obj-relationship name="toHsPosto" source="HsPostoRisco" target="HsPosto" deleteRule="Nullify" db-relationship-path="toHsPosto"/> <obj-relationship name="toHsPosto" source="HsPostoRisco" target="HsPosto" deleteRule="Nullify" db-relationship-path="toHsPosto"/>
<obj-relationship name="toHsRelatorioRiscoValorQualitativo" source="HsPostoRisco" target="HsRelatorioRiscoValorQualitativo" deleteRule="Nullify" db-relationship-path="toHsRelatorioRiscoValorQualitativo"/> <obj-relationship name="toHsRelatorioRiscoValorQualitativo" source="HsPostoRisco" target="HsRelatorioRiscoValorQualitativo" deleteRule="Nullify" db-relationship-path="toHsRelatorioRiscoValorQualitativo"/>
<obj-relationship name="toHsRisco" source="HsPostoRisco" target="HsRisco" deleteRule="Nullify" db-relationship-path="toHsRisco"/> <obj-relationship name="toHsRisco" source="HsPostoRisco" target="HsRisco" deleteRule="Nullify" db-relationship-path="toHsRisco"/>
<obj-relationship name="hsRelatorioArea" source="HsRelatorio" target="HsRelatorioArea" db-relationship-path="hsRelatorioArea"/> <obj-relationship name="hsRelatorioArea" source="HsRelatorio" target="HsRelatorioArea" deleteRule="Cascade" db-relationship-path="hsRelatorioArea"/>
<obj-relationship name="hsRelatorioEquipamentoMedicoArray" source="HsRelatorio" target="HsRelatorioEquipamentoMedico" deleteRule="Cascade" db-relationship-path="hsRelatorioEquipamentoMedicoArray"/> <obj-relationship name="hsRelatorioEquipamentoMedicoArray" source="HsRelatorio" target="HsRelatorioEquipamentoMedico" deleteRule="Cascade" db-relationship-path="hsRelatorioEquipamentoMedicoArray"/>
<obj-relationship name="hsRelatorioLegislacaoArray" source="HsRelatorio" target="HsRelatorioLegislacao" db-relationship-path="hsRelatorioLegislacaoArray"/> <obj-relationship name="hsRelatorioLegislacaoArray" source="HsRelatorio" target="HsRelatorioLegislacao" db-relationship-path="hsRelatorioLegislacaoArray"/>
<obj-relationship name="hsRelatorioNormalizacaoArray" source="HsRelatorio" target="HsRelatorioNormalizacao" db-relationship-path="hsRelatorioNormalizacaoArray"/> <obj-relationship name="hsRelatorioNormalizacaoArray" source="HsRelatorio" target="HsRelatorioNormalizacao" db-relationship-path="hsRelatorioNormalizacaoArray"/>
<obj-relationship name="hsRelatorioRiscoArray" source="HsRelatorio" target="HsRelatorioRisco" db-relationship-path="hsRelatorioRiscoArray"/> <obj-relationship name="hsRelatorioRiscoArray" source="HsRelatorio" target="HsRelatorioRisco" deleteRule="Cascade" db-relationship-path="hsRelatorioRiscoArray"/>
<obj-relationship name="toHsMarcacoesEstabelecimento" source="HsRelatorio" target="MarcacoesEstabelecimento" db-relationship-path="toHsMarcacoesEstabelecimento"/> <obj-relationship name="toHsMarcacoesEstabelecimento" source="HsRelatorio" target="MarcacoesEstabelecimento" db-relationship-path="toHsMarcacoesEstabelecimento"/>
<obj-relationship name="hsRelatorioPostoArray" source="HsRelatorioArea" target="HsRelatorioPosto" db-relationship-path="hsRelatorioPostoArray"/> <obj-relationship name="hsRelatorioPostoArray" source="HsRelatorioArea" target="HsRelatorioPosto" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoArray"/>
<obj-relationship name="toHsRelatorio" source="HsRelatorioArea" target="HsRelatorio" db-relationship-path="toHsRelatorio"/> <obj-relationship name="toHsRelatorio" source="HsRelatorioArea" target="HsRelatorio" deleteRule="Nullify" db-relationship-path="toHsRelatorio"/>
<obj-relationship name="toHsEquipamentoMedico" source="HsRelatorioEquipamentoMedico" target="HsEquipamentoMedico" deleteRule="Nullify" db-relationship-path="toHsEquipamentoMedico"/> <obj-relationship name="toHsEquipamentoMedico" source="HsRelatorioEquipamentoMedico" target="HsEquipamentoMedico" deleteRule="Nullify" db-relationship-path="toHsEquipamentoMedico"/>
<obj-relationship name="toHsRelatorio" source="HsRelatorioEquipamentoMedico" target="HsRelatorio" deleteRule="Nullify" db-relationship-path="toHsRelatorio"/> <obj-relationship name="toHsRelatorio" source="HsRelatorioEquipamentoMedico" target="HsRelatorio" deleteRule="Nullify" db-relationship-path="toHsRelatorio"/>
<obj-relationship name="toHsRelatorio" source="HsRelatorioLegislacao" target="HsRelatorio" db-relationship-path="toHsRelatorio"/> <obj-relationship name="toHsRelatorio" source="HsRelatorioLegislacao" target="HsRelatorio" db-relationship-path="toHsRelatorio"/>
<obj-relationship name="hsRelatorioPostoMedidaArray" source="HsRelatorioMedida" target="HsRelatorioPostoMedida" db-relationship-path="hsRelatorioPostoMedidaArray"/> <obj-relationship name="hsRelatorioPostoMedidaArray" source="HsRelatorioMedida" target="HsRelatorioPostoMedida" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoMedidaArray"/>
<obj-relationship name="toHsRelatorioRisco" source="HsRelatorioMedida" target="HsRelatorioRisco" db-relationship-path="toHsRelatorioRisco"/> <obj-relationship name="toHsRelatorioRisco" source="HsRelatorioMedida" target="HsRelatorioRisco" deleteRule="Nullify" db-relationship-path="toHsRelatorioRisco"/>
<obj-relationship name="toHsRelatorio" source="HsRelatorioNormalizacao" target="HsRelatorio" db-relationship-path="toHsRelatorio"/> <obj-relationship name="toHsRelatorio" source="HsRelatorioNormalizacao" target="HsRelatorio" db-relationship-path="toHsRelatorio"/>
<obj-relationship name="hsRelatorioPostoMedidaArray" source="HsRelatorioPosto" target="HsRelatorioPostoMedida" db-relationship-path="hsRelatorioPostoMedidaArray"/> <obj-relationship name="hsRelatorioPostoMedidaArray" source="HsRelatorioPosto" target="HsRelatorioPostoMedida" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoMedidaArray"/>
<obj-relationship name="hsRelatorioPostoRiscoArray" source="HsRelatorioPosto" target="HsRelatorioPostoRisco" db-relationship-path="hsRelatorioPostoRiscoArray"/> <obj-relationship name="hsRelatorioPostoRiscoArray" source="HsRelatorioPosto" target="HsRelatorioPostoRisco" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoRiscoArray"/>
<obj-relationship name="toHsRelatorioArea" source="HsRelatorioPosto" target="HsRelatorioArea" db-relationship-path="toHsRelatorioArea"/> <obj-relationship name="toHsRelatorioArea" source="HsRelatorioPosto" target="HsRelatorioArea" deleteRule="Nullify" db-relationship-path="toHsRelatorioArea"/>
<obj-relationship name="toHsRelatorioMedida" source="HsRelatorioPostoMedida" target="HsRelatorioMedida" db-relationship-path="toHsRelatorioMedida"/> <obj-relationship name="toHsRelatorioMedida" source="HsRelatorioPostoMedida" target="HsRelatorioMedida" deleteRule="Cascade" db-relationship-path="toHsRelatorioMedida"/>
<obj-relationship name="toHsRelatorioPosto" source="HsRelatorioPostoMedida" target="HsRelatorioPosto" db-relationship-path="toHsRelatorioPosto"/> <obj-relationship name="toHsRelatorioPosto" source="HsRelatorioPostoMedida" target="HsRelatorioPosto" deleteRule="Cascade" db-relationship-path="toHsRelatorioPosto"/>
<obj-relationship name="toHsRelatorioPosto" source="HsRelatorioPostoRisco" target="HsRelatorioPosto" db-relationship-path="toHsRelatorioPosto"/> <obj-relationship name="toHsRelatorioPosto" source="HsRelatorioPostoRisco" target="HsRelatorioPosto" deleteRule="Cascade" db-relationship-path="toHsRelatorioPosto"/>
<obj-relationship name="toHsRelatorioRisco" source="HsRelatorioPostoRisco" target="HsRelatorioRisco" db-relationship-path="toHsRelatorioRisco"/> <obj-relationship name="toHsRelatorioRisco" source="HsRelatorioPostoRisco" target="HsRelatorioRisco" deleteRule="Cascade" db-relationship-path="toHsRelatorioRisco"/>
<obj-relationship name="toHsRelatorioRiscoValorQualitativo" source="HsRelatorioPostoRisco" target="HsRelatorioRiscoValorQualitativo" db-relationship-path="toHsRelatorioRiscoValorQualitativo"/> <obj-relationship name="toHsRelatorioRiscoValorQualitativo" source="HsRelatorioPostoRisco" target="HsRelatorioRiscoValorQualitativo" deleteRule="Nullify" db-relationship-path="toHsRelatorioRiscoValorQualitativo"/>
<obj-relationship name="hsRelatorioMedidaArray" source="HsRelatorioRisco" target="HsRelatorioMedida" db-relationship-path="hsRelatorioMedidaArray"/> <obj-relationship name="hsRelatorioMedidaArray" source="HsRelatorioRisco" target="HsRelatorioMedida" deleteRule="Cascade" db-relationship-path="hsRelatorioMedidaArray"/>
<obj-relationship name="hsRelatorioPostoRiscoArray" source="HsRelatorioRisco" target="HsRelatorioPostoRisco" db-relationship-path="hsRelatorioPostoRiscoArray"/> <obj-relationship name="hsRelatorioPostoRiscoArray" source="HsRelatorioRisco" target="HsRelatorioPostoRisco" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoRiscoArray"/>
<obj-relationship name="toHsRelatorio" source="HsRelatorioRisco" target="HsRelatorio" db-relationship-path="toHsRelatorio"/> <obj-relationship name="toHsRelatorio" source="HsRelatorioRisco" target="HsRelatorio" deleteRule="Nullify" db-relationship-path="toHsRelatorio"/>
<obj-relationship name="hsPostoRiscoArray" source="HsRelatorioRiscoValorQualitativo" target="HsPostoRisco" db-relationship-path="hsPostoRiscoArray"/> <obj-relationship name="hsPostoRiscoArray" source="HsRelatorioRiscoValorQualitativo" target="HsPostoRisco" db-relationship-path="hsPostoRiscoArray"/>
<obj-relationship name="hsRelatorioPostoRiscoArray" source="HsRelatorioRiscoValorQualitativo" target="HsRelatorioPostoRisco" db-relationship-path="hsRelatorioPostoRiscoArray"/> <obj-relationship name="hsRelatorioPostoRiscoArray" source="HsRelatorioRiscoValorQualitativo" target="HsRelatorioPostoRisco" db-relationship-path="hsRelatorioPostoRiscoArray"/>
<obj-relationship name="hsPostoRiscoArray" source="HsRisco" target="HsPostoRisco" deleteRule="Cascade" db-relationship-path="hsPostoRiscoArray"/> <obj-relationship name="hsPostoRiscoArray" source="HsRisco" target="HsPostoRisco" deleteRule="Cascade" db-relationship-path="hsPostoRiscoArray"/>

@ -30,6 +30,8 @@ public class LeafButton extends JButton
protected void paintComponent( Graphics g ) protected void paintComponent( Graphics g )
{ {
if( icon == null )
{
boolean pushed = getModel().isPressed(); boolean pushed = getModel().isPressed();
// Color borderColor = getBackground(); // Color borderColor = getBackground();
// Color highlightColor = getBackground(); // Color highlightColor = getBackground();
@ -67,7 +69,8 @@ public class LeafButton extends JButton
y -= 1; y -= 1;
g2.setColor( textColor ); g2.setColor( textColor );
g2.drawString( getText(), x, y ); g2.drawString( getText(), x, y );
if( icon != null ) }
else
{ {
super.paintComponent( g ); super.paintComponent( g );
} }

@ -31,4 +31,14 @@ public class LeafIconButton extends LeafButton
return result; return result;
} }
public static LeafIconButton createButton( String title, String imagePath )
{
LeafIconButton result = createButton( imagePath );
if( result != null )
{
result.setText( title );
}
return result;
}
} }

@ -5,6 +5,19 @@ import siprp.database.cayenne.objects.auto._HsPosto;
public class HsPosto extends _HsPosto { public class HsPosto extends _HsPosto {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override
public String getDescription()
{
return parseFromUnicode( super.getDescription() );
}
@Override
public void setDescription( String nome )
{
super.setDescription( parseToUnicode( nome ) );
}
@Override @Override
public String toString() public String toString()

@ -1,5 +1,6 @@
package siprp.logic; package siprp.logic;
import java.util.HashMap;
import java.util.List; import java.util.List;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
@ -10,9 +11,14 @@ import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsArea; import siprp.database.cayenne.objects.HsArea;
import siprp.database.cayenne.objects.HsPosto; import siprp.database.cayenne.objects.HsPosto;
import siprp.database.cayenne.objects.HsPostoEstabelecimento; import siprp.database.cayenne.objects.HsPostoEstabelecimento;
import siprp.database.cayenne.objects.HsPostoRisco;
import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioArea; import siprp.database.cayenne.objects.HsRelatorioArea;
import siprp.database.cayenne.objects.HsRelatorioMedida;
import siprp.database.cayenne.objects.HsRelatorioPosto; import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.database.cayenne.objects.HsRelatorioRisco;
import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo; import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo;
import siprp.database.cayenne.objects.HsRisco; import siprp.database.cayenne.objects.HsRisco;
import siprp.database.cayenne.objects.HsRiscoEmpresa; import siprp.database.cayenne.objects.HsRiscoEmpresa;
@ -20,13 +26,13 @@ import siprp.database.cayenne.objects.HsRiscoMedida;
import siprp.database.cayenne.objects.HsRiscoTema; import siprp.database.cayenne.objects.HsRiscoTema;
import siprp.database.cayenne.providers.MedicinaDAO; import siprp.database.cayenne.providers.MedicinaDAO;
import siprp.database.cayenne.providers.PlanoActuacaoDAO; import siprp.database.cayenne.providers.PlanoActuacaoDAO;
import siprp.higiene.gestao.postos.AreaNode;
import siprp.higiene.gestao.postos.PostoNode;
import siprp.higiene.gestao.riscos.NodeMedida;
import siprp.higiene.gestao.riscos.NodeRisco;
import siprp.higiene.gestao.riscos.NodeRiscoTema;
import siprp.higiene.relatorio.AreaRelatorioNode; import siprp.higiene.relatorio.AreaRelatorioNode;
import siprp.higiene.relatorio.PostoRelatorioNode; import siprp.higiene.relatorio.PostoRelatorioNode;
import siprp.logic.node.AreaNode;
import siprp.logic.node.NodeMedida;
import siprp.logic.node.NodeRisco;
import siprp.logic.node.NodeRiscoTema;
import siprp.logic.node.PostoNode;
public class HigieneSegurancaLogic public class HigieneSegurancaLogic
{ {
@ -157,4 +163,72 @@ public class HigieneSegurancaLogic
} }
return result; return result;
} }
public static void reverterRelatorio( HsRelatorio relatorio )
{
if(relatorio != null)
{
List<HsRelatorioArea> areas = relatorio.getHsRelatorioArea();
int areasSize = areas == null ? 0 : areas.size();
for( int i = 0; i < areasSize; ++i )
{
areas.get( 0 ).delete();
}
relatorio.save();
Estabelecimentos estabelecimento = relatorio.getToHsMarcacoesEstabelecimento() == null ? null : relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos();
if( estabelecimento != null )
{
List<HsPostoEstabelecimento> postos = estabelecimento.getHsPostoEstabelecimentoArray();
reverterPostos(relatorio,postos);
relatorio.save();
}
}
}
private static void reverterPostos( HsRelatorio relatorio, List<HsPostoEstabelecimento> postos )
{
HashMap<HsArea,HsRelatorioArea> areasInserted = new HashMap<HsArea, HsRelatorioArea>();
for( HsPostoEstabelecimento rel : postos )
{
HsPosto posto = rel.getToHsPosto();
HsRelatorioPosto rPosto = new HsRelatorioPosto();
rPosto.setDescription( posto.getDescription() );
HsArea area = posto.getToHsArea();
HsRelatorioArea rArea = areasInserted.get( area );
if( rArea == null )
{
rArea = new HsRelatorioArea();
rArea.setDescription( area.getDescription() );
rArea.setToHsRelatorio( relatorio );
areasInserted.put(area,rArea);
}
rPosto.setToHsRelatorioArea( rArea );
addMedidasAndRiscos(posto,rPosto);
}
}
private static void addMedidasAndRiscos(HsPosto posto, HsRelatorioPosto rPosto)
{
for( HsPostoRisco postoRisco : posto.getHsPostoRiscoArray() )
{
HsRelatorioRisco rRelatorioRisco = new HsRelatorioRisco();
rRelatorioRisco.setToHsRelatorio( rPosto.getToHsRelatorioArea().getToHsRelatorio() );
rRelatorioRisco.setDescription( postoRisco.getToHsRisco().getDescription() );
HsRelatorioPostoRisco rPostoRisco = new HsRelatorioPostoRisco();
rPostoRisco.setToHsRelatorioPosto( rPosto );
rPostoRisco.setToHsRelatorioRisco( rRelatorioRisco );
for( HsRiscoMedida riscoMedida : postoRisco.getToHsRisco().getHsRiscoMedidaArray() )
{
HsRelatorioMedida rMedida = new HsRelatorioMedida();
rMedida.setDescription( riscoMedida.getToHsMedida().getDescription() );
rMedida.setRequesitosLegais( riscoMedida.getToHsMedida().getRequesitosLegais() );
rMedida.setToHsRelatorioRisco( rRelatorioRisco );
HsRelatorioPostoMedida rPostoMedida = new HsRelatorioPostoMedida();
rPostoMedida.setIsPlanoActuacao( false );
rPostoMedida.setToHsRelatorioMedida( rMedida );
rPostoMedida.setToHsRelatorioPosto( rPosto );
}
}
}
} }

@ -1,4 +1,4 @@
package siprp.higiene.gestao.postos; package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;

@ -0,0 +1,17 @@
package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioArea;
public class AreaRelatorioNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public AreaRelatorioNode( HsRelatorioArea risco )
{
super( risco );
}
}

@ -0,0 +1,16 @@
package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
public class MedidaRelatorioNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public MedidaRelatorioNode( HsRelatorioPostoMedida medida )
{
super( medida );
}
}

@ -1,4 +1,4 @@
package siprp.higiene.gestao.riscos; package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;

@ -1,4 +1,4 @@
package siprp.higiene.gestao.riscos; package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;

@ -1,4 +1,4 @@
package siprp.higiene.gestao.riscos; package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;

@ -1,4 +1,4 @@
package siprp.higiene.gestao.postos; package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;

@ -0,0 +1,17 @@
package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioPosto;
public class PostoRelatorioNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public PostoRelatorioNode( HsRelatorioPosto risco )
{
super( risco );
}
}

@ -0,0 +1,16 @@
package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
public class RiscoRelatorioNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public RiscoRelatorioNode( HsRelatorioPostoRisco risco )
{
super( risco );
}
}
Loading…
Cancel
Save