* @return List
*/
public List getSegmentoItemArtigosPorEditoria(ServletContext application,UsuarioUsu usuario,String codSatb){
List lista = new ArrayList();
try{
Mensagem properties = new Mensagem(application);
Date dataAtual = Data.getDataAtual();
SegmentoItemSgti segItemSuper = getSegmentoItemSuperDestaque(application);
List editorias = new ArrayList();
List atributos = new ArrayList();
String aspas = "";
if (segItemSuper.getSegmentoSisAtribSgtsas() != null && segItemSuper.getSegmentoSisAtribSgtsas().size() > 0)
atributos.addAll(segItemSuper.getSegmentoSisAtribSgtsas());
Iterator it = atributos.iterator();
while(it.hasNext()){
SisAtributoSatb atb = (SisAtributoSatb) it.next();
aspas = "'" + atb.getCodSatb() + "'";
editorias.add(aspas);
}
String todos = null;
String teste = null;
try {
todos = Pagina.getParamStr(request, "todos");
teste = Pagina.getParamStr(request, "codSatb");
}
catch(NullPointerException ne){
this.logger.error(ne);
}
StringBuilder select = new StringBuilder("select i from SegmentoItemSgti i where i.indAtivoSgti = 'S' ")
.append(" and ( i.dataIniValidadeSgti <= :dataAtual")
.append(" and i.dataFimValidadeSgti >= :dataAtual )")
.append(" and i.segmentoSgt.codSgt = :codSgt ")
.append(" and i.codSgti in (").append("select s.comp_id.codSgti from SegmentoSisAtribSgtsa s ")
.append("where s.comp_id.codSatb = :codSatb)")
.append(" and ((i.indUtilizTpAcessoSgti = 'N') or ")
.append("(i.indUtilizTpAcessoSgti = 'S' and i.codSgti in (")
.append("select b.comp_id.codSgti from SegmentoItemTpAcesSgtITA b ")
.append("where b.comp_id.codSatb in (").append("select a.comp_id.codSatb from UsuarioAtributoUsua a ")
.append("where a.comp_id.codUsu = :codUsu))))");
//if ((segItemSuper != null)&&(todos == null)){
// select = select + " and i.codSgti != :codSgti";
// select = select + " and i.indSuperDestaqueSgti = 'S' ";
//}
//if (todos == ""){
// select = select + " and ((i.indDestaqueSgti = 'S') or (i.indDestaqueSgti = 'N' and i.indSuperDestaqueSgti = 'S')) ";
//}
StringBuilder order = new StringBuilder(" order by i.dataItemSgti desc");
Query query = this.getSession().createQuery(select.toString() + order);
query.setLong("codSgt", Long.valueOf(properties.getMensagem("admPortal.materias")).longValue());
query.setDate("dataAtual", dataAtual);
query.setLong("codUsu", usuario.getCodUsu().longValue());
query.setLong("codSatb",Long.parseLong(codSatb));