How to get the info of a NodeDraft in a Generator plugin?

Extensions and customization
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
kaigephi
Posts:11
Joined:18 Mar 2011 12:28
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
How to get the info of a NodeDraft in a Generator plugin?

Post by kaigephi » 21 Apr 2011 21:59

I am writing a generator plugin using 0.8 alpha. I need to access information about a NodeDraft such as its ID and those stored in the AttributeTable, but can't figure out a way to do this. I need this information to decide whether to add an EdgeDraft between a pair of DraftNodes.

I saw this post about NodeDraft attributes: http://forum.gephi.org/viewtopic.php?f= ... =nodedraft
and tried to use GraphModel to get the information but only got "Null Pointer Exception".

Currently I had to create my own Node class to store the information, which is a bit annoying.

User avatar
mbastian
Gephi Architect
Posts:728
Joined:10 Dec 2009 10:11
Location:San Francisco, CA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: How to get the info of a NodeDraft in a Generator plugin

Post by mbastian » 22 Apr 2011 00:11

NodeDraft is design to set values, and NodeDraftGetter to get values. It's two separate interfaces, but implemented by the same class in the implementation, so you can simply cast your NodeDraft into NodeDraftGetter and use getId() or getAttributeRow() to access attributes.

At this stage of Import, there is nothing in GraphModel. Draft elements are only appended to the GraphModel once the import (or generator) is validated by the user. This is quite useful, as cancelling an import is straightforward in the code.

kaigephi
Posts:11
Joined:18 Mar 2011 12:28
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: How to get the info of a NodeDraft in a Generator plugin

Post by kaigephi » 23 Apr 2011 10:25

Thanks! I knew there would be something like the NodeDraftGetter, but just couldn't quite find it :-)

Is there a way to get the list of NodeDraft/EdgeDraft added to ContainerLoader?

User avatar
mbastian
Gephi Architect
Posts:728
Joined:10 Dec 2009 10:11
Location:San Francisco, CA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: How to get the info of a NodeDraft in a Generator plugin

Post by mbastian » 25 Apr 2011 22:05

Cast the ContainerLoader to ContainerUnloader :-)

There could be some limitations though, let us know what is your use case

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable