Example usage for org.springframework.util StringUtils isEmpty

List of usage examples for org.springframework.util StringUtils isEmpty

Introduction

In this page you can find the example usage for org.springframework.util StringUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable Object str) 

Source Link

Document

Check whether the given object (possibly a String ) is empty.

Usage

From source file:com.baidu.rigel.biplatform.tesseract.isservice.index.service.impl.IndexServiceImpl.java

@Override
public void updateIndexByDataSourceKey(String dataSourceKey, String[] factTableNames,
        Map<String, Map<String, BigDecimal>> dataSetMap) throws IndexAndSearchException {

    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "updateIndexByDataSourceKey",
            dataSourceKey));/*from  ww  w.j  a va 2 s. c  om*/
    if (StringUtils.isEmpty(dataSourceKey)) {
        LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION,
                "updateIndexByDataSourceKey", dataSourceKey));
        throw new IllegalArgumentException();
    }

    List<IndexMeta> metaList = new ArrayList<IndexMeta>();
    IndexAction idxAction = IndexAction.INDEX_UPDATE;

    if (MapUtils.isEmpty(dataSetMap)) {
        if (!ArrayUtils.isEmpty(factTableNames)) {
            for (String factTableName : factTableNames) {
                List<IndexMeta> fTableMetaList = this.indexMetaService
                        .getIndexMetasByFactTableName(factTableName, dataSourceKey);
                if (!CollectionUtils.isEmpty(fTableMetaList)) {
                    metaList.addAll(fTableMetaList);
                } else {
                    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_PROCESS,
                            "updateIndexByDataSourceKey", dataSourceKey,
                            "can not find IndexMeta for Facttable:[" + factTableNames + "]"));
                }
            }
        } else {
            metaList = this.indexMetaService.getIndexMetasByDataSourceKey(dataSourceKey);
        }
    } else {
        idxAction = IndexAction.INDEX_MOD;
        for (String factTableName : dataSetMap.keySet()) {
            List<IndexMeta> fTableMetaList = this.indexMetaService.getIndexMetasByFactTableName(factTableName,
                    dataSourceKey);
            if (!CollectionUtils.isEmpty(fTableMetaList)) {
                metaList.addAll(fTableMetaList);
            }
        }

    }

    for (IndexMeta meta : metaList) {
        Map<String, BigDecimal> tableDataSetMap = null;
        if (!MapUtils.isEmpty(dataSetMap)) {
            tableDataSetMap = dataSetMap.get(meta.getFacttableName());
        }
        try {
            doIndexByIndexAction(meta, idxAction, tableDataSetMap);
        } catch (Exception e) {
            LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION,
                    "updateIndexByDataSourceKey", "DataSourceKey:[" + dataSourceKey + "] FactTable:["
                            + meta.getFacttableName() + "] IndexMetaId:[" + meta.getIndexMetaId() + "]"));
            String message = TesseractExceptionUtils.getExceptionMessage(
                    IndexAndSearchException.INDEXEXCEPTION_MESSAGE,
                    IndexAndSearchExceptionType.INDEX_EXCEPTION);
            throw new IndexAndSearchException(message, e.getCause(),
                    IndexAndSearchExceptionType.INDEX_EXCEPTION);
        }
    }
    try {
        publishIndexUpdateEvent(metaList);
    } catch (Exception e) {
        LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION,
                "updateIndexByDataSourceKey", dataSourceKey));
        String message = TesseractExceptionUtils.getExceptionMessage(
                IndexAndSearchException.INDEXEXCEPTION_MESSAGE,
                IndexAndSearchExceptionType.INDEX_UPDATE_EXCEPTION);
        throw new IndexAndSearchException(message, e.getCause(), IndexAndSearchExceptionType.INDEX_EXCEPTION);
    }

    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "updateIndexByDataSourceKey",
            dataSourceKey));
}

From source file:burstcoin.jminer.core.CoreProperties.java

