org.apache.commons.collections4.SetUtils Java Examples

The following examples show how to use org.apache.commons.collections4.SetUtils. 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: JwtRealm.java    From spring-boot-plus with Apache License 2.0 6 votes vote down vote up
/**
 * 授权认证,设置角色/权限信息
 *
 * @param principalCollection
 * @return
 */
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
    log.debug("doGetAuthorizationInfo principalCollection...");
    // 设置角色/权限信息
    JwtToken jwtToken = (JwtToken) principalCollection.getPrimaryPrincipal();
    // 获取username
    String username = jwtToken.getUsername();
    // 获取登录用户角色权限信息
    LoginSysUserRedisVo loginSysUserRedisVo = loginRedisService.getLoginSysUserRedisVo(username);
    SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
    // 设置角色
    authorizationInfo.setRoles(SetUtils.hashSet(loginSysUserRedisVo.getRoleCode()));
    // 设置权限
    authorizationInfo.setStringPermissions(loginSysUserRedisVo.getPermissionCodes());
    return authorizationInfo;
}
 
Example #2
Source File: SecretsExtension.java    From gocd with Apache License 2.0 6 votes vote down vote up
public List<Secret> lookupSecrets(String pluginId, SecretConfig secretConfig, Set<String> keys) {
    final List<Secret> secrets = getVersionedSecretsExtension(pluginId).lookupSecrets(pluginId, secretConfig, keys);
    final Set<String> resolvedSecrets = secrets.stream().map(Secret::getKey).collect(Collectors.toSet());

    final Set<String> additionalSecretsInResponse = SetUtils.difference(resolvedSecrets, keys).toSet();
    if (!additionalSecretsInResponse.isEmpty()) {
        throw SecretResolutionFailureException.withUnwantedSecretParams(secretConfig.getId(), keys, additionalSecretsInResponse);
    }

    if (resolvedSecrets.containsAll(keys)) {
        return secrets;
    }

    final Set<String> missingSecrets = SetUtils.disjunction(resolvedSecrets, keys).toSet();
    throw SecretResolutionFailureException.withMissingSecretParams(secretConfig.getId(), keys, missingSecrets);
}
 
Example #3
Source File: PluginExtensionsAndVersionValidatorImpl.java    From gocd with Apache License 2.0 6 votes vote down vote up
private ValidationResult validate(GoPluginDescriptor descriptor, Map<String, List<String>> extensionsInfoFromPlugin) {
    ValidationResult validationResult = new ValidationResult(descriptor.id());
    final Set<String> gocdSupportedExtensions = extensionsRegistry.allRegisteredExtensions();

    final Set<String> difference = SetUtils.difference(extensionsInfoFromPlugin.keySet(), gocdSupportedExtensions).toSet();

    if (difference.size() > 0) {
        validationResult.addError(format(UNSUPPORTED_EXTENSION_ERROR_MESSAGE, difference, gocdSupportedExtensions));
        return validationResult;
    }


    for (String extensionType : extensionsInfoFromPlugin.keySet()) {
        final List<Double> gocdSupportedExtensionVersions = extensionsRegistry.gocdSupportedExtensionVersions(extensionType).stream()
                .map(Double::parseDouble).collect(toList());

        final List<String> requiredExtensionVersionsByPlugin = extensionsInfoFromPlugin.get(extensionType);
        validateExtensionVersions(validationResult, extensionType, gocdSupportedExtensionVersions, requiredExtensionVersionsByPlugin);
    }

    return validationResult;
}
 
Example #4
Source File: Mutect2IntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test(dataProvider = "vcfsForFiltering")
public void testFilterMitochondria(File unfiltered, final double minAlleleFraction, final List<String> intervals, List<Set<String>> expectedFilters, List<List<String>> expectedASFilters)  {
    final File filteredVcf = createTempFile("filtered", ".vcf");

    // vcf sequence dicts don't match ref
    runFilterMutectCalls(unfiltered, filteredVcf, MITO_REF.getAbsolutePath(),
            args -> args.add(M2ArgumentCollection.MITOCHONDRIA_MODE_LONG_NAME, true),
            args -> args.add(StandardArgumentDefinitions.DISABLE_SEQUENCE_DICT_VALIDATION_NAME, true),
            args -> args.add(M2FiltersArgumentCollection.MIN_AF_LONG_NAME, minAlleleFraction),
            args -> args.add(M2FiltersArgumentCollection.MIN_READS_ON_EACH_STRAND_LONG_NAME, 1),
            args -> args.add(M2FiltersArgumentCollection.UNIQUE_ALT_READ_COUNT_LONG_NAME, 2),
            args -> {
                intervals.stream().map(SimpleInterval::new).forEach(args::addInterval);
                return args;
            });

    final List<Set<String>> actualFilters = VariantContextTestUtils.streamVcf(filteredVcf)
            .map(VariantContext::getFilters).collect(Collectors.toList());

    final List<List<String>> actualASFilters = VariantContextTestUtils.streamVcf(filteredVcf)
            .map(vc -> AnnotationUtils.decodeAnyASListWithRawDelim(vc.getCommonInfo().getAttributeAsString(GATKVCFConstants.AS_FILTER_STATUS_KEY, ""))).collect(Collectors.toList());
    Assert.assertEquals(actualASFilters, expectedASFilters);

    Assert.assertEquals(actualFilters.size(), expectedFilters.size());
    for (int n = 0; n < actualFilters.size(); n++) {
        Assert.assertTrue(actualFilters.get(n).containsAll(expectedFilters.get(n)), "Actual filters missing some expected filters: " + SetUtils.difference(expectedFilters.get(n), actualFilters.get(n)));
        Assert.assertTrue(expectedFilters.get(n).containsAll(actualFilters.get(n)), "Expected filters missing some actual filters: " + SetUtils.difference(actualFilters.get(n), expectedFilters.get(n)));
    }

    Assert.assertEquals(actualFilters, expectedFilters);
}
 
Example #5
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenSet_when_OrderedSet_thenMaintainElementOrder() {
    Set<Integer> set = new HashSet<>(Arrays.asList(10, 1, 5));
    System.out.println("unordered set: " + set);

    Set<Integer> orderedSet = SetUtils.orderedSet(new HashSet<>());
    orderedSet.addAll(Arrays.asList(10, 1, 5));
    System.out.println("ordered set = " + orderedSet);
}
 
Example #6
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenTwoSet_whenDisjunction_thenDisjunctionSet() {
    Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
    Set<Integer> b = new HashSet<>(Arrays.asList(1, 2, 3));
    SetUtils.SetView<Integer> result = SetUtils.disjunction(a, b);
    assertTrue(result.toSet().contains(5) && result.toSet().contains(3));
}
 
Example #7
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenSet_whenTransformedSet_thenTransformedResult() {
    Set<Integer> a = SetUtils.transformedSet(new HashSet<>(), (e) -> e * 2);
    a.add(2);
    assertEquals(a.toArray()[0], 4);

    Set<Integer> source = new HashSet<>(Arrays.asList(1));
    Set<Integer> newSet = TransformedSet.transformedSet(source, (e) -> e * 2);
    assertEquals(newSet.toArray()[0], 2);
    assertEquals(source.toArray()[0], 2);
}
 
Example #8
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenTwoSets_whenIntersection_thenIntersectionResult() {
    Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
    Set<Integer> b = new HashSet<>(Arrays.asList(1, 2));
    Set<Integer> expected = new HashSet<>(Arrays.asList(1, 2));
    SetUtils.SetView<Integer> intersect = SetUtils.intersection(a, b);
    assertTrue(SetUtils.isEqualSet(expected, intersect));
}
 
Example #9
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenTwoSets_whenUnion_thenUnionResult() {
    Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
    Set<Integer> b = new HashSet<>(Arrays.asList(1, 2));
    Set<Integer> expected = new HashSet<>(Arrays.asList(1, 2, 5));
    SetUtils.SetView<Integer> union = SetUtils.union(a, b);
    assertTrue(SetUtils.isEqualSet(expected, union));
}
 
Example #10
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenTwoSets_whenDifference_thenSetView() {
    Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
    Set<Integer> b = new HashSet<>(Arrays.asList(1, 2));
    SetUtils.SetView<Integer> result = SetUtils.difference(a, b);
    assertTrue(result.size() == 1 && result.contains(5));
}
 
Example #11
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void givenSetAndPredicate_whenPredicatedSet_thenValidateSet_and_throw_IllegalArgumentException() {
    Set<String> sourceSet = new HashSet<>();
    sourceSet.addAll(Arrays.asList("London", "Lagos", "Err Source1"));
    Set<String> validatingSet = SetUtils.predicatedSet(sourceSet, (s) -> s.startsWith("L"));
    validatingSet.add("Err Source2");
}
 
Example #12
Source File: Mutect2IntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test(dataProvider = "vcfsForNuMTFiltering")
public void testNuMTFilterMitochondria(File initialFilters, final double autosomalCoverage, final List<String> intervals, List<Set<String>> expectedFilters, List<List<String>> expectedASFilters)  {
    final File filteredVcf = createTempFile("filtered", ".vcf");

    final ArgumentsBuilder args = new ArgumentsBuilder()
            .addVCF(initialFilters)
            .addOutput(filteredVcf)
            .addReference(MITO_REF.getAbsolutePath())
            .add(NuMTFilterTool.MEDIAN_AUTOSOMAL_COVERAGE_LONG_NAME, autosomalCoverage)
            .add(NuMTFilterTool.MAX_NUMT_COPIES_IN_AUTOSOME_LONG_NAME, 4.0);

    intervals.stream().map(SimpleInterval::new).forEach(args::addInterval);

    // vcf sequence dicts don't match ref
    runCommandLine(args, NuMTFilterTool.class.getSimpleName());

    final List<Set<String>> actualFilters = VariantContextTestUtils.streamVcf(filteredVcf)
            .map(VariantContext::getFilters).collect(Collectors.toList());

    final List<List<String>> actualASFilters = VariantContextTestUtils.streamVcf(filteredVcf)
            .map(vc -> AnnotationUtils.decodeAnyASListWithRawDelim(vc.getCommonInfo().getAttributeAsString(GATKVCFConstants.AS_FILTER_STATUS_KEY, ""))).collect(Collectors.toList());
    Assert.assertEquals(actualASFilters, expectedASFilters);

    Assert.assertEquals(actualFilters.size(), expectedFilters.size());
    for (int n = 0; n < actualFilters.size(); n++) {
        Assert.assertTrue(actualFilters.get(n).containsAll(expectedFilters.get(n)), "Actual filters missing some expected filters: " + SetUtils.difference(expectedFilters.get(n), actualFilters.get(n)));
        Assert.assertTrue(expectedFilters.get(n).containsAll(actualFilters.get(n)), "Expected filters missing some actual filters: " + SetUtils.difference(actualFilters.get(n), expectedFilters.get(n)));
    }

    Assert.assertEquals(actualFilters, expectedFilters);
}
 
Example #13
Source File: SchemaAnalyzer.java    From tcases with MIT License 5 votes vote down vote up
/**
 * Returns true if and only if the given schema represents an input that is applicable when
 * only instances of the given types are valid.
 */
private boolean isApplicableInput( Schema<?> schema, Set<String> validTypes)
  {
  return
    Optional.ofNullable( validTypes)
    .flatMap( required -> Optional.ofNullable( getValidTypes( schema)).map( valid -> !SetUtils.intersection( valid, required).isEmpty()))
    .orElse( true);
  }
 
Example #14
Source File: SchemaChangedListener.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
private ShardingOrchestrationEvent createSchemaNamesUpdatedEvent(final String shardingSchemaNames) {
    Collection<String> persistShardingSchemaNames = configurationNode.splitShardingSchemaName(shardingSchemaNames);
    Set<String> addedSchemaNames = SetUtils.difference(new HashSet<>(persistShardingSchemaNames), new HashSet<>(existedSchemaNames));
    if (!addedSchemaNames.isEmpty()) {
        return createUpdatedEventForNewSchema(addedSchemaNames.iterator().next());
    }
    Set<String> deletedSchemaNames = SetUtils.difference(new HashSet<>(existedSchemaNames), new HashSet<>(persistShardingSchemaNames));
    if (!deletedSchemaNames.isEmpty()) {
        return createDeletedEvent(deletedSchemaNames.iterator().next());
    }
    return new IgnoredShardingOrchestrationEvent();
}
 
