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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 17 years ago
parent 52cf46002a
commit 6126b9ee53

@ -106,13 +106,13 @@ public abstract class AdicionarPanel extends JPanel
@Override
public void valueChanged( TreeSelectionEvent e )
{
setEnabled();
TreePath path = tree.getSelectionPath();
if( path != null )
{
Object selection = path.getLastPathComponent();
firePropertyChange( SELECTION_CHANGED, null, selection );
}
setEnabled();
}
} );
}

@ -17,10 +17,15 @@ 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.TreeInserterDialog;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioEquipamento;
import siprp.higiene.HigieneDataProvider;
import siprp.logic.HigieneSegurancaLogic;
import siprp.logic.node.EquipamentoNode;
public class AdicionarEquipamentosPanel extends JPanel
@ -105,8 +110,9 @@ public class AdicionarEquipamentosPanel extends JPanel
{
setEnabled();
TreePath path = tree.getSelectionPath();
Object object = path == null ? null : path.getLastPathComponent();
HsRelatorioEquipamento rel = object == null ? null : ((object instanceof HsRelatorioEquipamento) ? (HsRelatorioEquipamento) ((EquipamentoNode) object).getUserObject() : null);
DefaultMutableTreeNode node = path == null ? null : (DefaultMutableTreeNode)path.getLastPathComponent();
Object obj = node == null ? null : node.getUserObject();
HsRelatorioEquipamento rel = obj == null ? null : ((obj instanceof HsRelatorioEquipamento) ? (HsRelatorioEquipamento) obj : null);
firePropertyChange( SELECTION_CHANGED, null, rel == null ? null : rel.getToHsRelatorio() );
}
} );
@ -130,18 +136,65 @@ public class AdicionarEquipamentosPanel extends JPanel
private void add()
{
if( relatorio != null )
{
DefaultMutableTreeNode allEquipamentos = HigieneSegurancaLogic.getEquipamentosTree();
TreeInserterDialog dialog = new TreeInserterDialog(this,"Adicionar equipamento",allEquipamentos);
DefaultMutableTreeNode result = dialog.getResult();
if( result != null )
{
for( int i = 0; i < result.getChildCount(); ++i )
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) result.getChildAt( i );
Object obj = node.getUserObject();
if( obj instanceof HsEquipamento )
{
try
{
HsEquipamento equipamento = (HsEquipamento) obj;
HsRelatorioEquipamento relEqui = new HsRelatorioEquipamento();
relEqui.setHsEquipamento( equipamento.getId() );
relEqui.setToHsRelatorio( relatorio );
relEqui.setMarca( equipamento.getMarca() );
relEqui.setModelo( equipamento.getModelo() );
relEqui.setTipo( equipamento.getTipo() );
relEqui.save();
}
catch (Exception e)
{
LeafError.error( e );
}
}
}
}
refresh();
}
}
private void rem()
{
try
{
TreePath path = tree.getSelectionPath();
DefaultMutableTreeNode node = path == null ? null : (DefaultMutableTreeNode)path.getLastPathComponent();
Object obj = node.getUserObject();
HsRelatorioEquipamento rel = obj == null ? null : ((obj instanceof HsRelatorioEquipamento) ? (HsRelatorioEquipamento) obj : null);
if( rel != null )
{
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(false );
buttonRemover.setEnabled( false);
buttonAdicionar.setEnabled( relatorio != null && relatorio.getIsSubmetido() == null );
buttonRemover.setEnabled( tree.getSelectionCount() > 0 );
}
public void refresh()

@ -31,6 +31,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel
this.empresa = empresa;
this.estabelecimento = null;
refresh();
setEnabled();
}
public void setEstabelecimento( Estabelecimentos estabelecimento )
@ -38,6 +39,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel
this.empresa = null;
this.estabelecimento = estabelecimento;
refresh();
setEnabled();
}
@Override
@ -80,6 +82,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel
TreeTools.remove( portuguesaAll, portuguesaCurrent );
TreeTools.remove( internacionalAll, internacionalCurrent );
}
setEnabled();
}
private void addResult( DefaultMutableTreeNode root )
@ -131,7 +134,6 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel
{
TreeTools.merge( root, HigieneSegurancaLogic.getNormalizacaoTreeForEstabelecimento( estabelecimento ) );
}
setEnabled();
TreeTools.refreshTree( tree, root );
}

