Example usage for java.util List forEach

List of usage examples for java.util List forEach

Introduction

In this page you can find the example usage for java.util List forEach.

Prototype

default void forEach(Consumer<? super T> action) 

Source Link

Document

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

Usage

From source file:nc.noumea.mairie.appock.services.impl.PanierServiceImpl.java

@Override
public Panier videPanier(Panier panier) {
    // On passe par une liste intrmdiaire pour ne pas avoir de ConcurrentModificationException
    List<ArticlePanier> listeArticlePanier = new ArrayList<>();
    listeArticlePanier.addAll(panier.getListeArticlePanier());
    listeArticlePanier.forEach(panier::removeArticlePanier);
    panierRepository.save(panier);/*from  w  ww.  j  av a  2 s  . com*/
    return panier;
}

From source file:uk.ac.kcl.iop.brc.core.pipeline.dncpipeline.data.PatientDao.java

private void setNhsNumbers(Patient patient) {
    SessionWrapper sessionWrapper = getCurrentSourceSession();
    try {//from  w  w w  . j  a  v a 2  s.  c  o  m
        Query getNhsNumbers = sessionWrapper.getNamedQuery("getNhsNumbers");
        getNhsNumbers.setParameter("patientId", patient.getId());
        List nhsNumbers = getNhsNumbers.list();
        nhsNumbers.forEach(object -> {
            String number;
            if (object instanceof String) {
                number = (String) object;
            } else {
                Object[] nhsNumberRow = (Object[]) object;
                number = clobHelper.getStringFromExpectedClob(nhsNumberRow[0]);
            }
            if (!StringUtils.isBlank(number)) {
                patient.addNhsNumber(number);
            }
        });
    } catch (Exception ex) {
        logger.warn("Error while loading NHS Numbers of patient " + patient.getId()
                + ". Does the specified table exist? " + ex.getMessage());
    } finally {
        sessionWrapper.closeSession();
    }
}

From source file:net.bcsw.sdnwlan.IngressVlans.java

/**
 * Create new ingress VLAN object/*from w w  w  .j  a va 2s .  co m*/
 *
 *   The input VLAN list is arranged with outermost tag first
 *
 * @param vids List of VLANS
 */
public IngressVlans(List<VlanId> vids) {
    // TODO: Range check on VLAN would be good here...
    if (vids != null) {
        vids.forEach(vlan -> {
            if (!vlan.equals(VlanId.NONE)) {
                vlanList.add(vlan);
            }
        });
    }
}

From source file:com.cognifide.qa.bb.aem.core.component.dialog.ConfigDialogImpl.java

private void setFields(List<FieldConfig> value) {
    WebElement parent = determineParentScope();
    value.forEach(fieldConfig -> dialogConfigurer
            .getDialogField(parent, fieldConfig.getLabel(), fieldConfig.getType())
            .setValue(fieldConfig.getValue()));
}

From source file:cognition.pipeline.data.PatientDao.java

private void setDateOfBirths(Individual individual) {
    SessionWrapper sessionWrapper = createSourceSession();
    try {//  ww w .  ja v a  2s  .com
        Query getDateOfBirths = sessionWrapper.getNamedQuery("getDateOfBirths");
        getDateOfBirths.setParameter("patientId", individual.getId());
        List dateOfBirths = getDateOfBirths.list();
        dateOfBirths.forEach(object -> {
            Date dateOfBirth;
            if (object instanceof Date) {
                dateOfBirth = (Date) object;
            } else {
                Object[] dateOfBirthRow = (Object[]) object;
                dateOfBirth = (Date) dateOfBirthRow[0];
            }
            if (dateOfBirth != null) {
                individual.addDateOfBirth(dateOfBirth);
            }
        });
    } catch (Exception ex) {
        logger.warn("Error while loading date of births of patient " + individual.getId()
                + ". Does the specified table exist? " + ex.getMessage());
    } finally {
        sessionWrapper.closeSession();
    }
}

From source file:com.bouncestorage.swiftproxy.v1.ObjectResource.java

