List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:net.neurowork.cenatic.centraldir.workers.XMLRestWorker.java
private Capacidad importCapacidad(String xmlString, Integer capacityId) throws ParserConfigurationException, SAXException, IOException { Document doc = XmlParserUtil.createDocumentFromString(xmlString); Capacidad ret = null;/* w w w. j a v a 2 s . c o m*/ NodeList nodeLst = doc.getElementsByTagName("capacity"); for (int s = 0; s < nodeLst.getLength(); s++) { Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element elPDU = (Element) fstNode; String code = XmlParserUtil.getAttribute(elPDU, "code"); String category = XmlParserUtil.getAttribute(elPDU, "category"); NodeList fstNm = elPDU.getChildNodes(); String capacidadName = null; if (fstNm.getLength() > 0) { capacidadName = ((Node) fstNm.item(0)).getNodeValue(); Integer capId = getId(code); Capacidad capacidad = null; try { List<Capacidad> capacidades = organizacionService.findCapacidadByName(capacidadName); if (capacidades != null && capacidades.size() > 0) { capacidad = capacidades.get(0); } else { capacidad = new Capacidad(); capacidad.setName(capacidadName); if (StringUtils.hasLength(category)) capacidad.setCategoria(category); organizacionService.saveCapacidad(capacidad); } if (capId != null && capId.equals(capacityId)) { ret = capacidad; } } catch (ServiceException e) { logger.error(e.getMessage()); } } } } if (ret != null) { if (logger.isTraceEnabled()) logger.trace("Se devuelve la Capacidad: " + ret); return ret; } if (logger.isTraceEnabled()) logger.trace("No se ha encontrado la Capacidad con Id: " + capacityId); return null; }
From source file:net.neurowork.cenatic.centraldir.workers.XMLRestWorker.java
private ClasificacionOrganizacion importClasificacionOrganizacion(String xmlString, Integer id) throws ParserConfigurationException, SAXException, IOException { Document doc = XmlParserUtil.createDocumentFromString(xmlString); ClasificacionOrganizacion ret = null; NodeList nodeLst = doc.getElementsByTagName("classification"); for (int s = 0; s < nodeLst.getLength(); s++) { Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element elPDU = (Element) fstNode; String code = XmlParserUtil.getAttribute(elPDU, "code"); NodeList fstNm = elPDU.getChildNodes(); String classOrg = null; if (fstNm.getLength() > 0) { classOrg = ((Node) fstNm.item(0)).getNodeValue(); Integer orgId = getId(code); ClasificacionOrganizacion clasificacionOrganizacion = null; try { List<ClasificacionOrganizacion> lCO = organizacionService .findClasificacionOrganizacionByName(classOrg); if (lCO != null && lCO.size() > 0) { clasificacionOrganizacion = lCO.get(0); } else { clasificacionOrganizacion = new ClasificacionOrganizacion(); clasificacionOrganizacion.setName(classOrg); organizacionService.saveClasificacionOrganizacion(clasificacionOrganizacion); }/* www. jav a 2s .c om*/ if (orgId != null && orgId.equals(id)) { ret = clasificacionOrganizacion; } } catch (ServiceException e) { logger.error(e.getMessage()); } } } } return ret; }
From source file:net.cbtltd.server.ReservationService.java
private static String getNotes(PaymentTransaction paymentTransaction) { StringBuilder string = new StringBuilder(); Integer gatewayId = paymentTransaction.getGatewayId(); String message = paymentTransaction.getMessage(); Double finalAmount = paymentTransaction.getFinalAmount(); Integer partialIin = paymentTransaction.getPartialIin(); String chargeType = paymentTransaction.getChargeType(); Integer paymentMethod = paymentTransaction.getPaymentMethod(); if (gatewayId != null && !gatewayId.equals("")) { string.append("Gateway ID: " + gatewayId); }/*from w ww. j a v a 2s . com*/ if (message != null && !message.equals("")) { string.append("Message: " + message); } if (finalAmount != null) { string.append("Final amount: " + finalAmount); } if (partialIin != null) { string.append("Last four credit card digits: " + partialIin); } if (chargeType != null && !chargeType.equals("")) { string.append("Charge type: " + chargeType); } if (paymentMethod != null && !paymentMethod.equals("")) { string.append("Payment method: " + paymentMethod); } return string.toString(); }
From source file:gov.nih.nci.cabig.caaers.web.ae.CreateAdverseEventAjaxFacade.java
public AjaxOutput addReviewComment(String comment, String reportIdString) { Integer reportId = Integer.parseInt(reportIdString); // ExpeditedAdverseEventInputCommand command = (ExpeditedAdverseEventInputCommand) extractCommand(); String userId = getUserId();/*from w ww. j a v a 2s . c o m*/ // Report report = null; // for(Report r: command.getAeReport().getActiveReports()) // if(r.getId().equals(reportId)) // report = r; Report report = null; if (reportId != null || !reportId.equals("")) report = reportDao.getById(reportId); adverseEventRoutingAndReviewRepository.addReportReviewComment(report, comment, userId); return fetchPreviousComments(reportId, userId); }
From source file:com.globalsight.connector.blaise.BlaiseCreateJobHandler.java
@SuppressWarnings("rawtypes") private void dataForTable(HttpServletRequest request) throws GeneralException { HttpSession session = request.getSession(false); SessionManager sessionManager = (SessionManager) session.getAttribute(WebAppConstants.SESSION_MANAGER); int numPerPage = getNumPerPage(request); int numOfPages = getNumOfPages(totalSize, numPerPage); int pageNum = this.getCurrentPageNum(request, totalSize, numPerPage); Integer lastPageNumber = (Integer) sessionManager.getAttribute(LAST_PAGE_NUM); int sortChoice = getSortBy(request); Boolean reverseSort = Boolean.FALSE; // Compare to the last sort choice. If the sort choice has changed, // then kick them back to page one Integer lastSortChoice = (Integer) sessionManager.getAttribute(SORTING); Integer currentSortChoice = new Integer(sortChoice); reverseSort = (Boolean) sessionManager.getAttribute(REVERSE_SORT); if (reverseSort == null) { reverseSort = Boolean.FALSE; sessionManager.setAttribute(REVERSE_SORT, reverseSort); }/*from w ww . java 2s . c o m*/ Integer currentPageNumber = new Integer(pageNum); if (lastPageNumber == null) { lastPageNumber = currentPageNumber; sessionManager.setAttribute(LAST_PAGE_NUM, lastPageNumber); } // "doSort" should be passed in the url on column headers. This // is so that when another button on that page returns to the same // page, it keeps the same sort, rather than reversing it. String doSort = (String) request.getParameter(DO_SORT); if (lastSortChoice == null) { sessionManager.setAttribute(SORTING, currentSortChoice); } else if (doSort != null) { // see if the user stayed on the same page and // clicked a sort column header if (lastSortChoice.equals(currentSortChoice)) { // flip the sort direction (no auto refresh on this page) // if they clicked the same link again on the same page if (lastPageNumber.equals(currentPageNumber)) { reverseSort = new Boolean(!reverseSort.booleanValue()); sessionManager.setAttribute(REVERSE_SORT, reverseSort); } } else { reverseSort = Boolean.FALSE; sessionManager.setAttribute(REVERSE_SORT, reverseSort); } sessionManager.setAttribute(SORTING, currentSortChoice); } if (currPageEntries == null) request.setAttribute("blaiseEntryList", new ArrayList()); else request.setAttribute("blaiseEntryList", currPageEntries); request.setAttribute(PAGE_NUM, new Integer(pageNum)); request.setAttribute(NUM_PAGES, new Integer(numOfPages)); request.setAttribute(NUM_PER_PAGE, new Integer(numPerPage)); request.setAttribute(TOTAL_SIZE, new Integer(totalSize)); // remember the sortChoice and pageNumber int current = currentPageNumber.intValue(); if (current > numOfPages && numOfPages != 0) { sessionManager.setAttribute(LAST_PAGE_NUM, new Integer(current - 1)); } else { sessionManager.setAttribute(LAST_PAGE_NUM, currentPageNumber); } }
From source file:com.aurel.track.lucene.search.LuceneSearcher.java
/** * Get the list of all field names and the localized labels to look whether there is * explicit fieldName specified in the user entered search string * @return//from w ww . jav a 2s . c o m */ private static List<String> getAllFieldNames(Map<String, Integer> compositeFieldIDByFieldName, Map<String, String> fieldLabelToFieldNameMap, Locale locale) { List<String> fieldNames = new LinkedList<String>(); Map<Integer, TFieldBean> fieldBeanCache = FieldTypeManager.getInstance().getFieldBeanCache(); Map<Integer, TFieldConfigBean> fieldConfigsMap = FieldRuntimeBL.getLocalizedDefaultFieldConfigsMap(locale); Collection<TFieldBean> fieldBeans = fieldBeanCache.values(); for (TFieldBean fieldBean : fieldBeans) { Integer fieldID = fieldBean.getObjectID(); TFieldConfigBean fieldConfigBean = fieldConfigsMap.get(fieldID); IFieldTypeRT fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID); if (fieldTypeRT != null && fieldTypeRT.getValueType() == ValueType.EXTERNALID) { if (fieldTypeRT != null && fieldTypeRT.getValueType() == ValueType.EXTERNALID) { try { IExternalLookupLucene externalLookupLucene = (IExternalLookupLucene) fieldTypeRT; String[] searchableFieldNames = externalLookupLucene.getSearchableFieldNames(); if (searchableFieldNames != null) { for (String searchableFieldName : searchableFieldNames) { fieldNames.add(LuceneUtil.normalizeFieldName(searchableFieldName)); } } } catch (Exception e) { LOGGER.warn("Getting the field names for external lookup " + fieldID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } else { String fieldName = LuceneUtil.normalizeFieldName(fieldBean.getName()); if (fieldTypeRT != null && fieldTypeRT.isComposite() && compositeFieldIDByFieldName != null) { compositeFieldIDByFieldName.put(fieldName, fieldID); } fieldNames.add(fieldName); if (fieldConfigBean != null) { String fieldLabel = fieldConfigBean.getLabel(); boolean isProjectSpecificIssueNo = fieldID.equals(SystemFields.INTEGER_ISSUENO) && ApplicationBean.getInstance().getSiteBean().getProjectSpecificIDsOn(); if (EqualUtils.notEqual(fieldName, fieldLabel) || isProjectSpecificIssueNo) { if (isProjectSpecificIssueNo) { //replace localized "Issue No." label with projectSpecificIssueNo name TFieldBean issueNofieldBean = fieldBeanCache .get(SystemFields.INTEGER_PROJECT_SPECIFIC_ISSUENO); if (issueNofieldBean != null) { fieldName = issueNofieldBean.getName(); } } fieldLabelToFieldNameMap.put(fieldLabel, fieldName); } } } } return fieldNames; }
From source file:it.drwolf.ridire.session.JobManager.java
public void setValidation(CrawledResource crawledResource, Integer validationStatus) { if (crawledResource != null && validationStatus >= CrawledResource.TO_BE_VALIDATED_RESOURCE && validationStatus <= CrawledResource.NOT_VALID_RESOURCE) { crawledResource.setValidationStatus(validationStatus); if (!validationStatus.equals(CrawledResource.TO_BE_VALIDATED_RESOURCE)) { crawledResource.setValidation(CrawledResource.VALIDATED); } else {//from w w w . j a v a 2s. c om crawledResource.setValidation(CrawledResource.CHOOSEN_FOR_VALIDATION); } this.setValidationToBeSaved(true); // this.entityManager.merge(crawledResource); } // if (this.getValidatedResourcesNumber() == 0) { // this.job.setValidationStatus(Job.TO_BE_VALIDATED); // } else if (this.getValidatedResourcesNumber() < this // .getTotalSelectedResourcesNumber()) { // this.job.setValidationStatus(Job.VALIDATION_IN_PROGRESS); // } else { // this.job.setValidationStatus(this.calculateValidationResult()); // } // this.entityManager.merge(this.job); }
From source file:net.neurowork.cenatic.centraldir.workers.XMLRestWorker.java
private Asociacion importAsociacion(String xmlString, Integer associationCode) throws ParserConfigurationException, SAXException, IOException { Document doc = XmlParserUtil.createDocumentFromString(xmlString); Asociacion ret = null;//from w ww. j av a 2s .com NodeList nodeLst = doc.getElementsByTagName("association"); for (int s = 0; s < nodeLst.getLength(); s++) { Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element elPDU = (Element) fstNode; String code = XmlParserUtil.getAttribute(elPDU, "code"); String url = XmlParserUtil.getAttribute(elPDU, "url"); String icon = XmlParserUtil.getAttribute(elPDU, "icon"); NodeList fstNm = elPDU.getChildNodes(); String associationName = null; if (fstNm.getLength() > 0) { associationName = ((Node) fstNm.item(0)).getNodeValue(); Integer capId = getId(code); Asociacion association = null; try { Collection<Asociacion> associations = asociacionService.findByName(associationName); if (associations != null && associations.size() > 0) { association = associations.iterator().next(); } else { association = new Asociacion(); association.setName(associationName); association.setUrl(url); association.setIcon(icon); logger.info("Saving Asociacion: " + associationName + " url: " + url + " icon " + icon); asociacionService.save(association); } if (capId != null && capId.equals(associationCode)) { ret = association; } } catch (ServiceException e) { logger.error(e.getMessage()); } } } } return ret; }
From source file:info.ajaxplorer.synchro.SyncJob.java
protected Map<String, Object[]> applyChanges(Map<String, Object[]> changes) throws Exception { Iterator<Map.Entry<String, Object[]>> it = changes.entrySet().iterator(); Map<String, Object[]> notApplied = new TreeMap<String, Object[]>(); // Make sure to apply those one at the end Map<String, Object[]> moves = new TreeMap<String, Object[]>(); Map<String, Object[]> deletes = new TreeMap<String, Object[]>(); RestRequest rest = new RestRequest(); while (it.hasNext()) { Map.Entry<String, Object[]> entry = it.next(); String k = entry.getKey(); Object[] value = entry.getValue().clone(); Integer v = (Integer) value[0]; Node n = (Node) value[1]; if (n == null) continue; if (this.interruptRequired) { value[2] = STATUS_INTERRUPTED; notApplied.put(k, value);/*from ww w . j a va2s . c o m*/ continue; } //Thread.sleep(2000); try { if (n.isLeaf() && value[2].equals(STATUS_CONFLICT_SOLVED)) { if (v.equals(TASK_SOLVE_KEEP_MINE)) { v = TASK_REMOTE_PUT_CONTENT; } else if (v.equals(TASK_SOLVE_KEEP_THEIR)) { v = TASK_LOCAL_GET_CONTENT; } else if (v.equals(TASK_SOLVE_KEEP_BOTH)) { // COPY LOCAL FILE AND GET REMOTE COPY File origFile = new File(currentLocalFolder, k); File targetFile = new File(currentLocalFolder, k + ".mine"); InputStream in = new FileInputStream(origFile); OutputStream out = new FileOutputStream(targetFile); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); v = TASK_LOCAL_GET_CONTENT; } } if (v == TASK_LOCAL_GET_CONTENT) { Node node = new Node(Node.NODE_TYPE_ENTRY, "", null); node.setPath(k); File targetFile = new File(currentLocalFolder, k); this.logChange(Manager.getMessage("job_log_downloading"), k); try { this.updateNode(node, targetFile, n); } catch (IllegalStateException e) { if (this.statRemoteFile(node, "file", rest) == null) continue; else throw e; } if (!targetFile.exists() || targetFile.length() != Integer.parseInt(n.getPropertyValue("bytesize"))) { throw new Exception("Error while downloading file from server"); } if (n != null) { targetFile.setLastModified(n.getLastModified().getTime()); } countFilesDownloaded++; } else if (v == TASK_LOCAL_MKDIR) { File f = new File(currentLocalFolder, k); if (!f.exists()) { this.logChange(Manager.getMessage("job_log_mkdir"), k); boolean res = f.mkdirs(); if (!res) { throw new Exception("Error while creating local folder"); } countResourcesSynchronized++; } } else if (v == TASK_LOCAL_REMOVE) { deletes.put(k, value); } else if (v == TASK_REMOTE_REMOVE) { deletes.put(k, value); } else if (v == TASK_REMOTE_MKDIR) { this.logChange(Manager.getMessage("job_log_mkdir_remote"), k); Node currentDirectory = new Node(Node.NODE_TYPE_ENTRY, "", null); int lastSlash = k.lastIndexOf("/"); currentDirectory.setPath(k.substring(0, lastSlash)); RestStateHolder.getInstance().setDirectory(currentDirectory); rest.getStatusCodeForRequest(AjxpAPI.getInstance().getMkdirUri(k.substring(lastSlash + 1))); JSONObject object = rest.getJSonContent(AjxpAPI.getInstance().getStatUri(k)); if (!object.has("mtime")) { throw new Exception("Could not create remote folder"); } countResourcesSynchronized++; } else if (v == TASK_REMOTE_PUT_CONTENT) { this.logChange(Manager.getMessage("job_log_uploading"), k); Node currentDirectory = new Node(Node.NODE_TYPE_ENTRY, "", null); int lastSlash = k.lastIndexOf("/"); currentDirectory.setPath(k.substring(0, lastSlash)); RestStateHolder.getInstance().setDirectory(currentDirectory); File sourceFile = new File(currentLocalFolder, k); if (!sourceFile.exists()) { // Silently ignore, or it will continously try to reupload it. continue; } boolean checked = false; if (sourceFile.length() == 0) { rest.getStringContent(AjxpAPI.getInstance().getMkfileUri(sourceFile.getName())); } else { checked = this.synchronousUP(currentDirectory, sourceFile, n); } if (!checked) { JSONObject object = rest.getJSonContent(AjxpAPI.getInstance().getStatUri(n.getPath(true))); if (!object.has("size") || object.getInt("size") != Integer.parseInt(n.getPropertyValue("bytesize"))) { throw new Exception("Could not upload file to the server"); } } countFilesUploaded++; } else if (v == TASK_DO_NOTHING && value[2] == STATUS_CONFLICT) { // Recheck that it's a real conflict? this.logChange(Manager.getMessage("job_log_conflict"), k); notApplied.put(k, value); countConflictsDetected++; } else if (v == TASK_LOCAL_MOVE_FILE || v == TASK_REMOTE_MOVE_FILE) { moves.put(k, value); } } catch (FileNotFoundException ex) { ex.printStackTrace(); countResourcesErrors++; // Do not put in the notApplied again, otherwise it will indefinitely happen. } catch (Exception e) { Logger.getRootLogger().error("Synchro", e); countResourcesErrors++; value[2] = STATUS_ERROR; notApplied.put(k, value); } } // APPLY MOVES Iterator<Map.Entry<String, Object[]>> mIt = moves.entrySet().iterator(); while (mIt.hasNext()) { Map.Entry<String, Object[]> entry = mIt.next(); String k = entry.getKey(); Object[] value = entry.getValue().clone(); Integer v = (Integer) value[0]; Node n = (Node) value[1]; if (this.interruptRequired) { value[2] = STATUS_INTERRUPTED; notApplied.put(k, value); continue; } try { if (v == TASK_LOCAL_MOVE_FILE && value.length == 4) { this.logChange("Moving resource locally", k); Node dest = (Node) value[3]; File origFile = new File(currentLocalFolder, n.getPath()); if (!origFile.exists()) { // Cannot move a non-existing file! Download instead! value[0] = TASK_LOCAL_GET_CONTENT; value[1] = dest; value[2] = STATUS_TODO; notApplied.put(dest.getPath(true), value); continue; } File destFile = new File(currentLocalFolder, dest.getPath()); origFile.renameTo(destFile); if (!destFile.exists()) { throw new Exception("Error while creating " + dest.getPath()); } countResourcesSynchronized++; } else if (v == TASK_REMOTE_MOVE_FILE && value.length == 4) { this.logChange("Moving resource remotely", k); Node dest = (Node) value[3]; JSONObject object = rest.getJSonContent(AjxpAPI.getInstance().getStatUri(n.getPath())); if (!object.has("size")) { value[0] = TASK_REMOTE_PUT_CONTENT; value[1] = dest; value[2] = STATUS_TODO; notApplied.put(dest.getPath(true), value); continue; } rest.getStatusCodeForRequest(AjxpAPI.getInstance().getRenameUri(n, dest)); object = rest.getJSonContent(AjxpAPI.getInstance().getStatUri(dest.getPath())); if (!object.has("size")) { throw new Exception("Could not move remote file to " + dest.getPath()); } countResourcesSynchronized++; } } catch (FileNotFoundException ex) { ex.printStackTrace(); countResourcesErrors++; // Do not put in the notApplied again, otherwise it will indefinitely happen. } catch (Exception e) { Logger.getRootLogger().error("Synchro", e); countResourcesErrors++; value[2] = STATUS_ERROR; notApplied.put(k, value); } } // APPLY DELETES Iterator<Map.Entry<String, Object[]>> dIt = deletes.entrySet().iterator(); while (dIt.hasNext()) { Map.Entry<String, Object[]> entry = dIt.next(); String k = entry.getKey(); Object[] value = entry.getValue().clone(); Integer v = (Integer) value[0]; //Node n = (Node)value[1]; if (this.interruptRequired) { value[2] = STATUS_INTERRUPTED; notApplied.put(k, value); continue; } try { if (v == TASK_LOCAL_REMOVE) { this.logChange(Manager.getMessage("job_log_rmlocal"), k); File f = new File(currentLocalFolder, k); if (f.exists()) { boolean res = f.delete(); if (!res) { throw new Exception("Error while removing local resource"); } countResourcesSynchronized++; } } else if (v == TASK_REMOTE_REMOVE) { this.logChange(Manager.getMessage("job_log_rmremote"), k); Node currentDirectory = new Node(Node.NODE_TYPE_ENTRY, "", null); int lastSlash = k.lastIndexOf("/"); currentDirectory.setPath(k.substring(0, lastSlash)); RestStateHolder.getInstance().setDirectory(currentDirectory); rest.getStatusCodeForRequest(AjxpAPI.getInstance().getDeleteUri(k)); JSONObject object = rest.getJSonContent(AjxpAPI.getInstance().getStatUri(k)); if (object.has("mtime")) { // Still exists, should be empty! throw new Exception("Could not remove the resource from the server"); } countResourcesSynchronized++; } } catch (FileNotFoundException ex) { ex.printStackTrace(); countResourcesErrors++; // Do not put in the notApplied again, otherwise it will indefinitely happen. } catch (Exception e) { Logger.getRootLogger().error("Synchro", e); countResourcesErrors++; value[2] = STATUS_ERROR; notApplied.put(k, value); } } rest.release(); return notApplied; }
From source file:com.aurel.track.accessControl.AccessBeans.java
/** * Verifies if a person has one of the specific rights for a list of * workItemBeans. Specific rights means either a role with any arrRights or * a RACI role If the person does not have the right, the workItemBean is * removed form the list//w w w .j a va2 s. c o m * * @param personID * , the id of the person * @param workItemBeans * , list of reportBean which needs o be checked * @param editFlagNeeded * whether the edit flag should be set for workItems * */ public static List<TWorkItemBean> filterWorkItemBeans(Integer personID, List<TWorkItemBean> workItemBeans, boolean editFlagNeeded) { List<TWorkItemBean> workItemBeansPassed = new LinkedList<TWorkItemBean>(); Set<Integer> workItemIDsPassed = new HashSet<Integer>(); Map<Integer, TWorkItemBean> notEditableMap = new HashMap<Integer, TWorkItemBean>(); Date start = null; if (LOGGER.isInfoEnabled()) { start = new Date(); } if (personID == null || workItemBeans == null || workItemBeans.isEmpty()) { LOGGER.debug("PersonID " + personID + " and number of items " + workItemBeans.size()); return new LinkedList<TWorkItemBean>(); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Person " + personID + ": total number of items before filter " + workItemBeans.size()); } List<Integer> meAndSubstitutedIDs = getMeAndSubstituted(personID); /** * First loop: pass the direct RACI (my) items */ Iterator<TWorkItemBean> workItemBeansItr = workItemBeans.iterator(); while (workItemBeansItr.hasNext()) { TWorkItemBean workItemBean = workItemBeansItr.next(); Integer workItemID = workItemBean.getObjectID(); Integer originatorID = workItemBean.getOriginatorID(); if (workItemBean.isAccessLevelFlag() && !originatorID.equals(personID)) { // check the access level (private) flag: independently of any // other assigned roles or RACI roles // a workItem with accessLevel set to ACCESS_LEVEL_PRIVATE is // readable only when the person logged is the originator if (LOGGER.isDebugEnabled()) { LOGGER.debug("Remove item " + workItemID + ": private issue"); } workItemBeansItr.remove(); continue; } Integer responsibleID = workItemBean.getResponsibleID(); Integer managerID = workItemBean.getOwnerID(); // pass the workItem and set as editable if it is my item if (meAndSubstitutedIDs.contains(originatorID) || meAndSubstitutedIDs.contains(managerID) || meAndSubstitutedIDs.contains(responsibleID)) { if (LOGGER.isTraceEnabled()) { LOGGER.trace(addItem + workItemID + ": direct RACI"); } if (editFlagNeeded) { workItemBean.setEditable(true); } workItemBeansPassed.add(workItemBean); workItemIDsPassed.add(workItemBean.getObjectID()); workItemBeansItr.remove(); } } int noOfDirectRACIItems = workItemBeansPassed.size(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Number of direct RACI items: " + noOfDirectRACIItems + ", " + workItemBeans.size() + remaining); } /** * Second loop: pass by project roles for person */ List<Integer> meAndSubstitutedAndGroups = null; int noOfProjectRightItems = 0; if (!workItemBeans.isEmpty()) { meAndSubstitutedAndGroups = getMeAndSubstitutedAndGroups(personID); Set<Integer> projectsDirectlyInvolved = new HashSet<Integer>(); for (TWorkItemBean workItemBean : workItemBeans) { Integer projectID = workItemBean.getProjectID(); projectsDirectlyInvolved.add(projectID); } List<TProjectBean> projectBeansInvolved = ProjectBL .loadByProjectIDs(GeneralUtils.createListFromSet(projectsDirectlyInvolved)); Map<Integer, TProjectBean> involvedProjectsMap = new HashMap<Integer, TProjectBean>(); Map<Integer, Integer> childToParentProject = ProjectBL.getChildToParentMap(projectBeansInvolved, involvedProjectsMap); Integer[] ancestorProjects = GeneralUtils.createIntegerArrFromCollection(involvedProjectsMap.keySet()); // get the array with groupIDs the person is member of (the personID // is also contained) // projects-issueTypes with project admin right for person // projects/issueTypes with projectAdmin roles // projects/issueTypes with read any roles int[] readAnyRights = new int[] { AccessFlagIndexes.READANYTASK, AccessFlagIndexes.PROJECTADMIN }; // projects-issueTypes with read right for person Map<Integer, Set<Integer>> projectToIssueTypesWithReadRight = getProjectsToIssueTypesWithRoleForPerson( meAndSubstitutedAndGroups, ancestorProjects, readAnyRights); // projects-issueTypes with edit right for person Map<Integer, Set<Integer>> projectToIssueTypesWithEditRight = null; if (editFlagNeeded) { int[] editAnyRights; editAnyRights = new int[] { AccessFlagIndexes.MODIFYANYTASK, AccessFlagIndexes.PROJECTADMIN }; projectToIssueTypesWithEditRight = getProjectsToIssueTypesWithRoleForPerson( meAndSubstitutedAndGroups, ancestorProjects, editAnyRights); } workItemBeansItr = workItemBeans.iterator(); while (workItemBeansItr.hasNext()) { TWorkItemBean workItemBean = workItemBeansItr.next(); Integer workItemID = workItemBean.getObjectID(); Integer projectID = workItemBean.getProjectID(); Integer issueType = workItemBean.getListTypeID(); // leave the archived/deleted workItems only if the person is // project admin if (editFlagNeeded && hasExplicitRight(personID, workItemID, projectID, issueType, projectToIssueTypesWithEditRight, childToParentProject, "edit")) { // explicit edit right: pass and set as editable if (LOGGER.isTraceEnabled()) { String projectName = null; ILabelBean projectBean = LookupContainer.getProjectBean(projectID); if (projectBean != null) { projectName = projectBean.getLabel(); } LOGGER.trace(addItem + workItemID + " for user " + personID + ": 'modify any' project right for project " + projectID + " (" + projectName + ")"); } if (!workItemIDsPassed.contains(workItemBean.getObjectID())) { workItemIDsPassed.add(workItemBean.getObjectID()); workItemBeansPassed.add(workItemBean); workItemBean.setEditable(true); } workItemBeansItr.remove(); } else { if (hasExplicitRight(personID, workItemID, projectID, issueType, projectToIssueTypesWithReadRight, childToParentProject, "read")) { // explicit read right: pass but do not set as editable if (!workItemIDsPassed.contains(workItemBean.getObjectID())) { workItemIDsPassed.add(workItemBean.getObjectID()); workItemBeansPassed.add(workItemBean); if (LOGGER.isTraceEnabled()) { String projectName = null; ILabelBean projectBean = LookupContainer.getProjectBean(projectID); if (projectBean != null) { projectName = projectBean.getLabel(); } LOGGER.trace(addItem + workItemID + ": 'read any' project right for project " + projectID + " (" + projectName + ")"); } } if (editFlagNeeded) { // although it is readable but not editable though // project level roles: if edit flag is needed do // not remove // to remain in set by searching for indirect RACI // and possibly set it editable later notEditableMap.put(workItemID, workItemBean); } else { // remove to do not take care about in next loops workItemBeansItr.remove(); } } } } noOfProjectRightItems = workItemBeansPassed.size() - noOfDirectRACIItems; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Number of items in projects with role for person: " + noOfProjectRightItems + ", " + workItemBeans.size() + remaining); } } /** * Third loop: pass by indirect RACI persons: responsible through group, * reciprocal RACI through group membership in the same group */ int noOfIndirectRACIItems = 0; Set<Integer> reciprocOriginators = null; if (!workItemBeans.isEmpty()) { Map<Integer, List<Integer>> reciprocGroups = getRaciprocGroupsMap(meAndSubstitutedIDs); List<Integer> allGroupsForPerson = reciprocGroups.get(ALL_PERSONGROUPS); List<TPersonBean> originatorsInReciprocGroups = PersonBL .getIndirectPersons(reciprocGroups.get(SystemFields.ORIGINATOR), false, null); reciprocOriginators = GeneralUtils.createIntegerSetFromIntegerList( GeneralUtils.createIntegerListFromBeanList(originatorsInReciprocGroups)); List<TPersonBean> managersInReciprocGroups = PersonBL .getIndirectPersons(reciprocGroups.get(SystemFields.MANAGER), false, null); Set<Integer> reciprocManagers = GeneralUtils.createIntegerSetFromIntegerList( GeneralUtils.createIntegerListFromBeanList(managersInReciprocGroups)); List<TPersonBean> responsiblesInReciprocGroups = PersonBL .getIndirectPersons(reciprocGroups.get(SystemFields.RESPONSIBLE), false, null); Set<Integer> reciprocResponsibles = GeneralUtils.createIntegerSetFromIntegerList( GeneralUtils.createIntegerListFromBeanList(responsiblesInReciprocGroups)); workItemBeansItr = workItemBeans.iterator(); while (workItemBeansItr.hasNext()) { TWorkItemBean workItemBean = workItemBeansItr.next(); Integer workItemID = workItemBean.getObjectID(); Integer originatorID = workItemBean.getOriginatorID(); Integer responsibleID = workItemBean.getResponsibleID(); Integer managerID = workItemBean.getOwnerID(); if ((allGroupsForPerson != null && allGroupsForPerson.contains(responsibleID)) || reciprocOriginators.contains(originatorID) || reciprocManagers.contains(managerID) || reciprocResponsibles.contains(responsibleID)) { // indirect RACI: set as editable if (LOGGER.isTraceEnabled()) { if (allGroupsForPerson != null && allGroupsForPerson.contains(responsibleID)) { LOGGER.trace(addItem + workItemID + ": responsible through group"); } else { if (reciprocOriginators.contains(originatorID)) { LOGGER.trace(addItem + workItemID + ": reciproc originator through group"); } else { if (reciprocManagers.contains(managerID)) { LOGGER.trace(addItem + workItemID + ": reciproc manager through group"); } else { if (reciprocResponsibles.contains(responsibleID)) { LOGGER.trace(addItem + workItemID + ": reciproc responsible through group"); } } } } } // set it to editable anyway but add to the passed list if // it was not yet added as read only (to avoid adding the // item two times) workItemBeansItr.remove(); if (!workItemIDsPassed.contains(workItemBean.getObjectID())) { workItemIDsPassed.add(workItemBean.getObjectID()); workItemBeansPassed.add(workItemBean); } if (editFlagNeeded) { workItemBean.setEditable(true); if (notEditableMap.containsKey(workItemID)) { notEditableMap.remove(workItemID); } } } } noOfIndirectRACIItems = workItemBeansPassed.size() - noOfDirectRACIItems - noOfProjectRightItems; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Number of indirect RACI items: " + noOfIndirectRACIItems + ", " + workItemBeans.size() + remaining); } } /** * Fourth loop: pass by watcher person */ int noOfWatcherItems = 0; if (!workItemBeans.isEmpty()) { List<Integer> workItemIDs = GeneralUtils.createIntegerListFromBeanList(workItemBeans); List<TNotifyBean> watcherBeans = ConsInfBL.getByWorkItemsAndPersons(workItemIDs, meAndSubstitutedAndGroups); if (watcherBeans != null && !watcherBeans.isEmpty()) { Set<Integer> consultedPersons = new HashSet<Integer>(); Set<Integer> informedPersons = new HashSet<Integer>(); for (TNotifyBean notifyBean : watcherBeans) { Integer workItemID = notifyBean.getWorkItem(); String raciRole = notifyBean.getRaciRole(); if (raciRole != null) { if (RaciRole.CONSULTANT.equals(raciRole)) { consultedPersons.add(workItemID); } else { if (RaciRole.INFORMANT.equals(raciRole)) { informedPersons.add(workItemID); } } } } workItemBeansItr = workItemBeans.iterator(); while (workItemBeansItr.hasNext()) { TWorkItemBean workItemBean = workItemBeansItr.next(); Integer workItemID = workItemBean.getObjectID(); if (consultedPersons.contains(workItemID)) { // consulted: pass and set editable if (LOGGER.isTraceEnabled()) { LOGGER.trace(addItem + workItemID + ": consulted"); } // set it to editable anyway but add to the passed list // if it was not yet added as read only (to avoid adding // the item two times) workItemBeansItr.remove(); if (!workItemIDsPassed.contains(workItemBean.getObjectID())) { workItemIDsPassed.add(workItemBean.getObjectID()); workItemBeansPassed.add(workItemBean); } if (editFlagNeeded) { workItemBean.setEditable(true); if (notEditableMap.containsKey(workItemID)) { notEditableMap.remove(workItemID); } } } else { // not already "only" readable through project roles if (informedPersons.contains(workItemID)) { if (!workItemIDsPassed.contains(workItemBean.getObjectID())) { workItemIDsPassed.add(workItemBean.getObjectID()); workItemBeansPassed.add(workItemBean); } // informed: pass but do not set as editable // although it is readable but not editable: if edit // flag is needed do not remove // to remain in set by searching for indirect RACI // and possibly set it editable later if (LOGGER.isTraceEnabled()) { LOGGER.trace(addItem + workItemID + ": informed"); } if (editFlagNeeded) { // although it is readable but not editable: if // edit flag is needed do not remove // to remain in set by searching for indirect // RACI and possibly set it editable later notEditableMap.put(workItemID, workItemBean); } else { // remove to do not take care about in next // loops workItemBeansItr.remove(); } } } } } noOfWatcherItems = workItemBeansPassed.size() - noOfDirectRACIItems - noOfProjectRightItems - noOfIndirectRACIItems; if (LOGGER.isDebugEnabled()) { LOGGER.debug( "Number of watcher items " + noOfWatcherItems + ", " + workItemBeans.size() + remaining); } } /** * Fifth loop: pass by on behalf persons */ int noOfOnBehalfItems = 0; if (!workItemBeans.isEmpty()) { List<Integer> workItemIDs = GeneralUtils.createIntegerListFromBeanList(workItemBeans); List<TAttributeValueBean> userPickerAttributes = AttributeValueBL .getUserPickerAttributesByWorkItems(workItemIDs); Map<Integer, List<TAttributeValueBean>> userPickerMap = null; if (userPickerAttributes != null && !userPickerAttributes.isEmpty()) { userPickerMap = new HashMap<Integer, List<TAttributeValueBean>>(); for (TAttributeValueBean attributeValueBean : userPickerAttributes) { Integer workItemID = attributeValueBean.getWorkItem(); List<TAttributeValueBean> attributeValueBeansList = userPickerMap.get(workItemID); if (attributeValueBeansList == null) { attributeValueBeansList = new LinkedList<TAttributeValueBean>(); userPickerMap.put(workItemID, attributeValueBeansList); } attributeValueBeansList.add(attributeValueBean); } workItemBeansItr = workItemBeans.iterator(); while (workItemBeansItr.hasNext()) { TWorkItemBean workItemBean = workItemBeansItr.next(); Integer workItemID = workItemBean.getObjectID(); Set<Integer> onBehalfOfSet = null; List<TAttributeValueBean> attributeValueBeansList = userPickerMap.get(workItemID); if (attributeValueBeansList != null) { for (TAttributeValueBean attributeValueBean : attributeValueBeansList) { Integer fieldID = attributeValueBean.getField(); IFieldTypeRT fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID); if (fieldTypeRT.isUserPicker()) { UserPickerRT userPickerRT = (UserPickerRT) fieldTypeRT; if (userPickerRT.inheritsOriginatorRole()) { if (onBehalfOfSet == null) { onBehalfOfSet = new HashSet<Integer>(); } onBehalfOfSet.add(attributeValueBean.getSystemOptionID()); } } } } Set<Integer> onBehalfPersonsAll = new HashSet<Integer>(); Set<Integer> onBehalfPersonsDirect = getOnBehalfPersonsDirect(onBehalfOfSet, onBehalfPersonsAll); if (hasCommon(meAndSubstitutedIDs, onBehalfPersonsAll) || hasCommon(reciprocOriginators, onBehalfPersonsDirect)) { // indirect RACI: set as editable if (LOGGER.isDebugEnabled()) { LOGGER.debug(addItem + workItemID + ": on behalf of"); } // set it to editable anyway but add to the passed list // if it was not yet added as read only (to avoid adding // the item two times) workItemBeansItr.remove(); if (!workItemIDsPassed.contains(workItemBean.getObjectID())) { workItemIDsPassed.add(workItemBean.getObjectID()); workItemBeansPassed.add(workItemBean); } if (editFlagNeeded) { workItemBean.setEditable(true); if (notEditableMap.containsKey(workItemID)) { notEditableMap.remove(workItemID); } } } } } noOfOnBehalfItems = workItemBeansPassed.size() - noOfDirectRACIItems - noOfProjectRightItems - noOfIndirectRACIItems - noOfWatcherItems; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Number of in behalf of person items " + noOfOnBehalfItems + ", " + workItemBeans.size() + remaining); } } if (LOGGER.isDebugEnabled()) { // workItemBeans contain the // 1. not readable and // 2. might contain also the only readable but not editable items // (these items are passed already) // The difference is the really not readable items LOGGER.debug("Number of items remained with no read right " + (workItemBeans.size() - notEditableMap.size())); LOGGER.debug("Number of items passed " + workItemBeansPassed.size()); Date end = new Date(); LOGGER.debug("Removing not accessible items lasted " + Long.toString(end.getTime() - start.getTime()) + " ms"); } return workItemBeansPassed; }