org.apache.commons.collections.ListUtils Java Examples
The following examples show how to use
org.apache.commons.collections.ListUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkflowTrackerConcurrencyTest.java From hop with Apache License 2.0 | 6 votes |
@Test public void readAndUpdateTrackerConcurrently() throws Exception { final AtomicBoolean condition = new AtomicBoolean( true ); List<Getter> getters = new ArrayList<Getter>( gettersAmount ); for ( int i = 0; i < gettersAmount; i++ ) { getters.add( new Getter( condition, tracker ) ); } List<Searcher> searchers = new ArrayList<Searcher>( searchersAmount ); for ( int i = 0; i < searchersAmount; i++ ) { int lookingFor = updatersAmount * updatersCycles / 2 + i; assertTrue( "We are looking for reachable index", lookingFor < updatersAmount * updatersCycles ); searchers.add( new Searcher( condition, tracker, mockJobEntryCopy( "workflow-action-" + lookingFor, lookingFor ) ) ); } final AtomicInteger generator = new AtomicInteger( 0 ); List<Updater> updaters = new ArrayList<Updater>( updatersAmount ); for ( int i = 0; i < updatersAmount; i++ ) { updaters.add( new Updater( tracker, updatersCycles, generator, "workflow-action-%d" ) ); } //noinspection unchecked ConcurrencyTestRunner.runAndCheckNoExceptionRaised( updaters, ListUtils.union( getters, searchers ), condition ); assertEquals( updatersAmount * updatersCycles, generator.get() ); }
Example #2
Source File: UserFinderAction.java From entando-components with GNU Lesser General Public License v3.0 | 6 votes |
@Override public List<String> getSearchResult() { List<String> mainSearchResult = super.getSearchResult(); try { Integer userType = this.getUserType(); if (null == userType || userType == 0) { return mainSearchResult; } else { Boolean entandoUser = (userType == 1); List<String> ldapUsernames = this.getLdapUsernames(); List<String> newList = null; if (entandoUser) { newList = (List<String>) ListUtils.removeAll(mainSearchResult, ldapUsernames); } else { newList = (List<String>) ListUtils.intersection(mainSearchResult, ldapUsernames); } return newList; } } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "getSearchResult"); throw new RuntimeException("Error while searching users", t); } }
Example #3
Source File: CollectionGroupBuilder.java From rice with Educational Community License v2.0 | 6 votes |
/** * Performs any filtering necessary on the collection before building the collection fields. * * <p>If showInactive is set to false and the collection line type implements {@code Inactivatable}, * invokes the active collection filter. Then any {@link CollectionFilter} instances configured for the collection * group are invoked to filter the collection. Collections lines must pass all filters in order to be * displayed</p> * * @param view view instance that contains the collection * @param model object containing the views data * @param collectionGroup collection group component instance that will display the collection * @param collection collection instance that will be filtered */ protected List<Integer> performCollectionFiltering(View view, Object model, CollectionGroup collectionGroup, Collection<?> collection) { List<Integer> filteredIndexes = new ArrayList<Integer>(); for (int i = 0; i < collection.size(); i++) { filteredIndexes.add(Integer.valueOf(i)); } if (Inactivatable.class.isAssignableFrom(collectionGroup.getCollectionObjectClass()) && !collectionGroup .isShowInactiveLines()) { List<Integer> activeIndexes = collectionGroup.getActiveCollectionFilter().filter(view, model, collectionGroup); filteredIndexes = ListUtils.intersection(filteredIndexes, activeIndexes); } for (CollectionFilter collectionFilter : collectionGroup.getFilters()) { List<Integer> indexes = collectionFilter.filter(view, model, collectionGroup); filteredIndexes = ListUtils.intersection(filteredIndexes, indexes); if (filteredIndexes.isEmpty()) { break; } } return filteredIndexes; }
Example #4
Source File: PcapGetterHBaseImplTest.java From opensoc-streaming with Apache License 2.0 | 6 votes |
/** * Test_sort keys by asc order_with out reverse traffic. * * @throws IOException * Signals that an I/O exception has occurred. */ @Test public void test_sortKeysByAscOrder_withOutReverseTraffic() throws IOException { PcapGetterHBaseImpl pcapGetter = (PcapGetterHBaseImpl) PcapGetterHBaseImpl .getInstance(); List<String> keys = new ArrayList<String>(); keys.add("18800006-1800000b-11-0035-3810"); keys.add("18800006-1800000b-06-0050-5af6"); keys.add("18800006-1800000b-06-0019-caac"); List<String> result = pcapGetter.sortKeysByAscOrder(keys, false); List<String> testKeys = new ArrayList<String>(); testKeys.add("18800006-1800000b-06-0019-caac"); testKeys.add("18800006-1800000b-06-0050-5af6"); testKeys.add("18800006-1800000b-11-0035-3810"); Assert.isTrue(ListUtils.isEqualList(result, testKeys)); }
Example #5
Source File: ReloadingDataDictionary.java From rice with Educational Community License v2.0 | 6 votes |
/** * Call back when a dictionary file is changed. Calls the spring bean reader * to reload the file (which will override beans as necessary and destroy * singletons) and runs the indexer * * @see no.geosoft.cc.io.FileListener#fileChanged(java.io.File) */ public void fileChanged(File file) { LOG.info("reloading dictionary configuration for " + file.getName()); try { List<String> beforeReloadBeanNames = Arrays.asList(ddBeans.getBeanDefinitionNames()); Resource resource = new FileSystemResource(file); xmlReader.loadBeanDefinitions(resource); List<String> afterReloadBeanNames = Arrays.asList(ddBeans.getBeanDefinitionNames()); List<String> addedBeanNames = ListUtils.removeAll(afterReloadBeanNames, beforeReloadBeanNames); String namespace = KRADConstants.DEFAULT_NAMESPACE; if (fileToNamespaceMapping.containsKey(file.getAbsolutePath())) { namespace = fileToNamespaceMapping.get(file.getAbsolutePath()); } ddIndex.addBeanNamesToNamespace(namespace, addedBeanNames); performDictionaryPostProcessing(true); } catch (Exception e) { LOG.info("Exception in dictionary hot deploy: " + e.getMessage(), e); } }
Example #6
Source File: GroupItem.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/** * The accepted command types of a group item is the same as of the underlying base item. * If none is defined, the intersection of all sets of accepted command types of all group * members is used instead. * * @return the accepted command types of this group item */ @Override @SuppressWarnings("unchecked") public List<Class<? extends Command>> getAcceptedCommandTypes() { if (baseItem != null) { return baseItem.getAcceptedCommandTypes(); } else { List<Class<? extends Command>> acceptedCommandTypes = null; for (Item item : members) { if (acceptedCommandTypes == null) { acceptedCommandTypes = item.getAcceptedCommandTypes(); } else { acceptedCommandTypes = ListUtils.intersection(acceptedCommandTypes, item.getAcceptedCommandTypes()); } } return acceptedCommandTypes == null ? ListUtils.EMPTY_LIST : acceptedCommandTypes; } }
Example #7
Source File: JobTrackerConcurrencyTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void readAndUpdateTrackerConcurrently() throws Exception { final AtomicBoolean condition = new AtomicBoolean( true ); List<Getter> getters = new ArrayList<Getter>( gettersAmount ); for ( int i = 0; i < gettersAmount; i++ ) { getters.add( new Getter( condition, tracker ) ); } List<Searcher> searchers = new ArrayList<Searcher>( searchersAmount ); for ( int i = 0; i < searchersAmount; i++ ) { int lookingFor = updatersAmount * updatersCycles / 2 + i; assertTrue( "We are looking for reachable index", lookingFor < updatersAmount * updatersCycles ); searchers.add( new Searcher( condition, tracker, mockJobEntryCopy( "job-entry-" + lookingFor, lookingFor ) ) ); } final AtomicInteger generator = new AtomicInteger( 0 ); List<Updater> updaters = new ArrayList<Updater>( updatersAmount ); for ( int i = 0; i < updatersAmount; i++ ) { updaters.add( new Updater( tracker, updatersCycles, generator, "job-entry-%d" ) ); } //noinspection unchecked ConcurrencyTestRunner.runAndCheckNoExceptionRaised( updaters, ListUtils.union( getters, searchers ), condition ); assertEquals( updatersAmount * updatersCycles, generator.get() ); }
Example #8
Source File: PcapGetterHBaseImplTest.java From opensoc-streaming with Apache License 2.0 | 6 votes |
/** * Test_remove duplicates. * * @throws IOException * Signals that an I/O exception has occurred. */ @Test public void test_removeDuplicates() throws IOException { PcapGetterHBaseImpl pcapGetter = (PcapGetterHBaseImpl) PcapGetterHBaseImpl .getInstance(); List<String> keys = new ArrayList<String>(); keys.add("18800006-1800000b-06-0050-5af6"); keys.add("18800006-1800000b-11-0035-3810"); keys.add("18800006-1800000b-06-0019-caac"); keys.add("18800006-1800000b-06-0050-5af6"); List<String> deDupKeys = pcapGetter.removeDuplicateKeys(keys); Assert.isTrue(deDupKeys.size() == 3); List<String> testKeys = new ArrayList<String>(); keys.add("18800006-1800000b-06-0050-5af6"); keys.add("18800006-1800000b-11-0035-3810"); keys.add("18800006-1800000b-06-0019-caac"); ListUtils.isEqualList(deDupKeys, testKeys); }
Example #9
Source File: LateralJoinPrel.java From Bats with Apache License 2.0 | 6 votes |
/** * Check to make sure that the fields of the inputs are the same as the output field names. * If not, insert a project renaming them. */ public RelNode getLateralInput(int ordinal, RelNode input) { int offset = ordinal == 0 ? 0 : getInputSize(0); Preconditions.checkArgument(DrillJoinRelBase.uniqueFieldNames(input.getRowType())); final List<String> fields = getRowType().getFieldNames(); final List<String> inputFields = input.getRowType().getFieldNames(); final List<String> outputFields = fields.subList(offset, offset + getInputSize(ordinal)); if (ListUtils.subtract(outputFields, inputFields).size() != 0) { // Ensure that input field names are the same as output field names. // If there are duplicate field names on left and right, fields will get // lost. // In such case, we need insert a rename Project on top of the input. return rename(input, input.getRowType().getFieldList(), outputFields); } else { return input; } }
Example #10
Source File: SqlConverter.java From Bats with Apache License 2.0 | 6 votes |
/** * check if the schema provided is a valid schema: * <li>schema is not indicated (only one element in the names list)<li/> * * @param names list of schema and table names, table name is always the last element * @throws UserException if the schema is not valid. */ private void isValidSchema(final List<String> names) throws UserException { SchemaPlus defaultSchema = session.getDefaultSchema(this.rootSchema); String defaultSchemaCombinedPath = SchemaUtilites.getSchemaPath(defaultSchema); List<String> schemaPath = Util.skipLast(names); String schemaPathCombined = SchemaUtilites.getSchemaPath(schemaPath); String commonPrefix = SchemaUtilites.getPrefixSchemaPath(defaultSchemaCombinedPath, schemaPathCombined, parserConfig.caseSensitive()); boolean isPrefixDefaultPath = commonPrefix.length() == defaultSchemaCombinedPath.length(); List<String> fullSchemaPath = Strings.isNullOrEmpty(defaultSchemaCombinedPath) ? schemaPath : isPrefixDefaultPath ? schemaPath : ListUtils.union(SchemaUtilites.getSchemaPathAsList(defaultSchema), schemaPath); if (names.size() > 1 && (SchemaUtilites.findSchema(this.rootSchema, fullSchemaPath) == null && SchemaUtilites.findSchema(this.rootSchema, schemaPath) == null)) { SchemaUtilites.throwSchemaNotFoundException(defaultSchema, schemaPath); } }
Example #11
Source File: WorkflowMapConcurrencyTest.java From hop with Apache License 2.0 | 6 votes |
@Test public void updateGetAndReplaceConcurrently() throws Exception { AtomicBoolean condition = new AtomicBoolean( true ); AtomicInteger generator = new AtomicInteger( 10 ); List<Updater> updaters = new ArrayList<>(); for ( int i = 0; i < updatersAmount; i++ ) { Updater updater = new Updater( workflowMap, generator, updatersCycles ); updaters.add( updater ); } List<Getter> getters = new ArrayList<>(); for ( int i = 0; i < gettersAmount; i++ ) { getters.add( new Getter( workflowMap, condition ) ); } List<Replacer> replacers = new ArrayList<>(); for ( int i = 0; i < replaceAmount; i++ ) { replacers.add( new Replacer( workflowMap, condition ) ); } //noinspection unchecked ConcurrencyTestRunner.runAndCheckNoExceptionRaised( updaters, ListUtils.union( replacers, getters ), condition ); }
Example #12
Source File: GroupItem.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/** * The accepted data types of a group item is the same as of the underlying base item. * If none is defined, the intersection of all sets of accepted data types of all group * members is used instead. * * @return the accepted data types of this group item */ @Override @SuppressWarnings("unchecked") public List<Class<? extends State>> getAcceptedDataTypes() { if (baseItem != null) { return baseItem.getAcceptedDataTypes(); } else { List<Class<? extends State>> acceptedDataTypes = null; for (Item item : members) { if (acceptedDataTypes == null) { acceptedDataTypes = item.getAcceptedDataTypes(); } else { acceptedDataTypes = ListUtils.intersection(acceptedDataTypes, item.getAcceptedDataTypes()); } } return acceptedDataTypes == null ? ListUtils.EMPTY_LIST : acceptedDataTypes; } }
Example #13
Source File: AlertDeduplication.java From eagle with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object that) { if (that == this) { return true; } if (!(that instanceof AlertDeduplication)) { return false; } AlertDeduplication another = (AlertDeduplication) that; if (ListUtils.isEqualList(another.dedupFields, this.dedupFields) && Objects.equals(another.dedupIntervalMin, this.dedupIntervalMin) && Objects.equals(another.outputStreamId, this.outputStreamId)) { return true; } return false; }
Example #14
Source File: EurekaServerListProcessor.java From spring-cloud-gray with Apache License 2.0 | 6 votes |
@Override public List<Server> process(String serviceId, List<Server> servers) { if (!grayHoldoutServerProperties.isEnabled() || CollectionUtils.isEmpty(grayHoldoutServerProperties.getServices().get(serviceId))) { return servers; } List<Server> serverList = null; if (grayHoldoutServerProperties.isCacheable()) { serverList = serversMap.get(serviceId); if (CollectionUtils.isNotEmpty(serverList)) { return serverList; } } serverList = servers; List<Server> unUpServers = getUnUpServers(serviceId); if (CollectionUtils.isNotEmpty(unUpServers)) { serverList = ListUtils.union(servers, unUpServers); } if (grayHoldoutServerProperties.isCacheable()) { serversMap.put(serviceId, serverList); } return serverList; }
Example #15
Source File: PolicyDefinition.java From eagle with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object that) { if (that == this) { return true; } if (!(that instanceof Definition)) { return false; } Definition another = (Definition) that; if (another.type.equals(this.type) && another.value.equals(this.value) && ListUtils.isEqualList(another.inputStreams, this.inputStreams) && ListUtils.isEqualList(another.outputStreams, this.outputStreams)) { return true; } return false; }
Example #16
Source File: RibbonServerChooser.java From spring-cloud-gray with Apache License 2.0 | 6 votes |
@Override public ServerListResult<Server> distinguishAndMatchGrayServerList(List<Server> servers) { ServerListResult<Server> serverListResult = distinguishServerList(servers); if (serverListResult == null) { return null; } if (GrayClientHolder.getGraySwitcher().isEanbleGrayRouting()) { serverListResult.setGrayServers( serverListResult.getGrayServers().stream() .filter(this::matchGrayDecisions) .collect(Collectors.toList())); }else{ serverListResult.setGrayServers(ListUtils.EMPTY_LIST); } return serverListResult; }
Example #17
Source File: PolicyExecutionPlannerImpl.java From eagle with Apache License 2.0 | 6 votes |
private void retrievePartition(StreamPartition partition) { if (partition == null) { return; } if (!effectivePartitions.containsKey(partition.getStreamId())) { effectivePartitions.put(partition.getStreamId(), partition); } else if (!effectivePartitions.get(partition.getStreamId()).equals(partition)) { StreamPartition existingPartition = effectivePartitions.get(partition.getStreamId()); // If same Type & Columns but different sort spec, then use larger if (existingPartition.getType().equals(partition.getType()) && ListUtils.isEqualList(existingPartition.getColumns(), partition.getColumns()) && partition.getSortSpec().getWindowPeriodMillis() > existingPartition.getSortSpec().getWindowPeriodMillis() || existingPartition.getType().equals(StreamPartition.Type.SHUFFLE)) { effectivePartitions.put(partition.getStreamId(), partition); } else { // Throw exception as it unable to conflict effectivePartitions on same stream will not be able to run in distributed mode throw new SiddhiAppValidationException("You have incompatible partitions on stream " + partition.getStreamId() + ": [1] " + effectivePartitions.get(partition.getStreamId()).toString() + " [2] " + partition.toString() + ""); } } }
Example #18
Source File: CollectionStringEqualComparator.java From spring-cloud-gray with Apache License 2.0 | 6 votes |
@Override public boolean test(Collection<String> src, Collection<String> another) { if (CollectionUtils.isEmpty(src)) { return CollectionUtils.isEmpty(another) ? true : false; } if (CollectionUtils.isEmpty(another)) { return false; } List<String> srcSorted = new ArrayList<>(src); Collections.sort(srcSorted); List<String> anotherSorted = new ArrayList<>(another); Collections.sort(anotherSorted); // return CollectionUtils.isEqualCollection(); return ListUtils.isEqualList(srcSorted, anotherSorted); }
Example #19
Source File: JobMapConcurrencyTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void updateGetAndReplaceConcurrently() throws Exception { AtomicBoolean condition = new AtomicBoolean( true ); AtomicInteger generator = new AtomicInteger( 10 ); List<Updater> updaters = new ArrayList<>(); for ( int i = 0; i < updatersAmount; i++ ) { Updater updater = new Updater( jobMap, generator, updatersCycles ); updaters.add( updater ); } List<Getter> getters = new ArrayList<>(); for ( int i = 0; i < gettersAmount; i++ ) { getters.add( new Getter( jobMap, condition ) ); } List<Replacer> replacers = new ArrayList<>(); for ( int i = 0; i < replaceAmount; i++ ) { replacers.add( new Replacer( jobMap, condition ) ); } //noinspection unchecked ConcurrencyTestRunner.runAndCheckNoExceptionRaised( updaters, ListUtils.union( replacers, getters ), condition ); }
Example #20
Source File: SiddhiExecutionPlanner.java From flink-siddhi with Apache License 2.0 | 6 votes |
private void retrievePartition(StreamPartition partition) throws Exception { if (partition == null) { return; } if (!streamPartitions.containsKey(partition.getInputStreamId())) { streamPartitions.put(partition.getInputStreamId(), partition); } else { StreamPartition existingPartition = streamPartitions.get(partition.getInputStreamId()); if (existingPartition.getType().equals(partition.getType()) && ListUtils.isEqualList(existingPartition.getGroupByList(), partition.getGroupByList()) || existingPartition.getType().equals(StreamPartition.Type.SHUFFLE) || existingPartition.getType().equals(StreamPartition.Type.PARTITIONWITH)) { streamPartitions.put(partition.getInputStreamId(), partition); } else { throw new Exception("You have incompatible partitions on stream " + partition.getInputStreamId() + ": [1] " + streamPartitions.get(partition.getInputStreamId()).toString() + " [2] " + partition.toString() + ""); } } }
Example #21
Source File: ElementBuilder.java From hugegraph-loader with Apache License 2.0 | 6 votes |
@Override public void extractFromEdge(Map<String, Object> keyValues, List<String> fieldNames) { this.pkNames = fieldNames.stream().map(mapping()::mappingField) .collect(Collectors.toList()); List<String> primaryKeys = this.vertexLabel.primaryKeys(); E.checkArgument(ListUtils.isEqualList(this.pkNames, primaryKeys), "Make sure the the primary key fields %s are " + "not empty, or check whether the headers or " + "field_mapping are configured correctly", primaryKeys); this.pkValues = new Object[this.pkNames.size()]; for (int i = 0; i < fieldNames.size(); i++) { String fieldName = fieldNames.get(i); Object fieldValue = keyValues.get(fieldName); Object pkValue = mappingValue(fieldName, fieldValue); this.pkValues[i] = pkValue; } }
Example #22
Source File: ZookeeperCacheManager.java From bird-java with MIT License | 6 votes |
/** * 从zookeeper中加载模块以及路由信息 */ private void loadAllRoute() { if (!zkClient.exists(ZkPathConstant.ROUTE_PARENT)) { zkClient.createPersistent(ZkPathConstant.ROUTE_PARENT, true); } List<String> modules = zkClient.getChildren(ZkPathConstant.ROUTE_PARENT); modules.forEach(this::loadWatchModule); zkClient.subscribeChildChanges(ZkPathConstant.ROUTE_PARENT, (parentPath, currentModules) -> { List<String> existModules = new ArrayList<>(MODULE_MAP.keySet()); List<String> newModules = ListUtils.subtract(currentModules, existModules); List<String> removeModules = ListUtils.subtract(existModules, currentModules); newModules.forEach(this::loadWatchModule); removeModules.forEach(this::unloadModule); }); }
Example #23
Source File: RoleDBStore.java From ranger with Apache License 2.0 | 5 votes |
public List<RangerRole> getRoles(String serviceName) { List<RangerRole> ret = ListUtils.EMPTY_LIST; if (StringUtils.isNotEmpty(serviceName)) { XXService xxService = daoMgr.getXXService().findByName(serviceName); ret = getRoles(xxService); } return ret; }
Example #24
Source File: ContentListHelper.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
protected List<String> executeFullTextSearch(IContentListTagBean bean, List<String> masterContentsId, RequestContext reqCtx) throws ApsSystemException { UserFilterOptionBean fullTextUserFilter = null; List<UserFilterOptionBean> userFilterOptions = bean.getUserFilterOptions(); if (null != userFilterOptions) { for (UserFilterOptionBean userFilter : userFilterOptions) { if (null != userFilter.getFormFieldValues() && userFilter.getFormFieldValues().size() > 0) { if (!userFilter.isAttributeFilter() && userFilter.getKey().equals(UserFilterOptionBean.KEY_FULLTEXT)) { fullTextUserFilter = userFilter; } } } } if (fullTextUserFilter != null && null != fullTextUserFilter.getFormFieldValues()) { String word = fullTextUserFilter.getFormFieldValues().get(fullTextUserFilter.getFormFieldNames()[0]); Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG); List<String> fullTextResult = this.getSearchEngineManager().searchEntityId(currentLang.getCode(), word, this.getAllowedGroups(reqCtx)); if (null != fullTextResult) { return ListUtils.intersection(fullTextResult, masterContentsId); } else { return new ArrayList<>(); } } else { return masterContentsId; } }
Example #25
Source File: CombineTwoLists.java From levelup-java-examples with Apache License 2.0 | 5 votes |
@Test public void combine_two_lists_in_java_with_apache_commons () { @SuppressWarnings("unchecked") List<String> allStates = ListUtils.union( firstHalfStates, secondHalfStates); assertTrue(allStates.size() == 50); }
Example #26
Source File: TrackedEntityInstanceAclReadTests.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Assert that a list, other, of OrgUnit uids contains at least one Uid matching the inScope list of OrgUnit uids. * * @param inScope OrgUnit uids in the scope * @param other OrgUnits to test */ private void assertWithinOuScope( List<String> inScope, List<String> other ) { assertFalse( ListUtils.intersection( inScope, other ).isEmpty(), String.format( "OrganisationUnit [%s] is not within user's capture or search scope [%s]", String.join( ",", other ), String.join( ",", inScope ) ) ); }
Example #27
Source File: ReloadingDataDictionary.java From rice with Educational Community License v2.0 | 5 votes |
public void urlContentChanged(final URL url) { LOG.info("reloading dictionary configuration for " + url.toString()); try { InputStream urlStream = url.openStream(); InputStreamResource resource = new InputStreamResource(urlStream); List<String> beforeReloadBeanNames = Arrays.asList(ddBeans.getBeanDefinitionNames()); int originalValidationMode = xmlReader.getValidationMode(); xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); xmlReader.loadBeanDefinitions(resource); xmlReader.setValidationMode(originalValidationMode); List<String> afterReloadBeanNames = Arrays.asList(ddBeans.getBeanDefinitionNames()); List<String> addedBeanNames = ListUtils.removeAll(afterReloadBeanNames, beforeReloadBeanNames); String namespace = KRADConstants.DEFAULT_NAMESPACE; if (urlToNamespaceMapping.containsKey(url.toString())) { namespace = urlToNamespaceMapping.get(url.toString()); } ddIndex.addBeanNamesToNamespace(namespace, addedBeanNames); performDictionaryPostProcessing(true); } catch (Exception e) { LOG.info("Exception in dictionary hot deploy: " + e.getMessage(), e); } }
Example #28
Source File: GroupInternalServiceImpl.java From rice with Educational Community License v2.0 | 5 votes |
private MembersDiff getMembersDiff(List<String> oldMemberPrincipalIds, List<String> newMemberPrincipalIds) { // ListUtils does not check the null case. Which can happen when adding a new group // so, if they're null make them empty lists. if(oldMemberPrincipalIds == null) { oldMemberPrincipalIds = new ArrayList<String>(); } if(newMemberPrincipalIds == null) { newMemberPrincipalIds = new ArrayList<String>(); } Set<String> addedPrincipalIds = new HashSet<String>(ListUtils.subtract(newMemberPrincipalIds, oldMemberPrincipalIds)); Set<String> removedPrincipalIds = new HashSet<String>(ListUtils.subtract(oldMemberPrincipalIds, newMemberPrincipalIds)); return new MembersDiff(addedPrincipalIds, removedPrincipalIds); }
Example #29
Source File: BackupCreatorIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void givenMultipleInputMessagesFromDifferentDays_whenBackupCreatorIsUser_thenMessagesAreGroupedProperly() throws Exception { LocalDateTime currentTime = LocalDateTime.now(); InputMessage message = new InputMessage("Me", "User", currentTime, "First TestMessage"); InputMessage secondMessage = new InputMessage("Me", "User", currentTime.plusHours(1), "First TestMessage"); InputMessage thirdMessage = new InputMessage("Me", "User", currentTime.plusHours(2), "First TestMessage"); InputMessage fourthMessage = new InputMessage("Me", "User", currentTime.plusHours(3), "First TestMessage"); InputMessage fifthMessage = new InputMessage("Me", "User", currentTime.plusHours(25), "First TestMessage"); InputMessage sixthMessage = new InputMessage("Me", "User", currentTime.plusHours(26), "First TestMessage"); List<InputMessage> firstBackupMessages = Arrays.asList(message, secondMessage, thirdMessage, fourthMessage); List<InputMessage> secondBackupMessages = Arrays.asList(fifthMessage, sixthMessage); List<InputMessage> inputMessages = ListUtils.union(firstBackupMessages, secondBackupMessages); StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); env.setParallelism(1); DataStreamSource<InputMessage> testDataSet = env.fromCollection(inputMessages); CollectingSink sink = new CollectingSink(); testDataSet.assignTimestampsAndWatermarks(new InputMessageTimestampAssigner()) .timeWindowAll(Time.hours(24)) .aggregate(new BackupAggregator()) .addSink(sink); env.execute(); Awaitility.await().until(() -> sink.backups.size() == 2); assertEquals(2, sink.backups.size()); assertEquals(firstBackupMessages, sink.backups.get(0).getInputMessages()); assertEquals(secondBackupMessages, sink.backups.get(1).getInputMessages()); }
Example #30
Source File: IntervalOverlappingIteratorUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@DataProvider(name="data") public Object[][] getData() { // the sequence dictionary final SAMSequenceDictionary dictionary = new SAMSequenceDictionary(); dictionary.addSequence(new SAMSequenceRecord("1", 1000000)); dictionary.addSequence(new SAMSequenceRecord("2", 1000000)); // the set of intervals final List<SimpleInterval> intervals_1 = Arrays.asList(new SimpleInterval("1:500-600"), new SimpleInterval("1:700-800")); final List<SimpleInterval> intervals_2 = Arrays.asList(new SimpleInterval("2:100-200"), new SimpleInterval("2:400-1000")); // some records final SimpleInterval record_1_1_100 = new SimpleInterval("1:1-100"); final SimpleInterval record_1_1_800 = new SimpleInterval("1:1-800"); final SimpleInterval record_1_500_600 = new SimpleInterval("1:500-600"); final SimpleInterval record_1_700_750 = new SimpleInterval("1:700-750"); final SimpleInterval record_2_100_150 = new SimpleInterval("2:100-150"); final SimpleInterval record_2_900_999 = new SimpleInterval("2:900-999"); // test cases return new Object[][] { // first record starts before the first interval, second record overlaps the first interval {intervals_1, dictionary, new SimpleInterval[]{record_1_1_100, record_1_500_600, record_2_900_999}, new SimpleInterval[]{record_1_500_600}}, // first record starts after the first interval, second interval overlaps the first record {intervals_1, dictionary, new SimpleInterval[]{record_1_700_750, record_2_900_999}, new SimpleInterval[]{record_1_700_750}}, // first interval is on a later contig than the first record, but overlaps later records {intervals_2, dictionary, new SimpleInterval[]{record_1_1_100, record_2_900_999}, new SimpleInterval[]{record_2_900_999}}, // first interval is on an earlier contig than the first record, but later records overlap later intervals {ListUtils.union(intervals_1, intervals_2), dictionary, new SimpleInterval[]{record_2_100_150, record_2_900_999}, new SimpleInterval[]{record_2_100_150, record_2_900_999}}, // no records overlap any intervals {intervals_1, dictionary, new SimpleInterval[]{record_2_900_999}, new SimpleInterval[0]}, // an interval overlaps multiple records {intervals_1, dictionary, new SimpleInterval[]{record_1_1_800, record_1_500_600, record_2_900_999}, new SimpleInterval[]{record_1_1_800, record_1_500_600}}, // a record overlaps multiple intervals {intervals_1, dictionary, new SimpleInterval[]{record_1_1_800, record_2_100_150}, new SimpleInterval[]{record_1_1_800}} }; }