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

The following examples show how to use org.apache.commons.collections.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
Source Project: directory-fortress-core   Author: apache   File: ReviewMgrConsole.java    License: Apache License 2.0 6 votes vote down vote up
private static void printAddress( Address address, String label )
{
    if ( address != null )
    {
        System.out.println( label );
        if ( CollectionUtils.isNotEmpty( address.getAddresses() ) )
        {
            for ( String addr : address.getAddresses() )
            {
                System.out.println( "    line        [" + addr + "]" );
            }
        }
        System.out.println( "    city        [" + address.getCity() + "]" );
        System.out.println( "    state       [" + address.getState() + "]" );
        System.out.println( "    zip         [" + address.getPostalCode() + "]" );
    }
}
 
Example #2
Source Project: dubbox   Author: learningtcc   File: ActivityRuleService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<ActivityRuleEntity> getActivityRule(ActivityRuleEntity activityRuleEntity) throws DTSAdminException {
    ActivityRuleDO activityRuleDO = ActivityRuleHelper.toActivityRuleDO(activityRuleEntity);
    ActivityRuleDOExample example = new ActivityRuleDOExample();
    Criteria criteria = example.createCriteria();
    criteria.andIsDeletedIsNotNull();
    if (StringUtils.isNotEmpty(activityRuleDO.getBizType())) {
        criteria.andBizTypeLike(activityRuleDO.getBizType());
    }
    if (StringUtils.isNotEmpty(activityRuleDO.getApp())) {
        criteria.andAppLike(activityRuleDO.getApp());
    }
    if (StringUtils.isNotEmpty(activityRuleDO.getAppCname())) {
        criteria.andAppCnameLike(activityRuleDO.getAppCname());
    }
    example.setOrderByClause("app,biz_type");
    List<ActivityRuleDO> lists = activityRuleDOMapper.selectByExample(example);
    if (CollectionUtils.isEmpty(lists)) {
        return Lists.newArrayList();
    }
    List<ActivityRuleEntity> entities = Lists.newArrayList();
    for (ActivityRuleDO an : lists) {
        entities.add(ActivityRuleHelper.toActivityRuleEntity(an));
    }
    return entities;
}
 
Example #3
Source Project: diff-check   Author: yangziwen   File: DiffFilter.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public DiffFilter(MavenProject project, File gitDir, List<DiffEntryWrapper> entries) {
    File baseDir = project.getBasedir();
    String baseDirPath = baseDir.getAbsolutePath();
    @SuppressWarnings("unchecked")
    List<String> modules = project.getModules();
    for (DiffEntryWrapper entry : entries) {
        if (!entry.getAbsoluteNewPath().startsWith(baseDirPath)) {
            continue;
        }
        String name = StringUtils.replaceOnce(entry.getAbsoluteNewPath(), baseDirPath, "");
        if (CollectionUtils.isNotEmpty(modules)) {
            for (String module : modules) {
                if (name.startsWith("/" + module)) {
                    name = StringUtils.replaceOnce(name, "/" + module, "");
                    break;
                }
            }
        }
        if (!name.startsWith(SOURCE_PATH_PREFIX)) {
            continue;
        }
        name = StringUtils.replaceOnce(name, SOURCE_PATH_PREFIX, "");
        classPathDiffEntryMap.put(name, entry);
    }
}
 
Example #4
protected List<ApprovedLearningAgreementExecutedAction> getSentLearningAgreementActions() {
    List<ApprovedLearningAgreementExecutedAction> executedActionList =
            new ArrayList<ApprovedLearningAgreementExecutedAction>();

    CollectionUtils.select(getExecutedActionsSet(), new Predicate() {

        @Override
        public boolean evaluate(Object arg0) {
            return ((ApprovedLearningAgreementExecutedAction) arg0).isSentLearningAgreementAction();
        };

    }, executedActionList);

    Collections.sort(executedActionList, Collections.reverseOrder(ExecutedAction.WHEN_OCCURED_COMPARATOR));

    return executedActionList;
}
 
