Example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty

List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty

Introduction

In this page you can find the example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty.

Prototype

public static boolean isNotEmpty(final Collection<?> coll) 

Source Link

Document

Null-safe check if the specified collection is not empty.

Usage

From source file:nc.noumea.mairie.appock.core.impl.AppUserImplTest.java

private AppUser creeAppUserEnBase(boolean actif, boolean gestionnaire, List<Role> listeRole) {
    AppUser appUser = new AppUser();
    appUser.setActif(actif);//from  ww w  . j av  a  2s .c  o  m
    appUser.setEmail("test@test.com");
    appUser.setLogin("test");
    appUser.setNom("test");
    appUser.setPrenom("test");

    if (CollectionUtils.isNotEmpty(listeRole)) {
        for (Role role : listeRole) {
            appUser.addRole(role);
        }
    }

    AppUser result = appUserRepository.save(appUser);
    appockEntityManager.flush();

    return result;
}

From source file:nc.noumea.mairie.appock.viewmodel.CreateCatalogueViewModel.java

/**
 * Vrifie que le libell est unique puis lance la sauvegarde gnrique
 *//*from ww w.  j a v  a2  s .c  om*/
@Override
@Command
@NotifyChange({ "entity", "popupVisible" })
public void save() {
    if (CollectionUtils.isNotEmpty(catalogueRepository.findAllByLibelle(entity.getLibelle()))) {
        showErrorPopup("Le libell " + entity.getLibelle() + " est dj utilis");
        return;
    }
    super.save();
}

From source file:cherry.example.web.applied.ex10.AppliedEx11ControllerImpl.java

@Override
public ModelAndView start(int rownum, AppliedEx10Form form, BindingResult binding, Authentication auth,
        Locale locale, SitePreference sitePref, NativeWebRequest request) {

    AppliedEx11Form f = new AppliedEx11Form();
    f.setItem(new HashMap<Integer, AppliedEx10SubForm>());
    if (CollectionUtils.isNotEmpty(form.getItem()) && form.getItem().size() > rownum) {
        f.getItem().put(rownum, form.getItem().get(rownum));
    }/*  w  ww . j  a  v a 2s.  c  om*/

    return withViewname(viewnameOfStart).addObject(f).build();
}

From source file:cherry.example.web.applied.ex20.AppliedEx21ControllerImpl.java

@Override
public ModelAndView start(int rownum, AppliedEx20Form form, BindingResult binding, Authentication auth,
        Locale locale, SitePreference sitePref, NativeWebRequest request) {

    AppliedEx21Form f = new AppliedEx21Form();
    f.setItem(new HashMap<Integer, AppliedEx20SubForm>());
    if (CollectionUtils.isNotEmpty(form.getItem()) && form.getItem().size() > rownum) {
        f.getItem().put(rownum, form.getItem().get(rownum));
    }/*from ww w  . ja  va2 s  .co m*/

    return withViewname(viewnameOfStart).addObject(f).build();
}

From source file:com.baifendian.swordfish.execserver.job.impexp.Args.MysqlReaderArg.java

public MysqlReaderArg(MysqlReader mysqlReader) throws JSONException {
    ObjectNode connObject = JsonUtil.createObjectNode();

    if (StringUtils.isNotEmpty(mysqlReader.getQuerySql())) {
        connObject.put("querySql", mysqlReader.getQuerySql());
    }//w  ww . j av a2 s.co  m

    List<String> tableList = mysqlReader.getTable();
    if (CollectionUtils.isNotEmpty(tableList)) {
        ArrayNode tableJsonList = connObject.putArray("table");
        for (String table : tableList) {
            tableJsonList.add(table);
        }
    }

    if (StringUtils.isNotEmpty(mysqlReader.getWhere())) {
        connObject.put("where", mysqlReader.getWhere());
    }

    connection.add(connObject);

    if (StringUtils.isNotEmpty(mysqlReader.getWhere())) {
        where = mysqlReader.getWhere();
    }

    column = mysqlReader.getColumn();
}

From source file:com.baifendian.swordfish.execserver.job.storm.StormSubmitArgsUtil.java

private static List<String> sqlArgs(StormParam stormParam) {
    StormSqlParam stormSqlParam = (StormSqlParam) stormParam.getStormParam();
    List<String> args = new ArrayList<>();
    args.add(SQL);// www  .j a va 2 s  .c o  m

    args.add(stormSqlParam.getSqlFile().getRes());

    args.add(stormParam.getTopologyName());
    //add Jars
    List<ResourceInfo> jars = stormSqlParam.getJars();
    if (CollectionUtils.isNotEmpty(jars)) {
        args.add(JARS);
        args.add(StringUtils.join(jars.stream().map(p -> p.getRes()).toArray(), ","));
    }

    if (StringUtils.isNotEmpty(stormSqlParam.getArtifacts())) {
        args.add(ARTIFACTS);
        args.add(stormSqlParam.getArtifacts());
    }

    if (StringUtils.isNotEmpty(stormSqlParam.getArtifactRepositories())) {
        args.add(ARTIFACTREPOSITORIES);
        args.add(stormSqlParam.getArtifactRepositories());
    }

    return args;
}

