Issue Details (XML | Word | Printable)

Key: GDS-523
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: William Draï
Reporter: heyoulin
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
GraniteDS

PagedCollection suport Map

Created: 22/Sep/09 05:08 AM   Updated: 19/Feb/10 05:53 PM   Resolved: 24/Sep/09 10:54 AM
Component/s: Tide
Affects Version/s: 2.0.0_SP1
Fix Version/s: 2.1.0_RC1


 Description  « Hide
need to supprt map PagedCollection using id instead of uddi

change: org.granite.tide.collections.PagedCollection.as


public override function getItemIndex(obj:Object):int {
if (obj == null)
return -1;

            // log.debug("getItemIndex {0}", obj);
if (localIndex) {
// Local data available: lookup by id
if(obj is IUID)
{
for (var idx:int = 0; idx < localIndex.length; idx++) {
if (IUID(obj).uid == IUID(localIndex[idx]).uid)
return _first + idx;
}
}
else
{
for (idx = 0; idx < localIndex.length; idx++) {
if(obj.ID)
if (obj.ID == localIndex[idx].ID)
return _first + idx;
if(obj.id)
if (obj.id == localIndex[idx].id)
return _first + idx;
}
}
}

return -1;
}


private function nullCompare(o1:Object, o2:Object, fields:Array = null):int {
if (o1 is IUID && o2 is IUID) {
if (IUID(o1) == IUID(o2))
return 0;
return 1;
}
else
{
if (o1!=null && o2 !=null) {
if(o1.ID)
if (o1.ID == o2.ID)
return 0;
if(o1.id)
if (o1.id == o2.id)
return 0;
return 1;
}


}
return 0;
}



server side can use List<Map> as resultList. map must contain id key

heyoulin added a comment - 23/Sep/09 05:28 PM
thanks for this new feature. But when i user spring JdbcTemplate's queryForList on oracle database it always return upcase UID.

can change to this ??

public override function getItemIndex(obj:Object):int {
if (obj == null)
return -1;

            // log.debug("getItemIndex {0}", obj);
if (localIndex) {
var idx:int;
if (obj is IUID) {
// Local data available: lookup by id
for (idx = 0; idx < localIndex.length; idx++) {
if (IUID(obj).uid == IUID(localIndex[idx]).uid)
return _first + idx;
}
}
else if (obj.hasOwnProperty("uid")) {
// GDS-523
for (idx = 0; idx < localIndex.length; idx++) {
if (obj.uid == localIndex[idx].uid)
return _first + idx;
}
}
else if (obj.hasOwnProperty("UID")) {
// GDS-523
for (idx = 0; idx < localIndex.length; idx++) {
if (obj.UID == localIndex[idx].UID)
return _first + idx;
}
}
}

return -1;
}


private function nullCompare(o1:Object, o2:Object, fields:Array = null):int {
if (o1 is IUID && o2 is IUID) {
if (IUID(o1) == IUID(o2))
return 0;
return 1;
}
// GDS-523
if (o1 != null && o2 != null && o1.hasOwnProperty("uid") && o2.hasOwnProperty("uid")) {
if (o1.uid == o2.uid)
return 0;
return 1;
}
// GDS-523
if (o1 != null && o2 != null && o1.hasOwnProperty("UID") && o2.hasOwnProperty("UID")) {
if (o1.UID == o2.UID)
return 0;
return 1;
}
return 0;
}

heyoulin added a comment - 23/Sep/09 05:45 PM
BWT uid is oracle key words. i'd like to use id instead of uid

William Draï added a comment - 24/Sep/09 01:28 AM
Added uidProperty to PagedCollection (defaults to uid to keep consistent with Flex default uid property).

heyoulin added a comment - 24/Sep/09 02:39 AM
nice work. thanks