NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Best solution to save datamodel using DataObject

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
Klaus Martinschitz
Posted via mailing list.





PostPosted: Tue Aug 11, 2009 9:27 am    Post subject: Best solution to save datamodel using DataObject Reply with quote

Hi!

I have a datamodel were each object has its corresponding node. So the
data model is represented as a node tree. I have got a Configuration.xml
file as a configuration file for my project which should save the data
model as XML structure. If a property in one of my data objects is
changed the DataObject of the Configuration.xml file should be set as
marked. Now I ask myself what is the best way to solve this problem. Of
course I could add the DataObject of Configuration.xml in the
constructor of each object which seems to be pretty ugly to me. Another
approach was following. I get the node of my object. Then I look for the
Project which contains this node, so that I have the correct project
(remember that there could be many projects opened of the same type).
Then I get the DataObject from the Project's lookup (where it has been
put before). Using this approach I have got two questions.

1.) What is the best way to determine the project which contains a
corresponding node?
2.) How would you realise the setModified method of a DataObject to be
called if needed?

Thanks a lot,
Bye,
Klaus
Back to top
tomwheeler



Joined: 03 Sep 2008
Posts: 950

PostPosted: Wed Aug 12, 2009 11:32 pm    Post subject: Best solution to save datamodel using DataObject Reply with quote

For your first question, you could check for a Project in the node's
lookup and then call node.getParent until you find one.
Alternatively, you could check for a FileObject (or DataObject, then
invoke getPrimaryFile() on it) and call FileOwnerQuery.getOwner to
find out the owning project.

I didn't understand your second question. If you meant how can you
tell if a DataObject is modified, you could call isModified on it. If
you meant how can you cause it to save, you could check its Lookup for
SaveCookie and call save() on it.

On Tue, Aug 11, 2009 at 4:17 AM, Klaus
Martinschitz<address-removed> wrote:
Quote:
Hi!

I have a datamodel were each object has its corresponding node. So the
data model is represented as a node tree. I have got a Configuration.xml
file as a configuration file for my project which should save the data
model as XML structure. If a property in one of my data objects is
changed the DataObject of the Configuration.xml file should be set as
marked. Now I ask myself what is the best way to solve this problem. Of
course I could add the DataObject of Configuration.xml in the
constructor of each object which seems to be pretty ugly to me. Another
approach was following. I get the node of my object. Then I look for the
Project which contains this node, so that I have the correct project
(remember that there could be many projects opened of the same type).
Then I get the DataObject from the Project's lookup (where it has been
put before). Using this approach I have got two questions.

1.) What is the best way to determine the project which contains a
corresponding node?
2.) How would you realise the setModified method of a DataObject to be
called if needed?

Thanks a lot,
Bye,
Klaus




--
Tom Wheeler
http://www.tomwheeler.com/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo