Last modified 3 years ago
Last modified on 12/16/08 15:58:07
Pages linking to CORE_ADDITIONS_R0:
PRO_REGISTRY_PARENT_CHILD_R0
CORE_ADDITIONS_R1
TASK_INDEX
ITERATION_02
PRO_REGISTRY_PARENT_CHILD_R0
CORE_ADDITIONS_R1
TASK_INDEX
ITERATION_02
Analysis
Overview
This task involves the improvement of org.sophie2.core module.
Task requirements
- Revise org.sophie2.core and add some extra functionality that is needed:
- Solve problems of 1-to-1 relations between properties (which currently cause workarounds)
- Child properties should no longer be used
- High performance is not critical at the current stage
- Transform client code that uses child properties according to new implementation
- Write appropriate unit tests
Task result
The result of this task should be source code (including unit tests).
Implementation idea
- Provide functionality to add @Own annotation to properties (except Parent Properties)
- When such annotation is present, an index of all relations should be kept
- Parent property status should be accessed through that index
- @Own annotation can be applied to list properties, too
Related
How to demo
Run the unit tests and show the results to the team.
Design
- @Own annotation should be added. Every owner should be of type ProObject.
- ChildrenProperty is to be dropped.
- the @Own annotation will do the job of children properties.
- Parent properties will be automatically set through the prolib. Not user intervention should be able to set the parent.
- The relationship parent<=>child will be kept in a registry called OwnershipRegistry and will be represented by owner<=>owned pair of ProObjects. The registry will be presented with a hash table where every owned ProObject is mapped to an owner ProObject. This is reasonable since every owned should have exactly one owner. Every owner on the other hand can have one or several owned objects. That is why:
- We should support ObjectProperty and ListProperty where the @Own annotation is used.
- Setting automatically will be done if and only if the method that returns a ParentProperty is named parent(). Example:
/** * A test class representing a child. * */ public static class DummyPage extends BaseProObject { /** * The parent of this {@link DummyPage} * @return property. */ public Prop<DummyBook> parent() { return getBean().makeParentProp(DummyBook.class); } } - methods having an @Own annotation and returning owned things should NOT return a ParentProperty. Every other kind of property is allowed to contain the owned ProObjects.
- The OwnershipRegistry is accessible from everywhere but should NOT be used elsewhere except for the ObjectProperty and ListProperty for them to manage the relations between owned and owners.
- Since parents cannot be set manually, all code having children properties and parent properties should be revised. This applies to the BookView, AppView, PageView, !App, !Book, !Page, all the hierarchy that appears for Flaps,Tabs and Palettes, Halos in menus etc. For every of these and other not mentioned above, the things should be designed and implemented accordingly. We should examine things separately not trying to generalize things but find the most suitable resolution to the problem.
- @Own should work with value properties, value list properties, auto properties, auto list properties.
- @Own should support "null" for values and lists.
Implementation
- done according to design.
- ChildrenProperty? usage is deprecated.
- A listener for value properties is added that observes a StatusChange in the ObjectProperty.
- A listener for list properties is added that observes a ProListChange in the ListProperty.
- Parent properties are not able to be set.
- When a child is owned by a parent, trying to add it to another parent results in an AlreadyOwnedException.
- For more details see the corresponding code - since there were numerous changes here is provided the final result of the CORE_ADDITIONS_R0:
- source code: ObjectProperty, ListProperty, AlreadyOwnedException, Property
- Unit Tests: Own Annotation Unit Tests
Testing
Comments
Log
Analysis: someone !?!? (has not mentioned his name)
Design: Peko - done - 3h
Implementation: Peko - 19h - done
Testing:
Comments:
