Search in sources :

Example 1 with Criteria

use of it.cnr.si.opencmis.criteria.Criteria in project cool-jconon by consiglionazionaledellericerche.

the class PrintService method getProdotti.

private List<PrintDetailBulk> getProdotti(List<String> propertyValue, Folder application, JCONONPolicyType peopleProduct, Session cmisSession, ApplicationModel applicationModel, boolean printDetail) {
    List<PrintDetailBulk> result = new ArrayList<PrintDetailBulk>();
    OperationContext ocRel = new OperationContextImpl(cmisSession.getDefaultContext());
    ocRel.setIncludeRelationships(IncludeRelationships.SOURCE);
    Map<String, List<Pair<String, String>>> sezioni = getSezioni(propertyValue, cmisSession);
    for (String key : sezioni.keySet()) {
        for (Pair<String, String> pair : sezioni.get(key)) {
            Criteria criteria = CriteriaFactory.createCriteria(pair.getSecond());
            Criteria criteriaAspect = criteria.createCriteria(peopleProduct.queryName(), "people");
            Criteria criteriaCommon = criteria.createCriteria("cvpeople:commonMetadata", "common");
            criteriaAspect.addJoinCriterion(Restrictions.eqProperty(criteria.prefix(PropertyIds.OBJECT_ID), criteriaAspect.prefix(PropertyIds.OBJECT_ID)));
            criteriaCommon.addJoinCriterion(Restrictions.eqProperty(criteria.prefix(PropertyIds.OBJECT_ID), criteriaCommon.prefix(PropertyIds.OBJECT_ID)));
            criteria.addColumn(PropertyIds.OBJECT_ID);
            criteriaCommon.addOrder(Order.desc("common.cvpeople:anno"));
            criteria.add(Restrictions.inFolder(application.getId()));
            criteria.addOrder(Order.desc(PropertyIds.NAME));
            ItemIterable<QueryResult> queryResults = criteria.executeQuery(cmisSession, false, cmisSession.getDefaultContext());
            if (queryResults.getTotalNumItems() > 0) {
                for (QueryResult queryResult : queryResults.getPage(Integer.MAX_VALUE)) {
                    List<PrintDetailBulk> rels = new ArrayList<PrintDetailBulk>();
                    CmisObject riga = cmisSession.getObject((String) queryResult.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue(), ocRel);
                    if (!riga.getType().getQueryName().equalsIgnoreCase(pair.getSecond()))
                        continue;
                    if (riga.getRelationships() != null && !riga.getRelationships().isEmpty()) {
                        for (Relationship relationship : riga.getRelationships()) {
                            if (relationship.getType().getId().equals(JCONONRelationshipType.JCONON_ATTACHMENT_IN_PRODOTTO.value())) {
                                CmisObject target = cmisSession.getObject(relationship.getTarget());
                                String link = applicationModel.getContextURL() + "/search/content?nodeRef=" + target.getId();
                                if (printDetail)
                                    rels.add(new PrintDetailBulk(null, "Allegati", link, getFields(target, applicationModel), null));
                                else {
                                    rels.add(new PrintDetailBulk(null, "Allegati", link, target.getProperty(PropertyIds.NAME).getValueAsString(), null));
                                }
                            }
                        }
                    }
                    if (printDetail) {
                        result.add(new PrintDetailBulk(key, pair.getFirst(), null, getFields(riga, applicationModel), rels));
                    } else {
                        String link = null;
                        if (((BigInteger) riga.getPropertyValue(PropertyIds.CONTENT_STREAM_LENGTH)).compareTo(BigInteger.ZERO) > 0) {
                            link = applicationModel.getContextURL() + "/search/content?nodeRef=" + riga.getId() + "&fileName=" + riga.getName() + ".pdf";
                        }
                        String title = riga.getPropertyValue("cvpeople:id_tipo_txt");
                        title += " - " + riga.getPropertyValue("cvpeople:titolo");
                        PrintDetailBulk detail = new PrintDetailBulk(key, pair.getFirst(), link, title, rels);
                        detail.setPeriodo(String.valueOf(riga.getProperty("cvpeople:anno").getFirstValue()));
                        if (riga.getProperty("cvpeople:numeroCitazioni") != null && riga.getProperty("cvpeople:numeroCitazioni").getValues().size() != 0)
                            detail.setNroCitazioni(((BigInteger) riga.getProperty("cvpeople:numeroCitazioni").getValue()).intValue());
                        if (riga.getProperty("cvpeople:ifRivistaValore") != null && riga.getProperty("cvpeople:ifRivistaValore").getValues().size() != 0) {
                            try {
                                detail.setIfValore(riga.getProperty("cvpeople:ifRivistaValore").getValueAsString());
                            } catch (NumberFormatException _ex) {
                                LOGGER.error("Estrazione scheda di valutazione NumberFormatException for " + riga.getProperty("cvpeople:ifRivistaValore").getValueAsString() + " objectId:" + riga.getId());
                            }
                        }
                        if (riga.getProperty("cvpeople:altroRuoloSvolto") != null && riga.getProperty("cvpeople:altroRuoloSvolto").getValues().size() != 0) {
                            detail.setRuolo(riga.getProperty("cvpeople:altroRuoloSvolto").getValueAsString());
                        }
                        if (riga.getProperty("cvpeople:ruoloSvolto") != null && riga.getProperty("cvpeople:ruoloSvolto").getValues().size() != 0) {
                            for (Object ruoloSvolto : riga.getProperty("cvpeople:ruoloSvolto").getValues()) {
                                if (!ruoloSvolto.equals("Altro")) {
                                    if (detail.getRuolo() != null) {
                                        detail.setRuolo(String.valueOf(ruoloSvolto).replace("_", " ") + "," + detail.getRuolo());
                                    } else {
                                        detail.setRuolo(String.valueOf(ruoloSvolto).replace("_", " "));
                                    }
                                }
                            }
                        }
                        if (riga.getProperty("cvpeople:altroIfRivistaFonte") != null && riga.getProperty("cvpeople:altroIfRivistaFonte").getValues().size() != 0) {
                            detail.setIfFonte(riga.getProperty("cvpeople:altroIfRivistaFonte").getValueAsString());
                        }
                        if (riga.getProperty("cvpeople:SjrQuartile") != null && riga.getProperty("cvpeople:SjrQuartile").getValues().size() != 0) {
                            detail.setQuartile(riga.getProperty("cvpeople:SjrQuartile").getValueAsString());
                        }
                        if (riga.getProperty("cvpeople:ifRivistaFonte") != null && riga.getProperty("cvpeople:ifRivistaFonte").getValues().size() != 0) {
                            for (Object ifRivistaFonte : riga.getProperty("cvpeople:ifRivistaFonte").getValues()) {
                                if (!ifRivistaFonte.equals("Altro")) {
                                    if (detail.getIfFonte() != null) {
                                        detail.setIfFonte(String.valueOf(ifRivistaFonte).replace("_", " ") + "," + detail.getIfFonte());
                                    } else {
                                        detail.setIfFonte(String.valueOf(ifRivistaFonte).replace("_", " "));
                                    }
                                }
                            }
                        }
                        result.add(detail);
                    }
                }
            }
        }
    }
    return result;
}
Also used : OperationContextImpl(org.apache.chemistry.opencmis.client.runtime.OperationContextImpl) Criteria(it.cnr.si.opencmis.criteria.Criteria) BigInteger(java.math.BigInteger) List(java.util.List) PDImageXObject(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject) JSONObject(org.json.JSONObject) PrintDetailBulk(it.cnr.si.cool.jconon.model.PrintDetailBulk)

