Java Code Examples for org.apache.commons.collections4.CollectionUtils

The following examples show how to use org.apache.commons.collections4.CollectionUtils. These examples are extracted from open source projects. 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
private List<ClusterComponent> determineCdhRepoConfig(Cluster cluster, List<Component> stackCdhRepoConfig,
        String osType, String blueprintCdhVersion) {
    if (Objects.isNull(stackCdhRepoConfig) || stackCdhRepoConfig.isEmpty()) {
        DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(blueprintCdhVersion, osType);
        Map<String, String> stack = defaultCDHInfo.getRepo().getStack();
        ClouderaManagerProduct cmProduct = new ClouderaManagerProduct()
                .withVersion(defaultCDHInfo.getVersion())
                .withName(stack.get("repoid").split("-")[0])
                .withParcel(stack.get(osType));
        List<ClouderaManagerProduct> products = CollectionUtils.isNotEmpty(defaultCDHInfo.getParcels())
                ? defaultCDHInfo.getParcels() : new ArrayList<>();
        products.add(cmProduct);
        return products.stream().map(product -> new ClusterComponent(CDH_PRODUCT_DETAILS, product.getName(), new Json(product), cluster))
                .collect(Collectors.toList());
    } else {
        return stackCdhRepoConfig.stream()
                .map(Component::getAttributes)
                .map(json -> new ClusterComponent(CDH_PRODUCT_DETAILS,
                        json.getSilent(ClouderaManagerProduct.class).getName(), json, cluster))
                .collect(Collectors.toList());
    }
}
 
Example 2
@Override
protected StepPhase executeStep(ProcessContext context) {
    CloudApplicationExtended app = context.getVariable(Variables.APP_TO_PROCESS);

    getStepLogger().debug(MessageFormat.format(Messages.PUBLISHING_PUBLIC_PROVIDED_DEPENDENCIES, app.getName()));

    List<ConfigurationEntry> entriesToPublish = context.getVariable(Variables.CONFIGURATION_ENTRIES_TO_PUBLISH);

    if (CollectionUtils.isEmpty(entriesToPublish)) {
        context.setVariable(Variables.PUBLISHED_ENTRIES, Collections.emptyList());
        getStepLogger().debug(Messages.NO_PUBLIC_PROVIDED_DEPENDENCIES_FOR_PUBLISHING);
        return StepPhase.DONE;
    }

    List<ConfigurationEntry> publishedEntries = publish(entriesToPublish);

    getStepLogger().debug(Messages.PUBLISHED_ENTRIES, SecureSerialization.toJson(publishedEntries));
    context.setVariable(Variables.PUBLISHED_ENTRIES, publishedEntries);

    getStepLogger().debug(Messages.PUBLIC_PROVIDED_DEPENDENCIES_PUBLISHED);
    return StepPhase.DONE;
}
 
Example 3
Source Project: prebid-server-java   Source File: VideoResponseFactory.java    License: Apache License 2.0 6 votes vote down vote up
public VideoResponse toVideoResponse(BidRequest bidRequest, BidResponse bidResponse, List<PodError> podErrors) {
    final List<Bid> bids = bidsFrom(bidResponse);
    final boolean anyBidsReturned = CollectionUtils.isNotEmpty(bids);
    final List<ExtAdPod> adPods = adPodsWithTargetingFrom(bids);

    if (anyBidsReturned && CollectionUtils.isEmpty(adPods)) {
        throw new PreBidException("caching failed for all bids");
    }

    adPods.addAll(adPodsWithErrors(podErrors));

    final ExtResponseDebug extResponseDebug;
    final Map<String, List<ExtBidderError>> errors;
    // Fetch debug and errors information from response if requested
    if (isDebugEnabled(bidRequest)) {
        final ExtBidResponse extBidResponse = extResponseFrom(bidResponse);

        extResponseDebug = extResponseDebugFrom(extBidResponse);
        errors = errorsFrom(extBidResponse);
    } else {
        extResponseDebug = null;
        errors = null;
    }
    return VideoResponse.of(adPods, extResponseDebug, errors, null);
}
 