Example #5
Source Project: atlas   Author: apache   File: EntityLineageService.java    License: Apache License 2.0 6 votes vote down vote up
private boolean lineageContainsEdge(AtlasLineageInfo lineageInfo, AtlasEdge edge) {
    boolean ret = false;

    if (lineageInfo != null && CollectionUtils.isNotEmpty(lineageInfo.getRelations()) && edge != null) {
        String               relationGuid = AtlasGraphUtilsV2.getEncodedProperty(edge, RELATIONSHIP_GUID_PROPERTY_KEY, String.class);
        Set<LineageRelation> relations    = lineageInfo.getRelations();

        for (LineageRelation relation : relations) {
            if (relation.getRelationshipId().equals(relationGuid)) {
                ret = true;
                break;
            }
        }
    }

    return ret;
}
 
Example #6
Source Project: atlas   Author: apache   File: DeleteHandlerV1.java    License: Apache License 2.0 6 votes vote down vote up
public List<AtlasVertex> removeTagPropagation(AtlasVertex classificationVertex) throws AtlasBaseException {
    List<AtlasVertex> ret = new ArrayList<>();

    if (classificationVertex != null) {
        List<AtlasEdge> propagatedEdges = getPropagatedEdges(classificationVertex);

        if (CollectionUtils.isNotEmpty(propagatedEdges)) {
            AtlasClassification classification = entityRetriever.toAtlasClassification(classificationVertex);

            for (AtlasEdge propagatedEdge : propagatedEdges) {
                AtlasVertex entityVertex = propagatedEdge.getOutVertex();

                ret.add(entityVertex);

                // record remove propagation details to send notifications at the end
                RequestContext.get().recordRemovedPropagation(getGuid(entityVertex), classification);

                deletePropagatedEdge(propagatedEdge);
            }
        }
    }

    return ret;
}
 
Example #7
Source Project: DDMQ   Author: didi   File: ZKV4ConfigServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ConsoleBaseResponse<?> pushCProxyByCluster(String clusterName) throws Exception {
    Cluster cluster = clusterService.findByClusterName(clusterName);
    if (cluster == null) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群不存在");
    }
    List<Node> list = nodeService.findByClusterIdNodeType(cluster.getId(), NodeType.CONSUMER_PROXY);
    if (CollectionUtils.isEmpty(list)) {
        return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "集群暂无CProxy");
    }

    for (Node node : list) {
        updateCProxyConfig(node.getId());
    }
    return ConsoleBaseResponse.success();
}
 
Example #8
Source Project: cachecloud   Author: sohutv   File: ClientVersionServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<AppClientVersion> getAppAllServerClientVersion(long appId) {
    List<AppClientVersion> appClientVersionList = getAppAllClientVersion(appId);
    if (CollectionUtils.isEmpty(appClientVersionList)) {
        return Collections.emptyList();
    }
    List<AppClientVersion> appClientVersionServerList = new ArrayList<AppClientVersion>();
    for (AppClientVersion appClientVersion : appClientVersionList) {
        String clientIp = appClientVersion.getClientIp();
        String[] items = clientIp.split(".");
        //过滤办公网段ip
        if (!OFFICE_IP.contains(items[0] + "." + items[1])) {
            appClientVersionServerList.add(appClientVersion);
        }
    }
    return appClientVersionServerList;
}
 
Example #9
Source Project: projectforge-webapp   Author: micromata   File: EingangsrechnungDao.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the scales of percentage and currency amounts. <br/>
 * Gutschriftsanzeigen dürfen keine Rechnungsnummer haben. Wenn eine Rechnungsnummer für neue Rechnungen gegeben wurde, so muss sie
 * fortlaufend sein. Berechnet das Zahlungsziel in Tagen, wenn nicht gesetzt, damit es indiziert wird.
 * @see org.projectforge.core.BaseDao#onSaveOrModify(org.projectforge.core.ExtendedBaseDO)
 */
@Override
protected void onSaveOrModify(final EingangsrechnungDO obj)
{
  if (obj.getZahlBetrag() != null) {
    obj.setZahlBetrag(obj.getZahlBetrag().setScale(2, RoundingMode.HALF_UP));
  }
  obj.recalculate();
  if (CollectionUtils.isEmpty(obj.getPositionen()) == true) {
    throw new UserException("fibu.rechnung.error.rechnungHatKeinePositionen");
  }
  final int size = obj.getPositionen().size();
  for (int i = size - 1; i > 0; i--) {
    // Don't remove first position, remove only the last empty positions.
    final EingangsrechnungsPositionDO position = obj.getPositionen().get(i);
    if (position.getId() == null && position.isEmpty() == true) {
      obj.getPositionen().remove(i);
    } else {
      break;
    }
  }
  RechnungDao.writeUiStatusToXml(obj);
}
 
