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:uk.gov.nationalarchives.discovery.taxonomy.batch.actor.supervisor.CategorisationSupervisorActor.java

public String[] getNextDocumentsToCategorise() {
    switch (status) {
    case INITIATED:
    case ONGOING:
        status = CategorisationStatusEnum.ONGOING;
        BrowseAllDocsResponse browseAllDocs = iaViewService.browseAllDocs(this.lastElementRetrieved,
                nbOfDocsToCategoriseAtATime);

        this.lastElementRetrieved = browseAllDocs.getLastScoreDoc();

        List<String> listOfDocReferences = browseAllDocs.getListOfDocReferences();
        if (!CollectionUtils.isEmpty(listOfDocReferences)) {
            logger.debug(//from w ww  . j a  va  2 s .  c  om
                    ".getNextDocumentsToCategorise: returning new set of docs: lastScoreDoc={}, size={}, docs={}",
                    this.lastElementRetrieved, nbOfDocsToCategoriseAtATime,
                    ArrayUtils.toString(listOfDocReferences));
            return listOfDocReferences.toArray(new String[0]);
        }
        status = CategorisationStatusEnum.TERMINATED;
        return null;
    case NOT_STARTED:
    case TERMINATED:
    default:
        return null;
    }

}

From source file:be.roots.taconic.pricingguide.domain.Model.java

public List<String> getApplicationsSorted() {
    if (!CollectionUtils.isEmpty(applications)) {
        final List<String> apps = new ArrayList<>(applications);
        Collections.sort(apps);/*  w ww  .  j  a  va2  s. c  o  m*/
        return apps;
    }
    return new ArrayList<>();
}

From source file:com.sinet.gage.provision.controller.DomainController.java

/**
 * Returns all child domains domains/*from w  ww. jav a2s .co  m*/
 * 
 * @param domainId
 * @return
 */
@RequestMapping(value = "/list/{domainId}", method = RequestMethod.GET)
@ResponseBody
public Message getAllChildDomains(@PathVariable("domainId") String domainId,
        @RequestParam(value = "querystring", required = false, defaultValue = "0") String queryString,
        @RequestParam(value = "searchtext", required = false, defaultValue = "") String searchText,
        @RequestParam(value = "limit", required = false, defaultValue = "0") Integer limit,
        @RequestHeader(value = "token", required = false) String token) {
    List<DomainResponse> listOfDomainResponse = domainService.findAllChildDomains(token, domainId, queryString,
            searchText, limit);
    if (!CollectionUtils.isEmpty(listOfDomainResponse)) {
        LOGGER.debug("Found " + listOfDomainResponse.size() + " child domains " + domainId);
        return messageUtil.createMessageWithPayload(MessageConstants.DOMAINS_FOUND, listOfDomainResponse,
                Collections.singletonMap("dataModels", "domains"), DomainResponse.class);
    } else {
        LOGGER.debug("No child domains available  for parent " + domainId);
        return messageUtil.createMessage(MessageConstants.DOMAINS_NOT_FOUND, Boolean.FALSE);
    }
}

From source file:fi.vm.kapa.identification.proxy.service.MetadataService.java

