public Map<InstanceSummaryKey, Long> countInstancesSummary(Set<String> pids) {
Map<InstanceSummaryKey, Long> result = new HashMap<InstanceSummaryKey, Long>();
if (!pids.isEmpty()) {
for (StatusKeys status : InstanceFilter.StatusKeys.values()) {
Query query = em.createNamedQuery(ProcessInstanceDAOImpl.COUNT_INSTANCES_BY_PROCESSES_IDS_AND_STATES);
query.setParameter("states", new InstanceFilter("status=" + status.toString()).convertFilterState());
query.setParameter("processIds", pids);
for (Object o : query.getResultList()) {
Object[] row = (Object[]) o;
InstanceSummaryKey key = new InstanceSummaryKey(row[0].toString(), status.toString());
result.put(key, (Long) row[1]);