Example #10
Source Project: ranger   Author: apache   File: RangerServiceDefHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Builds a directed graph where each resource is node and arc goes from parent level to child level
 *
 * @param resourceDefs
 * @return
 */
DirectedGraph createGraph(List<RangerResourceDef> resourceDefs) {
	DirectedGraph graph = null;

	if(CollectionUtils.isNotEmpty(resourceDefs)) {
		graph = new DirectedGraph();

		for (RangerResourceDef resourceDef : resourceDefs) {
			String name = resourceDef.getName();

			graph.add(name);
			String parent = resourceDef.getParent();
			if (StringUtils.isNotEmpty(parent)) {
				graph.addArc(parent, name);
			}
		}
	}

	if (LOG.isDebugEnabled()) {
		LOG.debug("Created graph for resources: " + graph);
	}
	return graph;
}
 
Example #11
Source Project: fenixedu-academic   Author: FenixEdu   File: CurricularCourse.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public boolean hasActiveScopeInGivenSemesterForCommonAndGivenBranch(final Integer semester, final Branch branch) {

    Collection<CurricularCourseScope> scopes = getScopesSet();

    List<CurricularCourseScope> result = (List<CurricularCourseScope>) CollectionUtils.select(scopes, new Predicate() {
        @Override
        public boolean evaluate(Object obj) {
            CurricularCourseScope curricularCourseScope = (CurricularCourseScope) obj;
            return ((curricularCourseScope.getBranch().getBranchType().equals(BranchType.COMNBR) || curricularCourseScope
                    .getBranch().equals(branch))
                    && curricularCourseScope.getCurricularSemester().getSemester().equals(semester) && curricularCourseScope
                    .isActive().booleanValue());
        }
    });

    return !result.isEmpty();
}
 
Example #12
Source Project: ExecDashboard   Author: Hygieia   File: PortfolioCollector.java    License: Apache License 2.0 6 votes vote down vote up
private Iterable<Lob> createLobs() {
    List<Lob> lobList = new ArrayList<>();

    if (CollectionUtils.isEmpty(lobRowsList)){
        return lobList;
    }
    for (Row productRow : lobRowsList) {
        String lobName = productRow.getAs("ownerDept");
        String pName = productRow.getAs("businessOwner");

        Lob lob =
                lobList.stream()
                        .filter(l -> l.getName().equalsIgnoreCase(lobName))
                        .findFirst().orElse(null);
        if (lob == null) {
            lob = new Lob();
            lob.setName(lobName);
            lobList.add(lob);
        }
        LOGGER.debug("Lob Name = " + lobName);
        addProductToLob(lob, productRow);
        lob.addOwner(new PeopleRoleRelation(getPeople(pName, "businessOwner"), RoleRelationShipType.BusinessOwner));
    }
    lobRepository.deleteAll();
    return lobRepository.save(lobList);
}
 
Example #13
Source Project: ranger   Author: apache   File: AtlasNotificationMapper.java    License: Apache License 2.0 6 votes vote down vote up
static private List<RangerTagDef> getTagDefs(RangerAtlasEntityWithTags entityWithTags) {
    List<RangerTagDef> ret = new ArrayList<>();

    if (entityWithTags != null && CollectionUtils.isNotEmpty(entityWithTags.getTags())) {

        Map<String, String> tagNames = new HashMap<>();

        for (EntityNotificationWrapper.RangerAtlasClassification tag : entityWithTags.getTags()) {

            if (!tagNames.containsKey(tag.getName())) {
                tagNames.put(tag.getName(), tag.getName());

                RangerTagDef tagDef = new RangerTagDef(tag.getName(), "Atlas");
                if (MapUtils.isNotEmpty(tag.getAttributes())) {
                    for (String attributeName : tag.getAttributes().keySet()) {
                        tagDef.getAttributeDefs().add(new RangerTagAttributeDef(attributeName, entityWithTags.getTagAttributeType(tag.getName(), attributeName)));
                    }
                }
                ret.add(tagDef);
            }
        }
    }

    return ret;
}
 
Example #14
Source Project: atlas   Author: apache   File: HiveHook.java    License: Apache License 2.0 6 votes vote down vote up
public PreprocessAction getPreprocessActionForHiveTable(String qualifiedName) {
    PreprocessAction ret = PreprocessAction.NONE;

    if (qualifiedName != null && (CollectionUtils.isNotEmpty(hiveTablesToIgnore) || CollectionUtils.isNotEmpty(hiveTablesToPrune))) {
        ret = hiveTablesCache.get(qualifiedName);

        if (ret == null) {
            if (isMatch(qualifiedName, hiveTablesToIgnore)) {
                ret = PreprocessAction.IGNORE;
            } else if (isMatch(qualifiedName, hiveTablesToPrune)) {
                ret = PreprocessAction.PRUNE;
            } else {
                ret = PreprocessAction.NONE;
            }

            hiveTablesCache.put(qualifiedName, ret);
        }
    }

    return ret;
}
 
Example #15
Source Project: ranger   Author: apache   File: ElasticsearchClient.java    License: Apache License 2.0 6 votes vote down vote up
private static List<String> filterResourceFromResponse(String resourceMatching, List<String> existingResources,
		List<String> resourceResponses) {
	List<String> resources = new ArrayList<String>();
	for (String resourceResponse : resourceResponses) {
		if (CollectionUtils.isNotEmpty(existingResources) && existingResources.contains(resourceResponse)) {
			continue;
		}
		if (StringUtils.isEmpty(resourceMatching) || resourceMatching.startsWith("*")
				|| resourceResponse.toLowerCase().startsWith(resourceMatching.toLowerCase())) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("filterResourceFromResponse(): Adding elasticsearch resource " + resourceResponse);
			}
			resources.add(resourceResponse);
		}
	}
	return resources;
}
 
Example #16
Source Project: product-ei   Author: wso2   File: RegistryDataManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Encrypt the registry properties by new algorithm and update
 *
 * @param registry
 * @param resource
 * @param properties
 * @throws RegistryException
 * @throws CryptoException
 */
private void updateRegistryProperties(Registry registry, String resource, List<String> properties)
        throws RegistryException, CryptoException {
    if (registry == null || StringUtils.isEmpty(resource) || CollectionUtils.isEmpty(properties)) {
        return;
    }
    if (registry.resourceExists(resource)) {
        try {
            registry.beginTransaction();
            Resource resourceObj = registry.get(resource);
            for (String encryptedPropertyName : properties) {
                String oldValue = resourceObj.getProperty(encryptedPropertyName);
                String newValue = Utility.getNewEncryptedValue(oldValue);
                if (StringUtils.isNotEmpty(newValue)) {
                    resourceObj.setProperty(encryptedPropertyName, newValue);
                }
            }
            registry.put(resource, resourceObj);
            registry.commitTransaction();
        } catch (RegistryException e) {
            registry.rollbackTransaction();
            log.error("Unable to update the registry resource", e);
            throw e;
        }
    }
}
 
Example #17
Source Project: Raincat   Author: Dromara   File: TxManagerServiceImpl.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Boolean saveTxTransactionGroup(final TxTransactionGroup txTransactionGroup) {
    try {
        final String groupId = txTransactionGroup.getId();
        //保存数据 到sortSet
        redisTemplate.opsForZSet().add(CommonConstant.REDIS_KEY_SET, groupId, CommonConstant.REDIS_SCOPE);
        final List<TxTransactionItem> itemList = txTransactionGroup.getItemList();
        if (CollectionUtils.isNotEmpty(itemList)) {
            for (TxTransactionItem item : itemList) {
                redisTemplate.opsForHash().put(cacheKey(groupId), item.getTaskKey(), item);
            }
        }
    } catch (Exception e) {
        return false;
    }
    return true;
}
 
Example #18
Source Project: circus-train   Author: HotelsDotCom   File: CommonBeans.java    License: Apache License 2.0 6 votes vote down vote up
private HiveConf newHiveConf(TunnelMetastoreCatalog hiveCatalog, Configuration baseConf) {
  List<String> siteXml = hiveCatalog.getSiteXml();
  if (CollectionUtils.isEmpty(siteXml)) {
    LOG.info("No Hadoop site XML is defined for catalog {}.", hiveCatalog.getName());
  }
  Map<String, String> properties = new HashMap<>();
  for (Entry<String, String> entry : baseConf) {
    properties.put(entry.getKey(), entry.getValue());
  }
  if (hiveCatalog.getHiveMetastoreUris() != null) {
    properties.put(ConfVars.METASTOREURIS.varname, hiveCatalog.getHiveMetastoreUris());
  }
  putConfigurationProperties(hiveCatalog.getConfigurationProperties(), properties);
  HiveConf hiveConf = new HiveConfFactory(siteXml, properties).newInstance();
  return hiveConf;
}
 