Example 4
Source Project: Thunder   Source File: ConfigController.java    License: Apache License 2.0 6 votes vote down vote up
private static void assembleApplication(RegistryExecutor registryExecutor, ProtocolType protocolType, ElementNode root) throws Exception {
    ElementNode protocolNode = new ElementNode(protocolType.toString(), protocolType.toString(), null, protocolType.toString());
    root.add(protocolNode);

    List<String> groups = null;
    try {
        groups = registryExecutor.getGroupList();
    } catch (Exception e) {
        LOG.warn("Get group list failed, protocol={}", protocolType);
    }

    if (CollectionUtils.isNotEmpty(groups)) {
        for (String group : groups) {
            ElementNode groupNode = new ElementNode(protocolType.toString(), group, null, group);
            protocolNode.add(groupNode);

            List<String> applications = registryExecutor.getApplicationList(group);
            for (String application : applications) {
                ElementNode applicationNode = new ElementNode(protocolType.toString(), application, null, application);
                groupNode.add(applicationNode);
            }
        }
    }
}
 
Example 5
Source Project: youran   Source File: TreeUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 根据父节点获取所有下级节点集合
 *
 * @param t        父节点对象
 * @param justLeaf 是否只采集叶子节点
 * @param <T>      树节点泛型
 * @return 子节点集合
 */
public static <T extends TreeNode> Set<T> getChildSet(T t, boolean justLeaf) {
    List<T> children = t.fetchChildren();
    if (CollectionUtils.isEmpty(children)) {
        return null;
    }
    Set<T> childSet = new HashSet<>();
    for (T child : children) {
        TreeUtil.recurTreeNode(child, (t1, isLeaf) -> {
            //仅采集叶子的情况判断
            if (justLeaf && !isLeaf) {
                return;
            }
            childSet.add(t1);
        });
    }
    return childSet;
}
 
Example 6
Source Project: DDMQ   Source File: CarreraConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean validate() throws ConfigException {
    if (CollectionUtils.isEmpty(retryDelays)) {
        throw new ConfigException("[CarreraConfiguration] retryDelays empty");
    } else if (thriftServer == null || !thriftServer.validate()) {
        throw new ConfigException("[CarreraConfiguration] thriftServer error");
    } else if (useKafka && (kafkaProducers <= 0 || MapUtils.isEmpty(kafkaConfigurationMap) || !kafkaConfigurationMap.values().stream().allMatch(KafkaConfiguration::validate))) {
        throw new ConfigException("[CarreraConfiguration] kafka config error");
    } else if (useRocketmq && (rocketmqProducers <= 0 || MapUtils.isEmpty(rocketmqConfigurationMap) || !rocketmqConfigurationMap.values().stream().allMatch(RocketmqConfiguration::validate))) {
        throw new ConfigException("[CarreraConfiguration] rocketmq config error");
    } else if (useAutoBatch && (autoBatch == null || !autoBatch.validate())) {
        throw new ConfigException("[CarreraConfiguration] autoBatch error");
    } else if (maxTps <= 0) {
        throw new ConfigException("[CarreraConfiguration] maxTps <= 0");
    } else if (tpsWarningRatio <= 0) {
        throw new ConfigException("[CarreraConfiguration] tpsWarningRatio <= 0");
    } else if (defaultTopicInfoConf == null) {
        throw new ConfigException("[CarreraConfiguration] defaultTopicInfoConf is null");
    }

    return true;
}
 
Example 7
Source Project: cuba   Source File: SettingsWindow.java    License: Apache License 2.0 6 votes vote down vote up
protected List<MenuItem> collectPermittedScreens(List<MenuItem> menuItems) {
    List<MenuItem> collectedItems = new ArrayList<>();

    for (MenuItem item : menuItems) {
        if (!item.isPermitted(userSession))
            continue;

        if (StringUtils.isNotEmpty(item.getScreen())) {
            collectedItems.add(item);
        }

        if (CollectionUtils.isNotEmpty(item.getChildren())) {
            collectedItems.addAll(collectPermittedScreens(item.getChildren()));
        }
    }

    return collectedItems;
}
 
Example 8
Source Project: tabu   Source File: BasicNeighborSolutionLocator.java    License: MIT License 6 votes vote down vote up
/**
 * Find the non-tabu {@link Solution} with the lowest value.<br>
 * This method doesn't use any Aspiration Criteria.
 */
