hydrologics/Oasis.Base — Issue #13: Metadata created for any arbitrary new object - not saved objects
Author: danrichardson
Created: 2011-10-21 20:16:00+00:00
State: open

Interesting twist to the new separated Metadata database - metadata is created (and added) to the database, and assigned a GUID, whenever an object is created (new Arc(), say). If the object isn't saved to the database, the metadata lingers.

Is this a problem? Maybe not, it shows that work was done (playing around with Arcs, say), but not saved. Not sure how useful it is.

It's a bigger problem with the new "Create new object regardless of if we save it or not" temporary editor scheme. We'll be flooded with lingering metadata whenever an Arc editor is opened.

What if the metadata isn't saved until an Element is saved? I'm not sure how to implement this, however.

One idea is to put this in a transaction, though I'm not sure since it appears that the table will be locked for writing (for everyone? For the context? Dunno).

Another idea is to pull this out of the CreateObjectMetadatum method:
Add(meta);
Commit();
EventAggregatorHost.Publish(new MetadatumCreatedEvent(meta));

And add it to a new SaveObjectMetadatum method, which would be called when the Owning object is saved. If anything, the owning object has its own metadata (since it's returned, I assume Arc.Metadata == the returned metadata object). When we do an Arc.Save(), the Save method also saves the metadata.

BUT! What about the case when you're saving it to a run...

Arc _arc = new Arc();
Arc.stuff = values;
_run.Arcs.Add(arc);
_run.Save(); <-- We'd have to fire off the Metadata save here, but does the run inherently know it is saving specific Arcs? Will the Presentation Arc's editor have to do this (call the Arc.SaveObjectMetadatum(meta) or some such?). Seems reasonable - the Presentation is already going to have to determine if an Arc changed in any way, and if it is doing that, it can save the metadata then, right?