Example #19
Source Project: myth   Author: Dromara   File: ScheduledService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Scheduled auto recover.
 */
private void scheduledAutoRecover() {
    new ScheduledThreadPoolExecutor(1, MythTransactionThreadFactory.create("MythAutoRecoverService", true))
            .scheduleWithFixedDelay(() -> {
                LogUtil.debug(LOGGER, "auto recover execute delayTime:{}", mythConfig::getScheduledDelay);
                try {
                    final List<MythTransaction> mythTransactionList = mythCoordinatorService.listAllByDelay(acquireData(mythConfig));
                    if (CollectionUtils.isNotEmpty(mythTransactionList)) {
                        mythTransactionList.forEach(mythTransaction -> {
                            final Boolean success = mythSendMessageService.sendMessage(mythTransaction);
                            //发送成功 ,更改状态
                            if (success) {
                                mythTransaction.setStatus(MythStatusEnum.COMMIT.getCode());
                                publisher.publishEvent(mythTransaction, EventTypeEnum.UPDATE_STATUS.getCode());
                            }
                        });
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }, 30, mythConfig.getScheduledDelay(), TimeUnit.SECONDS);

}
 
Example #20
Source Project: atlas   Author: apache   File: AtlasStructDefStoreV2.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public AtlasStructDef create(AtlasStructDef structDef, AtlasVertex preCreateResult) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasStructDefStoreV1.create({}, {})", structDef, preCreateResult);
    }

    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_CREATE, structDef), "create struct-def ", structDef.getName());

    if (CollectionUtils.isEmpty(structDef.getAttributeDefs())) {
        throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Missing attributes for structdef");
    }

    AtlasVertex vertex = (preCreateResult == null) ? preCreate(structDef) : preCreateResult;

    AtlasStructDefStoreV2.updateVertexAddReferences(structDef, vertex, typeDefStore);

    AtlasStructDef ret = toStructDef(vertex);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasStructDefStoreV1.create({}, {}): {}", structDef, preCreateResult, ret);
    }

    return ret;
}
 
Example #21
Source Project: rest-client   Author: wisdom-projects   File: RESTUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
* 
* @Title      : diff 
* @Description: Differ JSON nodes 
* @Param      : @param json1
* @Param      : @param json2
* @Param      : @param excludedNodes
* @Param      : @return 
* @Return     : boolean
* @Throws     :
 */
public static boolean diff(String json1, String json2, List<String> exclNodes)
{
    if (CollectionUtils.isEmpty(exclNodes))
    {
        return json1.equals(json2);
    }

    JsonParser p = new JsonParser();
    JsonElement e1 = p.parse(json1);
    JsonElement e2 = p.parse(json2);

    jsonTree(e1, "", exclNodes);
    jsonTree(e2, "", exclNodes);

    return e1.equals(e2);
}
 
Example #22
Source Project: joyqueue   Author: chubaostream   File: ExtensionTransactionalResultAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<SendResult> send(List<Message> messages) {
    try {
        Preconditions.checkArgument(CollectionUtils.isNotEmpty(messages), "messages can not be null");

        List<ProduceMessage> produceMessages = checkAndConvertMessage(messages);
        List<org.joyqueue.client.internal.producer.domain.SendResult> sendResults = transactionMessageProducer.batchSend(produceMessages);
        return SendResultConverter.convert(sendResults);
    } catch (Throwable cause) {
        throw ExceptionConverter.convertProduceException(cause);
    }
}
 
