Bug 215299 - add methods to IResource to get all session and persistent properties
Summary: add methods to IResource to get all session and persistent properties
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.3.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Szymon Brandys CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-01-15 01:07 EST by Francis Upton IV CLA
Modified: 2008-03-27 11:35 EDT (History)
5 users (show)

See Also:


Attachments
Patch for I20071213-1500 (12.67 KB, patch)
2008-01-31 14:26 EST, Francis Upton IV CLA
no flags Details | Diff
Reviewed patch (12.88 KB, patch)
2008-03-26 10:24 EDT, Szymon Brandys CLA
no flags Details | Diff
Reviewed patch with since tags (12.93 KB, patch)
2008-03-26 10:51 EDT, Szymon Brandys CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Francis Upton IV CLA 2008-01-15 01:07:57 EST
Currently, when a delete is undone, the session and persistent properties associated with the resource are lost, and this is the subject of bug 160729.

In order to implement the fix for that, the UI needs an API on IResource that will get all of the session and persistent properties.  Something like this (on IResource):

// K<QualifiedName> V<String>
public Map getSessionProperties()

// K<QualifeedName> V<String> 
public Map setPersistentProperties()

Implementation of each of this is straightforward and I would be happy to provide a patch if people agree that we should have this.

I think these methods could also be generally useful for applications that provide ways to store all of the properties of a in a separate area or file for things like source control.
Comment 1 Szymon Brandys CLA 2008-01-15 09:45:57 EST
Right. The implementation is straightforward. Could you please attach the patch for  a review?
Comment 2 Francis Upton IV CLA 2008-01-29 05:45:23 EST
This is no longer needed for the persistent properties portion of the delete undo support (bug 160729).  A new enhancement request, bug 216884 replaces this one.

However, this is needed for the session properties portion of delete undo.  And it might be useful for to have the persistent properties API in any case, so I will submit a patch that adds these APIs.

Comment 3 Szymon Brandys CLA 2008-01-29 05:57:24 EST
Thanks for the patch.
However I would suggest to unify the API for persistent and session properties. 
I like your first proposal for adding these methods in IResource...

public Map getSessionProperties()
public Map getPersistentProperties()
public void setSessionProperties(Map)
public void setPersistentProperties(Map)

I've been thinking about adding somthing like

public QualifiedName[] getSessionPropertiesKeys()
public QualifiedName[] getPersistentPropertiesKeys()

however the issue is that, even if we got this list we would have to call getters couple times, what would be less efficient than just getting whole map of properties.
Comment 4 Francis Upton IV CLA 2008-01-29 06:07:10 EST
I think we should go with creating a map for the reasons you outline.  Especially for the persistent properties, since they are stored on disk, forcing a double access if you want to read the values can get expensive.

Please note however that the patch submitted was bug 216884, which is necessary to support the delete undo without keeping the properties in memory.  I still think that's the direction we should go; if we take the approach outlined in this bug report, we would be keeping an unbounded amount of persistent properties in memory which could be quite a problem.  If you disagree with this, can you say why?

I would be happy to submit a patch to provide these APIs as well, as they might be useful for other purposes (and are required to support delete undo for the session properties).

(In reply to comment #3)
> Thanks for the patch.
> However I would suggest to unify the API for persistent and session properties. 
> I like your first proposal for adding these methods in IResource...
> 
> public Map getSessionProperties()
> public Map getPersistentProperties()
> public void setSessionProperties(Map)
> public void setPersistentProperties(Map)
> 
> I've been thinking about adding somthing like
> 
> public QualifiedName[] getSessionPropertiesKeys()
> public QualifiedName[] getPersistentPropertiesKeys()
> 
> however the issue is that, even if we got this list we would have to call
> getters couple times, what would be less efficient than just getting whole map
> of properties.
> 

Comment 5 Francis Upton IV CLA 2008-01-31 14:26:01 EST
Created attachment 88441 [details]
Patch for  I20071213-1500

Here is a patch for adding these methods:

public Map getSessionProperties()
public Map getPersistentProperties()

I did not see any point in adding the set methods since there are already adequate set methods.

I also added some test for properties (there did not appear to be any).  They test for:

1) The new APIS
2) Properties persist across copy (session properties don't)
3) Properties persist across close (session properties don't)

This also includes a minor refactoring in Resource which eliminated a few lines of duplicate code that appears in many places.
Comment 6 Francis Upton IV CLA 2008-03-25 04:08:39 EDT
Szymon, can we try to get this into M6?  This should be pretty straightforward, and I think will be very useful to people.
Comment 7 Szymon Brandys CLA 2008-03-26 10:24:12 EDT
Created attachment 93593 [details]
Reviewed patch

We should be very careful about new introduced API. If we introduced it now, we would not be able to remove it, since M6 is almost done.

Besides I think that better API would be methods that get array of properties' keys. Then if people wanted to get properties' values, they could do it using the existing methods.

Anyway I made some changes in your patch since this new getters should return copies of properties map.
Comment 8 Szymon Brandys CLA 2008-03-26 10:51:21 EDT
Created attachment 93609 [details]
Reviewed patch with since tags
Comment 9 John Arthorne CLA 2008-03-26 10:52:36 EDT
Patch released. Francis, thanks for your contribution. How do you want to appear in the copyright attribution? Under your name or a company name?
Comment 10 John Arthorne CLA 2008-03-26 10:56:42 EDT
I have added the following to the copyright of the changed files:

 *     Oakland Software Incorporated - added getSessionProperties and getPersistentProperties
Comment 11 Francis Upton IV CLA 2008-03-26 12:24:52 EDT
(In reply to comment #10)
> I have added the following to the copyright of the changed files:
> 
>  *     Oakland Software Incorporated - added getSessionProperties and
> getPersistentProperties
> 

That's fine; here is what I typically have been using:

 *     Oakland Software (Francis Upton) <francisu@ieee.org> - bug xxxxx

In the future I will make sure my patches have the property copyright notice.

Thanks for taking this! 

Comment 12 Szymon Brandys CLA 2008-03-27 11:35:03 EDT
Verified in I20080327-0100.