@Override
public Solution findBestNeighbor(List<Solution> neighborsSolutions, final List<Solution> solutionsInTabu) {
	//remove any neighbor that is in tabu list
	CollectionUtils.filterInverse(neighborsSolutions, new Predicate<Solution>() {
		@Override
		public boolean evaluate(Solution neighbor) {
			return solutionsInTabu.contains(neighbor);
		}
	});
	
	//sort the neighbors
	Collections.sort(neighborsSolutions, new Comparator<Solution>() {
		@Override
		public int compare(Solution a, Solution b) {
			return a.getValue().compareTo(b.getValue());
		}
	});
	
	//get the neighbor with lowest value
	return neighborsSolutions.get(0);
}
 
Example 9
Source Project: java_in_examples   Source File: CollectionCompareTests.java    License: Apache License 2.0 6 votes vote down vote up
private static void testContainsAll() {
    Collection<String> collection1 = Lists.newArrayList("a1", "a2", "a3", "a1");
    Collection<String> collection2 = Lists.newArrayList("a1", "a2", "a3", "a1");
    Iterable<String> iterable1 = collection1;
    Iterable<String> iterable2 = collection2;
    MutableCollection<String> mutableCollection1 = FastList.newListWith("a1", "a2", "a3", "a1");
    MutableCollection<String> mutableCollection2 = FastList.newListWith("a1", "a2", "a3", "a1");

    // Check full equals with two collections
    boolean jdk =  collection1.containsAll(collection2); // using JDK
    boolean guava = Iterables.elementsEqual(iterable1, iterable2); // using guava
    boolean apache = CollectionUtils.containsAll(collection1, collection2);  // using Apache
    boolean gs = mutableCollection1.containsAll(mutableCollection2); // using GS

    System.out.println("containsAll = " + jdk + ":" + guava + ":" + apache + ":" + gs); // print containsAll = true:true:true:true
}
 
Example 10
Source Project: prebid-server-java   Source File: AppnexusBidder.java    License: Apache License 2.0 6 votes vote down vote up
private static String makeKeywords(List<AppnexusKeyVal> keywords) {
    if (CollectionUtils.isEmpty(keywords)) {
        return null;
    }

    final List<String> kvs = new ArrayList<>();
    for (AppnexusKeyVal keyVal : keywords) {
        final String key = keyVal.getKey();
        final List<String> values = keyVal.getValue();
        if (values == null || values.isEmpty()) {
            kvs.add(key);
        } else {
            for (String value : values) {
                kvs.add(String.format("%s=%s", key, value));
            }
        }
    }

    return String.join(",", kvs);
}
 
Example 11
Source Project: spring-microservice-exam   Source File: SubjectUtil.java    License: MIT License 6 votes vote down vote up
/**
 * 转换对象
 *
 * @param subjectDtoList subjectDtoList
 * @return List
 */
public static List<SubjectExcelModel> convertToExcelModel(List<SubjectDto> subjectDtoList) {
    List<SubjectExcelModel> subjectExcelModels = new ArrayList<>(subjectDtoList.size());
    subjectDtoList.forEach(subject -> {
        SubjectExcelModel subjectExcelModel = new SubjectExcelModel();
        BeanUtils.copyProperties(subject, subjectExcelModel);
        if (CollectionUtils.isNotEmpty(subject.getOptions())) {
            List<String> optionString = subject.getOptions().stream()
                    .map(option -> "$$" + option.getOptionName() + "# " + option.getOptionContent()).collect(Collectors.toList());
            subjectExcelModel.setOptions(StringUtils.join(optionString, "\n"));
        }
        subjectExcelModel.setAnswer(subject.getAnswer().getAnswer());
        subjectExcelModels.add(subjectExcelModel);
    });
    return subjectExcelModels;
}
 
Example 12
Source Project: DDMQ   Source File: TopicServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
private Map<Long, TopicOrderVo> getTopicVoMap(List<Topic> list, List<CustomTopicConf> confList, Boolean needExtraParams) {
    Map<Long/*topicID*/, TopicOrderVo> topicVoMap = Maps.newLinkedHashMap();
    list.forEach((topic -> {
        TopicOrderVo vo = TopicOrderVo.buildTopicVo(topic);
        topicVoMap.put(topic.getId(), vo);
    }));
    if (CollectionUtils.isNotEmpty(confList)) {
        Map<Long, Cluster> clusterMap = clusterService.findMap();

        confList.forEach(conf -> {
            if (topicVoMap.containsKey(conf.getTopicId())) {
                try {
                    TopicConfVo confVo = TopicConfVo.buildTopicConfVo(conf);
                    confVo.setClusterDesc(clusterMap.get(conf.getClusterId()).getDescription());
                    topicVoMap.get(conf.getTopicId()).addConf(confVo);

                } catch (Exception e) {
                    LOGGER.error("getTopicVoMap exception", e);
                }
            }
        });
    }
    return topicVoMap;
}
 
