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:burstcoin.jminer.core.network.Network.java

public void triggerServer() {
    if (!StringUtils.isEmpty(soloServer)) {
        NetworkRequestTriggerServerTask networkRequestTriggerServerTask = context
                .getBean(NetworkRequestTriggerServerTask.class);
        networkRequestTriggerServerTask.init(soloServer, numericAccountId, connectionTimeout);
        networkPool.execute(networkRequestTriggerServerTask);
    }/* w  w w .  ja  v  a 2 s .c o m*/
}

From source file:com.biz.report.service.impl.ItemDashBoardServiceImpl.java

public List<Report5DataSet> readDataForLineChart(String items, String months, String year) {
    if (!StringUtils.isEmpty(items) && items.contains("[")) {
        items = items.substring(1, items.length() - 1);
    }/*w  w w . j  a va 2s.  c  o  m*/
    String[] typeAr;
    if (!StringUtils.isEmpty(items) && items.contains(",")) {
        typeAr = items.split("[,]");
    } else {
        typeAr = new String[] { items };
    }
    if (!StringUtils.isEmpty(months) && months.contains("[")) {
        months = months.substring(1, months.length() - 1);
    }
    String[] monthAr;
    if (!StringUtils.isEmpty(months) && months.contains(",")) {
        monthAr = months.split("[,]");
    } else {
        monthAr = new String[] { months };
    }
    int typeCount = typeAr.length;
    List list = itemDashBoardDao.read(items, months, year);
    List<Report1> reportList = new MappingEngine().getList(list);
    logger.info(reportList.size());
    List<Report5DataSet> dataSets = new ArrayList<Report5DataSet>();
    for (int i = 0; i < typeCount; i++) {
        List<DataPoint> dataPoints = constructDataPoints(reportList, typeAr[i].trim(), monthAr, i);
        dataSets.add(new Report5DataSet(dataPoints, typeAr[i]));
    }
    return dataSets;
}

From source file:org.ihtsdo.otf.refset.security.RefsetIdentityService.java

/**
 * @param obj//from  w  w w .  j a v a2  s.  c  o m
 */
private User populateUser(User user, JsonNode obj) {

    //mandatory values
    JsonNode userJson = obj.get("user");
    String id = userJson.findValue("name").asText();
    String status = userJson.findValue("status").asText();

    boolean authenticated = !StringUtils.isEmpty(status) && status.equalsIgnoreCase("enabled") ? true : false;

    user.setUsername(id);
    user.setPassword(userJson.findValue("token").asText());
    user.setAuthenticated(authenticated);
    user.setEnabled(authenticated);
    //other details
    JsonNode email = userJson.findValue("email");

    if (email != null) {

        user.setEmail(email.asText());

    }
    JsonNode middleName = userJson.findValue("middleName");

    if (middleName != null) {

        user.setMiddlename(middleName.asText());

    }

    JsonNode givenName = userJson.findValue("givenName");

    if (givenName != null) {

        user.setGivenname(givenName.asText());

    }

    JsonNode surname = userJson.findValue("surname");

    if (surname != null) {

        user.setSurname(surname.asText());

    }

    return user;
}

From source file:ymanv.forex.web.RateController.java

private Pageable getPageRequest(Integer page, String dir, String sortedBy) {
    // Sort direction
    Direction sortDir = Direction.DESC;//from  w w w .j  a  v a  2s .  co m
    if ("asc".equalsIgnoreCase(dir)) {
        sortDir = Direction.ASC;
    }
    // Sort fields
    String[] fields = new String[1];
    if (!StringUtils.isEmpty(sortedBy)) {
        fields[0] = sortedBy;
    } else {
        fields[0] = "date";
    }
    return new PageRequest(page != null && page > 0 ? page - 1 : 0, countPerPage, sortDir, fields);
}

From source file:com.digitalgeneralists.assurance.ui.components.FilePickerTextField.java

public boolean validateFormState() {
    boolean result = true;

    if (StringUtils.isEmpty(this.pathTextField.getText())) {
        this.pathTextField.setBackground(this.controlInErrorBackgroundColor);
        result = false;//from ww  w  .java2  s  . co m
    } else {
        this.pathTextField.setBackground(this.defaultControlBackgroundColor);
    }

    return result;
}

From source file:org.jdal.aop.SerializableReference.java

