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

lxbfYeaa
Frederico Palma 17 years ago
parent cbb96c10d5
commit 130fe48971

@ -5,16 +5,20 @@ import java.util.Vector;
import org.jdom.Element; import org.jdom.Element;
public class AreaToPrint public class AreaToPrint
implements PrintableInterface implements PrintableInterface, Comparable
{ {
protected String designacao; protected String designacao;
protected Vector<PostoToPrint> postos; 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(); super();
this.designacao = designacao; this.designacao = designacao;
this.postos = postos; this.postos = postos;
this.ordem = ordem;
this.temGenerico = temGenerico;
} }
@Override @Override
@ -31,4 +35,25 @@ public class AreaToPrint
return areaElement; 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 String designacao;
protected Vector<RiscoToPrint> riscos; 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.designacao = designacao;
this.riscos = riscos; this.riscos = riscos;
this.generico = generico;
} }
@Override @Override
@ -31,4 +33,9 @@ public class PostoToPrint
} }
return postoElement; return postoElement;
} }
public boolean isGenerico()
{
return generico;
}
} }

@ -344,7 +344,7 @@ public class RelatorioPrintDataProvider
new String[]{ "hs_relatorio_area" }, new String[]{ "hs_relatorio_area" },
new Integer[]{}, new Integer[]{},
new Expression[]{}, new Expression[]{},
new String[]{ "id", "description" }, new String[]{ "id", "description", "ordem" },
new Field( "relatorio_id" ).isEqual( relatorioId ).and( new Field( "relatorio_id" ).isEqual( relatorioId ).and(
new Field( "deleted_date" ).isEqual( null ) ), new Field( "deleted_date" ).isEqual( null ) ),
new String[]{ "id" }, new String[]{ "id" },
@ -357,12 +357,19 @@ public class RelatorioPrintDataProvider
{ {
Integer areaId = ( Integer ) array.get( n, 0 ); Integer areaId = ( Integer ) array.get( n, 0 );
String areaDescricao = ( String ) array.get( n, 1 ); String areaDescricao = ( String ) array.get( n, 1 );
Integer ordem = ( Integer ) array.get( n, 2 );
Vector<PostoToPrint> postos = getPostosToPrintByAreaId( areaId ); Vector<PostoToPrint> postos = getPostosToPrintByAreaId( areaId );
if( postos.size() > 0 ) 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; return areas;
} }
@ -387,7 +394,8 @@ public class RelatorioPrintDataProvider
{ {
Integer id = ( Integer ) array.get( n, 0 ); Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 ); 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; return postos;
} }

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

Loading…
Cancel
Save