Actualizado esquema de base de dados

Corrigidos erros de implementacao

git-svn-id: https://svn.coded.pt/svn/SIPRP@685 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 18 years ago
parent dfd78af525
commit 50b194db4f

@ -406,6 +406,8 @@
</db-entity>
<db-entity name="trabalhadores_ecd" schema="public">
<db-attribute name="analisador_id" type="INTEGER" length="10"/>
<db-attribute name="data_envio" type="DATE" length="13"/>
<db-attribute name="data_recepcao" type="DATE" length="13"/>
<db-attribute name="ecd_id" type="INTEGER" length="10"/>
<db-attribute name="ecd_oficial_id" type="INTEGER" length="10"/>
<db-attribute name="enviado" type="CHAR" length="1"/>
@ -777,6 +779,8 @@
<obj-attribute name="observacao" type="java.lang.String" db-attribute-path="observacao"/>
</obj-entity>
<obj-entity name="TrabalhadoresEcd" className="siprp.database.cayenne.objects.TrabalhadoresEcd" lock-type="optimistic" dbEntityName="trabalhadores_ecd" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="dataEnvio" type="java.util.Date" db-attribute-path="data_envio"/>
<obj-attribute name="dataRecepcao" type="java.util.Date" db-attribute-path="data_recepcao"/>
<obj-attribute name="enviado" type="java.lang.Character" db-attribute-path="enviado"/>
<obj-attribute name="estado" type="java.lang.Integer" db-attribute-path="estado"/>
</obj-entity>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<driver project-version="3.0" class="org.postgresql.Driver">
<url value="jdbc:postgresql://localhost:5432/siprp_local"/>
<url value="jdbc:postgresql://storage:5432/siprp_local"/>
<connectionPool min="1" max="1"/>
<login userName="postgres" password="Typein" encoderClass="org.apache.cayenne.conf.PlainTextPasswordEncoder" passwordLocation="model" passwordSource="Not Applicable"/>
</driver>

@ -34,7 +34,6 @@ import javax.swing.SwingUtilities;
public class LeafInputField<ObjClass extends Object> extends JPanel implements FocusListener, MouseListener, PropertyChangeListener
{
private static final Dimension SIZE = new Dimension( 0, 20 );
public static final String PROPERTY_CHANGED_CONSTANT = "LEAF_INPUT_PROPERTY_CHANGED";
public static final String PROPERTY_CHANGED_CLICK = "LEAF_PROPERTY_CHANGED_CLICK";
@ -45,6 +44,8 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
private static final int defaultColorDec = 20;
private int colorDec = defaultColorDec;
public Dimension size = null;
private Color hot = null;
private Color cold = null;
@ -544,6 +545,7 @@ public class LeafInputField<ObjClass extends Object> extends JPanel implements F
repaint();
}
} );
size = thiz.getPreferredSize();
thiz.setOpaque( false );
}
}

