List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:ml.shifu.guagua.mapreduce.GuaguaMapReduceClient.java
/** * Run all jobs added to JobControl.// w w w . ja v a 2 s .c o m */ public void run() throws IOException { // Initially, all jobs are in wait state. List<ControlledJob> jobsWithoutIds = this.jc.getWaitingJobList(); int totalNeededMRJobs = jobsWithoutIds.size(); LOG.info("{} map-reduce job(s) waiting for submission.", jobsWithoutIds.size()); Thread jcThread = new Thread(this.jc, "Guagua-MapReduce-JobControl"); jcThread.start(); JobClient jobClient = new JobClient(new JobConf(new Configuration())); double lastProg = -1; Set<String> sucessfulJobs = new HashSet<String>(); while (!this.jc.allFinished()) { try { jcThread.join(1000); } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); } List<ControlledJob> jobsAssignedIdInThisRun = new ArrayList<ControlledJob>(totalNeededMRJobs); for (ControlledJob job : jobsWithoutIds) { if (job.getJob().getJobID() != null) { jobsAssignedIdInThisRun.add(job); LOG.info("Job {} is started.", job.getJob().getJobID().toString()); } else { // This job is not assigned an id yet. } } jobsWithoutIds.removeAll(jobsAssignedIdInThisRun); List<ControlledJob> successfulJobs = jc.getSuccessfulJobList(); for (ControlledJob controlledJob : successfulJobs) { String jobId = controlledJob.getJob().getJobID().toString(); if (!sucessfulJobs.contains(jobId)) { LOG.info("Job {} is successful.", jobId); sucessfulJobs.add(jobId); } } List<ControlledJob> failedJobs = jc.getFailedJobList(); for (ControlledJob controlledJob : failedJobs) { String failedJobId = controlledJob.getJob().getJobID().toString(); if (!this.failedCheckingJobs.contains(failedJobId)) { this.failedCheckingJobs.add(failedJobId); String jobName = controlledJob.getJob().getJobName(); Integer jobIndex = this.jobIndexMap.get(jobName); Integer runTimes = this.jobRunningTimes.get(jobIndex); if (runTimes <= 1) { LOG.warn("Job {} is failed, will be submitted again.", jobName); Job newJob = createJob(this.jobIndexParams.get(jobIndex)); this.jc.addJob(new ControlledJob(newJob, null)); this.jobRunningTimes.put(jobIndex, runTimes + 1); this.jobIndexMap.put(newJob.getJobName(), jobIndex); jobsWithoutIds = this.jc.getWaitingJobList(); } else { LOG.warn("Job {} is failed twice, will not be submitted again.", jobName); } } } double prog = calculateProgress(jc, jobClient) / totalNeededMRJobs; notifyProgress(prog, lastProg); lastProg = prog; try { Thread.sleep(2 * 1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } List<ControlledJob> successfulJobs = jc.getSuccessfulJobList(); LOG.info("Sucessful jobs:"); for (ControlledJob controlledJob : successfulJobs) { LOG.info("Job: {} ", controlledJob); } if (totalNeededMRJobs == successfulJobs.size()) { LOG.info("Guagua jobs: 100% complete"); // add failed jobs to debug since all jobs are finished. List<ControlledJob> failedJobs = jc.getFailedJobList(); if (failedJobs != null && failedJobs.size() > 0) { LOG.debug("Failed jobs:"); for (ControlledJob controlledJob : failedJobs) { LOG.debug("Job: {} ", controlledJob); } } } else { List<ControlledJob> failedJobs = jc.getFailedJobList(); if (failedJobs != null && failedJobs.size() > 0) { LOG.info("Failed jobs:"); for (ControlledJob controlledJob : failedJobs) { LOG.warn("Job: {} ", controlledJob); } } } this.jc.stop(); }
From source file:ait.ffma.service.preservation.riskmanagement.TestLODFreebaseRetrieve.java
/** * This method checks the existing array and add new passed value to this array * @param arr// ww w . ja va2 s . c o m * @param value * @return extended array with new value */ private String[] addValueToStringArray(String[] arr, String value) { List<String> existingValues = new ArrayList<String>(); if (arr != null && arr.length > 0 && !arr[0].equals(" ")) { existingValues.addAll(Arrays.asList(arr)); List<String> emptyStrings = new ArrayList<String>(); emptyStrings.add(" "); existingValues.removeAll(emptyStrings); } if (existingValues != null && value != null && value.length() > 0) { if (!existingValues.contains(value)) { try { existingValues.add(value); } catch (Exception e) { log.info("Unsupported operation exception: " + e); } } } return existingValues.toArray(new String[] {}); }
From source file:de.unihannover.l3s.mws.bean.CompareSearches.java
public void refineWebSearch(Type type) { System.out.println("TYPE: REFINE Web "); //String accountKey = "BmbX+6Sy9/VEcS5oOjurccO5MQpKr2ewvLQ2vRHBKXQ"; // TextManager tmgr=new TextManager(); searchterms.removeAll(Collections.singleton("")); String q = ""; for (String t : this.searchterms) { q += "\"" + t + "\" "; }// w w w . java 2s. c o m if (type == Type.REFINE_DOMAIN_PIE) { List<String> excludedomain = new ArrayList<String>(siteAvailableDomainlist1); excludedomain.removeAll(siteSelectedDomainlist1); List<String> excludelist = new ArrayList<String>(); for (String s : siteSelectedlist1) if (excludedomain.contains(getTldString("http://" + s))) excludelist.add(s); List<String> includelist = new ArrayList<String>(); for (String s : siteAvailablelist1) if (!excludedomain.contains(getTldString("http://" + s))) includelist.add(s); siteSelectedlist1.removeAll(excludelist); siteSelectedlist1.addAll(includelist); } List<String> exclude = new ArrayList<String>(siteAvailablelist1); exclude.removeAll(siteSelectedlist1); exclude.addAll(excludeWeb); for (String s : exclude) q += " -site:" + s + " "; System.out.println(q); Track track = new Track(); track.setDate((new GregorianCalendar()).getTime()); track.setOperation("search"); track.setParam1(q); track.setParam2(type.name()); track.setParam3("1"); track.setUtente(this.user.getUtente()); TrackDao td = new TrackDao(); td.addTrack(track); List<SearchResult> toremove = new ArrayList<SearchResult>(); searchResult1 = new ArrayList<SearchResult>(searchResultWeb); for (SearchResult res : searchResult1) { for (String exc : exclude) if (res.getUrl().contains(exc)) { // || excludedomain.contains(this.getTldString(res.getUrl()))){ System.out.println("removing " + exc); toremove.add(res); } } for (SearchResult sr : toremove) { searchResult1.remove(sr); } if (searchterms.size() == 0) searchterms.add(""); // PIE WEB StatsManager sm = new StatsManager(); List<YData> list = sm.getMatcthTable(sm.getSites(searchResult1, null, null)); searchDataPie1 = "var data = [ "; List<String> datastring = new ArrayList<String>(); for (YData a : list) { datastring.add("{ label: \"" + a.getSite() + "\", data: " + a.getQty() + "} "); } searchDataPie1 += Joiner.on(",").join(datastring); searchDataPie1 += " ]; "; searchDataPie1 += " var options = { series: { pie: {show: true, label: {show: false} } }, grid: { hoverable: true, clickable: true }, legend: {show: false} }; "; searchDataPie1 += "$.plot($(\"#chartpie1\"), data, options ); \n"; String hover = " $(\"#chartpie1\").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;background-color:\", obj.series.color, \"\\\">\", \"<span style=\\\"font-weight:bold;color:red\\\">\", obj.series.label, \" (\", percent, \"%)</span>\", \"</div>\"); $(\"#showInteractive\").html(html.join('')); }); "; hover = " $(\"#chartpie1\").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>\"); $(\"#showInteractive\").html(html.join('')); }); "; searchDataPie1 += hover; searchDataPie1 += " var choiceContainer = $(\"#chartpie1\");"; searchDataPie1 += " choiceContainer.find(\"input\").click(plotAccordingToChoices);"; searchDataPie1 += " function plotAccordingToChoices() { "; searchDataPie1 += " var key = $(this).attr(\"name\"); "; searchDataPie1 += " $( \"input[value*='\"+key+\"']\" ).trigger('click'); "; searchDataPie1 += " }"; searchDataPie1 += " "; // return "basicSearch"; List<YData> wlist = sm.getMatcthWeightedTable(sm.getSites(searchResult1, null, null)); searchWeightedDataPie1 = "var weighteddata = [ "; datastring = new ArrayList<String>(); for (YData a : wlist) { datastring.add("{ label: \"" + a.getSite() + "\", data: " + a.getQty() + "} "); } searchWeightedDataPie1 += Joiner.on(",").join(datastring); searchWeightedDataPie1 += " ]; "; searchWeightedDataPie1 += "$.plot($(\"#chartweightedpie1\"), weighteddata, options ); \n"; String hoverW = " $(\"#chartweightedpie1\").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>\"); $(\"#showInteractive1W\").html(html.join('')); }); "; searchWeightedDataPie1 += hoverW; searchWeightedDataPie1 += " var choiceContainerW = $(\"#chartweightedpie1\");"; searchWeightedDataPie1 += " choiceContainerW.find(\"input\").click(plotAccordingToChoicesW);"; searchWeightedDataPie1 += " function plotAccordingToChoicesW() { "; searchWeightedDataPie1 += " var key = $(this).attr(\"name\"); "; searchWeightedDataPie1 += " $( \"input[value*='\"+key+\"']\" ).trigger('click'); "; searchWeightedDataPie1 += " }"; searchWeightedDataPie1 += " "; List<YData> Llist = sm.getMatcthTable(sm.getLangSites(searchResult1, null, null)); searchLangDataPie1 = "var langdata = [ "; 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; 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(); }
From source file:uk.ac.ebi.intact.editor.services.curate.cvobject.CvObjectService.java
@Transactional(value = "jamiTransactionManager", readOnly = true, propagation = Propagation.REQUIRED) public DualListModel<IntactCvTerm> loadParentsList(IntactCvTerm cv) { List<IntactCvTerm> cvObjectsByClass = new ArrayList<IntactCvTerm>( getIntactDao().getCvTermDao().getByObjClass(cv.getObjClass())); List<IntactCvTerm> existingParents = new ArrayList<IntactCvTerm>(cv.getParents().size()); // reload parents for (OntologyTerm parent : cv.getParents()) { existingParents.add((IntactCvTerm) parent); }//from w w w . ja v a2 s . c o m // remove parents from source cvObjectsByClass.removeAll(existingParents); Collections.sort(existingParents, new CvObjectComparator()); Collections.sort(cvObjectsByClass, new CvObjectComparator()); DualListModel<IntactCvTerm> parents = new DualListModel<IntactCvTerm>(cvObjectsByClass, existingParents); return parents; }
From source file:fr.aliacom.obm.common.calendar.CalendarBindingImpl.java
private void ensureNewAttendeesWithDelegationAreAcceptedOnEvent(Event before, Event event) { List<Attendee> newAttendees = new ArrayList<Attendee>(event.getAttendees()); if (before != null) { newAttendees.removeAll(before.getAttendees()); }//from w w w . j a v a 2s . c o m for (Attendee attendee : newAttendees) { if (attendee.isCanWriteOnCalendar()) { attendee.setParticipation(Participation.accepted()); } } }
From source file:com.inkubator.hrm.web.flow.JobJabatanFormController.java
public void doResetJobJabatanFacultyForm(RequestContext context) { JobJabatanModel jobJabatanModel = (JobJabatanModel) context.getFlowScope().get("jobJabatanModel"); try {/*from ww w . j a v a 2s. c o m*/ if (jobJabatanModel.getId() == null) { List<Faculty> listSourceFaculty = facultyService.getAllData(); dualListModelFaculty.setSource(listSourceFaculty); dualListModelFaculty.setTarget(new ArrayList<Faculty>()); } else { List<Faculty> listSourceFaculty = facultyService.getAllData(); List<JabatanFakulty> listTargetJabatanFakulty = jabatanFacultyService .getAllDataByJabatanId(jobJabatanModel.getId()); List<Faculty> listTargetFaculty = Lambda.extract(listTargetJabatanFakulty, Lambda.on(JabatanFakulty.class).getFaculty()); listSourceFaculty.removeAll(listTargetFaculty); dualListModelFaculty = new DualListModel<Faculty>(listSourceFaculty, listTargetFaculty); } } catch (Exception e) { e.printStackTrace(); } jobJabatanModel.setListFaculties(new ArrayList<Faculty>()); context.getFlowScope().put("jobJabatanModel", jobJabatanModel); }
From source file:io.fabric8.kubernetes.api.Controller.java
/** * Removes all the tags with the given name * @return the number of tags removed/* w w w . j a v a 2 s .c om*/ */ private int removeTagByName(List<TagReference> tags, String tagName) { List<TagReference> removeTags = new ArrayList<>(); for (TagReference tag : tags) { if (Objects.equal(tagName, tag.getName())) { removeTags.add(tag); } } tags.removeAll(removeTags); return removeTags.size(); }
From source file:com.ms.commons.fasttext.decorator.TextScanDecorator.java
/** * <pre>// w w w . ja v a 2s . co m * ?Html?,"<"">" * "< X"(X?)?">" "<X"">"Html,??? * </pre> * * @param orign char[] * @param keyList ?? */ protected void removeTagTerms(char[] orign, List<WordTerm> keyList) { int tagPos = -1; // ???? int offset = -1; // ????? int index = -1; List<WordTerm> removedList = new LinkedList<WordTerm>(); for (int i = index + 1; i < keyList.size(); i++) { WordTerm term = keyList.get(i); tagPos = term.position; offset = term.begin; if (tagPos == leftTagPosition) { if (offset + 1 < orign.length && !isTagOrSpace(orign[offset + 1])) { // 1.1."<X",???">","<X",?,? index = i; } else if (index > -1) { // 1.2."<X"?,??"<",?:<xxx<>xx>,??, index = -1; } removedList.add(term); } else if (tagPos == rightTagPosition) { // 2.1.index <= -1?">", ???"<X",?">" if (index <= -1) { removedList.add(term); continue; } // 2.2.???">". for (int j = index; j <= i; j++) { // 3."<X"?,">"?(?)?? removedList.add(keyList.get(j)); } index = -1; } } keyList.removeAll(removedList); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
public boolean listIdContainsAll(List<CodeType> codeTypes, String... valuesToMatch) { if (valuesToMatch == null || valuesToMatch.length == 0 || CollectionUtils.isEmpty(codeTypes)) { return true; }//w ww . j a v a 2 s. c om codeTypes.removeAll(Collections.singleton(null)); List<String> valueList = Arrays.asList(valuesToMatch); valueList.removeAll(Collections.singleton(null)); for (String val : valueList) { for (CodeType IdType : codeTypes) { if (!val.equals(IdType.getListId())) { return true; } } } return false; }
From source file:eu.planets_project.pp.plato.action.workflow.EvaluateExperimentsAction.java
/** * evaluates the given leaves automatically. * This is only possible for criteria, where information on the measurement has been defined. * The registered evaluators are applied one after an other, * if an evaluator is able to measure a criterion, its value is applied and the criterion is excluded from further evaluation. * /* w w w.j a v a2 s . com*/ * First per alternative all action related evaluators are called. * * Then per alternative, for each sample object, all object/runtime related evaluators are called. * * @param leaves */ private void evaluateLeaves(List<Leaf> leaves) { clearLogBuffer(); // we evaluate measurements and have to assign each result to the corresponding leaf: build a map HashMap<MeasurementInfoUri, Leaf> measurementOfLeaf = new HashMap<MeasurementInfoUri, Leaf>(); // list of measurements which shall be evaluated List<MeasurementInfoUri> allMeasurementsToEval = new LinkedList<MeasurementInfoUri>(); for (Leaf l : leaves) { // measure this criterion automatically MeasurementInfoUri m = l.getMeasurementInfo().toMeasurementInfoUri(); if ((m != null) && (m.getAsURI() != null)) { measurementOfLeaf.put(m, l); allMeasurementsToEval.add(m); } } try { // start evaluation: List<MeasurementInfoUri> measurementsToEval = new ArrayList<MeasurementInfoUri>(); // first action evaluators List<IActionEvaluator> actionEvaluators = MiniRED.getInstance().getActionEvaluationSequence(); for (Alternative alternative : selectedPlan.getAlternativesDefinition().getConsideredAlternatives()) { // we want to evaluate each property only once, by the evaluator with the highest priority measurementsToEval.clear(); measurementsToEval.addAll(allMeasurementsToEval); for (IActionEvaluator evaluator : actionEvaluators) { Map<MeasurementInfoUri, Value> results = evaluator.evaluate(alternative, measurementsToEval, this); // apply all results for (MeasurementInfoUri m : results.keySet()) { Value value = results.get(m); if (value != null) { Leaf l = measurementOfLeaf.get(m); value.setScale(l.getScale()); l.getValues(alternative.getName()).setValue(0, value); } } // exclude evaluated leaves from further evaluation measurementsToEval.removeAll(results.keySet()); } } // then object evaluators List<IObjectEvaluator> objEvaluators = MiniRED.getInstance().getObjectEvaluationSequence(); for (Alternative alternative : selectedPlan.getAlternativesDefinition().getConsideredAlternatives()) { // .. for all alternatives List<SampleObject> samples = selectedPlan.getSampleRecordsDefinition().getRecords(); for (int i = 0; i < samples.size(); i++) { // we want to evaluate each property only once, by the evaluator with the highest priority measurementsToEval.clear(); measurementsToEval.addAll(allMeasurementsToEval); for (IObjectEvaluator evaluator : objEvaluators) { DigitalObject r = alternative.getExperiment().getResults().get(samples.get(i)); DigitalObject r2 = (r == null ? null : em.merge(r)); try { Map<MeasurementInfoUri, Value> results = evaluator.evaluate(alternative, em.merge(samples.get(i)), r2, measurementsToEval, this); // apply all results for (MeasurementInfoUri m : results.keySet()) { Value value = results.get(m); if (value != null) { Leaf l = measurementOfLeaf.get(m); value.setScale(l.getScale()); // add evaluation result for the current result-object! l.getValues(alternative.getName()).setValue(i, value); } } // exclude evaluated leaves from further evaluation measurementsToEval.removeAll(results.keySet()); } catch (Exception e) { log.error("evaluator failed" + e.getMessage(), e); continue; } } } } } catch (Exception e) { log.error("Automated evaluation threw exception " + e.getMessage(), e); FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR, "Automated evaluation failed:" + e.getMessage()); updateStatus("Automated evaluation threw exception " + e.getMessage()); } Contexts.getEventContext().set("evaluationMessage", evaluationLogBuffer.toString()); }