List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:com.nortal.petit.orm.statement.BeansStatement.java
public void exec() { if (!CollectionUtils.isEmpty(getBeans())) { execBatchUpdate();/* w w w . j a va 2 s . c o m*/ } else { getJdbcTemplate().update(getSql(), getParams(null)); } }
From source file:org.wallride.web.controller.guest.article.ArticleDescribeController.java
@RequestMapping public String describe(@PathVariable int year, @PathVariable int month, @PathVariable int day, @PathVariable String code, BlogLanguage blogLanguage, Model model, RedirectAttributes redirectAttributes) { Article article = articleService.getArticleByCode(code, blogLanguage.getLanguage()); if (article == null) { article = articleService.getArticleByCode(code, blogLanguage.getBlog().getDefaultLanguage()); }//from w w w .j av a 2 s. c om if (article == null) { throw new HttpNotFoundException(); } if (article.getStatus() != Post.Status.PUBLISHED) { throw new HttpNotFoundException(); } LocalDate date = LocalDate.of(year, month, day); if (!article.getDate().toLocalDate().equals(date)) { redirectAttributes.addAttribute("year", article.getDate().getYear()); redirectAttributes.addAttribute("month", article.getDate().getMonth().getValue()); redirectAttributes.addAttribute("day", article.getDate().getDayOfMonth()); redirectAttributes.addAttribute("code", code); return "redirect:/{year}/{month}/{day}/{code}"; } CommentSearchRequest request = new CommentSearchRequest(); request.setPostId(article.getId()); request.setApproved(Boolean.TRUE); Page<Comment> comments = commentService.getComments(request, new PageRequest(0, 1000)); List<Long> ids = articleService.getArticleIds(new ArticleSearchRequest().withStatus(Post.Status.PUBLISHED)); if (!CollectionUtils.isEmpty(ids)) { int index = ids.indexOf(article.getId()); if (index < ids.size() - 1) { Article next = articleService.getArticleById(ids.get(index + 1)); model.addAttribute("next", next); } if (index > 0) { Article prev = articleService.getArticleById(ids.get(index - 1)); model.addAttribute("prev", prev); } } model.addAttribute("article", article); model.addAttribute("comments", comments); return "article/describe"; }
From source file:com.gst.infrastructure.hooks.domain.Hook.java
private Hook(final HookTemplate template, final String displayName, final Boolean isActive, final Set<HookConfiguration> config, final Set<HookResource> events, final Template ugdTemplate) { this.template = template; if (StringUtils.isNotBlank(displayName)) { this.name = displayName.trim(); } else {/*from w w w . j a v a2 s . co m*/ this.name = template.getName(); } this.isActive = isActive; if (!CollectionUtils.isEmpty(config)) { this.config = associateConfigWithThisHook(config); } if (!CollectionUtils.isEmpty(events)) { this.events = associateEventsWithThisHook(events); } this.ugdTemplate = ugdTemplate; }
From source file:com.zuoxiaolong.blog.service.impl.UserArticleServiceImpl.java
/** * ??/*from www .j a v a 2s . c om*/ * * @param map * @return */ private List<UserArticle> getTopCommendArticles(Map<String, Object> map) { List<UserArticle> userArticles = userArticleMapper.getTopCommendArticles(map); List<UserArticle> recommendUserArticle = userArticleMapper .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:uk.gov.nationalarchives.discovery.taxonomy.ws.controller.TaxonomyController.java
/** * Endpoint: search for InformationAssetViews in lucene index using a * category query and other parameters/* w w w. j a v a 2s .co m*/ * * @param searchRequest * @return paginated list of found information asset views * @throws Exception */ @RequestMapping(value = "/search", method = RequestMethod.POST, consumes = APPLICATION_JSON, produces = APPLICATION_JSON) @ResponseBody PaginatedList<InformationAssetView> searchIAView(@RequestBody SearchIAViewRequest searchRequest) throws Exception { logger.info("/search > {}", searchRequest.toString()); if (StringUtils.isEmpty(searchRequest.getCategoryQuery())) { throw new TaxonomyException(TaxonomyErrorType.INVALID_CATEGORY_QUERY, "categoryQuery should be provided and not empty"); } if (searchRequest.getLimit() == null) { searchRequest.setLimit(10); } if (searchRequest.getOffset() == null) { searchRequest.setOffset(0); } PaginatedList<InformationAssetView> listOfIAViews = iaViewService.performSearch( searchRequest.getCategoryQuery(), searchRequest.getScore(), searchRequest.getLimit(), searchRequest.getOffset()); logger.info("/search < {} IAViews returned, {} IAViews found", listOfIAViews.size(), listOfIAViews.getNumberOfResults()); if (!CollectionUtils.isEmpty(listOfIAViews.getResults())) { logger.info("/search < first element: {}", listOfIAViews.getResults().get(0).toString()); } return listOfIAViews; }
From source file:cn.wanghaomiao.seimi.http.hc.HcRequestGenerator.java
public static RequestBuilder getHttpRequestBuilder(Request request, CrawlerModel crawlerModel) { RequestBuilder requestBuilder;// w ww. j ava 2 s. c o m BaseSeimiCrawler crawler = crawlerModel.getInstance(); if (request.isUseSeimiAgent()) { if (StringUtils.isBlank(crawler.seimiAgentHost())) { throw new SeimiProcessExcepiton("SeimiAgentHost is blank."); } String seimiAgentUrl = "http://" + crawler.seimiAgentHost() + (crawler.seimiAgentPort() != 80 ? (":" + crawler.seimiAgentPort()) : "") + "/doload"; requestBuilder = RequestBuilder.post().setUri(seimiAgentUrl); requestBuilder.addParameter("url", request.getUrl()); if (StringUtils.isNotBlank(crawler.proxy())) { requestBuilder.addParameter("proxy", crawler.proxy()); } if (request.getSeimiAgentRenderTime() > 0) { requestBuilder.addParameter("renderTime", String.valueOf(request.getSeimiAgentRenderTime())); } if (StringUtils.isNotBlank(request.getSeimiAgentScript())) { requestBuilder.addParameter("script", request.getSeimiAgentScript()); } //SeimiAgent?cookie if ((request.isSeimiAgentUseCookie() == null && crawlerModel.isUseCookie()) || (request.isSeimiAgentUseCookie() != null && request.isSeimiAgentUseCookie())) { requestBuilder.addParameter("useCookie", "1"); } if (request.getParams() != null && request.getParams().size() > 0) { requestBuilder.addParameter("postParam", JSON.toJSONString(request.getParams())); } if (request.getSeimiAgentContentType().val() > SeimiAgentContentType.HTML.val()) { requestBuilder.addParameter("contentType", request.getSeimiAgentContentType().typeVal()); } } else { if (HttpMethod.POST.equals(request.getHttpMethod())) { requestBuilder = RequestBuilder.post().setUri(request.getUrl()); } else { requestBuilder = RequestBuilder.get().setUri(request.getUrl()); } RequestConfig config = RequestConfig.custom().setProxy(crawlerModel.getProxy()) .setCircularRedirectsAllowed(true).build(); if (request.getParams() != null) { for (Map.Entry<String, String> entry : request.getParams().entrySet()) { requestBuilder.addParameter(entry.getKey(), entry.getValue()); } } requestBuilder.setConfig(config).setHeader("User-Agent", crawlerModel.isUseCookie() ? crawlerModel.getCurrentUA() : crawler.getUserAgent()); requestBuilder.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); requestBuilder.setHeader("Accept-Language", "zh-CN,zh;q=0.8,en;q=0.6"); } if (!CollectionUtils.isEmpty(request.getHeader())) { for (Map.Entry<String, String> entry : request.getHeader().entrySet()) { requestBuilder.setHeader(entry.getKey(), entry.getValue()); } } return requestBuilder; }
From source file:uk.gov.nationalarchives.discovery.taxonomy.batch.scheduler.updateSolrCloudTask.java
@SuppressWarnings("unchecked") @Scheduled(fixedRateString = "${batch.update-solr-cloud.rate-between-updates}") public void updateSolrCloudWithLatestUpdatesOnCategories() { List<IAViewUpdate> listOfIAViewUpdatesToProcess = getNewCategorisedDocuments(); if (CollectionUtils.isEmpty(listOfIAViewUpdatesToProcess)) { return;//from w w w .j a v a 2 s .c o m } updateSolrService.bulkUpdateCategoriesOnIAViews(listOfIAViewUpdatesToProcess); updateLastIAViewUpdateObjectId(listOfIAViewUpdatesToProcess); }
From source file:org.surfnet.oaaas.resource.AbstractResource.java
protected void validate(AbstractEntity entity) { Set<ConstraintViolation<AbstractEntity>> validate = validator.validate(entity); if (!CollectionUtils.isEmpty(validate)) { throw new ConstraintViolationException((Set) validate); }/* w ww .j ava2 s . co m*/ }
From source file:org.openlmis.fulfillment.service.referencedata.UserReferenceDataService.java
/** * Finds users by their ids.//from w w w. j a va 2 s . c o m * * @param ids ids to look for. * @return a page of users */ public List<UserDto> findByIds(Collection<UUID> ids) { if (CollectionUtils.isEmpty(ids)) { return Collections.emptyList(); } return getPage(RequestParameters.init().set("id", ids)).getContent(); }
From source file:com.alibaba.otter.manager.biz.common.DataSourceCreator.java
/** * ,? dataSource//ww w . ja va2s.c om */ private DataSource preCreate(Long pipelineId, DbMediaSource dbMediaSource) { if (CollectionUtils.isEmpty(dataSourceHandlers)) { return null; } DataSource dataSource = null; for (DataSourceHanlder handler : dataSourceHandlers) { if (handler.support(dbMediaSource)) { dataSource = handler.create(pipelineId, dbMediaSource); if (dataSource != null) { return dataSource; } } } return null; }