Search in sources :

Example 1 with PjOpi

use of fr.univlorraine.ecandidat.entities.ecandidat.PjOpi in project esup-ecandidat by EsupPortail.

the class OpiController method deversePjOpi.

/**
 * Deverse les PJ dans la table des PJ OPI
 * @param opi
 * @param codOpiIntEpo
 * @param codIndOpi
 */
public void deversePjOpi(final Opi opi, final String codOpiIntEpo, final Long codIndOpi) {
    if (opi == null || opi.getDatPassageOpi() == null || opi.getCodOpi() == null) {
        return;
    }
    final Candidature candidature = opi.getCandidature();
    final List<PjCand> listPjOpiToDeverse = getPJToDeverse(candidature);
    logger.debug("deversement PJ OPI dans eCandidat " + codOpiIntEpo + " Nombre de PJ : " + listPjOpiToDeverse.size());
    listPjOpiToDeverse.forEach(pjCand -> {
        logger.debug("deversement PJ OPI dans eCandidat " + codOpiIntEpo + " PJ : " + pjCand.getPieceJustif());
        /* On créé la clé primaire */
        final PjOpiPK pk = new PjOpiPK(codOpiIntEpo, pjCand.getPieceJustif().getCodApoPj());
        /* On charge une eventuelle piece */
        PjOpi pjOpi = pjOpiRepository.findOne(pk);
        /* Dans le cas ou il y a deja une PJ Opi */
        if (pjOpi != null) {
            /* on va vérifier que la pièce n'a pas été déversée et que le fichier existe
				 * encore */
            if (pjOpi.getDatDeversement() == null && fichierRepository.findOne(pjOpi.getIdFichier()) == null) {
                // dans ce cas, on supprime
                pjOpiRepository.delete(pjOpi);
                pjOpi = null;
            }
        }
        /* On l'insert */
        if (pjOpi == null) {
            pjOpi = new PjOpi();
            pjOpi.setId(pk);
            pjOpi.setCandidat(candidature.getCandidat());
            if (codIndOpi != null) {
                try {
                    pjOpi.setCodIndOpi(String.valueOf(codIndOpi));
                } catch (final Exception e) {
                }
            }
            pjOpi.setDatDeversement(null);
            pjOpi.setIdFichier(pjCand.getFichier().getIdFichier());
            pjOpi = pjOpiRepository.save(pjOpi);
            logger.debug("Ajout PJ OPI dans eCandidat " + pjOpi);
        }
    });
}
Also used : PjOpi(fr.univlorraine.ecandidat.entities.ecandidat.PjOpi) PjCand(fr.univlorraine.ecandidat.entities.ecandidat.PjCand) PjOpiPK(fr.univlorraine.ecandidat.entities.ecandidat.PjOpiPK) TypeDecisionCandidature(fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature) Candidature(fr.univlorraine.ecandidat.entities.ecandidat.Candidature) FileException(fr.univlorraine.ecandidat.services.file.FileException) SiScolException(fr.univlorraine.ecandidat.services.siscol.SiScolException)

Example 2 with PjOpi

use of fr.univlorraine.ecandidat.entities.ecandidat.PjOpi in project esup-ecandidat by EsupPortail.

the class OpiController method launchBatchAsyncOPIPj.

/**
 * Lance le batch de creation de PJ OPI asynchrone
 * @param batchHisto
 */
public void launchBatchAsyncOPIPj(final BatchHisto batchHisto) {
    final Campagne campagne = campagneController.getCampagneActive();
    if (campagne == null) {
        return;
    }
    final List<PjOpi> listePjOpi = pjOpiRepository.findByCandidatCompteMinimaCampagneIdCampAndDatDeversementIsNull(campagne.getIdCamp());
    batchController.addDescription(batchHisto, "Lancement batch, deversement de " + listePjOpi.size() + " PJOPI");
    Integer i = 0;
    Integer cpt = 0;
    Integer nbError = 0;
    for (final PjOpi pjOpi : listePjOpi) {
        try {
            deversePjOpi(pjOpi);
        } catch (final SiScolException e) {
            nbError++;
        }
        i++;
        cpt++;
        if (i.equals(ConstanteUtils.BATCH_LOG_NB_SHORT)) {
            batchController.addDescription(batchHisto, "Deversement de " + cpt + " PJOPI, dont " + nbError + " erreur(s)");
            i = 0;
        }
    }
    batchController.addDescription(batchHisto, "Fin batch, deversement de " + cpt + " PJOPI, dont " + nbError + " erreur(s)");
}
Also used : PjOpi(fr.univlorraine.ecandidat.entities.ecandidat.PjOpi) SiScolException(fr.univlorraine.ecandidat.services.siscol.SiScolException) Campagne(fr.univlorraine.ecandidat.entities.ecandidat.Campagne)

Example 3 with PjOpi

use of fr.univlorraine.ecandidat.entities.ecandidat.PjOpi in project esup-ecandidat by EsupPortail.