Example 13
Source Project: spring-microservice-exam   Source File: MenuService.java    License: MIT License 6 votes vote down vote up
/**
 * 合并默认租户和租户的菜单,租户菜单优先
 *
 * @param defaultMenus defaultMenus
 * @param tenantMenus  tenantMenus
 * @return List
 * @author tangyi
 * @date 2019-09-14 14:45
 */
private List<Menu> mergeMenu(List<Menu> defaultMenus, List<Menu> tenantMenus) {
	if (CollectionUtils.isEmpty(tenantMenus))
		return defaultMenus;
	List<Menu> userMenus = new ArrayList<>();
	// 默认菜单
	defaultMenus.forEach(defaultMenu -> {
		Optional<Menu> menu = tenantMenus.stream()
				.filter(tenantMenu -> tenantMenu.getName().equals(defaultMenu.getName())).findFirst();
		if (menu.isPresent()) {
			userMenus.add(menu.get());
		} else {
			userMenus.add(defaultMenu);
		}
	});
	// 租户菜单
	tenantMenus.forEach(tenantMenu -> {
		Optional<Menu> exist = userMenus.stream()
				.filter(userMenu -> userMenu.getName().equals(tenantMenu.getName()) && userMenu.getParentId()
						.equals(tenantMenu.getParentId())).findFirst();
		if (!exist.isPresent()) {
			userMenus.add(tenantMenu);
		}
	});
	return userMenus;
}
 
Example 14
Source Project: DrivingAgency   Source File: AgentManageServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
public List<AgentBaseInfoVo> listAllAgentsByDailyAchievements() {
    List<AgentVo> agentVos = listAllProcessedAgents();
    List<AgentBaseInfoVo> collect =Lists.newArrayList();
    if (CollectionUtils.isEmpty(agentVos)){
        return null;
    }
    agentVos.stream()
            .filter(agentVo -> agentVo.getStatus().equals(AgentStatus.EXAMINED.getCode()))
            .sorted(Comparator.comparing(AgentVo::getDailyAchieve).reversed())
            .forEach(agentVo -> {
                AgentBaseInfoVo agentBaseInfoVo=new AgentBaseInfoVo();
                BeanUtils.copyProperties(agentVo,agentBaseInfoVo);


                collect.add(agentBaseInfoVo);
            });
    return collect;
}
 
Example 15
/**
 *  添加数据记录并检查是否换行
 * @param row 实际当前行号
 * @param col 实际记录当前列
 * @param value  当前cell的值
 */
public void addDataAndrChangeRow(int row,int col,Object value){
	//当前行如果大于实际行表示改行忽略,不记录
	if(curRowNum!=row){
		if(CollectionUtils.isEmpty(currentSheetDataMap)){
			 currentSheetDataMap=new ArrayList<Map<String,Object>>();
		}
		currentSheetDataMap.add(currentSheetRowDataMap);
		//logger.debug( "行号:"+curRowNum +" 行内容:"+currentSheetRowDataMap.toString());
		//logger.debug( "\n" );
		currentSheetRowDataMap=new HashMap<String,Object>();
		currentSheetRowDataMap.put(trianListheadTitle[col], value);
		logger.debug(row+":"+col+"  "+value+"\r" );
		curRowNum=row;
	}else{
		currentSheetRowDataMap.put(trianListheadTitle[col], value);
		//logger.debug(row+":"+col+"  "+value+"\r" );
	}
}
 
Example 16
Source Project: jvm-sandbox-repeater   Source File: JavaEntrancePlugin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected List<EnhanceModel> getEnhanceModels() {
    if (config == null || CollectionUtils.isEmpty(config.getJavaEntranceBehaviors())) { return null;}
    List<EnhanceModel> ems = Lists.newArrayList();
    for (Behavior behavior : config.getJavaEntranceBehaviors()) {
        ems.add(EnhanceModel.convert(behavior));
    }
    return ems;
}
 
