List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:com.excilys.ebi.bank.util.Asserts.java
public static void notEmpty(Collection<?> collection, String messagePattern, Object arg) { if (CollectionUtils.isEmpty(collection)) { throw new IllegalArgumentException(MessageFormatter.format(messagePattern, arg).getMessage()); }/*from ww w . j ava 2 s. c o m*/ }
From source file:com.formkiq.core.service.ArchiveServiceImpl.java
/** * Reset {@link FormJSON} UUID.//ww w . ja v a 2 s .com * @param archive {@link ArchiveDTO} * @param form {@link FormJSON} * @param map {@link Map} */ private void resetFormUUID(final ArchiveDTO archive, final FormJSON form, final Map<String, String> map) { String oldUUID = form.getUUID(); String newUUID = map.get(oldUUID); Workflow workflow = archive.getWorkflow(); archive.removeForm(form); form.setSourceFormUUID(oldUUID); form.setUUID(newUUID); archive.addForm(form); form.setParentUUID(workflow.getParentUUID()); Collections.replaceAll(workflow.getSteps(), oldUUID, newUUID); Collections.replaceAll(workflow.getPrintsteps(), oldUUID, newUUID); if (!CollectionUtils.isEmpty(workflow.getOutputs())) { resetWorkflowOutput(workflow, form, oldUUID, newUUID); } }
From source file:com.embedler.moon.graphql.boot.sample.test.GenericTodoSchemaParserTest.java
@Test public void restUploadFileTest() throws IOException { LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); map.add("file", new ClassPathResource("application.yml")); String qlQuery = "mutation UploadFileMutation{uploadFile(input: {clientMutationId:\"m-123\"}){ filename }}"; map.add("query", qlQuery); map.add("variables", "{}"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<>(map, headers); ResponseEntity<GraphQLServerResult> responseEntity = restTemplate.exchange( "http://localhost:" + port + "/graphql", HttpMethod.POST, requestEntity, GraphQLServerResult.class); GraphQLServerResult result = responseEntity.getBody(); Assert.assertTrue(CollectionUtils.isEmpty(result.getErrors())); Assert.assertFalse(CollectionUtils.isEmpty(result.getData())); LOGGER.info(objectMapper.writeValueAsString(result.getData())); }
From source file:org.codehaus.grepo.query.jpa.generator.QueryGeneratorBase.java
protected void applyAddHintsSetting(JpaQueryOptions queryOptions, Query query, JpaQueryExecutionContext context) { if (!CollectionUtils.isEmpty(context.getDefaultQueryHints())) { for (Entry<String, Object> entry : context.getDefaultQueryHints().entrySet()) { query.setHint(entry.getKey(), entry.getValue()); logger.debug("Setting default hint name={} value={}", entry.getKey(), entry.getValue()); }/*w w w. ja va 2 s . c om*/ } if (queryOptions != null) { for (QueryHint hint : queryOptions.queryHints()) { query.setHint(hint.name(), hint.value()); logger.debug("Setting hint name={} value={}", hint.name(), hint.value()); } } if (hasHints()) { for (Entry<String, Object> entry : hints.entrySet()) { query.setHint(entry.getKey(), entry.getValue()); logger.debug("Setting hint name={} value={}", entry.getKey(), entry.getValue()); } } }
From source file:org.wallride.model.ArticleSearchRequest.java
public boolean isEmpty() { if (StringUtils.hasText(getKeyword())) { return false; }// w w w .j a v a2 s . co m if (getDateFrom() != null) { return false; } if (getDateTo() != null) { return false; } if (!CollectionUtils.isEmpty(getCategoryIds())) { return false; } if (!CollectionUtils.isEmpty(getTagNames())) { return false; } if (!CollectionUtils.isEmpty(getCustomFields())) { return false; } if (getAuthorId() != null) { return false; } if (getStatus() != null) { return false; } if (StringUtils.hasText(getLanguage())) { return false; } return true; }
From source file:com.azaptree.services.spring.application.config.SpringApplicationServiceConfig.java
private void loadJvmSystemProperties(final SpringApplicationService config) { final JvmSystemProperties props = config.getJvmSystemProperties(); if (props != null && !CollectionUtils.isEmpty(props.getProp())) { jvmSystemProperties = new Properties(); for (final Prop prop : props.getProp()) { jvmSystemProperties.setProperty(prop.getName(), prop.getValue().trim()); }/*from w w w . ja v a2 s . com*/ } }
From source file:cn.loveapple.client.android.database.impl.TemperatureDaoImpl.java
/** * {@inheritDoc}//from w w w . ja v a 2s. c om */ @Override public SortedMap<String, TemperatureEntity> findTemperatureMap(String datePoint) { Calendar current = Calendar.getInstance(); Calendar start = Calendar.getInstance(); if (StringUtils.isNotEmpty(datePoint)) { current.setTime(DateUtil.paseDate(datePoint, DateUtil.DATE_PTTERN_YYYYMMDD)); } start.set(current.get(Calendar.YEAR), current.get(Calendar.MONTH) - LIMIT_MONTH, current.get(Calendar.DAY_OF_MONTH)); List<TemperatureEntity> tempList = findByTerm(DateUtil.toDateString(start.getTime()), DateUtil.toDateString(current.getTime())); SortedMap<String, TemperatureEntity> result = new TreeMap<String, TemperatureEntity>(); if (CollectionUtils.isEmpty(tempList)) { return result; } // ??? SortedSet<String> dateSet = createDateKey(tempList.get(0).getDate()); for (TemperatureEntity temp : tempList) { dateSet.remove(temp.getDate()); result.put(temp.getDate(), temp); } for (String date : dateSet) { TemperatureEntity temperature = new TemperatureEntity(); temperature.setDate(date); result.put(date, temperature); } return result; }
From source file:com.sra.biotech.submittool.persistence.client.DatabaseToCdmClient.java
public List<Experiment> findAllExperiments(Link submissionExperimentsLink) { Experiment experiment = null;//from w w w . ja va 2 s. com Run run = null; DataBlock dataBlock = null; File file = null; Link experimentDataBlocksLink = null; Link experimentRunsLink = null; Link datablockFilesLink = null; RunResources runResources = null; FileResources fileResources = null; DataBlockResources dataBlockResources = null; List<Experiment> experiments = new ArrayList<Experiment>(); List<Run> runs = new ArrayList<Run>(); List<DataBlock> dataBlocks = new ArrayList<DataBlock>(); List<File> files = new ArrayList<File>(); ExperimentResources experimentResources = restTemplate.getForObject(submissionExperimentsLink.getHref(), ExperimentResources.class); if (experimentResources == null || CollectionUtils.isEmpty(experimentResources.getContent())) { return Collections.emptyList(); } for (ExperimentResource experimentResource : experimentResources) { experiment = experimentResource.getContent(); /* Get Run */ experimentRunsLink = experimentResource.getLink("runs"); runResources = restTemplate.getForObject(experimentRunsLink.getHref(), RunResources.class); for (RunResource runResource : runResources) { /* Get Datablocks */ run = runResource.getContent(); runs.add(run); experimentDataBlocksLink = runResource.getLink("dataBlocks"); dataBlockResources = restTemplate.getForObject(experimentDataBlocksLink.getHref(), DataBlockResources.class); for (DataBlockResource resource : dataBlockResources) { dataBlock = resource.getContent(); datablockFilesLink = resource.getLink("files"); fileResources = restTemplate.getForObject(datablockFilesLink.getHref(), FileResources.class); for (FileResource fileResource : fileResources) { dataBlock.getFiles().add(fileResource.getContent()); } run.getDataBlocks().add(dataBlock); } } /* End Of run resources */ experiment.setRuns(runs); experiments.add(experiment); } return experiments; //return experimentResources.unwrap(); }
From source file:be.roots.taconic.pricingguide.util.iTextUtil.java
public static byte[] merge(byte[]... pdfAsBytes) throws DocumentException, IOException { try (final ByteArrayOutputStream copyBaos = new ByteArrayOutputStream()) { final Document doc = new Document(); final PdfCopy copy = new PdfSmartCopy(doc, copyBaos); doc.open();/*from w w w . jav a 2 s .c o m*/ int numberOfPages = 0; final java.util.List<HashMap<String, Object>> bookmarks = new ArrayList<>(); PdfReader pdf = null; for (byte[] pdfAsByte : pdfAsBytes) { if (pdfAsByte != null && pdfAsByte.length > 0) { pdf = new PdfReader(pdfAsByte); pdf.consolidateNamedDestinations(); final List<HashMap<String, Object>> pdfBookmarks = SimpleBookmark.getBookmark(pdf); if (!CollectionUtils.isEmpty(pdfBookmarks)) { SimpleBookmark.shiftPageNumbers(pdfBookmarks, numberOfPages, null); bookmarks.addAll(pdfBookmarks); } for (int i = 1; i <= pdf.getNumberOfPages(); i++) { copy.addPage(copy.getImportedPage(pdf, i)); } numberOfPages += pdf.getNumberOfPages(); } } if (pdf != null) { SimpleNamedDestination.getNamedDestination(pdf, false); } if (!CollectionUtils.isEmpty(bookmarks)) { copy.setOutlines(bookmarks); } copy.close(); return copyBaos.toByteArray(); } }
From source file:fr.mby.saml2.sp.impl.config.BasicIdpConfig.java
/** * Process IdP metadatas.//from w w w . j a v a 2 s .c om * * @throws MetadataProviderException * @throws XMLParserException * @throws ConfigurationException */ protected void processIdpMetadata() throws MetadataProviderException, XMLParserException, ConfigurationException { BasicIdpConfig.LOGGER.debug("Precessing metadata of IdP with Id: [{}]...", this.id); DefaultBootstrap.bootstrap(); this.idpMetadataProvider = OpenSamlHelper.buildMetadataProvider(this.idpMetadata); Assert.notNull(this.idpMetadataProvider, "IdP metadata provider wasn't build !"); BasicIdpConfig.LOGGER.debug("IdP metadata provider ref: [{}].", this.idpMetadataProvider); this.signatureTrustEngine = this.buildSignatureTrustEngine(this.idpMetadataProvider); Assert.notNull(this.signatureTrustEngine, "Signature trust engine wasn't build !"); BasicIdpConfig.LOGGER.debug("IdP signature trust engine ref: [{}].", this.signatureTrustEngine); final EntityDescriptor idpEntityDescriptor = this.idpMetadataProvider.getEntityDescriptor(this.idpEntityId); Assert.notNull(idpEntityDescriptor, String .format("No entity descriptor found in IdP metadata for IdP entityId [%s]", this.idpEntityId)); BasicIdpConfig.LOGGER.debug("IdP entity descriptor ref: [{}].", idpEntityDescriptor); final IDPSSODescriptor ssoDescriptors = idpEntityDescriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS); if (ssoDescriptors != null) { // Retrieve SSO endpoints URL. final List<SingleSignOnService> ssoServices = ssoDescriptors.getSingleSignOnServices(); if (!CollectionUtils.isEmpty(ssoServices)) { for (final SingleSignOnService ssoService : ssoServices) { if ((ssoService != null)) { final SamlBindingEnum binding = SamlBindingEnum.fromSamlUri(ssoService.getBinding()); if (binding != null) { this.idpSsoEndpointUrl.put(binding, ssoService.getLocation()); } } } } // Retrieve Single Logout endpoints URL. final List<SingleLogoutService> slServices = ssoDescriptors.getSingleLogoutServices(); if (!CollectionUtils.isEmpty(slServices)) { for (final SingleLogoutService slService : slServices) { if ((slService != null)) { final SamlBindingEnum binding = SamlBindingEnum.fromSamlUri(slService.getBinding()); if (binding != null) { this.idpSloEndpointUrl.put(binding, slService.getLocation()); } } } } } for (final SamlBindingEnum binding : SamlBindingEnum.values()) { if (!StringUtils.hasText(this.idpSsoEndpointUrl.get(binding))) { BasicIdpConfig.LOGGER .warn(String.format("No SSO %s endpoint URL found in metadata for the [%s] IdP connector !", binding.getDescription(), this.getIdpEntityId())); } ; } for (final SamlBindingEnum binding : SamlBindingEnum.values()) { if (!StringUtils.hasText(this.idpSloEndpointUrl.get(binding))) { BasicIdpConfig.LOGGER .warn(String.format("No SLO %s endpoint URL found in metadata for the [%s] IdP connector !", binding.getDescription(), this.getIdpEntityId())); } } BasicIdpConfig.LOGGER.debug("IdP registered SSO endpoint URL: [{}]", this.idpSsoEndpointUrl); BasicIdpConfig.LOGGER.debug("IdP registered SLO endpoint URL: [{}]", this.idpSloEndpointUrl); }