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.sinet.gage.provision.service.impl.DomainServiceImpl.java

/**
 * /* ww  w  . j  a va 2  s.  c  om*/
 * @param token
 * @param catalogIds
 * @return
 */
private List<Securehash> buildLTILists(String token, List<String> catalogIds) {
    List<Securehash> listOfSecureHashs = null;
    if (!CollectionUtils.isEmpty(catalogIds)) {
        listOfSecureHashs = new ArrayList<>();
        for (String catalogId : catalogIds) {
            logger.debug(" Looking up LTI code for domain " + catalogId);
            Customization customization = getDomainData(token, Long.parseLong(catalogId));
            if (customization != null && !CollectionUtils.isEmpty(customization.getSecurehash())) {
                logger.debug(" Found LTI code for domain " + catalogId);
                listOfSecureHashs.addAll(customization.getSecurehash());
            }
        }
    }
    return listOfSecureHashs;
}

From source file:com.alibaba.otter.shared.arbitrate.impl.setl.zookeeper.termin.NormalTerminProcess.java

private boolean doProcess(TerminEventData data, boolean retry) {
    Long pipelineId = data.getPipelineId();
    Long processId = data.getProcessId();

    List<String> currentStages = null;
    try {//  ww w. j  a  va  2s  .c om
        currentStages = zookeeper.getChildren(StagePathUtils.getProcess(pipelineId, processId));
        Collections.sort(currentStages, new StageComparator());
    } catch (ZkNoNodeException e) {
        // ignore?
        return false;
    } catch (ZkException e) {
        throw new ArbitrateException("Termin_process", e);
    }

    // ?S.E.T.L
    // s
    if (currentStages == null || currentStages.contains(ArbitrateConstants.NODE_SELECTED)) {
        try {
            boolean successed = zookeeper.delete(StagePathUtils.getSelectStage(pipelineId, processId));
            if (!successed) {
                processDeleteFailed();
            }
        } catch (ZkException e) {
            throw new ArbitrateException("Termin_process", e);
        }
    }

    // e
    if (currentStages == null || currentStages.contains(ArbitrateConstants.NODE_EXTRACTED)) {
        try {
            boolean successed = zookeeper.delete(StagePathUtils.getExtractStage(pipelineId, processId));
            if (!successed) {
                processDeleteFailed();
            }
        } catch (ZkException e) {
            throw new ArbitrateException("Termin_process", e);
        }
    }

    // t
    if (currentStages == null || currentStages.contains(ArbitrateConstants.NODE_TRANSFORMED)) {
        try {
            boolean successed = zookeeper.delete(StagePathUtils.getTransformStage(pipelineId, processId));
            if (!successed) {
                processDeleteFailed();
            }
        } catch (ZkException e) {
            throw new ArbitrateException("Termin_process", e);
        }
    }
    // l
    // try {
    // zookeeper.delete(StagePathUtils.getLoadStage(pipelineId, processId), -1, new VoidCallback() {
    //
    // public void processResult(int rc, String path, Object ctx) {
    // logger.debug("delete {} successful. ", path);
    // }
    // }, null);
    // } catch (NoNodeException e) {
    // // ignore,?
    // } catch (KeeperException e) {
    // throw new ArbitrateException("Termin_process", e);
    // } catch (InterruptedException e) {
    // // ignore
    // }

    // transform?s/enormalrollback/shutdown?
    // ?????
    return processDelete(data, CollectionUtils.isEmpty(currentStages), retry);
}

From source file:org.agatom.springatom.data.hades.model.appointment.NAppointment.java

public NAppointment assignTasks() {
    if (!CollectionUtils.isEmpty(this.tasks)) {
        for (final NAppointmentTask task : this.tasks) {
            task.setAppointment(this);
        }/* w w  w  .j  av a2 s  .  c  o m*/
    }
    return this;
}

From source file:org.pgptool.gui.encryption.implpgp.KeyRingServicePgpImpl.java

