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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 17 years ago
parent b882491cc9
commit 88830f4af6

@ -68,6 +68,8 @@ public class EmpresaPanel extends JPanel
implements ControllableComponent, ListSelectionListener
{
private static final long serialVersionUID = 1L;
private static final String STRING_TRABALHADORES_ACTIVOS = "Trabalhadores activos";
private JDOProvider JDO;

@ -201,9 +201,12 @@ public class ImagePanel extends JPanel implements MouseListener, ControllableCom
byte [] result = null;
try
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write( image, "PNG", out );
result = out.toByteArray();
if( image != null )
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write( image, "PNG", out );
result = out.toByteArray();
}
}
catch( IOException e )
{

@ -2,6 +2,7 @@ package siprp.higiene.gestao;
import javax.swing.JTabbedPane;
import siprp.higiene.gestao.equipamentos.GerirEquipamentosPanel;
import siprp.higiene.gestao.legislacao.GerirLegislacaoPanel;
import siprp.higiene.gestao.normalizacao.GerirNormalizacaoPanel;
import siprp.higiene.gestao.riscos.GerirRiscosPanel;
@ -18,6 +19,8 @@ public class GlobalPanel extends JTabbedPane
private final GerirLegislacaoPanel panelLegislacao = new GerirLegislacaoPanel();
private final GerirNormalizacaoPanel panelNormalizacao= new GerirNormalizacaoPanel();
private final GerirEquipamentosPanel panelEquipamentos = new GerirEquipamentosPanel();
public GlobalPanel()
{
@ -32,21 +35,20 @@ public class GlobalPanel extends JTabbedPane
addTab( "Riscos", panelRiscos );
addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao );
addTab( "Normaliza" + ccedil + atilde + "o", panelNormalizacao );
addTab( "Equipamentos", panelEquipamentos );
setEnabledAt( 3, false );
}
private void setupLayout()
{
}
private void placeComponents()
{
}
private void startupListeners()
{
}
}

@ -1,14 +1,11 @@
package siprp.higiene.gestao.equipamentos;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
@ -20,12 +17,10 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafIconButton;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsEquipamentoMedico;
import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioEquipamentoMedico;
import siprp.database.cayenne.objects.HsRelatorioEquipamento;
import siprp.logic.node.EquipamentoNode;
public class AdicionarEquipamentosPanel extends JPanel
@ -111,7 +106,7 @@ public class AdicionarEquipamentosPanel extends JPanel
setEnabled();
TreePath path = tree.getSelectionPath();
Object object = path == null ? null : path.getLastPathComponent();
HsRelatorioEquipamentoMedico rel = object == null ? null : ((object instanceof HsRelatorioEquipamentoMedico) ? (HsRelatorioEquipamentoMedico) ((EquipamentoNode) object).getUserObject() : null);
HsRelatorioEquipamento rel = object == null ? null : ((object instanceof HsRelatorioEquipamento) ? (HsRelatorioEquipamento) ((EquipamentoNode) object).getUserObject() : null);
firePropertyChange( SELECTION_CHANGED, null, rel == null ? null : rel.getToHsRelatorio() );
}
} );
@ -135,54 +130,18 @@ public class AdicionarEquipamentosPanel extends JPanel
private void add()
{
try
{
if( relatorio != null )
{
String equipamentoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar novo equipamento de medi" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE );
if( equipamentoString != null )
{
HsEquipamentoMedico equipamento = new HsEquipamentoMedico();
equipamento.setNome( equipamentoString );
equipamento.save();
HsRelatorioEquipamentoMedico rel = new HsRelatorioEquipamentoMedico();
rel.setToHsRelatorio( relatorio );
rel.setToHsEquipamentoMedico( equipamento );
rel.save();
refresh();
}
}
} catch( Exception e )
{
e.printStackTrace();
}
}
private void rem()
{
try
{
TreePath path = tree.getSelectionPath();
if( path != null )
{
Object object = path.getLastPathComponent();
if( object instanceof EquipamentoNode )
{
HsRelatorioEquipamentoMedico rel = ((HsRelatorioEquipamentoMedico) ((EquipamentoNode) object).getUserObject());
rel.delete();
}
}
refresh();
} catch( Exception e )
{
LeafError.error(e);
}
}
private void setEnabled()
{
buttonAdicionar.setEnabled( relatorio != null && relatorio.getIsSubmetido() == null );
buttonRemover.setEnabled( tree.getSelectionCount() > 0 );
// buttonAdicionar.setEnabled( relatorio != null && relatorio.getIsSubmetido() == null );
// buttonRemover.setEnabled( tree.getSelectionCount() > 0 );
buttonAdicionar.setEnabled(false );
buttonRemover.setEnabled( false);
}
public void refresh()
@ -190,7 +149,7 @@ public class AdicionarEquipamentosPanel extends JPanel
root.removeAllChildren();
if( relatorio != null )
{
for( HsRelatorioEquipamentoMedico rel : relatorio.getHsRelatorioEquipamentoMedicoArray() )
for( HsRelatorioEquipamento rel : relatorio.getHsRelatorioEquipamentoArray() )
{
root.add( new EquipamentoNode( rel ) );
}

@ -0,0 +1,229 @@
package siprp.higiene.gestao.equipamentos;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.data.Validator;
import leaf.ui.LeafButton;
import leaf.ui.LeafTextAreaEditor;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.logic.HigieneSegurancaLogic;
public class GerirEquipamentosPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private final JPanel panelButtons = new JPanel();
private final JPanel panelTree = new JPanel();
private final JPanel panelData = new JPanel();
private final LeafTextAreaEditor textMarca = new LeafTextAreaEditor( new Validator<String>()
{
@Override
public boolean isValid( String object )
{
return isMarcaValida( object );
}
}, true );
private final LeafTextAreaEditor textModelo = new LeafTextAreaEditor( new Validator<String>()
{
@Override
public boolean isValid( String object )
{
return isModeloValido( object );
}
}, true );
private final LeafButton buttonCriar = new LeafButton( "Criar" );
private final LeafButton buttonEditar = new LeafButton( "Editar" );
private final LeafButton buttonRemover = new LeafButton( "Remover" );
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
private final DefaultTreeModel model = new DefaultTreeModel( root );
private final JTree tree = new JTree( model );
private final JScrollPane scroll = new JScrollPane( tree );
public GerirEquipamentosPanel()
{
startupComponents();
startupLayout();
placeComponents();
setupListeners();
refresh();
}
private void setupListeners()
{
buttonCriar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
criar();
}
} );
buttonEditar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
editar();
}
} );
buttonRemover.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
remover();
}
} );
tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener()
{
@Override
public void valueChanged( TreeSelectionEvent e )
{
setEnabled();
}
} );
}
private void criar()
{
}
private void editar()
{
}
private void remover()
{
}
private HsEquipamento getSelected()
{
Object object = getSelectedObject();
return object == null ? null : ((object instanceof HsEquipamento) ? (HsEquipamento) object : null);
}
private Object getSelectedObject()
{
DefaultMutableTreeNode node = getSelectedNode();
return node == null ? null : node.getUserObject();
}
private DefaultMutableTreeNode getSelectedNode()
{
TreePath path = tree.getSelectionPath();
return path == null ? null : (DefaultMutableTreeNode) path.getLastPathComponent();
}
private void startupComponents()
{
panelTree.setPreferredSize( new Dimension( 400, 400 ) );
tree.setRootVisible( false );
tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
}
private void setEnabled()
{
HsEquipamento equipamento = getSelected();
buttonEditar.setEnabled( equipamento != null );
buttonRemover.setEnabled( equipamento != null );
}
private void startupLayout()
{
TableLayout layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL
}, new double[] {
TableLayout.FILL
} );
layout.setHGap( 5 );
layout.setVGap( 5 );
setLayout( layout );
layout = new TableLayout( new double[] {
TableLayout.MINIMUM
}, new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM
} );
layout.setHGap( 5 );
layout.setVGap( 5 );
panelButtons.setLayout( layout );
layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.FILL
}, new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM
} );
layout.setHGap( 5 );
layout.setVGap( 5 );
panelData.setLayout( layout );
panelTree.setLayout( new GridLayout( 1,1 ) );
}
private void placeComponents()
{
panelButtons.add( buttonCriar, new TableLayoutConstraints( 0, 0 ) );
panelButtons.add( buttonEditar, new TableLayoutConstraints( 0, 1 ) );
panelButtons.add( buttonRemover, new TableLayoutConstraints( 0, 2 ) );
panelTree.add( scroll, new TableLayoutConstraints( 0, 0 ) );
panelData.add( new JLabel("Marca"), new TableLayoutConstraints( 0, 0 ) );
panelData.add( textMarca, new TableLayoutConstraints( 1, 0 ) );
panelData.add( new JLabel("Modelo"), new TableLayoutConstraints( 0, 1 ) );
panelData.add( textModelo, new TableLayoutConstraints( 1, 1 ) );
add( panelButtons, new TableLayoutConstraints( 0, 0 ) );
add( panelTree, new TableLayoutConstraints( 1, 0 ) );
add( panelData, new TableLayoutConstraints( 2, 0 ) );
}
private void refresh()
{
root.removeAllChildren();
TreeTools.merge( root, HigieneSegurancaLogic.getEquipamentosTree() );
TreeTools.refreshTree( tree, root );
setEnabled();
}
private boolean isMarcaValida( String marca )
{
return true;
}
private boolean isModeloValido( String modelo )
{
return true;
}
}