Example 2 with Criteria

use of it.cnr.si.opencmis.criteria.Criteria in project cool-jconon by consiglionazionaledellericerche.

the class ApplicationService method verificaAttivita.

protected void verificaAttivita(Boolean ctrlAlternativeAttivita, Boolean existVerificaAttivita, Boolean existRelazioneAttivita, Boolean existCurriculum, StringBuilder messageError, Folder application, Session cmisSession) {
    if (ctrlAlternativeAttivita) {
        if (!existVerificaAttivita) {
            messageError.append((messageError.length() != 0 ? "<br>" : "") + i18nService.getLabel("message.error.allegati.attivita.ver.not.exists", Locale.ITALY));
        }
        if (!existRelazioneAttivita) {
            messageError.append((messageError.length() != 0 ? "<br>" : "") + i18nService.getLabel("message.error.allegati.attivita.rel.not.exists", Locale.ITALY));
        }
        Criteria criteriaCurr = CriteriaFactory.createCriteria("jconon_attachment:cv_element");
        criteriaCurr.add(Restrictions.inFolder(application.getId()));
        OperationContext operationContextCurr = cmisSession.getDefaultContext();
        operationContextCurr.setIncludeRelationships(IncludeRelationships.SOURCE);
        long numRigheCurriculum = criteriaCurr.executeQuery(cmisSession, false, operationContextCurr).getTotalNumItems();
        if (!existCurriculum && numRigheCurriculum <= 0) {
            messageError.append((messageError.length() != 0 ? "<br>" : "") + i18nService.getLabel("message.error.allegati.alternative.curriculum.not.exists", Locale.ITALY));
        }
        if (existCurriculum && numRigheCurriculum > 0) {
            messageError.append((messageError.length() != 0 ? "<br>" : "") + i18nService.getLabel("message.error.allegati.alternative.curriculum.all.exists", Locale.ITALY));
        }
    }
}
Also used : Criteria(it.cnr.si.opencmis.criteria.Criteria)