private static Boolean asBoolean(String key, boolean defaultValue) {
    String booleanProperty = PROPS.containsKey(key) ? String.valueOf(PROPS.getProperty(key)) : null;
    Boolean value = null;// w  w  w . j a va2 s . c om
    if (!StringUtils.isEmpty(booleanProperty)) {
        try {
            value = Boolean.valueOf(booleanProperty);
        } catch (Exception e) {
            LOG.error("property: '" + key + "' value should be of type 'boolean' (e.g. 'true' or 'false').");
        }
    }
    return value != null ? value : defaultValue;
}

From source file:uk.ac.ebi.ep.parser.parsers.ChEBICompounds.java

/**
 * Searches a compound name in ChEBI. Please note that if the name does not
 * match <i>exactly</i> any names/synonyms returned by ChEBI, the result
 * will be <code>null</code>.
 *
 * @param moleculeName the compound name.
 * @return an entry with a ChEBI ID, or <code>null</code> if not found.
 *///from w ww  .  j  a v  a2  s.  c o  m
protected EnzymePortalCompound searchMoleculeInChEBI(String moleculeName) {

    EnzymePortalCompound entry = null;
    // Sometimes moleculeName comes as "moleculeName (ACRONYM)"
    // sometimes as "moleculeName (concentration)":
    Matcher m = COMPOUND_NAME_PATTERN.matcher(moleculeName);
    m.matches(); // always
    String[] nameAcronym = { m.group(1), m.group(2) };
    // first name, then acronym (if any):
    nameLoop: for (String name : nameAcronym) {
        if (name == null) {
            continue; // acronym, usually
        }
        try {
            LiteEntityList lites = chebiWsClient.getLiteEntity(name, SearchCategory.ALL_NAMES, 25,
                    StarsCategory.ALL);
            String chebiId = null;

            if (lites != null) {
                liteLoop: for (LiteEntity lite : lites.getListElement()) {
                    Entity completeEntity = chebiWsClient.getCompleteEntity(lite.getChebiId());
                    List<String> synonyms = new ArrayList<>();
                    for (DataItem dataItem : completeEntity.getSynonyms()) {
                        synonyms.add(dataItem.getData().toLowerCase());
                    }
                    List<String> formulae = new ArrayList<>();
                    for (DataItem formula : completeEntity.getFormulae()) {
                        formulae.add(formula.getData());
                    }
                    if (completeEntity.getChebiAsciiName().equalsIgnoreCase(name)
                            || synonyms.contains(name.toLowerCase()) || formulae.contains(name)) {
                        chebiId = completeEntity.getChebiId();
                    }
                    if (chebiId != null) {
                        break liteLoop;
                    }
                }
            }

            if ((chebiId == null || blackList.contains(name)) || StringUtils.isEmpty(name)) {
                LOGGER.warn("Not found in ChEBI: " + name);
            } else {
                entry = new EnzymePortalCompound();
                entry.setCompoundSource(MmDatabase.ChEBI.name());
                entry.setCompoundId(chebiId);
                entry.setCompoundName(name);
                break;
            }
        } catch (ChebiWebServiceFault_Exception e) {
            LOGGER.error("Searching for " + name, e);
        }
    }
    return entry;
}

From source file:org.nekorp.workflow.desktop.view.DatosAutoView.java