private static GetOptions addRanges(GetOptions options, List<Pair<Long, Long>> ranges) {
    ranges.forEach(rangeSpec -> {
        if (rangeSpec.getFirst() == null) {
            if (rangeSpec.getSecond() == 0) {
                throw new ClientErrorException(Response.Status.REQUESTED_RANGE_NOT_SATISFIABLE);
            }/*from   w  w  w  . jav a  2s .c o m*/
            options.tail(rangeSpec.getSecond());
        } else if (rangeSpec.getSecond() == null) {
            options.startAt(rangeSpec.getFirst());
        } else {
            options.range(rangeSpec.getFirst(), rangeSpec.getSecond());
        }
    });
    return options;
}

From source file:fi.vm.kapa.identification.proxy.metadata.MetadataClient.java

public Map<String, ServiceProvider> getServiceProviders() throws IOException {
    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);
    final Map<String, ServiceProvider> serviceProviders = new HashMap<>();
    List<MetadataDTO> serviceProvidersAsMetadataDTOs = getMetadataDTOs(httpClient, getMethod);
    if (!CollectionUtils.isEmpty(serviceProvidersAsMetadataDTOs)) {
        serviceProvidersAsMetadataDTOs.forEach(data -> {
            logger.debug(/*from  w ww  .j a va 2 s.c  om*/
                    "data.getDbEntityIdAuthContextUrlByAuthProviderAuthContextUrl(): " + data.getEntityId());
            logger.debug("--adding serviceProvider - ent ID: " + data.getEntityId() + ", dns: "
                    + data.getDnsName() + ", permitted auth methods: " + data.getAttributeLevelOfAssurance()
                    + ", type: " + data.getProviderType() + ", profile: " + data.getSessionProfile());
            ServiceProvider serviceProvider = new ServiceProvider(data.getEntityId(),
                    data.getLevelOfAssurance(), data.getAttributeLevelOfAssurance(), data.getSessionProfile(),
                    data.isVtjVerificationRequired());
            serviceProviders.put(data.getEntityId(), serviceProvider);
        });
    }
    return serviceProviders;
}

From source file:app.service.CollectionService.java

public List<Collection> getLatestCollections(String uid, int page, int size) {
    Page<Collection> colPage = mColRepo.findAll(new PageRequest(page, size, mLatestSort));
    List<Collection> colList = getFromPage(colPage, true);
    colList.forEach(collection -> fillCollection(collection, uid));
    return colList;
}

From source file:uk.ac.kcl.iop.brc.core.pipeline.dncpipeline.data.PatientDao.java

/**
 * Fetches the addresses of the patient from the DB and assigns them to the given patient.
 *
 * @param patient/*from w w w .  ja  v  a 2s  .com*/
 */
private void setAddresses(Patient patient) {
    SessionWrapper sessionWrapper = getCurrentSourceSession();
    try {
        Query getAddresses = sessionWrapper.getNamedQuery("getAddresses");
        getAddresses.setParameter("patientId", patient.getId());
        List addressObjects = getAddresses.list();
        addressObjects.forEach(object -> {
            Object[] addressRow = (Object[]) object;
            String addressStr = clobHelper.getStringFromExpectedClob(addressRow[0]);
            String postCode = "";
            if (addressRow.length > 1) {
                postCode = clobHelper.getStringFromExpectedClob(addressRow[1]);
            }
            PatientAddress address = PatientAddress.newAddressPostCode(addressStr, postCode);
            patient.addAddress(address);
        });
    } catch (Exception ex) {
        logger.warn("Error while loading addresses of patient " + patient.getId()
                + ". Does the specified address table exist? " + ex.getMessage());
    } finally {
        sessionWrapper.closeSession();
    }
}

From source file:ijfx.service.ui.DefaultHintService.java

@Override
public void displayHints(Class clazz, boolean force) {
    logger.info("Trying to hint widget " + clazz.getSimpleName());
    try {//  w w w.  j  a v a 2  s.  c  o  m
        String url = clazz.getSimpleName() + "Hints.json";

        if (clazz.getResource(url) == null)
            return;

        List<DefaultHint> hintList = jsonToHintList(TextFileUtils.readFileFromJar(url, clazz));
        hintList.forEach(hint -> hint.setId(clazz.getSimpleName() + hint.getTarget()));
        logger.info(String.format("%s had %d hints loaded", clazz.getSimpleName(), hintList.size()));
        displayHints(hintList, force);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    }

}