Example usage for com.google.common.collect Iterables concat

List of usage examples for com.google.common.collect Iterables concat

Introduction

In this page you can find the example usage for com.google.common.collect Iterables concat.

Prototype

public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) 

Source Link

Document

Combines two iterables into a single iterable.

Usage

From source file:org.obiba.opal.web.project.permissions.ProjectSubjectPermissionsResource.java

/**
 * Get all permissions of a subject in the project.
 *
 * @param domain//from  ww  w .ja  v  a2s .c  om
 * @param type
 * @return
 */
@GET
public Iterable<Opal.Acl> getSubjectPermissions(@QueryParam("type") @DefaultValue("USER") SubjectType type) {

    // make sure project exists
    projectService.getProject(name);

    Iterable<SubjectAclService.Permissions> permissions = Iterables.concat(
            subjectAclService.getSubjectNodeHierarchyPermissions(DOMAIN, getProjectNode(),
                    type.subjectFor(principal)),
            Iterables.filter(subjectAclService.getSubjectNodeHierarchyPermissions(DOMAIN, getDatasourceNode(),
                    type.subjectFor(principal)), new MagmaPermissionsPredicate()));

    return Iterables.transform(permissions, PermissionsToAclFunction.INSTANCE);
}

From source file:fr.aliasource.webmail.common.folders.ListAvailableFoldersCommand.java

public List<IFolder> getData() throws IOException, StoreException, InterruptedException {
    LinkedList<IFolder> l = new LinkedList<IFolder>();

    ListResult infos = null;/*from w ww.j av  a  2s . c o m*/
    ListResult subs = null;
    NameSpaceInfo namespaces = null;
    IStoreConnection con = account.getStoreProtocol();
    try {
        subs = con.lsub("", "*");
        infos = con.list("", "*");
        namespaces = con.namespace();
    } finally {
        con.destroy();
    }

    if (infos != null && namespaces != null) {
        List<String> sharedNamespaces = Lists
                .newArrayList(Iterables.concat(namespaces.getOtherUsers(), namespaces.getMailShares()));

        for (ListInfo info : infos) {
            if (info.isSelectable()) {
                boolean shared = isShared(sharedNamespaces, info);
                IFolder folder = new IMAPFolder(extractDisplayName(infos.getImapSeparator(), info),
                        info.getName(), false, shared);
                if (subs != null) {
                    for (ListInfo subInfo : subs) {
                        if (subInfo.getName().equals(info.getName())) {
                            folder.setSubscribed(true);
                            break;
                        }
                    }
                }
                l.add(folder);
            }
        }
    }
    return l;
}

From source file:org.eclipse.sirius.business.api.query.IFileQuery.java

/**
 * Check if this file is handled by an opened session, ie:
 * <UL>// w ww  .  j  av  a2 s  .com
 * <LI>a semantic resource of this session,</LI>
 * <LI>a referenced sub representations file,</LI>
 * <LI>a controlled resource.</LI>
 * </UL>
 * Tip: This method returns false for the main representations file of a
 * session.
 * 
 * @return true if this file is handled by an opened session, false
 *         otherwise.
 */
public boolean isResourceHandledByOpenedSession() {
    boolean result = false;
    URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
    for (Session session : Lists.newArrayList(SessionManager.INSTANCE.getSessions())) {
        if (session.isOpen() && fileURI != null) {

            Iterable<Resource> handledResources = Iterables.concat(session.getSemanticResources(),
                    session.getReferencedSessionResources());
            if (session instanceof DAnalysisSessionEObject) {
                handledResources = Iterables.concat(handledResources,
                        ((DAnalysisSessionEObject) session).getControlledResources());
            }

            for (Iterator<Resource> iterator = handledResources.iterator(); iterator.hasNext()
                    && !result; /* */) {
                Resource res = iterator.next();
                if (fileURI.equals(res.getURI())) {
                    result = true;
                }
            }
        }
    }
    return result;
}

From source file:com.b2international.snowowl.datastore.server.snomed.merge.rules.SnomedInvalidRelationshipMergeConflictRule.java