@ -12,6 +12,7 @@ package siprp.update;
import java.util.Vector;
import siprp.update.updates.V10_0_To_V10_1;
import siprp.update.updates.V10_1_To_V10_2;
import siprp.update.updates.V9_1_To_V9_2;
import siprp.update.updates.V9_2_To_V9_3;
import siprp.update.updates.V9_3_To_V9_4;
@ -54,7 +55,8 @@ public class UpdateList
new V9_3_To_V9_4(), new V9_4_To_V9_5(),
new V9_5_To_V9_6(), new V9_6_To_V9_7(),
new V9_7_To_V9_8(), new V9_8_To_V9_9(),
new V9_9_To_V10_0(), new V10_0_To_V10_1() };
new V9_9_To_V10_0(), new V10_0_To_V10_1(),
new V10_1_To_V10_2() };
protected static Executer EXECUTER;
protected static double version = -1;

@ -0,0 +1,65 @@
package siprp.update.updates;
import com.evolute.utils.Singleton;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
public class V10_1_To_V10_2
implements siprp.update.Update
{
public V10_1_To_V10_2()
{
}
public String []listChanges()
{
return new String[]{
"adicionadas normalizacoes para estabelecimentos e empresas"
};
}
public double getStartVersion()
{
return 10.1;
}
public double getEndVersion()
{
return 10.2;
}
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(
"CREATE TABLE hs_equipamento( " +
"id SERIAL PRIMARY KEY, " +
"tipo VARCHAR(512) NOT NULL, " +
"marca VARCHAR(255), " +
"modelo VARCHAR(255), " +
"deleted_date TIMESTAMP " +
"); " +
"CREATE TABLE hs_relatorio_equipamento( " +
"hs_relatorio_id INT4 REFERENCES hs_relatorio(id), " +
"hs_equipamento INT4 REFERENCES hs_equipamento(id), " +
"CONSTRAINT hs_relatorio_equipamento_pkey PRIMARY KEY (hs_relatorio_id,hs_equipamento) " +
"); " +
"INSERT INTO hs_equipamento(id, tipo) " +
"SELECT id, nome FROM hs_equipamento_medico ; " +
"INSERT INTO hs_relatorio_equipamento(hs_relatorio_id, hs_equipamento) " +
"SELECT hs_relatorio_id, hs_equipamento_medico_id FROM hs_relatorio_equipamento_medico; " +
"DROP TABLE hs_relatorio_equipamento_medico; " +
"DROP TABLE hs_equipamento_medico; "
);
executer.executeQuery( update );
}
public String toString()
{
return "v" + getStartVersion() + " para v" + getEndVersion();
}
}