@ -13,8 +13,10 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.EventObject;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
@ -31,10 +33,12 @@ import javax.swing.event.ChangeListener;
import leaf.ui.LeafError;
import leaf.ui.LeafIconButton;
import siprp.database.cayenne.objects.HsEmailEstabelecimento;
import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.MarcacoesEstabelecimento;
import siprp.database.cayenne.objects.MarcacoesTecnicosHst;
import siprp.higiene.gestao.equipamentos.AdicionarEquipamentosPanel;
import siprp.medicina.processo.mail.MailSender;
import com.evolute.utils.ui.calendar.JCalendarPanel;
@ -58,11 +62,9 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private final JTextField fieldNome1 = new JTextField();
private final JTextField fieldNome2 = new JTextField();
// private final JTextField fieldNome3 = new JTextField();
private final JTextField fieldFuncao1 = new JTextField();
private final JTextField fieldFuncao2 = new JTextField();
// private final JTextField fieldFuncao3 = new JTextField();
private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE );
private final LeafIconButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT );
@ -115,7 +117,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED
}, new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM/*, TableLayout.MINIMUM*/
TableLayout.MINIMUM, TableLayout.MINIMUM
} );
layout.setVGap( 5 );
layout.setHGap( 5 );
@ -132,10 +134,6 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
panelAcompanhantes.add( fieldNome2, new TableLayoutConstraints( 1, 1 ) );
panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 1 ) );
panelAcompanhantes.add( fieldFuncao2, new TableLayoutConstraints( 3, 1 ) );
// panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 2 ) );
// panelAcompanhantes.add( fieldNome3, new TableLayoutConstraints( 1, 2 ) );
// panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 2 ) );
// panelAcompanhantes.add( fieldFuncao3, new TableLayoutConstraints( 3, 2 ) );
TableLayout layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM
@ -170,10 +168,8 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
{
fieldFuncao1.addCaretListener( this );
fieldFuncao2.addCaretListener( this );
// fieldFuncao3.addCaretListener( this );
fieldNome1.addCaretListener( this );
fieldNome2.addCaretListener( this );
// fieldNome3.addCaretListener( this );
dataRelatorio.addChangeListener( this );
radioInicial.addActionListener( this );
radioPeriodica.addActionListener( this );
@ -198,7 +194,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
@Override
public void actionPerformed( ActionEvent e )
{
if( isValidPlano() && JOptionPane.OK_OPTION == confirmSubmit() )
if( isValidPlano() && confirmSubmit() )
{
submit();
}
@ -217,9 +213,9 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
return result;
}
private int confirmSubmit()
private boolean confirmSubmit()
{
return JOptionPane.showConfirmDialog( this, "Ao submeter o Plano de Actua"+ccedil+atilde+"o n"+atilde+"o ser"+aacute+" mais poss"+iacute+"vel alter"+aacute+"-lo. Deseja continuar?" );
return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( this, "Ao submeter o Plano de Actua"+ccedil+atilde+"o n"+atilde+"o ser"+aacute+" mais poss"+iacute+"vel alter"+aacute+"-lo. Deseja continuar?" );
}
private void submit()
@ -230,6 +226,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
{
relatorio.setIsSubmetido( new Date() );
relatorio.save();
sendMail( relatorio );
refresh();
setRelatorio( relatorio, false );
}
@ -239,6 +236,70 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
}
}
private void sendMail( HsRelatorio relatorio )
{
try
{
MailSender sender = new MailSender();
String nomeEstabelecimento = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getNome();
MarcacoesTecnicosHst tecnico = relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosHst();
String nomeTecnico = tecnico == null ? "" : tecnico.getNome();
Date dataVisita = relatorio.getToHsMarcacoesEstabelecimento().getData();
String dataVisitaString = new SimpleDateFormat("dd/MM/yyyy").format( dataVisita );
String subject = "Relatório da Avaliação de Riscos Laborais e Plano de Actuação de " + nomeEstabelecimento + " - auditoria de " + dataVisitaString;
String body = "Exmos. Senhores" +
"\n" +
"\n" +
"\n" +
"Junto enviamos o relatório de avaliação de riscos laborais e " +
"respectivo plano de actuação da auditoria realizada no dia " +
dataVisitaString +
"ao vosso estabelecimento de " +
nomeEstabelecimento +
". Aconselhamos que tenham em conta as não conformidades indicadas " +
"nestes documentos e que preencham o plano de actuação por forma a " +
"auxiliar-vos na planificação das medidas correctivas e para poderem " +
"apresentá-los em caso de inspecção da ACT Autoridade para as Condições do Trabalho." +
"\n" +
"\n" +
"\n" +
"Caso pretendam o nosso apoio ou necessitem de qualquer esclarecimento, contactem-nos, por favor, através do telefone (+351) 213 504 540." +
"\n" +
"\n" +
"\n" +
"Com os melhores cumprimentos, " +
"\n" +
"\n" +
"\n" +
nomeTecnico +
"\n" +
"SIPRP - Sociedade Ibérica de Prevenção de Riscos Profissionais " +
"\n" +
"Atrium Saldanha - Praça Duque de Saldanha, 1 - 9º G - 1050-094 Lisboa " +
"\n" +
"Telefone: (+351) 213 504 540 " +
"\n" +
"Fax: (+351) 213 504 549 " +
"\n" +
"E-mail: geral@siprp.pt " +
"\n" +
"URL: www.siprp.com " +
"\n" +
"\n" +
"\n" +
"Esta é uma mensagem gerada automaticamente pelo nosso sistema, por favor não responda";
List<HsEmailEstabelecimento> rels = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getHsEmailEstabelecimento();
for( HsEmailEstabelecimento rel : rels )
{
sender.send( rel.getToHsEmail().getEmail(), "", subject, body, null, null );
}
}
catch( Exception ex )
{
ex.printStackTrace();
}
}
private void save()
{
try
@ -247,23 +308,12 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
{
relatorio.setData( dataRelatorio.getDate() );
relatorio.setAvaliacaoInicial( radioInicial.isSelected() );
// MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento();
// if( marcacao != null )
// {
// MarcacoesTecnicosHst tecnico = marcacao.getToMarcacoesTecnicosHst();
// if( tecnico != null )
// {
// tecnico.setNome( fieldTecnico.getText() );
// }
// }
}
relatorio.setAcompanhante1( fieldNome1.getText() );
relatorio.setAcompanhante2( fieldNome2.getText() );
// relatorio.setAcompanhante3( fieldNome3.getText() );
relatorio.setFuncaoAcompanhante1(fieldFuncao1.getText());
relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText());
// relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText());
relatorio.save();
refresh();
buttonRevert.setEnabled( false );
@ -309,10 +359,8 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
fieldTecnico.setText( tecnicoName );
fieldNome1.setText( relatorio == null ? null : relatorio.getAcompanhante1() );
fieldNome2.setText( relatorio == null ? null : relatorio.getAcompanhante2() );
// fieldNome3.setText( relatorio == null ? null : relatorio.getAcompanhante3() );
fieldFuncao1.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante1() );
fieldFuncao2.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante2() );
// fieldFuncao3.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante3() );
}
private void setEnabled()
@ -324,10 +372,8 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
fieldTecnico.setEnabled( false );
fieldNome1.setEnabled( enabled );
fieldNome2.setEnabled( enabled );
// fieldNome3.setEnabled( enabled );
fieldFuncao1.setEnabled( enabled );
fieldFuncao2.setEnabled( enabled );
// fieldFuncao3.setEnabled( enabled );
buttonSubmit.setEnabled( enabled );
}

