Search in sources :

Example 6 with Criteria

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

the class ApplicationService method finalCall.

public void finalCall(Session cmisSession, String objectId) {
    Criteria criteriaDomande = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
    criteriaDomande.add(Restrictions.inTree(objectId));
    criteriaDomande.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), StatoDomanda.CONFERMATA.getValue()));
    OperationContext context = cmisSession.getDefaultContext();
    context.setMaxItemsPerPage(1000);
    ItemIterable<QueryResult> domande = criteriaDomande.executeQuery(cmisSession, false, context);
    for (QueryResult queryResultDomande : domande) {
        String applicationAttach = competitionService.findAttachmentId(cmisSession, (String) queryResultDomande.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue(), JCONONDocumentType.JCONON_ATTACHMENT_APPLICATION);
        if (applicationAttach != null) {
            Folder folderId = createFolderFinal(cmisSession, objectId);
            try {
                ((FileableCmisObject) cmisSession.getObject(applicationAttach)).addToFolder(folderId, true);
            } catch (CmisRuntimeException _ex) {
                LOGGER.error("Cannot find folder", _ex);
            }
        }
    }
}
Also used : Criteria(it.cnr.si.opencmis.criteria.Criteria)

Example 7 with Criteria

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

the class ApplicationService method loadApplicationByCall.

protected Folder loadApplicationByCall(Session cmisSession, String callId, Map<String, Object> model, String userId) {
    if (model != null && !model.isEmpty() && model.get("application") != null)
        return (Folder) model.get("application");
    Folder call = loadCallById(cmisSession, callId, model);
    Criteria criteria = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
    criteria.addColumn(PropertyIds.OBJECT_ID);
    criteria.add(Restrictions.inFolder(call.getId()));
    criteria.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_USER.value(), userId));
    ItemIterable<QueryResult> iterable = criteria.executeQuery(cmisSession, false, cmisSession.getDefaultContext());
    if (iterable.getTotalNumItems() == 0 || iterable.getTotalNumItems() == -1) {
        return null;
    } else if (iterable.getTotalNumItems() > 1)
        throw new ClientMessageException("message.error.domanda.multipla");
    for (QueryResult queryResult : iterable) {
        Folder folder = (Folder) cmisSession.getObject((String) queryResult.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue());
        folder.refresh();
        model.put("folder", folder);
        return folder;
    }
    throw new ClientMessageException("message.error.domanda.multipla");
}
Also used : ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) Criteria(it.cnr.si.opencmis.criteria.Criteria)

Example 8 with Criteria

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

the class CallService method estraiGraduatorie.

public Map<String, List<?>> estraiGraduatorie(Session session, String codice) {
    if (!Optional.ofNullable(codice).isPresent())
        throw new ClientMessageException("Valorizzare il codice del Bando");
    Criteria criteriaCalls = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_CALL.queryName());
    criteriaCalls.addColumn(PropertyIds.OBJECT_ID);
    criteriaCalls.addColumn(JCONONPropertyIds.CALL_CODICE.value());
    criteriaCalls.add(Restrictions.like(JCONONPropertyIds.CALL_CODICE.value(), "%".concat(codice.trim()).concat("%")));
    ItemIterable<QueryResult> calls = criteriaCalls.executeQuery(session, false, session.getDefaultContext());
    Map<String, List<?>> result = new HashMap<String, List<?>>();
    for (QueryResult call : calls.getPage(Integer.MAX_VALUE)) {
        List<Object> apps = new ArrayList<>();
        result.put(call.getPropertyValueById(JCONONPropertyIds.CALL_CODICE.value()), apps);
        Criteria criteriaApplications = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
        criteriaApplications.addColumn(JCONONPropertyIds.APPLICATION_USER.value());
        criteriaApplications.addColumn(JCONONPropertyIds.APPLICATION_NOME.value());
        criteriaApplications.addColumn(JCONONPropertyIds.APPLICATION_COGNOME.value());
        criteriaApplications.addColumn(JCONONPropertyIds.APPLICATION_CODICE_FISCALE.value());
        criteriaApplications.addColumn(JCONONPropertyIds.APPLICATION_TOTALE_PUNTEGGIO.value());
        criteriaApplications.addColumn(JCONONPropertyIds.APPLICATION_GRADUATORIA.value());
        criteriaApplications.addColumn(JCONONPropertyIds.APPLICATION_ESITO_CALL.value());
        criteriaApplications.add(Restrictions.inTree(call.getPropertyValueById(PropertyIds.OBJECT_ID)));
        criteriaApplications.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
        criteriaApplications.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
        criteriaApplications.addOrder(Order.asc(JCONONPropertyIds.APPLICATION_GRADUATORIA.value()));
        ItemIterable<QueryResult> applications = criteriaApplications.executeQuery(session, false, session.getDefaultContext());
        for (QueryResult application : applications.getPage(Integer.MAX_VALUE)) {
            apps.add(application.getProperties().stream().collect(Collectors.toMap(PropertyData::getId, PropertyData::getFirstValue, (oldValue, newValue) -> oldValue, Hashtable::new)));
        }
    }
    return result;
}
Also used : PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) Criteria(it.cnr.si.opencmis.criteria.Criteria) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject)

Example 9 with Criteria

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

the class CallService method getApplicationConfirmed.

public ItemIterable<QueryResult> getApplicationConfirmed(Session session, Folder call) {
    Criteria criteriaDomande = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
    criteriaDomande.add(Restrictions.inTree(call.getId()));
    criteriaDomande.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
    criteriaDomande.addOrder(Order.asc(JCONONPropertyIds.APPLICATION_COGNOME.value()));
    return criteriaDomande.executeQuery(session, false, session.getDefaultContext());
}
Also used : Criteria(it.cnr.si.opencmis.criteria.Criteria)

Example 10 with Criteria

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

the class CallService method isCallAttachmentPresent.

protected boolean isCallAttachmentPresent(Session cmisSession, Folder source, JCONONDocumentType documentType) {
    Criteria criteria = CriteriaFactory.createCriteria(documentType.queryName());
    criteria.add(Restrictions.inFolder(source.getId()));
    return criteria.executeQuery(cmisSession, false, cmisSession.getDefaultContext()).getTotalNumItems() != 0;
}
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