private Object readResolve() throws ObjectStreamException {
    if (beanFactory == null) {
        log.error("Can't not deserialize reference without bean factory");
        return null;
    }//from w ww. j  a v a 2s .c o  m

    if (useMemoryCache) {
        Object ret = serializedObjects.remove(this.id);
        if (ret != null) {
            if (log.isDebugEnabled())
                log.debug("Removed a serialized reference. serialized objects size [" + serializedObjects.size()
                        + "]");

            return getSerializableProxy(ret);
        }
    }

    if (targetBeanName != null) {
        if (log.isDebugEnabled())
            log.debug("Resolving serializable object to bean name [" + targetBeanName + "]");

        return getSerializableProxy();
    }

    if (log.isDebugEnabled())
        log.debug("Resolving serializable object for [" + descriptor.getDependencyName() + "]");

    Field field = descriptor.getField();

    // Check bean definition
    BeanDefinition rbd = beanFactory.getBeanDefinition(beanName);
    PropertyValues pvs = rbd.getPropertyValues();
    if (pvs.contains(field.getName())) {
        Object value = pvs.getPropertyValue(field.getName());
        if (value instanceof BeanReference) {
            // cache the bean name 
            this.targetBeanName = ((BeanReference) value).getBeanName();
            return getSerializableProxy();
        }
    }

    // Check Autowired
    try {
        Object bean = beanFactory.resolveDependency(descriptor, beanName);

        if (bean != null)
            return getSerializableProxy(bean);
    } catch (BeansException be) {
        // dependency not found.
    }

    // Check Resource annotation
    if (field.isAnnotationPresent(Resource.class)) {
        Resource r = field.getAnnotation(Resource.class);
        String name = StringUtils.isEmpty(r.name()) ? descriptor.getField().getName() : r.name();

        if (beanFactory.containsBean(name)) {
            this.targetBeanName = name;
            return getSerializableProxy();
        }
    }

    // Try with depend beans.      
    String[] dependentBeans = beanFactory.getDependenciesForBean(beanName);
    List<String> candidates = new ArrayList<String>();

    for (String name : dependentBeans) {
        if (beanFactory.isTypeMatch(name, descriptor.getDependencyType()))
            ;
        candidates.add(name);
    }

    if (candidates.size() == 1)
        return getSerializableProxy(beanFactory.getBean(candidates.get(0)));

    if (candidates.size() > 1) {
        for (PropertyValue pv : pvs.getPropertyValues()) {
            if (pv.getValue() instanceof BeanReference) {
                BeanReference br = (BeanReference) pv.getValue();
                if (candidates.contains(br.getBeanName()))
                    return getSerializableProxy(beanFactory.getBean(br.getBeanName()));
            }
        }
    }

    log.error("Cant not resolve serializable reference wiht candidates " + candidates.toArray());

    return null;
}

From source file:cz.muni.fi.mir.tools.SiteTitleInterceptor.java

private void resolveClassLevelTitle(SiteTitle siteTitle, SiteTitleContainer result) {
    if (!StringUtils.isEmpty(siteTitle.mainTitle())) {
        result.setMainTitle(siteTitle.mainTitle());
    } else {//from w  w w .j av a 2  s . c  o  m
        result.setMainTitle(this.mainTitle);
    }
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.cli.CLIRunner.java

public void run(String... args) throws IOException, ParseException, org.apache.commons.cli.ParseException {

    logger.info("Start cat CLI Runner.");
    logger.debug("mongo host: {}", host);
    logger.debug("mongo Index path: {}", iaviewCollectionPath);

    final String[] cliArgs = filterInputToGetOnlyCliArguments(args);

    Options options = registerAvailableActionsAndOptions();

    CommandLineParser parser = new BasicParser();
    CommandLine cmd = parser.parse(options, cliArgs);

    if (cliArgs.length > 0) {
        logger.debug("args: {} ", Arrays.asList(cliArgs).toString());
    } else {//ww  w .  jav a2 s .c o m
        logger.warn("no valid argument provided");
        logger.info("Stop cat CLI Runner.");
        return;
    }

    /**
     * Management of training Set
     */

    if (cmd.hasOption(ACTION_UPDATE_CATEGORIES_SCORES)) {
        logger.info("update categories scores ");
        String minNumber = cmd.getOptionValue(OPTION_MIN_ELEMENTS_PER_CAT);
        String maxNumber = cmd.getOptionValue(OPTION_MAX_ELEMENTS_PER_CAT);
        trainingSetService.updateCategoriesScores(Integer.parseInt(minNumber), Integer.parseInt(maxNumber));
    }

    if (cmd.hasOption(ACTION_UPDATE)) {
        logger.info("update (create if not existing) training set");
        String categoryCiaid = null;
        if (cmd.hasOption(OPTION_CIAID)) {
            categoryCiaid = cmd.getOptionValue(OPTION_CIAID);
        }
        Integer fixedLimitSize = null;
        if (cmd.hasOption(OPTION_FIXED_SIZE)) {
            fixedLimitSize = Integer.valueOf(cmd.getOptionValue(OPTION_FIXED_SIZE));
        }

        updateTrainingSet(categoryCiaid, fixedLimitSize);
    }

    if (cmd.hasOption(ACTION_INDEX)) {
        trainingSetService.indexTrainingSet();
    }

    /**
     * Run Categorisation
     */

    if (cmd.hasOption(ACTION_TEST_CATEGORISE_SINGLE)) {
        String docRef = cmd.getOptionValue(OPTION_DOC_REF);
        if (StringUtils.isEmpty(docRef)) {
            docRef = "C1253";
        }
        categoriser.testCategoriseSingle(docRef);
    }
    if (cmd.hasOption(ACTION_CATEGORISE_SINGLE)) {
        String docRef = cmd.getOptionValue(OPTION_DOC_REF);
        if (StringUtils.isEmpty(docRef)) {
            docRef = "C1253";
        }
        categoriser.categoriseSingle(docRef);
    }

    // if (cmd.hasOption(ACTION_TEST_CATEGORISE_ALL)) {
    // categoriser.testCategoriseIAViewSolrIndex();
    // }

    /**
     * Evaluate Categorisation System
     */

    if (cmd.hasOption(ACTION_CREATE_EVALUATION_DATA_SET)) {
        Integer minimumSizePerCat = 10;
        if (cmd.hasOption(OPTION_MINIMUM_SIZE_PER_CATEGORY)) {
            minimumSizePerCat = Integer.valueOf(cmd.getOptionValue(OPTION_MINIMUM_SIZE_PER_CATEGORY));
        }
        evaluationService.createEvaluationTestDataset(minimumSizePerCat);
    }

    if (cmd.hasOption(ACTION_CATEGORISE_EVALUATION_DATA_SET)) {
        Boolean matchNbOfReturnedCategories = false;
        if (cmd.hasOption(OPTION_MATCH_NB_OF_RETURNED_CATEGORIES)) {
            matchNbOfReturnedCategories = Boolean
                    .valueOf(cmd.getOptionValue(OPTION_MATCH_NB_OF_RETURNED_CATEGORIES));
        }
        evaluationService.runCategorisationOnTestDataSet(matchNbOfReturnedCategories);
    }

    if (cmd.hasOption(ACTION_GET_EVALUATION_REPORT)) {
        String userComments = null;
        if (cmd.hasOption(OPTION_EVALUATION_REPORT_COMMENTS)) {
            userComments = cmd.getOptionValue(OPTION_EVALUATION_REPORT_COMMENTS);
        }

        String aggregatedComments = aggregateCommentsWithArguments(userComments, args);

        getEvaluationReport(aggregatedComments);

    }

    /**
     * get Help
     */

    if (cmd.hasOption(ACTION_HELP)) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(150);
        formatter.printHelp("help", options);
    }

    logger.info("Stop cat CLI Runner.");
}

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