@ -24,9 +24,7 @@ public class MailSender
}
public void send( String to, String bcc, String subject, String body,
String attachmentNames[], byte attachments[][] )
throws Exception
public void send( String to, String bcc, String subject, String body, String attachmentNames[], byte attachments[][] ) throws Exception
{
Properties props = System.getProperties();
props.put( "mail.smtp.host", mailServer );

@ -13,6 +13,7 @@ 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.V10_2_To_V10_3;
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;
@ -56,7 +57,7 @@ public class UpdateList
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 V10_1_To_V10_2() };
new V10_1_To_V10_2(), new V10_2_To_V10_3() };
protected static Executer EXECUTER;
protected static double version = -1;

@ -0,0 +1,69 @@
package siprp.update.updates;
import com.evolute.utils.Singleton;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
public class V10_2_To_V10_3
implements siprp.update.Update
{
public V10_2_To_V10_3()
{
}
public String []listChanges()
{
return new String[]{
"adicionadas normalizacoes duplicadas para planos de actuacao",
"adicionados campos aos tecnicos de higiene e seguranca"
};
}
public double getStartVersion()
{
return 10.2;
}
public double getEndVersion()
{
return 10.3;
}
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_relatorio_equipamento drop constraint hs_relatorio_equipamento_hs_equipamento_fkey; " +
"alter table hs_relatorio_equipamento drop constraint hs_relatorio_equipamento_pkey; " +
"alter table hs_relatorio_equipamento add column id serial PRIMARY KEY; " +
"alter table hs_relatorio_equipamento add column tipo varchar(512); " +
"alter table hs_relatorio_equipamento add column marca varchar(256); " +
"alter table hs_relatorio_equipamento add column modelo varchar(256); " +
"select setval('hs_relatorio_equipamento_id_seq',1000);" +
"alter table hs_relatorio_legislacao drop constraint hs_relatorio_legislacao_hs_legislacao_id_fkey; " +
"alter table hs_relatorio_legislacao drop constraint hs_relatorio_legislacao_pkey; " +
"alter table hs_relatorio_legislacao add column id serial PRIMARY KEY; " +
"alter table hs_relatorio_legislacao add column categoria varchar(255); " +
"alter table hs_relatorio_legislacao add column descricao varchar(1024); " +
"alter table hs_relatorio_normalizacao drop constraint hs_relatorio_normalizacao_hs_normalizacao_id_fkey; " +
"alter table hs_relatorio_normalizacao drop constraint hs_relatorio_normalizacao_pkey; " +
"alter table hs_relatorio_normalizacao add column id serial PRIMARY KEY; " +
"alter table hs_relatorio_normalizacao add column codigo varchar(128) NOT NULL; " +
"alter table hs_relatorio_normalizacao add column descricao varchar(1024); " +
"alter table hs_relatorio_normalizacao add column portuguesa boolean NOT NULL; " +
"alter table marcacoes_tecnicos_hst add column cap varchar(128); " +
"alter table marcacoes_tecnicos_hst add column formacao varchar(128); " +
"alter table marcacoes_tecnicos_hst add column assinatura int4 REFERENCES image(id); "
);
executer.executeQuery( update );
}
public String toString()
{
return "v" + getStartVersion() + " para v" + getEndVersion();
}
}