@Override
public Collection<MergeConflict> validate(CDOTransaction transaction) {

    Iterable<Relationship> newOrDirtyRelationships = Iterables.concat(
            ComponentUtils2.getDirtyObjects(transaction, Relationship.class),
            ComponentUtils2.getNewObjects(transaction, Relationship.class));

    Set<String> relationshipConceptIds = newHashSet();

    for (Relationship relationship : newOrDirtyRelationships) {
        if (relationship.isActive()) {
            relationshipConceptIds.add(relationship.getSource().getId());
            relationshipConceptIds.add(relationship.getDestination().getId());
            relationshipConceptIds.add(relationship.getType().getId());
        }//from ww  w.  java  2 s.  c  o m
    }

    // Either there were no relationships added or modified, or all of them were inactive
    if (relationshipConceptIds.isEmpty()) {
        return emptySet();
    }

    Set<String> inactiveConceptIds = SnomedRequests.prepareSearchConcept().filterByIds(relationshipConceptIds)
            .filterByActive(false).all()
            .build(SnomedDatastoreActivator.REPOSITORY_UUID, BranchPathUtils.createPath(transaction).getPath())
            .execute(getEventBus())
            .then(concepts -> concepts.getItems().stream().map(IComponent::getId).collect(toSet())).getSync();

    Iterable<Concept> newOrDirtyConcepts = Iterables.concat(
            ComponentUtils2.getDirtyObjects(transaction, Concept.class),
            ComponentUtils2.getNewObjects(transaction, Concept.class));

    for (Concept concept : newOrDirtyConcepts) {
        String conceptId = concept.getId();

        if (relationshipConceptIds.contains(conceptId)) {
            if (concept.isActive()) {
                inactiveConceptIds.remove(conceptId);
            } else {
                inactiveConceptIds.add(conceptId);
            }
        }
    }

    // None of the concepts referenced by an active relationship were inactive
    if (inactiveConceptIds.isEmpty()) {
        return emptySet();
    }

    List<MergeConflict> conflicts = newArrayList();

    for (Relationship relationship : newOrDirtyRelationships) {

        if (inactiveConceptIds.contains(relationship.getSource().getId())) {
            conflicts.add(
                    MergeConflictImpl.builder().componentId(relationship.getId()).componentType("Relationship")
                            .conflictingAttribute(ConflictingAttributeImpl.builder().property("sourceId")
                                    .value(relationship.getSource().getId()).build())
                            .type(ConflictType.HAS_INACTIVE_REFERENCE).build());
        }

        if (inactiveConceptIds.contains(relationship.getDestination().getId())) {
            conflicts.add(
                    MergeConflictImpl.builder().componentId(relationship.getId()).componentType("Relationship")
                            .conflictingAttribute(ConflictingAttributeImpl.builder().property("destinationId")
                                    .value(relationship.getDestination().getId()).build())
                            .type(ConflictType.HAS_INACTIVE_REFERENCE).build());
        }

        if (inactiveConceptIds.contains(relationship.getType().getId())) {
            conflicts.add(
                    MergeConflictImpl.builder().componentId(relationship.getId()).componentType("Relationship")
                            .conflictingAttribute(ConflictingAttributeImpl.builder().property("typeId")
                                    .value(relationship.getType().getId()).build())
                            .type(ConflictType.HAS_INACTIVE_REFERENCE).build());
        }
    }

    return conflicts;
}

From source file:org.eclipse.osee.cache.admin.internal.LoadingCacheProxy.java

@Override
public Iterable<? extends K> getAllKeys() throws Exception {
    Iterable<? extends K> iterator1 = getAllKeysPresent();
    Iterable<? extends K> iterator2 = keyProvider.getAllKeys();
    Iterable<? extends K> joined = Iterables.concat(iterator1, iterator2);
    return Sets.newHashSet(joined);

}

From source file:org.gradle.jvm.internal.DefaultJvmBinarySpec.java

