use of fr.univlorraine.ecandidat.entities.siscol.WSIndividu in project esup-ecandidat by EsupPortail.
the class DemoController method recupInfoEtudiant.
/**
* @param ine
* @return un individu Apogee anonyme
*/
public WSIndividu recupInfoEtudiant(final String ine) {
WSIndividu ind = null;
if (ine != null && ine.equals("0000000000") || ine.equals("1111111111") || ine.equals("2222222222") || ine.equals("3333333333") || ine.equals("4444444444") || ine.equals("5555555555") || ine.equals("6666666666") || ine.equals("7777777777") || ine.equals("8888888888") || ine.equals("9999999999")) {
final String cpt = ine.substring(0, 1);
ind = new WSIndividu(1, "1", "057", new BigDecimal(ine), ine, "A", "D", LocalDate.of(1992, 2, 12), "NomPat-" + cpt, "NomUsu-" + cpt, "Prenom1-" + cpt, "Prenom2-" + cpt, "Metz", "100");
ind.setAdresse(new WSAdresse(1, "57000", "57463", "100", "15 rue de Nancy", "Etage 1", "Porte droite", "0383542120", "0612356421"));
ind.setBac(new WSBac(Long.valueOf(ine), "S", "057", "0573227Y", null, "2009", "O", null, null, null, null, null, null, null));
final List<WSCursusInterne> listCursusInterne = new ArrayList<>();
listCursusInterne.add(new WSCursusInterne("VET001-001", "License 1 - Droit", "2010", "AB", "1", "10", 1));
listCursusInterne.add(new WSCursusInterne("VET001-002", "License 2 - Droit", "2011", "P", "1", "11", 1));
listCursusInterne.add(new WSCursusInterne("VET001-003", "License 2 - Droit", "2012", "P", "1", "12", 1));
listCursusInterne.add(new WSCursusInterne("VET001-004", "Master 1 - Droit", "2013", "B", "1", "13", 1));
listCursusInterne.add(new WSCursusInterne("VET001-005", "Master 2 - Droit", "2014", "P", "1", "14", 1));
ind.setListCursusInterne(listCursusInterne);
}
return ind;
}
use of fr.univlorraine.ecandidat.entities.siscol.WSIndividu in project esup-ecandidat by EsupPortail.
the class SiScolApogeeWSServiceImpl method getIndividu.
/**
* @see fr.univlorraine.ecandidat.services.siscol.SiScolGenericService#getIndividu(java.lang.String,
* java.lang.String, java.lang.String)
*/
@Override
public WSIndividu getIndividu(final String codEtu, final String ine, final String cleIne) throws SiScolException {
try {
/* Instanciation du service */
if (etudiantService == null) {
etudiantService = ServiceProvider.getService(EtudiantMetierServiceInterface.class);
}
/* Mise en majuscule de l'ine */
String ineAndKey = null;
if (ine != null && cleIne != null) {
ineAndKey = ine.toUpperCase() + cleIne.toUpperCase();
}
final IdentifiantsEtudiantDTO2 etudiant = etudiantService.recupererIdentifiantsEtudiantV2(codEtu, null, ineAndKey, null, null, null, null, null, "N");
if (etudiant != null && etudiant.getCodEtu() != null) {
final InfoAdmEtuDTO4 data = etudiantService.recupererInfosAdmEtuV4(etudiant.getCodEtu().toString());
if (data != null) {
String civilite = "";
if (data.getSexe() != null) {
if (data.getSexe().equals("F")) {
civilite = "2";
} else {
civilite = "1";
}
}
/* civilite */
final WSIndividu individu = new WSIndividu(etudiant.getCodInd(), civilite, new BigDecimal(etudiant.getCodEtu()), MethodUtils.getIne(etudiant.getNumeroINE()), MethodUtils.getCleIne(etudiant.getNumeroINE()), data.getDateNaissance().toLocalDate(), data.getNomPatronymique(), data.getNomUsuel(), data.getPrenom1(), data.getPrenom2(), data.getLibVilleNaissance());
if (data.getDepartementNaissance() != null) {
individu.setCodDepNai(data.getDepartementNaissance().getCodeDept());
}
if (data.getPaysNaissance() != null) {
individu.setCodPayNai(data.getPaysNaissance().getCodPay());
} else {
individu.setCodPayNai(ConstanteUtils.PAYS_CODE_FRANCE);
}
if (data.getNationaliteDTO() != null) {
individu.setCodPayNat(data.getNationaliteDTO().getCodeNationalite());
} else {
individu.setCodPayNat(ConstanteUtils.PAYS_CODE_FRANCE);
}
/* Recuperation du bac */
if (data.getListeBacs() != null) {
final List<IndBacDTO2> liste = data.getListeBacs().getItem();
final Optional<IndBacDTO2> optBac = liste.stream().filter(e1 -> e1.getAnneeObtentionBac() != null && e1.getCodBac() != null).sorted((e1, e2) -> e2.getAnneeObtentionBac().compareTo(e1.getAnneeObtentionBac())).findFirst();
if (optBac.isPresent()) {
final IndBacDTO2 bacDTO = optBac.get();
final WSBac bac = new WSBac();
bac.setCodBac(bacDTO.getCodBac());
bac.setDaaObtBacIba(bacDTO.getAnneeObtentionBac());
if (bacDTO.getDepartementBac() != null) {
bac.setCodDep(bacDTO.getDepartementBac().getCodeDept());
}
if (bacDTO.getEtbBac() != null) {
bac.setCodEtb(bacDTO.getEtbBac().getCodeEtb());
}
if (bacDTO.getMentionBac() != null) {
bac.setCodMnb(bacDTO.getMentionBac().getCodMention());
}
/* Spécialités/Options */
bac.setCodSpeBacPre(bacDTO.getCodSpeBacPre());
bac.setCodSpe1Bac(bacDTO.getCodSpe1Bac());
bac.setCodSpe2Bac(bacDTO.getCodSpe2Bac());
bac.setCodOpt1Bac(bacDTO.getCodOpt1Bac());
bac.setCodOpt2Bac(bacDTO.getCodOpt2Bac());
bac.setCodOpt3Bac(bacDTO.getCodOpt3Bac());
bac.setCodOpt4Bac(bacDTO.getCodOpt4Bac());
individu.setBac(bac);
}
}
/* Recuperation de l'adresse */
individu.setAdresse(getAdresse(etudiant.getCodEtu().toString()));
/* Recuperation du cursus */
individu.setListCursusInterne(getCursusInterne(etudiant.getCodEtu().toString()));
return individu;
}
}
return null;
} catch (final Exception ex) {
if (ex.getMessage() != null && ex.getMessage().equals("technical.data.nullretrieve.etudiant")) {
return null;
} else if (ex.getMessage() != null && ex.getMessage().equals("technical.parameter.noncoherentinput.codEtu")) {
return null;
}
final String error = "Probleme avec le WS lors de la recherche complete de l'etudiant (individu, bac, adresse, cursus) dont codetu est : " + codEtu + " et codIne est : " + ine;
logger.error(error, ex);
throw new SiScolException(error, ex);
}
}
use of fr.univlorraine.ecandidat.entities.siscol.WSIndividu in project esup-ecandidat by EsupPortail.
the class CandidatController method synchronizeCandidat.
/**
* Synchronise un compte candidat avec apogée
* @param cptMin
*/
public void synchronizeCandidat(final CompteMinima cptMin, final CandidatAdminListener listener) {
if (!parametreController.getSiScolMode().equals(ConstanteUtils.SI_SCOL_APOGEE)) {
return;
}
final String lockError = getLockErrorFull(cptMin);
if (lockError != null) {
Notification.show(lockError, Type.WARNING_MESSAGE);
return;
}
final ConfirmWindow win = new ConfirmWindow(applicationContext.getMessage("candidat.sync.apo.window", null, UI.getCurrent().getLocale()));
win.addBtnOuiListener(e -> {
Candidat candidat = cptMin.getCandidat();
if (candidat == null) {
candidat = new Candidat(cptMin, cacheController.getLangueDefault());
}
try {
WSIndividu individu = null;
if (cptMin != null && cptMin.getSupannEtuIdCptMin() != null && !cptMin.getSupannEtuIdCptMin().equals("")) {
individu = recupInfoCandidat(cptMin.getSupannEtuIdCptMin(), null, null);
if (individu != null && isINEPresent(individu.getCodNneInd(), individu.getCodCleNneInd(), candidat)) {
Notification.show(applicationContext.getMessage("infoperso.ine.allready.present", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
} else if (candidat != null && candidat.getIneCandidat() != null && !candidat.getIneCandidat().equals("") && candidat.getCleIneCandidat() != null && !candidat.getCleIneCandidat().equals("")) {
final String ine = candidat.getIneCandidat();
final String cleIne = candidat.getCleIneCandidat();
if (ine == null || ine.equals("") || cleIne == null || cleIne.equals("")) {
Notification.show(applicationContext.getMessage("candidat.sync.apo.ine.absent", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
if (isINEPresent(ine, cleIne, candidat)) {
Notification.show(applicationContext.getMessage("infoperso.ine.allready.present", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
individu = recupInfoCandidat(null, ine, cleIne);
}
if (individu != null) {
candidat = getCandidatByApogeeData(individu, candidat);
if (MethodUtils.validateBean(candidat, logger)) {
if (individu.getAdresse() != null) {
final Adresse adresse = getAdresseByApogeeData(individu.getAdresse());
if (MethodUtils.validateBean(adresse, logger)) {
final Adresse lastAdresse = candidat.getAdresse();
if (lastAdresse != null) {
adresse.setIdAdr(lastAdresse.getIdAdr());
}
candidat.setAdresse(adresse);
}
} else {
candidat.setAdresse(null);
}
candidat = saveCandidat(candidat, individu, listener);
candidatParcoursController.getBacByApogeeData(individu.getBac(), candidat, true);
if (parametreController.getIsGetCursusInterne()) {
candidatParcoursController.getCursusInterne(individu.getListCursusInterne(), candidat, true);
}
} else {
Notification.show(applicationContext.getMessage("candidat.sync.apo.etu.nok", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
} else {
Notification.show(applicationContext.getMessage("candidat.sync.apo.etu.absent", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
} catch (final SiScolException f) {
logger.error(applicationContext.getMessage("siscol.connect.error", null, UI.getCurrent().getLocale()), f);
Notification.show(applicationContext.getMessage("siscol.connect.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
}
Notification.show(applicationContext.getMessage("candidat.sync.apo.ok", null, UI.getCurrent().getLocale()), Type.TRAY_NOTIFICATION);
});
UI.getCurrent().addWindow(win);
}
use of fr.univlorraine.ecandidat.entities.siscol.WSIndividu in project esup-ecandidat by EsupPortail.
the class SiScolController method testWSSiScolConnnexion.
/**
* Teste la connexion au WS Apogée
*/
public void testWSSiScolConnnexion() {
final InputWindow inputWindow = new InputWindow(applicationContext.getMessage("version.ws.message", null, UI.getCurrent().getLocale()), applicationContext.getMessage("version.ws.title", null, UI.getCurrent().getLocale()), false, 15);
inputWindow.addBtnOkListener(text -> {
if (text instanceof String && !text.isEmpty()) {
if (text != null) {
try {
WSIndividu ind;
if (demoController.getDemoMode()) {
ind = demoController.recupInfoEtudiant("0000000000");
} else {
ind = siScolService.getIndividu(text, null, null);
}
String ret = "Pas d'info";
if (ind != null) {
ret = "<u>Individu</u> : <br>" + ind + "<br><br><u>Adresse</u> : <br>" + ind.getAdresse() + "<br><br><u>Bac</u> : <br>" + ind.getBac() + "<br><br><u>Cursus interne</u> : <br>" + ind.getListCursusInterne();
}
UI.getCurrent().addWindow(new InfoWindow(applicationContext.getMessage("version.ws.result", null, UI.getCurrent().getLocale()), ret, 500, 70));
} catch (final Exception e) {
Notification.show(applicationContext.getMessage("version.ws.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
}
}
}
});
UI.getCurrent().addWindow(inputWindow);
}
use of fr.univlorraine.ecandidat.entities.siscol.WSIndividu in project esup-ecandidat by EsupPortail.
the class TestWsController method testWs.
@SuppressWarnings("unchecked")
public void testWs() throws IOException {
logger.info("********** Début des Tests des Webservices **********");
final EntityManagerFactory emf = Persistence.createEntityManagerFactory("pun-jpa-siscol");
final EntityManager em = emf.createEntityManager();
final ResourceBundle bundle = ResourceBundle.getBundle("test-ws");
final String codOpi = bundle.getString("opi.codOpi");
try {
logger.info("********** Vérifications OPI **********");
final Candidature candOpi = candidatureRepository.findOne(Integer.valueOf(bundle.getString("opi.idCand")));
if (countOpiData(em, "IND_OPI", codOpi) > 0) {
throw new RuntimeException("Impossible de lancer les tests, nettoyez d'abord les OPI");
}
logger.info("********** Vérifications OPI terminée, lancement des tests **********");
/* Checkine */
logger.info("********** Vérifications Checkine **********");
final Boolean isInes = siScolService.checkStudentINES(bundle.getString("checkine.ine"), bundle.getString("checkine.key"));
if (!isInes) {
throw new RuntimeException("Checkines ne fonctionne pas");
} else {
logger.info("Ok - " + bundle.getString("checkine.ine") + bundle.getString("checkine.key"));
}
/* Données individu */
logger.info("********** Test Données individu **********");
final String codEtu = bundle.getString("ind.codEtu");
final WSIndividu ind = siScolService.getIndividu(codEtu, null, null);
checkString(bundle, String.valueOf(ind.getCodEtu()), "ind.codEtu");
checkString(bundle, String.valueOf(ind.getCodInd()), "ind.codInd");
checkString(bundle, ind.getCodNneInd(), "ind.codNneInd");
checkString(bundle, ind.getCodCleNneInd(), "ind.codCleNneInd");
checkString(bundle, ind.getCodPayNai(), "ind.codPayNai");
checkString(bundle, ind.getCodDepNai(), "ind.codDepNai");
checkString(bundle, ind.getCodPayNat(), "ind.codPayNat");
checkString(bundle, ind.getLibNomPatInd(), "ind.libNomPatInd");
checkString(bundle, ind.getLibNomUsuInd(), "ind.libNomUsuInd");
checkString(bundle, ind.getLibPr1Ind(), "ind.libPr1Ind");
checkString(bundle, ind.getLibPr2Ind(), "ind.libPr2Ind");
checkString(bundle, ind.getLibVilNaiEtu(), "ind.libVilNaiEtu");
/* Données bac */
logger.info("********** Test Données bac **********");
final WSBac bac = ind.getBac();
checkString(bundle, bac.getCodBac(), "bac.codBac");
checkString(bundle, bac.getCodDep(), "bac.codDep");
checkString(bundle, bac.getCodEtb(), "bac.codEtb");
checkString(bundle, bac.getCodMnb(), "bac.codMnb");
checkString(bundle, bac.getDaaObtBacIba(), "bac.daaObtBacIba");
checkString(bundle, bac.getTemInsAdm(), "bac.temInsAdm");
checkString(bundle, bac.getCodSpeBacPre(), "bac.codSpeBacPre");
checkString(bundle, bac.getCodSpe1Bac(), "bac.codSpe1Bac");
checkString(bundle, bac.getCodSpe2Bac(), "bac.codSpe2Bac");
checkString(bundle, bac.getCodOpt1Bac(), "bac.codOpt1Bac");
checkString(bundle, bac.getCodOpt2Bac(), "bac.codOpt2Bac");
checkString(bundle, bac.getCodOpt3Bac(), "bac.codOpt3Bac");
checkString(bundle, bac.getCodOpt4Bac(), "bac.codOpt4Bac");
/* Données Adresse */
logger.info("********** Test Données adresse **********");
final WSAdresse adr = ind.getAdresse();
checkString(bundle, adr.getCodBdi(), "adr.codBdi");
checkString(bundle, adr.getCodCom(), "adr.codCom");
checkString(bundle, adr.getCodPay(), "adr.codPay");
checkString(bundle, adr.getLibAd1(), "adr.libAd1");
checkString(bundle, adr.getLibAd2(), "adr.libAd2");
checkString(bundle, adr.getLibAd3(), "adr.libAd3");
checkString(bundle, adr.getLibAde(), "adr.libAde");
checkString(bundle, adr.getNumTel(), "adr.numTel");
checkString(bundle, adr.getNumTelPort(), "adr.numTelPort");
/* Données Cursus (test de la taille de liste et de la premiere inscription) */
logger.info("********** Test Données Cursus interne **********");
final List<WSCursusInterne> listCursus = ind.getListCursusInterne();
checkString(bundle, String.valueOf(listCursus.size()), "cursus.size");
final WSCursusInterne cursus = listCursus.get(0);
checkString(bundle, cursus.getCodVet(), "cursus.codVet");
checkString(bundle, cursus.getLibVet(), "cursus.libVet");
checkString(bundle, cursus.getCodAnu(), "cursus.codAnu");
checkString(bundle, cursus.getCodMen(), "cursus.codMen");
checkString(bundle, cursus.getCodTre(), "cursus.codTre");
checkString(bundle, cursus.getNotVet(), "cursus.notVet");
checkString(bundle, String.valueOf(cursus.getBarNotVet()), "cursus.barNotVet");
/* Données PJ */
logger.info("********** Test Données PJ **********");
final WSPjInfo pjInfo = siScolService.getPjInfoFromApogee(bundle.getString("pj.codAnu"), bundle.getString("pj.codEtu"), bundle.getString("pj.codTpj"));
checkString(bundle, pjInfo.getCodAnu(), "pj.codAnu");
checkString(bundle, pjInfo.getCodTpj(), "pj.codTpj");
checkString(bundle, pjInfo.getLibTpj(), "pj.libTpj");
checkString(bundle, pjInfo.getNomFic(), "pj.nomFic");
checkString(bundle, String.valueOf(pjInfo.getTemDemPJ()), "pj.temDemPJ");
checkString(bundle, pjInfo.getStuPj(), "pj.stuPj");
checkString(bundle, pjInfo.getMtfRefus(), "pj.mtfRefus");
checkString(bundle, pjInfo.getCmtMtfRefus(), "pj.cmtMtfRefus");
checkString(bundle, pjInfo.getDatDemPj(), "pj.datDemPj");
checkString(bundle, pjInfo.getDatRecPj(), "pj.datRecPj");
checkString(bundle, pjInfo.getDatRefus(), "pj.datRefus");
checkString(bundle, pjInfo.getDatVal(), "pj.datVal");
checkString(bundle, pjInfo.getDatExp(), "pj.datExp");
checkString(bundle, pjInfo.getDaaPreTra(), "pj.daaPreTra");
/* Données PJ */
logger.info("********** Test Fichier PJ **********");
final InputStream pjFichier = siScolService.getPjFichierFromApogee(bundle.getString("pj.codAnu"), bundle.getString("pj.codEtu"), bundle.getString("pj.codTpj"));
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final byte[] bytes = new byte[1024];
int count;
while ((count = pjFichier.read(bytes)) > 0) {
out.write(bytes, 0, count);
}
checkString(bundle, String.valueOf(out.size()), "filepj.size");
logger.info("********** Test OPI **********");
final Opi opi = opiRepository.findOne(candOpi.getIdCand());
opi.setDatPassageOpi(null);
opi.setCodOpi(null);
opiRepository.save(opi);
final PjOpiPK pk = new PjOpiPK(bundle.getString("opi.codOpi"), bundle.getString("opi.codTpj"));
final PjOpi pj = pjOpiRepository.findOne(pk);
pj.setDatDeversement(null);
pjOpiRepository.save(pj);
siScolService.creerOpiViaWS(candOpi.getCandidat(), true);
logger.info("********** Vérification OPI **********");
checkOpiData(em, "IND_OPI", codOpi);
checkOpiData(em, "OPI_BAC", codOpi);
checkOpiData(em, "VOEUX_INS", codOpi);
checkOpiData(em, "ADRESSE_OPI", codOpi);
checkOpiData(em, "OPI_PJ", codOpi);
logger.info("********** Vérification OPI PJ **********");
final String requete = "Select a from IndOpi a where a.codOpiIntEpo='" + codOpi + "'";
final Query query = em.createQuery(requete, IndOpi.class);
final List<IndOpi> lindopi = query.getResultList();
final IndOpi indOpi = lindopi.get(0);
final Session cmisSession = getCmisSession(bundle);
final Folder folder = (Folder) cmisSession.getObject(cmisSession.createObjectId(bundle.getString("opi.pj.candidatureId")));
final String pathDoc = folder.getPath() + "/" + indOpi.getCodIndOpi() + "_OPI/PJ_" + bundle.getString("pj.codTpj") + "_" + indOpi.getCodIndOpi() + bundle.getString("opi.pj.ext");
logger.info("Recherche par path : " + pathDoc);
final Document d = (Document) cmisSession.getObjectByPath(pathDoc);
checkString(bundle, String.valueOf(d.getContentStreamLength()), "opi.pj.size");
logger.info("********** Fin des Tests des Webservices **********");
} catch (final Exception e) {
e.printStackTrace();
} finally {
em.close();
}
}
Aggregations