@ -23,13 +23,15 @@ import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.ScrollPaneConstants;
import com.evolute.utils.tables.models.SortableModel;
public class LeafOptionDialog<KeyClass extends Object> extends JDialog
{
private static final Dimension OPTION_SIZE = new Dimension( 200, 20 );
private static final Dimension BUTTON_SIZE = new Dimension( 200, 20 );
private Dimension OPTION_SIZE = new Dimension( 200, 20 );
private Dimension BUTTON_SIZE = new Dimension( 200, 20 );
private static final int MAX_VISIBLE_OPTIONS = 5;
private int MAX_VISIBLE_OPTIONS = 20;
private static final long serialVersionUID = 1L;
@ -157,11 +159,13 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
}
((JComponent) getContentPane()).setBorder( BorderFactory.createRaisedBevelBorder() );
setSize( layout.preferredLayoutSize( this.getContentPane() ) );
// setSize( optionsScrollPane.getPreferredSize().width, getSize().height );
setLocationRelativeTo( getParent() );
}
private void setupOptionsComponents( Iterator<KeyClass> iterator, Integer size )
{
int maxWidth = OPTION_SIZE.width;
double[] cols = new double[] {
TableLayout.PREFERRED
};
@ -196,7 +200,10 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
Boolean isEnabled = mapEnabledForKey.get( current );
component.setClickable( isEnabled == null || isEnabled );
component.setPreferredSize( OPTION_SIZE );
if(component.size != null && component.size.width > maxWidth )
{
maxWidth = component.size.width;
}
optionsPanel.add( component, new TableLayoutConstraints( 0, i ) );
addListenerToComponent( component );
}
@ -207,7 +214,7 @@ public class LeafOptionDialog<KeyClass extends Object> extends JDialog
verticalScrollBar.setUnitIncrement( (int) OPTION_SIZE.getHeight() + 3 );
optionsScrollPane.setVerticalScrollBar( verticalScrollBar );
optionsScrollPane.setVerticalScrollBarPolicy( size > MAX_VISIBLE_OPTIONS ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS : ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER );
optionsScrollPane.setPreferredSize( new Dimension((int) OPTION_SIZE.getWidth() + 10 , size > MAX_VISIBLE_OPTIONS ? (MAX_VISIBLE_OPTIONS * ((int) (OPTION_SIZE.getHeight() + 3 )) ) : (size * ((int) (OPTION_SIZE.getHeight() + 3 )) ) ));
optionsScrollPane.setPreferredSize( new Dimension( maxWidth + 30 , size > MAX_VISIBLE_OPTIONS ? (MAX_VISIBLE_OPTIONS * ((int) (OPTION_SIZE.getHeight() + 3 )) ) : (size * ((int) (OPTION_SIZE.getHeight() + 3 )) ) ));
}
private KeyClass getKeyForValue( Object value )