@ -208,12 +208,15 @@
<db-attribute name="email_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="estabelecimento_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
</db-entity>
<db-entity name="hs_equipamento_medico" schema="public">
<db-entity name="hs_equipamento" schema="public">
<db-attribute name="deleted_date" type="TIMESTAMP" length="29"/>
<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="nome" type="VARCHAR" isMandatory="true" length="255"/>
<db-attribute name="marca" type="VARCHAR" length="255"/>
<db-attribute name="modelo" type="VARCHAR" length="255"/>
<db-attribute name="tipo" type="VARCHAR" isMandatory="true" length="512"/>
<db-key-generator>
<db-generator-type>ORACLE</db-generator-type>
<db-generator-name>hs_equipamento_medico_id_seq</db-generator-name>
<db-generator-name>hs_equipamento_id_seq</db-generator-name>
<db-key-cache-size>1</db-key-cache-size>
</db-key-generator>
</db-entity>
@ -334,8 +337,8 @@
<db-key-cache-size>1</db-key-cache-size>
</db-key-generator>
</db-entity>
<db-entity name="hs_relatorio_equipamento_medico" schema="public">
<db-attribute name="hs_equipamento_medico_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-entity name="hs_relatorio_equipamento" schema="public">
<db-attribute name="hs_equipamento" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="hs_relatorio_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
</db-entity>
<db-entity name="hs_relatorio_legislacao" schema="public">
@ -915,8 +918,11 @@
</obj-entity>
<obj-entity name="HsEmailEstabelecimento" className="siprp.database.cayenne.objects.HsEmailEstabelecimento" dbEntityName="hs_email_estabelecimento" superClassName="siprp.database.cayenne.objects.BaseObject">
</obj-entity>
<obj-entity name="HsEquipamentoMedico" className="siprp.database.cayenne.objects.HsEquipamentoMedico" dbEntityName="hs_equipamento_medico" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="nome" type="java.lang.String" db-attribute-path="nome"/>
<obj-entity name="HsEquipamento" className="siprp.database.cayenne.objects.HsEquipamento" dbEntityName="hs_equipamento" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="deletedDate" type="java.util.Date" db-attribute-path="deleted_date"/>
<obj-attribute name="marca" type="java.lang.String" db-attribute-path="marca"/>
<obj-attribute name="modelo" type="java.lang.String" db-attribute-path="modelo"/>
<obj-attribute name="tipo" type="java.lang.String" db-attribute-path="tipo"/>
</obj-entity>
<obj-entity name="HsLegislacao" className="siprp.database.cayenne.objects.HsLegislacao" dbEntityName="hs_legislacao" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="deletedDate" type="java.util.Date" db-attribute-path="deleted_date"/>
@ -976,7 +982,7 @@
<obj-attribute name="deletedDate" type="java.util.Date" db-attribute-path="deleted_date"/>
<obj-attribute name="description" type="java.lang.String" db-attribute-path="description"/>
</obj-entity>
<obj-entity name="HsRelatorioEquipamentoMedico" className="siprp.database.cayenne.objects.HsRelatorioEquipamentoMedico" dbEntityName="hs_relatorio_equipamento_medico" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-entity name="HsRelatorioEquipamento" className="siprp.database.cayenne.objects.HsRelatorioEquipamento" dbEntityName="hs_relatorio_equipamento" superClassName="siprp.database.cayenne.objects.BaseObject">
</obj-entity>
<obj-entity name="HsRelatorioLegislacao" className="siprp.database.cayenne.objects.HsRelatorioLegislacao" dbEntityName="hs_relatorio_legislacao" superClassName="siprp.database.cayenne.objects.BaseObject">
</obj-entity>
@ -1355,8 +1361,8 @@
<db-relationship name="toHsEmail" source="hs_email_estabelecimento" target="hs_email" toMany="false">
<db-attribute-pair source="email_id" target="id"/>
</db-relationship>
<db-relationship name="hsRelatorioEquipamentoMedicoArray" source="hs_equipamento_medico" target="hs_relatorio_equipamento_medico" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="hs_equipamento_medico_id"/>
<db-relationship name="hsRelatorioEquipamentoArray" source="hs_equipamento" target="hs_relatorio_equipamento" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="hs_equipamento"/>
</db-relationship>
<db-relationship name="hsLegislacaoEmpresaArray" source="hs_legislacao" target="hs_legislacao_empresa" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="legislacao_id"/>
@ -1445,7 +1451,7 @@
<db-relationship name="hsRelatorioArea" source="hs_relatorio" target="hs_relatorio_area" toMany="true">
<db-attribute-pair source="id" target="relatorio_id"/>
</db-relationship>
<db-relationship name="hsRelatorioEquipamentoMedicoArray" source="hs_relatorio" target="hs_relatorio_equipamento_medico" toDependentPK="true" toMany="true">
<db-relationship name="hsRelatorioEquipamentoArray" source="hs_relatorio" target="hs_relatorio_equipamento" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="hs_relatorio_id"/>
</db-relationship>
<db-relationship name="hsRelatorioLegislacaoArray" source="hs_relatorio" target="hs_relatorio_legislacao" toDependentPK="true" toMany="true">
@ -1466,10 +1472,10 @@
<db-relationship name="toHsRelatorio" source="hs_relatorio_area" target="hs_relatorio" toMany="false">
<db-attribute-pair source="relatorio_id" target="id"/>
</db-relationship>
<db-relationship name="toHsEquipamentoMedico" source="hs_relatorio_equipamento_medico" target="hs_equipamento_medico" toMany="false">
<db-attribute-pair source="hs_equipamento_medico_id" target="id"/>
<db-relationship name="toHsEquipamento" source="hs_relatorio_equipamento" target="hs_equipamento" toMany="false">
<db-attribute-pair source="hs_equipamento" target="id"/>
</db-relationship>
<db-relationship name="toHsRelatorio" source="hs_relatorio_equipamento_medico" target="hs_relatorio" toMany="false">
<db-relationship name="toHsRelatorio" source="hs_relatorio_equipamento" target="hs_relatorio" toMany="false">
<db-attribute-pair source="hs_relatorio_id" target="id"/>
</db-relationship>
<db-relationship name="toHsRelatorio" source="hs_relatorio_legislacao" target="hs_relatorio" toMany="false">
@ -1868,7 +1874,7 @@
<obj-relationship name="toHsEmail" source="HsEmailEmpresa" target="HsEmail" deleteRule="Nullify" db-relationship-path="toHsEmail"/>
<obj-relationship name="toEstabelecimento" source="HsEmailEstabelecimento" target="Estabelecimentos" deleteRule="Nullify" db-relationship-path="toEstabelecimento"/>
<obj-relationship name="toHsEmail" source="HsEmailEstabelecimento" target="HsEmail" deleteRule="Nullify" db-relationship-path="toHsEmail"/>
<obj-relationship name="hsRelatorioEquipamentoMedicoArray" source="HsEquipamentoMedico" target="HsRelatorioEquipamentoMedico" db-relationship-path="hsRelatorioEquipamentoMedicoArray"/>
<obj-relationship name="hsRelatorioEquipamentoArray" source="HsEquipamento" target="HsRelatorioEquipamento" db-relationship-path="hsRelatorioEquipamentoArray"/>
<obj-relationship name="hsLegislacaoEmpresaArray" source="HsLegislacao" target="HsLegislacaoEmpresa" deleteRule="Cascade" db-relationship-path="hsLegislacaoEmpresaArray"/>
<obj-relationship name="hsLegislacaoEstabelecimentoArray" source="HsLegislacao" target="HsLegislacaoEstabelecimento" deleteRule="Cascade" db-relationship-path="hsLegislacaoEstabelecimentoArray"/>
<obj-relationship name="toHsLegislacaoCategoria" source="HsLegislacao" target="HsLegislacaoCategoria" deleteRule="Nullify" db-relationship-path="toHsLegislacaoCategoria"/>
@ -1897,15 +1903,15 @@
<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="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="hsRelatorioEquipamentoArray" source="HsRelatorio" target="HsRelatorioEquipamento" db-relationship-path="hsRelatorioEquipamentoArray"/>
<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="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="hsRelatorioPostoArray" source="HsRelatorioArea" target="HsRelatorioPosto" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoArray"/>
<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="toHsRelatorio" source="HsRelatorioEquipamentoMedico" target="HsRelatorio" deleteRule="Nullify" db-relationship-path="toHsRelatorio"/>
<obj-relationship name="toHsEquipamento" source="HsRelatorioEquipamento" target="HsEquipamento" db-relationship-path="toHsEquipamento"/>
<obj-relationship name="toHsRelatorio" source="HsRelatorioEquipamento" 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" deleteRule="Cascade" db-relationship-path="hsRelatorioPostoMedidaArray"/>
<obj-relationship name="toHsRelatorioRisco" source="HsRelatorioMedida" target="HsRelatorioRisco" deleteRule="Nullify" db-relationship-path="toHsRelatorioRisco"/>

@ -10,8 +10,10 @@ import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.JTextComponent;
import com.evolute.utils.ui.text.CopyPasteHandler;
@ -34,9 +36,9 @@ public class LeafTextAreaEditor extends JPanel
private final LeafButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT );
private final JTextArea fieldText = new JTextArea();
private final JTextComponent fieldText;
private final JScrollPane scroll = new JScrollPane(fieldText);
private final JScrollPane scroll;
private final Validator<String> validator;
@ -45,10 +47,17 @@ public class LeafTextAreaEditor extends JPanel
public LeafTextAreaEditor( Validator<String> validator )
{
this( validator, false );
}
public LeafTextAreaEditor( Validator<String> validator, boolean textField )
{
this.validator = validator;
startupComponents();
startupLayout();
placeComponents();
fieldText = textField ? new JTextField() : new JTextArea();
scroll = new JScrollPane(fieldText);
startupComponents( textField );
startupLayout( textField );
placeComponents( textField );
setupListeners();
enableButtons( false );
}
@ -59,10 +68,13 @@ public class LeafTextAreaEditor extends JPanel
fieldText.setText( initialValue );
}
private void startupComponents()
private void startupComponents( boolean textField )
{
fieldText.setWrapStyleWord( true );
fieldText.setLineWrap( true );
if( !textField )
{
((JTextArea) fieldText).setWrapStyleWord( true );
((JTextArea) fieldText).setLineWrap( true );
}
new CopyPasteHandler(fieldText);
scroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
scroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
@ -70,19 +82,38 @@ public class LeafTextAreaEditor extends JPanel
buttonRevert.setMargin( new Insets(0,0,0,0) );
}
private void startupLayout()
private void startupLayout( boolean textField )
{
TableLayout layout = new TableLayout(
new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL } );
TableLayout layout;
if( !textField )
{
layout = new TableLayout(
new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL } );
}
else
{
layout = new TableLayout(
new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM },
new double[]{ TableLayout.MINIMUM } );
}
this.setLayout( layout );
}
private void placeComponents()
private void placeComponents( boolean textField )
{
this.add( scroll, new TableLayoutConstraints( 0, 1, 2, 1) );
this.add( buttonSave, new TableLayoutConstraints( 1, 0 ) );
this.add( buttonRevert, new TableLayoutConstraints( 2, 0 ) );
if( ! textField )
{
this.add( scroll, new TableLayoutConstraints( 0, 1, 2, 1) );
this.add( buttonSave, new TableLayoutConstraints( 1, 0 ) );
this.add( buttonRevert, new TableLayoutConstraints( 2, 0 ) );
}
else
{
this.add( fieldText, new TableLayoutConstraints( 0, 0 ) );
this.add( buttonSave, new TableLayoutConstraints( 1, 0 ) );
this.add( buttonRevert, new TableLayoutConstraints( 2, 0 ) );
}
}
private void setupListeners()