Example 17
Source Project: zkdoctor   Source File: ZKServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean offLineCluster(int clusterId) {
    List<InstanceInfo> instanceInfoList = instanceService.getInstancesByClusterId(clusterId);
    if (CollectionUtils.isEmpty(instanceInfoList)) {
        return false;
    }
    for (InstanceInfo instanceInfo : instanceInfoList) {
        stopZKInstance(instanceInfo.getId());
    }
    // 下线集群操作,直接更改集群状态
    return clusterService.updateClusterStatus(clusterId, ClusterStatusEnum.OFFLINE.getStatus());
}
 
Example 18
Source Project: DDMQ   Source File: ConfigManager.java    License: Apache License 2.0 5 votes vote down vote up
private synchronized void onDataChange(PProxyConfig newPProxyConfig) throws Exception {
    LogUtils.getMainLogger().info("proxyConfig change, old:{}, new:{}", proxyConfig, newPProxyConfig);
    if (!checkProxyConfig(newPProxyConfig)) {
        return;
    }

    //swap
    PProxyConfig oldProxyConfig = proxyConfig.clone();
    proxyConfig = newPProxyConfig;

    //add new and delete not in management
    if (!CollectionUtils.isEqualCollection(oldProxyConfig.getTopics(), proxyConfig.getTopics())) {
        Set<String> topics = getTopicsInProxyConfigAndLocal(proxyConfig);
        updateTopics(topics);
    }

    //rocketmq client update
    checkAndUpdateRmqConfig(oldProxyConfig.getCarreraConfiguration().getRocketmqConfigurationMap(),
            proxyConfig.getCarreraConfiguration().getRocketmqConfigurationMap());

    //kafka client update
    checkAndUpdateKafkaConfig(oldProxyConfig.getCarreraConfiguration().getKafkaConfigurationMap(),
            proxyConfig.getCarreraConfiguration().getKafkaConfigurationMap());

    //cluster change, update all topics
    if (!CollectionUtils.isEqualCollection(oldProxyConfig.getBrokerClusters(), proxyConfig.getBrokerClusters())) {
        updateAllTopicConfig();
        LogUtils.getMainLogger().info("cluster change, old:{}, new:{}", oldProxyConfig.getBrokerClusters(), proxyConfig.getBrokerClusters());
    }

    //node rate limiter update
    if (oldProxyConfig.getCarreraConfiguration().getMaxTps() != proxyConfig.getCarreraConfiguration().getMaxTps()
            || oldProxyConfig.getCarreraConfiguration().getTpsWarningRatio() != proxyConfig.getCarreraConfiguration().getTpsWarningRatio()) {
        requestLimiter.updateNodeConfig(proxyConfig.getCarreraConfiguration().getTpsWarningRatio(),
                proxyConfig.getCarreraConfiguration().getMaxTps());
    }

    proxyConfigService.getAndWatchIndex(proxyConfig.getTopics(), new TopicConfigCallback());
    LogUtils.getMainLogger().info("proxyConfig change completely");
}
 
Example 19
Source Project: DDMQ   Source File: BaseCarreraConsumer.java    License: Apache License 2.0 5 votes vote down vote up
protected List<OffsetTrackSnapshot> removeUnsubscriptedQids(List<OffsetTrackSnapshot> snapshots) {
    Map<String, Set<String>> subscribedQids = getCurrentQids();
    snapshots = snapshots.stream().filter(snapshot -> {
        Set<String> qids = subscribedQids.get(snapshot.getTopic());
        return CollectionUtils.isNotEmpty(qids) && qids.contains(snapshot.getQid());
    }).collect(Collectors.toList());
    return snapshots;
}
 
Example 20
/** {@inheritDoc} */
public String getAnonId(final String siteId, final String userId)
{
	// Query for a single user in the site
	List<AnonymousMapping> results = findMappingsBySiteAndUsers(siteId, Collections.singletonList(userId));

	if (CollectionUtils.isEmpty(results))
	{
		return null;
	}

	return results.get(0).getAnonId();
}
 
