Skip to content

Commit

Permalink
Changed the excel extraction for scoring with many applications
Browse files Browse the repository at this point in the history
  • Loading branch information
mspasiano committed Oct 20, 2022
1 parent d3b5508 commit 2c052df
Showing 1 changed file with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import it.cnr.si.cool.jconon.util.CMISPropertyIds;
import it.cnr.si.cool.jconon.util.JcononGroups;
import it.cnr.si.cool.jconon.util.QrCodeUtil;
import it.cnr.si.cool.jconon.util.StatoComunicazione;
import it.cnr.si.opencmis.criteria.Criteria;
import it.cnr.si.opencmis.criteria.CriteriaFactory;
import it.cnr.si.opencmis.criteria.Order;
Expand All @@ -81,6 +82,7 @@
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
import org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl;
import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.ContentStream;
Expand All @@ -90,6 +92,7 @@
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import org.apache.chemistry.opencmis.commons.enums.*;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException;
import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
Expand Down Expand Up @@ -3137,9 +3140,29 @@ public Map<String, Object> extractionApplicationForPunteggi(Session session, Str
final HSSFSheet sheet = wb.getSheet(SHEET_DOMANDE);
sheet.setColumnHidden(0, true);
List<CmisObject> applications = new ArrayList<>();
call.getChildren().forEach(cmisObject -> {
applications.add(cmisObject);
});

Criteria criteriaApplication = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
Criteria criteriaPunteggi = criteriaApplication.createCriteria(
JCONONPolicyType.JCONON_APPLICATION_PUNTEGGI.queryName());
criteriaPunteggi.addJoinCriterion(Restrictions.eqProperty(
criteriaApplication.prefix(PropertyIds.OBJECT_ID),
criteriaPunteggi.prefix(PropertyIds.OBJECT_ID)));
criteriaApplication.addColumn(PropertyIds.OBJECT_ID);
criteriaApplication.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), StatoDomanda.CONFERMATA.getValue()));
criteriaApplication.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
criteriaApplication.add(Restrictions.inTree(callId));
ItemIterable<QueryResult> iterablePunteggi = criteriaApplication.executeQuery(session, false, session.getDefaultContext());
final int maxItemsPerPage = session.getDefaultContext().getMaxItemsPerPage();
int skipTo = 0;
do {
iterablePunteggi = iterablePunteggi.skipTo(skipTo).getPage(maxItemsPerPage);
for (QueryResult queryResult : iterablePunteggi) {
final String propertyValueById = queryResult.<String>getPropertyValueById(PropertyIds.OBJECT_ID);
LOGGER.info("Estrazione punteggi domanda: {} Totale domande: {}", propertyValueById, applications.size());
applications.add(session.getObject(propertyValueById));
}
skipTo = skipTo + maxItemsPerPage;
} while (iterablePunteggi.getHasMoreItems());
applications.stream()
.filter(Folder.class::isInstance)
.map(Folder.class::cast)
Expand All @@ -3156,6 +3179,7 @@ public Map<String, Object> extractionApplicationForPunteggi(Session session, Str
LOGGER.error("USER {} not found", userId, _ex);
user = new CMISUser(userId);
}
LOGGER.info("Estrazione punteggi riga: {}", idx[0]);
getRecordCSVForPunteggi(session, call, folder, user, contexURL, sheet, idx[0]++);
});

Expand Down

0 comments on commit 2c052df

Please sign in to comment.