/** * Loads a list of attributeValueBeans from the TAttributeValue table by an array of workItemIDs * * @param workItemIDs * @return */ @Override public List<TAttributeValueBean> loadByWorkItemKeys(int[] workItemIDs) { List<TAttributeValueBean> attributeValueBeansList = new ArrayList<TAttributeValueBean>(); List<TAttributeValue> tav = new ArrayList<TAttributeValue>(); if (workItemIDs == null || workItemIDs.length == 0) { return attributeValueBeansList; } Criteria criteria; List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(workItemIDs); if (workItemIDChunksList == null) { return attributeValueBeansList; } Iterator<int[]> iterator = workItemIDChunksList.iterator(); while (iterator.hasNext()) { int[] workItemIDChunk = iterator.next(); criteria = new Criteria(); criteria.addIn(WORKITEM, workItemIDChunk); try { tav.addAll(doSelect(criteria)); } catch (Exception e) { LOGGER.error( "Loading the attributeValueBeans by workItemIDs failed with " + e.getMessage()); } } return convertTorqueListToBeanList(tav); }
/** * Get the custom option type attributeValueBeans for an array of workItemIDs * * @param workItemIDs * @return */ @Override public List<TAttributeValueBean> loadLuceneCustomOptionAttributeValues(int[] workItemIDs) { List<TAttributeValueBean> attributeValueBeansList = new ArrayList<TAttributeValueBean>(); if (workItemIDs == null || workItemIDs.length == 0) { return attributeValueBeansList; } Criteria criteria; List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(workItemIDs); if (workItemIDChunksList == null) { return attributeValueBeansList; } Iterator<int[]> iterator = workItemIDChunksList.iterator(); while (iterator.hasNext()) { int[] workItemIDChunk = iterator.next(); criteria = new Criteria(); criteria.addIn(WORKITEM, workItemIDChunk); try { attributeValueBeansList.addAll(getReportCustomOptionAttributeValues(criteria)); } catch (Exception e) { LOGGER.error( "Loading the custom option type attributeValueBeans by workItemIDs failed with " + e.getMessage()); } } return attributeValueBeansList; }
/** * Whether a system option from list appears as custom attribute The reflection does not work * because an additional condition should be satisfied (no direct foreign key relationship exists) * * @param objectIDs * @param fieldID */ @Override public boolean isSystemOptionAttribute(List<Integer> objectIDs, Integer fieldID) { if (objectIDs == null || objectIDs.isEmpty()) { return false; } List attributes = null; Criteria selectCriteria; List<int[]> chunkList = GeneralUtils.getListOfChunks(objectIDs); Iterator<int[]> iterator = chunkList.iterator(); while (iterator.hasNext()) { int[] idChunk = iterator.next(); selectCriteria = new Criteria(); selectCriteria.addIn(SYSTEMOPTIONID, idChunk); selectCriteria.add(SYSTEMOPTIONTYPE, fieldID); selectCriteria.setDistinct(); try { attributes = doSelect(selectCriteria); } catch (Exception e) { LOGGER.error( "Verifiying the dependent " + "oldPersonIDs " + objectIDs.size() + " for the user picker failed with " + e.getMessage(), e); } if (attributes != null && !attributes.isEmpty()) { return true; } } return false; }
/** * Loads a filterCategoryBeans by parentIDs * * @param parentIDs * @return */ @Override public List<TReportCategoryBean> loadByParents(List<Integer> parentIDs) { List<TReportCategory> categories = new ArrayList<TReportCategory>(); if (parentIDs == null || parentIDs.isEmpty()) { return new ArrayList<TReportCategoryBean>(); } List<int[]> parentIDChunksList = GeneralUtils.getListOfChunks(parentIDs); if (parentIDChunksList != null && !parentIDChunksList.isEmpty()) { Iterator<int[]> iterator = parentIDChunksList.iterator(); while (iterator.hasNext()) { int[] parentIDsChunk = iterator.next(); Criteria criteria = new Criteria(); criteria.addIn(PARENTID, parentIDsChunk); criteria.addAscendingOrderByColumn(LABEL); try { categories.addAll(doSelect(criteria)); } catch (Exception e) { LOGGER.error( "Getting the report categories by parents " + parentIDsChunk.length + " failed with " + e.getMessage(), e); } } } return convertTorqueListToBeanList(categories); }
/** * Loads filterCategoryBeans by repository * * @param repository * @param personID * @return */ @Override public List<TReportCategoryBean> loadByRepositoryPersonProjects( Integer repository, Integer personID, List<Integer> projects) { List<TReportCategory> categories = new ArrayList<TReportCategory>(); Criteria criteria = new Criteria(); criteria.add(REPOSITORY, repository); if (personID != null) { criteria.add(CREATEDBY, personID); } if (projects != null && !projects.isEmpty()) { criteria.addIn(PROJECT, projects); } criteria.addAscendingOrderByColumn(LABEL); try { categories.addAll(doSelect(criteria)); } catch (Exception e) { LOGGER.error( "Getting filter categories by repository " + repository + " personID " + personID + " projects " + projects + " failed with " + e.getMessage(), e); } return convertTorqueListToBeanList(categories); }
/** * Retrieve a multiple objects by pk * * @param pks List of primary keys * @param dbcon the connection to use * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static List retrieveByPKs(List pks, Connection dbcon) throws TorqueException { List objs = null; if (pks == null || pks.size() == 0) { objs = new LinkedList(); } else { Criteria criteria = new Criteria(); criteria.addIn(EXAM_ID, pks); objs = doSelect(criteria, dbcon); } return objs; }
/** * Retrieve a multiple objects by pk * * @param pks List of primary keys * @param dbcon the connection to use * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a * TorqueException. */ public static List<TRoleListType> retrieveByPKs(List<ObjectKey> pks, Connection dbcon) throws TorqueException { List<TRoleListType> objs = null; if (pks == null || pks.size() == 0) { objs = new LinkedList<TRoleListType>(); } else { Criteria criteria = new Criteria(); criteria.addIn(OBJECTID, pks); objs = doSelect(criteria, dbcon); } return objs; }
/** * Gets the user picker attributes by a list of workItemIDs * * @param allWorkItemIDs * @return */ @Override public List<TAttributeValueBean> getUserPickerAttributesByWorkItems(List<Integer> workItemIDs) { List<TAttributeValueBean> attributeValueBeans = new LinkedList<TAttributeValueBean>(); if (workItemIDs == null || workItemIDs.isEmpty()) { return attributeValueBeans; } List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(workItemIDs); Iterator<int[]> chunkIterator = workItemIDChunksList.iterator(); while (chunkIterator.hasNext()) { int[] workItemIDChunk = chunkIterator.next(); Criteria crit = new Criteria(); crit.addIn(WORKITEM, workItemIDChunk); crit.add(VALIDVALUE, ValueType.SYSTEMOPTION); crit.add(SYSTEMOPTIONTYPE, SystemFields.INTEGER_PERSON); try { attributeValueBeans.addAll(convertTorqueListToBeanList(doSelect(crit))); } catch (TorqueException e) { LOGGER.error( "Loading the user pickers by workItemIDs failed with failed with " + e.getMessage()); } } return attributeValueBeans; }