Example 21
@Test
public void testBigBoomAtClassicWalls3() {
    List<Wall> barriers = new LinkedList<Wall>();
    CollectionUtils.addAll(barriers, new OriginalWalls(v(SIZE)).iterator());
    Point source = pt(11, 12);
    int radius = 3;
    int countBlasts = 2*radius + 1;

    assertBoom(barriers, source, radius, countBlasts,
            "☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼\n" +
            "☼                   ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼\n" +
            "☼                   ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼\n" +
            "☼          ҉        ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼҉☼ ☼ ☼ ☼ ☼\n" +
            "☼          ҉        ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼☻☼ ☼ ☼ ☼ ☼\n" +
            "☼          ҉        ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼҉☼ ☼ ☼ ☼ ☼\n" +
            "☼          ҉        ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼\n" +
            "☼                   ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼\n" +
            "☼                   ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼\n" +
            "☼                   ☼\n" +
            "☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼ ☼\n" +
            "☼                   ☼\n" +
            "☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼\n");
}
 
Example 22
Source Project: WeEvent   Source File: BrokerService.java    License: Apache License 2.0 5 votes vote down vote up
private void deleteRule(BrokerEntity brokerEntity, HttpServletRequest request) throws GovernanceException {
    try {
        List<RuleEngineEntity> ruleEngines = ruleEngineRepository.findAllByBrokerIdAndDeleteAt(brokerEntity.getId(), IsDeleteEnum.NOT_DELETED.getCode());
        if (CollectionUtils.isNotEmpty(ruleEngines)) {
            for (RuleEngineEntity ruleEngine : ruleEngines) {
                ruleEngineService.deleteProcessRule(request, ruleEngine);
            }
        }
    } catch (Exception e) {
        log.error("delete rule fail", e);
        throw new GovernanceException("delete rule fail", e);
    }
}
 
Example 23
Source Project: cuba   Source File: SwingXTableSettings.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Element element, boolean sortable) {
    String horizontalScroll = element.attributeValue("horizontalScroll");
    if (!StringUtils.isBlank(horizontalScroll)) {
        table.setHorizontalScrollEnabled(Boolean.valueOf(horizontalScroll));
    }

    loadFontPreferences(element);

    final Element columnsElem = element.element("columns");
    if (columnsElem == null) {
        return;
    }

    Collection<String> modelIds = new LinkedList<>();
    for (TableColumn modelColumn : table.getColumns(true)) {
        modelIds.add(String.valueOf(modelColumn.getIdentifier()));
    }

    Collection<String> loadedIds = new LinkedList<>();
    for (Element colElem : Dom4j.elements(columnsElem, "column")) {
        String id = colElem.attributeValue("id");
        loadedIds.add(id);
    }

    Configuration configuration = AppBeans.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);

    if (clientConfig.getLoadObsoleteSettingsForTable()
            || CollectionUtils.isEqualCollection(modelIds, loadedIds)) {
        applyColumnSettings(element, sortable);
    }
}
 
Example 24
public List<AclLevelRes> dynamicMenuTree(DynamicMenuAuthorReq loginAuthReq, RedisUser redisUser) {
    List<AclDO> userAclList = commonSysCoreServiceCache.getUserAclList(loginAuthReq, redisUser);
    //获取第三方管理员权限id列表
    String redisAdminKey = RedisKeyEnum.REDIS_ADMIN_ROLE_STR.getKey() + redisUser.getTenantId();
    Object roleDoObj = redisUtil.get(redisAdminKey);
    if (null == roleDoObj) {
        return Lists.newArrayList();
    }
    RoleDO roleDO = JSON.parseObject(String.valueOf(roleDoObj), new TypeReference<RoleDO>() {
    });
    if (roleDO.getDisabledFlag().equals(1) || roleDO.getDelFlag().equals(1)) {
        return Lists.newArrayList();
    }
    Object aclIdsObj = redisUtil.hget(RedisKeyEnum.REDIS_ROLE_ACLS_MAP.getKey() + roleDO.getId(), loginAuthReq.getAclPermissionCode());
    if (null == aclIdsObj) {
        return Lists.newArrayList();
    }

    List<Long> adminAclIds = JSON.parseObject(String.valueOf(aclIdsObj), new TypeReference<List<Long>>() {
    });
    if (CollectionUtils.isEmpty(adminAclIds)) {
        return Lists.newArrayList();
    }
    List<AclLevelRes> aclDtoList = Lists.newArrayList();
    for (AclDO acl : userAclList) {
        //权限继承
        //企业员工权限列表不能大于该企业下管理员(老板)权限列表
        if (acl.getDisabledFlag().equals(0) && acl.getDelFlag().equals(0)) {
            if (adminAclIds.contains(acl.getId())) {
                AclLevelRes dto = AclLevelRes.adapt(acl);
                dto.setHasAcl(true);
                dto.setDisabled(false);
                dto.setChecked(true);
                aclDtoList.add(dto);
            }
        }
    }
    return aclListToTree(aclDtoList);
}
 
