forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@892 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
620715c814
commit
61dadc84a6
@ -0,0 +1,504 @@
|
|||||||
|
package siprp.higiene.gestao.normalizacao;
|
||||||
|
|
||||||
|
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
|
||||||
|
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
|
||||||
|
import static com.evolute.utils.strings.UnicodeLatin1Map.oacute;
|
||||||
|
import info.clearthought.layout.TableLayout;
|
||||||
|
import info.clearthought.layout.TableLayoutConstraints;
|
||||||
|
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.LayoutManager;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
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.LeafError;
|
||||||
|
import leaf.ui.LeafTextAreaEditor;
|
||||||
|
import leaf.ui.TreeTools;
|
||||||
|
import siprp.database.cayenne.objects.HsNormalizacao;
|
||||||
|
import siprp.logic.HigieneSegurancaLogic;
|
||||||
|
|
||||||
|
public class GerirNormalizacaoPanel extends JPanel
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final JPanel panelPortuguesa = new JPanel();
|
||||||
|
|
||||||
|
private final JPanel panelInternacional = new JPanel();
|
||||||
|
|
||||||
|
private final JPanel panelButtonsPortuguesa = new JPanel();
|
||||||
|
|
||||||
|
private final LeafButton buttonPortuguesaCriar = new LeafButton( "Criar" );
|
||||||
|
|
||||||
|
private final LeafButton buttonPortuguesaEditar = new LeafButton( "Editar" );
|
||||||
|
|
||||||
|
private final LeafButton buttonPortuguesaRemover = new LeafButton( "Remover" );
|
||||||
|
|
||||||
|
private final JPanel panelButtonsInternacional = new JPanel();
|
||||||
|
|
||||||
|
private final LeafButton buttonInternacionalCriar = new LeafButton( "Criar" );
|
||||||
|
|
||||||
|
private final LeafButton buttonInternacionalEditar = new LeafButton( "Editar" );
|
||||||
|
|
||||||
|
private final LeafButton buttonInternacionalRemover = new LeafButton( "Remover" );
|
||||||
|
|
||||||
|
private final DefaultMutableTreeNode rootPortuguesa = new DefaultMutableTreeNode();
|
||||||
|
|
||||||
|
private final DefaultTreeModel modelPortuguesa = new DefaultTreeModel( rootPortuguesa );
|
||||||
|
|
||||||
|
private final JTree treePortuguesa = new JTree( modelPortuguesa );
|
||||||
|
|
||||||
|
private final JScrollPane scrollPortuguesa = new JScrollPane( treePortuguesa );
|
||||||
|
|
||||||
|
private final DefaultMutableTreeNode rootInternacional = new DefaultMutableTreeNode();
|
||||||
|
|
||||||
|
private final DefaultTreeModel modelInternacional = new DefaultTreeModel( rootInternacional );
|
||||||
|
|
||||||
|
private final JTree treeInternacional = new JTree( modelInternacional );
|
||||||
|
|
||||||
|
private final JScrollPane scrollInternacional = new JScrollPane( treeInternacional );
|
||||||
|
|
||||||
|
private HsNormalizacao selectedPortuguesa = null;
|
||||||
|
|
||||||
|
private HsNormalizacao selectedInternacional = null;
|
||||||
|
|
||||||
|
private final JPanel panelData = new JPanel();
|
||||||
|
|
||||||
|
private final JTextField textCodigo = new JTextField(10);
|
||||||
|
|
||||||
|
private final LeafTextAreaEditor textDescricao = new LeafTextAreaEditor( new Validator<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean isValid( String object )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
public GerirNormalizacaoPanel()
|
||||||
|
{
|
||||||
|
startupComponents();
|
||||||
|
startupLayout();
|
||||||
|
placeComponents();
|
||||||
|
setupListeners();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startupComponents()
|
||||||
|
{
|
||||||
|
panelPortuguesa.setBorder( BorderFactory.createTitledBorder( "Normaliza" + ccedil + atilde + "o Portuguesa" ) );
|
||||||
|
|
||||||
|
panelInternacional.setBorder( BorderFactory.createTitledBorder( "Normaliza" + ccedil + atilde + "o Internacional" ) );
|
||||||
|
|
||||||
|
treeInternacional.setRootVisible( false );
|
||||||
|
treePortuguesa.setRootVisible( false );
|
||||||
|
treeInternacional.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
|
||||||
|
treePortuguesa.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
|
||||||
|
|
||||||
|
textCodigo.setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startupLayout()
|
||||||
|
{
|
||||||
|
LayoutManager layout = new TableLayout( new double[] {
|
||||||
|
TableLayout.FILL, TableLayout.FILL
|
||||||
|
}, new double[] {
|
||||||
|
TableLayout.FILL, TableLayout.FILL
|
||||||
|
} );
|
||||||
|
this.setLayout( layout );
|
||||||
|
|
||||||
|
layout = new TableLayout( new double[] {
|
||||||
|
TableLayout.MINIMUM, TableLayout.FILL
|
||||||
|
}, new double[] {
|
||||||
|
TableLayout.MINIMUM, TableLayout.FILL
|
||||||
|
} );
|
||||||
|
panelPortuguesa.setLayout( layout );
|
||||||
|
((TableLayout) layout).setHGap( 5 );
|
||||||
|
((TableLayout) layout).setVGap( 5 );
|
||||||
|
|
||||||
|
layout = new TableLayout( new double[] {
|
||||||
|
TableLayout.MINIMUM, TableLayout.FILL
|
||||||
|
}, new double[] {
|
||||||
|
TableLayout.MINIMUM, TableLayout.FILL
|
||||||
|
} );
|
||||||
|
((TableLayout) layout).setHGap( 5 );
|
||||||
|
((TableLayout) layout).setVGap( 5 );
|
||||||
|
|
||||||
|
panelInternacional.setLayout( layout );
|
||||||
|
|
||||||
|
layout = new GridLayout( 3, 1, 5, 5 );
|
||||||
|
panelButtonsPortuguesa.setLayout( layout );
|
||||||
|
|
||||||
|
layout = new GridLayout( 3, 1, 5, 5 );
|
||||||
|
panelButtonsInternacional.setLayout( layout );
|
||||||
|
|
||||||
|
layout = new TableLayout( new double[] {
|
||||||
|
TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL
|
||||||
|
}, new double[] {
|
||||||
|
TableLayout.MINIMUM, TableLayout.FILL
|
||||||
|
} );
|
||||||
|
((TableLayout) layout).setHGap( 5 );
|
||||||
|
((TableLayout) layout).setVGap( 5 );
|
||||||
|
panelData.setLayout( layout );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void placeComponents()
|
||||||
|
{
|
||||||
|
panelButtonsPortuguesa.add( buttonPortuguesaCriar );
|
||||||
|
panelButtonsPortuguesa.add( buttonPortuguesaEditar );
|
||||||
|
panelButtonsPortuguesa.add( buttonPortuguesaRemover );
|
||||||
|
|
||||||
|
panelButtonsInternacional.add( buttonInternacionalCriar );
|
||||||
|
panelButtonsInternacional.add( buttonInternacionalEditar );
|
||||||
|
panelButtonsInternacional.add( buttonInternacionalRemover );
|
||||||
|
|
||||||
|
panelPortuguesa.add( panelButtonsPortuguesa, new TableLayoutConstraints( 0, 0 ) );
|
||||||
|
panelPortuguesa.add( scrollPortuguesa, new TableLayoutConstraints( 1, 0, 1, 1 ) );
|
||||||
|
|
||||||
|
panelInternacional.add( panelButtonsInternacional, new TableLayoutConstraints( 0, 0 ) );
|
||||||
|
panelInternacional.add( scrollInternacional, new TableLayoutConstraints( 1, 0, 1, 1 ) );
|
||||||
|
|
||||||
|
panelData.add( new JLabel("C" + oacute + "digo"), new TableLayoutConstraints( 0, 0 ) );
|
||||||
|
panelData.add( textCodigo, new TableLayoutConstraints( 1, 0 ) );
|
||||||
|
panelData.add( textDescricao, new TableLayoutConstraints( 0, 1, 2, 1 ) );
|
||||||
|
|
||||||
|
this.add( panelPortuguesa, new TableLayoutConstraints( 0, 0 ) );
|
||||||
|
this.add( panelInternacional, new TableLayoutConstraints( 0, 1 ) );
|
||||||
|
this.add( panelData, new TableLayoutConstraints( 1, 0, 1, 1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupListeners()
|
||||||
|
{
|
||||||
|
treeInternacional.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void valueChanged( TreeSelectionEvent e )
|
||||||
|
{
|
||||||
|
TreePath selectionPath = e.getNewLeadSelectionPath();
|
||||||
|
if( selectionPath != null )
|
||||||
|
{
|
||||||
|
Object last = selectionPath.getLastPathComponent();
|
||||||
|
if( last instanceof DefaultMutableTreeNode )
|
||||||
|
{
|
||||||
|
Object userObject = ((DefaultMutableTreeNode) last).getUserObject();
|
||||||
|
if( userObject instanceof HsNormalizacao )
|
||||||
|
{
|
||||||
|
selectedInternacional = (HsNormalizacao) userObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
treePortuguesa.clearSelection();
|
||||||
|
selectedPortuguesa = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
selectedInternacional = null;
|
||||||
|
}
|
||||||
|
refreshData();
|
||||||
|
setEnable();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
treePortuguesa.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void valueChanged( TreeSelectionEvent e )
|
||||||
|
{
|
||||||
|
TreePath selectionPath = e.getNewLeadSelectionPath();
|
||||||
|
if( selectionPath != null )
|
||||||
|
{
|
||||||
|
Object last = selectionPath.getLastPathComponent();
|
||||||
|
if( last instanceof DefaultMutableTreeNode )
|
||||||
|
{
|
||||||
|
Object userObject = ((DefaultMutableTreeNode) last).getUserObject();
|
||||||
|
if( userObject instanceof HsNormalizacao )
|
||||||
|
{
|
||||||
|
selectedPortuguesa = (HsNormalizacao) userObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
treeInternacional.clearSelection();
|
||||||
|
selectedInternacional = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
selectedPortuguesa = null;
|
||||||
|
}
|
||||||
|
refreshData();
|
||||||
|
setEnable();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
textDescricao.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void propertyChange( PropertyChangeEvent evt )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String newValue = (String) evt.getNewValue();
|
||||||
|
if( selectedInternacional != null )
|
||||||
|
{
|
||||||
|
selectedInternacional.setDescricao( newValue );
|
||||||
|
selectedInternacional.save();
|
||||||
|
}
|
||||||
|
else if( selectedPortuguesa != null )
|
||||||
|
{
|
||||||
|
selectedPortuguesa.setDescricao( newValue );
|
||||||
|
selectedPortuguesa.save();
|
||||||
|
}
|
||||||
|
reload();
|
||||||
|
} catch( Exception e )
|
||||||
|
{
|
||||||
|
LeafError.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
buttonPortuguesaCriar.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
criarPortuguesa();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
buttonPortuguesaEditar.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
editarPortuguesa();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
buttonPortuguesaRemover.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
removerPortuguesa();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
buttonInternacionalCriar.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
criarInternacional();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
buttonInternacionalEditar.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
editarInternacional();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
buttonInternacionalRemover.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
removerInternacional();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCodigoForNormalizacao( boolean criar, boolean portuguesa )
|
||||||
|
{
|
||||||
|
String result = null;
|
||||||
|
if( criar )
|
||||||
|
{
|
||||||
|
result = JOptionPane.showInputDialog( this, "C" + oacute + "digo", "Criar normaliza" + ccedil + atilde + "o" + (portuguesa ? " Portuguesa": " internacional"), JOptionPane.QUESTION_MESSAGE );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = JOptionPane.showInputDialog( this, "C" + oacute + "digo", portuguesa ? selectedPortuguesa.getCodigo() : selectedInternacional.getCodigo() );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidCodigo( String codigo )
|
||||||
|
{
|
||||||
|
boolean result = false;
|
||||||
|
if( codigo != null )
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void criarPortuguesa()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String codigo = getCodigoForNormalizacao(true,true);
|
||||||
|
if( isValidCodigo(codigo) )
|
||||||
|
{
|
||||||
|
HsNormalizacao normalizacao = new HsNormalizacao();
|
||||||
|
normalizacao.setDescricao( "" );
|
||||||
|
normalizacao.setCodigo( codigo );
|
||||||
|
normalizacao.setPortuguesa( true );
|
||||||
|
normalizacao.save();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
} catch( Exception e )
|
||||||
|
{
|
||||||
|
LeafError.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editarPortuguesa()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( selectedPortuguesa != null )
|
||||||
|
{
|
||||||
|
String codigo = getCodigoForNormalizacao(false, true);
|
||||||
|
if( isValidCodigo(codigo) )
|
||||||
|
{
|
||||||
|
selectedPortuguesa.setCodigo( codigo );
|
||||||
|
selectedPortuguesa.save();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch( Exception e )
|
||||||
|
{
|
||||||
|
LeafError.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removerPortuguesa()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( selectedPortuguesa != null )
|
||||||
|
{
|
||||||
|
selectedPortuguesa.setDeletedDate( new Date() );
|
||||||
|
selectedPortuguesa.save();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
} catch( Exception e )
|
||||||
|
{
|
||||||
|
LeafError.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void criarInternacional()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String codigo = getCodigoForNormalizacao(true, false);
|
||||||
|
if( isValidCodigo(codigo) )
|
||||||
|
{
|
||||||
|
HsNormalizacao normalizacao = new HsNormalizacao();
|
||||||
|
normalizacao.setDescricao( "" );
|
||||||
|
normalizacao.setCodigo( codigo );
|
||||||
|
normalizacao.setPortuguesa( false );
|
||||||
|
normalizacao.save();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
} catch( Exception e )
|
||||||
|
{
|
||||||
|
LeafError.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editarInternacional()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( selectedInternacional != null )
|
||||||
|
{
|
||||||
|
String codigo = getCodigoForNormalizacao(false, false);
|
||||||
|
if( isValidCodigo(codigo) )
|
||||||
|
{
|
||||||
|
selectedInternacional.setCodigo( codigo );
|
||||||
|
selectedInternacional.save();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch( Exception e )
|
||||||
|
{
|
||||||
|
LeafError.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removerInternacional()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( selectedInternacional != null )
|
||||||
|
{
|
||||||
|
selectedInternacional.setDeletedDate( new Date() );
|
||||||
|
selectedInternacional.save();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
} catch( Exception e )
|
||||||
|
{
|
||||||
|
LeafError.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void reload()
|
||||||
|
{
|
||||||
|
rootPortuguesa.removeAllChildren();
|
||||||
|
rootInternacional.removeAllChildren();
|
||||||
|
textCodigo.setText( "" );
|
||||||
|
TreeTools.merge( rootPortuguesa, HigieneSegurancaLogic.getNormalizacao( true ) );
|
||||||
|
TreeTools.merge( rootInternacional, HigieneSegurancaLogic.getNormalizacao( false ) );
|
||||||
|
TreeTools.refreshTree( treePortuguesa, rootPortuguesa );
|
||||||
|
TreeTools.refreshTree( treeInternacional, rootInternacional );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshData()
|
||||||
|
{
|
||||||
|
buttonInternacionalRemover.setEnabled( false );
|
||||||
|
buttonPortuguesaRemover.setEnabled( false );
|
||||||
|
buttonInternacionalEditar.setEnabled( false );
|
||||||
|
buttonPortuguesaEditar.setEnabled( false );
|
||||||
|
textDescricao.setEnabled( false );
|
||||||
|
if( selectedInternacional != null )
|
||||||
|
{
|
||||||
|
textDescricao.setValue( selectedInternacional.getDescricao() );
|
||||||
|
textDescricao.setEnabled( true );
|
||||||
|
textCodigo.setText( selectedInternacional.getCodigo() );
|
||||||
|
}
|
||||||
|
else if( selectedPortuguesa != null )
|
||||||
|
{
|
||||||
|
textDescricao.setValue( selectedPortuguesa.getDescricao() );
|
||||||
|
textDescricao.setEnabled( true );
|
||||||
|
textCodigo.setText( selectedPortuguesa.getCodigo() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textDescricao.setValue( null );
|
||||||
|
textCodigo.setText( "" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEnable()
|
||||||
|
{
|
||||||
|
buttonPortuguesaEditar.setEnabled( selectedPortuguesa != null );
|
||||||
|
buttonPortuguesaRemover.setEnabled( selectedPortuguesa != null );
|
||||||
|
buttonInternacionalEditar.setEnabled( selectedInternacional != null );
|
||||||
|
buttonInternacionalRemover.setEnabled( selectedInternacional != null );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package siprp.update.updates;
|
||||||
|
|
||||||
|
import com.evolute.utils.Singleton;
|
||||||
|
import com.evolute.utils.db.DBManager;
|
||||||
|
import com.evolute.utils.db.Executer;
|
||||||
|
|
||||||
|
public class V10_0_To_V10_1
|
||||||
|
implements siprp.update.Update
|
||||||
|
{
|
||||||
|
|
||||||
|
public V10_0_To_V10_1()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String []listChanges()
|
||||||
|
{
|
||||||
|
return new String[]{
|
||||||
|
"adicionadas normalizacoes para estabelecimentos e empresas"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getStartVersion()
|
||||||
|
{
|
||||||
|
return 10.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getEndVersion()
|
||||||
|
{
|
||||||
|
return 10.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
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_normalizacao_empresa " +
|
||||||
|
"( " +
|
||||||
|
" normalizacao_id int4 REFERENCES hs_normalizacao(id), " +
|
||||||
|
" empresa_id int4 REFERENCES empresas(id), " +
|
||||||
|
" CONSTRAINT hs_normalizacao_empresa_pkey PRIMARY KEY(normalizacao_id,empresa_id) " +
|
||||||
|
"); " +
|
||||||
|
"CREATE TABLE hs_normalizacao_estabelecimento " +
|
||||||
|
"( " +
|
||||||
|
" normalizacao_id int4 REFERENCES hs_normalizacao(id), " +
|
||||||
|
" estabelecimento_id int4 REFERENCES estabelecimentos(id), " +
|
||||||
|
" CONSTRAINT hs_normalizacao_estabelecimento_pkey PRIMARY KEY(normalizacao_id,estabelecimento_id) " +
|
||||||
|
");"
|
||||||
|
);
|
||||||
|
executer.executeQuery( update );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "v" + getStartVersion() + " para v" + getEndVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package siprp.database.cayenne.objects;
|
||||||
|
|
||||||
|
import siprp.database.cayenne.objects.auto._HsNormalizacaoEmpresa;
|
||||||
|
|
||||||
|
public class HsNormalizacaoEmpresa extends _HsNormalizacaoEmpresa {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package siprp.database.cayenne.objects;
|
||||||
|
|
||||||
|
import siprp.database.cayenne.objects.auto._HsNormalizacaoEstabelecimento;
|
||||||
|
|
||||||
|
public class HsNormalizacaoEstabelecimento extends _HsNormalizacaoEstabelecimento {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package siprp.database.cayenne.objects.auto;
|
||||||
|
|
||||||
|
import siprp.database.cayenne.objects.BaseObject;
|
||||||
|
import siprp.database.cayenne.objects.Empresas;
|
||||||
|
import siprp.database.cayenne.objects.HsNormalizacao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class _HsNormalizacaoEmpresa 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 _HsNormalizacaoEmpresa extends BaseObject {
|
||||||
|
|
||||||
|
public static final String TO_EMPRESA_PROPERTY = "toEmpresa";
|
||||||
|
public static final String TO_HS_NORMALIZACAO_PROPERTY = "toHsNormalizacao";
|
||||||
|
|
||||||
|
public static final String EMPRESA_ID_PK_COLUMN = "empresa_id";
|
||||||
|
public static final String NORMALIZACAO_ID_PK_COLUMN = "normalizacao_id";
|
||||||
|
|
||||||
|
public void setToEmpresa(Empresas toEmpresa) {
|
||||||
|
setToOneTarget("toEmpresa", toEmpresa, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Empresas getToEmpresa() {
|
||||||
|
return (Empresas)readProperty("toEmpresa");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setToHsNormalizacao(HsNormalizacao toHsNormalizacao) {
|
||||||
|
setToOneTarget("toHsNormalizacao", toHsNormalizacao, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HsNormalizacao getToHsNormalizacao() {
|
||||||
|
return (HsNormalizacao)readProperty("toHsNormalizacao");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package siprp.database.cayenne.objects.auto;
|
||||||
|
|
||||||
|
import siprp.database.cayenne.objects.BaseObject;
|
||||||
|
import siprp.database.cayenne.objects.Estabelecimentos;
|
||||||
|
import siprp.database.cayenne.objects.HsNormalizacao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class _HsNormalizacaoEstabelecimento 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 _HsNormalizacaoEstabelecimento extends BaseObject {
|
||||||
|
|
||||||
|
public static final String TO_ESTABELECIMENTO_PROPERTY = "toEstabelecimento";
|
||||||
|
public static final String TO_HS_NORMALIZACAO_PROPERTY = "toHsNormalizacao";
|
||||||
|
|
||||||
|
public static final String ESTABELECIMENTO_ID_PK_COLUMN = "estabelecimento_id";
|
||||||
|
public static final String NORMALIZACAO_ID_PK_COLUMN = "normalizacao_id";
|
||||||
|
|
||||||
|
public void setToEstabelecimento(Estabelecimentos toEstabelecimento) {
|
||||||
|
setToOneTarget("toEstabelecimento", toEstabelecimento, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Estabelecimentos getToEstabelecimento() {
|
||||||
|
return (Estabelecimentos)readProperty("toEstabelecimento");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setToHsNormalizacao(HsNormalizacao toHsNormalizacao) {
|
||||||
|
setToOneTarget("toHsNormalizacao", toHsNormalizacao, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HsNormalizacao getToHsNormalizacao() {
|
||||||
|
return (HsNormalizacao)readProperty("toHsNormalizacao");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue