List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.red5.client.net.rtmp.RTMPConnManager.java
/** {@inheritDoc} */ @Override//from ww w. jav a 2 s . c o m public Collection<RTMPConnection> removeConnections() { ArrayList<RTMPConnection> list = new ArrayList<RTMPConnection>(connMap.size()); list.addAll(connMap.values()); connMap.clear(); conns.set(0); return list; }
From source file:org.mycontroller.standalone.api.jaxrs.json.RoleJson.java
@JsonIgnore public void createOrUpdateRole() { Role role = this.getRole(); if (role.getId() != null) { //clear all old mapping removeMapping(role);/*from ww w . java 2 s .co m*/ //Update role DaoUtils.getRoleDao().update(role); } else { DaoUtils.getRoleDao().create(role); } //Map resources //Update users map if (users != null) { User user = User.builder().build(); RoleUserMap roleUserMap = RoleUserMap.builder().role(role).build(); for (Integer userId : users) { user.setId(userId); roleUserMap.setUser(user); DaoUtils.getRoleUserMapDao().create(roleUserMap); } } if (role.getPermission() == PERMISSION_TYPE.SUPER_ADMIN) { } else if (role.getPermission() == PERMISSION_TYPE.USER) { //Update gateway map if (gateways != null) { GatewayTable gatewayTable = GatewayTable.builder().build(); RoleGatewayMap roleGatewayMap = RoleGatewayMap.builder().role(role).build(); for (Integer gatewayId : gateways) { gatewayTable.setId(gatewayId); roleGatewayMap.setGatewayTable(gatewayTable); DaoUtils.getRoleGatewayMapDao().create(roleGatewayMap); } } //Update node map if (nodes != null) { Node node = Node.builder().build(); RoleNodeMap roleNodeMap = RoleNodeMap.builder().role(role).build(); for (Integer nodeId : nodes) { node.setId(nodeId); roleNodeMap.setNode(node); DaoUtils.getRoleNodeMapDao().create(roleNodeMap); } } //Update sensor map if (sensors != null) { Sensor sensor = Sensor.builder().build(); RoleSensorMap roleSensorMap = RoleSensorMap.builder().role(role).build(); for (Integer sensorId : sensors) { sensor.setId(sensorId); roleSensorMap.setSensor(sensor); DaoUtils.getRoleSensorMapDao().create(roleSensorMap); } } } else if (role.getPermission() == PERMISSION_TYPE.MQTT_USER) { RoleMqttMap roleMqttMap = RoleMqttMap.builder().role(role).build(); if (topicsPublish != null) { ArrayList<String> topics = new ArrayList<String>(); topics.addAll(Arrays.asList(topicsPublish.split("\\s*,\\s*"))); roleMqttMap.setPublish(topics); } if (topicsSubscribe != null) { ArrayList<String> topics = new ArrayList<String>(); topics.addAll(Arrays.asList(topicsSubscribe.split("\\s*,\\s*"))); roleMqttMap.setSubscribe(topics); } DaoUtils.getRoleMqttMapDao().create(roleMqttMap); } }
From source file:eu.morfeoproject.fast.catalogue.planner.ScreenPlanner.java
private void calculateForwards(Screen screen) { if (screen.getPostconditions().size() > 0) { ArrayList<Screen> screens = new ArrayList<Screen>(); screens.add(screen);// ww w.ja v a 2s.c om ArrayList<URI> results = new ArrayList<URI>(); results.addAll(catalogue.findScreensForwards(screens, new ArrayList<Condition>(), new ArrayList<Condition>(), true, true, 0, -1, null)); for (URI result : results) { planner.add(screen.getUri(), result); if (log.isInfoEnabled()) log.info("added transition " + screen.getUri() + " -> " + result); } } }
From source file:com.ciphertool.sentencebuilder.dao.BasicWordMapDao.java
/** * Constructor with autowired dependency. * /* w ww . ja v a2 s. c om*/ * @param wordDao * the WordDao to use for populating the internal Maps */ @Autowired public BasicWordMapDao(WordDao wordDao) { if (wordDao == null) { throw new IllegalArgumentException("Error constructing BasicWordMapDao. WordDao cannot be null."); } ArrayList<Word> allWords = new ArrayList<Word>(); log.info("Beginning fetching of words from database."); long start = System.currentTimeMillis(); allWords.addAll(wordDao.findAll()); log.info("Finished fetching words from database in " + (System.currentTimeMillis() - start) + "ms."); partOfSpeechWordMap = mapByPartOfSpeech(allWords); lengthWordMap = mapByWordLength(allWords); }
From source file:eu.morfeoproject.fast.catalogue.planner.ScreenPlanner.java
private void calculateBackwards(Screen screen) { if (screen.getPreconditions().size() == 0) { planner.add(ROOT_NODE, screen.getUri()); } else {/*from www . j av a2 s . co m*/ ArrayList<Screen> screens = new ArrayList<Screen>(); screens.add(screen); ArrayList<URI> results = new ArrayList<URI>(); results.addAll(catalogue.findScreensBackwards(screens, new ArrayList<Condition>(), new ArrayList<Condition>(), true, true, 0, -1, null)); for (URI result : results) { planner.add(result, screen.getUri()); if (log.isInfoEnabled()) log.info("added transition " + result + " -> " + screen.getUri()); } } }
From source file:com.thoughtworks.webanalyticsautomation.Engine.java
private Result verifyWebAnalyticsData(String actionName, ArrayList<Section> actualSectionList, ArrayList<Section> expectedSectionList) { if ((actualSectionList.size() == 0) && (expectedSectionList.size() != 0)) { return new Result(actionName, Status.FAIL, getAllTagsFromExpectedSectionList(expectedSectionList)); } else {/*from ww w . j a v a 2 s .c o m*/ ArrayList<String> errorList = new ArrayList<String>(); for (Section expectedSection : expectedSectionList) { errorList.addAll(getListOfMissingTagsInActualSections(actualSectionList, expectedSection)); } if (errorList.size() != 0) { errorList.addAll(addActualSectionsInErrorList(actualSectionList)); } return new Result(actionName, errorList); } }
From source file:fi.vrk.xroad.catalog.persistence.MemberRepositoryTest.java
@Test public void testGetChangedSince() { LocalDateTime changedSince = testUtil.createDate(1, 1, 2017); Iterable<Member> members = memberRepository.findActiveChangedSince(changedSince); // members 3-7 have been changed since 1/1/2017, // 3-6 have different parts changed, #7 has all parts changed log.info("found changed members with ids: " + testUtil.getIds(members)); assertEquals(5, Iterables.size(members)); Set ids = testUtil.getIds(members); assertTrue(ids.containsAll(Arrays.asList(3L, 4L, 5L, 6L, 7L))); log.info("found members:"); for (Member member : members) { log(member);//from ww w . j av a 2 s .co m } // verify that member #7 was fetched correctly with all the bits and pieces Optional optionalMember = testUtil.getEntity(members, 7L); assertTrue(optionalMember.isPresent()); Member member7 = (Member) optionalMember.get(); assertEquals(3, member7.getActiveSubsystems().size()); ArrayList<Service> allServices7 = new ArrayList<>(); for (Subsystem s : member7.getActiveSubsystems()) { allServices7.addAll(s.getAllServices()); } assertEquals(6, allServices7.size()); ArrayList<Wsdl> allWsdls7 = new ArrayList<>(); for (Service s : allServices7) { if (s.getWsdl() != null) { allWsdls7.add(s.getWsdl()); } } // test data: // member (7) -> subsystem (8) -> service (6) -> wsdl (4) // member (7) -> subsystem (8) -> service (8, removed) -> wsdl (6) // member (7) -> subsystem (8) -> service (9, removed) -> wsdl (7, removed) // member (7) -> subsystem (8) -> service (10) -> (-) // member (7) -> subsystem (9) -> service (7) -> wsdl (5) assertEquals(4, allWsdls7.size()); }
From source file:com.nomsic.sid.Sid.java
/** * /*from w w w . j av a 2 s. c o m*/ * @param thresholdSq * @return * @throws IOException */ public List<Match> getMatches(final double thresholdSq) throws IOException { if (recordSets == null) { Preconditions.checkNotNull(recordFile); FieldRecordProcessor processor = new FieldRecordProcessor(); processor.setIgnoreFirstLine(ignoreFirstLine); recordSets = Files.readLines(recordFile, Charset.defaultCharset(), processor); } @SuppressWarnings("unchecked") Map<SortedSet<String>, Integer> recordSetCardinalityMap = CollectionUtils.getCardinalityMap(recordSets); buildRecordSimsetMap(recordSetCardinalityMap); buildRecordFieldCountMap(); Set<Match> matches = computeMatches(); matches = Sets.filter(matches, new Predicate<Match>() { @Override public boolean apply(Match m) { return m.getSimilarityIndex() > thresholdSq; } }); ArrayList<Match> matchList = Lists.newArrayList(); matchList.addAll(matches); Collections.sort(matchList, new Comparator<Match>() { @Override public int compare(Match o1, Match o2) { return o2.getSimilarityIndex().compareTo(o1.getSimilarityIndex()); } }); return matchList; }
From source file:edu.uci.ics.jung.graph.DirectedSparseGraph.java
public boolean removeVertex(V vertex) { if (!containsVertex(vertex)) return false; // copy to avoid concurrent modification in removeEdge ArrayList<E> incident = new ArrayList<E>(getIncoming_internal(vertex)); incident.addAll(getOutgoing_internal(vertex)); for (E edge : incident) removeEdge(edge);//from ww w .j a v a2 s .co m vertices.remove(vertex); return true; }
From source file:eu.morfeoproject.fast.catalogue.planner.ScreenPlanner.java
/** * Generates all the plans from a given list of screens, already stored in the catalogue */// w w w . j a v a 2 s . c om protected void seed() { for (Screen screen : catalogue.getAllScreens()) { if (screen.getPreconditions().size() > 0) { ArrayList<Screen> screens = new ArrayList<Screen>(); screens.add(screen); ArrayList<URI> results = new ArrayList<URI>(); results.addAll(catalogue.findScreensBackwards(screens, new ArrayList<Condition>(), new ArrayList<Condition>(), true, true, 0, -1, null)); for (URI result : results) { planner.add(result, screen.getUri()); } } } }