Example 3 with Criteria

use of it.cnr.si.opencmis.criteria.Criteria in project cool-jconon by consiglionazionaledellericerche.

the class ApplicationService method concludiProcessoSchedeAnonime.

public String concludiProcessoSchedeAnonime(Session currentCMISSession, String idCall, Locale locale, String contextURL, CMISUser user) {
    final String userId = user.getId();
    if (!callService.isMemberOfRDPGroup(user, (Folder) currentCMISSession.getObject(idCall)) && !user.isAdmin()) {
        LOGGER.error("USER:" + userId + " try to generaSchedeValutazione for call:" + idCall);
        throw new ClientMessageException("USER:" + userId + " try to generaSchedeValutazione for call:" + idCall);
    }
    OperationContext context = currentCMISSession.getDefaultContext();
    context.setMaxItemsPerPage(Integer.MAX_VALUE);
    String message = "";
    Criteria criteriaSchedeAnonime = CriteriaFactory.createCriteria(JCONONDocumentType.JCONON_ATTACHMENT_SCHEDA_ANONIMA_SINTETICA_GENERATED.queryName(), "doc");
    criteriaSchedeAnonime.add(Restrictions.inTree(idCall));
    Criteria criteriaValutazione = criteriaSchedeAnonime.createCriteria(JCONONPolicyType.JCONON_SCHEDA_ANONIMA_VALUTAZIONE.queryName(), "val");
    criteriaValutazione.addJoinCriterion(Restrictions.eqProperty(criteriaSchedeAnonime.prefix(PropertyIds.OBJECT_ID), criteriaValutazione.prefix(PropertyIds.OBJECT_ID)));
    criteriaValutazione.add(Restrictions.isNull(criteriaValutazione.getTypeAlias() + "." + JCONONPropertyIds.SCHEDA_ANONIMA_VALUTAZIONE_ESITO.value()));
    if (criteriaSchedeAnonime.executeQuery(currentCMISSession, false, context).getTotalNumItems() > 0)
        throw new ClientMessageException("message.concludi.processo.schede.anonime.interrotto");
    Criteria criteria = CriteriaFactory.createCriteria(JCONONDocumentType.JCONON_ATTACHMENT_SCHEDA_ANONIMA_SINTETICA_GENERATED.queryName(), "doc");
    criteria.add(Restrictions.inTree(idCall));
    ItemIterable<QueryResult> schede = criteria.executeQuery(currentCMISSession, false, context);
    int domandeConfermate = 0, domandeEscluse = 0;
    for (QueryResult scheda : schede) {
        Document schedaAnonimaSintetica = (Document) currentCMISSession.getObject((String) scheda.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue());
        Folder domanda = schedaAnonimaSintetica.getParents().get(0);
        if (schedaAnonimaSintetica.<Boolean>getPropertyValue(JCONONPropertyIds.SCHEDA_ANONIMA_VALUTAZIONE_ESITO.value())) {
            domandeConfermate++;
        } else {
            Map<String, Object> schedaAnonimaproperties = new HashMap<String, Object>();
            List<String> secondaryTypesId = new ArrayList<String>();
            for (SecondaryType secondaryType : schedaAnonimaSintetica.getSecondaryTypes()) {
                secondaryTypesId.add(secondaryType.getId());
            }
            secondaryTypesId.add(JCONONPolicyType.JCONON_ATTACHMENT_GENERIC_DOCUMENT.value());
            schedaAnonimaproperties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypesId);
            schedaAnonimaSintetica.updateProperties(schedaAnonimaproperties);
            Map<String, Serializable> properties = new HashMap<String, Serializable>();
            properties.put("jconon_application:esclusione_rinuncia", "S");
            cmisService.createAdminSession().getObject(domanda).updateProperties(properties);
            domandeEscluse++;
        }
        message = "Il processo di valutazione si รจ concluso con:<br><b>Domande Confermate:</b> " + domandeConfermate + "<br><b>Domande Escluse:</b>" + domandeEscluse;
    }
    if (schede.getTotalNumItems() != 0) {
        Folder call = (Folder) currentCMISSession.getObject(idCall);
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(JCONONPropertyIds.CALL_STATO.value(), CallStato.PROCESSO_SCHEDE_ANONIME_CONCLUSO_COMMISSIONE_NON_ABILITATA.name());
        call.updateProperties(properties);
    }
    return message;
}
Also used : Criteria(it.cnr.si.opencmis.criteria.Criteria) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject) UnfileObject(org.apache.chemistry.opencmis.commons.enums.UnfileObject)