public void bindComponents() {
    bindingManager.registerBind(viewServicioModel, "descripcion", (Bindable) this.descripcionServicio);

    this.bindingManager.registerBind(viewServicioModel.getAuto(), "marca", marca.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getAuto(), "tipo", tipo.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getAuto(), "version", version.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getAuto(), "numeroSerie", (Bindable) numeroSerie);
    this.bindingManager.registerBind(viewServicioModel.getAuto(), "modelo", modelo.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getAuto(), "color", color.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getAuto(), "placas", placas.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getDatosAuto(), "kilometraje",
            kilometraje.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getDatosAuto(), "combustible",
            combustible.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getDatosAuto(), "combustible",
            (Bindable) combustibleSlide);

    this.bindingManager.registerBind(viewServicioModel.getAuto().getEquipamiento(), "transmision",
            (Bindable) estandar);/*from w ww  . ja  v a 2 s.c  o m*/
    this.bindingManager.registerBind(viewServicioModel.getAuto().getEquipamiento(), "transmision",
            (Bindable) automatico);
    this.bindingManager.registerBind(viewServicioModel.getAuto().getEquipamiento(), "elevadores",
            (Bindable) manuales);
    this.bindingManager.registerBind(viewServicioModel.getAuto().getEquipamiento(), "elevadores",
            (Bindable) electrico);
    this.bindingManager.registerBind(viewServicioModel.getAuto().getEquipamiento(), "bolsasDeAire",
            bolsasDeAire.getTextField());
    this.bindingManager.registerBind(viewServicioModel.getAuto().getEquipamiento(), "aireAcondicionado",
            (Bindable) aireAcondicionado);
    this.bindingManager.registerBind(viewServicioModel.getAuto().getEquipamiento(), "equipoAdicional",
            (Bindable) modelEquipoAdicional);

    //binding validaciones
    this.bindingManager.registerBind(validacionDatosAuto, "marca", marca);
    this.bindingManager.registerBind(validacionDatosAuto, "tipo", tipo);
    this.bindingManager.registerBind(validacionDatosAuto, "version", version);
    this.bindingManager.registerBind(validacionDatosAuto, "numeroSerie", wrapperSearch);
    this.bindingManager.registerBind(validacionDatosAuto, "modelo", modelo);
    this.bindingManager.registerBind(validacionDatosAuto, "color", color);
    this.bindingManager.registerBind(validacionDatosAuto, "placas", placas);
    this.bindingManager.registerBind(validacionDatosAuto, "kilometraje", kilometraje);
    this.bindingManager.registerBind(validacionDatosAuto, "descripcionServicio", new ReadOnlyBinding() {
        @Override
        public void notifyUpdate(Object origen, String property, Object value) {
            EstatusValidacion status = (EstatusValidacion) value;
            if (status.isValido()) {
                descripcionServicio.setBorder(
                        javax.swing.BorderFactory.createLineBorder(new java.awt.Color(224, 230, 230), 2));
            } else {
                descripcionServicio.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED, 2));
            }
            if (StringUtils.isEmpty(status.getDetalle())) {
                descripcionServicio.setToolTipText(null);
            } else {
                descripcionServicio.setToolTipText(status.getDetalle());
            }
        }
    });

    //permisos
    Bindable permisosBind = new ReadOnlyBinding() {
        @Override
        public void notifyUpdate(Object origen, String property, Object value) {
            boolean valor = (boolean) value;
            setEditableStatus(valor);
        }
    };
    bindingManager.registerBind(permisos, "puedeEditar", permisosBind);
    this.wrapperSearch.getTextField().setText("");
    this.wrapperSearch.setEnabled(false);
}

From source file:me.doshou.admin.maintain.staticresource.web.controller.StaticResourceVersionController.java

private Map<String, List<StaticResource>> findStaticResources(String realPath) throws IOException {

    final Map<String, List<StaticResource>> resources = Maps.newTreeMap();

    final int realPathLength = realPath.length();

    Collection<File> files = FileUtils.listFiles(new File(realPath), new String[] { "jspf" }, true);

    for (File file : files) {

        String fileName = file.getAbsolutePath().substring(realPathLength);
        List<String> contents = FileUtils.readLines(file);

        List<StaticResource> resourceList = resources.get(fileName);
        if (resourceList == null) {
            resourceList = Lists.newArrayList();
        }/*from   w w w.  j a v  a  2s. c om*/

        for (String content : contents) {
            if (!StringUtils.isEmpty(content)) {
                StaticResource resource = extractResource(fileName, content);
                if (resource != null) {
                    resourceList.add(resource);
                }
            }
        }

        if (CollectionUtils.isNotEmpty(resourceList)) {
            resources.put(fileName, resourceList);
        }
    }

    return resources;
}