@Override
public List<Key> findMatchingKeys(Set<String> keysIds) {
    Preconditions.checkArgument(!CollectionUtils.isEmpty(keysIds));

    List<Key> ret = new ArrayList<>(keysIds.size());
    List<Key> allKeys = readKeys();

    for (String neededKeyId : keysIds) {
        log.debug("Trying to find key by id: " + neededKeyId);
        for (Iterator<Key> iter = allKeys.iterator(); iter.hasNext();) {
            Key existingKey = iter.next();
            String user = existingKey.getKeyInfo().getUser();
            if (existingKey.getKeyData().isHasAlternativeId(neededKeyId)) {
                log.debug("Found matching key: " + user);
                ret.add(existingKey);//from  w  w  w.  java2  s. c  om
                break;
            }
        }
    }
    return ret;
}

From source file:com.capitalone.dashboard.collector.TeamDataClient.java

/**
 * Validates current entry and removes new entry if an older item exists in
 * the repo//from  ww  w.j a v a  2s  . c  o m
 *
 * @param localId
 *            local repository item ID (not the precise mongoID)
 */
protected Boolean removeExistingEntity(String localId) {
    if (StringUtils.isEmpty(localId))
        return false;
    List<ScopeOwnerCollectorItem> teamIdList = teamRepo.getTeamIdById(localId);
    if (CollectionUtils.isEmpty(teamIdList))
        return false;
    ScopeOwnerCollectorItem socItem = teamIdList.get(0);
    if (!localId.equalsIgnoreCase(socItem.getTeamId()))
        return false;

    this.setOldTeamId(socItem.getId());
    this.setOldTeamEnabledState(socItem.isEnabled());
    teamRepo.delete(socItem.getId());
    return true;

}

From source file:com.alibaba.otter.node.etl.extract.extractor.DatabaseExtractor.java

@Override
public void extract(DbBatch dbBatch) throws ExtractException {
    Assert.notNull(dbBatch);//  w ww  .  ja v  a 2 s  .c o m
    Assert.notNull(dbBatch.getRowBatch());
    // ??
    Pipeline pipeline = getPipeline(dbBatch.getRowBatch().getIdentity().getPipelineId());
    boolean mustDb = pipeline.getParameters().getSyncConsistency().isMedia();
    boolean isRow = pipeline.getParameters().getSyncMode().isRow();// ???
    // ??
    adjustPoolSize(pipeline.getParameters().getExtractPoolSize()); // Extractor?
    ExecutorCompletionService completionService = new ExecutorCompletionService(executor);

    // ???
    ExtractException exception = null;
    // ??
    List<DataItem> items = new ArrayList<DataItem>();
    List<Future> futures = new ArrayList<Future>();
    List<EventData> eventDatas = dbBatch.getRowBatch().getDatas();
    for (EventData eventData : eventDatas) {
        if (eventData.getEventType().isDdl()) {
            continue;
        }

        DataItem item = new DataItem(eventData);
        // row??????row???
        boolean flag = mustDb
                || (eventData.getSyncConsistency() != null && eventData.getSyncConsistency().isMedia());

        // ?case, oracle erosa??????
        if (!flag && CollectionUtils.isEmpty(eventData.getUpdatedColumns())) {
            DataMedia dataMedia = ConfigHelper.findDataMedia(pipeline, eventData.getTableId());
            if (dataMedia.getSource().getType().isOracle()) {
                flag |= true;
                eventData.setRemedy(true);// ???erosa?????
            }
        }

        if (isRow && !flag) {
            // ?????
            // view??
            flag = checkNeedDbForRowMode(pipeline, eventData);
        }

        if (flag && (eventData.getEventType().isInsert() || eventData.getEventType().isUpdate())) {// ????
            Future future = completionService.submit(new DatabaseExtractWorker(pipeline, item), null); // ??
            if (future.isDone()) {
                // ?CallerRun????
                try {
                    future.get();
                } catch (InterruptedException e) {
                    cancel(futures);// ??
                    throw new ExtractException(e);
                } catch (ExecutionException e) {
                    cancel(futures); // ??
                    throw new ExtractException(e);
                }
            }

            futures.add(future);// 
        }

        items.add(item);// ?
    }

    // ?
    int index = 0;
    while (index < futures.size()) { // ??
        try {
            Future future = completionService.take();// ?
            future.get();
        } catch (InterruptedException e) {
            exception = new ExtractException(e);
            break;// future
        } catch (ExecutionException e) {
            exception = new ExtractException(e);
            break;// future
        }

        index++;
    }

    if (index < futures.size()) {
        // ???cancel?????
        cancel(futures);
        throw exception;
    } else {
        // ?, ????
        for (int i = 0; i < items.size(); i++) {
            DataItem item = items.get(i);
            if (item.filter) { // ???????
                eventDatas.remove(item.getEventData());
            }
        }
    }

}

