Professional Documents
Culture Documents
csv;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import ch.vd.sieeo.neo.domain.Ecr;
import ch.vd.sieeo.neo.domain.EcrObjectif;
import ch.vd.sieeo.neo.domain.Eleve;
import ch.vd.sieeo.neo.domain.EleveObjectif;
import ch.vd.sieeo.neo.domain.Evaluation;
/**
* @author neo
*
*/
public class CsvEcrDelegate extends CsvDelegate
{
private Ecr ecr;
private List<Eleve> eleves;
private Map<Long, Evaluation> evaluations;
private List<EcrObjectif> objs;
private boolean isNewFile;
private Map<EleveObjectif, Evaluation> mapElevObj;
/*
* (non-Javadoc)
*
* @see ch.vd.sieeo.neo.service.csv.CsvDelegate#getHeaders()
*/
@Override
public List<String> getHeaders()
{
String[] headers = { "ANREF", "LIVREUR", "DATLIVR", "ID_ECR",
"ECR_ANNEE", "ECR_VOIE", "ECR_NIVEAU", "ECR_DISCIPLINE",
"ECR_TYPE", "ECR_DATEPASSATION", "CLAnn�eCourant", "VOIE",
"IDCLASSE", "NMCLASSE", "NUMDFJ",
"ANNAI", "MOINAI", "JOURNAI", "IDETABL", "NMETABL", "SEXE",
"NATCOD", "NATLIB", "LANGCODE",
"LANGLIB" };
// Add objectifs
// EDV-NEO-243 : Export should have 6 columns
int size = 6; // objs.size();
headersList.add("total_calcul");
headersList.add("statut_epreuve");
return headersList;
}
@Override
public Iterator<List<String>> iterator()
{
Iterator<List<String>> it = new Iterator<List<String>>() {
@Override
public boolean hasNext()
{
return eleveIte.hasNext();
}
@Override
public List<String> next()
{
Eleve anEleve = eleveIte.next();
return getContentForEleve(anEleve);
}
@Override
public void remove()
{
// Bad boy
throw new UnsupportedOperationException();
}
};
return it;
}
private List<String> getContentForEleve(Eleve eleve)
{
List<String> content = new ArrayList<String>();
DateFormat formatter = new SimpleDateFormat("yyyy.MM.dd");
// LIVREUR
content.add("NEO");
content.add("" + formatter.format(ecr.getCreateDate()));
// ID_ECR
content.add("" + ecr.getId());
// ECR_ANNEE
content.add(ecr.getDegre());
// ECR_VOIE
content.add("" + ecr.getVoie());
// ECR_NIVEAU
content.add(ecr.getNiveau() != null ?
ecr.getNiveau().getAbreviation() : "");
// ECR_DISCIPLINE
content.add(ecr.getDiscipline().getAbreviation());
// ECR_TYPE
content.add(epreuveType);
// CLAnn�eCourant
content.add(eleve.getClasse().getDegre());
// VOIE
content.add("" + eleve.getClasse().getVoie());
// IDCLASSE
content.add("" + eleve.getClasse().getId());
// NMCLASSE
content.add(eleve.getClasse().getNom());
// NUMDFJ
content.add(dfjcToString);
// NOMELEVE
// content.add(eleve.getNom());
// PRENOMELEVE
// content.add(eleve.getPrenom());
// of
// date
// is
// 0-base
day = formattingTwoDigit(calendar.get(Calendar.DAY_OF_MONTH));
}
// ANNAI
content.add(year);
// MOINAI
content.add(month);
// JOURNAI
content.add(day);
// IDETABL
content.add(eleve.getEtablissement().getId().toString());
// NMETABL
content.add(eleve.getEtablissement().getNom());
// SEXE
content.add(eleve.getGenre());
// NATCOD
content.add(eleve.getCodeNationalite());
// NATLIB
content.add(eleve.getLibelleNationalite());
// LANGCOD
content.add(eleve.getCodeLangueMaternelle());
// LANGLIB
content.add(eleve.getLibelleLangueMaternelle());
int nbObjectifs = 0;
// CD_OBJECTIF 1..n
content.add(objectifEcr.getCode());
if (evalOjb != null)
{
// Points_Objectif 1..n
String pts = evalOjb.getNote() != null ?
evalOjb.getNote().toString() : null;
content.add(pts);
if (evalOjb.getNote() != null)
{
sumPoints += evalOjb.getNote();
}
} else
{
content.add(null);
}
}
// Points
content.add(null);
}
}
// total_calcul
String sumPtsStr = sumPoints != null ? sumPoints.toString() : null;
content.add(sumPtsStr);
// status_epreuve
// TODO to correct later
String status = (ecrEval != null && ecrEval.getRemarque() != null && !
ecrEval.getRemarque().equals("null")) ? ecrEval
.getRemarque() : null;
content.add(status);
return content;
}
/*
* (non-Javadoc)
*
* @see ch.vd.sieeo.neo.service.csv.CsvDelegate#isNewFile()
*/
@Override
public boolean isNewFile()
{
return this.isNewFile;
}