public static List<DependencySpec> collectDependencies(final BinarySpec binary,
        @Nullable final SourceComponentSpec owner, final Collection<DependencySpec>... specificDependencies) {
    List<DependencySpec> dependencies = Lists.newArrayList();
    if (specificDependencies != null) {
        for (Collection<DependencySpec> deps : specificDependencies) {
            dependencies.addAll(deps);//from   www . j av  a2 s  .  co m
        }
    }
    Collection<LanguageSourceSet> binarySources = binary.getSources().values();
    Iterable<LanguageSourceSet> sourceSets = owner != null
            ? Iterables.concat(owner.getSources().values(), binarySources)
            : binarySources;
    for (LanguageSourceSet sourceSet : sourceSets) {
        if (sourceSet instanceof DependentSourceSet) {
            dependencies.addAll(((DependentSourceSet) sourceSet).getDependencies().getDependencies());
        }
    }
    return dependencies;
}

From source file:com.google.idea.blaze.java.sync.workingset.JavaWorkingSet.java

public JavaWorkingSet(WorkspaceRoot workspaceRoot, WorkingSet workingSet,
        Predicate<String> buildFileNamePredicate) {
    Set<String> modifiedBuildFileRelativePaths = Sets.newHashSet();
    Set<String> modifiedJavaFileRelativePaths = Sets.newHashSet();

    for (WorkspacePath workspacePath : Iterables.concat(workingSet.addedFiles, workingSet.modifiedFiles)) {
        if (buildFileNamePredicate.test(workspaceRoot.fileForPath(workspacePath).getName())) {
            modifiedBuildFileRelativePaths.add(workspacePath.relativePath());
        } else if (workspacePath.relativePath().endsWith(".java")) {
            modifiedJavaFileRelativePaths.add(workspacePath.relativePath());
        }/*from w w w. j  av  a2  s. c  o m*/
    }

    this.modifiedBuildFileRelativePaths = modifiedBuildFileRelativePaths;
    this.modifiedJavaFileRelativePaths = modifiedJavaFileRelativePaths;
}

From source file:com.google.gxp.compiler.base.Template.java

public Template(SourcePosition sourcePosition, String displayName, TemplateName.FullyQualified name,
        Schema schema, List<JavaAnnotation> javaAnnotations, Constructor constructor, List<Import> imports,
        List<ImplementsDeclaration> implementsDeclarations, List<ThrowsDeclaration> throwsDeclarations,
        List<Parameter> parameters, List<FormalTypeParameter> formalTypeParameters, Expression content) {
    super(sourcePosition, displayName, name, schema, javaAnnotations, imports, throwsDeclarations, parameters,
            formalTypeParameters);//from w  ww  .j  a  va  2s  .c o  m
    this.constructor = Preconditions.checkNotNull(constructor);
    this.allParameters = ImmutableList.copyOf(Iterables.concat(constructor.getParameters(), getParameters()));
    this.implementsDeclarations = ImmutableList.copyOf(implementsDeclarations);
    this.content = Preconditions.checkNotNull(content);

    this.callable = new TemplateCallable(name, schema, getAllParameters());

    List<Parameter> params = Lists.newArrayList();
    params.addAll(getParameters());
    params.add(new Parameter(new FormalParameter(sourcePosition, Implementable.INSTANCE_PARAM_NAME,
            Implementable.INSTANCE_PARAM_NAME, new InstanceType(this, name))));
    this.instanceCallable = new TemplateInstanceCallable(name, schema, params);
}

From source file:org.trancecode.xml.saxon.SaxonAxis.java

public static Iterable<XdmItem> childXdmItems(final XdmNode node) {
    return Iterables.concat(axis(node, Axis.ATTRIBUTE), axis(node, Axis.CHILD));
}

From source file:org.gradle.api.internal.file.FileSystemSubset.java

public Iterable<? extends File> getRoots() {
    return FileUtils.calculateRoots(
            Iterables.concat(files, Iterables.transform(trees, new Function<DirectoryTree, File>() {
                @Override//w w w . ja va 2 s  .c o m
                public File apply(DirectoryTree input) {
                    return input.getDir();
                }
            })));
}