List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:net.sf.sze.service.api.stammdaten.SchuelerList.java
/** * @return true wenn es keine Schueler gibt. */ public boolean isEmpty() { return CollectionUtils.isEmpty(schuelerList); }
From source file:com.zuoxiaolong.blog.cache.service.UserArticleServiceManager.java
/** * ??/*from w w w .j a va2s .c o m*/ * * @param map * @return */ public List<UserArticle> getTopCommendArticles(Map<String, Object> map) { List<UserArticle> userArticles = userArticleService.getTopCommendArticles(map); List<UserArticle> recommendUserArticle = userArticleService .getArticleCommentByCategoryId((Integer) map.get(QUERY_PARAMETER_CATEGORY_ID)); if (CollectionUtils.isEmpty(userArticles) && !CollectionUtils.isEmpty(recommendUserArticle)) { //??DEFAULT_DAYS_BEFORE_PLUS map.put(QUERY_PARAMETER_TIME, Timestamp.valueOf(((Timestamp) map.get(QUERY_PARAMETER_TIME)) .toLocalDateTime().minus(DEFAULT_DAYS_BEFORE_PLUS, ChronoUnit.DAYS))); userArticles = this.getTopReadArticlesByCategoryIdAndTime(map); } return userArticles; }
From source file:com.alibaba.otter.manager.biz.monitor.impl.GlobalMonitor.java
@Override public void explore() { Map<Long, List<AlarmRule>> rules = alarmRuleService.getAlarmRules(AlarmRuleStatus.ENABLE); if (!CollectionUtils.isEmpty(rules)) { if (needConcurrent) { concurrentProcess(rules);/* w w w .ja va 2 s . c o m*/ } else {// serialProcess(rules); } } else { log.warn("no enabled alarm rule at all. Check the rule setting please!"); } // ?? if (recoveryPaused) { List<Long> channelIds = channelService.listAllChannelId(); if (needConcurrent) { concurrentProcess(channelIds); } else {// serialProcess(channelIds); } } }
From source file:com.toptal.dao.UserDaoImpl.java
/** * Single result from query.// w w w . j av a 2 s . co m * @param query Criteria query. * @return Single entity. */ private User getSingleResult(final CriteriaQuery<User> query) { final List<User> users = this.manager.createQuery(query).getResultList(); User result = null; if (!CollectionUtils.isEmpty(users)) { result = users.get(0); } return result; }
From source file:com.consol.citrus.admin.web.ConfigurationController.java
@RequestMapping(value = "/global-variables", method = { RequestMethod.GET }) @ResponseBody// ww w. j av a 2 s . c o m public GlobalVariablesModel getGlobalVariables() { List<GlobalVariablesModel> components = springBeanService.getBeanDefinitions( projectService.getProjectContextConfigFile(), projectService.getActiveProject(), GlobalVariablesModel.class); if (CollectionUtils.isEmpty(components)) { return new GlobalVariablesModel(); } else { return components.get(0); } }
From source file:org.wallride.job.UpdatePostViewsItemReader.java
@Override protected void doReadPage() { if (results == null) { results = new CopyOnWriteArrayList<>(); } else {/*www . ja va 2 s .c o m*/ results.clear(); } Blog blog = blogService.getBlogById(Blog.DEFAULT_ID); GoogleAnalytics googleAnalytics = blog.getGoogleAnalytics(); if (googleAnalytics == null) { logger.warn("Configuration of Google Analytics can not be found"); return; } Analytics analytics = GoogleAnalyticsUtils.buildClient(googleAnalytics); try { LocalDate now = LocalDate.now(); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); Analytics.Data.Ga.Get request = analytics.data().ga() .get(googleAnalytics.getProfileId(), now.minusYears(1).format(dateTimeFormatter), now.format(dateTimeFormatter), "ga:pageViews") // .setDimensions(String.format("ga:dimension%d", googleAnalytics.getCustomDimensionIndex())) // .setSort(String.format("-ga:dimension%d", googleAnalytics.getCustomDimensionIndex())) .setDimensions(String.format("ga:pagePath", googleAnalytics.getCustomDimensionIndex())) .setSort(String.format("-ga:pageViews", googleAnalytics.getCustomDimensionIndex())) .setStartIndex(getPage() * getPageSize() + 1).setMaxResults(getPageSize()); logger.info(request.toString()); final GaData gaData = request.execute(); if (CollectionUtils.isEmpty(gaData.getRows())) { return; } results.addAll(gaData.getRows()); } catch (IOException e) { logger.warn("Failed to synchronize with Google Analytics", e); throw new GoogleAnalyticsException(e); } // logger.info("Synchronization to google analytics is now COMPLETE. {} posts updated.", count); }
From source file:com.joyveb.dbpimpl.cass.prepare.core.CassandraSessionFactoryBean.java
@Override public void afterPropertiesSet() { if (converter == null) { throw new IllegalArgumentException("converter is required"); }/* w ww . ja v a 2s.c o m*/ super.afterPropertiesSet(); mappingContext = converter.getMappingContext(); schemaOperations = new DefaultSchemaOperations(session, keyspace, converter); schemaCqlOperations = new DefaultSchemaCqlOperations(session, keyspace); if (StringUtils.hasText(keyspace)) { if (!CollectionUtils.isEmpty(tables)) { for (TableAttributes tableAttributes : tables) { String entityClassName = tableAttributes.getEntityClass(); Class<?> entityClass = loadClass(entityClassName); String useTableName = tableAttributes.getTableName() != null ? tableAttributes.getTableName() : this.getTableName(entityClass); if (keyspaceCreated) { createNewTable(useTableName, entityClass); } else if (keyspaceAttributes.isUpdate()) { TableMetadata table = schemaCqlOperations.getTableMetadata(useTableName); if (table == null) { createNewTable(useTableName, entityClass); } else { Optional<UpdateOperation> alter = schemaOperations.alterTable(useTableName, entityClass, true); if (alter.isPresent()) { alter.get().execute(); } schemaOperations.alterIndexes(useTableName, entityClass).execute(); } } else if (keyspaceAttributes.isValidate()) { TableMetadata table = schemaCqlOperations.getTableMetadata(useTableName); if (table == null) { throw new InvalidDataAccessApiUsageException( "not found table " + useTableName + " for entity " + entityClassName); } String query = schemaOperations.validateTable(useTableName, entityClass); if (query != null) { throw new InvalidDataAccessApiUsageException("invalid table " + useTableName + " for entity " + entityClassName + ". modify it by " + query); } List<String> queryList = schemaOperations.validateIndexes(useTableName, entityClass); if (!queryList.isEmpty()) { throw new InvalidDataAccessApiUsageException("invalid indexes in table " + useTableName + " for entity " + entityClassName + ". modify it by " + queryList); } } } } } }
From source file:be.roots.taconic.pricingguide.service.HubSpotServiceImpl.java
public Contact getContactFor(String hsID) throws IOException { LOGGER.info("Start getting the recent contact information based on conversion-id: " + hsID); final RestTemplate restTemplate = new RestTemplate(); RecentContacts recentContacts = null; do {//from w w w . j a v a 2s.c o m if (recentContacts == null) { // first call LOGGER.info("Initial call for recent contacts"); recentContacts = restTemplate.getForObject(apiUrl + apiKey + "&count=100", RecentContacts.class); } else { // page through the next calls LOGGER.info("Secondary call for recent contacts with timeOffset=" + recentContacts.getTimeOffset() + ", and vidOffset=" + recentContacts.getVidOffset()); recentContacts = restTemplate.getForObject(apiUrl + apiKey + "&count=100&timeOffset=" + recentContacts.getTimeOffset() + "&vidOffset=" + recentContacts.getVidOffset(), RecentContacts.class); } if (recentContacts != null && !CollectionUtils.isEmpty(recentContacts.getContacts())) { for (RecentContact contact : recentContacts.getContacts()) { if (!CollectionUtils.isEmpty(contact.getFormSubmissions())) { for (FormSubmission form : contact.getFormSubmissions()) { if (hsID.equals(form.getConversionId())) { final Contact result = getContactDetailsFor( String.format(apiContactUrl + apiKey, contact.getVid())); result.setHsId(hsID); return result; } } } } } } while (recentContacts.isHasMore()); LOGGER.info("No recent contact information found for: " + hsID); return null; }
From source file:org.arrow.service.engine.execution.interceptor.impl.BoundaryEventAwareInitializer.java
/** * {@inheritDoc}/*from ww w . ja va2 s.c om*/ */ @Override public boolean supports(Object entity) { if (entity instanceof BoundaryEventAware) { BoundaryEventAware bea = (BoundaryEventAware) entity; return !CollectionUtils.isEmpty(bea.getBoundaryEvents()); } return false; }