|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
how to retrieve the object_version of a enterprise/person from an addressHi,
for the OGoAddressMapLinks, I wanted to save the coordinates that I looked up on google persistently, so I need to recognize, when an address changes, to lookup new coordinates. In the address table there is a object_version fields, but it doesn't seem to be used. The address version is bound to the company object_version. The address entity has a companyId, pointing to the company that has the address assigned. I'm struggling to figure out the version of the company, any hint how this can be done easily. Or a pointer to some class in the ogo sources as an example would be great. kind regards Sebastian -- OpenGroupware.org Developer developer@... http://mail.opengroupware.org/mailman/listinfo/developer |
|
|
Re: how to retrieve the object_version of a enterprise/person from an address> for the OGoAddressMapLinks, I wanted to save the coordinates that I looked up on
> google persistently, so I need to recognize, when an address changes, to lookup > new coordinates. > In the address table there is a object_version fields, but it doesn't seem to be > used. The address version is bound to the company object_version. > The address entity has a companyId, pointing to the company that has the address > assigned. > I'm struggling to figure out the version of the company, any hint how this can > be done easily. Or a pointer to some class in the ogo sources as an example > would be great. The only way I can think of is to retrieve the company record from the database. gid = [[context typeManager] globalIDForPrimaryKey:companyId]; if (gid == nil) return nil; company = [context runCommand:@"object::get-by-globalid", @"gid", companyId, @"returnType", [NSNumber numberWithInt:LSDBReturnType_OneObject], nil]; if [company isNotNull] { ... ... [company valueForKey:@"objectVersion"] ... ... } Just off the top of my head; that probably won't work. :) Or maybe there is some way to use the toEnterprise attribute/method from the LSAddress object you have (LSAddress is an EOGenericRecord). Not sure, I still haven't found any real documentation on EO/GDL. -- OpenGroupware.org Developer developer@... http://mail.opengroupware.org/mailman/listinfo/developer |
|
|
Re: how to retrieve the object_version of a enterprise/person from an addressOn 08.06.2008, at 18:08, Adam Tauno Williams wrote:
> Or maybe there is some way to use the toEnterprise attribute/method > from the LSAddress object you have (LSAddress is an EOGenericRecord). Its possible that there is such a KVC key, but its not recommended to use those. > In the address table there is a object_version fields, but it > doesn't seem to be used. The address version is bound to the company > object_version. Would be good if both versions would bump if an address changes. But its important that the company version increases when an address changes. Greets, Helge -- Helge Hess http://www.helgehess.eu/ -- OpenGroupware.org Developer developer@... http://mail.opengroupware.org/mailman/listinfo/developer |
|
|
|
|
|
Re: how to retrieve the object_version of a enterprise/person from an addressOn 09.06.2008, at 01:58, Sebastian Reitenbach wrote:
> So you mean the unused object_version of the address could be > considered a bug? Well, not a bug, an unimplemented feature. > A filled object_version field in the address table would make life a > lot easier for my task. > Maybe I should investigate, how to get it filled, instead of trying > to figure out the object version of the assigned company. Yes, the code which bumps the company version on changed addresses could probably also bump the address version field. Don't know exactly how the specific code is setup. Helge -- Helge Hess http://www.helgehess.eu/ -- OpenGroupware.org Developer developer@... http://mail.opengroupware.org/mailman/listinfo/developer |
|
|
|
|
|
Re: how to retrieve the object_version of a enterprise/person from an addressOn Tue, 2008-06-10 at 10:02 +0200, Sebastian Reitenbach wrote: > developer@... wrote: > > On 09.06.2008, at 01:58, Sebastian Reitenbach wrote: > > > So you mean the unused object_version of the address could be > > > considered a bug? > > > > Well, not a bug, an unimplemented feature. > ah, ok ;) > http://bugzilla.opengroupware.org/bugzilla/show_bug.cgi?id=1983 > > > > > A filled object_version field in the address table would make life a > > > lot easier for my task. > > > Maybe I should investigate, how to get it filled, instead of trying > > > to figure out the object version of the assigned company. > > > > Yes, the code which bumps the company version on changed addresses > > could probably also bump the address version field. Don't know exactly > > how the specific code is setup. > ok, going to take a look, especially, as it would make the lookup of > coordinates far more efficient, as the addresses do not change as often as > company info changes, so fewer external lookups are needed. LSSetAddressCommand bumps the company address, but not it's own. ----------------------------------------------------- - (void)_executeInContext:(id)_context { NSNumber *companyId; NSArray *companies; [super _executeInContext:_context]; companyId = [[self object] valueForKey:@"companyId"]; companies = LSRunCommandV(_context, @"company", @"get", @"primaryKey", @"companyId", @"companyId", companyId, nil); [self assert:([companies count] < 2) format:@"Only one object allowed for one companyId, " @"found %i companies: %@", [companies count], companies]; [self assert:[companies isNotEmpty] format:@"Need one object for companyId %@, found none", companyId]; if (self->shouldLog) { LSRunCommandV(_context, @"object", @"add-log", @"logText", [self valueForKey:@"logText"], @"action", [self valueForKey:@"logAction"], @"objectId", companyId, nil); } LSRunCommandV(_context, @"object", @"increase-version", @"object", [companies lastObject], nil); } ------------------------------------------------- LSDBObjectSetCommand, the parent class of LSSetAddressCommand provides: (void)bumpChangeTrackingFields. Just calling [self bumpChangeTrackingFields] *before* the [super _executeInContext:_context] call. The LSDBObjectSetCommand's _executeInContext does the actual database update. Insert the call to bumpChangeTrackingFields, enable SQL logging, and see what happens. :) Generally it would be good if more of the commands used bumpChangeTrackingFields since it also updates lastModified/lastmodifiedDate if the entity has such an attribute. -- OpenGroupware.org Developer developer@... http://mail.opengroupware.org/mailman/listinfo/developer |
|
|
Re: how to retrieve the object_version of a enterprise/person from an addressOn 10.06.2008, at 14:36, Adam Tauno Williams wrote:
> Generally it would be good if more of the commands used > bumpChangeTrackingFields since it also updates > lastModified/lastmodifiedDate if the entity has such an attribute. Which is not always correct. Remember that the ::set commands are used for ALL updates. Sometimes the caller decides whether a version is bumped or whether a change should bump a version. Document snapshots might be an example. So basically you are right, but in practice one needs to be quite careful with such changes. Helge -- Helge Hess http://www.helgehess.eu/ -- OpenGroupware.org Developer developer@... http://mail.opengroupware.org/mailman/listinfo/developer |
| Free Forum Powered by Nabble | Forum Help |