List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:com.digitalgeneralists.assurance.ui.components.ScanDefinitionPanel.java
public boolean validateFormState() { Color controlInErrorBackgroundColor = Color.red; Color defaultControlBackgroundColor = Color.white; boolean result = true; if (StringUtils.isEmpty(this.nameTextField.getText())) { this.nameTextField.setBackground(controlInErrorBackgroundColor); result = false;/* www. java 2s .co m*/ } else { this.nameTextField.setBackground(defaultControlBackgroundColor); } if (!this.scanMappingsList.validateFormState()) { result = false; } return result; }
From source file:org.ihtsdo.otf.refset.graph.gao.HistoryGao.java
/** * @param memberId/* w w w .j a v a 2s . co m*/ * @return {@link ChangeRecord} */ public ChangeRecord<Member> getMemberStateHistory(String memberId, String refsetId) throws RefsetGraphAccessException, EntityNotFoundException { Object[] criteria = { memberId, refsetId }; LOGGER.debug("Getting member history for criteria {}", criteria); ChangeRecord<Member> history = new ChangeRecord<Member>(); TitanGraph g = null; try { g = f.getReadOnlyGraph(); Iterable<Vertex> vRs = g.query().has(TYPE, VertexType.refset.toString()).has(ID, refsetId).limit(1) .vertices(); if (!vRs.iterator().hasNext()) { throw new EntityNotFoundException("Refset does not exist for given refset id " + refsetId); } Vertex vR = vRs.iterator().next(); GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>(g); pipe.start(vR).inE(EdgeLabel.members.toString()).outV().has(ID, memberId).has(TYPE, VertexType.member.toString()); List<Vertex> vMs = pipe.toList(); for (Vertex vM : vMs) { Member currentMember = RefsetConvertor.getMember(vM); Iterable<Edge> edges = vM.getEdges(Direction.OUT, EdgeLabel.members.toString()); for (Edge edge : edges) { Set<String> eKeys = edge.getPropertyKeys(); if (eKeys.contains(REFERENCE_COMPONENT_ID)) { String referenceComponentId = edge.getProperty(REFERENCE_COMPONENT_ID); currentMember.setReferencedComponentId(referenceComponentId); } } GremlinPipeline<Vertex, Vertex> fPipe = new GremlinPipeline<Vertex, Vertex>(); fPipe.start(vM).outE(EdgeLabel.hasState.toString()).inV().has(ACTIVE).has(TYPE, VertexType.hMember.toString()); List<Vertex> fls = fPipe.toList(); List<Member> ms = RefsetConvertor.getStateMembers(fls); //we need to get missing data from existing member detail. TODO create full details during state creation for (Member m : ms) { if (StringUtils.isEmpty(m.getModuleId())) { m.setModuleId(currentMember.getModuleId()); } if (StringUtils.isEmpty(m.getReferencedComponentId())) { m.setReferencedComponentId(currentMember.getReferencedComponentId()); } } history.setRecords(ms); } } catch (EntityNotFoundException e) { RefsetGraphFactory.rollback(g); LOGGER.error("Error getting member state history", e); throw e; } catch (Exception e) { RefsetGraphFactory.rollback(g); LOGGER.error("Error getting member state history", e); throw new RefsetGraphAccessException(e.getMessage(), e); } finally { RefsetGraphFactory.shutdown(g); } LOGGER.debug("Returning {} ", history); return history; }
From source file:com.sastix.cms.client.impl.CmsClient.java
@Override public String getUID(String region) { StringBuilder url = new StringBuilder(getUrlRoot()).append(Constants.GET_UID); LOG.debug("API call: " + url); if (StringUtils.isEmpty(region)) { region = Constants.UID_REGION; }//from w w w . ja v a2s.c om final String UID = retryRestTemplate.postForObject(url.toString(), region, String.class); return UID; }
From source file:com.formkiq.core.equifax.service.EquifaxResponseProcessor.java
/** * Determine error code./* w ww .ja v a2 s . c o m*/ * @param err {@link CERRSegment} * @return {@link String} */ private String getErrorCode(final CERRSegment err) { if (err.getNumberOfProcessingErrors() > 0) { String code = this.processingErrors.get(err.getProcessingErrorCode1()); if (StringUtils.isEmpty(code)) { code = "Application is not approved PE " + err.getProcessingErrorCode1(); } return code; } if (err.getNumberOfFormatErrors() > 0) { String code = this.formatErrors.get(err.getFormatErrorCode1()); if (StringUtils.isEmpty(code)) { code = "Application is not approved FE " + err.getFormatErrorCode1(); } return code; } if (err.getNumberOfValidityErrors() > 0) { String code = this.validityErrors.get(err.getValidityErrorCode1()); if (StringUtils.isEmpty(code)) { code = "Application is not approved VC " + err.getValidityErrorCode1(); } return code; } return "Application is not approved"; }
From source file:com.seajas.search.contender.service.enricher.EnricherService.java
/** * Build the media notification context. * * @param document/*from w w w. j av a 2 s . co m*/ * @param reference * @return List<String> */ private List<String> buildContext(final EnricherDocument document, final String reference) { List<String> result = new ArrayList<String>(); result.add("referrer=" + reference); if (!StringUtils.isEmpty(document.getTitle())) result.add("title=" + document.getTitle()); return result; }
From source file:cn.guoyukun.spring.jpa.plugin.web.controller.BaseTreeableController.java
@Override protected String redirectToUrl(String backURL) { if (!StringUtils.isEmpty(backURL)) { return super.redirectToUrl(backURL); }/*from w ww . jav a 2 s . co m*/ return super.redirectToUrl(viewName("success")); }
From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java
private PdfPTable buildModelPricingTable(Pricing pricing) { final PdfPTable pricingTable = new PdfPTable(pricing.getNumberOfHeaderItems()); pricingTable.addCell(cell(new Paragraph(pricing.getCategory(), iTextUtil.getFontModelCategory()), pricing.getNumberOfHeaderItems())); pricingTable.addCell(cell(new Paragraph(" "), pricing.getNumberOfHeaderItems())); if (pricing.isQuantities()) { pricingTable.addCell(cellH(new Paragraph("Quantity", iTextUtil.getFontModelPricingTitle()))); }/*from www.j av a 2s .c o m*/ if (pricing.isAge()) { pricingTable.addCell(cellH(new Paragraph("Age (weeks)", iTextUtil.getFontModelPricingTitle()))); } if (pricing.isMale()) { pricingTable.addCell(cellH(new Paragraph("Male", iTextUtil.getFontModelPricingTitle()))); } if (pricing.isFemale()) { pricingTable.addCell(cellH(new Paragraph("Female", iTextUtil.getFontModelPricingTitle()))); } boolean invert = false; for (Line line : pricing.getLines()) { if (pricing.isQuantities()) { pricingTable.addCell( cellD(new Paragraph(line.getQuantity(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isAge()) { pricingTable .addCell(cellD(new Paragraph(line.getAge(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isMale()) { pricingTable .addCell(cellD(new Paragraph(line.getMale(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isFemale()) { pricingTable.addCell( cellD(new Paragraph(line.getFemale(), iTextUtil.getFontModelPricingData()), invert)); } invert = !invert; } if (!StringUtils.isEmpty(pricing.getMessage())) { pricingTable.addCell(cell(new Paragraph(pricing.getMessage(), iTextUtil.getFontModelPricingMessage()), pricing.getNumberOfHeaderItems())); } pricingTable.addCell(cell(new Paragraph(" "), pricing.getNumberOfHeaderItems())); return pricingTable; }
From source file:com.formkiq.core.service.UserServiceImplTest.java
/** * testGenerateResetToken01()./*w ww . j ava 2 s. c o m*/ */ @Test public void testGenerateResetToken01() { // given String email = "ASD"; Date date = new Date(); User u = new User(); u.setStatus(UserStatus.ACTIVE); // when expect(this.dateService.now()).andReturn(date); expect(this.userDao.findUser(email)).andReturn(u); expect(this.userDao.saveUser(u)).andReturn(u); replayAll(); this.service.generateResetToken(email); // then verifyAll(); assertFalse(StringUtils.isEmpty(u.getResetToken())); assertEquals(date, u.getResetInsertedDate()); }
From source file:com.baidu.rigel.biplatform.tesseract.node.service.impl.IsNodeServiceImpl.java
@Override public void saveNodeImage(Node node) { LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "saveNodeImage", "[node:" + node + "]")); if (node == null || StringUtils.isEmpty(node.getClusterName())) { LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "saveNodeImage", "[node:" + node + "]")); throw new IllegalArgumentException(); }//from w w w. j a v a 2s . c o m FileUtils.write(node.getImageFilePath(), SerializationUtils.serialize(node), true); LOGGER.info( String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "saveNodeImage", "[node:" + node + "]")); }
From source file:io.spring.initializr.web.ui.UiController.java
@RequestMapping(value = "/ui/dependencies", produces = "application/json") public ResponseEntity<String> dependencies(@RequestParam(required = false) String version) { List<DependencyGroup> dependencyGroups = metadataProvider.get().getDependencies().getContent(); List<DependencyItem> content = new ArrayList<>(); Version v = StringUtils.isEmpty(version) ? null : Version.parse(version); dependencyGroups.forEach(g -> g.getContent().forEach(d -> { if (v != null && d.getVersionRange() != null) { if (d.match(v)) { content.add(new DependencyItem(g.getName(), d)); }//from ww w . j a v a 2 s .co m } else { content.add(new DependencyItem(g.getName(), d)); } })); String json = writeDependencies(content); return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).eTag(createUniqueId(json)).body(json); }