@RequestMapping(value = "/generateHash", method = { RequestMethod.POST, RequestMethod.GET })
public ResponseWrapper generateHash(HttpServletRequest request, HttpServletResponse response) {
    logger.info("PatientRecordController---generateHash()--STARTS");
    ResponseWrapper wrapper = new ResponseWrapper();
    String data = request.getParameter("data");
    try {//from   ww w . j  a  va  2s .  c o m
        if (utils.verifychaincode()) {
            if (data != null && !data.isEmpty()) {
                JSONObject hashData = (JSONObject) new JSONParser().parse(data);
                String patientID = ((String) hashData.get("patientSSN")).toUpperCase().trim();
                String lastName = ((String) hashData.get("lastName")).toUpperCase().trim();
                String dob = ((String) hashData.get("dateOfBirth")).trim();
                String dov = ((String) hashData.get("dateOfVisit")).trim();
                String docLicense = ((String) hashData.get("doctorLicense")).trim();
                if (!StringUtils.isEmpty(patientID) && !StringUtils.isEmpty(lastName)
                        && !StringUtils.isEmpty(dob) && !StringUtils.isEmpty(dov)
                        && !StringUtils.isEmpty(docLicense)) {
                    String hashdata = patientID.concat(lastName).concat(dob).concat(dov).concat(docLicense);
                    MessageDigest digest = DigestSHA3.getInstance("SHA-256");
                    digest.update(hashdata.getBytes());
                    wrapper.resultObject = Hex.toHexString(digest.digest());
                } 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.INTERNAL_ERROR);
        logger.error("PatientRecordController---generateHash()--ERROR " + e);
    }
    logger.info("PatientRecordController---generateHash()--ENDS");
    return wrapper;
}

From source file:com.biz.report.service.impl.CustomerServiceImpl.java

public List<Report5DataSet> readDataForLineChart(String customers, String months, String year) {
    if (!StringUtils.isEmpty(customers) && customers.contains("[")) {
        customers = customers.substring(1, customers.length() - 1);
    }//from w ww .  j  a  v  a 2 s  . com
    String[] typeAr;
    if (!StringUtils.isEmpty(customers) && customers.contains(",")) {
        typeAr = customers.split("[,]");
    } else {
        typeAr = new String[] { customers };
    }
    if (!StringUtils.isEmpty(months) && months.contains("[")) {
        months = months.substring(1, months.length() - 1);
    }
    String[] monthAr;
    if (!StringUtils.isEmpty(months) && months.contains(",")) {
        monthAr = months.split("[,]");
    } else {
        monthAr = new String[] { months };
    }
    int typeCount = typeAr.length;
    List list = customerReportDao.read(customers, months, year);
    List<Report1> reportList = new MappingEngine().getList(list);
    logger.info(reportList.size());
    List<Report5DataSet> dataSets = new ArrayList<Report5DataSet>();
    for (int i = 0; i < typeCount; i++) {
        List<DataPoint> dataPoints = constructDataPoints(reportList, typeAr[i].trim(), monthAr, i);
        dataSets.add(new Report5DataSet(dataPoints, typeAr[i]));
    }
    return dataSets;
}