List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:ch.iterate.openstack.swift.Client.java
/** * @param container The name of the container * @param name The name of the object * @param entity The name of the request entity (make sure to set the Content-Type * @param metadata The metadata for the object * @param md5sum The 32 character hex encoded MD5 sum of the data * @param objectSize The total size in bytes of the object to be stored * @param segmentSize Optional size in bytes of the object segments to be stored (forces large object support) default 4G * @param dynamicLargeObject Optional setting to use dynamic large objects, False/null will use static large objects if required * @param segmentContainer Optional name of container to store file segments, defaults to storing chunks in the same container as the file sill appear * @param segmentFolder Optional name of folder for storing file segments, defaults to ".chunks/" * @param leaveSegments Optional setting to leave segments of large objects in place when the manifest is overwrtten/changed * @return The ETAG if the save was successful, null otherwise * @throws GenericException There was a protocol level error talking to CloudFiles *//*from w w w . j av a 2s .com*/ public String storeObject(Region region, String container, String name, HttpEntity entity, Map<String, String> metadata, String md5sum, Long objectSize, Long segmentSize, Boolean dynamicLargeObject, String segmentContainer, String segmentFolder, Boolean leaveSegments) throws IOException, InterruptedException { /* * Default values for large object support. We also use the defaults combined with the inputs * to determine whether to store as a large object. */ /* * The maximum size of a single object (5GiB). */ long singleObjectSizeLimit = (long) (5 * Math.pow(1024, 3)); /* * The default minimum segment size (1MiB). */ long minSegmentSize = 1024L * 1024L; /* * Set the segment size. * * Defaults to 4GiB segments, and will not permit smaller than 1MiB segments. */ long actualSegmentSize = (segmentSize == null) ? (long) (4 * Math.pow(1024, 3)) : Math.max(segmentSize, minSegmentSize); /* * Determines if we will store using large objects - we may do this for 3 reasons: * * - A segmentSize has been specified and the object size is greater than the minimum segment size * - If an objectSize is provided and is larger than the single object size limit of 5GiB * - A segmentSize has been specified, but no objectSize given (we take this as a request for segmentation) * * The last case may fail if the user does not provide at least as much data as the minimum segment * size configured on the server, and will always produce a large object structure (even if only one * small segment is required). */ objectSize = (objectSize == null) ? -1 : objectSize; boolean useLargeObject = ((segmentSize != null) && (objectSize > actualSegmentSize)) || (objectSize > singleObjectSizeLimit) || ((segmentSize != null) && (objectSize == -1)); if (!useLargeObject) { return storeObject(region, container, name, entity, metadata, md5sum); } else { /* * We need to upload a large object as defined by the method * parameters. For now this is done sequentially, but a parallel * version using appropriate random access to the underlying data * may be desirable. * * We make the assumption that the given file size will not be * greater than int.MAX_VALUE * segmentSize * */ leaveSegments = (leaveSegments == null) ? Boolean.FALSE : leaveSegments; dynamicLargeObject = (dynamicLargeObject == null) ? Boolean.FALSE : dynamicLargeObject; segmentFolder = (segmentFolder == null) ? ".file-segments" : segmentFolder; segmentContainer = (segmentContainer == null) ? container : segmentContainer; Map<String, List<StorageObject>> oldSegmentsToRemove = null; /* * If we have chosen not to leave existing large object segments in place (default) * then we need to collect information about any existing file segments so that we can * deal with them after we complete the upload of the new manifest. * * We should only delete existing segments after a successful upload of a new manifest file * because this constitutes an object update and the older file should remain available * until the new file can be downloaded. */ if (!leaveSegments) { ObjectMetadata existingMetadata; String manifestDLO = null; Boolean manifestSLO = Boolean.FALSE; try { existingMetadata = getObjectMetaData(region, container, name); if (existingMetadata.getMetaData().containsKey(Constants.MANIFEST_HEADER)) { manifestDLO = existingMetadata.getMetaData().get(Constants.MANIFEST_HEADER); } else if (existingMetadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) { JSONParser parser = new JSONParser(); String manifestSLOValue = existingMetadata.getMetaData() .get(Constants.X_STATIC_LARGE_OBJECT); manifestSLO = (Boolean) parser.parse(manifestSLOValue); } } catch (NotFoundException e) { /* * Just means no object exists already, so continue */ } catch (ParseException e) { /* * X_STATIC_LARGE_OBJECT header existed but failed to parse. * If a static large object already exists this must be set to "true". * If we got here then the X_STATIC_LARGE_OBJECT header existed, but failed * to parse as a boolean, so fail upload as a precaution. */ return null; } if (manifestDLO != null) { /* * We have found an existing dynamic large object, so use the prefix to get a list of * existing objects. If we're putting up a new dlo, make sure the segment prefixes are * different, then we can delete anything that's not in the new list if necessary. */ String oldContainer = manifestDLO.substring(0, manifestDLO.indexOf('/', 1)); String oldPath = manifestDLO.substring(manifestDLO.indexOf('/', 1), manifestDLO.length()); oldSegmentsToRemove = new HashMap<String, List<StorageObject>>(); oldSegmentsToRemove.put(oldContainer, listObjects(region, oldContainer, oldPath)); } else if (manifestSLO) { /* * We have found an existing static large object, so grab the manifest data that * details the existing segments - delete any later that we don't need any more */ } } int segmentNumber = 1; long timeStamp = System.currentTimeMillis() / 1000L; String segmentBase = String.format("%s/%d/%d", segmentFolder, timeStamp, objectSize); /* * Create subInputStream from the OutputStream we will pass to the * HttpEntity for writing content. */ final PipedInputStream contentInStream = new PipedInputStream(64 * 1024); final PipedOutputStream contentOutStream = new PipedOutputStream(contentInStream); SubInputStream segmentStream = new SubInputStream(contentInStream, actualSegmentSize, false); /* * Fork the call to entity.writeTo() that allows us to grab any exceptions raised */ final HttpEntity e = entity; final Callable<Boolean> writer = new Callable<Boolean>() { public Boolean call() throws Exception { e.writeTo(contentOutStream); return Boolean.TRUE; } }; ExecutorService writeExecutor = Executors.newSingleThreadExecutor(); final Future<Boolean> future = writeExecutor.submit(writer); /* * Check the future for exceptions after we've finished uploading segments */ Map<String, List<StorageObject>> newSegmentsAdded = new HashMap<String, List<StorageObject>>(); List<StorageObject> newSegments = new LinkedList<StorageObject>(); JSONArray manifestSLO = new JSONArray(); boolean finished = false; /* * Upload each segment of the file by reading sections of the content input stream * until the entire underlying stream is complete */ while (!finished) { String segmentName = String.format("%s/%08d", segmentBase, segmentNumber); String etag; boolean error = false; try { etag = storeObject(region, segmentContainer, segmentStream, "application/octet-stream", segmentName, new HashMap<String, String>()); } catch (IOException ex) { // Finished storing the object System.out.println("Caught IO Exception: " + ex.getMessage()); ex.printStackTrace(); throw ex; } String segmentPath = segmentContainer + "/" + segmentName; long bytesUploaded = segmentStream.getBytesProduced(); /* * Create the appropriate manifest structure if we're making a static large * object. * * ETAG returned by the simple upload * total size of segment uploaded * path of segment */ if (!dynamicLargeObject) { JSONObject segmentJSON = new JSONObject(); segmentJSON.put("path", segmentPath); segmentJSON.put("etag", etag); segmentJSON.put("size_bytes", bytesUploaded); manifestSLO.add(segmentJSON); newSegments.add(new StorageObject(segmentName)); } segmentNumber++; if (!finished) { finished = segmentStream.endSourceReached(); } newSegmentsAdded.put(segmentContainer, newSegments); System.out.println("JSON: " + manifestSLO.toString()); if (error) return ""; segmentStream.readMoreBytes(actualSegmentSize); } /* * Attempts to retrieve the return value from the write operation * Any exceptions raised can then be handled appropriately */ try { future.get(); } catch (InterruptedException ex) { /* * The write was interrupted... delete the segments? */ } catch (ExecutionException ex) { /* * This should always be an IOException or a RuntimeException * because the call to entity.writeTo() only throws IOException */ Throwable t = ex.getCause(); if (t instanceof IOException) { throw (IOException) t; } else { throw (RuntimeException) t; } } /* * Create an appropriate manifest depending on our DLO/SLO choice */ String manifestEtag = null; if (dynamicLargeObject) { /* * Empty manifest with header detailing the shared prefix of object segments */ long manifestTimeStamp = System.currentTimeMillis() / 1000L; metadata.put("X-Object-Manifest", segmentBase); metadata.put("x-object-meta-mtime", String.format("%s", manifestTimeStamp)); manifestEtag = storeObject(region, container, new ByteArrayInputStream(new byte[0]), entity.getContentType().getValue(), name, metadata); } else { /* * Manifest containing json list specifying details of the object segments. */ URIBuilder urlBuild = new URIBuilder(region.getStorageUrl(container, name)); urlBuild.setParameter("multipart-manifest", "put"); URI url; try { url = urlBuild.build(); String manifestContent = manifestSLO.toString(); InputStreamEntity manifestEntity = new InputStreamEntity( new ByteArrayInputStream(manifestContent.getBytes()), -1); manifestEntity.setChunked(true); manifestEntity.setContentType(entity.getContentType()); HttpPut method = new HttpPut(url); method.setEntity(manifestEntity); method.setHeader("x-static-large-object", "true"); Response response = this.execute(method, new DefaultResponseHandler()); if (response.getStatusCode() == HttpStatus.SC_CREATED) { manifestEtag = response.getResponseHeader(HttpHeaders.ETAG).getValue(); } else { throw new GenericException(response); } } catch (URISyntaxException ex) { ex.printStackTrace(); } } /* * Delete stale segments of overwritten large object if requested. */ if (!leaveSegments) { /* * Before deleting old segments, remove any objects from the delete list * that are also part of a new static large object that were updated during the upload. */ if (!(oldSegmentsToRemove == null)) { for (String c : oldSegmentsToRemove.keySet()) { List<StorageObject> rmv = oldSegmentsToRemove.get(c); if (newSegmentsAdded.containsKey(c)) { rmv.removeAll(newSegmentsAdded.get(c)); } List<String> rmvNames = new LinkedList<String>(); for (StorageObject s : rmv) { rmvNames.add(s.getName()); } deleteObjects(region, c, rmvNames); } } } return manifestEtag; } }
From source file:io.github.lucaseasedup.logit.account.AccountManager.java
/** * Selects an account with the given username from the underlying storage unit. * // ww w .ja va 2s. c o m * @param username the username of an account to be selected. * @param queryKeys the account keys to be returned by this query. * * @return an {@code Account} object, or {@code null} * if there was no account with the given username * or an I/O error occurred. * * @throws IllegalArgumentException if {@code username} or * {@code queryKeys} is {@code null}. * * @throws ReportedException if an I/O error occurred, * and it was reported to the logger. */ public Account selectAccount(String username, List<String> queryKeys) { if (username == null || queryKeys == null) throw new IllegalArgumentException(); if (!queryKeys.contains(keys.username())) throw new IllegalArgumentException("Missing query key: username"); username = username.toLowerCase(); Account cachedAccount = null; // If the buffer contains some information about this account. if (buffer.containsKey(username)) { cachedAccount = buffer.get(username); // The account is known not to exist. if (cachedAccount == null) { return null; } // The account exists in the buffer. else { // All the query keys can be found in the cached entry. if (CollectionUtils.isSubset(queryKeys, cachedAccount.getEntry().getKeys())) { return cachedAccount; } // Some keys need to be fetched from the storage // in order to fulfill the selection request. else { // Remove the keys that have already been fetched; // we only need those that hasn't been. queryKeys = new ArrayList<>(queryKeys); queryKeys.removeAll(cachedAccount.getEntry().getKeys()); // If the username key has been removed // (actually, it is always the case), // then put it back into the key list. if (!queryKeys.contains(keys.username())) { queryKeys.add(keys.username()); } } } } List<Storage.Entry> entries = null; try { entries = storage.selectEntries(unit, queryKeys, new SelectorCondition(keys.username(), Infix.EQUALS, username)); } catch (IOException ex) { log(Level.WARNING, ex); ReportedException.throwNew(ex); } // If an I/O error occurred, return null. if (entries == null) return null; // If no such account exists in the storage, // mark it in the buffer as non-existing and return null. if (entries.isEmpty()) { buffer.put(username, null); return null; } // If the account is just partially cached, // fill the missing keys with the values fetched from the storage. if (cachedAccount != null) { for (Datum datum : entries.get(0)) { if (!cachedAccount.getEntry().containsKey(datum.getKey())) { cachedAccount.getEntry().put(datum.getKey(), datum.getValue()); cachedAccount.getEntry().clearKeyDirty(datum.getKey()); } } } // If there was no cached account in the buffer, // create a new Account object for it and put it into the buffer. if (!buffer.containsKey(username)) { cachedAccount = new Account(entries.get(0), false); buffer.put(username, cachedAccount); } return cachedAccount; }
From source file:de.unihannover.l3s.mws.bean.CompareSearches.java
public void loadSearch(Long id) { id = Long.parseLong(this.resultId); if (id != 0) { RicercaDao rd = new RicercaDao(); Ricerca ric = rd.getRicercaById(id); this.searches.add(ric); this.name = ric.getNome(); try {//from w w w . j ava2 s .co m TrackDao td = new TrackDao(); Track track = new Track(); Calendar c = new GregorianCalendar(); track.setDate(c.getTime()); track.setOperation("load_search"); track.setParam1(this.name); track.setUtente(this.user.getUtente()); td.addTrack(track); JSONObject avList = new JSONObject(ric.getSiteAvailablelists()); JSONArray arr1 = (JSONArray) avList.get("siteAvailablelist1"); this.siteAvailablelist1 = new ArrayList<String>(); for (int i = 0; i < arr1.length(); i++) this.siteAvailablelist1.add(arr1.get(i).toString()); arr1 = (JSONArray) avList.get("siteAvailablelist2"); this.siteAvailablelist2 = new ArrayList<String>(); for (int i = 0; i < arr1.length(); i++) this.siteAvailablelist2.add(arr1.get(i).toString()); arr1 = (JSONArray) avList.get("siteAvailablelist3"); this.siteAvailablelist3 = new ArrayList<String>(); for (int i = 0; i < arr1.length(); i++) this.siteAvailablelist3.add(arr1.get(i).toString()); JSONObject slList = new JSONObject(ric.getSiteSelectedlists()); arr1 = (JSONArray) slList.get("siteSelectedlist1"); this.siteSelectedlist1 = new ArrayList<String>(); for (int i = 0; i < arr1.length(); i++) this.siteSelectedlist1.add(arr1.get(i).toString()); arr1 = (JSONArray) slList.get("siteSelectedlist2"); this.siteSelectedlist2 = new ArrayList<String>(); for (int i = 0; i < arr1.length(); i++) this.siteSelectedlist2.add(arr1.get(i).toString()); arr1 = (JSONArray) slList.get("siteSelectedlist3"); this.siteSelectedlist3 = new ArrayList<String>(); for (int i = 0; i < arr1.length(); i++) this.siteSelectedlist3.add(arr1.get(i).toString()); JSONObject stList = new JSONObject(ric.getSearchterms()); arr1 = (JSONArray) stList.get("searchTerms"); this.searchterms = new ArrayList<String>(); for (int i = 0; i < arr1.length(); i++) this.searchterms.add(arr1.get(i).toString()); JSONObject dpList = new JSONObject(ric.getSearchDataPies()); this.searchDataPie1 = dpList.get("searchDataPie1").toString(); this.searchDataPie2 = dpList.get("searchDataPie2").toString(); this.searchDataPie3 = dpList.get("searchDataPie3").toString(); JSONObject WdpList = new JSONObject(ric.getSearchWeightedDataPies()); this.searchWeightedDataPie1 = WdpList.get("searchWeightedPie1").toString(); JSONObject DdpList = new JSONObject(ric.getSearchDomainDataPies()); this.searchLangDataPie1 = DdpList.get("searchDomainPie1").toString(); searchResultWeb = new ArrayList<SearchResult>(); searchResultVideo = new ArrayList<SearchResult>(); searchResultImg = new ArrayList<SearchResult>(); List<String> exclude1 = new ArrayList<String>(siteAvailablelist1); exclude1.removeAll(siteSelectedlist1); List<String> exclude2 = new ArrayList<String>(siteAvailablelist2); exclude2.removeAll(siteSelectedlist2); List<String> exclude3 = new ArrayList<String>(siteAvailablelist3); exclude3.removeAll(siteSelectedlist3); teasers = new ArrayList<String>(); for (Risultati r : ric.getRisultati()) { JSONObject ris = new JSONObject(r.getRisultato()); if (r.getType().equals("WEB")) { SearchWebResult rweb = new SearchWebResult(); rweb.setTitle(ris.getString("title")); rweb.setDescription(ris.getString("description")); teasers.add(ris.getString("description")); rweb.setUrl(ris.getString("url")); searchResultWeb.add(rweb); } if (r.getType().equals("VIDEO")) { SearchVideoResult rvideo = new SearchVideoResult(); rvideo.setTitle(ris.getString("title")); rvideo.setRuntime(ris.getString("runtime")); JSONObject thumbnail = (JSONObject) ris.get("thumbnail"); BingThumbnail bt = new BingThumbnail(); if (thumbnail.has("fileSize")) bt.setFileSize(thumbnail.getLong("fileSize")); if (thumbnail.has("height")) bt.setHeight(thumbnail.getInt("height")); if (thumbnail.has("mediaUrl")) bt.setMediaUrl(thumbnail.getString("mediaUrl")); if (thumbnail.has("width")) bt.setHeight(thumbnail.getInt("width")); if (thumbnail.has("contentType")) bt.setContentType(thumbnail.getString("contentType")); rvideo.setThumbnail(bt); if (ris.has("url")) rvideo.setUrl(ris.getString("url")); else System.out.println("SENZA URL : " + r.getId()); searchResultVideo.add(rvideo); } if (r.getType().equals("IMAGE")) { SearchImageResult rimg = new SearchImageResult(); rimg.setTitle(ris.getString("title")); if (ris.has("height")) rimg.setHeight(ris.getInt("height")); if (ris.has("width")) rimg.setWidth(ris.getInt("width")); if (ris.has("url")) rimg.setUrl(ris.getString("url")); searchResultImg.add(rimg); } } searchResult1 = new ArrayList<SearchResult>(searchResultWeb); ArrayList<SearchResult> toremove = new ArrayList<SearchResult>(); for (SearchResult res : searchResult1) { for (String exc : exclude1) if (res.getUrl().contains(exc)) toremove.add(res); } for (SearchResult sr : toremove) searchResult1.remove(sr); searchResult2 = new ArrayList<SearchResult>(searchResultVideo); toremove = new ArrayList<SearchResult>(); for (SearchResult res : searchResult2) { for (String exc : exclude2) if (res.getUrl().contains(exc)) toremove.add(res); } for (SearchResult sr : toremove) searchResult2.remove(sr); searchResult3 = new ArrayList<SearchResult>(searchResultImg); toremove = new ArrayList<SearchResult>(); for (SearchResult res : searchResult3) { for (String exc : exclude3) if (res.getUrl().contains(exc)) toremove.add(res); } for (SearchResult sr : toremove) searchResult3.remove(sr); StatsManager sm = new StatsManager(); List<YData> Llist = sm.getMatcthTable(sm.getLangSites(searchResult1, null, null)); searchLangDataPie1 = "var langdata = [ "; List<String> datastring = new ArrayList<String>(); for (YData a : Llist) { datastring.add("{ label: \"" + a.getSite() + "\", data: " + a.getQty() + "} "); } searchLangDataPie1 += Joiner.on(",").join(datastring); searchLangDataPie1 += " ]; "; searchLangDataPie1 += "$.plot($(\"#chartlangpie1\"), langdata, options ); \n"; String hoverL = " $(\"#chartlangpie1\").bind(\"plothover\", function(event, pos, obj){ if (!obj){return;} percent = parseFloat(obj.series.percent).toFixed(2); var html = []; html.push(\"<div style=\\\"flot:left;width:105px;height:20px;text-align:center;border:0px solid black; \\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive1L\").html(html.join('')); }); "; searchLangDataPie1 += hoverL; String plotclickL = " $(\"#chartlangpie1\").bind(\"plotclick\", function(event, pos, obj){ if (!obj){return;} }); "; searchLangDataPie1 += plotclickL; searchLangDataPie1 += " var choiceContainerL = $(\"#chartlangpie1\");"; searchLangDataPie1 += " choiceContainerL.find(\"input\").click(plotAccordingToChoicesL);"; searchLangDataPie1 += " function plotAccordingToChoicesL() { "; searchLangDataPie1 += " var key = $(this).attr(\"name\"); "; searchLangDataPie1 += " $( \"input[value*='\"+key+\"']\" ).trigger('click'); "; searchLangDataPie1 += " }"; searchLangDataPie1 += " "; alignSiteDomain(); this.resultId = "0"; } catch (JSONException e) { e.printStackTrace(); } } // return "basicSearch"; }
From source file:com.ibm.asset.trails.service.impl.ReconWorkspaceServiceImpl.java
@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED) public List<Map<String, Object>> reconcileTypeActions() { // User Story 23223 - remove "CO/CM" from reconcile type list Start List<Map<String, Object>> reconcileTypeList = reconTypeDAO.reconcileTypeActions(); List<Map<String, Object>> reconcileTypeRemoveList = new ArrayList<Map<String, Object>>(); for (Map<String, Object> reconcileTypeMap : reconcileTypeList) { if (reconcileTypeMap.get("id") != null && ((Long) reconcileTypeMap.get("id")).intValue() == 2) {// judge // if // reconcile // type // is // manual // CO/CM reconcileTypeRemoveList.add(reconcileTypeMap);// add manual // CO/CM // reconcile // type into // reconcile // type remove // list }//from w ww. j ava 2s. com } reconcileTypeList.removeAll(reconcileTypeRemoveList);// remove manual // CO/CM // reconcile // type from // reconcile // type list return reconcileTypeList; // User Story 23223 - remove "CO/CM" from reconcile type list End }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.generator.ActivityRequestFactGenerator.java
@Override public List<AbstractFact> generateAllFacts() { List<AbstractFact> facts = new ArrayList<>(); facts.add(activityFactMapper.generateFactForFluxFaReportMessage(fluxfaReportMessage)); List<FAReportDocument> faReportDocuments = fluxfaReportMessage.getFAReportDocuments(); if (CollectionUtils.isNotEmpty(faReportDocuments)) { facts.addAll(activityFactMapper.generateFactForFaReportDocuments(faReportDocuments)); int index = 1; for (FAReportDocument faReportDocument : faReportDocuments) { xPathUtil.append(FLUXFA_REPORT_MESSAGE).appendWithIndex(FA_REPORT_DOCUMENT, index); facts.addAll(addFacts(faReportDocument.getSpecifiedFishingActivities(), faReportDocument, false)); xPathUtil.append(FLUXFA_REPORT_MESSAGE).appendWithIndex(FA_REPORT_DOCUMENT, index) .append(SPECIFIED_VESSEL_TRANSPORT_MEANS); facts.add(activityFactMapper.generateFactForVesselTransportMean( faReportDocument.getSpecifiedVesselTransportMeans(), true)); xPathUtil.append(FLUXFA_REPORT_MESSAGE).appendWithIndex(FA_REPORT_DOCUMENT, index) .append(SPECIFIED_VESSEL_TRANSPORT_MEANS, SPECIFIED_STRUCTURED_ADDRESS); addFactsForVesselTransportMeansStructuresAddress(facts, Arrays.asList(faReportDocument.getSpecifiedVesselTransportMeans())); index++;/*w ww . j a va2 s . c o m*/ } } facts.removeAll(Collections.singleton(null)); return facts; }
From source file:org.openmrs.module.providermanagement.api.impl.ProviderManagementServiceImpl.java
@Override public List<Person> getProvidersAsPersons(String query, List<ProviderRole> providerRoles, Boolean includeRetired) { // return empty list if no query if (query == null || query.length() == 0) { return new ArrayList<Person>(); }/*w ww . j a v a 2 s . co m*/ List<Person> nameMatches = getProvidersAsPersons(query, null, providerRoles, includeRetired); List<Person> identifierMatches = getProvidersAsPersons(null, query, providerRoles, includeRetired); if (identifierMatches == null || identifierMatches.size() == 0) { return nameMatches; } else if (nameMatches == null || nameMatches.size() == 0) { return identifierMatches; } else { // do a union // TODO: how is the performance of this? nameMatches.removeAll(identifierMatches); identifierMatches.addAll(nameMatches); Collections.sort(identifierMatches, new PersonByFirstNameComparator()); return identifierMatches; } }
From source file:com.inkubator.hrm.web.flow.JobJabatanFormController.java
public void doResetJobJabatanEdukasiForm(RequestContext context) { JobJabatanModel jobJabatanModel = (JobJabatanModel) context.getFlowScope().get("jobJabatanModel"); try {//from w w w .j a va2s . c om if (jobJabatanModel.getId() == null) { List<EducationLevel> listSourceEducationLevel = educationLevelService.getAllData(); dualListModelEducationLevel.setSource(listSourceEducationLevel); dualListModelEducationLevel.setTarget(new ArrayList<EducationLevel>()); } else { List<EducationLevel> listSourceEducationLevel = educationLevelService.getAllData(); List<JabatanEdukasi> listTargetJabatanEdukasi = jabatanEdukasiService .getAllDataByJabatanId(jobJabatanModel.getId()); List<EducationLevel> listTargetEducationLevel = Lambda.extract(listTargetJabatanEdukasi, Lambda.on(JabatanEdukasi.class).getEducationLevel()); listSourceEducationLevel.removeAll(listTargetEducationLevel); dualListModelEducationLevel = new DualListModel<EducationLevel>(listSourceEducationLevel, listTargetEducationLevel); } } catch (Exception e) { e.printStackTrace(); } jobJabatanModel.setListEducationLevel(new ArrayList<EducationLevel>()); context.getFlowScope().put("jobJabatanModel", jobJabatanModel); }
From source file:hydrograph.ui.parametergrid.dialog.MultiParameterFileDialog.java
private void saveParamterDialogChanges() { List<ParameterFile> tempParameterFiles = new LinkedList<>(); tempParameterFiles.addAll(parameterFiles); getComponentCanvas().saveParamterFileSequence(parameterFiles); tempParameterFiles.removeAll(jobLevelParamterFiles); saveParameters();// w w w .ja va 2 s.c om tempParameterFiles.remove(getJobSpecificFile()); getComponentCanvas().addJobLevelParamterFiles(jobLevelParamterFiles); runGraph = true; okPressed = true; }
From source file:com.topsec.tsm.sim.report.web.ReportController.java
private void removeRepeatDs(List<SimDatasource> simDatasources) { if (null == simDatasources || simDatasources.size() < 1) { return;//from w ww . j a v a2 s .com } List<SimDatasource> removedDatasources = new ArrayList<SimDatasource>(); for (int i = 0; i < simDatasources.size(); i++) { SimDatasource simDatasource = simDatasources.get(i); for (int j = i + 1; j < simDatasources.size(); j++) { SimDatasource simDatasourceOther = simDatasources.get(j); if (simDatasource.getDeviceIp().equals(simDatasourceOther.getDeviceIp()) && simDatasource .getSecurityObjectType().equals(simDatasourceOther.getSecurityObjectType())) { removedDatasources.add(simDatasourceOther); } } } if (removedDatasources.size() > 0) { simDatasources.removeAll(removedDatasources); } }