List of usage examples for java.lang Iterable forEach
default void forEach(Consumer<? super T> action)
From source file:co.com.carpco.altablero.hibernate.bll.ClassRoomBll.java
private void initializeCache() { CachingProvider cachingProvider = Caching.getCachingProvider(); CacheManager cacheManager = cachingProvider.getCacheManager(); MutableConfiguration<Integer, Set> config = new MutableConfiguration<Integer, Set>() .setTypes(Integer.class, Set.class).setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_DAY)) .setWriteThrough(true).setReadThrough(true) .setCacheLoaderFactory(new Factory<CacheLoader<Integer, Set>>() { @Override/*from ww w . j a v a 2 s . c om*/ public CacheLoader<Integer, Set> create() { return new CacheLoader<Integer, Set>() { @Override public Set load(Integer key) throws CacheLoaderException { final Set<ClassRoomBO> classRoomBOSet = new HashSet<>(); Set<BzClassRoom> bzClassRoomSet = classRoomDao.getClassRoomSet(key); if (bzClassRoomSet != null && bzClassRoomSet.size() > 0) { bzClassRoomSet.forEach((BzClassRoom bzClassRoom) -> classRoomBOSet .add(new ClassRoomBO(bzClassRoom))); } return classRoomBOSet; } @Override public Map<Integer, Set> loadAll(Iterable<? extends Integer> itrbl) throws CacheLoaderException { Map<Integer, Set> answer = new HashMap<>(); itrbl.forEach((Integer k) -> answer.put(k, load(k))); return answer; } }; } }).setCacheWriterFactory(new Factory<CacheWriter<Integer, Set>>() { @Override public CacheWriter<Integer, Set> create() { CacheWriter<Integer, Set> writer = new CacheWriter<Integer, Set>() { @Override public void write(Cache.Entry<? extends Integer, ? extends Set> entry) throws CacheWriterException { } @Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends Set>> clctn) throws CacheWriterException { } @Override public void delete(Object o) throws CacheWriterException { } @Override public void deleteAll(Collection<?> clctn) throws CacheWriterException { } }; return writer; } }).setStatisticsEnabled(true); cache = cacheManager.createCache("classRoomXYearCache", config); config.isReadThrough(); }
From source file:de.qaware.chronix.solr.compaction.ChronixCompactionHandler.java
private void doCompact(LazyDocumentLoader documentLoader, LazyCompactor compactor, SolrQueryResponse rsp, String tsId, String q) throws IOException, SyntaxError { Query query = depProvider.parser(q).getQuery(); Iterable<Document> docs = documentLoader.load(query, SORT); Iterable<CompactionResult> compactionResults = compactor.compact(docs); List<Document> docsToDelete = new LinkedList<>(); List<SolrInputDocument> docsToAdd = new LinkedList<>(); compactionResults.forEach(it -> { docsToDelete.addAll(it.getInputDocuments()); docsToAdd.addAll(it.getOutputDocuments()); });/*from www . j a v a 2s . c o m*/ depProvider.solrUpdateService().add(docsToAdd); depProvider.solrUpdateService().delete(docsToDelete); rsp.add("timeseries " + tsId + " oldNumDocs:", docsToDelete.size()); rsp.add("timeseries " + tsId + " newNumDocs:", docsToAdd.size()); }
From source file:co.com.carpco.altablero.hibernate.bll.UserBll.java
private void initializeCache() { CachingProvider cachingProvider = Caching.getCachingProvider(); CacheManager cacheManager = cachingProvider.getCacheManager(); MutableConfiguration<String, UserBO> config = new MutableConfiguration<String, UserBO>() .setTypes(String.class, UserBO.class) .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_DAY)).setWriteThrough(true) .setReadThrough(true).setCacheLoaderFactory(new Factory<CacheLoader<String, UserBO>>() { @Override/* w w w . ja va 2 s . c o m*/ public CacheLoader<String, UserBO> create() { return new CacheLoader<String, UserBO>() { @Override public UserBO load(String k) throws CacheLoaderException { return new UserBO(userDao.getUserByDocumentNumber(k)); } @Override public Map<String, UserBO> loadAll(Iterable<? extends String> itrbl) throws CacheLoaderException { Map<String, UserBO> answer = new HashMap<>(); itrbl.forEach((String k) -> answer.put(k, load(k))); return answer; } }; } }).setCacheWriterFactory(new Factory<CacheWriter<String, UserBO>>() { @Override public CacheWriter<String, UserBO> create() { CacheWriter<String, UserBO> writer = new CacheWriter<String, UserBO>() { @Override public void write(Cache.Entry<? extends String, ? extends UserBO> entry) throws CacheWriterException { UserBO userBo = entry.getValue(); userDao.saveUser(userBo); } @Override public void writeAll(Collection<Cache.Entry<? extends String, ? extends UserBO>> clctn) throws CacheWriterException { } @Override public void delete(Object o) throws CacheWriterException { } @Override public void deleteAll(Collection<?> clctn) throws CacheWriterException { } }; return writer; } }).setStatisticsEnabled(true); cache = cacheManager.createCache("userCache", config); config.isReadThrough(); }
From source file:edu.zipcloud.cloudstreetmarket.core.services.CommunityServiceImpl.java
private List<UserActivityDTO> transform(Iterable<Action> actions) { List<UserActivityDTO> result = Lists.newLinkedList(); actions.forEach(a -> { if (a instanceof AccountActivity) { UserActivityDTO accountActivity = new UserActivityDTO(a.getUser().getUsername(), a.getUser().getProfileImg(), ((AccountActivity) a).getType(), ((AccountActivity) a).getDate(), a.getId()); accountActivity.setSocialReport(a.getSocialEventAction()); result.add(accountActivity); } else if (a instanceof Transaction) { UserActivityDTO transaction = new UserActivityDTO((Transaction) a); transaction.setSocialReport(a.getSocialEventAction()); result.add(transaction);/*w ww. j ava2s . c om*/ } }); return result; }
From source file:org.yukung.daguerreo.domain.repository.BasicJooqRepository.java
/** * {@inheritDoc}/*from ww w. j a va 2s .c o m*/ */ @Override public void delete(Iterable<? extends E> entities) { Field<?>[] pk = pk(); if (pk != null) { List<ID> ids = new ArrayList<>(); entities.forEach(entity -> ids.add(getId(entity))); dsl.deleteFrom(table).where(in(pk, ids)).execute(); } }
From source file:com.ericsson.deviceaccess.spi.impl.genericdevice.GDPropertiesImpl.java
public GDPropertiesImpl(Iterable<GDPropertyMetadata> metadataArray, GDServiceImpl parentService) { this.parentService = parentService; // this.metadata = new HashMap<>(); this.properties = new HashMap<>(); if (metadataArray != null) { metadataArray.forEach(meta -> { properties.put(meta.getName(), new Data(meta).setToDefault()); });/*from w w w .ja va 2 s .c om*/ } }
From source file:org.yukung.daguerreo.domain.repository.BasicJooqRepository.java
/** * {@inheritDoc}/*w w w. j ava2s . com*/ */ @Override public List<E> findAll(Iterable<ID> ids) { if (ids == null) { return Collections.emptyList(); } Field<?>[] pk = pk(); List<ID> keys = new ArrayList<>(); ids.forEach(keys::add); List<E> result = new ArrayList<>(); if (pk != null) { result = dsl.selectFrom(table).where(in(pk, keys)).fetch().map(mapper()); } return result; }
From source file:io.seventyone.mongoutils.MongoConverterImplementation.java
@Override public <T> List<T> entitiesFrom(Iterable<Document> iterable, Class<T> entityClass) { if (iterable == null || entityClass == null) { return null; }//w w w . jav a 2 s .c o m List<T> entities = Lists.newArrayList(); Consumer<Document> consumer = (Document document) -> { T entity = this.entityFrom(document, entityClass); if (entity != null) { entities.add(entity); } }; iterable.forEach(consumer); return entities; }
From source file:com.bgh.myopeninvoice.jsf.jsfbeans.UsersBean.java
private void fillDualList() { final Iterable<RolesEntity> allRolesEntity = invoiceDAO.getRolesRepository().findAll(); final Collection<UserRoleEntity> assignedRolesEntity = selectedUsersEntity.getUserRolesByUserId(); List<RolesEntity> sourceList = new ArrayList<>(); List<RolesEntity> targetList = new ArrayList<>(); rolesDualListModel = new DualListModel<>(); allRolesEntity.forEach(sourceList::add); assignedRolesEntity.forEach(r -> targetList.add(r.getRolesByRoleId())); sourceList.removeAll(targetList);/*from w w w . ja va2 s. c o m*/ rolesDualListModel.setSource(sourceList); rolesDualListModel.setTarget(targetList); }
From source file:org.yukung.daguerreo.domain.repository.BasicJooqRepository.java
/** * {@inheritDoc}/*from w ww. ja va2 s .c om*/ * <p> * NOTE: Please note that the case of large number of entity to be saved which is becomes very slowly. * Because in the inside are calling the save() in the loop. * </p> */ @Override public <S extends E> Iterable<S> save(Iterable<S> entities) { if (entities == null) { return Collections.emptyList(); } // TODO if jOOQ supports auto-generated ID when the batch update, modify using it here. // See: https://github.com/jOOQ/jOOQ/issues/3327 List<S> result = new ArrayList<>(); entities.forEach(entity -> result.add(save(entity))); return result; }