List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:com.alibaba.otter.node.etl.extract.extractor.GroupExtractor.java
private void groupFilter(EventData eventData, ColumnGroup columnGroup) { List<EventColumn> addColumns = new ArrayList<EventColumn>(); // ??/*w w w .j a v a 2 s .c om*/ Set<String> updatedColumns = new HashSet<String>(); Set<String> pks = new HashSet<String>(); // ????? for (EventColumn column : eventData.getUpdatedColumns()) { updatedColumns.add(column.getColumnName()); } for (EventColumn pk : eventData.getKeys()) { pks.add(pk.getColumnName()); } if (!CollectionUtils.isEmpty(eventData.getOldKeys())) {// ?? int i = 0; for (EventColumn pk : eventData.getKeys()) { if (!StringUtils.equals(pk.getColumnValue(), eventData.getOldKeys().get(i).getColumnValue())) { updatedColumns.add(pk.getColumnName()); } i++; } } if (containsInGroupColumn(updatedColumns, columnGroup.getColumnPairs())) {// // ?+? group? for (ColumnPair columnPair : columnGroup.getColumnPairs()) { boolean groupColumnHasInChangedColunms = false;// ???? // add by ljh at 2012-11-04 // ? // 1. select??FileResolver? // 2. groupupdate=trueGroup?before??????? // columns??updateColumns // for (String columnName : updatedColumns) { for (EventColumn column : eventData.getColumns()) { if (StringUtils.equalsIgnoreCase(columnPair.getSourceColumn().getName(), column.getColumnName())) { groupColumnHasInChangedColunms = true; if (!column.isUpdate()) {// ??update=true?? column.setUpdate(true); } break; } } if (!groupColumnHasInChangedColunms) {// ?? String columnName = columnPair.getSourceColumn().getName(); if (!pks.contains(columnName)) { // ????column???? EventColumn addColumn = new EventColumn(); addColumn.setColumnName(columnPair.getSourceColumn().getName()); addColumn.setUpdate(true); addColumns.add(addColumn); } } } if (!CollectionUtils.isEmpty(addColumns)) { // ? eventData.getColumns().addAll(addColumns);// ? eventData.setSyncConsistency(SyncConsistency.MEDIA); return; } } }
From source file:nc.noumea.mairie.appock.services.impl.MailServiceImpl.java
@Override public Message sendMail(AppockMail appockMail) throws MessagingException { if (CollectionUtils.isEmpty(appockMail.getListeDestinataire())) { log.warn("Mail non envoy, liste des destinataires vide : " + appockMail); return null; }/*from ww w . j a va 2 s .c o m*/ MimeMessage msg = new MimeMessage(mailServer); msg.setFrom(appockMail.getFrom() != null ? appockMail.getFrom() : defaultFrom()); String prefixeSujet = isModeProduction() ? "" : "[TEST APPOCK] "; msg.setSubject(prefixeSujet + appockMail.getSujet(), configService.getEncodageSujetEmail()); StringBuilder infoAdditionnelle = new StringBuilder(); for (InternetAddress adresse : appockMail.getListeDestinataire()) { if (isModeProduction()) { // on est en production, envoi rel de mail au destinataire msg.addRecipient(Message.RecipientType.TO, adresse); } else { // en test, on envoie le mail la personne connecte InternetAddress adresseTesteur = getAdresseMailDestinataireTesteur(); if (adresseTesteur != null) { msg.addRecipient(Message.RecipientType.TO, adresseTesteur); } List<String> listeAdresseMail = new ArrayList<>(); for (InternetAddress internetAddress : appockMail.getListeDestinataire()) { listeAdresseMail.add(internetAddress.getAddress()); } infoAdditionnelle.append("En production cet email serait envoy vers ") .append(StringUtils.join(listeAdresseMail, ", ")).append("<br/><hr/>"); break; } } String contenuFinal = ""; if (!StringUtils.isBlank(infoAdditionnelle.toString())) { contenuFinal += "<font face=\"arial\" >" + infoAdditionnelle.toString() + "</font>"; } contenuFinal += "<font face=\"arial\" >" + appockMail.getContenu() + "<br/><br/></font>" + configService.getPiedDeMail(); gereBonLivraisonDansMail(appockMail, msg, contenuFinal); if (!ArrayUtils.isEmpty(msg.getAllRecipients())) { Transport.send(msg); } return msg; }
From source file:org.spring.data.gemfire.cache.execute.ProgrammerFunctions.java
@GemfireFunction public List<Programmer> updateReputation(@RegionData Region<Long, Programmer> filteredProgrammers, String programmingLanguage, int reputationDelta) { try {/* w w w .j av a2s . c o m*/ ProgrammerRepository localProgrammerRepository = getProgrammerRepository(filteredProgrammers); //List<Programmer> programmers = nullSafeList( // localProgrammerRepository.findDistinctByProgrammingLanguageOrderByNameAsc(programmingLanguage)); List<Programmer> programmers = nullSafeList(filteredProgrammers .<Programmer>query(String.format("programmingLanguage = '%1$s'", programmingLanguage)) .asList()); if (!CollectionUtils.isEmpty(programmers)) { for (Programmer programmer : programmers) { programmer.setReputation(programmer.getReputation() + reputationDelta); } localProgrammerRepository.save(programmers); } return programmers; } catch (Exception e) { throw new RuntimeException("?", e); } }
From source file:fi.vm.kapa.identification.proxy.rest.ProxyResourceImpl.java
@Override public SessionAttributeDTO getSessionAttributes(String uid, String authMethodOid, String relyingParty) { logger.debug(/* w w w. ja v a 2 s .c om*/ "Got session attributes request from Shibboleth IdP, uid: {}, authMethodOid: {}, relyingParty: {}", uid, authMethodOid, relyingParty); SessionAttributeDTO attributes = sessionHandlingService.getSessionAttributes(uid, authMethodOid, relyingParty); if (!CollectionUtils.isEmpty(attributes.getAttributeMap())) { return attributes; } else { throw new WebApplicationException(Response.Status.NOT_FOUND); } }
From source file:com.alibaba.otter.manager.web.home.module.screen.DataMatrixList.java
public void execute(@Param("pageIndex") int pageIndex, @Param("matrixId") Long matrixId, @Param("groupKey") String groupKey, @Param("searchKey") String searchKey, Context context) throws Exception { Map<String, Object> condition = new HashMap<String, Object>(); if ("(??NodeID????)".equals(searchKey)) { searchKey = ""; }//from w ww . ja va2 s .co m condition.put("searchKey", searchKey); int count = dataMatrixService.getCount(condition); Paginator paginator = new Paginator(); paginator.setItems(count); paginator.setPage(pageIndex); condition.put("offset", paginator.getOffset()); condition.put("length", paginator.getLength()); List<DataMatrix> matrixs = new ArrayList<DataMatrix>(); if ((null != matrixId) && (matrixId != 0l)) { DataMatrix matrix = dataMatrixService.findById(matrixId); matrixs.add(matrix); paginator.setItems(1); paginator.setPage(0); searchKey = String.valueOf(matrixId); // searchKey } else if (StringUtils.isNotEmpty(groupKey)) { DataMatrix matrix = dataMatrixService.findByGroupKey(groupKey); matrixs.add(matrix); paginator.setItems(1); paginator.setPage(0); searchKey = String.valueOf(groupKey); // searchKey } else { matrixs = dataMatrixService.listByCondition(condition); } List<SeniorDataMatrix> seniorMatrixs = new ArrayList<SeniorDataMatrix>(); for (DataMatrix matrix : matrixs) { SeniorDataMatrix seniorMatrix = new SeniorDataMatrix(); seniorMatrix.setId(matrix.getId()); seniorMatrix.setGroupKey(matrix.getGroupKey()); seniorMatrix.setMaster(matrix.getMaster()); seniorMatrix.setSlave(matrix.getSlave()); seniorMatrix.setGmtCreate(matrix.getGmtCreate()); seniorMatrix.setGmtModified(matrix.getGmtModified()); Map dataSourceCondition = new HashMap(); condition.put("searchKey", "jdbc:mysql://groupKey=" + matrix.getGroupKey()); List<DataMediaSource> dataSources = dataMediaSourceService.listByCondition(dataSourceCondition); seniorMatrix.setUsed(!CollectionUtils.isEmpty(dataSources)); seniorMatrixs.add(seniorMatrix); } context.put("dataMatrixs", seniorMatrixs); context.put("paginator", paginator); context.put("searchKey", searchKey); }
From source file:com.alibaba.otter.manager.biz.common.DataSourceCreator.java
public boolean letHandlerDestroyIfSupport(Long pipelineId, DataSource source) { boolean destroied = false; if (CollectionUtils.isEmpty(this.dataSourceHandlers)) { return destroied; }/*from w w w . j a va2 s . c o m*/ for (DataSourceHanlder handler : this.dataSourceHandlers) { if (handler.support(source)) { handler.destory(pipelineId); destroied = true; return destroied; } } return destroied; }
From source file:com.jim.im.message.service.MessageServiceImpl.java
private void setTopicName(ImMessage message) throws TopicRpcException { TopicRequest topicRequest = TopicRequest.build(message.getTargetId(), message.getAppId(), message.getTenantId(), message.getTopicOwnerType(), message.getMsgType().getTopicType()); Map<TopicType, TopicInfo> topicInfo = topicRpcService.getTopicInfo(topicRequest); if (CollectionUtils.isEmpty(topicInfo)) throw new TopicRpcException("Topic Info is not exist."); TopicType topicType = message.getMsgType().getTopicType(); message.setTopicName(topicInfo.get(topicType).getName()); }
From source file:com.github.cric.app.ui.SettingPanel.java
private void initUI() { setLayout(new BorderLayout(GAP, GAP)); setBorder(new EmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN)); add(getFormPanel(), BorderLayout.NORTH); add(getSubmitPanel(), BorderLayout.CENTER); msgLabel.setForeground(Color.MAGENTA); msgLabel.setHorizontalAlignment(JLabel.CENTER); add(msgLabel, BorderLayout.SOUTH); populateMatchList();/*from ww w . j a v a 2 s .c o m*/ if (CollectionUtils.isEmpty(matchList)) { setAllEnabled(false); } }
From source file:com.zuoxiaolong.blog.cache.service.UserArticleServiceManager.java
/** * ??//from ww w .ja v a2 s.c o m * * @param map * @return */ public List<UserArticle> getTopReadArticlesByCategoryIdAndTime(Map<String, Object> map) { List<UserArticle> userArticles = userArticleService.getTopReadArticles(map); List<UserArticle> articles = userArticleService .getArticlesByCategoryId((Integer) map.get(QUERY_PARAMETER_CATEGORY_ID)); if (CollectionUtils.isEmpty(userArticles) && !CollectionUtils.isEmpty(articles)) { //??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:org.agatom.springatom.data.vin.decoder.resolver.DefaultWMIManufacturedInResolver.java
private void postProcessWMIBeans(final WMIBeanList wmiBeans) throws NotFoundException { for (final WMIBean wmiBean : wmiBeans) { final List<String> codes = wmiBean.codes; Assert.notEmpty(codes);/* ww w.j a va 2 s . com*/ final List<CountryCode> byName = CountryCode.findByName(wmiBean.country); if (CollectionUtils.isEmpty(byName)) { final String format = String.format("%s has no country code corresponding", wmiBean.country); LOGGER.warn(format); continue; } for (final String code : codes) { final String[] split = code.split("-"); final CodeRangeWrapper wrapper = CodeRangeWrapper.newCodeRangeWrapper(split[0], split.length == 2 ? split[1] : ""); final CountryCode countryCode = byName.get(0); LOGGER.trace(String.format("Key=>%s, CountryCode=%s", wrapper, countryCode)); this.countryCodeMap.put(wrapper, countryCode); } } }