@ -0,0 +1,52 @@
package siprp.database.cayenne.objects;
import siprp.database.cayenne.objects.auto._HsEquipamento;
public class HsEquipamento extends _HsEquipamento {
private static final long serialVersionUID = 1L;
@Override
public String getTipo()
{
return parseFromUnicode( super.getTipo() );
}
@Override
public void setTipo( String nome )
{
super.setTipo( parseToUnicode( nome ) );
}
@Override
public String getMarca()
{
return parseFromUnicode( super.getMarca() );
}
@Override
public void setMarca( String marca )
{
super.setMarca( parseToUnicode( marca ) );
}
@Override
public String getModelo()
{
return parseFromUnicode( super.getModelo() );
}
@Override
public void setModelo( String modelo )
{
super.setModelo( parseToUnicode( modelo ) );
}
@Override
public String toString()
{
return getTipo();
}
}

@ -1,28 +0,0 @@
package siprp.database.cayenne.objects;
import siprp.database.cayenne.objects.auto._HsEquipamentoMedico;
public class HsEquipamentoMedico extends _HsEquipamentoMedico {
private static final long serialVersionUID = 1L;
@Override
public String getNome()
{
return parseFromUnicode( super.getNome() );
}
@Override
public void setNome( String nome )
{
super.setNome( parseToUnicode( nome ) );
}
@Override
public String toString()
{
return getNome();
}
}