Example 4 with Criteria

use of it.cnr.si.opencmis.criteria.Criteria in project cool-jconon by consiglionazionaledellericerche.

the class ApplicationService method validateSchedeAnonime.

protected void validateSchedeAnonime(Session cmisSession, Folder call, Folder application) {
    Boolean flagSchedaAnonima = call.getPropertyValue(JCONONPropertyIds.CALL_FLAG_SCHEDA_ANONIMA_SINTETICA.value());
    if (flagSchedaAnonima != null && flagSchedaAnonima) {
        Criteria criteriaSchedeAnonime = CriteriaFactory.createCriteria(JCONONDocumentType.JCONON_ATTACHMENT_SCHEDA_ANONIMA.queryName());
        criteriaSchedeAnonime.add(Restrictions.inFolder(application.getId()));
        long numRigheSchedeAnonime = criteriaSchedeAnonime.executeQuery(cmisSession, false, cmisSession.getDefaultContext()).getTotalNumItems();
        if (numRigheSchedeAnonime == 0) {
            throw new ClientMessageException("message.error.schede.anonime.not.found");
        }
    }
}
Also used : ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) Criteria(it.cnr.si.opencmis.criteria.Criteria)

Example 5 with Criteria

use of it.cnr.si.opencmis.criteria.Criteria in project cool-jconon by consiglionazionaledellericerche.

the class ApplicationService method findSchedeValutazione.

/**
 * Ritorna una Map con key il COGNOME e NOME dell'utente e come value l'id della scheda
 *
 * @param currentCMISSession
 * @param idCall
 * @return
 */
public Map<String, String> findSchedeValutazione(Session currentCMISSession, String idCall) {
    Map<String, String> result = new TreeMap<String, String>();
    Criteria criteriaDomande = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
    criteriaDomande.add(Restrictions.inTree(idCall));
    criteriaDomande.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), StatoDomanda.CONFERMATA.getValue()));
    criteriaDomande.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
    criteriaDomande.addOrder(Order.asc(JCONONPropertyIds.APPLICATION_COGNOME.value()));
    OperationContext context = currentCMISSession.getDefaultContext();
    context.setMaxItemsPerPage(10000);
    ItemIterable<QueryResult> domande = criteriaDomande.executeQuery(currentCMISSession, false, context);
    for (QueryResult queryResultDomande : domande) {
        String applicationAttach = competitionService.findAttachmentId(currentCMISSession, (String) queryResultDomande.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue(), JCONONDocumentType.JCONON_ATTACHMENT_SCHEDA_VALUTAZIONE);
        if (applicationAttach != null) {
            result.put(queryResultDomande.getPropertyById(JCONONPropertyIds.APPLICATION_COGNOME.value()).getFirstValue() + " " + queryResultDomande.getPropertyById(JCONONPropertyIds.APPLICATION_NOME.value()).getFirstValue(), applicationAttach);
        }
    }
    return result;
}
Also used : Criteria(it.cnr.si.opencmis.criteria.Criteria)

Aggregations

Criteria (it.cnr.si.opencmis.criteria.Criteria)53 ClientMessageException (it.cnr.cool.web.scripts.exception.ClientMessageException)26 JSONObject (org.json.JSONObject)19 BindingSession (org.apache.chemistry.opencmis.client.bindings.spi.BindingSession)18 CoolUserFactoryException (it.cnr.cool.exception.CoolUserFactoryException)17 CMISUser (it.cnr.cool.security.service.impl.alfresco.CMISUser)16 BigInteger (java.math.BigInteger)16 ACLType (it.cnr.cool.cmis.model.ACLType)14 CriteriaFactory (it.cnr.si.opencmis.criteria.CriteriaFactory)14 java.util (java.util)14 Collectors (java.util.stream.Collectors)14 Output (org.apache.chemistry.opencmis.client.bindings.spi.http.Output)14 Response (org.apache.chemistry.opencmis.client.bindings.spi.http.Response)14 PropertyIds (org.apache.chemistry.opencmis.commons.PropertyIds)14 UrlBuilder (org.apache.chemistry.opencmis.commons.impl.UrlBuilder)14 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 Autowired (org.springframework.beans.factory.annotation.Autowired)14 CoolPropertyIds (it.cnr.cool.cmis.model.CoolPropertyIds)13 GroupsEnum (it.cnr.cool.security.GroupsEnum)13