@ -8,6 +8,7 @@ import siprp.database.cayenne.objects.TrabalhadoresEcd;
import com.evolute.utils.tables.BaseTableModel;
import com.evolute.utils.tables.models.SortableModel;
public class LeafTableModel extends BaseTableModel
{
@ -76,7 +77,16 @@ public class LeafTableModel extends BaseTableModel
this.map = (OrderedMap<Object>) map;
fireTableDataChanged();
}
public void order(int ... colNumber )
{
if(colNumber != null)
{
map.order(colNumber);
fireTableDataChanged();
}
}
@Override
public void appendEmptyRow()
{

@ -23,7 +23,7 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
public OrderedMap(Collection<KeyClass> allPrestadores)
{
Iterator<KeyClass> iterator = allPrestadores.iterator();
while(iterator.hasNext())
while( iterator.hasNext() )
{
KeyClass value = iterator.next();
this.putLast( value, value );
@ -69,7 +69,7 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
}
/**
* returns the length of the biggest column
* returns the length of the biggest line
*
* @return
*/
@ -124,25 +124,26 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
Object result = null;
if( row < order.size() )
{
List<Object> line = map.get( order.get( row ));
if( column < line.size())
List<Object> line = map.get( order.get( row ) );
if( column < line.size() )
{
result = line.get( column );
}
}
return result;
}
/**
* Adds arguments to the end of the row (on given order)
*
* @param key
* @param values
*/
public void putLast( KeyClass key, Object ... values)
public void putLast( KeyClass key, Object... values )
{
if( values != null)
if( values != null )
{
for( Object currentValue: values )
for( Object currentValue : values )
{
putLast( key, currentValue );
}
@ -151,6 +152,7 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
/**
* Adds argument to the end of the row
*
* @param key
* @param value
*/
@ -181,30 +183,92 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
*/
public void order()
{
if( order != null && order.size() > 0 )
order( 0 );
}
public void order( int columnNumber )
{
order( new int[] {
columnNumber
}, 0, 0, order.size() - 1, order );
}
public void order( int[] colNumbers )
{
order( colNumbers, 0, 0, order.size() - 1, order );
}
private void order( int[] colNumbers, int currentColumnIndex, int fromLineNumber, int toLineNumber, List<KeyClass> order )
{
if( colNumbers != null && currentColumnIndex >= 0 && fromLineNumber < toLineNumber && toLineNumber < order.size() && currentColumnIndex < colNumbers.length )
{
HashMap<Object, KeyClass> keyForObject = new HashMap<Object, KeyClass>();
List<String> sortedList = new ArrayList<String>();
for( KeyClass key : order )
int columnNumber = colNumbers[currentColumnIndex];
if( order != null && order.size() > 0 )
{
List<Object> row = map.get( key );
Object value = null;
if( row != null && row.size() > 0 )
List<Pair<String, KeyClass>> sortedList = new ArrayList<Pair<String, KeyClass>>();
for( int i = fromLineNumber; i < order.size() && i < (toLineNumber + 1); ++i )
{
value = row.get( 0 );
keyForObject.put( value.toString(), key );
sortedList.add( value.toString() );
KeyClass key = order.get( i );
List<Object> row = map.get( key );
String value = "";
if( row != null && row.size() > columnNumber && row.get( columnNumber ) != null )
{
value = row.get( columnNumber ).toString();
}
sortedList.add( new Pair<String, KeyClass>( value, key ) );
}
}
if( sortedList.size() == order.size() )
{
Collections.sort( sortedList );
Vector<KeyClass> newOrder = new Vector<KeyClass>();
for( String value : sortedList )
List<Pair<String, KeyClass>> equalEntries = new ArrayList<Pair<String, KeyClass>>();
for( int i = 0; i < sortedList.size(); ++i )
{
Pair<String, KeyClass> entry = sortedList.get( i );
if( equalEntries.isEmpty() && i < (sortedList.size() - 1) )
{
equalEntries.add( entry );
}
else
{
Pair<String, KeyClass> previousEntry = equalEntries.get( 0 );
if( previousEntry.getCar().equals( entry.getCar() ) )
{
if( i < (sortedList.size() - 1) )
{
equalEntries.add( entry );
continue;
}
else
{
equalEntries.add( entry );
++i;
}
}
if( equalEntries.size() > 1 )
{
List<KeyClass> toSubOrder = new Vector<KeyClass>();
List<String> DEBUGLIST = new Vector<String>();
for( Pair<String, KeyClass> pair : equalEntries )
{
toSubOrder.add( pair.getCdr() );
DEBUGLIST.add( pair.getCar() );
}
order( colNumbers, currentColumnIndex + 1, 0, toSubOrder.size() - 1, toSubOrder );
for( int j = 0; j < toSubOrder.size(); ++j )
{
sortedList.set( i - toSubOrder.size() + j, new Pair<String, KeyClass>( "", toSubOrder.get( j ) ) );
}
}
equalEntries.clear();
if( i < (sortedList.size() - 1) )
{
equalEntries.add( entry );
}
}
}
for( int i = 0; i < sortedList.size(); ++i )
{
newOrder.add( keyForObject.get( value ) );
Pair<String, KeyClass> value = sortedList.get( i );
order.set( i, value.getCdr() );
}
order = newOrder;
}
}
}
@ -264,10 +328,10 @@ public class OrderedMap<KeyClass extends Object> implements Iterable<KeyClass>
public Object getValue( KeyClass key, int i )
{
Object result = null;
if(key != null && order.contains( key))
if( key != null && order.contains( key ) )
{
List<Object> row = map.get( key );
if(row != null && row.size() > i)
if( row != null && row.size() > i )
{
result = row.get( i );
}

@ -0,0 +1,48 @@
package leaf;
public class Pair<CarClass extends Comparable<CarClass>, CdrClass> implements Comparable<Pair<CarClass, CdrClass>>
{
private final CarClass car;
private final CdrClass cdr;
public Pair(CarClass car, CdrClass cdr)
{
this.car = car;
this.cdr = cdr;
}
public CarClass getCar()
{
return car;
}
public CdrClass getCdr()
{
return cdr;
}
@Override
public int compareTo( Pair<CarClass, CdrClass> toPair )
{
if(toPair == null)
{
return 1;
}
else if(car == null && toPair.getCar() == null)
{
return 0;
}
else
{
return getCar().compareTo( toPair.getCar() );
}
}
@Override
public String toString()
{
return "(" + (car == null ? "" : car.toString()) + ", "+ (cdr == null ? "" : cdr.toString()) + ")";
}
}

@ -7,6 +7,8 @@ package siprp.database.cayenne.objects.auto;
*/
public abstract class _TrabalhadoresEcd extends siprp.database.cayenne.objects.BaseObject {
public static final String DATA_ENVIO_PROPERTY = "dataEnvio";
public static final String DATA_RECEPCAO_PROPERTY = "dataRecepcao";
public static final String ENVIADO_PROPERTY = "enviado";
public static final String ESTADO_PROPERTY = "estado";
public static final String TO_ANALISADOR_PROPERTY = "toAnalisador";
@ -16,6 +18,22 @@ public abstract class _TrabalhadoresEcd extends siprp.database.cayenne.objects.B
public static final String ID_PK_COLUMN = "id";
public void setDataEnvio(java.util.Date dataEnvio) {
writeProperty("dataEnvio", dataEnvio);
}
public java.util.Date getDataEnvio() {
return (java.util.Date)readProperty("dataEnvio");
}
public void setDataRecepcao(java.util.Date dataRecepcao) {
writeProperty("dataRecepcao", dataRecepcao);
}
public java.util.Date getDataRecepcao() {
return (java.util.Date)readProperty("dataRecepcao");
}
public void setEnviado(Character enviado) {
writeProperty("enviado", enviado);
}

@ -91,17 +91,14 @@ public class MedicinaDAO extends MainDAO implements MedicinaConstants
public Collection<TrabalhadoresEcd> getPendingExamesForAnalisador( Prestadores currentAnalisador )
{
Map<TrabalhadoresEcd, TrabalhadoresEcd> resultMap = new HashMap<TrabalhadoresEcd, TrabalhadoresEcd>();
SelectQuery query = new SelectQuery( TrabalhadoresEcdsDatas.class, /*ExpressionFactory.noMatchExp( TrabalhadoresEcdsDatas.DATA_ENVIO_PROPERTY, null ).andExp(*/ ExpressionFactory.matchExp(TrabalhadoresEcdsDatas.DATA_RECEPCAO_PROPERTY, null )/*)*/);
List<TrabalhadoresEcdsDatas> all = context.performQuery( query );
for( TrabalhadoresEcdsDatas data : all )
{
SelectQuery query = new SelectQuery( TrabalhadoresEcd.class, ExpressionFactory.matchExp(TrabalhadoresEcd.DATA_RECEPCAO_PROPERTY, null ));
List<TrabalhadoresEcd> all = context.performQuery( query );
for( TrabalhadoresEcd ecd : all )
{
TrabalhadoresEcdsDatas data = ecd.getToTrabalhadoresEcdsDatas();
if(new Integer(MedicinaConstants.ESTADO_REALIZADO).equals( data.getEstado()))
{
List<TrabalhadoresEcd> ecds = data.getTrabalhadoresEcdArray();
if( ecds != null )
{
for(TrabalhadoresEcd ecd : ecds)
{
if(currentAnalisador.equals( ecd.getToAnalisador() ))
{
resultMap.put( ecd ,ecd );
@ -109,8 +106,6 @@ public class MedicinaDAO extends MainDAO implements MedicinaConstants
{
resultMap.put( ecd, ecd );
}
}
}
}
}
return resultMap.values();

@ -257,6 +257,7 @@ public class TrabalhadorPanel extends JPanel
components.putDummy( TrabalhadorData.PERFIL );
components.putDummy( TrabalhadorData.ESTABELECIMENTO );
components.putDummy( TrabalhadorData.NOME_PLAIN );
components.putDummy( TrabalhadorData.BI );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.NOME, nomeText );
// components.putComponent( FichaDataProvider.T_TRABALHADORES + "." + FichaDataProvider.DATA_NASCIMENTO, dataNascimentoPanel );
@ -319,6 +320,9 @@ public class TrabalhadorPanel extends JPanel
{
trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID );
String names[] = trabalhador.getFieldNames();
System.out.println(names.length);
System.out.println(trabalhador.getHashData().size());
System.out.println(components.size());
ComponentController.fill( names, trabalhador.getHashData(), components );
// trabalhador = provider.load( FichaDataProvider.TRABALHADORES, new DBKey( trabalhadorID ) );
// DBField fields[] = FichaDataProvider.TRABALHADORES.getInsertFields();

@ -149,6 +149,7 @@ public class RecepcaoExamesWindow extends LeafWindow
}
orderedMap.putLast( current, empresa, estabelecimento, trabalhador, current);
}
orderedMap.order( new int[]{ 0, 1, 2 } );
examesModel.setValues( orderedMap );
}
}
@ -168,12 +169,12 @@ public class RecepcaoExamesWindow extends LeafWindow
{
for( int i = 0; i < selectedRows.length; ++i)
{
Object ecd = examesModel.getKey( i );
Object ecd = examesModel.getKey( selectedRows[i] );
if(ecd != null)
{
if( ecd instanceof TrabalhadoresEcd)
{
((TrabalhadoresEcd) ecd ).getToTrabalhadoresEcdsDatas().setDataRecepcao( fieldData.getObject() );
((TrabalhadoresEcd) ecd ).setDataRecepcao( fieldData.getObject() );
result.add( (TrabalhadoresEcd) ecd );
}
}

@ -99,7 +99,7 @@ public class ProcessoAccoesPanel extends JPanel
public final LeafButton buttonFecharProcesso = new LeafButton( "Fechar Processo" );
@ActionActivation(onSelect = CREATE_FICHA, onChange = "")
public final LeafButton buttonCriarFicha = new LeafButton( "Editar Ficha" );
public final LeafButton buttonCriarFicha = new LeafButton( "Ficha de Aptid"+atilde+"o" );
@ActionActivation(onSelect = {
CREATE_CONSULTA, CREATE_CONSULTA_MARCACAO

@ -571,7 +571,7 @@ public class ProcessoDadosPanel extends JPanel
TrabalhadoresConsultas consulta = consultaMarcacao.getToTrabalhadoresConsultas();
if( consulta != null )
{
String[] subjectAndBody = sendMail(consulta.getToTrabalhadores(), consultaMarcacao.getData(), SingletonConstants.LETTER_CONSULTA );
String[] subjectAndBody = sendMail(consulta.getToTrabalhadores(), consultaMarcacao.getDataString(), SingletonConstants.LETTER_CONSULTA, SingletonConstants.SUBJECT_CONSULTA );
if( subjectAndBody != null )
{
email.setSubject( subjectAndBody[0] );
@ -586,7 +586,7 @@ public class ProcessoDadosPanel extends JPanel
}
}
private String[] sendMail(Trabalhadores trabalhador, Date dataConsulta, String letter )
private String[] sendMail(Trabalhadores trabalhador, String data, String letterName, String subjectName )
{
String [] result = null;
if( trabalhador != null )
@ -599,25 +599,21 @@ public class ProcessoDadosPanel extends JPanel
String subject = "";
String body = "";
String sedeNome = estabelecimento.getNome();
subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_VISITA );
subject = ( String ) Singleton.getInstance( subject );
if( subject == null)
{
subject = "";
}
subject = subject.replaceAll( CompanyDataLoader.NOME, sedeNome );
subject = subject.replaceAll( CompanyDataLoader.NOME, estabelecimento.getNome() );
String morada = estabelecimento.getMorada();
String data = DateFormat.getDateInstance( DateFormat.SHORT ).format( dataConsulta );
body = ( String ) Singleton.getInstance( letter );
body = ( String ) Singleton.getInstance( letterName );
if( body == null)
{
body = "";
}
body = body.replaceAll( CompanyDataLoader.DATA, data );
body = body.replaceAll( CompanyDataLoader.NOME, sedeNome );
body = body.replaceAll( CompanyDataLoader.MORADA, morada );
body = body.replaceAll( CompanyDataLoader.NOME, trabalhador.getNome() );
// body = body.replaceAll( CompanyDataLoader.MORADA, morada );
body = body.replaceAll( "%0A", "<br>" );
Contactos estabelecimentoContacto = estabelecimento.getToContactos();
@ -702,7 +698,7 @@ public class ProcessoDadosPanel extends JPanel
TrabalhadoresEcds exame = exameMarcacao.getToTrabalhadoresEcds();
if( exame != null )
{
String[] subjectAndBody = sendMail(exame.getToTrabalhadores(), exameMarcacao.getData(), SingletonConstants.LETTER_EXAMES );
String[] subjectAndBody = sendMail(exame.getToTrabalhadores(), exameMarcacao.getDataString(), SingletonConstants.LETTER_EXAMES, SingletonConstants.SUBJECT_EXAMES );
if( subjectAndBody != null )
{
email.setSubject( subjectAndBody[0] );

@ -300,9 +300,31 @@ public class ProcessoTreePanel extends JPanel
{
addNodeTo( loadExame( current ), node );
}
List<TrabalhadoresFichasAptidao> fichas = processo.getTrabalhadoresFichasAptidaoArray();
if( fichas != null )
{
TrabalhadoresFichasAptidao ficha = null;
for( TrabalhadoresFichasAptidao currentFicha : fichas )
{
if( ficha == null && ficha.getId() < currentFicha.getId() )
{
ficha = currentFicha;
}
}
if( ficha != null )
{
// addNodeTo( loadFicha( ficha ), node);
}
}
return node;
}
private FichaAptidaoMutableTreeNode loadFicha(TrabalhadoresFichasAptidao ficha)
{
return null;
}
private ECDsMutableTreeNode loadExame( TrabalhadoresEcds exame )
{

@ -31,7 +31,7 @@ public class UpdateList
new siprp.update.updates.V7_9_To_V8_0(), new siprp.update.updates.V8_0_To_V8_1(),
new siprp.update.updates.V8_1_To_V8_2(), new siprp.update.updates.V8_2_To_V8_3(),
new siprp.update.updates.V8_3_To_V8_4(), new siprp.update.updates.V8_4_To_V8_5(),
new siprp.update.updates.V8_5_To_V8_6() };
new siprp.update.updates.V8_5_To_V8_6(), new siprp.update.updates.V8_6_To_V8_7() };
protected static Executer EXECUTER;
protected static double version = -1;

@ -0,0 +1,66 @@
/*
* V8_1_To_V8_2.java
*
* Created on December 19, 2007, 3:12 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.update.updates;
import com.evolute.utils.Singleton;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Delete;
/**
*
* @author fpalma
*/
public class V8_6_To_V8_7
implements siprp.update.Update
{
/**
* Creates a new instance of V8_6_To_V8_7
*/
public V8_6_To_V8_7()
{
}
public String []listChanges()
{
return new String[]{ "Adicionados campos data_envio e data_recepcao a cada instancia de ECD" };
}
public double getStartVersion()
{
return 8.6;
}
public double getEndVersion()
{
return 8.7;
}
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 trabalhadores_ecd ADD data_envio DATE;" );
executer.executeQuery( update );
update =
new com.evolute.utils.sql.Update(
"ALTER TABLE trabalhadores_ecd ADD data_recepcao DATE;" );
executer.executeQuery( update );
}
public String toString()
{
return "v" + getStartVersion() + " para v" + getEndVersion();
}
}
Loading…
Cancel
Save