the class OpiController method traiteListOpiPjCandidat.

/**
 * Traite les PJ
 * @param listeOpi
 * @param codOpiIntEpo
 * @param logComp
 * @param isBatch
 */
public void traiteListOpiPjCandidat(final List<Opi> listeOpi, final String codOpiIntEpo, final long codIndOpi, final String logComp, final Boolean isBatch) {
    logger.debug("traiteListOpiPjCandidat " + codOpiIntEpo + logComp + " - " + listeOpi.size() + " opi");
    for (final Opi opi : listeOpi) {
        /* Traitement des PJ OPI si dématerialisation */
        if (candidatureController.isCandidatureDematerialise(opi.getCandidature()) && parametreController.getIsUtiliseOpiPJ()) {
            logger.debug("Deversement PJ OPI dans table eCandidat" + logComp);
            deversePjOpi(opi, codOpiIntEpo, codIndOpi);
        }
    }
    if (isBatch) {
        /* Deversement dans Apogée */
        final List<PjOpi> listePjOpi = pjOpiRepository.findByIdCodOpiAndDatDeversementIsNull(codOpiIntEpo);
        logger.debug("Tentative deversement PJ OPI WS Apogée " + codOpiIntEpo + logComp + " - " + listePjOpi.size() + " pjOPI");
        listePjOpi.forEach(pjOpi -> {
            try {
                deversePjOpi(pjOpi);
            } catch (final SiScolException e) {
            // si erreur on ne log rien, on est dans le batch OPI
            }
        });
    }
}
Also used : PjOpi(fr.univlorraine.ecandidat.entities.ecandidat.PjOpi) PjOpi(fr.univlorraine.ecandidat.entities.ecandidat.PjOpi) Opi(fr.univlorraine.ecandidat.entities.ecandidat.Opi) SiScolException(fr.univlorraine.ecandidat.services.siscol.SiScolException)

Example 4 with PjOpi

use of fr.univlorraine.ecandidat.entities.ecandidat.PjOpi 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();
    }
}
Also used : Query(javax.persistence.Query) WSIndividu(fr.univlorraine.ecandidat.entities.siscol.WSIndividu) PjOpiPK(fr.univlorraine.ecandidat.entities.ecandidat.PjOpiPK) PjOpi(fr.univlorraine.ecandidat.entities.ecandidat.PjOpi) Opi(fr.univlorraine.ecandidat.entities.ecandidat.Opi) IndOpi(fr.univlorraine.ecandidat.entities.siscol.IndOpi) Candidature(fr.univlorraine.ecandidat.entities.ecandidat.Candidature) Folder(org.apache.chemistry.opencmis.client.api.Folder) Document(org.apache.chemistry.opencmis.client.api.Document) WSAdresse(fr.univlorraine.ecandidat.entities.siscol.WSAdresse) WSCursusInterne(fr.univlorraine.ecandidat.entities.siscol.WSCursusInterne) WSPjInfo(fr.univlorraine.ecandidat.entities.siscol.WSPjInfo) InputStream(java.io.InputStream) IndOpi(fr.univlorraine.ecandidat.entities.siscol.IndOpi) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) EntityManager(javax.persistence.EntityManager) PjOpi(fr.univlorraine.ecandidat.entities.ecandidat.PjOpi) EntityManagerFactory(javax.persistence.EntityManagerFactory) WSBac(fr.univlorraine.ecandidat.entities.siscol.WSBac) ResourceBundle(java.util.ResourceBundle) Session(org.apache.chemistry.opencmis.client.api.Session)

Aggregations

PjOpi (fr.univlorraine.ecandidat.entities.ecandidat.PjOpi)4 SiScolException (fr.univlorraine.ecandidat.services.siscol.SiScolException)3 Candidature (fr.univlorraine.ecandidat.entities.ecandidat.Candidature)2 Opi (fr.univlorraine.ecandidat.entities.ecandidat.Opi)2 PjOpiPK (fr.univlorraine.ecandidat.entities.ecandidat.PjOpiPK)2 Campagne (fr.univlorraine.ecandidat.entities.ecandidat.Campagne)1 PjCand (fr.univlorraine.ecandidat.entities.ecandidat.PjCand)1 TypeDecisionCandidature (fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature)1 IndOpi (fr.univlorraine.ecandidat.entities.siscol.IndOpi)1 WSAdresse (fr.univlorraine.ecandidat.entities.siscol.WSAdresse)1 WSBac (fr.univlorraine.ecandidat.entities.siscol.WSBac)1 WSCursusInterne (fr.univlorraine.ecandidat.entities.siscol.WSCursusInterne)1 WSIndividu (fr.univlorraine.ecandidat.entities.siscol.WSIndividu)1 WSPjInfo (fr.univlorraine.ecandidat.entities.siscol.WSPjInfo)1 FileException (fr.univlorraine.ecandidat.services.file.FileException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ResourceBundle (java.util.ResourceBundle)1 EntityManager (javax.persistence.EntityManager)1