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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 17 years ago
parent cbb96c10d5
commit 130fe48971

@ -5,16 +5,20 @@ import java.util.Vector;
import org.jdom.Element;
public class AreaToPrint
implements PrintableInterface
implements PrintableInterface, Comparable
{
protected String designacao;
protected Vector<PostoToPrint> postos;
protected Integer ordem;
protected boolean temGenerico;
public AreaToPrint( String designacao, Vector<PostoToPrint> postos )
public AreaToPrint( String designacao, Vector<PostoToPrint> postos, Integer ordem, boolean temGenerico )
{
super();
this.designacao = designacao;
this.postos = postos;
this.ordem = ordem;
this.temGenerico = temGenerico;
}
@Override
@ -31,4 +35,25 @@ public class AreaToPrint
return areaElement;
}
@Override
public int compareTo(Object o)
{
if( o instanceof AreaToPrint )
{
if( temGenerico && !( ( AreaToPrint ) o ).temGenerico )
{
return -1;
}
else if( !temGenerico && ( ( AreaToPrint ) o ).temGenerico )
{
return 1;
}
}
if( ordem != null )
{
return ordem.compareTo( ( ( AreaToPrint ) o ).ordem );
}
return 0;
}
}

@ -10,11 +10,13 @@ public class PostoToPrint
{
protected String designacao;
protected Vector<RiscoToPrint> riscos;
protected boolean generico;
public PostoToPrint( String designacao, Vector<RiscoToPrint> riscos )
public PostoToPrint( String designacao, Vector<RiscoToPrint> riscos, boolean generico )
{
this.designacao = designacao;
this.riscos = riscos;
this.generico = generico;
}
@Override
@ -31,4 +33,9 @@ public class PostoToPrint
}
return postoElement;
}
public boolean isGenerico()
{
return generico;
}
}

@ -344,7 +344,7 @@ public class RelatorioPrintDataProvider
new String[]{ "hs_relatorio_area" },
new Integer[]{},
new Expression[]{},
new String[]{ "id", "description" },
new String[]{ "id", "description", "ordem" },
new Field( "relatorio_id" ).isEqual( relatorioId ).and(
new Field( "deleted_date" ).isEqual( null ) ),
new String[]{ "id" },
@ -357,12 +357,19 @@ public class RelatorioPrintDataProvider
{
Integer areaId = ( Integer ) array.get( n, 0 );
String areaDescricao = ( String ) array.get( n, 1 );
Integer ordem = ( Integer ) array.get( n, 2 );
Vector<PostoToPrint> postos = getPostosToPrintByAreaId( areaId );
if( postos.size() > 0 )
{
areas.add( new AreaToPrint( areaDescricao, postos ) );
boolean generico = false;
for( PostoToPrint posto : postos )
{
generico |= posto.isGenerico();
}
areas.add( new AreaToPrint( areaDescricao, postos, ordem, generico ) );
}
}
Collections.sort( areas );
return areas;
}
@ -387,7 +394,8 @@ public class RelatorioPrintDataProvider
{
Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 );
postos.add( new PostoToPrint( descricao, getRiscosToPrintByPostoId( id ) ) );
Boolean generico = ( Boolean ) array.get( n, 2 );
postos.add( new PostoToPrint( descricao, getRiscosToPrintByPostoId( id ), generico ) );
}
return postos;
}

@ -31,12 +31,18 @@ public class RiscoToPrint
Element descricaoElement = new Element( "descricao" );
descricaoElement.setText( descricao );
riscoElement.addContent( descricaoElement );
Element severidadeElement = new Element( "severidade" );
severidadeElement.setText( severidade != null ? severidade.toString() : " " );
riscoElement.addContent( severidadeElement );
Element probabilidadeElement = new Element( "probabilidade" );
probabilidadeElement.setText( probabilidade != null ? probabilidade.toString() : " " );
riscoElement.addContent( probabilidadeElement );
if( severidade != null )
{
Element severidadeElement = new Element( "severidade" );
severidadeElement.setText( severidade != null ? severidade.toString() : " " );
riscoElement.addContent( severidadeElement );
}
if( probabilidade != null )
{
Element probabilidadeElement = new Element( "probabilidade" );
probabilidadeElement.setText( probabilidade != null ? probabilidade.toString() : " " );
riscoElement.addContent( probabilidadeElement );
}
Element valorElement = new Element( "valor-numerico" );
valorElement.setText( ( severidade != null && probabilidade != null ) ? "" + ( severidade * probabilidade ) : " " );
riscoElement.addContent( valorElement );

Loading…
Cancel
Save