public void updateMetadataCache() {
    try {/*from   w w w . j  av  a 2 s .co m*/
        approvedAuthenticationProviders = new ApprovedAuthenticationProviders(metadataServerUrl);
        CloseableHttpClient httpClient = HttpClients.createDefault();
        final String serviceProviderMetadataReqUrl = metadataServerUrl + "?type="
                + ProviderType.SERVICE_PROVIDER.toString();
        logger.debug("url to metadata server: {}", serviceProviderMetadataReqUrl);
        HttpGet getMethod = new HttpGet(serviceProviderMetadataReqUrl);
        HttpContext context = HttpClientContext.create();
        CloseableHttpResponse response = httpClient.execute(getMethod, context);

        //            HttpEntity entity = response.getEntity();
        //            String content = EntityUtils.toString(entity);
        //            logger.debug("HTTP Entity:" + content);

        int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode == HTTP_OK) {
            Gson gson = new Gson();
            List<MetadataDTO> metadata = gson.fromJson(EntityUtils.toString(response.getEntity()),
                    new TypeToken<List<MetadataDTO>>() {
                    }.getType());
            response.close();
            if (!CollectionUtils.isEmpty(metadata)) {
                logger.debug("Clearing previous metadata cache, content size {}",
                        serviceProviderMetaDataCache.size());
                Map<String, MetadataDTO> newMetaDataCache = new HashMap<>();
                metadata.forEach(data -> {
                    MetadataDTO toCache = new MetadataDTO();
                    toCache.setEntityId(data.getEntityId());
                    logger.debug("data.getDbEntityIdAuthContextUrlByAuthProviderAuthContextUrl(): "
                            + data.getEntityId());
                    toCache.setDnsName(data.getDnsName());
                    toCache.setLevelOfAssurance(data.getLevelOfAssurance());
                    toCache.setAttributeLevelOfAssurance(data.getAttributeLevelOfAssurance());
                    toCache.setAcsAddress(data.getAcsAddress());
                    toCache.setProviderType(data.getProviderType());
                    toCache.setSessionProfile(data.getSessionProfile());
                    toCache.setVtjVerificationRequired(data.isVtjVerificationRequired());
                    logger.debug("data.getAuthenticationMethods(): " + data.getAttributeLevelOfAssurance());
                    toCache.setAuthenticationProviderDTOList(
                            approvedAuthenticationProviders.getByName(data.getAttributeLevelOfAssurance()));
                    logger.debug("--adding metadata - ent ID: " + data.getEntityId() + ", dns: "
                            + data.getDnsName() + ", permitted auth methods: "
                            + data.getAttributeLevelOfAssurance() + ", type: " + data.getProviderType()
                            + ", profile: " + data.getSessionProfile());
                    newMetaDataCache.put(data.getEntityId(), toCache);
                });
                serviceProviderMetaDataCache = newMetaDataCache; // when done replace old with new
            }
        } else {
            logger.warn("Metadata server responded with HTTP {}", statusCode);
            response.close();
        }
    } catch (Exception e) {
        logger.error("Error updating proxy metadata", e);
    }
}

From source file:pe.gob.mef.gescon.service.impl.AsignacionServiceImpl.java