Example 25
Source Project: dependency-track   Source File: OssIndexAnalysisTask.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Analyzes a list of Components.
 * @param components a list of Components
 */
public void analyze(final List<Component> components) {
    final Pageable<Component> paginatedComponents = new Pageable<>(100, components);
    while (!paginatedComponents.isPaginationComplete()) {
        final List<String> coordinates = new ArrayList<>();
        final List<Component> paginatedList = paginatedComponents.getPaginatedList();
        for (final Component component: paginatedList) {
            if (!component.isInternal() && shouldAnalyze(component.getPurl())) {
                //coordinates.add(component.getPurl().canonicalize()); // todo: put this back when minimizePurl() is removed
                coordinates.add(minimizePurl(component.getPurl()));
            }
        }
        if (CollectionUtils.isEmpty(coordinates)) {
            return;
        }
        final JSONObject json = new JSONObject();
        json.put("coordinates", coordinates);
        try {
            final List<ComponentReport> report = submit(json);
            processResults(report, paginatedList);
        } catch (UnirestException e) {
            handleRequestException(LOGGER, e);
        }
        LOGGER.info("Analyzing " + coordinates.size() + " component(s)");
        doThrottleDelay();
        paginatedComponents.nextPage();
    }
}
 
Example 26
@Override
public boolean equals(Object o) {
	if (this == o) {
		return true;
	}
	if (o == null || getClass() != o.getClass()) {
		return false;
	}
	ValueProviderImpl that = (ValueProviderImpl) o;
	return Objects.equals(name, that.name) &&
			Objects.equals(type, that.type) &&
			CollectionUtils.isEqualCollection(parameters, that.parameters);
}
 
Example 27
@Override
@Transactional
@Validate("deleteSubscriber") // TODO Check, why use "deleteSubscriber" validation rule here???
public Map<String, Object> getSubscriber(RecipientModel model) {
	Set<String> columns = model.getColumns();
	if (CollectionUtils.isEmpty(columns)) {
		return recipientDao.getCustomerDataFromDb(model.getCompanyId(), model.getCustomerId());
	} else {
		return recipientDao.getCustomerDataFromDb(model.getCompanyId(), model.getCustomerId(), columns);
	}
}
 
Example 28
Source Project: emissary   Source File: FeedCommand.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void startService() {
    if (CollectionUtils.isEmpty(priorityDirectories)) {
        LOG.error("No input root or priority directories specified");
        throw new ParameterException("Missing required parameter '-i' for input root or priority directories");
    }

    LOG.info("Starting feeder using {} as the workspace class", workspaceClass);
    try {
        WorkSpace ws = (WorkSpace) Class.forName(workspaceClass).getConstructor(FeedCommand.class).newInstance(this);
        ws.run();
    } catch (Exception e) {
        LOG.error("Error running WorkSpace class: {} ", workspaceClass, e);
    }
}
 
Example 29
Source Project: chronus   Source File: ClusterH2DaoImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<ClusterEntity> selectListAll() {
    List<ClusterH2Entity> envH2Entities = clusterJpaRepository.findAll();
    if (CollectionUtils.isEmpty(envH2Entities)) {
        return new ArrayList<>();
    }

    return envH2Entities.stream().map(this::transferEntity).collect(Collectors.toList());
}
 
Example 30
Source Project: sqlg   Source File: TestBatchNormalPrimitive.java    License: MIT License 5 votes vote down vote up
private void testShortEdge_assert(SqlgGraph sqlgGraph, Set<Edge> edgeSet, Set<Short> edgeNameSet) {
    Set<Edge> edges = sqlgGraph.traversal().E().toSet();
    Set<Short> edgesName = sqlgGraph.traversal().E().<Short>values("name").toSet();
    assertEquals(10, edges.size(), 0);
    assertTrue(CollectionUtils.isEqualCollection(edgeSet, edges));
    assertTrue(CollectionUtils.isEqualCollection(edgeNameSet, edgesName));
}