List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:com.castis.xylophone.adsmadapter.filePolling.MapperListPolling.java
private int mergeMapperList(ParsedMapperData parsedMapperData, int previousSuccessSchedulerLogId) { List<Mapper> mapperList = new ArrayList<Mapper>(parsedMapperData.getMapperList()); List<Mapper> persistentMapperList = new ArrayList<Mapper>(); List<Mapper> removeMapperList = new ArrayList<Mapper>(); for (Mapper mapper : mapperList) { Mapper persistentMapper = tambourineConnector.getMapper(mapper.getMapperAxisType(), mapper.getMappingIdDomain(), mapper.getMappingId(), mapper.getExternalId()); if (persistentMapper != null) { if (persistentMapper.getMapperStartDate().after( mapper.getMapperStartDate())) /*?? ? ? */ persistentMapper.setMapperStartDate(mapper.getMapperStartDate()); if (mapper.getMapperStartDate().after(persistentMapper .getMapperEndDate())) /*? ? */ persistentMapper.setMapperStartDate(mapper.getMapperStartDate()); persistentMapper.setMapperEndDate(mapper.getMapperEndDate()); persistentMapperList.add(persistentMapper); removeMapperList.add(mapper); }/*from ww w.j a v a 2 s . c om*/ } mapperList.removeAll(removeMapperList); mapperList.addAll(persistentMapperList); tambourineConnector.saveMapper(mapperList, parsedMapperData.getMapperAxisType(), parsedMapperData.getMappingIdDomain(), null, parsedMapperData.getMapperStartDate(), parsedMapperData.getSyncStartDate(), previousSuccessSchedulerLogId); return mapperList.size(); }
From source file:org.openmrs.module.hospitalcore.web.controller.department.DepartmentFormController.java
@ModelAttribute("wards") public List<Concept> populateCategories(HttpServletRequest request) { int deparmentId = NumberUtils.toInt(request.getParameter("departmentId"), 0); List<Concept> wards = new ArrayList<Concept>(); Concept opdWardConcept = Context.getConceptService().getConceptByName("OPD WARD"); if (opdWardConcept != null && CollectionUtils.isNotEmpty(opdWardConcept.getAnswers())) { for (ConceptAnswer answer : opdWardConcept.getAnswers()) { if (!wards.contains(answer.getAnswerConcept())) { wards.add(answer.getAnswerConcept()); }// w ww . ja v a 2 s . com } } Concept ipdWardConcept = Context.getConceptService().getConceptByName("IPD WARD"); if (ipdWardConcept != null && CollectionUtils.isNotEmpty(ipdWardConcept.getAnswers())) { for (ConceptAnswer answer : ipdWardConcept.getAnswers()) { if (!wards.contains(answer.getAnswerConcept())) { wards.add(answer.getAnswerConcept()); } } } //ensure one ward only belong one department PatientDashboardService patientDashboardService = Context.getService(PatientDashboardService.class); List<Department> listDepartment = patientDashboardService.listDepartment(null); if (CollectionUtils.isNotEmpty(listDepartment)) { for (Department department : listDepartment) { if (deparmentId != department.getId()) { wards.removeAll(department.getWards()); } } } return wards; }
From source file:com.wipro.ats.bdre.clustermigration.MigrationPreprocessor.java
private void formStageAndDestTableDDLs(Statement st, List<String> sourceColumnList, String sourceDb, String destDb, String table, String sourceStgtable, String bdreTechPartition, String processId, String instanceExecId) throws SQLException { ResultSet rsPartitionList = st.executeQuery(MigrationPreprocessor.getDescQuery(table)); int index = 0; StringBuilder partitionList = new StringBuilder(""); List<String> sourcePartitionColumnList = new ArrayList<>(); while (rsPartitionList.next()) { if ("# Partition Information".equals(rsPartitionList.getString(1))) { index++;//from w ww . jav a2 s . c o m } if (index > 0) index++; if (index > 4) { String partitionNameAndDataType = rsPartitionList.getString(1) + " " + rsPartitionList.getString(2).toUpperCase(); partitionList.append(partitionNameAndDataType + ","); sourcePartitionColumnList.add(partitionNameAndDataType); } } sourceColumnList.removeAll(sourcePartitionColumnList); //removing partition columns from the total columns list and concatenating with commas StringBuilder finalColumns = new StringBuilder(""); for (String sourceColumn : sourceColumnList) { finalColumns.append(sourceColumn + ","); } sourceRegularColumns = finalColumns.substring(0, finalColumns.length() - 1); sourcePartitionColumns = partitionList.substring(0, partitionList.length() - 1); stgPartitionColumns = sourcePartitionColumns.substring(0, sourcePartitionColumns.lastIndexOf(",")) + "," + bdreTechPartition; stgTableDDL = "create external table " + sourceDb + "." + sourceStgtable + " (" + sourceRegularColumns + ") " + "partitioned by (" + stgPartitionColumns + ") stored as orc location '/tmp/" + processId + "/" + instanceExecId + "'"; destTableDDL = "create table " + destDb + "." + table + " (" + sourceRegularColumns + ") " + "partitioned by (" + stgPartitionColumns + ") stored as orc"; LOGGER.debug("stgTableDDL = " + stgTableDDL); LOGGER.debug("destTableDDL = " + destTableDDL); execStageTableDDL(st, sourceDb, sourceStgtable); rsPartitionList.close(); }
From source file:com.bluexml.xforms.controller.mapping.MappingToolAlfrescoToForms.java
/** * Gets the list of associations that match the name and removes the matching associations from * the input list.//from ww w .ja v a 2s . co m * * @param alfrescoName * the alfresco name * @param associations * the associations * * @return the list of matching associations */ private List<GenericAssociation> getAssociationAndRemove(String alfrescoName, List<GenericAssociation> associations) { List<GenericAssociation> result = new ArrayList<GenericAssociation>(); for (GenericAssociation association : associations) { if (association.getQualifiedName().equals(alfrescoName)) { result.add(association); } } associations.removeAll(result); return result; }
From source file:com.netflix.metacat.usermetadata.mysql.MysqlUserMetadataService.java
@SuppressWarnings("checkstyle:methodname") private Void _softDeleteDataMetadatas(final Connection conn, final String userId, final List<String> uris) throws SQLException { if (uris != null && !uris.isEmpty()) { final List<String> paramVariables = uris.stream().map(s -> "?").collect(Collectors.toList()); final String[] aUris = uris.stream().toArray(String[]::new); final String paramString = Joiner.on(",").skipNulls().join(paramVariables); final ColumnListHandler<Long> handler = new ColumnListHandler<>("id"); final List<Long> ids = new QueryRunner().query(conn, String.format(SQL.GET_DATA_METADATA_IDS, paramString), handler, (Object[]) aUris); if (!ids.isEmpty()) { final List<String> idParamVariables = ids.stream().map(s -> "?").collect(Collectors.toList()); final Long[] aIds = ids.stream().toArray(Long[]::new); final String idParamString = Joiner.on(",").skipNulls().join(idParamVariables); final List<Long> dupIds = new QueryRunner().query(conn, String.format(SQL.GET_DATA_METADATA_DELETE_BY_IDS, idParamString), handler, (Object[]) aIds); if (!dupIds.isEmpty()) { ids.removeAll(dupIds); }/* w w w . j a v a2s . co m*/ final List<Object[]> deleteDataMetadatas = Lists.newArrayList(); ids.forEach(id -> deleteDataMetadatas.add(new Object[] { id, userId })); new QueryRunner().batch(conn, SQL.SOFT_DELETE_DATA_METADATA, deleteDataMetadatas.toArray(new Object[deleteDataMetadatas.size()][2])); } } return null; }
From source file:eu.planets_project.pp.plato.evaluation.evaluators.ObjectEvaluator.java
public HashMap<MeasurementInfoUri, Value> evaluate(Alternative alternative, SampleObject sample, DigitalObject result, List<MeasurementInfoUri> measurementInfoUris, IStatusListener listener) throws EvaluatorException { listener.updateStatus("Objectevaluator: Start evaluation"); //" for alternative: %s, samle: %s", NAME, alternative.getName(), sample.getFullname())); HashMap<MeasurementInfoUri, Value> results = new HashMap<MeasurementInfoUri, Value>(); for (MeasurementInfoUri measurementInfoUri : measurementInfoUris) { String propertyURI = measurementInfoUri.getAsURI(); Scale scale = descriptor.getMeasurementScale(measurementInfoUri); if (scale == null) { // This means that I am not entitled to evaluate this measurementInfo and therefore supposed to skip it: continue; }/*www. j a va 2 s . c o m*/ if (OBJECT_FORMAT_RELATIVEFILESIZE.equals(propertyURI)) { // evaluate here PositiveFloatValue v = (PositiveFloatValue) scale.createValue(); double d = ((double) result.getData().getSize()) / sample.getData().getSize() * 100; long l = Math.round(d); d = ((double) l) / 100; v.setValue(d); results.put(measurementInfoUri, v); listener.updateStatus(String.format("Objectevaluator: evaluated measurement: %s = %s", measurementInfoUri.getAsURI(), v.toString())); } } measurementInfoUris.removeAll(results.keySet()); FITSEvaluator fitsEval = new FITSEvaluator(); HashMap<MeasurementInfoUri, Value> fitsResults = fitsEval.evaluate(alternative, sample, result, measurementInfoUris, listener); fitsResults.putAll(results); return fitsResults; }
From source file:com.clustercontrol.plugin.HinemosPluginService.java
/** * HinemosPlugin???.// w w w. j av a 2 s. c o m * * <p> * {@link com.clustercontrol.plugin.api.HinemosPlugin.getDependency()}??? * ???????????? * </p> */ public synchronized void activate() { List<HinemosPlugin> waitingPlugin = new ArrayList<HinemosPlugin>(pluginMap.values()); pluginActivatationOrder.clear(); while (true) { boolean nonActivatable = true; for (HinemosPlugin plugin : waitingPlugin) { if (pluginStatusMap.get(plugin.getClass().getName()) == PluginStatus.ACTIVATED) { // ?activate???????? continue; } if (isPluginActivatable(plugin)) { // ???????activate?? log.info("activating plugin - " + plugin.getClass().getName()); nonActivatable = false; pluginStatusMap.put(plugin.getClass().getName(), PluginStatus.ACTIVATED); pluginActivatationOrder.add(plugin); try { plugin.activate(); } catch (Throwable t) { log.warn("plugin activation failure.", t); } } } // ?????? waitingPlugin.removeAll(pluginActivatationOrder); if (nonActivatable) { if (waitingPlugin.size() == 0) { // ???????? break; } // ?????????????????WARN??? for (HinemosPlugin plugin : waitingPlugin) { log.warn(String.format("plugin %s is not started because of dependency : %s", plugin.getClass().getName(), plugin.getDependency())); } log.warn("some plugin may be not activated bevcause of dependency."); break; } } }
From source file:bammerbom.ultimatecore.bukkit.UltimateCommands.java
@Override public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { if (Overrider.checkOverridden(sender, cmd, label, args)) { return null; }//from w w w.java 2 s .c om List<String> rtrn = null; if (label.startsWith("ultimatecore:")) { label = label.replaceFirst("ultimatecore:", ""); } for (UltimateCommand cmdr : cmds) { if (cmdr.getName().equals(label) || cmdr.getAliases().contains(label)) { try { rtrn = cmdr.onTabComplete(sender, cmd, label, args, args[args.length - 1], args.length - 1); } catch (Exception ex) { ErrorLogger.log(ex, "Failed tabcompleting for " + label); } break; } } if (rtrn == null) { rtrn = new ArrayList<>(); for (Player p : r.getOnlinePlayers()) { rtrn.add(p.getName()); } } ArrayList<String> rtrn2 = new ArrayList<>(); rtrn2.addAll(rtrn); rtrn = rtrn2; if (!StringUtil.nullOrEmpty(args[args.length - 1])) { List<String> remv = new ArrayList<>(); for (String s : rtrn) { if (!StringUtils.startsWithIgnoreCase(s, args[args.length - 1])) { remv.add(s); } } rtrn.removeAll(remv); } return rtrn; }
From source file:gov.nih.nci.caarray.test.api.external.v1_0.grid.SearchApiTest.java
@Test public void testSearchForFiles_Limit() throws RemoteException { logForSilverCompatibility(TEST_NAME, "testSearchForFiles_Limit"); FileSearchCriteria fsc = new FileSearchCriteria(); SearchResult<File> sr = gridClient.searchForFiles(fsc, null); assertTrue(sr.isFullResult());//from w w w. j a v a 2 s .c om int all = sr.getResults().size(); int chunk = all / 2 + 2; // somewhere near past the middle // first batch LimitOffset off = new LimitOffset(chunk, 0); sr = gridClient.searchForFiles(fsc, off); assertEquals(off.getOffset(), sr.getFirstResultOffset()); all -= sr.getResults().size(); List<String> ids = getIds(sr.getResults()); assertEquals(chunk, ids.size()); // second batch off.setOffset(sr.getResults().size()); sr = gridClient.searchForFiles(fsc, off); all -= sr.getResults().size(); assertEquals(0, all); // check we didnt get the same ones in the second chunk ids.removeAll(getIds(sr.getResults())); assertEquals(chunk, ids.size()); }
From source file:gov.nih.nci.caarray.test.api.external.v1_0.grid.SearchApiTest.java
@Test public void testsearchForBiomaterials_Limit() throws RemoteException { logForSilverCompatibility(TEST_NAME, "testsearchForBiomaterials_Limit"); BiomaterialSearchCriteria bisc = new BiomaterialSearchCriteria(); SearchResult<Biomaterial> sr = gridClient.searchForBiomaterials(bisc, null); assertTrue(sr.isFullResult());/*www . j a v a 2s .co m*/ int all = sr.getResults().size(); int chunk = all / 2 + 10; // somewhere near past the middle // first batch LimitOffset off = new LimitOffset(chunk, 0); sr = gridClient.searchForBiomaterials(bisc, off); assertEquals(off.getOffset(), sr.getFirstResultOffset()); all -= sr.getResults().size(); List<String> ids = getIds(sr.getResults()); assertEquals(chunk, ids.size()); // second batch off.setOffset(sr.getResults().size()); sr = gridClient.searchForBiomaterials(bisc, off); all -= sr.getResults().size(); assertEquals(0, all); // check we didnt get the same ones in the second chunk ids.removeAll(getIds(sr.getResults())); assertEquals(chunk, ids.size()); }