List of usage examples for java.util ListIterator remove
void remove();
From source file:org.springframework.statemachine.support.DefaultStateMachineExecutor.java
private synchronized boolean processDeferList() { if (log.isDebugEnabled()) { log.debug("Process defer list, size=" + deferList.size()); }//from ww w .j a v a2 s.co m ListIterator<Message<E>> iterator = deferList.listIterator(); State<S, E> currentState = stateMachine.getState(); while (iterator.hasNext()) { Message<E> event = iterator.next(); if (currentState.shouldDefer(event)) { // if current state still defers, just continue with others continue; } for (Transition<S, E> transition : transitions) { State<S, E> source = transition.getSource(); Trigger<S, E> trigger = transition.getTrigger(); if (source.equals(currentState)) { if (trigger != null && trigger.evaluate(new DefaultTriggerContext<S, E>(event.getPayload()))) { triggerQueue.add(new TriggerQueueItem(trigger, event)); iterator.remove(); // bail out when first deferred message is causing a trigger to fire return true; } } } } return false; }
From source file:ipnat.skel.Strahler.java
/** * This method is called when the plugin is loaded. * * @param arg//from ww w . ja v a 2s . c o m * the arguments as specified in {@code plugins.config} * */ @Override public void run(final String arg) { // Retrieve analysis image and its ROI srcImp = WindowManager.getCurrentImage(); if (!validRequirements(srcImp)) return; title = srcImp.getTitle(); rootRoi = srcImp.getRoi(); validRootRoi = (rootRoi != null && rootRoi.getType() == Roi.RECTANGLE); // TODO: 3D Roots are special. We need to: // 1) Check if ROI is associated with all slices or just one // 2) Ignore counts above/below the ROI, as needed // 3) Extend ip operations to stack if (srcImp.getNSlices() > 1) { final String warning = "3D images are currently supported with the following limitations:\n" + " - 'Root-protecting' ROIs are not yet supported\n" + " - Lengths are estimated from Z-projections\n \n" + "These issues will be addressed in future releases."; if (IJ.macroRunning()) IJ.log(warning); else IJ.showMessage("Warning", warning); validRootRoi = false; } // Retrieve grayscale image for intensity-based pruning of skel. loops if (!getSettings()) return; // Work on a skeletonized copy since we'll be modifing the image if (rootRoi != null) srcImp.killRoi(); final ImagePlus imp = srcImp.duplicate(); if (rootRoi != null) srcImp.setRoi(rootRoi); ip = imp.getProcessor(); skeletonizeWithoutHermits(imp); // Initialize ResultsTable: main and detailed info final ResultsTable rt = Utils.getTable(STRAHLER_TABLE); final ResultsTable logrt = Utils.getTable(VERBOSE_TABLE); // Analyze root ImagePlus rootImp; ImageProcessor rootIp = null; SkeletonResult rootResult = null; ArrayList<Point> rootEndpointsList = null; int nRootEndpoints = 0, nRootJunctions = 0; if (validRootRoi && verbose) { // Duplicate entire canvas. Ignore tree(s) outside ROI rootImp = imp.duplicate(); rootIp = rootImp.getProcessor(); rootIp.setValue(0.0); rootIp.fillOutside(rootRoi); // Get root properties final AnalyzeSkeleton_ root = new AnalyzeSkeleton_(); root.setup("", rootImp); rootResult = root.run(pruneChoice, false, false, grayscaleImp, true, false); rootImp.flush(); // We assume ROI contains only end-point branches, slab voxels and // no junction points. We'll thus remove end-points at ROI // boundaries nRootJunctions = sum(rootResult.getJunctions()); rootEndpointsList = rootResult.getListOfEndPoints(); final ListIterator<Point> it = rootEndpointsList.listIterator(); final Rectangle r = rootRoi.getBounds(); while (it.hasNext()) { final Point p = it.next(); if (p.x == r.x || p.y == r.y || p.x == (int) (r.x + r.getWidth() - 1) || p.y == (int) (r.y + r.getHeight() - 1)) it.remove(); } rootResult.setListOfEndPoints(rootEndpointsList); nRootEndpoints = rootEndpointsList.size(); } // Initialize display images. Use Z-projections to populate // iteration stack when dealing with 3D skeletons final int nSlices = imp.getNSlices(); ZProjector zp = null; final ImageStack iterationStack = new ImageStack(imp.getWidth(), imp.getHeight()); if (nSlices > 1) { zp = new ZProjector(imp); zp.setMethod(ZProjector.MAX_METHOD); zp.setStartSlice(1); zp.setStopSlice(nSlices); } // Initialize AnalyzeSkeleton_ final AnalyzeSkeleton_ as = new AnalyzeSkeleton_(); as.setup("", imp); // Perform the iterative pruning int order = 1, nEndpoints = 0, nJunctions = 0, nJunctions2 = 0; ArrayList<Point> endpointsList = null, junctionsList = null; String errorMsg = ""; do { IJ.showStatus("Retrieving measurements for order " + order + "..."); IJ.showProgress(order, getMaxOrder()); // (Re)skeletonize image if (order > 1) skeletonizeWithoutHermits(imp); // Get properties of loop-resolved tree(s) final SkeletonResult sr = as.run(pruneChoice, false, false, grayscaleImp, true, false); nEndpoints = sum(sr.getEndPoints()); nJunctions = sum(sr.getJunctions()); if (order == 1) { // Remember initial properties endpointsList = sr.getListOfEndPoints(); junctionsList = sr.getListOfJunctionVoxels(); // Do not include root in 1st order calculations nEndpoints -= nRootEndpoints; nJunctions -= nRootJunctions; } // Is it worth proceeding? if (nEndpoints == 0 || nJunctions2 == nJunctions) { errorMsg = "Error! Iteration " + order + " aborted: "; errorMsg += (nEndpoints == 0) ? "No end-poins found" : "Unsolved loop(s) detected"; break; } // Add current tree(s) to debug animation ImageProcessor ipd; if (nSlices > 1) { zp.doProjection(); ipd = zp.getProjection().getProcessor(); } else { ipd = ip.duplicate(); } iterationStack.addSlice("Order " + IJ.pad(order, 2), ipd); // Report properties of pruned structures if (verbose) { logrt.incrementCounter(); logrt.addValue("Image", title); logrt.addValue("Structure", "Skel. at iteration " + Integer.toString(order)); logrt.addValue("Notes", errorMsg); logrt.addValue("# Trees", sr.getNumOfTrees()); logrt.addValue("# Branches", sum(sr.getBranches())); logrt.addValue("# End-points", nEndpoints); logrt.addValue("# Junctions", nJunctions); logrt.addValue("# Triple points", sum(sr.getTriples())); logrt.addValue("# Quadruple points", sum(sr.getQuadruples())); logrt.addValue("Average branch length", average(sr.getAverageBranchLength())); } // Remember main results nJunctions2 = nJunctions; // Eliminate end-points as.run(pruneChoice, true, false, grayscaleImp, true, false, rootRoi); } while (order++ <= getMaxOrder() && nJunctions > 0); // Set counter to the de facto order order -= 1; // Append root properties to log table if (validRootRoi && verbose) { // Check if ROI contains unexpected structures final String msg = (nRootJunctions > 0) ? "Warning: ROI contains ramified root(s)" : "Root-branches inferred from ROI"; logrt.incrementCounter(); logrt.addValue("Image", title); logrt.addValue("Structure", "Root"); logrt.addValue("Notes", msg); logrt.addValue("# Trees", rootResult.getNumOfTrees()); logrt.addValue("# Branches", sum(rootResult.getBranches())); logrt.addValue("# End-points", nRootEndpoints); logrt.addValue("# Junctions", nRootJunctions); logrt.addValue("# Triple points", sum(rootResult.getTriples())); logrt.addValue("# Quadruple points", sum(rootResult.getQuadruples())); logrt.addValue("Average branch length", average(rootResult.getAverageBranchLength())); } // Safety check if (iterationStack == null || iterationStack.getSize() < 1) { error("Enable \"detailed\" mode and check " + VERBOSE_TABLE + " for details."); return; } // Create iteration stack final Calibration cal = srcImp.getCalibration(); final ImagePlus imp2 = new ImagePlus("StrahlerIteration_" + title, iterationStack); imp2.setCalibration(cal); if (outIS) { if (validRootRoi) { iterationStack.addSlice("Root", rootIp); paintPoints(iterationStack, rootEndpointsList, 255, "Root end-points"); imp2.setRoi(rootRoi); } paintPoints(iterationStack, endpointsList, 255, "End-points"); paintPoints(iterationStack, junctionsList, 255, "Junction-points"); } // Generate Strahler mask zp = new ZProjector(imp2); zp.setMethod(ZProjector.SUM_METHOD); zp.setStartSlice(1); zp.setStopSlice(order); zp.doProjection(); final ImageProcessor ip3 = zp.getProjection().getProcessor().convertToShortProcessor(false); clearPoints(ip3, junctionsList); // disconnect branches ip3.multiply(1 / 255.0); // map intensities to Strahler orders final ImagePlus imp3 = new ImagePlus("StrahlerMask_" + title, ip3); imp3.setCalibration(cal); // Measure segmented orders double prevNbranches = Double.NaN; for (int i = 1; i <= order; i++) { // Segment branches by order final ImagePlus maskImp = imp3.duplicate(); // Calibration is // retained IJ.setThreshold(maskImp, i, i); IJ.run(maskImp, "Convert to Mask", ""); // Analyze segmented order final AnalyzeSkeleton_ maskAs = new AnalyzeSkeleton_(); maskAs.setup("", maskImp); final SkeletonResult maskSr = maskAs.run(pruneChoice, false, false, grayscaleImp, true, false); maskImp.flush(); // Since all branches are disconnected at this stage, the n. of // branches is // the same as the # the trees unless zero-branches trees exist, // i.e., trees // with no slab voxels (defined by just an end-point). We will // ignore those // trees if the user requested it final int nBranches = (erodeIsolatedPixels) ? sum(maskSr.getBranches()) : maskSr.getNumOfTrees(); // Log measurements rt.incrementCounter(); rt.addValue("Image", title); rt.addValue("Strahler Order", i); rt.addValue("# Branches", nBranches); rt.addValue("Ramification ratios", prevNbranches / nBranches); rt.addValue("Average branch length", average(maskSr.getAverageBranchLength())); rt.addValue("Unit", cal.getUnit()); String noteMsg = ""; if (i == 1) { noteMsg = (erodeIsolatedPixels) ? "Ignoring" : "Including"; noteMsg += " single-point arbors..."; } rt.addValue("Notes", noteMsg); // Remember results for previous order prevNbranches = nBranches; } // Append any errors to last row rt.addValue("Notes", errorMsg); // Display outputs if (!tabular) { if (outIS) imp2.show(); ip3.setMinAndMax(0, order); ColorMaps.applyMagmaColorMap(imp3, 200, false); if (validRootRoi) imp3.setRoi(rootRoi); imp3.show(); addCalibrationBar(imp3, Math.min(order, 5), "Black"); } if (verbose) logrt.show(VERBOSE_TABLE); rt.show(STRAHLER_TABLE); IJ.showProgress(0, 0); IJ.showTime(imp, imp.getStartTime(), "Strahler Analysis concluded... "); imp.flush(); }
From source file:org.apache.fop.layoutmgr.FlowLayoutManager.java
/** {@inheritDoc} */ @Override/*from www . j a va 2 s . c o m*/ public List<KnuthElement> getChangedKnuthElements(List oldList, int alignment) { ListIterator<KnuthElement> oldListIterator = oldList.listIterator(); KnuthElement returnedElement; List<KnuthElement> returnedList = new LinkedList<KnuthElement>(); List<KnuthElement> returnList = new LinkedList<KnuthElement>(); KnuthElement prevElement = null; KnuthElement currElement = null; int fromIndex = 0; // "unwrap" the Positions stored in the elements KnuthElement oldElement; while (oldListIterator.hasNext()) { oldElement = oldListIterator.next(); if (oldElement.getPosition() instanceof NonLeafPosition) { // oldElement was created by a descendant of this FlowLM oldElement.setPosition((oldElement.getPosition()).getPosition()); } else { // thisElement was created by this FlowLM, remove it oldListIterator.remove(); } } // reset the iterator oldListIterator = oldList.listIterator(); while (oldListIterator.hasNext()) { currElement = oldListIterator.next(); if (prevElement != null && prevElement.getLayoutManager() != currElement.getLayoutManager()) { // prevElement is the last element generated by the same LM BlockLevelLayoutManager prevLM = (BlockLevelLayoutManager) prevElement.getLayoutManager(); BlockLevelLayoutManager currLM = (BlockLevelLayoutManager) currElement.getLayoutManager(); returnedList.addAll(prevLM.getChangedKnuthElements( oldList.subList(fromIndex, oldListIterator.previousIndex()), alignment)); fromIndex = oldListIterator.previousIndex(); // there is another block after this one if (prevLM.mustKeepWithNext() || currLM.mustKeepWithPrevious()) { // add an infinite penalty to forbid a break between blocks returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new Position(this), false)); } else if (!ListUtil.getLast(returnedList).isGlue()) { // add a null penalty to allow a break between blocks returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); } } prevElement = currElement; } if (currElement != null) { BlockLevelLayoutManager currLM = (BlockLevelLayoutManager) currElement.getLayoutManager(); returnedList .addAll(currLM.getChangedKnuthElements(oldList.subList(fromIndex, oldList.size()), alignment)); } // "wrap" the Position stored in each element of returnedList // and add elements to returnList ListIterator<KnuthElement> listIter = returnedList.listIterator(); while (listIter.hasNext()) { returnedElement = listIter.next(); if (returnedElement.getLayoutManager() != this) { returnedElement.setPosition(new NonLeafPosition(this, returnedElement.getPosition())); } returnList.add(returnedElement); } return returnList; }
From source file:org.kuali.kra.award.web.struts.action.AwardActionsAction.java
/** * Called to delete award sync changes./*from www .j a va2 s . c om*/ */ public ActionForward deleteChanges(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { AwardForm awardForm = (AwardForm) form; Award award = awardForm.getAwardDocument().getAward(); ListIterator<AwardSyncChange> iter = award.getSyncChanges().listIterator(); while (iter.hasNext()) { AwardSyncChange change = iter.next(); if (change.isDelete()) { getBusinessObjectService().delete(change); iter.remove(); } } return mapping.findForward(Constants.MAPPING_AWARD_BASIC); }
From source file:com.architexa.diagrams.relo.jdt.parts.CodeUnitEditPart.java
public List<ArtifactFragment> getNonDerivedModelChildren() { List<ArtifactFragment> retVal = new ArrayList<ArtifactFragment>(getModelChildren()); ListIterator<ArtifactFragment> li = retVal.listIterator(); while (li.hasNext()) { if (li.next() instanceof DerivedArtifact) { li.remove(); }//from w ww. j a va 2 s .c om } return retVal; }
From source file:org.openinfinity.tagcloud.domain.service.TargetServiceImpl.java
private List<Result> nearbySearch(List<Target> allTargets, List<Result> results, List<Tag> nearbyTags) { for (Target target : allTargets) { List<Tag> foundNearbyTags = new ArrayList<Tag>(); for (Tag tag : nearbyTags) { if (target.getTags().contains(tag)) foundNearbyTags.add(tag); }/*from ww w. j a v a2s .c om*/ if (foundNearbyTags.size() == 0) continue; ListIterator<Result> resultIterator = results.listIterator(0); while (resultIterator.hasNext()) { Result result = resultIterator.next(); for (Tag tag : foundNearbyTags) { NearbyTarget nearbyTarget = result.getNearbyTargetsMap().get(tag.getText()); double distance = calcRelativeDistance(result.getTarget(), target); if (distance < nearbyTarget.getDistance()) { nearbyTarget.setTarget(target); nearbyTarget.setDistance(distance); } } result.updateNearbyTargetList(); } } // update correct absolute distances and remove ones too far away ListIterator<Result> resultIterator = results.listIterator(0); while (resultIterator.hasNext()) { Result result = resultIterator.next(); for (NearbyTarget nearbyTarget : result.getNearbyTargetsList()) { nearbyTarget.setDistance(calcDistance(result.getTarget(), nearbyTarget.getTarget())); if (nearbyTarget.getDistance() > NearbyTarget.MAX_DISTANCE) { resultIterator.remove(); break; } } } return results; }
From source file:org.glite.security.voms.admin.persistence.dao.VOMSUserDAO.java
@SuppressWarnings("unchecked") public List<VOMSUser> findAUPFailingUsers(AUP aup) { List<VOMSUser> result = new ArrayList<VOMSUser>(); AUPVersion activeVersion = aup.getActiveVersion(); // Get users First that do not have any acceptance records for the // active aupVersion String noAcceptanceRecordForActiveAUPVersionQuery = "select u from VOMSUser u where u not in (select u from VOMSUser u join u.aupAcceptanceRecords r where r.aupVersion.active = true)"; Query q = HibernateFactory.getSession().createQuery(noAcceptanceRecordForActiveAUPVersionQuery); List<VOMSUser> noRecordUsers = q.list(); result.addAll(noRecordUsers);//from ww w . j a v a 2 s . c o m log.debug("Users without acceptance records for currently active aup: {}", result); // Add users that have an expired aup acceptance record due to aup // update or acceptance retriggering. String qString = "select u from VOMSUser u join u.aupAcceptanceRecords r where r.aupVersion.active = true and r.lastAcceptanceDate < :lastUpdateTime"; Query q2 = HibernateFactory.getSession().createQuery(qString); Date aupLastUpdateTime = activeVersion.getLastUpdateTime(); log.debug("AUP version lastUpdateTime: {}", aupLastUpdateTime); q2.setTimestamp("lastUpdateTime", aupLastUpdateTime); List<VOMSUser> expiredDueToAUPUpdateUsers = q2.list(); result.addAll(expiredDueToAUPUpdateUsers); log.debug("Users that signed the AUP before it was last updated:" + expiredDueToAUPUpdateUsers); // Add users that have a valid aup acceptance record that needs to be // checked against // the reacceptance period Query q3 = HibernateFactory.getSession().createQuery( "select u from VOMSUser u join u.aupAcceptanceRecords r where r.aupVersion.active = true" + " and r.lastAcceptanceDate > :lastUpdateTime "); q3.setTimestamp("lastUpdateTime", aupLastUpdateTime); List<VOMSUser> potentiallyExpiredUsers = q3.list(); HibernateFactory.getSession().flush(); log.debug("Users that needs checking since their aup acceptance record could be expired:" + potentiallyExpiredUsers); for (VOMSUser u : potentiallyExpiredUsers) { AUPAcceptanceRecord r = u.getAUPAccceptanceRecord(aup.getActiveVersion()); if (r.hasExpired()) { log.debug("Adding user{} to results due to expired aup acceptance report (aup validity expiration)", u); result.add(u); } } // Filter out expired users ListIterator<VOMSUser> iter = result.listIterator(); while (iter.hasNext()) { VOMSUser u = iter.next(); if (u.hasExpired() && u.isSuspended()) { log.debug("Removing supended user {} from results since " + "membership expired", u); iter.remove(); } } return result; }
From source file:org.easyrec.service.web.nodomain.impl.ShopRecommenderServiceImpl.java
@SuppressWarnings({ "unchecked" }) @IOLog//w w w . ja v a 2s . co m @Profiled @Override public List<Item> worstRatedItems(Integer tenantId, String userId, String itemType, Integer numberOfResults, Integer offset, String timeRange, TimeConstraintVO constraint, Session session) { List<Item> items; offset = CollectionUtils.getSafeOffset(offset); RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId); if (logger.isDebugEnabled()) { logger.debug("<WORST_RATED@" + remoteTenant.getStringId() + "> " + " requesting worst rated Items"); } if (timeRange == null) { timeRange = "ALL"; } // default timeRange if (userId == null) { Element e = cache.get(tenantId + WS.ACTION_WORST_RATED + itemType + timeRange); if ((e != null) && (!e.isExpired())) { items = itemService.filterDeactivatedItems((List<Item>) e.getValue()); return CollectionUtils.getSafeSubList(items, offset, numberOfResults); } if (constraint == null) constraint = new TimeConstraintVO(); adjustConstraint(constraint, TimeRange.getEnumFromString(timeRange)); } Monitor monCore = MonitorFactory.start(JAMON_REST_WORST_RATED_CORE); List<RatingVO<Integer, String>> ratedItems = domainActionService.badItemRatings(tenantId, idMappingDAO.lookup(userId), null, itemType, WS.MAX_NUMBER_OF_RANKING_RESULTS, constraint); // filter invisible items Set<String> invisibleItemTypes = typeMappingService.getItemTypes(tenantId, false); if (invisibleItemTypes.size() > 0) { ListIterator<RatingVO<Integer, String>> iterator = ratedItems.listIterator(); while (iterator.hasNext()) { RatingVO<Integer, String> ratingVO = iterator.next(); if (invisibleItemTypes.contains(ratingVO.getItem().getType())) iterator.remove(); } } monCore.stop(); items = idMappingService.mapRatedItems(ratedItems, remoteTenant, session, WS.MAX_NUMBER_OF_RANKING_RESULTS, 0); if ((userId == null)) cache.put(new Element(tenantId + WS.ACTION_WORST_RATED + itemType + timeRange, items)); return CollectionUtils.getSafeSubList(items, offset, numberOfResults); }
From source file:org.easyrec.service.web.nodomain.impl.ShopRecommenderServiceImpl.java
@SuppressWarnings({ "unchecked" }) @IOLog/*from ww w . j ava 2s . c om*/ @Profiled @Override public List<Item> bestRatedItems(Integer tenantId, String userId, String itemType, Integer numberOfResults, Integer offset, String timeRange, TimeConstraintVO constraint, Session session) { List<Item> items; offset = CollectionUtils.getSafeOffset(offset); RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId); if (logger.isDebugEnabled()) { logger.debug("<BEST_RATED@" + remoteTenant.getStringId() + "> " + " requesting best rated Items"); } if (timeRange == null) { timeRange = "ALL"; } // default timeRange if (userId == null) { Element e = cache.get(tenantId + WS.ACTION_BEST_RATED + itemType + timeRange); if ((e != null) && (!e.isExpired())) { items = itemService.filterDeactivatedItems((List<Item>) e.getValue()); return CollectionUtils.getSafeSubList(items, offset, numberOfResults); } if (constraint == null) constraint = new TimeConstraintVO(); adjustConstraint(constraint, TimeRange.getEnumFromString(timeRange)); } Monitor monCore = MonitorFactory.start(JAMON_REST_BEST_RATED_CORE); List<RatingVO<Integer, String>> ratedItems = domainActionService.goodItemRatings(tenantId, idMappingDAO.lookup(userId), null, itemType, WS.MAX_NUMBER_OF_RANKING_RESULTS, constraint); // filter invisible items Set<String> invisibleItemTypes = typeMappingService.getItemTypes(tenantId, false); if (invisibleItemTypes.size() > 0) { ListIterator<RatingVO<Integer, String>> iterator = ratedItems.listIterator(); while (iterator.hasNext()) { RatingVO<Integer, String> ratingVO = iterator.next(); if (invisibleItemTypes.contains(ratingVO.getItem().getType())) iterator.remove(); } } monCore.stop(); items = idMappingService.mapRatedItems(ratedItems, remoteTenant, session, WS.MAX_NUMBER_OF_RANKING_RESULTS, 0); if ((userId == null)) cache.put(new Element(tenantId + WS.ACTION_BEST_RATED + itemType + timeRange, items)); return CollectionUtils.getSafeSubList(items, offset, numberOfResults); }
From source file:org.easyrec.service.web.nodomain.impl.ShopRecommenderServiceImpl.java
@SuppressWarnings({ "unchecked" }) @IOLog/* w w w. j a v a 2 s . c o m*/ @Profiled @Override public List<Item> mostBoughtItems(Integer tenantId, String itemType, Integer cluster, Integer numberOfResults, Integer offset, String timeRange, TimeConstraintVO constraint, Session session) { List<Item> items; offset = CollectionUtils.getSafeOffset(offset); RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId); if (logger.isDebugEnabled()) { logger.debug("<MOST_BOUGHT@" + remoteTenant.getStringId() + "> " + " requesting most bought Items"); } if (timeRange == null) { timeRange = "ALL"; } // default timeRange String cacheKey = tenantId + WS.ACTION_MOST_BOUGHT + itemType + cluster + timeRange; Element e = cache.get(cacheKey); if ((e != null) && (!e.isExpired())) { items = itemService.filterDeactivatedItems((List<Item>) e.getValue()); return CollectionUtils.getSafeSubList(items, offset, numberOfResults); } if (constraint == null) constraint = new TimeConstraintVO(); adjustConstraint(constraint, TimeRange.getEnumFromString(timeRange)); Monitor monCore = MonitorFactory.start(JAMON_REST_MOST_BOUGHT_CORE); List<RankedItemVO<Integer, String>> rankedItems = domainActionService.mostBoughtItems(tenantId, itemType, cluster, WS.MAX_NUMBER_OF_RANKING_RESULTS, constraint, Boolean.TRUE); // filter invisible items Set<String> invisibleItemTypes = typeMappingService.getItemTypes(tenantId, false); if (invisibleItemTypes.size() > 0) { ListIterator<RankedItemVO<Integer, String>> iterator = rankedItems.listIterator(); while (iterator.hasNext()) { RankedItemVO<Integer, String> rankedItemVO = iterator.next(); if (invisibleItemTypes.contains(rankedItemVO.getItem().getType())) iterator.remove(); } } monCore.stop(); items = idMappingService.mapRankedItems(rankedItems, remoteTenant, session, WS.MAX_NUMBER_OF_RANKING_RESULTS, 0); cache.put(new Element(cacheKey, items)); return CollectionUtils.getSafeSubList(items, offset, numberOfResults); }