Example #15
Source File: MyCSVUtils.java    From spring-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 获取所有行数据
 *
 * @param csvFile   csv 文件
 * @param duplicate 是否过滤重复行 。判断重复行的依据是各个单元格内容是否相同
 * @return
 * @throws IOException
 */
public static List<CSVRecord> getCSVRecords(File csvFile, boolean duplicate) throws IOException {

    List<CSVRecord> collection = CSVParser.parse(csvFile, MyCharsetUtils.detectEncoding(csvFile), CSVFormat.DEFAULT).getRecords();

    if (duplicate) {
        //    logger.info("in list");
        return collection;
    } else {
        //自定义了一个比较器,只比较单元格内容
        //    logger.info("in set.");
        Set set = new TreeSet(new Comparator<CSVRecord>() {
            @Override
            // record.toString() 方法输出为  CSVRecord [comment=null, mapping=null, recordNumber=55, values=[USDA, 美国农业部, 1]]
            // values 为各行的值
            public int compare(CSVRecord csv1, CSVRecord csv2) {
                String values1 = getCSVListValues(csv1).toString();
                String values2 = getCSVListValues(csv2).toString();
                return values1.compareTo(values2);
            }
        });

        //创建一个按照 参数 set 进行排序的空 set ,用法见 SetUtils
        Set set1 = SetUtils.orderedSet(set);
        //重新用 set 包装,去掉重复元素
        for (CSVRecord csvRecord : collection) {
            set1.add(csvRecord);
        }

        return new ArrayList<>(set1);
    }
}
 
Example #16
Source File: ReadOnlyParametersChecker.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
private void checkForCommonParameters(NamedParametersContainer namedParametersContainer, Set<String> readOnlyParameters,
                                      Map<String, Set<String>> commonReadOnlyParameters) {
    Set<String> commonParameters = SetUtils.intersection(namedParametersContainer.getParameters()
                                                                                 .keySet(), readOnlyParameters);
    if (!commonParameters.isEmpty()) {
        commonReadOnlyParameters.put(namedParametersContainer.getName(), commonParameters);
    }
}
 
Example #17
Source File: SysRolePermissionServiceImpl.java    From spring-boot-plus with Apache License 2.0 5 votes vote down vote up
@Override
public boolean saveSysRolePermissionBatch(Long roleId, SetUtils.SetView addSet) {
    List<SysRolePermission> list = new ArrayList<>();
    addSet.forEach(id -> {
        SysRolePermission sysRolePermission = new SysRolePermission();
        Long permissionId = (Long) id;
        sysRolePermission
                .setRoleId(roleId)
                .setPermissionId(permissionId)
                .setState(StateEnum.ENABLE.getCode());
        list.add(sysRolePermission);
    });
    return saveBatch(list, 20);
}
 
Example #18
Source File: ProjectExportServiceImpl.java    From webanno with Apache License 2.0 4 votes vote down vote up
@Override
@Transactional
public Project importProject(ProjectImportRequest aRequest, ZipFile aZip)
    throws ProjectExportException
{
    long start = currentTimeMillis();
    
    Deque<ProjectExporter> deque = new LinkedList<>(exporters);
    Set<Class<? extends ProjectExporter>> initsSeen = new HashSet<>();
    Set<ProjectExporter> initsDeferred = SetUtils.newIdentityHashSet();
    
    Project project = new Project();
    
    try {
        ExportedProject exProject = loadExportedProject(aZip);
        
        // If the name of the project is already taken, generate a new name
        String projectName = exProject.getName();
        if (projectService.existsProject(projectName)) {
            projectName = copyProjectName(projectName);
        }
        project.setName(projectName);

        // We need to set the mode here already because the mode is a non-null column.
        // In older versions of WebAnno, the mode was an enum which was serialized as upper-case
        // during export but as lower-case in the database. This is compensating for this case.
        project.setMode(StringUtils.lowerCase(exProject.getMode(), Locale.US));

        // Initial saving of the project
        projectService.createProject(project);
        
        // Apply the importers
        while (!deque.isEmpty()) {
            ProjectExporter importer = deque.pop();
            
            if (initsDeferred.contains(importer)) {
                throw new IllegalStateException("Circular initializer dependencies in "
                        + initsDeferred + " via " + importer);
            }
            
            if (initsSeen.containsAll(importer.getImportDependencies())) {
                log.debug("Applying project importer: {}", importer);
                importer.importData(aRequest, project, exProject, aZip);
                initsSeen.add(importer.getClass());
                initsDeferred.clear();
            }
            else {
                log.debug(
                        "Deferring project exporter as dependencies are not yet fulfilled: [{}]",
                        importer);
                deque.add(importer);
                initsDeferred.add(importer);
            }
        }
    }
    catch (Exception e) {
        throw new ProjectExportException("Project import failed", e);
    }
    
    log.info("Imported project [{}]({}) ({})", project.getName(), project.getId(),
            formatDurationWords(currentTimeMillis() - start, true, true));
    
    return project;
}
 