From source file:org.agatom.springatom.cmp.wizards.data.result.WizardResult.java

public WizardResult setBindingErrors(final Set<ObjectError> bindingErrors) {
    if (CollectionUtils.isEmpty(bindingErrors)) {
        return this;
    }//from   w  ww  .java 2 s. c  o  m
    if (this.bindingErrors == null) {
        this.bindingErrors = bindingErrors;
    } else {
        this.bindingErrors.addAll(bindingErrors);
    }
    return this;
}

From source file:com.iana.dver.dao.impl.DverDetailsDaoImpl.java

@Override
public List<DverNotif> findAllFailNotifications(final int start, final int end) throws DataAccessException {
    List failNotifs = getHibernateTemplate().executeFind(new HibernateCallback<List<DverNotif>>() {
        @Override//  w w w . ja v a2s. com
        public List<DverNotif> doInHibernate(Session session) throws HibernateException, SQLException {
            logger.info("find All Failed Notifications ....");
            org.hibernate.Query q = session.createQuery(FIND_FAIL_NOTIFICATIONS);
            q.setFirstResult(start);
            q.setMaxResults(end);
            return q.list();
        }
    });

    return (!CollectionUtils.isEmpty(failNotifs)) ? failNotifs : new ArrayList<DverNotif>();

}

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

