List of usage examples for java.util Set clear
void clear();
From source file:org.apromore.portal.dialogController.similarityclusters.visualisation.ClusterVisualisationController.java
/** * Gets the current similarity cluster result set from the Session and * stores it, to be rendered on the index.zul file. * * @throws InterruptedException in case of Error displaying the Messagebox */// w w w.j a va 2 s.c o m @SuppressWarnings("unchecked") public ClusterVisualisationController() throws InterruptedException { super(); Session session = Sessions.getCurrent(); this.clusterResult = (List<ClusterSummaryType>) session.getAttribute(CLUSTER_RESULT_ATTRIBUTE_NAME); this.indexMap = new HashMap<>(); this.addEventListener("onShowSelection", new EventListener() { @Override public void onEvent(final Event event) throws InterruptedException { Set<String> pairwiseFilter = new HashSet<>(); pairwiseFilter.clear(); if (event.getData() != null) { Object[] idList = (Object[]) event.getData(); for (Object anIdList : idList) { pairwiseFilter.add((anIdList).toString()); } try { Clients.evalJavaScript( "clusterVisualisation.refreshData(" + writeUpdatedEdges(pairwiseFilter) + ");"); } catch (JSONException e) { Messagebox.show("Error generating JSON " + e.getMessage()); } } } }); if (this.clusterResult != null) { Map<String, String> param = new HashMap<>(); try { ByteArrayOutputStream os = new ByteArrayOutputStream(); writeVisualisationJSON(os); param.put("visualisationJSON", os.toString("UTF-8")); } catch (JSONException e) { Messagebox.show("Error generating JSON " + e.getMessage()); } catch (IOException e) { Messagebox.show("Error writing JSON " + e.getMessage()); } Executions.getCurrent().pushArg(param); } else { Messagebox.show( "The page or component you request is no longer available. This is normally caused by timeout, opening too many " + "Web pages, or rebooting the server."); } }
From source file:net.sourceforge.fenixedu.domain.ExternalApplication.java
public void setScopeList(List<AuthScope> newScopes) { Set<AuthScope> oldScopes = getScopesSet(); if (CollectionUtils.subtract(newScopes, oldScopes).size() > 0) { deleteAuthorizations();/*from w w w . j ava 2 s.c o m*/ } oldScopes.clear(); oldScopes.addAll(newScopes); }
From source file:voldemort.ServerTestUtils.java
/** * Returns a list of zones with their proximity list being in increasing * order//ww w . ja v a 2 s. com * * @param numberOfZones The number of zones to return * @return List of zones */ public static List<Zone> getZonesFromZoneIds(int[] zoneIds) { List<Zone> zones = Lists.newArrayList(); Set<Integer> zoneIdsSet = new HashSet<Integer>(); for (int i : zoneIds) { zoneIdsSet.add(i); } Set<Integer> removeSet = new HashSet<Integer>(); for (int i = 0; i < zoneIds.length; i++) { removeSet.add(zoneIds[i]); zones.add(new Zone(zoneIds[i], Lists.newLinkedList(Sets.symmetricDifference(zoneIdsSet, removeSet)))); removeSet.clear(); } return zones; }
From source file:com.appeligo.search.actions.KeywordAlertAction.java
public String deleteKeywordAlert() throws Exception { KeywordAlert keywordAlert = KeywordAlert.getById(getKeywordAlertId()); Set<ProgramAlert> programAlerts = keywordAlert.getProgramAlerts(); for (ProgramAlert programAlert : programAlerts) { programAlert.setOriginatingKeywordAlert(null); }/* ww w . j a v a2 s. co m*/ programAlerts.clear(); //ProgramAlert.removeKeywordAssociation(keywordAlert); keywordAlert.setDeleted(true); keywordAlert.save(); setReturnMessage("Deleted all alerts for <a href=\"" + getServletRequest().getContextPath() + "/search/search.action?query=" + keywordAlert.getUserQuery() + "\">" + keywordAlert.getUserQuery() + "</a>"); return SUCCESS; }
From source file:de.vandermeer.skb.base.utils.Skb_TextUtils_Tests.java
@Test public void test_Object2Target_General() { //most other tests are done in Transformations Skb_Transformer<Object, String> toStr = Skb_ObjectUtils.OBJECT_TO_TARGET(String.class, nullValue, falseValue, true);//from www . jav a 2 s .c om //String = ok, <null> (can't be <false>) assertEquals("test string", toStr.transform("test string")); assertEquals(nullValue, toStr.transform(null)); //try a set with null, then with a string, then with an object Set<Object> set = new HashSet<Object>(); assertEquals(nullValue, toStr.transform(set)); set.add(null); assertEquals(nullValue, toStr.transform(set)); set.add("test string2"); assertEquals("test string2", toStr.transform(set)); set.clear(); assertEquals(nullValue, toStr.transform(set)); // set.add(SetStrategy.HASH_SET);//TODO from refactoring unto utils // assertEquals(falseValue, toStr.transform(set));//TODO from refactoring unto utils }
From source file:org.apdplat.superword.tools.WordClassifierForYouDao.java
public static synchronized void save(Map<String, List<String>> data) { LOGGER.info("??"); data.keySet().forEach(key -> {// ww w . j a va 2 s.c om try { String path = "src/main/resources/word_" + key + ".txt"; LOGGER.info("??" + path); List<String> existWords = Files.readAllLines(Paths.get(path)); Set<String> allWords = new HashSet<>(); existWords.forEach(line -> { String[] attr = line.split("\\s+"); if (attr != null) { String w = ""; if (attr.length == 1) { w = attr[0]; } if (attr.length == 2) { w = attr[1]; } allWords.add(w); } }); if (data.get(key) != null) { allWords.addAll(data.get(key)); } AtomicInteger i = new AtomicInteger(); List<String> list = allWords.stream().sorted().map(word -> i.incrementAndGet() + "\t" + word) .collect(Collectors.toList()); Files.write(Paths.get(path), list); if (data.get(key) != null) { data.get(key).clear(); } existWords.clear(); allWords.clear(); list.clear(); } catch (Exception e) { LOGGER.error("??", e); } }); data.clear(); try { if (!NOT_FOUND_WORDS.isEmpty()) { String path = "src/main/resources/word_not_found.txt"; LOGGER.info("??" + path); AtomicInteger i = new AtomicInteger(); //NOT_FOUND_WORDS List<String> list = NOT_FOUND_WORDS.stream().sorted().map(word -> i.incrementAndGet() + "\t" + word) .collect(Collectors.toList()); Files.write(Paths.get(path), list); list.clear(); } //?HTML if (!ORIGIN_HTML.isEmpty()) { String path = "src/main/resources/origin_html_" + System.currentTimeMillis() + ".txt"; LOGGER.info("??" + path); Files.write(Paths.get(path), ORIGIN_HTML); ORIGIN_HTML.clear(); } } catch (Exception e) { LOGGER.error("??", e); } }
From source file:com.redhat.rhn.frontend.action.token.configuration.RankChannelsAction.java
private void setup(RequestContext context, DynaActionForm form, Set<String> set) { //This happens if the rank channels page is used without the //subscribe page. if (!isWizardMode(context)) { set.clear(); }//from www . j a va2s. c om //add things to the form so the widget can read them setupWidget(context, form, set); }
From source file:io.cloudslang.job.ScoreEngineJobsImpl.java
/** * Job that will handle the cleaning of queue table. */// w ww . j av a 2 s.c o m @Override public void cleanQueueJob() { try { Set<Long> ids = queueCleanerService.getFinishedExecStateIds(); if (logger.isDebugEnabled()) logger.debug("Will clean from queue the next Exec state ids amount:" + ids.size()); Set<Long> execIds = new HashSet<>(); for (Long id : ids) { execIds.add(id); if (execIds.size() >= QUEUE_BULK_SIZE) { queueCleanerService.cleanFinishedSteps(execIds); execIds.clear(); } } if (execIds.size() > 0) { queueCleanerService.cleanFinishedSteps(execIds); } } catch (Exception e) { logger.error("Can't run queue cleaner job.", e); } }
From source file:com.conwet.silbops.msg.UnadvertiseMsgTest.java
@Test public void shouldDeserializeOptionalUncovered() throws ParseException { // this test covers the case clients are sending unsubscribe UnadvertiseMsg msg = new UnadvertiseMsg(); msg.setAdvertise(new Advertise().attribute("attr1", Type.STRING).attribute("attr2", Type.STRING) .attribute("attr3", Type.DOUBLE)); Advertise covered = new Advertise(); covered.attribute("attrCov", Type.DOUBLE); Set<Advertise> uncovered = new HashSet<>(); uncovered.add(covered);/*from w ww .j a va 2s . c o m*/ msg.setUncovered(uncovered); JSONObject jsonTmp = msg.toJSON(); // delete uncovered part ((JSONObject) jsonTmp.get("payload")).remove("uncovered"); uncovered.clear(); String jsonStr = jsonTmp.toJSONString(); JSONObject json = (JSONObject) new JSONParser().parse(jsonStr); UnadvertiseMsg newMsg = (UnadvertiseMsg) UnadvertiseMsg.fromJSON(json); assertThat(newMsg).isEqualTo(msg); assertThat(newMsg.getUncovered()).isEqualTo(uncovered); }
From source file:com.spectralogic.ds3client.metadata.MetadataReceivedListenerImpl_Test.java
@Test public void testGettingMetadataFailureDoesntThrow() throws IOException, InterruptedException { Assume.assumeFalse(Platform.isWindows()); try {//from w w w . j a v a 2s . co m final String tempPathPrefix = null; final Path tempDirectory = Files.createTempDirectory(Paths.get("."), tempPathPrefix); final String fileName = "Gracie.txt"; final Path filePath = Files.createFile(Paths.get(tempDirectory.toString(), fileName)); try { // set permissions if (!Platform.isWindows()) { final PosixFileAttributes attributes = Files.readAttributes(filePath, PosixFileAttributes.class); final Set<PosixFilePermission> permissions = attributes.permissions(); permissions.clear(); permissions.add(PosixFilePermission.OWNER_READ); permissions.add(PosixFilePermission.OWNER_WRITE); Files.setPosixFilePermissions(filePath, permissions); } // get permissions final ImmutableMap.Builder<String, Path> fileMapper = ImmutableMap.builder(); fileMapper.put(filePath.toString(), filePath); final Map<String, String> metadataFromFile = new MetadataAccessImpl(fileMapper.build()) .getMetadataValue(filePath.toString()); FileUtils.deleteDirectory(tempDirectory.toFile()); // put old permissions back final Metadata metadata = new MetadataImpl(new MockedHeadersReturningKeys(metadataFromFile)); new MetadataReceivedListenerImpl(tempDirectory.toString()).metadataReceived(fileName, metadata); } finally { FileUtils.deleteDirectory(tempDirectory.toFile()); } } catch (final Throwable t) { fail("Throwing exceptions from metadata est verbotten"); } }