Example #23
Source Project: the-app   Author: devops-dojo   File: AbstractCsvReader.java    License: Apache License 2.0 5 votes vote down vote up
protected CsvToBean<T> getParser() {
    return new CsvToBean<T>() {
        @Override
        protected PropertyEditor getPropertyEditor(final PropertyDescriptor desc) throws InstantiationException, IllegalAccessException {

            if (getDestinationClass().isAssignableFrom(User.class) && "categories".equalsIgnoreCase(
                    desc.getDisplayName())) {
                return new DummyPropertyEditor() {
                    @Override
                    public Object getValue() {
                        if (StringUtils.isBlank(getAsText())) {
                            return null;
                        }
                        Set<String> result = new HashSet<>();
                        CollectionUtils.addAll(result, StringUtils.split(getAsText(), ","));
                        return result;
                    }
                };
            }
            final Class<?> enumCandidate = desc.getWriteMethod().getParameterTypes()[0];

            if (enumCandidate.isEnum()) {
                return new DummyPropertyEditor() {
                    @Override
                    public Object getValue() {
                        try {
                            Method valueOfMethod = enumCandidate.getMethod("valueOf", String.class);
                            return valueOfMethod.invoke(null, getAsText());
                        } catch (Exception e) {
                            throw new RuntimeException("Unable to parse enum " + enumCandidate + " from csv value "
                                    + getAsText());
                        }
                    }
                };
            }
            return super.getPropertyEditor(desc);
        }
    };
}
 
Example #24
Source Project: identity-api-server   Author: wso2   File: ServerScriptLibrariesService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a script libraries list response.
 *
 * @param scriptLibraries list of script libraries.
 * @param limit           Item per page.
 * @param offset          offset
 * @return scriptLibraryListResponse
 */
private ScriptLibraryListResponse createScriptLibrariesList(List<FunctionLibrary> scriptLibraries,
                                                            Integer limit, Integer offset) {

    ScriptLibraryListResponse scriptLibraryListResponse = new ScriptLibraryListResponse();
    if (CollectionUtils.isNotEmpty(scriptLibraries)) {
        List<ScriptLibrary> scriptLibraryItem = new ArrayList<>();
        for (FunctionLibrary functionLibrary : scriptLibraries) {
            ScriptLibrary scriptLibrary = new ScriptLibrary();
            scriptLibrary.setName(functionLibrary.getFunctionLibraryName());
            scriptLibrary.setDescription(functionLibrary.getDescription());
            scriptLibrary.setSelf(
                    ContextLoader.buildURIForBody(
                            String.format(V1_API_PATH_COMPONENT + SCRIPT_LIBRARY_PATH_COMPONENT + "/%s",
                                    functionLibrary.getFunctionLibraryName())).toString());
            scriptLibraryItem.add(scriptLibrary);
        }
        scriptLibraryListResponse.setScriptLibraries(scriptLibraryItem.subList(
                Math.min(scriptLibraryItem.size(), offset),
                Math.min(scriptLibraryItem.size(), offset + limit)));
        scriptLibraryListResponse.setCount(scriptLibraryListResponse.getScriptLibraries().size());
        scriptLibraryListResponse.setTotalResults(scriptLibraries.size());
        scriptLibraryListResponse.setStartIndex(offset + 1);
    } else {
        scriptLibraryListResponse.setCount(0);
    }
    return scriptLibraryListResponse;
}
 
Example #25
Source Project: atlas   Author: apache   File: AtlasTypeDefGraphStore.java    License: Apache License 2.0 5 votes vote down vote up
private boolean hasOwnedReferenceConstraint(List<AtlasConstraintDef> constraints) {
    if (CollectionUtils.isNotEmpty(constraints)) {
        for (AtlasConstraintDef constraint : constraints) {
            if (constraint.isConstraintType(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)) {
                return true;
            }
        }
    }

    return false;
}
 
Example #26
Source Project: yes-cart   Author: inspire-software   File: ShopEntity.java    License: Apache License 2.0 5 votes vote down vote up
protected Set<Long> getCsvValuesTrimmedAsSetLong(final String attributeKey) {
    final List<String> csv = getCsvValuesTrimmedAsListRaw(getAttributeValueByCode(attributeKey));
    if (CollectionUtils.isNotEmpty(csv)) {
        final Set<Long> set = new HashSet<>();
        for (final String item : csv) {
            set.add(NumberUtils.toLong(item));
        }
        return Collections.unmodifiableSet(set);
    }
    return Collections.emptySet();
}
 