From source file:io.cloudslang.lang.compiler.scorecompiler.ScoreCompilerImpl.java

@Override
public CompilationModellingResult compileSource(Executable executable, Set<Executable> path) {
    List<RuntimeException> exceptions = new ArrayList<>();
    Map<String, Executable> filteredDependencies = new HashMap<>();
    //we handle dependencies only if the file has imports
    boolean hasDependencies = CollectionUtils.isNotEmpty(executable.getExecutableDependencies())
            && executable.getType().equals(SlangTextualKeys.FLOW_TYPE);
    if (hasDependencies) {
        try {//from  w ww . j a  v a  2s  .c  o  m
            Validate.notEmpty(path, "Source " + executable.getName()
                    + " has dependencies but no path was given to the compiler");
            Validate.noNullElements(path, "Source " + executable.getName() + " has empty dependencies");
        } catch (RuntimeException ex) {
            exceptions.add(ex);
        }

        //we add the current executable since a dependency can require it
        List<Executable> availableExecutables = new ArrayList<>(path);
        availableExecutables.add(executable);

        try {
            //than we match the references to the actual dependencies
            filteredDependencies = dependenciesHelper.matchReferences(executable, availableExecutables);

            handleOnFailureCustomResults(executable, filteredDependencies);

            List<RuntimeException> errors = compileValidator.validateModelWithDependencies(executable,
                    filteredDependencies);
            exceptions.addAll(errors);
        } catch (RuntimeException ex) {
            exceptions.add(ex);
        }

    }

    try {
        //next we create an execution plan for the required executable
        ExecutionPlan executionPlan = compileToExecutionPlan(executable);

        //and also create execution plans for all other dependencies
        Converter<Executable, ExecutionPlan> converter = new Converter<Executable, ExecutionPlan>() {
            @Override
            public ExecutionPlan convert(Executable compiledExecutable) {
                return compileToExecutionPlan(compiledExecutable);
            }
        };
        Map<String, ExecutionPlan> dependencies = convertMap(filteredDependencies, converter);
        Collection<Executable> executables = new ArrayList<>(filteredDependencies.values());
        executables.add(executable);

        HashSet<String> subflowsUuids = new HashSet<>(dependencies.keySet());
        subflowsUuids.addAll(executable.getExternalExecutableDependencies());
        executionPlan.setSubflowsUUIDs(subflowsUuids);
        CompilationArtifact compilationArtifact = new CompilationArtifact(executionPlan, dependencies,
                executable.getInputs(), getSystemPropertiesFromExecutables(executables));
        return new CompilationModellingResult(compilationArtifact, exceptions);
    } catch (RuntimeException ex) {
        exceptions.add(ex);
    }
    return new CompilationModellingResult(null, exceptions);
}

From source file:cherry.example.web.applied.ex10.AppliedEx13ControllerImpl.java

@Override
public ModelAndView start(long id, int rownum, AppliedEx10Form form, BindingResult binding, Authentication auth,
        Locale locale, SitePreference sitePref, NativeWebRequest request) {

    AppliedEx11Form f = new AppliedEx11Form();
    f.setItem(new HashMap<Integer, AppliedEx10SubForm>());
    if (CollectionUtils.isNotEmpty(form.getItem()) && form.getItem().size() > rownum) {
        f.getItem().put(rownum, form.getItem().get(rownum));
    }/*  ww w  .ja v a  2  s  . c  om*/

    return withViewname(viewnameOfStart).addObject(f).build();
}

From source file:cherry.example.web.applied.ex20.AppliedEx23ControllerImpl.java

@Override
public ModelAndView start(long id, int rownum, AppliedEx20Form form, BindingResult binding, Authentication auth,
        Locale locale, SitePreference sitePref, NativeWebRequest request) {

    AppliedEx21Form f = new AppliedEx21Form();
    f.setItem(new HashMap<Integer, AppliedEx20SubForm>());
    if (CollectionUtils.isNotEmpty(form.getItem()) && form.getItem().size() > rownum) {
        f.getItem().put(rownum, form.getItem().get(rownum));
    }/*from ww  w. ja v a 2  s  .  c o m*/

    return withViewname(viewnameOfStart).addObject(f).build();
}

From source file:cherry.example.web.applied.ex30.AppliedEx32ControllerImpl.java

@Override
public ModelAndView start(long id, int rownum, AppliedEx31Form form, BindingResult binding, Authentication auth,
        Locale locale, SitePreference sitePref, NativeWebRequest request) {

    AppliedEx32Form f = new AppliedEx32Form();
    f.setItem(new HashMap<Integer, AppliedEx31SubForm>());
    if (CollectionUtils.isNotEmpty(form.getItem()) && form.getItem().size() > rownum) {
        f.getItem().put(rownum, form.getItem().get(rownum));
    }/*  w ww  .  j av  a  2 s.  co  m*/

    return withViewname(viewnameOfStart).addObject(f).build();
}