Example usage for org.springframework.util CollectionUtils isEmpty

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

Introduction

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

Prototype

public static boolean isEmpty(@Nullable Map<?, ?> map) 

Source Link

Document

Return true if the supplied Map is null or empty.

Usage

From source file:com.consol.citrus.admin.web.ConfigurationController.java

@RequestMapping(value = "/namespace-context", method = { RequestMethod.GET })
@ResponseBody//  ww w .j ava  2  s .  c om
public NamespaceContextModel getNamespaceContext() {
    List<NamespaceContextModel> components = springBeanService.getBeanDefinitions(
            projectService.getProjectContextConfigFile(), projectService.getActiveProject(),
            NamespaceContextModel.class);
    if (CollectionUtils.isEmpty(components)) {
        return new NamespaceContextModel();
    } else {
        return components.get(0);
    }
}

From source file:au.com.optus.mcas.sdp.bizservice.ott.ordertracking.batchjob.dao.impl.AbstractDaoImpl.java

/**
 * {@inheritDoc}/*w  w  w .  ja  v  a  2s . com*/
 */
@SuppressWarnings("unchecked")
public List<E> findByNamedQueryAndNamedParams(final String queryName,
        final Map<String, ? extends Object> parameters, int limit) {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(String.format(
                "Finding instances of '%s' using named query '%s' and the following parameter/value(s): %s",
                getEntityClass(), queryName, parameters));
    }

    final Query namedQuery = getEntityManager().createNamedQuery(queryName);
    // final TypedQuery<E> namedQuery = mEntityManager.createNamedQuery(queryName, mEntityClass);
    if (!CollectionUtils.isEmpty(parameters)) {
        for (final Map.Entry<String, ? extends Object> param : parameters.entrySet()) {
            namedQuery.setParameter(param.getKey(), param.getValue());
        }
    }
    namedQuery.setFirstResult(0);
    namedQuery.setMaxResults(limit);

    return namedQuery.getResultList();
}

From source file:fr.paris.lutece.plugins.mydashboard.business.PanelHome.java

/**
 * Returns  the default panel//from   ww  w .j  a v a2  s. co m
 * @param nKey The panel primary key
 * @return an instance of Panel
 */
public static Panel getDefaultPanel() {
    Panel defaultPanel = _dao.loadDefaultPanel(_plugin);

    if (defaultPanel == null) {
        List<Panel> listPanel = getPanelsList();
        defaultPanel = (!CollectionUtils.isEmpty(listPanel)) ? listPanel.get(0) : null;
    }

    return defaultPanel;
}

From source file:net.sf.sze.frontend.zeugnis.ZeugnisController.java

/**
 * Zeigt den Auswahl-Dialog fr die Klasse.
 * @param halbjahrId die Id des Halbjahres
 * @param klassenId die Id der Klasse//from   ww w. j  ava  2 s .c om
 * @param model das Modell
 * @return den View-Namen
 */
@RequestMapping(value = { URL.ZeugnisPath.START }, method = RequestMethod.GET)
public String chooseClass(@PathVariable(URL.Session.P_HALBJAHR_ID) Long halbjahrId,
        @PathVariable(URL.Session.P_KLASSEN_ID) Long klassenId, Model model) {
    LOG.debug("ChooseClass mit HalbjahrId {} und KlassenId {}", halbjahrId, klassenId);
    final List<Schulhalbjahr> halbjahre = zeugnisErfassungsService.getActiveSchulhalbjahre();
    if (CollectionUtils.isEmpty(halbjahre)) {
        return URL.redirect(URL.Configuration.HOME);
    }

    final List<Klasse> klassen = zeugnisErfassungsService.getActiveKlassen(halbjahre);
    Collections.sort(klassen);
    model.addAttribute("klassen", klassen);
    model.addAttribute("halbjahre", halbjahre);
    model.addAttribute("urlShowZeugnis", URL.filledURL(URL.Zeugnis.SHOW));
    model.addAttribute("urlShowBewertung", URL.filledURL(URL.Bewertungen.LIST));
    model.addAttribute("urlPrintZeugnis", URL.filledURL(URL.Zeugnis.ALL_PDFS));

    return "zeugnis/chooseClass";
}

From source file:com.canalplus.reco.interactclient.InteractRestClient.java

/**
 * /** permet d'ouvrir une session avec des parametres prdefini.
 *
 * @param audienceLevel// w w  w .  ja  v  a 2 s  .  c om
 *
 * @param icName
 * @return cmd commande
 * @throws JSONException
 */
