List of usage examples for java.util Iterator remove
default void remove()
From source file:org.jutge.joc.porra.model.account.Account.java
public void removeRole(final String role) { final Iterator<String> iter = this.roles.iterator(); while (iter.hasNext()) { if (iter.next().equals(role)) { iter.remove(); }// w w w. ja v a 2s. c o m } }
From source file:org.esxx.js.protocol.PreemptiveSchemes.java
public synchronized void purgeEntries() { long now = System.currentTimeMillis(); Iterator<PreemptiveScheme> i = schemes.iterator(); while (i.hasNext()) { PreemptiveScheme ps = i.next();//from w w w . ja va 2 s. c om if (ps.getCreatedDate() + maxAge > now) { i.remove(); } } }
From source file:it.geosolutions.geobatch.imagemosaic.ImageMosaicUpdater.java
/** * Removes from the passed addFileList already present (into the passed * dataStore) features /*from ww w . j av a 2 s .c o m*/ * * TODO this can be skipped to perform update (instead * of perform remove+update) */ private static boolean purgeAddFileList(List<File> addFileList, DataStore dataStore, String store, final String locationKey, final File baseDir, boolean absolute) { if (addFileList.isEmpty()) { if (LOGGER.isInfoEnabled()) { LOGGER.info("Add list is empty"); } // we're not expecting empty list here return false; } Filter addFilter = null; // calculate the query try { addFilter = getQuery(addFileList, absolute, locationKey); if (addFilter == null) { // if (LOGGER.isInfoEnabled()) { LOGGER.info("The ADD query is null. Should not happen"); } return false; } } catch (IllegalArgumentException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(e.getLocalizedMessage()); } } catch (CQLException e) { if (LOGGER.isErrorEnabled()) { LOGGER.error("Unable to build a query. Message: " + e, e); } return false; } final String handle = "ImageMosaic:" + Thread.currentThread().getId(); final Transaction transaction = new DefaultTransaction(handle); /* * CHECK IF ADD FILES ARE ALREADY INTO THE LAYER */ FeatureReader<SimpleFeatureType, SimpleFeature> fr = null; try { // get the schema if this feature final SimpleFeatureType schema = dataStore.getSchema(store); /* * TODO to save time we could use the store name which should be the * same */ final Query q = new Query(schema.getTypeName(), addFilter); fr = dataStore.getFeatureReader(q, transaction); if (fr == null) { if (LOGGER.isErrorEnabled()) { LOGGER.error("The FeatureReader is null, it's impossible to get a reader on the dataStore: " + dataStore.toString()); } return false; } while (fr.hasNext()) { SimpleFeature feature = fr.next(); if (feature != null) { String path = (String) feature.getAttribute(locationKey); // remove from the list the image which is already // into the layer if (absolute) { File added = new File(baseDir, path); addFileList.remove(added); if (LOGGER.isWarnEnabled()) { LOGGER.warn("The file: " + path + " is removed from the addFiles list because it is already present into the layer"); } } else { // check relative paths Iterator<File> it = addFileList.iterator(); while (it.hasNext()) { File file = it.next(); if (file.getName().equals(path)) { it.remove(); if (LOGGER.isWarnEnabled()) { LOGGER.warn("The file: " + path + " is removed from the addFiles list because it is already present into the layer"); } } } } } else { if (LOGGER.isErrorEnabled()) { LOGGER.error("Problem getting the next feature: it is null!"); } } } //commit transaction.commit(); } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error(e.getLocalizedMessage(), e); } try { transaction.rollback(); } catch (IOException ioe) { if (LOGGER.isErrorEnabled()) { LOGGER.error(ioe.getLocalizedMessage(), ioe); } } return false; } finally { try { transaction.close(); } catch (Throwable t) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("problem closing transaction: " + t.getLocalizedMessage(), t); } } try { if (fr != null) { fr.close(); fr = null; } } catch (Throwable t) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("problem closing transaction: " + t.getLocalizedMessage(), t); } } } return true; }
From source file:logicProteinHypernetwork.networkStates.MinimalNetworkStates.java
/** * Returns all possible minimal network states for a network entity. * * @param e the network entity/*from w w w . j ava2s.c om*/ * @return all minimal network states */ public List<MinimalNetworkState> getMinimalNetworkStates(NetworkEntity e) { List<MinimalNetworkState> states = new ArrayList<MinimalNetworkState>(minimalNetworkStates.get(e)); Iterator<MinimalNetworkState> ite = states.iterator(); while (ite.hasNext()) { if (removed.contains(ite.next())) ite.remove(); } return states; }
From source file:org.openmrs.module.metadatamapping.api.adapter.ConceptAdapterPre19.java
@Override public void purgeMapping(Concept concept, ConceptSource source, String code) { Collection<ConceptMap> maps = concept.getConceptMappings(); if (maps == null) { return;//from w w w . java 2 s . co m } Iterator<ConceptMap> it = maps.iterator(); while (it.hasNext()) { ConceptMap map = it.next(); if (source.equals(map.getSource())) { if (code.equals(map.getSourceCode())) { it.remove(); break; } } } }
From source file:com.arcbees.gwtp.upgrader.AbstractReWriter.java
protected void removeImport(String name) { if (imports != null) { Iterator<ImportDeclaration> it = imports.iterator(); while (it.hasNext()) { if (it.next().getName().toString().equals(name)) { it.remove(); markChanged();/*from ww w. ja va 2s . c om*/ } } } }
From source file:com.ibm.storlet.common.StorletObjectOutputStream.java
@SuppressWarnings("unchecked") public void setMetadata(Map<String, String> md) throws StorletException { JSONObject jobj = new JSONObject(); Iterator<Map.Entry<String, String>> it = md.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, String> pairs = (Map.Entry<String, String>) it.next(); jobj.put((String) pairs.getKey(), (String) pairs.getValue()); it.remove(); }/*from w w w . ja v a 2s. c o m*/ try { MetadataStream_.write(jobj.toString().getBytes()); MetadataStream_.close(); } catch (IOException e) { throw new StorletException("Failed to set metadata " + e.toString()); } }
From source file:com.avanza.ymer.FakeDocumentCollection.java
private void removeById(BasicDBObject dbObject) { Iterator<DBObject> it = collection.iterator(); while (it.hasNext()) { DBObject next = it.next();/*ww w .jav a 2 s. c o m*/ if (next.get("_id").equals(dbObject.get("_id"))) { it.remove(); return; } } }
From source file:csns.web.controller.RubricSubmissionController.java
@RequestMapping("/rubric/submission/{role}/list") public String list(@PathVariable String role, @RequestParam Long assignmentId, ModelMap models) { RubricAssignment assignment = rubricAssignmentDao.getRubricAssignment(assignmentId); Set<User> students = new HashSet<User>(); for (Enrollment enrollment : assignment.getSection().getEnrollments()) students.add(enrollment.getStudent()); // we need to remove the submissions for the students who already // dropped the class Iterator<RubricSubmission> i = assignment.getSubmissions().iterator(); while (i.hasNext()) { RubricSubmission submission = i.next(); if (!students.contains(submission.getStudent())) i.remove(); else//w ww .j ava 2 s . c om students.remove(submission.getStudent()); } // we then add a submission for each student who is in the class but // didn't have a submission for this assignment. for (User student : students) { RubricSubmission submission = new RubricSubmission(student, assignment); assignment.getSubmissions().add(submission); } assignment = rubricAssignmentDao.saveRubricAssignment(assignment); models.put("user", SecurityUtils.getUser()); models.put("assignment", assignment); // Instructor, evaluator, and student will see different views. return "rubric/submission/list/" + role; }
From source file:samza.samza_test.SamzaTestAggregate.java
private void cleanMap() { Iterator it = top.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Integer> pair = (Map.Entry<String, Integer>) it.next(); if (pair.getValue() < 100) { it.remove(); }/* www.j a va 2s . co m*/ } }