public void save(ActionEvent event) {
    try {/* w w w  .j  av a2 s  .c  o  m*/
        if (CollectionUtils.isEmpty(this.getListaRango())) {
            this.setListaRango(Collections.EMPTY_LIST);
        }
        Rango rango = new Rango();
        rango.setVnombre(this.getNombre());
        rango.setVdescripcion(this.getDescripcion());
        if (!errorValidation(rango)) {
            LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB");
            User user = loginMB.getUser();
            RangoService service = (RangoService) ServiceFinder.findBean("RangoService");
            rango.setNrangoid(service.getNextPK());
            rango.setVnombre(StringUtils.upperCase(this.getNombre().trim()));
            rango.setVdescripcion(StringUtils.capitalize(this.getDescripcion().trim()));
            rango.setNactivo(BigDecimal.ONE);
            rango.setNtiponormaid(this.getSelectedTipoNorma());
            rango.setDfechacreacion(new Date());
            rango.setVusuariocreacion(user.getVlogin());
            service.saveOrUpdate(rango);
            this.setListaRango(service.getRangos());
            this.cleanAttributes();
            RequestContext.getCurrentInstance().execute("PF('newDialog').hide();");
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.alibaba.otter.shared.arbitrate.impl.ArbitrateViewServiceImpl.java

public List<ProcessStat> listProcesses(Long channelId, Long pipelineId) {
    List<ProcessStat> processStats = new ArrayList<ProcessStat>();
    String processRoot = ManagePathUtils.getProcessRoot(channelId, pipelineId);
    IZkConnection connection = zookeeper.getConnection();
    // zkclient?stat??zk
    ZooKeeper orginZk = ((ZooKeeperx) connection).getZookeeper();

    // ?process/*from   w  ww  . j a  va2 s.  c  o  m*/
    List<String> processNodes = zookeeper.getChildren(processRoot);
    List<Long> processIds = new ArrayList<Long>();
    for (String processNode : processNodes) {
        processIds.add(ManagePathUtils.getProcessId(processNode));
    }

    Collections.sort(processIds);

    for (int i = 0; i < processIds.size(); i++) {
        Long processId = processIds.get(i);
        // ?process??
        ProcessStat processStat = new ProcessStat();
        processStat.setPipelineId(pipelineId);
        processStat.setProcessId(processId);

        List<StageStat> stageStats = new ArrayList<StageStat>();
        processStat.setStageStats(stageStats);
        try {
            String processPath = ManagePathUtils.getProcess(channelId, pipelineId, processId);
            Stat zkProcessStat = new Stat();
            List<String> stages = orginZk.getChildren(processPath, false, zkProcessStat);
            Collections.sort(stages, new StageComparator());

            StageStat prev = null;
            for (String stage : stages) {// ?processstage
                String stagePath = processPath + "/" + stage;
                Stat zkStat = new Stat();

                StageStat stageStat = new StageStat();
                stageStat.setPipelineId(pipelineId);
                stageStat.setProcessId(processId);

                byte[] bytes = orginZk.getData(stagePath, false, zkStat);
                if (bytes != null && bytes.length > 0) {
                    // ?zookeeperdata?managernodePipeKey?????'@'?
                    String json = StringUtils.remove(new String(bytes, "UTF-8"), '@');
                    EtlEventData data = JsonUtils.unmarshalFromString(json, EtlEventData.class);
                    stageStat.setNumber(data.getNumber());
                    stageStat.setSize(data.getSize());

                    Map exts = new HashMap();
                    if (!CollectionUtils.isEmpty(data.getExts())) {
                        exts.putAll(data.getExts());
                    }
                    exts.put("currNid", data.getCurrNid());
                    exts.put("nextNid", data.getNextNid());
                    exts.put("desc", data.getDesc());
                    stageStat.setExts(exts);
                }
                if (prev != null) {// start?
                    stageStat.setStartTime(prev.getEndTime());
                } else {
                    stageStat.setStartTime(zkProcessStat.getMtime()); // process?,select
                                                                      // await??USED?
                }
                stageStat.setEndTime(zkStat.getMtime());
                if (ArbitrateConstants.NODE_SELECTED.equals(stage)) {
                    stageStat.setStage(StageType.SELECT);
                } else if (ArbitrateConstants.NODE_EXTRACTED.equals(stage)) {
                    stageStat.setStage(StageType.EXTRACT);
                } else if (ArbitrateConstants.NODE_TRANSFORMED.equals(stage)) {
                    stageStat.setStage(StageType.TRANSFORM);
                    // } else if
                    // (ArbitrateConstants.NODE_LOADED.equals(stage)) {
                    // stageStat.setStage(StageType.LOAD);
                }

                prev = stageStat;
                stageStats.add(stageStat);
            }

            // ??
            StageStat currentStageStat = new StageStat();
            currentStageStat.setPipelineId(pipelineId);
            currentStageStat.setProcessId(processId);
            if (prev == null) {
                byte[] bytes = orginZk.getData(processPath, false, zkProcessStat);
                if (bytes == null || bytes.length == 0) {
                    continue; // 
                }

                ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
                if (nodeData.getStatus().isUnUsed()) {// process,
                    continue; // process
                } else {
                    currentStageStat.setStage(StageType.SELECT);// select?
                    currentStageStat.setStartTime(zkProcessStat.getMtime());
                }
            } else {
                // ?stage
                StageType stage = prev.getStage();
                if (stage.isSelect()) {
                    currentStageStat.setStage(StageType.EXTRACT);
                } else if (stage.isExtract()) {
                    currentStageStat.setStage(StageType.TRANSFORM);
                } else if (stage.isTransform()) {
                    currentStageStat.setStage(StageType.LOAD);
                } else if (stage.isLoad()) {// ??
                    continue;
                }

                currentStageStat.setStartTime(prev.getEndTime());// ?
            }

            if (currentStageStat.getStage().isLoad()) {// loadprocess
                if (i == 0) {
                    stageStats.add(currentStageStat);
                }
            } else {
                stageStats.add(currentStageStat);// 
            }

        } catch (NoNodeException e) {
            // ignore
        } catch (KeeperException e) {
            throw new ArbitrateException(e);
        } catch (InterruptedException e) {
            // ignore
        } catch (UnsupportedEncodingException e) {
            // ignore
        }

        processStats.add(processStat);
    }

    return processStats;
}