List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigurationTest.java
/** * Tests that all classes in *.javascript.* which have {@link JsxClasses}/{@link JsxClass} annotation, * are included in {@link JavaScriptConfiguration#CLASSES_}. */// w w w . ja v a2s. co m @Test public void jsxClasses() { final List<String> foundJsxClasses = new ArrayList<>(); for (final String className : getClassesForPackage(JavaScriptEngine.class)) { if (!className.contains("$")) { Class<?> klass = null; try { klass = Class.forName(className); } catch (final Throwable t) { continue; } if ("com.gargoylesoftware.htmlunit.javascript.host.intl".equals(klass.getPackage().getName())) { continue; } if (klass.getAnnotation(JsxClasses.class) != null) { foundJsxClasses.add(className); } else if (klass.getAnnotation(JsxClass.class) != null) { foundJsxClasses.add(className); } } } foundJsxClasses.remove(DedicatedWorkerGlobalScope.class.getName()); final List<String> definedClasses = new ArrayList<>(); for (final Class<?> klass : JavaScriptConfiguration.CLASSES_) { definedClasses.add(klass.getName()); } foundJsxClasses.removeAll(definedClasses); if (!foundJsxClasses.isEmpty()) { fail("Class " + foundJsxClasses.get(0) + " is not in JavaScriptConfiguration.CLASSES_"); } }
From source file:org.apache.unomi.services.services.SegmentServiceImpl.java
public void updateAutoGeneratedRules(Metadata metadata, Condition condition) { List<Rule> previousRules = persistenceService.query("linkedItems", metadata.getId(), null, Rule.class); List<Rule> rules = new ArrayList<Rule>(); if (condition != null) { getAutoGeneratedRules(metadata, condition, null, rules); }//w ww . j a va2 s. c om for (Rule rule : rules) { rulesService.setRule(rule); } previousRules.removeAll(rules); clearAutoGeneratedRules(previousRules, metadata.getId()); }
From source file:com.che.software.testato.business.IterationManager.java
/** * Creates the next iteration (both analytical and selective) for a given prioritization. * //from ww w. j av a 2 s . c om * @author Clement HELIOU (clement.heliou@che-software.com). * @param prioritization the given prioritization. * @param parentItemId the parent item id. Null if we are looking for the first level * @return true if an iteration has been created or if the current iteration is not completed yet, else false. * @since July, 2011. * @throws IterationCreationManagerException if an error occurs during the creation. */ public boolean createNextIteration(Prioritization prioritization, Integer parentItemId) throws IterationCreationManagerException { LOGGER.debug("createNextIteration(" + prioritization.getHierarchyId() + ")."); ScriptSearch searchBean = new ScriptSearch(prioritization.getHierarchyId()); searchBean.setParentScriptItem((null != parentItemId) ? parentItemId : 0); try { List<Script> scripts = scriptDAO.searchScript(searchBean); if (null != scripts && !scripts.isEmpty()) { IterationSearch iterationSearchBean = new IterationSearch(); iterationSearchBean.setScriptId(scripts.get(0).getScriptId()); List<Iteration> iterations = iterationDAO.searchIteration(iterationSearchBean); if (null == iterations || iterations.isEmpty()) { iterationDAO.createNextIteration(prioritization, scripts); LOGGER.debug("Stop condition: iteration created!"); return true; } if (!isIterationCompleted(iterations.get(0).getIterationId())) { LOGGER.debug("Stop condition: iteration not completed yet!"); return false; } searchBean = new ScriptSearch(prioritization.getHierarchyId()); searchBean.setIterationId(iterations.get(0).getIterationId()); searchBean.setSelected(false); scripts.removeAll(scriptDAO.searchScript(searchBean)); for (Script script : scripts) { ScriptItemSearch scriptItemSearchBean = new ScriptItemSearch(); scriptItemSearchBean.setScriptId(script.getScriptId()); for (ScriptItem item : scriptItemDAO.searchScriptItem(scriptItemSearchBean)) { if (createNextIteration(prioritization, item.getScriptItemId())) { return true; } } } } LOGGER.debug("Stop condition: all iterations have bean created!"); return false; } catch (Exception e) { throw new IterationCreationManagerException(e); } }
From source file:net.sf.jabref.JabRefPreferences.java
/** * Retrieves all information about the entry type in preferences, with the tag given by number. *///from ww w . j a v a2 s . co m public CustomEntryType getCustomEntryType(int number) { String nr = String.valueOf(number); String name = get(JabRefPreferences.CUSTOM_TYPE_NAME + nr); if (name == null) { return null; } List<String> req = getStringList(JabRefPreferences.CUSTOM_TYPE_REQ + nr); List<String> opt = getStringList(JabRefPreferences.CUSTOM_TYPE_OPT + nr); List<String> priOpt = getStringList(JabRefPreferences.CUSTOM_TYPE_PRIOPT + nr); if (priOpt.isEmpty()) { return new CustomEntryType(EntryUtil.capitalizeFirst(name), req, opt); } List<String> secondary = new ArrayList<>(opt); secondary.removeAll(priOpt); return new CustomEntryType(EntryUtil.capitalizeFirst(name), req, priOpt, secondary); }
From source file:fr.paris.lutece.plugins.workflowcore.service.workflow.WorkflowService.java
/** * {@inheritDoc}/* ww w .ja v a 2 s. c o m*/ */ @Override public Map<Integer, List<Action>> getActions(List<Integer> listIdResource, String strResourceType, Integer nIdExternalParentId, int nIdWorkflow) { Map<Integer, List<Action>> result = new HashMap<Integer, List<Action>>(); State initialState = null; // Get initial state StateFilter filter = new StateFilter(); filter.setIsInitialState(StateFilter.FILTER_TRUE); filter.setIdWorkflow(nIdWorkflow); List<State> listState = _stateService.getListStateByFilter(filter); if (listState.size() > 0) { initialState = listState.get(0); } Map<Integer, Integer> listIdsState = _resourceWorkflowService.getListIdStateByListId(listIdResource, nIdWorkflow, strResourceType, nIdExternalParentId); listIdResource.removeAll(listIdsState.keySet()); // Get all workflowstate StateFilter filterAll = new StateFilter(); filterAll.setIdWorkflow(nIdWorkflow); List<State> listAllState = _stateService.getListStateByFilter(filterAll); Map<Integer, List<Action>> listActionByStateId = new HashMap<Integer, List<Action>>(); for (State state : listAllState) { ActionFilter actionfilter = new ActionFilter(); actionfilter.setIdStateBefore(state.getId()); actionfilter.setIdWorkflow(nIdWorkflow); List<Action> listAction = _actionService.getListActionByFilter(actionfilter); listActionByStateId.put(state.getId(), listAction); } for (Entry<Integer, Integer> entry : listIdsState.entrySet()) { if (listActionByStateId.containsKey(entry.getValue())) { result.put(entry.getKey(), listActionByStateId.get(entry.getValue())); } } if (initialState != null) { ActionFilter actionfilter = new ActionFilter(); actionfilter.setIdStateBefore(initialState.getId()); actionfilter.setIdWorkflow(nIdWorkflow); List<Action> listAction = _actionService.getListActionByFilter(actionfilter); for (int nId : listIdResource) { result.put(nId, listAction); } } return result; }
From source file:cl.usach.trellosessionbeans.ActividadTrello.java
@Override public void buscarActividades(Equipo equipo) { Trello trello = new TrelloMake(); trello.setConfigTrello(equipo.getIdCuenta().getKeyCuenta(), equipo.getIdCuenta().getSecretCuenta(), equipo.getIdCuenta().getTokenCuenta()); try {/*from w ww. j a va2 s . c o m*/ List<ActionElement> actionElements = trello.getActions(equipo.getIdTablero().getIdTableroExt()); Collections.reverse(actionElements); if (actividadFacade.existeActividadPorTablero(equipo.getIdTablero())) { Actividad ultimaActividad = actividadFacade.buscarUltimaActividad(equipo.getIdTablero()); List<ActionElement> auxLista = new ArrayList<>(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Calendar cal = Calendar.getInstance(); for (ActionElement actionElement : actionElements) { Date date = null; if (actionElement.getDate() != null) { cal.setTime(formatter.parse(actionElement.getDate())); cal.add(Calendar.HOUR, -4); date = cal.getTime(); } if (ultimaActividad.getFechaActividad().after(date)) { auxLista.add(actionElement); } } actionElements.removeAll(auxLista); } for (ActionElement actionElement : actionElements) { TipoActividad tipoActividad; if (tipoActividadFacade.existeActividadPorNombre(actionElement.getType())) { tipoActividad = tipoActividadFacade.buscarPorNombre(actionElement.getType()); } else { TipoCuenta tipoCuenta = tipoCuentaFacade.buscarPorNombreTipoCuenta("Trello"); TipoActividad ta = new TipoActividad(actionElement.getType(), tipoCuenta); tipoActividadFacade.create(ta); tipoActividad = tipoActividadFacade.buscarPorNombre(actionElement.getType()); } if (!actividadFacade.existeActividadPorIdActividadExt(actionElement.getId())) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Calendar cal = Calendar.getInstance(); Date date = null; if (actionElement.getDate() != null) { cal.setTime(formatter.parse(actionElement.getDate())); cal.add(Calendar.HOUR, -4); date = cal.getTime(); } Actividad actividad = new Actividad(actionElement.getId(), date, tipoActividad); //Asignar miembro si es que existe if (miembroFacade.existeMiembroPorIdTableroYIdMiembroExt(equipo.getIdTablero(), actionElement.getIdMemberCreator())) { Miembro miembro = miembroFacade.buscarMiembroPorIdTableroYIdMiembroExt( equipo.getIdTablero(), actionElement.getIdMemberCreator()); actividad.setIdMiembro(miembro); } //Asignar tarjeta si es que tiene if (actionElement.getCardId() != null) { if (tarjetaFacade.existeTarjetaPorIdTarjetaExt(actionElement.getCardId())) { Tarjeta tarjeta = tarjetaFacade.buscarPorIdTarjetaExt(actionElement.getCardId()); actividad.setIdTarjeta(tarjeta); if (tipoActividad.getNombreTipoActividad().equals("updateCard")) { List<Lista> listaPU = listaFacade .buscarPrimeraYUltimaPorTablero(equipo.getIdTablero()); if (!listaPU.isEmpty()) { //Da fecha de inicio de la tarjeta if (actionElement.getIdListBefore() != null && listaPU.get(0) != null && listaPU .get(0).getIdListaExt().equals(actionElement.getIdListBefore())) { EstadoTarjeta estado = estadoTarjetaFacade .buscarPorNombreEstadoTarjeta("En proceso"); tarjeta.setIdEstadoTarjeta(estado); tarjeta.setFechaInicioTarjeta(date); if (tarjeta.getFechaCreacionTarjeta() == null) tarjeta.setFechaCreacionTarjeta(date); tarjetaFacade.edit(tarjeta); } else { //Da fecha fin de la tarjeta if (actionElement.getIdListAfter() != null && listaPU.get(1) != null && listaPU.get(1).getIdListaExt() .equals(actionElement.getIdListAfter())) { EstadoTarjeta estado = estadoTarjetaFacade .buscarPorNombreEstadoTarjeta("Terminada"); tarjeta.setIdEstadoTarjeta(estado); tarjeta.setFechaFinalTarjeta(date); if (tarjeta.getFechaCreacionTarjeta() == null) tarjeta.setFechaCreacionTarjeta(date); tarjetaFacade.edit(tarjeta); } else { //Eliminar fecha fin de la tarjeta if (actionElement.getIdListBefore() != null && listaPU.get(1) != null && listaPU.get(1).getIdListaExt() .equals(actionElement.getIdListBefore())) { EstadoTarjeta estado = estadoTarjetaFacade .buscarPorNombreEstadoTarjeta("En proceso"); tarjeta.setIdEstadoTarjeta(estado); tarjeta.setFechaFinalTarjeta(null); if (tarjeta.getFechaCreacionTarjeta() == null) tarjeta.setFechaCreacionTarjeta(date); tarjetaFacade.edit(tarjeta); } } } } } else { //Instrucciones si la tarjeta no se crea en la primera lista del tablero if (tipoActividad.getNombreTipoActividad().equals("createCard")) { //Agregar Fecha de creacion tarjeta.setFechaCreacionTarjeta(date); List<Lista> listaPU = listaFacade .buscarPrimeraYUltimaPorTablero(equipo.getIdTablero()); if (!listaPU.isEmpty()) { //Si la tarjeta se crea en la ultima lista if (listaPU.get(1) != null && listaPU.get(1).getIdLista() .equals(tarjeta.getIdLista().getIdLista())) { EstadoTarjeta estado = estadoTarjetaFacade .buscarPorNombreEstadoTarjeta("Terminada"); tarjeta.setIdEstadoTarjeta(estado); tarjeta.setFechaInicioTarjeta(date); tarjeta.setFechaFinalTarjeta(date); tarjetaFacade.edit(tarjeta); } else { //Si la tarjeta se crea en cualquier otra lista que no sea la primera ni la ultima if (listaPU.get(0) != null && !listaPU.get(0).getIdLista() .equals(tarjeta.getIdLista().getIdLista())) { EstadoTarjeta estado = estadoTarjetaFacade .buscarPorNombreEstadoTarjeta("En proceso"); tarjeta.setIdEstadoTarjeta(estado); tarjeta.setFechaInicioTarjeta(date); tarjetaFacade.edit(tarjeta); } } } } } } } actividadFacade.create(actividad); } } } catch (IOException | JSONException | ParseException ex) { Logger.getLogger(ActividadTrello.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.sf.jabref.preferences.JabRefPreferences.java
/** * Retrieves all information about the entry type in preferences, with the tag given by number. *//*from ww w. j av a2 s.c om*/ public Optional<CustomEntryType> getCustomEntryType(int number) { String nr = String.valueOf(number); String name = get(JabRefPreferences.CUSTOM_TYPE_NAME + nr); if (name == null) { return Optional.empty(); } List<String> req = getStringList(JabRefPreferences.CUSTOM_TYPE_REQ + nr); List<String> opt = getStringList(JabRefPreferences.CUSTOM_TYPE_OPT + nr); List<String> priOpt = getStringList(JabRefPreferences.CUSTOM_TYPE_PRIOPT + nr); if (priOpt.isEmpty()) { return Optional.of(new CustomEntryType(EntryUtil.capitalizeFirst(name), req, opt)); } List<String> secondary = new ArrayList<>(opt); secondary.removeAll(priOpt); return Optional.of(new CustomEntryType(EntryUtil.capitalizeFirst(name), req, priOpt, secondary)); }
From source file:jp.co.cyberagent.jenkins.plugins.AndroidAppZonePublisher.java
private List<FilePath> getPossibleAppFiles(final AbstractBuild build, final BuildListener listener) { try {//w w w. j ava2 s .co m List<FilePath> files = FileListUtil.listFilesRecursively(build.getWorkspace(), new RegexFileFilter("(.(?!unaligned)(?!unsigned))*(\\.apk|\\.ipa)")); List<FilePath> removeFiles = new LinkedList<FilePath>(); for (FilePath file : files) { String fileAbsolutePath = file.getRemote(); if (fileAbsolutePath.endsWith(".apk")) { FilePath propertiesFile = new FilePath(file.getParent().getParent(), "project.properties"); try { if (propertiesFile.exists()) { boolean isLibrary = propertiesFile.readToString().contains("android.library=true"); if (isLibrary) { removeFiles.add(file); } } else if (!fileAbsolutePath.endsWith("/build/apk/" + file.getName())) { removeFiles.add(file); } } catch (Exception e) { removeFiles.add(file); } } } files.removeAll(removeFiles); return files; } catch (Exception e) { listener.getLogger().println(TAG + "Error: " + e.getMessage()); } return new LinkedList<FilePath>(); }
From source file:com.couchbase.client.ViewConnection.java
/** * Reconfigures the connected ViewNodes. * * When a reconfiguration event happens, new ViewNodes may need to be added * or old ones need to be removed from the current configuration. This method * takes care that those operations are performed in the correct order and * are executed in a thread-safe manner. * * @param bucket the bucket which has been rebalanced. *//*from w ww . j a va 2s .com*/ public void reconfigure(Bucket bucket) { reconfiguring = true; try { // get a new collection of addresses from the received config HashSet<SocketAddress> newServerAddresses = new HashSet<SocketAddress>(); List<InetSocketAddress> newServers = AddrUtil.getAddressesFromURL(bucket.getConfig().getCouchServers()); for (InetSocketAddress server : newServers) { // add parsed address to our collections newServerAddresses.add(server); } // split current nodes to "odd nodes" and "stay nodes" ArrayList<ViewNode> shutdownNodes = new ArrayList<ViewNode>(); ArrayList<ViewNode> stayNodes = new ArrayList<ViewNode>(); ArrayList<InetSocketAddress> stayServers = new ArrayList<InetSocketAddress>(); wlock.lock(); try { for (ViewNode current : couchNodes) { if (newServerAddresses.contains(current.getSocketAddress())) { stayNodes.add(current); stayServers.add((InetSocketAddress) current.getSocketAddress()); } else { shutdownNodes.add(current); } } // prepare a collection of addresses for new nodes newServers.removeAll(stayServers); // create a collection of new nodes List<ViewNode> newNodes = createConnections(newServers); // merge stay nodes with new nodes List<ViewNode> mergedNodes = new ArrayList<ViewNode>(); mergedNodes.addAll(stayNodes); mergedNodes.addAll(newNodes); couchNodes = mergedNodes; } finally { wlock.unlock(); } // shutdown for the oddNodes for (ViewNode qa : shutdownNodes) { try { qa.shutdown(); } catch (IOException e) { getLogger().error("Error shutting down connection to " + qa.getSocketAddress()); } } } catch (IOException e) { getLogger().error("Connection reconfiguration failed", e); } finally { reconfiguring = false; } }
From source file:de.cismet.cids.custom.objecteditors.wunda_blau.WebDavPicturePanel.java
/** * DOCUMENT ME!/* w ww.j ava 2s . c om*/ * * @param evt DOCUMENT ME! */ private void btnRemoveImgActionPerformed(final ActionEvent evt) { //GEN-FIRST:event_btnRemoveImgActionPerformed final Object[] selection = lstFotos.getSelectedValues(); if ((selection != null) && (selection.length > 0)) { final int answer = JOptionPane.showConfirmDialog(StaticSwingTools.getParentFrame(this), "Sollen die Fotos wirklich gelscht werden?", "Fotos entfernen", JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.YES_OPTION) { try { listListenerEnabled = false; final List<Object> removeList = Arrays.asList(selection); final List<CidsBean> fotos = cidsBean.getBeanCollectionProperty(beanCollProp); if (fotos != null) { fotos.removeAll(removeList); } // TODO set the laufende_nr for (int i = 0; i < lstFotos.getModel().getSize(); i++) { final CidsBean foto = (CidsBean) lstFotos.getModel().getElementAt(i); foto.setProperty("laufende_nummer", i + 1); } for (final Object toDeleteObj : removeList) { if (toDeleteObj instanceof CidsBean) { final CidsBean fotoToDelete = (CidsBean) toDeleteObj; final String file = String.valueOf(fotoToDelete.getProperty("url.object_name")); IMAGE_CACHE.remove(file); removedFotoBeans.add(fotoToDelete); } } } catch (final Exception ex) { LOG.error(ex, ex); showExceptionToUser(ex, this); } finally { // TODO check the laufende_nummer attribute listListenerEnabled = true; final int modelSize = lstFotos.getModel().getSize(); if (modelSize > 0) { lstFotos.setSelectedIndex(0); } else { image = null; lblPicture.setIcon(FOLDER_ICON); } } } } }