@ -1,15 +1,14 @@
package siprp.database.cayenne.objects;
import siprp.database.cayenne.objects.auto._HsRelatorioEquipamentoMedico;
public class HsRelatorioEquipamentoMedico extends _HsRelatorioEquipamentoMedico {
import siprp.database.cayenne.objects.auto._HsRelatorioEquipamento;
public class HsRelatorioEquipamento extends _HsRelatorioEquipamento {
private static final long serialVersionUID = 1L;
@Override
public String toString()
{
return getToHsEquipamentoMedico().toString();
return getToHsEquipamento().toString();
}
}

@ -0,0 +1,65 @@
package siprp.database.cayenne.objects.auto;
import java.util.Date;
import java.util.List;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.HsRelatorioEquipamento;
/**
* Class _HsEquipamento was generated by Cayenne.
* It is probably a good idea to avoid changing this class manually,
* since it may be overwritten next time code is regenerated.
* If you need to make any customizations, please use subclass.
*/
public abstract class _HsEquipamento extends BaseObject {
public static final String DELETED_DATE_PROPERTY = "deletedDate";
public static final String MARCA_PROPERTY = "marca";
public static final String MODELO_PROPERTY = "modelo";
public static final String TIPO_PROPERTY = "tipo";
public static final String HS_RELATORIO_EQUIPAMENTO_ARRAY_PROPERTY = "hsRelatorioEquipamentoArray";
public static final String ID_PK_COLUMN = "id";
public void setDeletedDate(Date deletedDate) {
writeProperty("deletedDate", deletedDate);
}
public Date getDeletedDate() {
return (Date)readProperty("deletedDate");
}
public void setMarca(String marca) {
writeProperty("marca", marca);
}
public String getMarca() {
return (String)readProperty("marca");
}
public void setModelo(String modelo) {
writeProperty("modelo", modelo);
}
public String getModelo() {
return (String)readProperty("modelo");
}
public void setTipo(String tipo) {
writeProperty("tipo", tipo);
}
public String getTipo() {
return (String)readProperty("tipo");
}
public void addToHsRelatorioEquipamentoArray(HsRelatorioEquipamento obj) {
addToManyTarget("hsRelatorioEquipamentoArray", obj, true);
}
public void removeFromHsRelatorioEquipamentoArray(HsRelatorioEquipamento obj) {
removeToManyTarget("hsRelatorioEquipamentoArray", obj, true);
}
@SuppressWarnings("unchecked")
public List<HsRelatorioEquipamento> getHsRelatorioEquipamentoArray() {
return (List<HsRelatorioEquipamento>)readProperty("hsRelatorioEquipamentoArray");
}
}

@ -1,40 +0,0 @@
package siprp.database.cayenne.objects.auto;
import java.util.List;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.HsRelatorioEquipamentoMedico;
/**
* Class _HsEquipamentoMedico was generated by Cayenne.
* It is probably a good idea to avoid changing this class manually,
* since it may be overwritten next time code is regenerated.
* If you need to make any customizations, please use subclass.
*/
public abstract class _HsEquipamentoMedico extends BaseObject {
public static final String NOME_PROPERTY = "nome";
public static final String HS_RELATORIO_EQUIPAMENTO_MEDICO_ARRAY_PROPERTY = "hsRelatorioEquipamentoMedicoArray";
public static final String ID_PK_COLUMN = "id";
public void setNome(String nome) {
writeProperty("nome", nome);
}
public String getNome() {
return (String)readProperty("nome");
}
public void addToHsRelatorioEquipamentoMedicoArray(HsRelatorioEquipamentoMedico obj) {
addToManyTarget("hsRelatorioEquipamentoMedicoArray", obj, true);
}
public void removeFromHsRelatorioEquipamentoMedicoArray(HsRelatorioEquipamentoMedico obj) {
removeToManyTarget("hsRelatorioEquipamentoMedicoArray", obj, true);
}
@SuppressWarnings("unchecked")
public List<HsRelatorioEquipamentoMedico> getHsRelatorioEquipamentoMedicoArray() {
return (List<HsRelatorioEquipamentoMedico>)readProperty("hsRelatorioEquipamentoMedicoArray");
}
}

@ -5,7 +5,7 @@ import java.util.List;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.HsRelatorioArea;
import siprp.database.cayenne.objects.HsRelatorioEquipamentoMedico;
import siprp.database.cayenne.objects.HsRelatorioEquipamento;
import siprp.database.cayenne.objects.HsRelatorioLegislacao;
import siprp.database.cayenne.objects.HsRelatorioNormalizacao;
import siprp.database.cayenne.objects.HsRelatorioRisco;
@ -31,7 +31,7 @@ public abstract class _HsRelatorio extends BaseObject {
public static final String ID_PROPERTY = "id";
public static final String IS_SUBMETIDO_PROPERTY = "isSubmetido";
public static final String HS_RELATORIO_AREA_PROPERTY = "hsRelatorioArea";
public static final String HS_RELATORIO_EQUIPAMENTO_MEDICO_ARRAY_PROPERTY = "hsRelatorioEquipamentoMedicoArray";
public static final String HS_RELATORIO_EQUIPAMENTO_ARRAY_PROPERTY = "hsRelatorioEquipamentoArray";
public static final String HS_RELATORIO_LEGISLACAO_ARRAY_PROPERTY = "hsRelatorioLegislacaoArray";
public static final String HS_RELATORIO_NORMALIZACAO_ARRAY_PROPERTY = "hsRelatorioNormalizacaoArray";
public static final String HS_RELATORIO_RISCO_ARRAY_PROPERTY = "hsRelatorioRiscoArray";
@ -128,15 +128,15 @@ public abstract class _HsRelatorio extends BaseObject {
}
public void addToHsRelatorioEquipamentoMedicoArray(HsRelatorioEquipamentoMedico obj) {
addToManyTarget("hsRelatorioEquipamentoMedicoArray", obj, true);
public void addToHsRelatorioEquipamentoArray(HsRelatorioEquipamento obj) {
addToManyTarget("hsRelatorioEquipamentoArray", obj, true);
}
public void removeFromHsRelatorioEquipamentoMedicoArray(HsRelatorioEquipamentoMedico obj) {
removeToManyTarget("hsRelatorioEquipamentoMedicoArray", obj, true);
public void removeFromHsRelatorioEquipamentoArray(HsRelatorioEquipamento obj) {
removeToManyTarget("hsRelatorioEquipamentoArray", obj, true);
}
@SuppressWarnings("unchecked")
public List<HsRelatorioEquipamentoMedico> getHsRelatorioEquipamentoMedicoArray() {
return (List<HsRelatorioEquipamentoMedico>)readProperty("hsRelatorioEquipamentoMedicoArray");
public List<HsRelatorioEquipamento> getHsRelatorioEquipamentoArray() {
return (List<HsRelatorioEquipamento>)readProperty("hsRelatorioEquipamentoArray");
}

@ -1,29 +1,29 @@
package siprp.database.cayenne.objects.auto;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.HsEquipamentoMedico;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.database.cayenne.objects.HsRelatorio;
/**
* Class _HsRelatorioEquipamentoMedico was generated by Cayenne.
* Class _HsRelatorioEquipamento was generated by Cayenne.
* It is probably a good idea to avoid changing this class manually,
* since it may be overwritten next time code is regenerated.
* If you need to make any customizations, please use subclass.
*/
public abstract class _HsRelatorioEquipamentoMedico extends BaseObject {
public abstract class _HsRelatorioEquipamento extends BaseObject {
public static final String TO_HS_EQUIPAMENTO_MEDICO_PROPERTY = "toHsEquipamentoMedico";
public static final String TO_HS_EQUIPAMENTO_PROPERTY = "toHsEquipamento";
public static final String TO_HS_RELATORIO_PROPERTY = "toHsRelatorio";
public static final String HS_EQUIPAMENTO_MEDICO_ID_PK_COLUMN = "hs_equipamento_medico_id";
public static final String HS_EQUIPAMENTO_PK_COLUMN = "hs_equipamento";
public static final String HS_RELATORIO_ID_PK_COLUMN = "hs_relatorio_id";
public void setToHsEquipamentoMedico(HsEquipamentoMedico toHsEquipamentoMedico) {
setToOneTarget("toHsEquipamentoMedico", toHsEquipamentoMedico, true);
public void setToHsEquipamento(HsEquipamento toHsEquipamento) {
setToOneTarget("toHsEquipamento", toHsEquipamento, true);
}
public HsEquipamentoMedico getToHsEquipamentoMedico() {
return (HsEquipamentoMedico)readProperty("toHsEquipamentoMedico");
public HsEquipamento getToHsEquipamento() {
return (HsEquipamento)readProperty("toHsEquipamento");
}

@ -22,18 +22,21 @@ public class ImageDAO extends MainDAO implements MedicinaConstants
public void setImageForEmpresaID( Integer id, byte [] imageData )
{
Empresas empresa = (Empresas) DataObjectUtils.objectForPK( context, Empresas.class, id );
if( empresa != null )
if( id != null )
{
Image logo = null;
if( imageData != null )
Empresas empresa = (Empresas) DataObjectUtils.objectForPK( context, Empresas.class, id );
if( empresa != null )
{
logo = (Image) context.newObject( Image.class );
logo.setImageData( imageData );
logo.setName( "Logotipo: " + empresa.getDesignacaoSocial() );
Image logo = null;
if( imageData != null )
{
logo = (Image) context.newObject( Image.class );
logo.setImageData( imageData );
logo.setName( "Logotipo: " + empresa.getDesignacaoSocial() );
}
empresa.setToLogotipo( logo );
context.commitChanges();
}
empresa.setToLogotipo( logo );
context.commitChanges();
}
}

@ -9,8 +9,8 @@ import org.apache.cayenne.exp.ExpressionFactory;
import org.apache.cayenne.query.SelectQuery;
import siprp.database.cayenne.objects.EmailPlanoDeActuacao;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.database.cayenne.objects.HsLegislacao;
import siprp.database.cayenne.objects.HsLegislacaoCategoria;
import siprp.database.cayenne.objects.HsNormalizacao;
@ -335,4 +335,12 @@ public class PlanoActuacaoDAO extends MainDAO
return context.performQuery( query );
}
public List<HsEquipamento> getAllEquipamentos()
{
SelectQuery query = new SelectQuery( HsEquipamento.class );
query.andQualifier( ExpressionFactory.matchExp( HsEquipamento.DELETED_DATE_PROPERTY, null ) );
query.addOrdering( HsEquipamento.TIPO_PROPERTY, true );
return context.performQuery( query );
}
}

@ -10,6 +10,7 @@ import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsArea;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.database.cayenne.objects.HsLegislacao;
import siprp.database.cayenne.objects.HsLegislacaoCategoria;
import siprp.database.cayenne.objects.HsLegislacaoEmpresa;
@ -501,5 +502,19 @@ public class HigieneSegurancaLogic
}
return result;
}
public static DefaultMutableTreeNode getEquipamentosTree()
{
DefaultMutableTreeNode result = new DefaultMutableTreeNode();
List<HsEquipamento> equipamentos = planoProvider.getAllEquipamentos();
if( equipamentos != null )
{
for( HsEquipamento equipamento : equipamentos )
{
result.add( new DefaultMutableTreeNode( equipamento ) );
}
}
return result;
}
}

@ -2,14 +2,14 @@ package siprp.logic.node;
import javax.swing.tree.DefaultMutableTreeNode;
import siprp.database.cayenne.objects.HsRelatorioEquipamentoMedico;
import siprp.database.cayenne.objects.HsRelatorioEquipamento;
public class EquipamentoNode extends DefaultMutableTreeNode
{
private static final long serialVersionUID = 1L;
public EquipamentoNode( HsRelatorioEquipamentoMedico equipamento )
public EquipamentoNode( HsRelatorioEquipamento equipamento )
{
super( equipamento );
}

Loading…
Cancel
Save