From source file:burstcoin.jminer.core.CoreProperties.java

private static int asInteger(String key, int defaultValue) {
    String integerProperty = PROPS.containsKey(key) ? String.valueOf(PROPS.getProperty(key)) : null;
    Integer value = null;//from w ww.  jav a 2  s .  com
    if (!StringUtils.isEmpty(integerProperty)) {
        try {
            value = Integer.valueOf(integerProperty);
        } catch (NumberFormatException e) {
            LOG.error("value of property: '" + key + "' should be a numeric (int) value.");
        }
    }
    return value != null ? value : defaultValue;
}

From source file:com.krypc.hl.pr.controller.PatientRecordController.java

@RequestMapping(value = "/approveRecordRequest", method = { RequestMethod.POST, RequestMethod.GET })
public ResponseWrapper approveRecordRequest(HttpServletRequest request, HttpServletResponse response) {
    logger.info("PatientRecordController---approveRecordRequest()--STARTS");
    ResponseWrapper wrapper = new ResponseWrapper();
    String data = request.getParameter("data");
    try {//from  w ww .j a v a2 s . co m
        if (utils.verifychaincode()) {
            if (data != null && !data.isEmpty()) {
                JSONObject recordData = (JSONObject) new JSONParser().parse(data);
                String user = ((String) recordData.get("user")).trim();
                String patientSSN = ((String) recordData.get("patientSSN")).trim();
                String hash = ((String) recordData.get("hash")).trim();
                String docId = ((String) recordData.get("doctorId")).trim();
                String recordId = ((String) recordData.get("recordId")).trim();
                String isApproved = ((String) recordData.get("isApproved")).trim();
                String isPaid = ((String) recordData.get("isPaid")).trim();
                if (!StringUtils.isEmpty(isPaid) && !StringUtils.isEmpty(recordId) && !StringUtils.isEmpty(hash)
                        && !StringUtils.isEmpty(docId) && !StringUtils.isEmpty(patientSSN)
                        && !StringUtils.isEmpty(isApproved) && !StringUtils.isEmpty(user)) {
                    if ((isApproved.equals("0")) || (isApproved.equals("1")) || (isApproved.equals("2"))) {
                        if ((isPaid.equals("0")) || (isPaid.equals("1")) || (isPaid.equals("2"))) {
                            String[] arugs = new String[] { patientSSN, hash, docId, recordId, isApproved,
                                    isPaid };
                            InvokeRequest invokerequest = new InvokeRequest();
                            ArrayList<String> argss = new ArrayList<>(
                                    Arrays.asList(Constants.MethodName.patientapproval.toString()));
                            argss.addAll(Arrays.asList(arugs));
                            invokerequest.setArgs(argss);
                            invokerequest.setChaincodeID(utils.getChaincodeName().getChainCodeID());
                            invokerequest.setChaincodeName(utils.getChaincodeName().getTransactionID());
                            invokerequest.setChaincodeLanguage(ChaincodeLanguage.JAVA);
                            Member member = peerMembershipServicesAPI.getChain().getMember(user);
                            wrapper.resultObject = member.invoke(invokerequest);
                        } else {
                            wrapper.setError(ERROR_CODES.INVALID_PAYMENT_STATUS_PARAMETER);
                        }
                    } else {
                        wrapper.setError(ERROR_CODES.INVALID_RECORD_ACCESS_PARAMETER);
                    }
                } else {
                    wrapper.setError(ERROR_CODES.MANDATORY_FIELDS_MISSING);
                }
            } else {
                wrapper.setError(ERROR_CODES.MANDATORY_FIELDS_MISSING);
            }
        } else {
            wrapper.setError(ERROR_CODES.CHAINCODE_NOT_DEPLOYED);
        }
    } catch (Exception e) {
        wrapper.setError(ERROR_CODES.NO_RECORDS_FOUND_FOR_PROVIDED_PARAMETERS);
        logger.error("PatientRecordController---approveRecordRequest()--ERROR " + e);
    }
    logger.info("PatientRecordController---approveRecordRequest()--ENDS");
    return wrapper;
}

