List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:org.wallride.service.PostService.java
public List<Post> publishScheduledPosts() { logger.info("Starting public posts of the scheduled"); LocalDateTime now = LocalDateTime.now(); List<Post> posts = postRepository.findAllByStatusAndDateLessThanEqual(Post.Status.SCHEDULED, now); for (Post post : posts) { post.setStatus(Post.Status.PUBLISHED); postRepository.saveAndFlush(post); }/* w w w . j a v a 2 s . com*/ if (!CollectionUtils.isEmpty(posts)) { cacheManager.getCache(WallRideCacheConfiguration.ARTICLE_CACHE).clear(); cacheManager.getCache(WallRideCacheConfiguration.PAGE_CACHE).clear(); } return posts; }
From source file:net.sf.sze.frontend.zeugnis.BewertungenController.java
/** * Zeigt die Bewertungen des entsprechenden Faches der Klasse in dem Halbjahr. * @param halbjahrId die Id des Schulhalbjahres * @param klassenId die Id der Klasse/*from w ww . ja v a2 s .c om*/ * @param schulfachId die Id des Schulfaches. * @param model das Model * @param redirectAttributes Fehlermeldungen. * @return die logische View */ @RequestMapping(value = URL.BewertungenPath.LIST, method = RequestMethod.GET) public String showBewertungenPath(@PathVariable(URL.Session.P_HALBJAHR_ID) Long halbjahrId, @PathVariable(URL.Session.P_KLASSEN_ID) Long klassenId, @RequestParam(value = URL.Session.P_SCHULFACH_ID, required = false) Long schulfachId, Model model, RedirectAttributes redirectAttributes) { final ZeugnisFormular formular = zeugnisFormularService.getZeugnisFormular(halbjahrId.longValue(), klassenId.longValue()); if (formular == null) { redirectAttributes.addFlashAttribute("message", "Es wurden keine Bewertungen gefunden."); return URL.redirectWithNamedParams(URL.ZeugnisPath.START, URL.Session.P_HALBJAHR_ID, halbjahrId, URL.Session.P_KLASSEN_ID, klassenId); } if (!formular.getSchulhalbjahr().isSelectable()) { redirectAttributes.addFlashAttribute("message", "Das Schulhalbjahr ist nicht mehr selektierbar."); return URL.redirectWithNamedParams(URL.ZeugnisPath.START, URL.Session.P_HALBJAHR_ID, halbjahrId, URL.Session.P_KLASSEN_ID, klassenId); } final List<Schulfach> schulfaecher = bewertungErfassungsService.getActiveSchulfaecherOrderByName(formular); if (CollectionUtils.isEmpty(schulfaecher)) { redirectAttributes.addFlashAttribute("message", "Es wurden keine Bewertungen gefunden."); return URL.redirectWithNamedParams(URL.ZeugnisPath.START, URL.Session.P_HALBJAHR_ID, halbjahrId, URL.Session.P_KLASSEN_ID, klassenId); } final Long usedSchulfachId; if (schulfachId == null) { LOG.debug("Nehme das erste Schulfach"); usedSchulfachId = schulfaecher.get(0).getId(); } else { usedSchulfachId = schulfachId; } final List<Bewertung> bewertungen = bewertungErfassungsService.getSortedBewertungen(formular, usedSchulfachId.longValue()); model.addAttribute("bewertungen", bewertungen); model.addAttribute("schulfaecher", schulfaecher); model.addAttribute("zeugnisFormular", formular); model.addAttribute(URL.Session.P_SCHULFACH_ID, usedSchulfachId); return "bewertungen/listBewertungen"; }
From source file:com.sra.biotech.submittool.persistence.client.DatabaseToCdmClient.java
public List<Submission> findByStatus(String status) { RestTemplate restTemplate = restTemplateService.restTemplate(); SubmissionResources resources = restTemplate.getForObject( RestClientConfiguration.BASE_URL + "/submissions/search/findByStatus/?status={status}", SubmissionResources.class, status); if (resources == null || CollectionUtils.isEmpty(resources.getContent())) { return Collections.emptyList(); }// ww w. j av a2 s.co m // getting the author's books using the link with rel books Submission submission = null; List<Submission> submissions = new ArrayList<Submission>(); Link submissionSamplesLink = null; Link submissionStudiesLink = null; Link submissionExperimentsLink = null; // Collection<SampleResource> submissionSamples=null; SampleResources sampleResources = null; StudyResources studyResources = null; ExperimentResources experimentsResources = null; for (SubmissionResource resource : resources) { submission = resource.getContent(); /* Get Samples */ submissionSamplesLink = resource.getLink("samples"); sampleResources = restTemplate.getForObject(submissionSamplesLink.getHref(), SampleResources.class); submission.setSamples(sampleResources.unwrap()); /* Get Studies */ submissionStudiesLink = resource.getLink("studies"); studyResources = restTemplate.getForObject(submissionStudiesLink.getHref(), StudyResources.class); submission.setStudies(studyResources.unwrap()); /* Get Experiments */ submissionExperimentsLink = resource.getLink("experiments"); experimentsResources = restTemplate.getForObject(submissionExperimentsLink.getHref(), ExperimentResources.class); // submission.setExperiments(experimentsResources.unwrap()); submission.setExperiments(findAllExperiments(submissionExperimentsLink)); submissions.add(submission); } return resources.unwrap(); }
From source file:test.com.azaptree.services.spring.application.SpringApplicationServiceTest.java
@Test public void testSpringApplicationService_configClasses() throws Exception { final String[] args = { "classpath:spring-application-service.xml" }; try {// w ww. ja va 2 s . c om new Thread(new Runnable() { @Override public void run() { try { SpringApplicationService.main(args); } catch (Exception e) { e.printStackTrace(); } } }).start(); Thread.yield(); ApplicationContext ctx = SpringApplicationService.getApplicationContext(); while (ctx == null) { log.info("Waiting for ApplicationContext to initialize ..."); Thread.sleep(100l); ctx = SpringApplicationService.getApplicationContext(); } Assert.assertNotNull(ctx); final Properties props = ctx.getBean("systemProps", Properties.class); Assert.assertNotNull(props); Assert.assertFalse(CollectionUtils.isEmpty(props)); final Map<String, String> env = ctx.getBean("env", Map.class); Assert.assertNotNull(env); Assert.assertFalse(CollectionUtils.isEmpty(env)); log.info("bean count: {}", ctx.getBeanDefinitionCount()); for (String beanName : ctx.getBeanDefinitionNames()) { log.info("beanName: {}", beanName); } } finally { SpringApplicationService.shutdown(); } }
From source file:org.agatom.springatom.data.hades.model.person.NPerson.java
public boolean addContact(final Collection<NPersonContact> contacts) { if (!CollectionUtils.isEmpty(contacts)) { for (NPersonContact contact : contacts) { contact.setAssignee(this); this.getContacts().add(contact); }/*from w w w. j a va2 s . co m*/ return true; } return false; }
From source file:com.sinet.gage.provision.controller.DomainController.java
/** * Returns all state domains/*from www . j a v a 2s .c om*/ * * @return */ @RequestMapping(value = "/list/state", method = RequestMethod.GET) @ResponseBody public Message getAllStates(@RequestHeader(value = "token", required = false) String token) throws InterruptedException { List<DomainResponse> listOfDomainResponse = domainService.findAllStateDomains(token, 0); if (!CollectionUtils.isEmpty(listOfDomainResponse)) { LOGGER.debug("Found " + listOfDomainResponse.size() + " state domains"); return messageUtil.createMessageWithPayload(MessageConstants.DOMAINS_FOUND, listOfDomainResponse, Collections.singletonMap("dataModels", "domains"), DomainResponse.class); } else { LOGGER.debug("No state domains available"); return messageUtil.createMessage(MessageConstants.DOMAINS_NOT_FOUND, Boolean.FALSE); } }
From source file:com.alibaba.otter.node.etl.common.pipe.impl.http.RowDataHttpPipe.java
private HttpPipeKey saveDbBatch(DbBatch dbBatch) { RowBatch rowBatch = dbBatch.getRowBatch(); // proto// w w w. j a v a2s . com BatchProto.RowBatch.Builder rowBatchBuilder = BatchProto.RowBatch.newBuilder(); rowBatchBuilder.setIdentity(build(rowBatch.getIdentity())); // ?rowData for (EventData eventData : rowBatch.getDatas()) { BatchProto.RowData.Builder rowDataBuilder = BatchProto.RowData.newBuilder(); rowDataBuilder.setPairId(eventData.getPairId()); rowDataBuilder.setTableId(eventData.getTableId()); if (eventData.getSchemaName() != null) { rowDataBuilder.setSchemaName(eventData.getSchemaName()); } rowDataBuilder.setTableName(eventData.getTableName()); rowDataBuilder.setEventType(eventData.getEventType().getValue()); rowDataBuilder.setExecuteTime(eventData.getExecuteTime()); // add by ljh at 2012-10-31 if (eventData.getSyncMode() != null) { rowDataBuilder.setSyncMode(eventData.getSyncMode().getValue()); } if (eventData.getSyncConsistency() != null) { rowDataBuilder.setSyncConsistency(eventData.getSyncConsistency().getValue()); } // key column for (EventColumn keyColumn : eventData.getKeys()) { rowDataBuilder.addKeys(buildColumn(keyColumn)); } // old key column if (CollectionUtils.isEmpty(eventData.getOldKeys()) == false) { for (EventColumn keyColumn : eventData.getOldKeys()) { rowDataBuilder.addOldKeys(buildColumn(keyColumn)); } } // column for (EventColumn column : eventData.getColumns()) { rowDataBuilder.addColumns(buildColumn(column)); } rowDataBuilder.setRemedy(eventData.isRemedy()); rowDataBuilder.setSize(eventData.getSize()); if (StringUtils.isNotEmpty(eventData.getSql())) { rowDataBuilder.setSql(eventData.getSql()); } if (StringUtils.isNotEmpty(eventData.getDdlSchemaName())) { rowDataBuilder.setDdlSchemaName(eventData.getDdlSchemaName()); } if (StringUtils.isNotEmpty(eventData.getHint())) { rowDataBuilder.setHint(eventData.getHint()); } rowDataBuilder.setWithoutSchema(eventData.isWithoutSchema()); rowBatchBuilder.addRows(rowDataBuilder.build());// ?rowData } // ?FileBatch FileBatch fileBatch = dbBatch.getFileBatch(); BatchProto.FileBatch.Builder fileBatchBuilder = null; fileBatchBuilder = BatchProto.FileBatch.newBuilder(); fileBatchBuilder.setIdentity(build(fileBatch.getIdentity())); // proto for (FileData fileData : fileBatch.getFiles()) { BatchProto.FileData.Builder fileDataBuilder = BatchProto.FileData.newBuilder(); fileDataBuilder.setPairId(fileData.getPairId()); fileDataBuilder.setTableId(fileData.getTableId()); if (fileData.getNameSpace() != null) { fileDataBuilder.setNamespace(fileData.getNameSpace()); } if (fileData.getPath() != null) { fileDataBuilder.setPath(fileData.getPath()); } fileDataBuilder.setEventType(fileData.getEventType().getValue()); fileDataBuilder.setSize(fileData.getSize()); fileDataBuilder.setLastModifiedTime(fileData.getLastModifiedTime()); fileBatchBuilder.addFiles(fileDataBuilder.build());// ?fileData } // ?url String filename = buildFileName(rowBatch.getIdentity(), ClassUtils.getShortClassName(dbBatch.getClass())); // ? File file = new File(htdocsDir, filename); OutputStream output = null; try { output = new BufferedOutputStream(new FileOutputStream(file)); com.alibaba.otter.node.etl.model.protobuf.BatchProto.RowBatch rowBatchProto = rowBatchBuilder.build(); output.write(ByteUtils.int2bytes(rowBatchProto.getSerializedSize()));// ? rowBatchProto.writeTo(output);// row batch com.alibaba.otter.node.etl.model.protobuf.BatchProto.FileBatch fileBatchProto = fileBatchBuilder .build(); output.write(ByteUtils.int2bytes(fileBatchProto.getSerializedSize()));// ? fileBatchProto.writeTo(output); // file batch output.flush(); } catch (IOException e) { throw new PipeException("write_byte_error", e); } finally { IOUtils.closeQuietly(output); } HttpPipeKey key = new HttpPipeKey(); key.setUrl(remoteUrlBuilder.getUrl(rowBatch.getIdentity().getPipelineId(), filename)); key.setDataType(PipeDataType.DB_BATCH); key.setIdentity(rowBatch.getIdentity()); Pipeline pipeline = configClientService.findPipeline(rowBatch.getIdentity().getPipelineId()); if (pipeline.getParameters().getUseFileEncrypt()) { // ? EncryptedData encryptedData = encryptFile(file); key.setKey(encryptedData.getKey()); key.setCrc(encryptedData.getCrc()); } return key; }
From source file:cn.wanghaomiao.seimi.core.SeimiScanner.java
/** * ?????// w w w . j av a2 s. co m * @param reader * @param readerFactory * @return ture/false */ private boolean ifMatchesEntityType(MetadataReader reader, MetadataReaderFactory readerFactory, List<AnnotationTypeFilter> typeFilters) { if (!CollectionUtils.isEmpty(typeFilters)) { for (TypeFilter filter : typeFilters) { try { if (filter.match(reader, readerFactory)) { return true; } } catch (IOException e) { logger.error("? {}", e.getMessage()); } } } return false; }
From source file:pe.gob.mef.gescon.service.impl.ContenidoServiceImpl.java
@Override public List<Consulta> getConcimientosVinculados(HashMap filters) { List<Consulta> lista = new ArrayList<Consulta>(); try {//from w w w.j a va2s.c om ContenidoDao contenidoDao = (ContenidoDao) ServiceFinder.findBean("ContenidoDao"); List<HashMap> consulta = contenidoDao.getConcimientosVinculados(filters); if (!CollectionUtils.isEmpty(consulta)) { for (HashMap map : consulta) { Consulta c = new Consulta(); c.setId((BigDecimal) map.get("ID")); c.setIdconocimiento((BigDecimal) map.get("IDCONOCIMIENTO")); c.setCodigo((String) map.get("NUMERO")); c.setNombre((String) map.get("NOMBRE")); c.setSumilla((String) map.get("SUMILLA")); c.setFechaPublicacion((Date) map.get("FECHA")); c.setIdCategoria((BigDecimal) map.get("IDCATEGORIA")); c.setCategoria((String) map.get("CATEGORIA")); c.setIdTipoConocimiento((BigDecimal) map.get("IDTIPOCONOCIMIENTO")); c.setTipoConocimiento((String) map.get("TIPOCONOCIMIENTO")); c.setIdEstado((BigDecimal) map.get("IDESTADO")); c.setEstado((String) map.get("ESTADO")); lista.add(c); } } } catch (Exception e) { e.getMessage(); e.printStackTrace(); } return lista; }
From source file:com.frank.search.solr.core.DefaultQueryParser.java
private void processStatsOptions(SolrQuery solrQuery, Query query) { StatsOptions statsOptions = query.getStatsOptions(); if (statsOptions == null || (CollectionUtils.isEmpty(statsOptions.getFields()) && CollectionUtils.isEmpty(statsOptions.getFacets()) && CollectionUtils.isEmpty(statsOptions.getSelectiveFacets()))) { return;// ww w .j av a 2s . co m } solrQuery.set(StatsParams.STATS, true); for (Field field : statsOptions.getFields()) { solrQuery.add(StatsParams.STATS_FIELD, field.getName()); String selectiveCalcDistinctParam = CommonParams.FIELD + "." + field.getName() + "." + StatsParams.STATS_CALC_DISTINCT; Boolean selectiveCountDistincts = statsOptions.isSelectiveCalcDistincts(field); if (selectiveCountDistincts != null) { solrQuery.add(selectiveCalcDistinctParam, String.valueOf(selectiveCountDistincts.booleanValue())); } } for (Field field : statsOptions.getFacets()) { solrQuery.add(StatsParams.STATS_FACET, field.getName()); } for (Entry<Field, Collection<Field>> entry : statsOptions.getSelectiveFacets().entrySet()) { Field field = entry.getKey(); String prefix = CommonParams.FIELD + "." + field.getName() + "."; String paramName = prefix + StatsParams.STATS_FACET; for (Field facetField : entry.getValue()) { solrQuery.add(paramName, facetField.getName()); } } }