Hey Jack, 

actually it is Dresden(Striesen) right now :)

you might look into org.neo4j.helpers.collection.FilteringIterable, which takes 
a predicate to allow you arbitrary filtering.


        class FilteringClosableIterable<T> extends FilteringIterable<T> 
implements ClosableIterable<T> {
            private final ClosableIterable<T> source;

            public FilteringClosableIterable(ClosableIterable<T> source, 
Predicate<T> predicate) {
                super(source, predicate);
                this.source = source;
            }

            @Override
            public void close() {
                source.close();
            }
        }

        ClosableIterable<Person> people = ...
        new FilteringClosableIterable<Person>(people, new Predicate<Person>() {
            @Override
            public boolean accept(Person item) {
                return item != null;
            }
        });


Regarding Multi-Tenancy:

I spend some time thinking about multi-tenancy on the core-API level of Neo4j 
which should be more widely applicable.

something like new SingleTenantGraphDatabase(graphDatabaseService, tenantId);

which should just wrap all core-api methods to filter the stuff, for indexing 
there is the option of creating separate indexes with the tenant-Id as an 
suffix or prefix or filtering at the query level (probably the previous).

For all the other methods you just put a property on nodes and relationships 
that points to the tenant (which you have to filter out in the 
property-container methods).

And probably create different reference-nodes for each tenant.

That should be it.

Am 11.11.2011 um 12:07 schrieb jbeau:

> Hello Michael,
> 
> greetings to the Neustadt :)
> 
> I try to realize a multi tenancy environment and started with a first
> approach. In a abstract repository I call methods like this:
> 
> @Override
> public IClosableIterable findByName(final String name) {
>         return
> ClosableIterableAdapter.from(getGraphRepository().findAllByPropertyValue("name",
> name));
> }
> 
> In the ClosableIterableAdapter I posted above I want to avoid putting all
> entities into the iterator, which are not valid for the current tenant. The
> underlyingObjectToObject() forces to return something. In my case, the non
> valid entities are null. I guess it's not a good idea, to filter them later.
> I think I have to avoid to put them into the iterator here.
> 
> Thx for help
> Jack
> 
> --
> View this message in context: 
> http://neo4j-community-discussions.438527.n3.nabble.com/overriding-protected-I-underlyingObjectToObject-T-object-return-null-tp3499362p3499393.html
> Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user

_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to