From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java

private Phrase processHtmlCodes(String name, Font baseFont, Font symbol) {

    final Font italicFont = new Font(baseFont);
    italicFont.setStyle(Font.FontStyle.ITALIC.getValue());

    final Font normalFont = new Font(baseFont);

    Font usedFont = normalFont;//from  w  ww  .  jav a2s .c o  m

    final Phrase phrase = new Phrase();

    if (!StringUtils.isEmpty(name)) {

        for (String[] alphabet : GreekAlphabet.getAlphabet()) {
            name = name.replaceAll(alphabet[0], DELIMETER + alphabet[0] + DELIMETER);
        }
        name = name.replaceAll("<sup>|<SUP>", DELIMETER + "<sup>");
        name = name.replaceAll("</sup>|</SUP>", DELIMETER);
        name = name.replaceAll("<i>|<I>|<em>|<EM>", DELIMETER + "<i>");
        name = name.replaceAll("</i>|</I>|</em>|</EM>", DELIMETER + "</i>");

        final String[] tokens = name.split(DELIMETER);
        for (String token : tokens) {

            String text = token;
            if (text.startsWith("<i>")) {
                usedFont = italicFont;
                text = text.substring(3);
            } else if (text.startsWith("</i>")) {
                usedFont = normalFont;
                text = text.substring(4);
            }

            usedFont.setSize(baseFont.getSize());

            if (text.startsWith("&")) {
                final char replacement = GreekAlphabet.getReplacement(text);
                if (!Character.isWhitespace(replacement)) {
                    phrase.add(SpecialSymbol.get(replacement, symbol));
                } else {
                    phrase.add(new Chunk(text, usedFont));
                }
            } else if (text.startsWith("<sup>")) {

                final Font superScriptFont = new Font(usedFont);
                superScriptFont.setSize(baseFont.getSize() - 1.5f);

                final Chunk superScript = new Chunk(text.substring(5), superScriptFont);
                superScript.setTextRise(4f);
                phrase.add(superScript);

            } else {
                phrase.add(new Chunk(text, usedFont));
            }

        }
    }

    return phrase;
}

From source file:com.formkiq.core.service.UserServiceImpl.java

/**
 * Encrypts the User Login Token and set it into the object.
 * @param user User//from   w  w w  . jav a  2 s.co m
 * @param loginToken unencrypted login token
 */
private void setUserLoginToken(final User user, final String loginToken) {

    if (!StringUtils.isEmpty(loginToken)) {
        user.setLoginToken(loginToken);
    }
}

From source file:com.baidu.rigel.biplatform.tesseract.node.service.impl.IsNodeServiceImpl.java

@Override
public Node getNodeByNodeKey(String clusterName, String nodeKey, boolean isAvailable) {
    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "getNodeByNodeKey",
            "[clusterName:" + clusterName + "][nodeKey:" + nodeKey + "][isAvailable:" + isAvailable + "]"));

    if (StringUtils.isEmpty(nodeKey) || StringUtils.isEmpty(clusterName)) {
        LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_PROCESS, "getNodeByNodeKey",
                "[clusterName:" + clusterName + "][nodeKey:" + nodeKey + "][isAvailable:" + isAvailable + "]",
                "param illegal"));
        return null;
    }//  w w w .ja v  a  2  s .  c  o m
    List<String> nodeKeyList = new ArrayList<String>();
    nodeKeyList.add(nodeKey);
    Map<String, Node> nodeMap = getNodeMapByNodeKey(clusterName, nodeKeyList, isAvailable);
    if (MapUtils.isNotEmpty(nodeMap) && nodeMap.containsKey(nodeKey)) {
        return nodeMap.get(nodeKey);
    }
    return null;
}