List of usage examples for java.util ListIterator remove
void remove();
From source file:br.com.ingenieux.mojo.beanstalk.env.ReplaceEnvironmentMojo.java
/** * Prior to Launching a New Environment, lets look and copy the most we can * * @param curEnv current environment//from w w w .j a va2 s.c o m */ private void copyOptionSettings(EnvironmentDescription curEnv) throws Exception { /** * Skip if we don't have anything */ if (null != this.optionSettings && this.optionSettings.length > 0) { return; } DescribeConfigurationSettingsResult configSettings = getService() .describeConfigurationSettings(new DescribeConfigurationSettingsRequest() .withApplicationName(applicationName).withEnvironmentName(curEnv.getEnvironmentName())); List<ConfigurationOptionSetting> newOptionSettings = new ArrayList<ConfigurationOptionSetting>( configSettings.getConfigurationSettings().get(0).getOptionSettings()); ListIterator<ConfigurationOptionSetting> listIterator = newOptionSettings.listIterator(); while (listIterator.hasNext()) { ConfigurationOptionSetting curOptionSetting = listIterator.next(); boolean bInvalid = harmfulOptionSettingP(curEnv.getEnvironmentId(), curOptionSetting); if (bInvalid) { getLog().info(format("Excluding Option Setting: %s:%s['%s']", curOptionSetting.getNamespace(), curOptionSetting.getOptionName(), CredentialsUtil.redact(curOptionSetting.getValue()))); listIterator.remove(); } else { getLog().info(format("Including Option Setting: %s:%s['%s']", curOptionSetting.getNamespace(), curOptionSetting.getOptionName(), CredentialsUtil.redact(curOptionSetting.getValue()))); } } Object __secGroups = project.getProperties().get("beanstalk.securityGroups"); if (null != __secGroups) { String securityGroups = StringUtils.defaultString(__secGroups.toString()); if (!StringUtils.isBlank(securityGroups)) { ConfigurationOptionSetting newOptionSetting = new ConfigurationOptionSetting( "aws:autoscaling:launchconfiguration", "SecurityGroups", securityGroups); newOptionSettings.add(newOptionSetting); getLog().info(format("Including Option Setting: %s:%s['%s']", newOptionSetting.getNamespace(), newOptionSetting.getOptionName(), newOptionSetting.getValue())); } } /* * Then copy it back */ this.optionSettings = newOptionSettings.toArray(new ConfigurationOptionSetting[newOptionSettings.size()]); }
From source file:org.tightblog.ui.restapi.UserController.java
@GetMapping(value = "/tb-ui/authoring/rest/weblog/{weblogId}/potentialmembers") public Map<String, String> getPotentialNewBlogMembers(@PathVariable String weblogId, Principal p, HttpServletResponse response) throws ServletException { Weblog weblog = weblogRepository.findById(weblogId).orElse(null); if (weblog != null && userManager.checkWeblogRole(p.getName(), weblog, WeblogRole.OWNER)) { // member list excludes inactive accounts List<User> potentialUsers = userRepository.findByStatusEnabled(); // filter out people already members ListIterator<User> potentialIter = potentialUsers.listIterator(); List<UserWeblogRole> currentUserList = userWeblogRoleRepository.findByWeblog(weblog); while (potentialIter.hasNext() && !currentUserList.isEmpty()) { User su = potentialIter.next(); ListIterator<UserWeblogRole> alreadyIter = currentUserList.listIterator(); while (alreadyIter.hasNext()) { UserWeblogRole au = alreadyIter.next(); if (su.getId().equals(au.getUser().getId())) { potentialIter.remove(); alreadyIter.remove(); break; }//from w w w.ja v a 2 s.co m } } return createUserMap(potentialUsers); } else { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return null; } }
From source file:playground.christoph.evacuation.analysis.EvacuationTimePictureWriter.java
public FolderType getLinkFolder(String transportMode, Map<Id, BasicLocation> locations, Map<Id, Double> evacuationTimes) throws IOException { calcMaxEvacuationTime(evacuationTimes); /*//from w w w .j a va 2s . c o m * create Folders and connect them */ FolderType mainFolder = this.kmlObjectFactory.createFolderType(); FolderType linkFolder = this.kmlObjectFactory.createFolderType(); FolderType facilityFolder = this.kmlObjectFactory.createFolderType(); FolderType linkFolderA = this.kmlObjectFactory.createFolderType(); // 0 .. 10 valid Trips FolderType linkFolderB = this.kmlObjectFactory.createFolderType(); // 10 .. 100 valid Trips FolderType linkFolderC = this.kmlObjectFactory.createFolderType(); // 100 .. 1000 valid Trips FolderType linkFolderD = this.kmlObjectFactory.createFolderType(); // 1000 and more valid Trips FolderType facilityFolderA = this.kmlObjectFactory.createFolderType(); // 0 .. 10 valid Trips FolderType facilityFolderB = this.kmlObjectFactory.createFolderType(); // 10 .. 100 valid Trips FolderType facilityFolderC = this.kmlObjectFactory.createFolderType(); // 100 .. 1000 valid Trips FolderType facilityFolderD = this.kmlObjectFactory.createFolderType(); // 1000 and more valid Trips mainFolder.setName("Evacuation Times " + transportMode); linkFolder.setName("Links"); facilityFolder.setName("Facilities"); linkFolderA.setName("Links with 0..9 valid Trips"); linkFolderB.setName("Links with 10..99 valid Trips"); linkFolderC.setName("Links with 100..9 valid Trips"); linkFolderD.setName("Links with 1000 and more valid Trips"); facilityFolderA.setName("Facilities with 0..9 valid Trips"); facilityFolderB.setName("Facilities with 10..99 valid Trips"); facilityFolderC.setName("Facilities with 100..9 valid Trips"); facilityFolderD.setName("Facilities with 1000 and more valid Trips"); mainFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(linkFolder)); mainFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(facilityFolder)); linkFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(linkFolderA)); linkFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(linkFolderB)); linkFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(linkFolderC)); linkFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(linkFolderD)); facilityFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(facilityFolderA)); facilityFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(facilityFolderB)); facilityFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(facilityFolderC)); facilityFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder(facilityFolderD)); /* * create overall histogram and add it to the kmz file */ ScreenOverlayType histogram = createHistogram(transportMode, evacuationTimes); mainFolder.getAbstractFeatureGroup().add(kmlObjectFactory.createScreenOverlay(histogram)); /* * create legend and add it to the kmz file */ ScreenOverlayType legend = createLegend(transportMode); mainFolder.getAbstractFeatureGroup().add(kmlObjectFactory.createScreenOverlay(legend)); Map<BasicLocation, List<Double>> locationMap = new HashMap<BasicLocation, List<Double>>(); for (Entry<Id, BasicLocation> entry : locations.entrySet()) { Id id = entry.getKey(); BasicLocation location = entry.getValue(); List<Double> list = locationMap.get(location); if (list == null) { list = new ArrayList<Double>(); locationMap.put(location, list); } Double value = evacuationTimes.get(id); if (value == null) value = Double.NaN; list.add(value); } log.info("Number of different start locations found: " + locationMap.size()); if (doClustering) { EvacuationTimeClusterer clusterer = new EvacuationTimeClusterer(scenario.getNetwork(), locationMap, scenario.getConfig().global().getNumberOfThreads()); int numClusters = (int) Math.ceil(locationMap.size() / clusterFactor); locationMap = clusterer.buildCluster(numClusters, clusterIterations); } for (Entry<BasicLocation, List<Double>> entry : locationMap.entrySet()) { BasicLocation location = entry.getKey(); List<Double> list = entry.getValue(); int valid = 0; int invalid = 0; /* * Remove NaN entries from the List */ List<Double> listWithoutNaN = new ArrayList<Double>(); for (Double d : list) { if (d.isNaN()) { invalid++; } else listWithoutNaN.add(d); } /* * If trip with significant to high evacuation times should be cut off */ if (limitMaxEvacuationTime) { double cutOffValue = meanEvacuationTime + standardDeviation * evacuationTimeCutOffFactor; ListIterator<Double> iter = listWithoutNaN.listIterator(); while (iter.hasNext()) { double value = iter.next(); if (value > cutOffValue) { iter.remove(); invalid++; } } } valid = list.size() - invalid; double mean = 0.0; for (Double d : list) { mean = mean + d; } mean = mean / list.size(); // if at least one valid entry found - otherwise it would result in a divide by zero error if (listWithoutNaN.size() == 0) continue; // if (invalid < list.size()) mean = mean / (list.size() - invalid); // else continue; int index = getColorIndex(mean); StyleType styleType = colorBarStyles[index]; PlacemarkType placemark = createPlacemark(transportMode, location, mean, valid, invalid); placemark.setStyleUrl(styleType.getId()); if (location instanceof Facility) { if (valid < 10) facilityFolderA.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); else if (valid < 100) facilityFolderB.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); else if (valid < 1000) facilityFolderC.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); else facilityFolderD.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); } else if (location instanceof Link) { if (valid < 10) linkFolderA.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); else if (valid < 100) linkFolderB.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); else if (valid < 1000) linkFolderC.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); else linkFolderD.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); } else { mainFolder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(placemark)); } histogramToKMZ(transportMode, location, listWithoutNaN); boxplotToKMZ(transportMode, location, listWithoutNaN); } return mainFolder; }
From source file:org.squashtest.tm.service.importer.ImportLog.java
/** * * <p>The logs for the datasets also contain the logs for the dataset parameter values. * Since they were inserted separately we need to purge them from redundant informations.</p> * * <p>To ensure consistency we need to check that, for each imported line, there can be * a log entry with status OK if this is the unique log entry for that line. * From a procedural point of view we need, for each imported lines, to remove a log entry * if it has a status OK and ://ww w.jav a2 s. co m * <ul> * <li>there was already a status OK for that line, or</li> * <li>there is at least 1 warning or error</li> * </ul> * </p> * */ /* * NB : This code relies on the fact that the log entries are sorted by import line number then by status, * and that the status OK comes first. * * Basically the job boils down to the following rules : * * for each line, for each entry, if there was a previous element with status OK on this line -> remove it. * */ public void packLogs() { LinkedList<LogEntry> listiterableLogs = new LinkedList<>(findAllFor(DATASET)); Integer precLine = null; boolean okFoundOnPrecEntry = false; ListIterator<LogEntry> iter = listiterableLogs.listIterator(); while (iter.hasNext()) { LogEntry entry = iter.next(); Integer curLine = entry.getLine(); ImportStatus curStatus = entry.getStatus(); /* * if we found an occurence on the previous entry * and the current entry concerns the same line and * remove it. */ if (okFoundOnPrecEntry && curLine.equals(precLine)) { // finding the previous element actually means // to backtrack twice (because the cursor points // to the next element already) iter.previous(); iter.previous(); iter.remove(); // now we replace the cursor where it was before // the 'if'. iter.next(); } // now we set our flag according to the status of the // current entry and update precLine okFoundOnPrecEntry = curStatus == OK; precLine = curLine; } // once complete we replace the original list with the filtered one findAllFor(DATASET).clear(); logEntriesPerType.putAll(DATASET, listiterableLogs); }
From source file:org.apache.fop.layoutmgr.AbstractBreaker.java
/** * Gets the next block list (sequence) and adds it to a list of block lists * if it's not empty.//from w ww .j a va 2s. c o m * * @param childLC LayoutContext to use * @param nextSequenceStartsOn indicates on what page the next sequence * should start * @param positionAtIPDChange last element on the part before an IPD change * @param restartAtLM the layout manager from which to restart, if IPD * change occurs between two LMs * @param firstElements elements from non-restartable LMs on the new page * @return the page on which the next content should appear after a hard * break */ protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn, Position positionAtIPDChange, LayoutManager restartAtLM, List<KnuthElement> firstElements) { updateLayoutContext(childLC); //Make sure the span change signal is reset childLC.signalSpanChange(Constants.NOT_SET); BlockSequence blockList; List<KnuthElement> returnedList; if (firstElements == null) { returnedList = getNextKnuthElements(childLC, alignment); } else if (positionAtIPDChange == null) { /* * No restartable element found after changing IPD break. Simply add the * non-restartable elements found after the break. */ returnedList = firstElements; /* * Remove the last 3 penalty-filler-forced break elements that were added by * the Knuth algorithm. They will be re-added later on. */ ListIterator iter = returnedList.listIterator(returnedList.size()); for (int i = 0; i < 3; i++) { iter.previous(); iter.remove(); } } else { returnedList = getNextKnuthElements(childLC, alignment, positionAtIPDChange, restartAtLM); returnedList.addAll(0, firstElements); } if (returnedList != null) { if (returnedList.isEmpty()) { nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn); return nextSequenceStartsOn; } blockList = new BlockSequence(nextSequenceStartsOn, getCurrentDisplayAlign()); //Only implemented by the PSLM nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn); Position breakPosition = null; if (ElementListUtils.endsWithForcedBreak(returnedList)) { KnuthPenalty breakPenalty = (KnuthPenalty) ListUtil.removeLast(returnedList); breakPosition = breakPenalty.getPosition(); log.debug("PLM> break - " + getBreakClassName(breakPenalty.getBreakClass())); switch (breakPenalty.getBreakClass()) { case Constants.EN_PAGE: nextSequenceStartsOn = Constants.EN_ANY; break; case Constants.EN_COLUMN: //TODO Fix this when implementing multi-column layout nextSequenceStartsOn = Constants.EN_COLUMN; break; case Constants.EN_ODD_PAGE: nextSequenceStartsOn = Constants.EN_ODD_PAGE; break; case Constants.EN_EVEN_PAGE: nextSequenceStartsOn = Constants.EN_EVEN_PAGE; break; default: throw new IllegalStateException("Invalid break class: " + breakPenalty.getBreakClass()); } } blockList.addAll(returnedList); BlockSequence seq; seq = blockList.endBlockSequence(breakPosition); if (seq != null) { blockLists.add(seq); } } return nextSequenceStartsOn; }
From source file:org.cloudifysource.usm.launcher.DefaultProcessLauncher.java
private void modifyWindowsCommandLine(final List<String> commandLineParams, final File workingDir) { final String firstParam = commandLineParams.get(0); if (firstParam.endsWith(".bat") || firstParam.endsWith(".cmd")) { for (int i = 0; i < WINDOWS_BATCH_FILE_PREFIX_PARAMS.length; i++) { commandLineParams.add(i, WINDOWS_BATCH_FILE_PREFIX_PARAMS[i]); }/* w w w .j a va2 s.c om*/ } // if the file does not exist, this is probably an operating system // command File file = new File(firstParam); if (!file.isAbsolute()) { file = new File(workingDir, firstParam); } if (!file.exists()) { // this is not an executable file, so add the cmd interpreter // prefix for (int i = 0; i < WINDOWS_BATCH_FILE_PREFIX_PARAMS.length; i++) { commandLineParams.add(i, WINDOWS_BATCH_FILE_PREFIX_PARAMS[i]); } } // remove quotes final ListIterator<String> commandIterator = commandLineParams.listIterator(); while (commandIterator.hasNext()) { final String param = commandIterator.next(); commandIterator.remove(); commandIterator.add(StringUtils.replace(param, "\"", "")); } }
From source file:org.exfio.weave.account.exfiopeer.ExfioPeerV1.java
public Message[] getPendingClientAuthMessages() throws WeaveException { List<Message> msgPending = new ArrayList<Message>( Arrays.asList(comms.getPendingMessages(MESSAGE_TYPE_CLIENTAUTHREQUEST))); ListIterator<Message> iterPending = msgPending.listIterator(); while (iterPending.hasNext()) { Message msg = iterPending.next(); Client otherClient = comms.getClient(msg.getSourceClientId()); //Nothing to do if status no longer pending if (!otherClient.getStatus().equals("pending")) { Log.getInstance().info(String.format("Client '%s' (%s) status '%s'. Discarding client auth request", otherClient.getClientName(), otherClient.getClientId(), otherClient.getStatus())); comms.updateMessageSession(msg.getMessageSessionId(), "closed"); //remove message from pending list iterPending.remove(); continue; }//from w ww . j av a 2 s . c o m //Re instansiate as ClientAuthRequestMessage iterPending.set(new ClientAuthRequestMessage(msg)); } return msgPending.toArray(new Message[0]); }
From source file:org.opensilk.video.data.VideosProviderClient.java
public void removeOrphans(MediaBrowser.MediaItem parentItem, List<MediaBrowser.MediaItem> childItems) { List<MediaBrowser.MediaItem> indexedItems = getChildren(parentItem); for (MediaBrowser.MediaItem item : childItems) { Uri itemUri = MediaItemUtil.getMediaUri(item); ListIterator<MediaBrowser.MediaItem> indexedII = indexedItems.listIterator(); while (indexedII.hasNext()) { MediaBrowser.MediaItem indexedItem = indexedII.next(); Uri indexedItemUri = MediaItemUtil.getMediaUri(indexedItem); if (itemUri.equals(indexedItemUri)) { indexedII.remove(); break; }/* ww w.j a v a 2 s . c o m*/ } } for (MediaBrowser.MediaItem mediaItem : indexedItems) { removeMediaRecursive(mediaItem); } }
From source file:com.bringcommunications.etherpay.Payment_Processor.java
private void cancel_client_messages(Payment_Processor_Client client) { synchronized (monitor) { Integer count = client_map.get(client); int no_entries = (count == null) ? 0 : count.intValue(); ListIterator<Payment_Message> sit = send_message_list.listIterator(); while (sit.hasNext() && no_entries > 0) { if (sit.next().client.equals(client)) { --no_entries;//from ww w . ja v a 2 s .co m sit.remove(); } } ListIterator<Payment_Message> bit = balance_message_list.listIterator(); while (bit.hasNext() && no_entries > 0) { if (bit.next().client.equals(client)) { --no_entries; bit.remove(); } } count = new Integer(no_entries); client_map.put(client, count); } }
From source file:com.ibm.asset.trails.action.ShowConfirmation.java
@UserRole(userRole = UserRoleType.READER) public String deleteSelectedLicenses() { List<License> llLicense = getRecon().getLicenseList(); ListIterator<License> lliLicense = null; License llTemp;/* w w w . jav a 2 s .c o m*/ List<Report> lReport = new ArrayList<Report>(); lReport.add(new Report("License baseline", "licenseBaseline")); setReportList(lReport); if (llLicense == null) { llLicense = new ArrayList<License>(); } for (String lsLicenseId : selectedLicenseId) { lliLicense = llLicense.listIterator(); while (lliLicense.hasNext()) { llTemp = lliLicense.next(); if (llTemp.getId().compareTo(Long.valueOf(lsLicenseId)) == 0) { lliLicense.remove(); break; } } } getRecon().setLicenseList(llLicense); recon.setAutomated(automated); recon.setManual(manual); recon.setRunon(runon); if (getMaxLicenses() != null && getMaxLicenses().trim().length() > 0) { recon.setMaxLicenses(new Integer(maxLicenses)); } recon.setPer(per); return "license"; }