Example #19
Source File: ImageUtils.java    From openemm with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Set<String> getValidImageFileExtensions() {
	return SetUtils.unmodifiableSet(availableImageExtensions);
}
 
Example #20
Source File: MonitoringJob.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
@Transactional
public void execute( JobConfiguration jobConfiguration )
{
    notifier.clear( jobConfiguration ).notify( jobConfiguration, "Monitoring data" );

    MonitoringJobParameters monitoringJobParameters = (MonitoringJobParameters) jobConfiguration.getJobParameters();

    //TODO improve collection usage

    try
    {
        List<Period> periods;
        Collection<ValidationRule> validationRules;
        List<String> groupUIDs = monitoringJobParameters.getValidationRuleGroups();

        if ( groupUIDs.isEmpty() )
        {
            validationRules = validationRuleService
                .getValidationRulesWithNotificationTemplates();
        }
        else
        {
            validationRules = groupUIDs.stream()
                .map(validationRuleService::getValidationRuleGroup)
                .filter( Objects::nonNull )
                .map( ValidationRuleGroup::getMembers )
                .filter( Objects::nonNull )
                .reduce( Sets.newHashSet(), SetUtils::union );
        }

        if ( monitoringJobParameters.getRelativeStart() != 0 && monitoringJobParameters.getRelativeEnd() != 0 )
        {
            Date startDate = DateUtils.getDateAfterAddition( new Date(), monitoringJobParameters.getRelativeStart() );
            Date endDate = DateUtils.getDateAfterAddition( new Date(), monitoringJobParameters.getRelativeEnd() );

            periods = periodService.getPeriodsBetweenDates( startDate, endDate );

            periods = ListUtils.union( periods, periodService.getIntersectionPeriods( periods ) );
        }
        else
        {
            periods = validationRules.stream()
                .map( ValidationRule::getPeriodType )
                .distinct()
                .map( ( vr ) -> Arrays.asList( vr.createPeriod(), vr.getPreviousPeriod( vr.createPeriod() ) ) )
                .reduce( Lists.newArrayList(), ListUtils::union );
        }

        ValidationAnalysisParams parameters = validationService
            .newParamsBuilder( validationRules, null, periods )
            .withIncludeOrgUnitDescendants( true )
            .withMaxResults( ValidationService.MAX_SCHEDULED_ALERTS )
            .withSendNotifications( monitoringJobParameters.isSendNotifications() )
            .withPersistResults( monitoringJobParameters.isPersistResults() )
            .build();

        validationService.validationAnalysis( parameters );

        notifier.notify( jobConfiguration, INFO, "Monitoring process done", true );
    }
    catch ( RuntimeException ex )
    {
        notifier.notify( jobConfiguration, ERROR, "Process failed: " + ex.getMessage(), true );

        messageService.sendSystemErrorNotification( "Monitoring process failed", ex );

        throw ex;
    }
}
 
Example #21
Source File: ExactMatch.java    From AILibs with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public double loss(final List<? extends int[]> expected, final List<? extends IMultiLabelClassification> actual) {
	this.checkConsistency(expected, actual);
	return (double) IntStream.range(0, expected.size()).map(x -> SetUtils.isEqualSet(ArrayUtil.argMax(expected.get(x)), this.getThresholdedPredictionAsSet(actual.get(x))) ? 0 : 1).sum() / expected.size();
}
 
Example #22
Source File: ResilientCloudOperationExecutor.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
private Set<HttpStatus> getStatusesToIgnore() {
    if (additionalStatusesToIgnore.isEmpty()) {
        return DEFAULT_STATUSES_TO_IGNORE;
    }
    return SetUtils.union(DEFAULT_STATUSES_TO_IGNORE, additionalStatusesToIgnore);
}
 
