List of usage examples for java.lang Iterable spliterator
default Spliterator<T> spliterator()
From source file:org.talend.dataprep.preparation.service.PreparationService.java
/** * List all preparations details in the given folder. * * @param folderId the folder where to look for preparations. * @return the list of preparations details for the given folder path. *///from w ww . jav a 2 s. com private Stream<Preparation> searchByFolder(String folderId) { LOGGER.debug("looking for preparations in {}", folderId); final Iterable<FolderEntry> entries = folderRepository.entries(folderId, PREPARATION); return StreamSupport.stream(entries.spliterator(), false) // .map(e -> preparationRepository.get(e.getContentId(), Preparation.class)); }
From source file:org.obiba.mica.dataset.service.CollectedDatasetService.java
public List<DatasetVariable> processVariablesForStudyDataset(StudyDataset dataset, Iterable<DatasetVariable> variables) { if (!dataset.hasStudyTable()) { return Lists.newArrayList(variables); }/* www . j av a 2 s . co m*/ StudyTable studyTable = dataset.getStudyTable(); BaseStudy study = studyService.findStudy(dataset.getStudyTable().getStudyId()); Population population = study.findPopulation(studyTable.getPopulationId()); if (population == null) { return Lists.newArrayList(variables); } int populationWeight = population.getWeight(); DataCollectionEvent dataCollectionEvent = population .findDataCollectionEvent(studyTable.getDataCollectionEventId()); if (dataCollectionEvent == null) { return Lists.newArrayList(variables); } int dataCollectionEventWeight = dataCollectionEvent.getWeight(); return StreamSupport.stream(variables.spliterator(), false).map(datasetVariable -> { datasetVariable.setPopulationWeight(populationWeight); datasetVariable.setDataCollectionEventWeight(dataCollectionEventWeight); return datasetVariable; }).collect(toList()); }
From source file:com.evolveum.midpoint.gui.api.util.WebComponentUtil.java
public static boolean isAllNulls(Iterable<?> array) { return StreamSupport.stream(array.spliterator(), true).allMatch(o -> o == null); }
From source file:io.apiman.manager.api.rest.impl.OrganizationResourceImpl.java
@Override public void deleteApi(@PathParam("organizationId") String organizationId, @PathParam("apiId") String apiId) throws OrganizationNotFoundException, NotAuthorizedException, EntityStillActiveException { try {/*from w w w .j a v a2 s . co m*/ if (!securityContext.hasPermission(PermissionType.apiAdmin, organizationId)) throw ExceptionFactory.notAuthorizedException(); storage.beginTx(); ApiBean api = storage.getApi(organizationId, apiId); if (api == null) { throw ExceptionFactory.apiNotFoundException(apiId); } Iterator<ApiVersionBean> apiVersions = storage.getAllApiVersions(organizationId, apiId); Iterable<ApiVersionBean> iterable = () -> apiVersions; List<ApiVersionBean> registeredElems = StreamSupport.stream(iterable.spliterator(), false) .filter(clientVersion -> clientVersion.getStatus() == ApiStatus.Published).limit(5) .collect(toList()); if (!registeredElems.isEmpty()) { throw ExceptionFactory.entityStillActiveExceptionApiVersions(registeredElems); } storage.deleteApi(api); storage.commitTx(); log.debug("Deleted API: " + api.getName()); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
From source file:io.apiman.manager.api.rest.impl.OrganizationResourceImpl.java
@Override public void deleteClient(@PathParam("organizationId") String organizationId, @PathParam("clientId") String clientId) throws OrganizationNotFoundException, NotAuthorizedException, EntityStillActiveException { try {// w w w . jav a 2 s . co m if (!securityContext.hasPermission(PermissionType.clientAdmin, organizationId)) throw ExceptionFactory.notAuthorizedException(); storage.beginTx(); ClientBean client = storage.getClient(organizationId, clientId); if (client == null) { throw ExceptionFactory.clientNotFoundException(clientId); } Iterator<ClientVersionBean> clientVersions = storage.getAllClientVersions(organizationId, clientId); Iterable<ClientVersionBean> iterable = () -> clientVersions; List<ClientVersionBean> registeredElems = StreamSupport.stream(iterable.spliterator(), false) .filter(clientVersion -> clientVersion.getStatus() == ClientStatus.Registered).limit(5) .collect(toList()); if (!registeredElems.isEmpty()) { throw ExceptionFactory.entityStillActiveExceptionClientVersions(registeredElems); } storage.deleteClient(client); storage.commitTx(); log.debug("Deleted ClientApp: " + client.getName()); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
From source file:netention.core.Core.java
public Stream<Vertex> vertexNewestStream(double secondsAgo, int max) { long now = System.currentTimeMillis(); long then = (long) (now - (secondsAgo * 1000.0)); Iterable<Vertex> v = graph.query().interval("modifiedAt", then, now).limit(max).vertices(); return stream(v.spliterator(), false); }
From source file:org.apache.nifi.minifi.c2.cache.s3.S3CacheFileInfoImpl.java
@Override public Stream<WriteableConfiguration> getCachedConfigurations() throws IOException { Iterable<S3ObjectSummary> objectSummaries = S3Objects.withPrefix(s3, bucket, prefix); Stream<S3ObjectSummary> objectStream = StreamSupport.stream(objectSummaries.spliterator(), false); return objectStream.map(p -> { Integer version = getVersionIfMatch(p.getKey()); if (version == null) { return null; }//from w w w . jav a 2 s.c o m return new Pair<>(version, p); }).filter(Objects::nonNull) .sorted(Comparator.comparing(pair -> ((Pair<Integer, S3ObjectSummary>) pair).getFirst()).reversed()) .map(pair -> new S3WritableConfiguration(s3, pair.getSecond(), Integer.toString(pair.getFirst()))); }
From source file:org.cryptomator.frontend.webdav.mount.WindowsDriveLetters.java
public Set<Character> getOccupiedDriveLetters() { if (!SystemUtils.IS_OS_WINDOWS) { throw new UnsupportedOperationException("This method is only defined for Windows file systems"); }/*from w w w .ja v a 2s .c om*/ Iterable<Path> rootDirs = FileSystems.getDefault().getRootDirectories(); return StreamSupport.stream(rootDirs.spliterator(), false).map(Path::toString).map(CharUtils::toChar) .map(Character::toUpperCase).collect(toSet()); }
From source file:org.dllearner.reasoning.SPARQLReasoner.java
private String datatypeSparqlFilter(Iterable<OWLDatatype> dts) { return Joiner.on(" || ").join(StreamSupport.stream(dts.spliterator(), false) .map(input -> "DATATYPE(?o) = <" + input.toStringID() + ">").collect(Collectors.toList())); }
From source file:org.eclipse.hawkbit.repository.jpa.JpaRolloutManagement.java
private void deleteScheduledActions(final JpaRollout rollout, final Slice<JpaAction> scheduledActions) { final boolean hasScheduledActions = scheduledActions.getNumberOfElements() > 0; if (hasScheduledActions) { try {/*from www .j a v a 2s .c om*/ final Iterable<JpaAction> iterable = scheduledActions::iterator; final List<Long> actionIds = StreamSupport.stream(iterable.spliterator(), false).map(Action::getId) .collect(Collectors.toList()); actionRepository.deleteByIdIn(actionIds); afterCommit.afterCommit(() -> eventPublisher.publishEvent( new RolloutUpdatedEvent(rollout, EventPublisherHolder.getInstance().getApplicationId()))); } catch (final RuntimeException e) { LOGGER.error("Exception during deletion of actions of rollout {}", rollout, e); } } }