[OGo-Developer] Object Properties Question

Adam Tauno Williams developer@opengroupware.org
Fri, 09 Feb 2007 07:19:29 -0500


--=-eKJpbwMGGbjzkCKNmkEE
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Thu, 2007-02-08 at 23:17 -0500, Adam Tauno Williams wrote:
> I can get a dictionary of object properties using -
> [[[self getCTX] propertyManager] propertiesForGlobalID:eo];
> - in which case the property name as in
> "{http://www.opengroupware.org/properties/ext-attr}Color" is the key and
> the value is the value (as in "Blue").
> However I would very much like to have the object property id (the
> obj_property_id column of obj_property) and the "preferredType" (the
> preferred_type column in obj_property).  I see these attributes dealt
> with in the propertyManager (SkyObjectPropertyManager.m) but no way to
> get them.

I can accomplish this with the following code;  but this involves
calling the property manager's private _fetchPropertyRowsForGlobalIDs
method.  Is this kosher?  I can't see any other way to do it.

---------
-(NSDictionary *)_renderProperty:(id)_property {
  /*=20
    TODO: 1.) Deal with value types other than string
          2.) Add type and label information to rendered property from=20
              system defaults if namespace is              =20
              "http://www.opengroupware.org/properties/ext-attr" as=20
              those values are rendered in the UI as extended=20
              attributes.  Client will need these hints.
          3.) Figure out long string storage and BLOB encoding.
   */
           =20
  return [NSDictionary dictionaryWithObjectsAndKeys:
       [_property objectForKey:@"key"], @"propertyName",
       [_property objectForKey:@"namespacePrefix"], @"namespace",
       [_property objectForKey:@"preferredType"], @"preferredType",
       [self NIL:[_property objectForKey:@"valueString"]], @"value",
       @"objectProperty", @"entityName",
       [_property objectForKey:@"objectPropertyId"], @"objectId",
       [_property objectForKey:@"objectId"], @"entityObjectId",
       nil];
}

-(NSArray *)_propertiesForKey:(id)_objectId {
  NSMutableArray *propertyList;
  NSArray        *properties, *keys;
  id             property;
  NSEnumerator   *enumerator;

  propertyList =3D [[NSMutableArray alloc] initWithCapacity:6];
  keys =3D [NSArray arrayWithObjects:[self _getEOForPKey:_objectId], nil];
  properties =3D [[[self getCTX] propertyManager]=20
                 _fetchPropertyRowsForGlobalIDs:keys
                                      namespace:nil];
  enumerator =3D [properties objectEnumerator];
  while ((property =3D [enumerator nextObject]) !=3D nil) {
     [propertyList addObject:[self _renderProperty:property]];
   }
  return propertyList;
}
---------

--=-eKJpbwMGGbjzkCKNmkEE
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQBFzGbRLRePpNle04MRAhu6AJ4lWf8oNavDZX7gpV/H9t0M4ycOewCfUivG
GdkSLuHuQz8zx0ZrzOtpsdw=
=ilqM
-----END PGP SIGNATURE-----

--=-eKJpbwMGGbjzkCKNmkEE--