Example #27
Source Project: pinpoint   Author: naver   File: HbaseAgentEventDao.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<AgentEventBo> getAgentEvents(String agentId, Range range, Set<AgentEventType> excludeEventTypes) {
    Objects.requireNonNull(agentId, "agentId");
    Objects.requireNonNull(range, "range");

    Scan scan = new Scan();
    scan.setMaxVersions(1);
    scan.setCaching(SCANNER_CACHE_SIZE);

    scan.setStartRow(createRowKey(agentId, range.getTo()));
    scan.setStopRow(createRowKey(agentId, range.getFrom()));
    scan.addFamily(descriptor.getColumnFamilyName());

    if (!CollectionUtils.isEmpty(excludeEventTypes)) {
        FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
        for (AgentEventType excludeEventType : excludeEventTypes) {
            byte[] excludeQualifier = Bytes.toBytes(excludeEventType.getCode());
            filterList.addFilter(new QualifierFilter(CompareFilter.CompareOp.NOT_EQUAL, new BinaryComparator(excludeQualifier)));
        }
        scan.setFilter(filterList);
    }

    TableName agentEventTableName = descriptor.getTableName();
    List<AgentEventBo> agentEvents = this.hbaseOperations2.find(agentEventTableName, scan, agentEventResultsExtractor);
    logger.debug("agentEvents found. {}", agentEvents);
    return agentEvents;
}
 
Example #28
Source Project: rice   Author: kuali   File: UiDocumentServiceImpl.java    License: Educational Community License v2.0 5 votes vote down vote up
protected void setupName(IdentityManagementPersonDocument identityManagementPersonDocument, EntityBo kimEntity, List<EntityNameBo> origNames) {
   	if ( !identityManagementPersonDocument.getPrivacy().isSuppressName() ||
   			canOverrideEntityPrivacyPreferences( getInitiatorPrincipalId(identityManagementPersonDocument), identityManagementPersonDocument.getPrincipalId() ) ) {
    	List<EntityNameBo> entityNames = new ArrayList<EntityNameBo>();
		if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getNames())){
			for (PersonDocumentName name : identityManagementPersonDocument.getNames()) {
			    EntityNameBo entityName = new EntityNameBo();
				entityName.setNameCode(name.getNameCode());
                   if (name.getEntityNameType() != null) {
                       entityName.setNameType(name.getEntityNameType());
                   } else {
                       if (StringUtils.isNotEmpty(name.getNameCode())) {
                           entityName.setNameType(
                                   EntityNameTypeBo.from(getIdentityService().getNameType(name.getNameCode())));
                       }
                   }
				entityName.setFirstName(name.getFirstName());
				entityName.setLastName(name.getLastName());
				entityName.setMiddleName(name.getMiddleName());
				entityName.setNamePrefix(name.getNamePrefix());
				entityName.setNameSuffix(name.getNameSuffix());
				entityName.setActive(name.isActive());
				entityName.setDefaultValue(name.isDflt());
				entityName.setId(name.getEntityNameId());
				entityName.setEntityId(identityManagementPersonDocument.getEntityId());
				if(ObjectUtils.isNotNull(origNames)){
					for (EntityNameBo origName : origNames) {
						if (origName.getId()!=null && StringUtils.equals(origName.getId(), entityName.getId())) {
							entityName.setVersionNumber(origName.getVersionNumber());
						}

					}
				}
				entityNames.add(entityName);
			}
		}
		kimEntity.setNames(entityNames);
   	}
}
 
Example #29
Source Project: assertj-swagger   Author: RobWin   File: DocumentationDrivenValidator.java    License: Apache License 2.0 5 votes vote down vote up
private void validateDefinitionRequiredProperties(List<String> actualRequiredProperties, List<String> expectedRequiredProperties, String definitionName) {
    if (CollectionUtils.isNotEmpty(expectedRequiredProperties)) {
        softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).isNotEmpty();
        if (CollectionUtils.isNotEmpty(actualRequiredProperties)) {
            final Set<String> filteredExpectedProperties = filterWhitelistedPropertyNames(definitionName, new HashSet<>(expectedRequiredProperties));
            softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).hasSameElementsAs(filteredExpectedProperties);
        }
    } else {
        softAssertions.assertThat(actualRequiredProperties).as("Checking required properties of definition '%s'", definitionName).isNullOrEmpty();
    }
}
 
Example #30
Source Project: disconf   Author: nabilzhang   File: AppDaoImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<App> getByIds(Set<Long> ids) {

    if (CollectionUtils.isEmpty(ids)) {
        return findAll();
    }

    return find(match(Columns.APP_ID, ids));
}