[Neo4j] overriding protected I underlyingObjectToObject(T object) return null
Hello all, I stuck with returning null in underlyingObjectToObject. First of all, I have this class: public class ClosableIterableAdapterI, T extends IterableWrapperI, T implements IClosableIterable { private final ClosableIterableT closableNodeIterable; public static IF, TY ClosableIterableAdapterIF, TY from(ClosableIterableTY it) { return new ClosableIterableAdapterIF, TY(it); } public ClosableIterableAdapter(ClosableIterableT closableNodeIterable) { super(closableNodeIterable); this.closableNodeIterable = closableNodeIterable; } @SuppressWarnings(unchecked) @Override protected I underlyingObjectToObject(T object) { // if (true) return (I) object; // if (false) return null; } So long ... it works. But the returned null values destroy my resulting collection. How can I remove them? I mean how I can avoid to return them? Thx a lot for every hint. Jack -- View this message in context: http://neo4j-community-discussions.438527.n3.nabble.com/overriding-protected-I-underlyingObjectToObject-T-object-return-null-tp3499362p3499362.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
Re: [Neo4j] overriding protected I underlyingObjectToObject(T object) return null
Jack, can you provide some more context? Where do you want to use it and what is what you are trying to achieve? Thanks a lot Michael Am 11.11.2011 um 11:51 schrieb jbeau: Hello all, I stuck with returning null in underlyingObjectToObject. First of all, I have this class: public class ClosableIterableAdapterI, T extends IterableWrapperI, T implements IClosableIterable { private final ClosableIterableT closableNodeIterable; public static IF, TY ClosableIterableAdapterIF, TY from(ClosableIterableTY it) { return new ClosableIterableAdapterIF, TY(it); } public ClosableIterableAdapter(ClosableIterableT closableNodeIterable) { super(closableNodeIterable); this.closableNodeIterable = closableNodeIterable; } @SuppressWarnings(unchecked) @Override protected I underlyingObjectToObject(T object) { // if (true) return (I) object; // if (false) return null; } So long ... it works. But the returned null values destroy my resulting collection. How can I remove them? I mean how I can avoid to return them? Thx a lot for every hint. Jack -- View this message in context: http://neo4j-community-discussions.438527.n3.nabble.com/overriding-protected-I-underlyingObjectToObject-T-object-return-null-tp3499362p3499362.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
Re: [Neo4j] overriding protected I underlyingObjectToObject(T object) return null
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
Re: [Neo4j] overriding protected I underlyingObjectToObject(T object) return null
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 FilteringClosableIterableT extends FilteringIterableT implements ClosableIterableT { private final ClosableIterableT source; public FilteringClosableIterable(ClosableIterableT source, PredicateT predicate) { super(source, predicate); this.source = source; } @Override public void close() { source.close(); } } ClosableIterablePerson people = ... new FilteringClosableIterablePerson(people, new PredicatePerson() { @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
Re: [Neo4j] overriding protected I underlyingObjectToObject(T object) return null
Thx a lot for your advice! Multitenancy by API would be a great feature. I favor the idea of partitionated repos found here: http://blog.vivekprahlad.com/multitenancy-with-neo4jrb Striesen is ooch schön! -- View this message in context: http://neo4j-community-discussions.438527.n3.nabble.com/overriding-protected-I-underlyingObjectToObject-T-object-return-null-tp3499362p3499420.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
Re: [Neo4j] overriding protected I underlyingObjectToObject(T object) return null
True, nice approach! The https://github.com/neo4j/community/pull/51 is now merged, so the way is free for doing a Java version as a component of this if you want to get coding? Cheers, /peter neubauer GTalk: neubauer.peter Skype peter.neubauer Phone +46 704 106975 LinkedIn http://www.linkedin.com/in/neubauer Twitter http://twitter.com/peterneubauer http://www.neo4j.org - NOSQL for the Enterprise. http://startupbootcamp.org/ - Öresund - Innovation happens HERE. On Fri, Nov 11, 2011 at 12:26 PM, jbeau jbeauregard...@gmail.com wrote: Thx a lot for your advice! Multitenancy by API would be a great feature. I favor the idea of partitionated repos found here: http://blog.vivekprahlad.com/multitenancy-with-neo4jrb Striesen is ooch schön! -- View this message in context: http://neo4j-community-discussions.438527.n3.nabble.com/overriding-protected-I-underlyingObjectToObject-T-object-return-null-tp3499362p3499420.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
Re: [Neo4j] overriding protected I underlyingObjectToObject(T object) return null
I'll talk with James (ractive) about that :) -- View this message in context: http://neo4j-community-discussions.438527.n3.nabble.com/overriding-protected-I-underlyingObjectToObject-T-object-return-null-tp3499362p3499476.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