Example #23
Source File: SysRoleServiceImpl.java    From spring-boot-plus with Apache License 2.0 4 votes vote down vote up
@Override
public boolean updateSysRolePermission(UpdateSysRolePermissionParam param) throws Exception {
    Long roleId = param.getRoleId();
    List<Long> permissionIds = param.getPermissionIds();
    // 校验角色是否存在
    SysRole sysRole = getById(roleId);
    if (sysRole == null) {
        throw new BusinessException("该角色不存在");
    }
    if (CollectionUtils.isNotEmpty(permissionIds)) {
        // 校验权限列表是否存在
        if (!sysPermissionService.isExistsByPermissionIds(permissionIds)) {
            throw new BusinessException("权限列表id匹配失败");
        }
    }
    // 获取之前的权限id集合
    List<Long> beforeList = sysRolePermissionService.getPermissionIdsByRoleId(roleId);
    // 差集计算
    // before:1,2,3,4,5,6
    // after: 1,2,3,4,7,8
    // 删除5,6 新增7,8
    // 此处真实删除,去掉deleted字段的@TableLogic注解
    Set<Long> beforeSet = new HashSet<>(beforeList);
    Set<Long> afterSet = new HashSet<>(permissionIds);
    SetView<Long> deleteSet = SetUtils.difference(beforeSet, afterSet);
    SetView<Long> addSet = SetUtils.difference(afterSet, beforeSet);
    log.debug("deleteSet = " + deleteSet);
    log.debug("addSet = " + addSet);

    if (CollectionUtils.isNotEmpty(deleteSet)) {
        // 删除权限关联
        LambdaUpdateWrapper<SysRolePermission> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(SysRolePermission::getRoleId, roleId);
        updateWrapper.in(SysRolePermission::getPermissionId, deleteSet);
        boolean deleteResult = sysRolePermissionService.remove(updateWrapper);
        if (!deleteResult) {
            throw new DaoException("删除角色权限关系失败");
        }
    }

    if (CollectionUtils.isNotEmpty(addSet)) {
        // 新增权限关联
        boolean addResult = sysRolePermissionService.saveSysRolePermissionBatch(roleId, addSet);
        if (!addResult) {
            throw new DaoException("新增角色权限关系失败");
        }
    }

    return true;
}
 
Example #24
Source File: CombiningSets.java    From tutorials with MIT License 4 votes vote down vote up
public static Set<Object> usingApacheCommons(Set<Object> first, Set<Object> second) {
    Set<Object> combined = SetUtils.union(first, second);
    return combined;
}
 
Example #25
Source File: SetOperationsUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void givenTwoSets_WhenWeUseApacheCommonsIntersect_ThenWeGetTheIntersect() {
    Set<Integer> intersectSet = SetUtils.intersection(setA, setB);
    assertEquals(setOf(2,4), intersectSet);
}
 
Example #26
Source File: SetOperationsUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void givenTwoSets_WhenWeUseApacheCommonsUnion_ThenWeGetTheUnion() {
    Set<Integer> unionSet = SetUtils.union(setA, setB);
    assertEquals(setOf(1,2,3,4,6,8), unionSet);
}
 
Example #27
Source File: CollectionExamples.java    From spring-boot with Apache License 2.0 2 votes vote down vote up
/**
 * Set,过滤重复元素
 * 按照添加的顺序
 * Returns a set that maintains the order of elements that are added backed by the given set.
 * If an element is added twice, the order is determined by the first add. The order is observed through the iterator or toArray.
 * <p/>
 *
 * @param set
 * @return
 */
public Set getOrderSet(Set set) {
    // 创建一个按照 参数 set 元素放入顺序进行排序的空 set ,返回后需要按照需求添加元素
    return SetUtils.orderedSet(set);
}
 
Example #28
Source File: SysRolePermissionService.java    From spring-boot-plus with Apache License 2.0 2 votes vote down vote up
/**
 * 批量保存角色权限关系
 *
 * @param roleId
 * @param addSet
 * @return
 * @throws Exception
 */
boolean saveSysRolePermissionBatch(Long roleId, SetUtils.SetView addSet) throws Exception;