private static Command createStartSessionCommand(Parametres parametres, String audienceLevel)
        throws JSONException {
    final CommandImpl cmd = new CommandImpl();
    cmd.setMethodIdentifier(Command.COMMAND_STARTSESSION);
    // Audience level
    cmd.setAudienceLevel(audienceLevel);
    if (parametres != null) {
        // Event parameters
        if (!CollectionUtils.isEmpty(parametres.getContext())) {
            cmd.setEventParameters(convertContext(parametres.getContext()));
        }
        // donnees du profil
        // InteractiveChannel => uaciinteractivechannelname
        if (!CollectionUtils.isEmpty(parametres.getProfil())) {
            // Audience ID
            cmd.setAudienceID(convertAudienceID(parametres.getProfil()));
            for (final Parametre parametre : parametres.getProfil()) {
                if (Consts.INTERACTIVE_CHANEL_NAME.equals(parametre.getName())) {
                    cmd.setInteractiveChannel(parametre.getValue());
                }
            }
        }
    }
    // permet de re utiliser la session avec l'id session
    // si la seesion n'existe pas, elle est cree
    cmd.setRelyOnExistingSession(false);
    cmd.setDebug(true);
    return cmd;
}

From source file:com.beyond.common.base.AbstractBaseDao.java

public int deleteByIds(List<Long> ids) {
    if (CollectionUtils.isEmpty(ids)) {
        throw new QueryException("Batch delete input is empty.");
    }// w  ww.  ja  v a 2 s.  c  o  m
    return getSqlMapClientTemplate().delete(getStatementNamespace() + ".deleteByIds", ids);
}

From source file:pe.gob.mef.gescon.web.ui.PoliticaMB.java

public void setSelectedRow(ActionEvent event) {
    try {//from w w w. j  ava 2 s  .  c o m
        if (event != null) {
            int index = Integer.parseInt((String) JSFUtils.getRequestParameter("index"));
            if (!CollectionUtils.isEmpty(this.getFilteredListaPolitica())) {
                this.setSelectedPolitica(this.getFilteredListaPolitica().get(index));
            } else {
                this.setSelectedPolitica(this.getListaPolitica().get(index));
            }
            this.setFilteredListaPolitica(new ArrayList());
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }
}

From source file:ru.anr.base.services.BaseServiceImpl.java

/**
 * Throws an exception if specified validator contains some violations,
 * joining all error messages/*from w  w w .j a  v  a 2  s  .c  om*/
 * 
 * @param violations
 *            A collection with violations
 */
protected void rejectIfNeed(Set<ConstraintViolation<?>> violations) {

    if (!CollectionUtils.isEmpty(violations)) {

        throw new ApplicationException(getAllErrorsAsString(violations));
    }
}

From source file:org.jasig.portlet.calendar.mvc.EmptyView.java

/**
 * Filters out undesired attributes from the given model. The return value can be either another
 * {@link Map}, or a single value object.
 *
 * <p>Default implementation removes {@link BindingResult} instances and entries not included in
 * the {@link #setRenderedAttributes(Set) renderedAttributes} property.
 *
 * @param model the model, as passed on to {@link #renderMergedOutputModel}
 * @return the object to be rendered/*from w ww. j  a va  2 s .  c o m*/
 */
protected Object filterModel(Map<String, Object> model) {
    Map<String, Object> result = new HashMap<String, Object>(model.size());
    Set<String> renderedAttributes = !CollectionUtils.isEmpty(this.renderedAttributes) ? this.renderedAttributes
            : model.keySet();
    for (Map.Entry<String, Object> entry : model.entrySet()) {
        if (!(entry.getValue() instanceof BindingResult) && renderedAttributes.contains(entry.getKey())) {
            result.put(entry.getKey(), entry.getValue());
        }
    }
    return result;
}

From source file:com.zuoxiaolong.blog.cache.service.UserArticleServiceManager.java

/**
 * ????/*from  www  .  java  2s  .c om*/
 *
 * @param map
 * @return
 */
public List<UserArticle> getTopRecommendArticlesByCategoryIdAndTime(Map<String, Object> map) {
    List<UserArticle> userArticles = userArticleService.getTopRecommendArticles(map);
    List<UserArticle> articles = userArticleService
            .getArticlesByCategoryId((Integer) map.get(QUERY_PARAMETER_CATEGORY_ID));
    if (CollectionUtils.isEmpty(userArticles) && !CollectionUtils.isEmpty(articles)) {
        //??DEFAULT_DAYS_BEFORE_PLUS
        map.put(QUERY_PARAMETER_TIME, Timestamp.valueOf(((Timestamp) map.get(QUERY_PARAMETER_TIME))
                .toLocalDateTime().minus(DEFAULT_DAYS_BEFORE_PLUS, ChronoUnit.DAYS)));
        userArticles = this.getTopRecommendArticlesByCategoryIdAndTime(map);
    }
    return userArticles;
}