public void checkRoles(HttpSession httpSession, Role[] requiredRoles) throws AuthenticationException { List<Role> lRequiredRoles = Arrays.asList(requiredRoles); Role[] userRoles = roles(httpSession); if (userRoles == null) { throw new AuthenticationException("Authentication failure: no role defined"); } List<Role> lUserRoles = Arrays.asList(userRoles); Engine.logAdmin.debug("User roles: " + lUserRoles); Engine.logAdmin.debug("Required roles: " + lRequiredRoles); // Check if the user has one (or more) role(s) in common with the required roles list if (!ListUtils.intersection(lUserRoles, lRequiredRoles).isEmpty()) { return; } throw new AuthenticationException("Authentication failure: user has not sufficient rights!"); }
/** * * @param keyValues * @param keyList * @param incomingList2 */ private void checkAndAdjustRowsColumns(List<HivePartitionFields> keyValues,List<String> keyList, List<InputHivePartitionColumn> incomingList) { Set<String> colNames= new HashSet<>(); for (int i=0; i < incomingList.size();i++) { colNames=extractColumnNamesFromObject(incomingList.get(i), colNames); List<String> notAvailableFields = ListUtils.subtract(keyList,new ArrayList<>(colNames)); if(null!=notAvailableFields&¬AvailableFields.size()>0){ for(String fieldName:notAvailableFields){ keyValues.get(i).getRowFields().add(keyList.indexOf(fieldName), ""); } } colNames.clear(); } }
@Override protected void okPressed() { this.excelFormattingDataStructure = new ExcelFormattingDataStructure(); if(StringUtils.isNotBlank(combo.getText())){ excelFormattingDataStructure.setCopyOfField(combo.getText()); } if(!StringUtils.equals(combo.getText(),"Select")){ if(schemaFields !=null && !schemaFields.isEmpty() && draggedFields !=null && !draggedFields.isEmpty()){ List remainingFields = ListUtils.subtract(schemaFields, draggedFields); excelFormattingDataStructure.setCopyFieldList(remainingFields); } }else{ excelFormattingDataStructure.setCopyFieldList(new ArrayList<>()); } if(targetTableViewer.getInput() !=null){ excelFormattingDataStructure.setListOfExcelConfiguration((List<ExcelConfigurationDataStructure>) targetTableViewer.getInput()); } super.okPressed(); }
/** * Checks if column is modifiable. * * @param groupSelectionMap * the group selection map * @param selectionList * the selection list * @return true, if is column modifiable */ public boolean isColumnModifiable(TreeMap<Integer,List<List<Integer>>> groupSelectionMap,List<Integer> selectionList){ boolean retValue = false; for(int i=groupSelectionMap.lastKey();i>=0;i--){ retValue=true; List<List<Integer>> groups = new ArrayList<>(groupSelectionMap.get(i)); for (List<Integer> grp : groups) { if (ListUtils.intersection(selectionList, grp).size()>0) { retValue=false; } } if(retValue){ groupSelectionMap.get(i).add(selectionList); break; } } return retValue; }
/** * Rearrange groups. * * @param groupSelectionMap * the group selection map * @param selectionList * the selection list */ public void rearrangeGroups(TreeMap<Integer, List<List<Integer>>> groupSelectionMap,List<Integer> selectionList) { List<Integer> tempList = new ArrayList<>(); int lastKey=groupSelectionMap.lastKey(); for (int i = lastKey; i >= 0; i--) { List<List<Integer>> groups =groupSelectionMap.get(i); for (int j=0; j<=groups.size()-1;j++) { if (selectionList.size()< groups.get(j).size()&& ListUtils.intersection(selectionList, groups.get(j)).size() > 0) { tempList.addAll(groups.get(j)); groups.get(j).clear(); groups.set(j,new ArrayList<Integer>(selectionList)); selectionList.clear(); selectionList.addAll(tempList); } tempList.clear(); } } }
/** * Rearrange groups after delete row. * * @param groupSelectionMap * the group selection map * @param selectionList * the selection list * @return true, if successful */ public boolean rearrangeGroupsAfterDeleteRow(TreeMap<Integer, List<List<Integer>>> groupSelectionMap, List<Integer> selectionList) { boolean retValue = false; int lastKey = groupSelectionMap.lastKey(); int count = 0; for (int i = lastKey; i >= 0; i--) { List<List<Integer>> groups = groupSelectionMap.get(i); for (int j = 0; j <= groups.size() - 1; j++) { if (selectionList.size() == groups.get(j).size() && ListUtils.isEqualList(selectionList, groups.get(j))) { count++; if (count >= 2) { retValue = true; } } } } return retValue; }
public Mutect(GenomeLocParser genomeLocParser, RefContentProvider refContentProvider, SamContentProvider tumorContentProvider, SamContentProvider normalContentProvider, List<RODContentProvider> rodContentProviderList, List<GenomeLoc> intervals) { super(genomeLocParser, refContentProvider, tumorContentProvider, rodContentProviderList, intervals); if (normalContentProvider != null) { hasNormalBam = true; normalSamTraverser = getNormalLocusSamTraverser(normalContentProvider, intervals); } else { normalSamTraverser = getNormalLocusSamTraverser( new SamContentProvider(ListUtils.EMPTY_LIST, tumorContentProvider.getSamFileHeader()), intervals); } initialize(); }
@Override public GroupIdList getAllGroupIds( List<String> selectedRepos ) throws ArchivaRestServiceException { List<String> observableRepos = getObservableRepos(); List<String> repos = ListUtils.intersection( observableRepos, selectedRepos ); if ( repos == null || repos.isEmpty() ) { return new GroupIdList( Collections.<String>emptyList() ); } try { return new GroupIdList( new ArrayList<>( repositorySearch.getAllGroupIds( getPrincipal(), repos ) ) ); } catch ( RepositorySearchException e ) { log.error( e.getMessage(), e ); throw new ArchivaRestServiceException( e.getMessage(), e ); } }
/** * Prepares the list of the group search base for a dynamic binding in Spring MVC. */ @SuppressWarnings("unchecked") private void prepareGroupSearchBases() { List<LdapSearchBaseDefinition> searchBases = ListUtils.lazyList( new ArrayList<LdapSearchBaseDefinition>(), new Factory() { @Override public Object create() { return LdapSearchBaseDefinition.Factory.newInstance(); } }); if (groupSyncConfig.getGroupSearch().getSearchBases().isEmpty()) { searchBases.add(LdapSearchBaseDefinition.Factory.newInstance()); } else { searchBases.addAll(groupSyncConfig.getGroupSearch().getSearchBases()); } groupSyncConfig.getGroupSearch().setSearchBases(searchBases); }
/** * Prepares the list of the user search base for a dynamic binding in Spring MVC. */ @SuppressWarnings("unchecked") private void prepareUserSearchBases() { List<LdapSearchBaseDefinition> searchBases = ListUtils.lazyList( new ArrayList<LdapSearchBaseDefinition>(), new Factory() { @Override public Object create() { return LdapSearchBaseDefinition.Factory.newInstance(); } }); if (config.getUserSearch().getSearchBases().isEmpty()) { searchBases.add(LdapSearchBaseDefinition.Factory.newInstance()); } else { searchBases.addAll(config.getUserSearch().getSearchBases()); } config.getUserSearch().setSearchBases(searchBases); }
/** * 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 * @return throws a 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); } }
/** * 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; }
/** * 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 */ @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; } }
/** * 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 */ @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; } }
/** * get node evaluated to true with respect to formula (\neg arg1 \land \neg arg2) freshly * * @param eu EU sub-formula in the form of E(arg1 U arg2) * @param arg1 the first argument of eu sub-formula * @param arg2 the second argument of eu sub-formula * * @return list of ids of nodes */ @SuppressWarnings("unchecked") private List<String> getUpdatedAlnsID4AUorEU(Composite arg1, Composite arg2) { List<String> falArg1Alns = fal4SubFormula.get(arg1); List<String> falNewArg1Alns = falNew4SubFormula.get(arg1); List<String> falArg2Alns = fal4SubFormula.get(arg2); List<String> falNewArg2Alns = falNew4SubFormula.get(arg2); List<String> arg1_newArg2 = ListUtils.intersection(falArg1Alns, falNewArg2Alns); List<String> arg2_newArg1 = ListUtils.intersection(falNewArg1Alns, falArg2Alns); List<String> newArg1_newArg2 = ListUtils.intersection(falNewArg1Alns, falNewArg2Alns); List<String> arg1_arg2 = ListUtil.union(newArg1_newArg2,ListUtil.union(arg1_newArg2, arg2_newArg1)); return arg1_arg2; }
@Override public Object[] getChildren(final Object parentElement) { if (parentElement instanceof IProject && KarafProject.isKarafProject((IProject) parentElement)) { final IProject project = (IProject) parentElement; final IKarafProject karafProject = (IKarafProject) project.getAdapter(IKarafProject.class); return new Object[] { new FeatureRepositoryContentModel(karafProject) }; } else if (parentElement instanceof ContentModel) { final ContentModel contentModel = (ContentModel) parentElement; return contentModel.getElements(); } else if (parentElement == featuresRepositories && parentElement != null) { return featuresRepositories.toArray(); } else if (parentElement instanceof FeaturesRepository) { final FeaturesRepository featuresRepository = (FeaturesRepository) parentElement; return featuresRepository.getFeatures().getFeatures().toArray(); } else if (parentElement instanceof Features) { final Features features = (Features) parentElement; return features.getFeatures().toArray(); } else if (parentElement instanceof Feature) { final Feature feature = (Feature) parentElement; return ListUtils.union(feature.getFeatures(), feature.getBundles()).toArray(); } else { return new Object[0]; } }
/** * 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); }
/** * 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)); }
@Test public void testUpdateScript() throws Exception { populateWithTestDocs(); final UpdateScript script = new UpdateScript().setScript("ctx._source.tags += newtag"); script.putToParameters("newtag", "fun"); final UpdateOptions options = new UpdateOptions(); final DocumentIdentifier docId = new DocumentIdentifier(oneaaColumbiaDoc.get_id()).setType(TEST_TYPE); final IndexResponse result = client.update(docId, script, options, USER_TOKEN); assertEquals(oneaaColumbiaDoc.get_id(), result.get_id()); final Document updated = client.get(oneaaColumbiaDoc.get_id(), oneaaColumbiaDoc.get_type(), null, USER_TOKEN); final PlaceOfInterest updatedModel = gson.fromJson(updated.get_jsonObject(), PlaceOfInterest.class); final List<String> expectedTags = ListUtils.union(Arrays.asList(oneaaColumbia.getTags()), Collections.singletonList("fun")); assertArrayEquals(expectedTags.toArray(), updatedModel.getTags()); }
public static int[] getMatchesCount(List<String> retrievedDocuments, List<String> relevantDocuments) { int[] matchesLengths = new int[]{10, 5, 1}; int[] matches = new int[]{0, 0, 0}; for (int i = 0; i < matchesLengths.length; i++) { int matchesLength = matchesLengths[i]; if (retrievedDocuments.size() < matchesLength) matchesLength = retrievedDocuments.size(); // If matchesCount is already 0, avoid intersection if (i > 0 && matches[i - 1] == 0) { // do nothing } else { matches[i] = ListUtils.intersection(relevantDocuments, retrievedDocuments.subList(0, matchesLength)).size(); } } return matches; }
/** * 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); } }
@RequestMapping(value = {"/list/{filters}","/list/{filters}/"},method = RequestMethod.GET) public ModelAndView filterList(@MatrixVariable(pathVar = "filters") Map<String,List<String>> filters, @ModelAttribute("pagination") Pagination pagination) { ModelMap mm = new ModelMap(); if(filters.containsKey("apprun")) { ApplicationRun applicationRun = applicationRunService.getApplicationRunByID(Long.valueOf(filters.get("apprun").get(0))); SearchResponse<CanonicOutput> result = canonicOutputService.getCanonicOutputByAppRun(applicationRun, pagination); pagination.setNumberOfRecords(result.getTotalResultSize()); mm.addAttribute("pagination", pagination); mm.addAttribute("outputList", result.getResults()); } else { mm.addAttribute("outputList", ListUtils.EMPTY_LIST); } return new ModelAndView("canonicoutput_list",mm); }
/** * 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; }
@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 ); }
@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() ); }
@SuppressWarnings("unchecked") public List<IUser> getUsers() { if(users==null){ return ListUtils.EMPTY_LIST; } return users; }
@SuppressWarnings("unchecked") public List<IDept> getDepts() { if(depts==null){ return ListUtils.EMPTY_LIST; } return depts; }
@SuppressWarnings("unchecked") public List<IPosition> getPositions() { if(positions==null){ return ListUtils.EMPTY_LIST; } return positions; }
@Override @SuppressWarnings("unchecked") public void reset(ActionMapping mapping, HttpServletRequest request) { super.reset(mapping, request); this.drugs = ListUtils.lazyList(new ArrayList<BpmhDrug>(), new Factory() { public BpmhDrug create() { return new BpmhDrug(); } }); setConfirm(false); }
/*** */ @Test public void getDataResourceTestAbsolutePath(){ EasyMock.expect(resourcePickingStrategie.filter(ListUtils.EMPTY_LIST,resourceName)).andReturn(urlResultList); EasyMockUnitils.replay(); InputStream is = classPathDataLocator.getDataResource(resourceName, resourcePickingStrategie ); Assert.assertNotNull(is); }
/*** */ @Test public void getDataResourceTestNonExisting(){ EasyMock.expect(resourcePickingStrategie.filter((List<URL>) EasyMock.anyObject() ,(String)EasyMock.anyObject())).andReturn(ListUtils.EMPTY_LIST); EasyMockUnitils.replay(); InputStream is = classPathDataLocator.getDataResource(resourceName.substring(0, resourceName.length()-2).concat("bla"), resourcePickingStrategie ); Assert.assertNull(is); }
public List bestBookUDK(List l,String udk){ Result res; Query q=new WildcardQuery(new Term("DC",udk+"*")); res = BisisApp.getRecordManager().selectAll3x(SerializationUtils.serialize(q), SerializationUtils.serialize(filter), "TI_sort"); List resultList = ListUtils.intersection(res.getInvs(),l); return resultList; }