@Override
public List<Consulta> getNotificationsServedPanelByUser(User user) {
    List<Consulta> lista = new ArrayList<Consulta>();
    try {//from  w w w. j  ava 2s. co  m
        Mtuser mtuser = new Mtuser();
        BeanUtils.copyProperties(mtuser, user);
        AsignacionDao asignacionDao = (AsignacionDao) ServiceFinder.findBean("AsignacionDao");
        List<HashMap> consulta = asignacionDao.getNotificationsServedPanelByMtuser(mtuser);
        if (!CollectionUtils.isEmpty(consulta)) {
            for (HashMap map : consulta) {
                Consulta c = new Consulta();
                c.setIdconocimiento((BigDecimal) map.get("ID"));
                c.setCodigo((String) map.get("NUMERO"));
                c.setNombre((String) map.get("NOMBRE"));
                c.setSumilla((String) map.get("SUMILLA"));
                c.setFechaPublicacion((Date) map.get("FECHA"));
                c.setIdCategoria((BigDecimal) map.get("IDCATEGORIA"));
                c.setCategoria((String) map.get("CATEGORIA"));
                c.setIdTipoConocimiento((BigDecimal) map.get("IDTIPOCONOCIMIENTO"));
                c.setTipoConocimiento((String) map.get("TIPOCONOCIMIENTO"));
                c.setIdEstado((BigDecimal) map.get("IDESTADO"));
                c.setEstado((String) map.get("ESTADO"));
                c.setFechaAtencion((Date) map.get("FECHAATEN"));
                c.setIdAccion((BigDecimal) map.get("IDACCION"));
                c.setAccion((String) map.get("ACCION"));
                lista.add(c);
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
    return lista;
}

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

public void save(ActionEvent event) {
    try {/*w ww  .ja  va  2s . co m*/
        if (CollectionUtils.isEmpty(this.getListaMaestro())) {
            this.setListaMaestro(Collections.EMPTY_LIST);
        }
        Maestro maestro = new Maestro();
        maestro.setVnombre(this.getNombre().trim().toUpperCase());
        maestro.setVdescripcion(StringUtils.capitalize(this.getDescripcion().trim()));
        if (!errorValidation(maestro)) {
            LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB");
            User user = loginMB.getUser();
            MaestroService service = (MaestroService) ServiceFinder.findBean("MaestroService");
            maestro.setNmaestroid(service.getNextPK());
            maestro.setNactivo(BigDecimal.ONE);
            maestro.setVusuariocreacion(user.getVlogin());
            maestro.setDfechacreacion(new Date());
            service.saveOrUpdate(maestro);
            this.setListaMaestro(service.getMaestros());
            this.cleanAttributes();
            RequestContext.getCurrentInstance().execute("PF('newDialog').hide();");
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.formkiq.core.service.workflow.WorkflowServiceImpl.java

@Override
public List<FlowState> createStates(final ArchiveDTO archive, final List<String> formUUIDs) {

    List<FlowState> states = new ArrayList<>();
    states.add(new FlowState(FlowStateType.START));

    states.add(new FlowState(FlowStateType.DEFAULT, archive.getWorkflow()));

    if (!CollectionUtils.isEmpty(formUUIDs)) {

        for (String formUUID : formUUIDs) {
            states.add(new FlowState(FlowStateType.DEFAULT, archive.getForm(formUUID)));
        }//from  w  w w  . jav a 2 s .  c  o  m
    }

    states.add(new FlowState(FlowStateType.END));
    return states;
}

From source file:pe.gob.mef.gescon.service.impl.ConocimientoServiceImpl.java

@Override
public List<Consulta> getConcimientosDisponibles(HashMap filters) {
    List<Consulta> lista = new ArrayList<Consulta>();
    try {// w w w .j  a va  2s  .  com
        ConocimientoDao conocimientoDao = (ConocimientoDao) ServiceFinder.findBean("ConocimientoDao");
        List<HashMap> consulta = conocimientoDao.getConcimientosDisponibles(filters);
        if (!CollectionUtils.isEmpty(consulta)) {
            for (HashMap map : consulta) {
                Consulta c = new Consulta();
                c.setIdconocimiento((BigDecimal) map.get("ID"));
                c.setCodigo((String) map.get("NUMERO"));
                c.setNombre((String) map.get("NOMBRE"));
                c.setSumilla((String) map.get("SUMILLA"));
                c.setFechaPublicacion((Date) map.get("FECHA"));
                c.setIdCategoria((BigDecimal) map.get("IDCATEGORIA"));
                c.setCategoria((String) map.get("CATEGORIA"));
                c.setIdTipoConocimiento((BigDecimal) map.get("IDTIPOCONOCIMIENTO"));
                c.setTipoConocimiento((String) map.get("TIPOCONOCIMIENTO"));
                c.setIdEstado((BigDecimal) map.get("IDESTADO"));
                c.setEstado((String) map.get("ESTADO"));
                lista.add(c);
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
    return lista;
}

From source file:com.formkiq.core.form.service.FormValidatorServiceImpl.java

@Override
public Map<String, String> validate(final Workflow workflow) {

    Map<String, String> errors = new HashMap<>();

    if (workflow == null) {
        addGlobalError(errors, "Workflow is missing");
        return errors;
    }//www. j a  v a  2s .  c o m

    if (isEmpty(workflow.getUUID())) {
        errors.put("uuid", "UUID is required");
    }

    if (isEmpty(workflow.getName())) {
        errors.put("name", "Workflow name is required");
    }

    if (CollectionUtils.isEmpty(workflow.getSteps())) {
        errors.put("steps", "At least 1 Form is required");
    }

    if (hasText(workflow.getParentUUID())) {
        if (isEmpty(workflow.getLabel1())) {
            errors.put("label1", "Label1 is required");
        }
    }

    return errors;
}

From source file:com.deloitte.smt.service.SignalDetectionService.java

/**
 * @param signalDetection//from  ww  w. j a  v  a 2s .c  om
 */
private void saveSoc(SignalDetection signalDetection) {
    List<Soc> socs = signalDetection.getSocs();
    if (!CollectionUtils.isEmpty(socs)) {
        for (Soc soc : socs) {
            soc.setDetectionId(signalDetection.getId());
        }
        socs = socRepository.save(socs);
        for (Soc soc : socs) {
            saveHlgt(signalDetection, soc);
            saveHlt(signalDetection, soc);
            savePt(signalDetection, soc);
        }
    }
}