@ -338,12 +338,29 @@
</db-key-generator>
</db-entity>
<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-attribute name="hs_equipamento" type="INTEGER" isMandatory="true" length="10"/>
<db-attribute name="hs_relatorio_id" type="INTEGER" isMandatory="true" length="10"/>
<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="marca" type="VARCHAR" length="256"/>
<db-attribute name="modelo" type="VARCHAR" length="256"/>
<db-attribute name="tipo" type="VARCHAR" length="512"/>
<db-key-generator>
<db-generator-type>ORACLE</db-generator-type>
<db-generator-name>hs_relatorio_equipamento_id_seq</db-generator-name>
<db-key-cache-size>1</db-key-cache-size>
</db-key-generator>
</db-entity>
<db-entity name="hs_relatorio_legislacao" schema="public">
<db-attribute name="hs_legislacao_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="hs_relatorio_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="categoria" type="VARCHAR" length="255"/>
<db-attribute name="descricao" type="VARCHAR" length="1024"/>
<db-attribute name="hs_legislacao_id" type="INTEGER" isMandatory="true" length="10"/>
<db-attribute name="hs_relatorio_id" type="INTEGER" isMandatory="true" length="10"/>
<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-key-generator>
<db-generator-type>ORACLE</db-generator-type>
<db-generator-name>hs_relatorio_legislacao_id_seq</db-generator-name>
<db-key-cache-size>1</db-key-cache-size>
</db-key-generator>
</db-entity>
<db-entity name="hs_relatorio_medida" schema="public">
<db-attribute name="deleted_date" type="TIMESTAMP"/>
@ -358,8 +375,17 @@
</db-key-generator>
</db-entity>
<db-entity name="hs_relatorio_normalizacao" schema="public">
<db-attribute name="hs_normalizacao_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="hs_relatorio_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="codigo" type="VARCHAR" isMandatory="true" length="128"/>
<db-attribute name="descricao" type="VARCHAR" isMandatory="true" length="1024"/>
<db-attribute name="hs_normalizacao_id" type="INTEGER" isMandatory="true" length="10"/>
<db-attribute name="hs_relatorio_id" type="INTEGER" isMandatory="true" length="10"/>
<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="portuguesa" type="BOOLEAN" isMandatory="true"/>
<db-key-generator>
<db-generator-type>ORACLE</db-generator-type>
<db-generator-name>hs_relatorio_legislacao_id_seq</db-generator-name>
<db-key-cache-size>1</db-key-cache-size>
</db-key-generator>
</db-entity>
<db-entity name="hs_relatorio_posto" schema="public">
<db-attribute name="area_id" type="INTEGER" length="10"/>
@ -501,6 +527,9 @@
</db-key-generator>
</db-entity>
<db-entity name="marcacoes_tecnicos_hst" schema="public">
<db-attribute name="assinatura" type="INTEGER" length="10"/>
<db-attribute name="cap" type="VARCHAR" length="128"/>
<db-attribute name="formacao" type="VARCHAR" length="128"/>
<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="identificador" type="INTEGER" length="10"/>
<db-attribute name="inactivo" type="CHAR" isMandatory="true" length="1"/>
@ -920,6 +949,7 @@
</obj-entity>
<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="id" type="java.lang.Integer" db-attribute-path="id"/>
<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"/>
@ -927,6 +957,7 @@
<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"/>
<obj-attribute name="description" type="java.lang.String" db-attribute-path="description"/>
<obj-attribute name="id" type="java.lang.Integer" db-attribute-path="id"/>
</obj-entity>
<obj-entity name="HsLegislacaoCategoria" className="siprp.database.cayenne.objects.HsLegislacaoCategoria" dbEntityName="hs_legislacao_categoria" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="deletedDate" type="java.util.Date" db-attribute-path="deleted_date"/>
@ -945,6 +976,7 @@
<obj-attribute name="codigo" type="java.lang.String" db-attribute-path="codigo"/>
<obj-attribute name="deletedDate" type="java.util.Date" db-attribute-path="deleted_date"/>
<obj-attribute name="descricao" type="java.lang.String" db-attribute-path="descricao"/>
<obj-attribute name="id" type="java.lang.Integer" db-attribute-path="id"/>
<obj-attribute name="portuguesa" type="java.lang.Boolean" db-attribute-path="portuguesa"/>
</obj-entity>
<obj-entity name="HsNormalizacaoEmpresa" className="siprp.database.cayenne.objects.HsNormalizacaoEmpresa" dbEntityName="hs_normalizacao_empresa" superClassName="siprp.database.cayenne.objects.BaseObject">
@ -983,8 +1015,16 @@
<obj-attribute name="description" type="java.lang.String" db-attribute-path="description"/>
</obj-entity>
<obj-entity name="HsRelatorioEquipamento" className="siprp.database.cayenne.objects.HsRelatorioEquipamento" dbEntityName="hs_relatorio_equipamento" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="hsEquipamento" type="java.lang.Integer" db-attribute-path="hs_equipamento"/>
<obj-attribute name="hsRelatorioId" type="java.lang.Integer" db-attribute-path="hs_relatorio_id"/>
<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="HsRelatorioLegislacao" className="siprp.database.cayenne.objects.HsRelatorioLegislacao" dbEntityName="hs_relatorio_legislacao" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="categoria" type="java.lang.String" db-attribute-path="categoria"/>
<obj-attribute name="descricao" type="java.lang.String" db-attribute-path="descricao"/>
<obj-attribute name="hsLegislacaoId" type="java.lang.Integer" db-attribute-path="hs_legislacao_id"/>
</obj-entity>
<obj-entity name="HsRelatorioMedida" className="siprp.database.cayenne.objects.HsRelatorioMedida" dbEntityName="hs_relatorio_medida" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="deletedDate" type="java.util.Date" db-attribute-path="deleted_date"/>
@ -992,6 +1032,10 @@
<obj-attribute name="requesitosLegais" type="java.lang.String" db-attribute-path="requesitos_legais"/>
</obj-entity>
<obj-entity name="HsRelatorioNormalizacao" className="siprp.database.cayenne.objects.HsRelatorioNormalizacao" dbEntityName="hs_relatorio_normalizacao" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="codigo" type="java.lang.String" db-attribute-path="codigo"/>
<obj-attribute name="descricao" type="java.lang.String" db-attribute-path="descricao"/>
<obj-attribute name="hsNormalizacaoId" type="java.lang.Integer" db-attribute-path="hs_normalizacao_id"/>
<obj-attribute name="portuguesa" type="java.lang.Boolean" db-attribute-path="portuguesa"/>
</obj-entity>
<obj-entity name="HsRelatorioPosto" className="siprp.database.cayenne.objects.HsRelatorioPosto" dbEntityName="hs_relatorio_posto" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="deletedDate" type="java.util.Date" db-attribute-path="deleted_date"/>
@ -1063,6 +1107,9 @@
<obj-entity name="MarcacoesGruposRealizados" className="siprp.database.cayenne.objects.MarcacoesGruposRealizados" lock-type="optimistic" dbEntityName="marcacoes_grupos_realizados" superClassName="siprp.database.cayenne.objects.BaseObject">
</obj-entity>
<obj-entity name="MarcacoesTecnicosHst" className="siprp.database.cayenne.objects.MarcacoesTecnicosHst" lock-type="optimistic" dbEntityName="marcacoes_tecnicos_hst" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="assinatura" type="java.lang.Integer" db-attribute-path="assinatura"/>
<obj-attribute name="cap" type="java.lang.String" db-attribute-path="cap"/>
<obj-attribute name="formacao" type="java.lang.String" db-attribute-path="formacao"/>
<obj-attribute name="id" type="java.lang.Integer" db-attribute-path="id"/>
<obj-attribute name="identificador" type="java.lang.Integer" db-attribute-path="identificador"/>
<obj-attribute name="inactivo" type="java.lang.String" db-attribute-path="inactivo"/>
@ -1361,9 +1408,6 @@
<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="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"/>
</db-relationship>
@ -1451,13 +1495,13 @@
<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="hsRelatorioEquipamentoArray" source="hs_relatorio" target="hs_relatorio_equipamento" toDependentPK="true" toMany="true">
<db-relationship name="hsRelatorioEquipamentoArray" source="hs_relatorio" target="hs_relatorio_equipamento" 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">
<db-relationship name="hsRelatorioLegislacaoArray" source="hs_relatorio" target="hs_relatorio_legislacao" toMany="true">
<db-attribute-pair source="id" target="hs_relatorio_id"/>
</db-relationship>
<db-relationship name="hsRelatorioNormalizacaoArray" source="hs_relatorio" target="hs_relatorio_normalizacao" toDependentPK="true" toMany="true">
<db-relationship name="hsRelatorioNormalizacaoArray" source="hs_relatorio" target="hs_relatorio_normalizacao" toMany="true">
<db-attribute-pair source="id" target="hs_relatorio_id"/>
</db-relationship>
<db-relationship name="hsRelatorioRiscoArray" source="hs_relatorio" target="hs_relatorio_risco" toMany="true">
@ -1472,9 +1516,6 @@
<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="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" target="hs_relatorio" toMany="false">
<db-attribute-pair source="hs_relatorio_id" target="id"/>
</db-relationship>
@ -1874,7 +1915,6 @@
<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="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"/>
@ -1910,8 +1950,7 @@
<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="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="HsRelatorioEquipamento" target="HsRelatorio" deleteRule="Nullify" 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"/>

