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:com.zuoxiaolong.niubi.job.persistent.BaseDaoImpl.java

@Override
public <T> void update(List<T> entityList) {
    Session session = getHibernateSession();
    entityList.forEach(session::update);
}

From source file:com.zuoxiaolong.niubi.job.persistent.BaseDaoImpl.java

@Override
public <T> void delete(List<T> entityList) {
    Session session = getHibernateSession();
    entityList.forEach(session::delete);
}

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

private void setCarers(Patient patient) {
    SessionWrapper sessionWrapper = getCurrentSourceSession();
    try {//from  w  w w  . j a  v  a  2 s. co m
        Query getCarers = sessionWrapper.getNamedQuery("getCarers");
        getCarers.setParameter("patientId", patient.getId());
        List carerObjects = getCarers.list();
        carerObjects.forEach(object -> {
            Object[] carerRow = (Object[]) object;
            String name = clobHelper.getStringFromExpectedClob(carerRow[0]);
            String lastName = clobHelper.getStringFromExpectedClob(carerRow[1]);
            PatientCarer carer = new PatientCarer(name, lastName);
            patient.addCarer(carer);
        });
    } catch (Exception ex) {
        logger.warn("Error while loading carers of patient " + patient.getId()
                + ". Does the specified carer table exist? " + ex.getMessage());
    } finally {
        sessionWrapper.closeSession();
    }
}

From source file:com.epam.dlab.backendapi.service.impl.LibraryServiceImpl.java

@SuppressWarnings("unchecked")
private void populateComputational(Document computationalLibs, Map<LibKey, List<LibraryStatus>> model,
        String resourceType) {//from  w w w  .j  ava  2  s  .  c om
    for (Map.Entry<String, Object> entry : computationalLibs.entrySet()) {
        if (entry.getValue() != null) {
            List<Document> docs = (List<Document>) entry.getValue();
            docs.forEach(e -> populateModel(entry.getKey(), e, model, resourceType));
        }
    }
}

From source file:com.netflix.spinnaker.orca.clouddriver.tasks.providers.aws.AmazonImageTagger.java

/**
 * Return true iff the tags on the current machine image match the desired.
 */// w w  w  .  j  a  v a2 s  .c om
@Override
public boolean areImagesTagged(Collection<Image> targetImages, Stage stage) {
    Collection<MatchedImage> matchedImages = findImages(
            targetImages.stream().map(targetImage -> targetImage.imageName).collect(Collectors.toList()),
            stage);

    AtomicBoolean isUpserted = new AtomicBoolean(true);
    for (Image targetImage : targetImages) {
        targetImage.regions.forEach(region -> {
            MatchedImage matchedImage = matchedImages.stream()
                    .filter(m -> m.imageName.equals(targetImage.imageName)).findFirst().orElse(null);

            if (matchedImage == null) {
                isUpserted.set(false);
                return;
            }

            List<String> imagesForRegion = matchedImage.amis.get(region);
            imagesForRegion.forEach(image -> {
                Map<String, String> allImageTags = matchedImage.tagsByImageId.get(image);
                targetImage.tags.entrySet().forEach(entry -> {
                    // assert tag equality
                    isUpserted
                            .set(isUpserted.get() && entry.getValue().equals(allImageTags.get(entry.getKey())));
                });
            });
        });
    }

    return isUpserted.get();
}

From source file:com.esri.geoportal.harvester.waf.WafFolder.java

/**
 * Reads content of the folder./*  w w w .  j a v  a 2  s . co  m*/
 * @param httpClient HTTP client
 * @return content
 * @throws IOException if error reading content
 * @throws URISyntaxException if invalid URL
 */
public WafFolderContent readContent(BotsHttpClient httpClient) throws IOException, URISyntaxException {
    HtmlUrlScrapper scrapper = new HtmlUrlScrapper(httpClient, creds);
    List<URL> urls = scrapper.scrap(folderUrl);

    List<WafFile> files = new ArrayList<>();
    List<WafFolder> subFolders = new ArrayList<>();

    urls.forEach(u -> {
        if (u.toExternalForm().endsWith("/") || !cutOff(u.toExternalForm(), "/").contains(".")) {
            subFolders.add(new WafFolder(broker, u, matchPattern, creds));
        } else if (matchUrl(u, matchPattern)) {
            files.add(new WafFile(broker, u, creds));
        }
    });

    return new WafFolderContent(this, subFolders, files);
}

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

private void setNhsNumbers(Individual individual) {
    SessionWrapper sessionWrapper = createSourceSession();
    try {//from www.  j  av  a2s.  c  om
        Query getNhsNumbers = sessionWrapper.getNamedQuery("getNhsNumbers");
        getNhsNumbers.setParameter("patientId", individual.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)) {
                individual.addNhsNumber(number);
            }
        });
    } catch (Exception ex) {
        logger.warn("Error while loading NHS Numbers of patient " + individual.getId()
                + ". Does the specified table exist? " + ex.getMessage());
    } finally {
        sessionWrapper.closeSession();
    }
}

From source file:ch.sdi.core.impl.data.Person.java

public List<Long> getLongListProperty(String aKey) {
    List<Long> result = new ArrayList<Long>();
    List<?> list = getProperty(aKey, List.class);
    if (list != null) {
        list.forEach(item -> result.add((Long) item));
    } // if list != null
    return result;
}

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

/**
 * Fetches the addresses of the patient from the DB and assigns them to the given patient.
 *
 * @param individual/*from  ww  w .  j a va  2  s .  c  om*/
 */
private void setAddresses(Individual individual) {
    SessionWrapper sessionWrapper = createSourceSession();
    try {
        Query getAddresses = sessionWrapper.getNamedQuery("getAddresses");
        getAddresses.setParameter("patientId", individual.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);
            individual.addAddress(address);
        });
    } catch (Exception ex) {
        logger.warn("Error while loading addresses of patient " + individual.getId()
                + ". Does the specified address table exist? " + ex.getMessage());
    } finally {
        sessionWrapper.closeSession();
    }
}

From source file:de.hska.ld.recommendation.service.impl.DocumentRecommInfoServiceImpl.java

@Override
//@Transactional//from w ww . j  a va 2s  . com
public List<Document> addMissingRecommendationUpdatesDocuments(String accessToken) {
    List<Document> documentWithMissingRecommendationsList = repository
            .findAllDocumentsWithoutDocumentRecommInfo();
    documentWithMissingRecommendationsList.forEach(dwmr -> {
        DocumentRecommInfo documentRecommInfo = findByDocument(dwmr);
        if (documentRecommInfo == null) {
            // send current tags of the document to the SSS
            try {
                sssClient.performInitialSSSTagLoad(dwmr.getId(), accessToken);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    return documentWithMissingRecommendationsList;
}