@ -8,6 +8,18 @@ public class HsNormalizacao extends _HsNormalizacao {
private static final int TO_STRING_LENGTH = 58;
@Override
public String getCodigo()
{
return parseFromUnicode( super.getCodigo() );
}
@Override
public void setCodigo( String codigo )
{
super.setCodigo( parseToUnicode( codigo ) );
}
@Override
public String getDescricao()
{

@ -6,9 +6,47 @@ public class HsRelatorioEquipamento extends _HsRelatorioEquipamento {
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 getToHsEquipamento().toString();
String marca = getMarca() == null ? "" : getMarca();
String modelo = getModelo() == null ? "" : getModelo();
return getTipo() + ": " + marca + "-" + modelo;
}
}

@ -6,5 +6,22 @@ public class HsRelatorioLegislacao extends _HsRelatorioLegislacao {
private static final long serialVersionUID = 1L;
@Override
public String getDescricao()
{
return parseFromUnicode( super.getDescricao() );
}
@Override
public void setDescricao( String descricao )
{
super.setDescricao( parseToUnicode( descricao ) );
}
@Override
public String toString()
{
return getDescricao();
}
}

@ -3,5 +3,41 @@ package siprp.database.cayenne.objects;
import siprp.database.cayenne.objects.auto._HsRelatorioNormalizacao;
public class HsRelatorioNormalizacao extends _HsRelatorioNormalizacao {
private static final long serialVersionUID = 1L;
private static final int TO_STRING_LENGTH = 58;
@Override
public String getCodigo()
{
return parseFromUnicode( super.getCodigo() );
}
@Override
public void setCodigo( String codigo )
{
super.setCodigo( parseToUnicode( codigo ) );
}
@Override
public String getDescricao()
{
return parseFromUnicode( super.getDescricao() );
}
@Override
public void setDescricao( String nome )
{
super.setDescricao( parseToUnicode( nome ) );
}
@Override
public String toString()
{
String codigo = getCodigo();
String descricao = getDescricao() == null ? "" : getDescricao().replaceAll( "\n", " " );
return (codigo == null ? "" : codigo ) + ": " + ( descricao.substring( 0, Math.min( TO_STRING_LENGTH, descricao.length() ) ) + ( TO_STRING_LENGTH < descricao.length() ? "..." : "" ) );
}
}

@ -1,10 +1,8 @@
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.
@ -15,10 +13,10 @@ import siprp.database.cayenne.objects.HsRelatorioEquipamento;
public abstract class _HsEquipamento extends BaseObject {
public static final String DELETED_DATE_PROPERTY = "deletedDate";
public static final String ID_PROPERTY = "id";
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";
@ -29,6 +27,13 @@ public abstract class _HsEquipamento extends BaseObject {
return (Date)readProperty("deletedDate");
}
public void setId(Integer id) {
writeProperty("id", id);
}
public Integer getId() {
return (Integer)readProperty("id");
}
public void setMarca(String marca) {
writeProperty("marca", marca);
}
@ -50,16 +55,4 @@ public abstract class _HsEquipamento extends BaseObject {
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");
}
}

@ -18,6 +18,7 @@ public abstract class _HsLegislacao extends BaseObject {
public static final String DELETED_DATE_PROPERTY = "deletedDate";
public static final String DESCRIPTION_PROPERTY = "description";
public static final String ID_PROPERTY = "id";
public static final String HS_LEGISLACAO_EMPRESA_ARRAY_PROPERTY = "hsLegislacaoEmpresaArray";
public static final String HS_LEGISLACAO_ESTABELECIMENTO_ARRAY_PROPERTY = "hsLegislacaoEstabelecimentoArray";
public static final String TO_HS_LEGISLACAO_CATEGORIA_PROPERTY = "toHsLegislacaoCategoria";
@ -38,6 +39,13 @@ public abstract class _HsLegislacao extends BaseObject {
return (String)readProperty("description");
}
public void setId(Integer id) {
writeProperty("id", id);
}
public Integer getId() {
return (Integer)readProperty("id");
}
public void addToHsLegislacaoEmpresaArray(HsLegislacaoEmpresa obj) {
addToManyTarget("hsLegislacaoEmpresaArray", obj, true);
}

@ -18,6 +18,7 @@ public abstract class _HsNormalizacao extends BaseObject {
public static final String CODIGO_PROPERTY = "codigo";
public static final String DELETED_DATE_PROPERTY = "deletedDate";
public static final String DESCRICAO_PROPERTY = "descricao";
public static final String ID_PROPERTY = "id";
public static final String PORTUGUESA_PROPERTY = "portuguesa";
public static final String HS_NORMALIZACAO_EMPRESA_ARRAY_PROPERTY = "hsNormalizacaoEmpresaArray";
public static final String HS_NORMALIZACAO_ESTABELECIMENTO_ARRAY_PROPERTY = "hsNormalizacaoEstabelecimentoArray";
@ -45,6 +46,13 @@ public abstract class _HsNormalizacao extends BaseObject {
return (String)readProperty("descricao");
}
public void setId(Integer id) {
writeProperty("id", id);
}
public Integer getId() {
return (Integer)readProperty("id");
}
public void setPortuguesa(Boolean portuguesa) {
writeProperty("portuguesa", portuguesa);
}

@ -1,7 +1,6 @@
package siprp.database.cayenne.objects.auto;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.database.cayenne.objects.HsRelatorio;
/**
@ -12,20 +11,49 @@ import siprp.database.cayenne.objects.HsRelatorio;
*/
public abstract class _HsRelatorioEquipamento extends BaseObject {
public static final String TO_HS_EQUIPAMENTO_PROPERTY = "toHsEquipamento";
public static final String HS_EQUIPAMENTO_PROPERTY = "hsEquipamento";
public static final String HS_RELATORIO_ID_PROPERTY = "hsRelatorioId";
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 TO_HS_RELATORIO_PROPERTY = "toHsRelatorio";
public static final String HS_EQUIPAMENTO_PK_COLUMN = "hs_equipamento";
public static final String HS_RELATORIO_ID_PK_COLUMN = "hs_relatorio_id";
public static final String ID_PK_COLUMN = "id";
public void setToHsEquipamento(HsEquipamento toHsEquipamento) {
setToOneTarget("toHsEquipamento", toHsEquipamento, true);
public void setHsEquipamento(Integer hsEquipamento) {
writeProperty("hsEquipamento", hsEquipamento);
}
public Integer getHsEquipamento() {
return (Integer)readProperty("hsEquipamento");
}
public void setHsRelatorioId(Integer hsRelatorioId) {
writeProperty("hsRelatorioId", hsRelatorioId);
}
public Integer getHsRelatorioId() {
return (Integer)readProperty("hsRelatorioId");
}
public void setMarca(String marca) {
writeProperty("marca", marca);
}
public String getMarca() {
return (String)readProperty("marca");
}
public HsEquipamento getToHsEquipamento() {
return (HsEquipamento)readProperty("toHsEquipamento");
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 setToHsRelatorio(HsRelatorio toHsRelatorio) {
setToOneTarget("toHsRelatorio", toHsRelatorio, true);

@ -11,10 +11,33 @@ import siprp.database.cayenne.objects.HsRelatorio;
*/
public abstract class _HsRelatorioLegislacao extends BaseObject {
public static final String CATEGORIA_PROPERTY = "categoria";
public static final String DESCRICAO_PROPERTY = "descricao";
public static final String HS_LEGISLACAO_ID_PROPERTY = "hsLegislacaoId";
public static final String TO_HS_RELATORIO_PROPERTY = "toHsRelatorio";
public static final String HS_LEGISLACAO_ID_PK_COLUMN = "hs_legislacao_id";
public static final String HS_RELATORIO_ID_PK_COLUMN = "hs_relatorio_id";
public static final String ID_PK_COLUMN = "id";
public void setCategoria(String categoria) {
writeProperty("categoria", categoria);
}
public String getCategoria() {
return (String)readProperty("categoria");
}
public void setDescricao(String descricao) {
writeProperty("descricao", descricao);
}
public String getDescricao() {
return (String)readProperty("descricao");
}
public void setHsLegislacaoId(Integer hsLegislacaoId) {
writeProperty("hsLegislacaoId", hsLegislacaoId);
}
public Integer getHsLegislacaoId() {
return (Integer)readProperty("hsLegislacaoId");
}
public void setToHsRelatorio(HsRelatorio toHsRelatorio) {
setToOneTarget("toHsRelatorio", toHsRelatorio, true);

@ -11,10 +11,41 @@ import siprp.database.cayenne.objects.HsRelatorio;
*/
public abstract class _HsRelatorioNormalizacao extends BaseObject {
public static final String CODIGO_PROPERTY = "codigo";
public static final String DESCRICAO_PROPERTY = "descricao";
public static final String HS_NORMALIZACAO_ID_PROPERTY = "hsNormalizacaoId";
public static final String PORTUGUESA_PROPERTY = "portuguesa";
public static final String TO_HS_RELATORIO_PROPERTY = "toHsRelatorio";
public static final String HS_NORMALIZACAO_ID_PK_COLUMN = "hs_normalizacao_id";
public static final String HS_RELATORIO_ID_PK_COLUMN = "hs_relatorio_id";
public static final String ID_PK_COLUMN = "id";
public void setCodigo(String codigo) {
writeProperty("codigo", codigo);
}
public String getCodigo() {
return (String)readProperty("codigo");
}
public void setDescricao(String descricao) {
writeProperty("descricao", descricao);
}
public String getDescricao() {
return (String)readProperty("descricao");
}
public void setHsNormalizacaoId(Integer hsNormalizacaoId) {
writeProperty("hsNormalizacaoId", hsNormalizacaoId);
}
public Integer getHsNormalizacaoId() {
return (Integer)readProperty("hsNormalizacaoId");
}
public void setPortuguesa(Boolean portuguesa) {
writeProperty("portuguesa", portuguesa);
}
public Boolean getPortuguesa() {
return (Boolean)readProperty("portuguesa");
}
public void setToHsRelatorio(HsRelatorio toHsRelatorio) {
setToOneTarget("toHsRelatorio", toHsRelatorio, true);

@ -13,6 +13,9 @@ import siprp.database.cayenne.objects.MarcacoesEstabelecimento;
*/
public abstract class _MarcacoesTecnicosHst extends BaseObject {
public static final String ASSINATURA_PROPERTY = "assinatura";
public static final String CAP_PROPERTY = "cap";
public static final String FORMACAO_PROPERTY = "formacao";
public static final String ID_PROPERTY = "id";
public static final String IDENTIFICADOR_PROPERTY = "identificador";
public static final String INACTIVO_PROPERTY = "inactivo";
@ -23,6 +26,27 @@ public abstract class _MarcacoesTecnicosHst extends BaseObject {
public static final String ID_PK_COLUMN = "id";
public void setAssinatura(Integer assinatura) {
writeProperty("assinatura", assinatura);
}
public Integer getAssinatura() {
return (Integer)readProperty("assinatura");
}
public void setCap(String cap) {
writeProperty("cap", cap);
}
public String getCap() {
return (String)readProperty("cap");
}
public void setFormacao(String formacao) {
writeProperty("formacao", formacao);
}
public String getFormacao() {
return (String)readProperty("formacao");
}
public void setId(Integer id) {
writeProperty("id", id);
}

@ -24,7 +24,9 @@ import siprp.database.cayenne.objects.HsPostoEstabelecimento;
import siprp.database.cayenne.objects.HsPostoRisco;
import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioArea;
import siprp.database.cayenne.objects.HsRelatorioLegislacao;
import siprp.database.cayenne.objects.HsRelatorioMedida;
import siprp.database.cayenne.objects.HsRelatorioNormalizacao;
import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
@ -183,20 +185,13 @@ public class HigieneSegurancaLogic
{
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();
}
Estabelecimentos estabelecimento = relatorio.getToHsMarcacoesEstabelecimento() == null ? null : relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos();
if( estabelecimento != null )
{
reverterAreas( relatorio, estabelecimento );
reverterLegislacao( relatorio, estabelecimento );
reverterNormalizacao( relatorio, estabelecimento );
}
}
} catch( Exception e )
{
@ -204,6 +199,20 @@ public class HigieneSegurancaLogic
}
}
private static void reverterAreas( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception
{
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();
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>();
@ -250,6 +259,63 @@ public class HigieneSegurancaLogic
}
}
private static void reverterLegislacao( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception
{
for(HsRelatorioLegislacao legislacao : relatorio.getHsRelatorioLegislacaoArray())
{
legislacao.delete();
}
for( HsLegislacaoEstabelecimento rel : estabelecimento.getHsLegislacaoEstabelecimentoArray() )
{
HsLegislacao legislacao = rel.getToHsLegislacao();
HsRelatorioLegislacao relatorioLegislacao = criarRelatorioLegislacao( relatorio, legislacao );
relatorioLegislacao.save();
}
}
private static HsRelatorioLegislacao criarRelatorioLegislacao( HsRelatorio relatorio, HsLegislacao legislacao )
{
HsRelatorioLegislacao result = null;
if( relatorio != null && legislacao != null )
{
result = new HsRelatorioLegislacao();
result.setCategoria( legislacao.getToHsLegislacaoCategoria() == null ? null : legislacao.getToHsLegislacaoCategoria().getDescription() );
result.setToHsRelatorio( relatorio );
result.setHsLegislacaoId( legislacao.getId() );
result.setDescricao( legislacao.getDescription() );
}
return result;
}
private static void reverterNormalizacao( HsRelatorio relatorio, Estabelecimentos estabelecimento ) throws Exception
{
for(HsRelatorioNormalizacao normalizacao : relatorio.getHsRelatorioNormalizacaoArray() )
{
normalizacao.delete();
}
for( HsNormalizacaoEstabelecimento rel : estabelecimento.getHsNormalizacaoEstabelecimentoArray() )
{
HsNormalizacao normalizacao = rel.getToHsNormalizacao();
HsRelatorioNormalizacao relatorioNormalizacao = criarRelatorioNormalizacao( relatorio, normalizacao );
relatorioNormalizacao.save();
}
}
private static HsRelatorioNormalizacao criarRelatorioNormalizacao( HsRelatorio relatorio, HsNormalizacao normalizacao )
{
HsRelatorioNormalizacao result = null;
if( relatorio != null && normalizacao != null )
{
result = new HsRelatorioNormalizacao();
result.setCodigo( normalizacao.getCodigo() );
result.setDescricao( normalizacao.getDescricao() );
result.setToHsRelatorio( relatorio );
result.setHsNormalizacaoId( normalizacao.getId() );
result.setPortuguesa( normalizacao.getPortuguesa() );
}
return result;
}
public static boolean isProbabilidadeValida( Integer probabilidade )
{
return probabilidade != null && probabilidade > 0 && probabilidade < 17;

Loading…
Cancel
Save