Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,003 changes: 4,003 additions & 0 deletions core/event/event-manager.wip.js

Large diffs are not rendered by default.

734 changes: 734 additions & 0 deletions core/event/mutable-event.wip.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions data/model/data-identifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ exports.DataIdentifier = Montage.specialize(/** @lends DataIdentifier.prototype

/**
* The ObjectDescriptor associated with a dataIdentifier if available
* TODO: Rename to typeDescriptor
*
* @type {ObjectDescriptor}
*/
Expand Down
6 changes: 1 addition & 5 deletions data/model/data-identifier.mjson
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@
"DataIdentifier": {
"object": "./data-identifier"
},
"DataServiceDescriptor": {
"object": "data/service/data-service.mjson"
},
"dataService": {
"prototype": "core/meta/property-descriptor",
"values": {
"name": "dataService",
"valueType": "object",
"cardinality": 1,
"valueDescriptor": {"@": "DataServiceDescriptor"}
"cardinality": 1
}
},
"ObjectDescriptorDescriptor": {
Expand Down
104 changes: 96 additions & 8 deletions data/model/data-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const DataEvent = require("./data-event").DataEvent;
const Date = require("core/extras/date").Date;
const Montage = require("core/core").Montage;
const Target = require("core/target").Target;
const application = require("core/application").application;


/**
* @class DataObject
Expand All @@ -26,6 +28,14 @@ exports.DataObject = class DataObject extends Target {
*/
fullModuleId: { value: undefined },

// /**
// * an instance's dataIdentifier
// *
// * @property {DataIdentifier}
// * @default null
// */
// dataIdentifier: { value: undefined },

/**
* Stores the latest known data snapshot from an origin service it was imported from.
* An entry per origin data service contains the data snapshot from that origin
Expand Down Expand Up @@ -288,6 +298,55 @@ exports.DataObject = class DataObject extends Target {
}
}

// serializeSelf(serializer) {
// if (super.deserializeSelf) {
// super.deserializeSelf(deserializer);
// }

// // Can't use this unless we know that this.objectDescriptor is available to us
// if (this.objectDescriptor) {
// let objectDescriptor = this.objectDescriptor,
// propertyDescriptors = objectDescriptor.propertyDescriptors,
// ownPropertyNames = Object.keys(this);

// for (let i=0, iPropertyDescriptor, iCount = ownPropertyNames.length; i < iCount; i++) {
// //for (let iPropertyDescriptor of propertyDescriptors) {
// if (((iPropertyDescriptor = objectDescriptor.propertyDescriptorNamed(ownPropertyNames[i])) !== null) && iPropertyDescriptor.isSerializable !== false && this[iPropertyDescriptor.name] !== undefined) {
// serializer.setProperty(iPropertyName, this[iPropertyName]);
// }
// }
// } else {

// if (this.originId) {
// serializer.setProperty("originId", this.originId);
// }
// if (this.originDataSnapshot) {
// serializer.setProperty("originDataSnapshot", this.originDataSnapshot);
// }

// if (this.isType !== undefined) {
// serializer.setProperty("isType", this.isType);
// }
// if (this.isTemplate !== undefined) {
// serializer.setProperty("isTemplate", this.isTemplate);
// }

// if (this.description) {
// serializer.setProperty("description", this.description);
// }
// if (this.creationDate) {
// serializer.setProperty("creationDate", this.creationDate);
// }
// if (this.modificationDate) {
// serializer.setProperty("modificationDate", this.modificationDate);
// }
// if (this.publicationDate) {
// serializer.setProperty("publicationDate", this.publicationDate);
// }
// }
// }


clone() {
return this;
}
Expand All @@ -309,16 +368,45 @@ exports.DataObject = class DataObject extends Target {
*/

static prepareToHandleDataEvents(event) {
event.dataService.objectDescriptorForType(this).addEventListener(DataEvent.create, this, false);
event.dataService.objectDescriptorForType(this).addEventListener(DataEvent.willSave, this, false);
}

static handleCreate(event) {
// if(event.dataObject instanceof this) {
event.dataObject.creationDate = event.dataObject.modificationDate = new Date();
// }
}
// static handleCreate(event) {
// // if(event.dataObject instanceof this) {
// event.dataObject.creationDate = event.dataObject.modificationDate = new Date();
// event.dataObject.creationIdentity = application.identity;
// // }
// }

static handleWillSave(event) {
const objectDescriptor = event.target,
transaction = event.detail,
createdDataObjects = transaction.createdDataObjects.get(objectDescriptor),
updatedDataObjects = transaction.updatedDataObjects.get(objectDescriptor),
deletedDataObjects = transaction.deletedDataObjects.get(objectDescriptor),
nowDate = new Date(),
identity = transaction.identity;

if(createdDataObjects) {
for(let instance of createdDataObjects) {
instance.creationDate = instance.modificationDate = nowDate;
instance.creationIdentity = instance.modificationIdentity = identity;
}
}

if(updatedDataObjects) {
for(let instance of updatedDataObjects) {
instance.modificationDate = nowDate;
instance.modificationIdentity = identity;
}
}

if(deletedDataObjects) {
for(let instance of deletedDataObjects) {
instance.archivalDate = nowDate;
instance.archivalIdentity = identity;
}
}

static handleUpdate(event) {
event.dataObject.modificationDate = new Date();
}
};
14 changes: 14 additions & 0 deletions data/model/data-object.mjson
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"name": "DataObject",
"propertyDescriptors": [
{"@": "fullModuleId"},
{"@": "dataIdentifier"},
{"@": "date"},
{"@": "originId"},
{"@": "originDataSnapshot"},
Expand Down Expand Up @@ -53,6 +54,19 @@
}
},

"DataIdentifierDescriptor": {
"object": "./data-identifier.mjson"
},

"dataIdentifier": {
"prototype": "core/meta/property-descriptor",
"values": {
"name": "dataIdentifier",
"valueDescriptor": {"@": "DataIdentifierDescriptor"},
"description": "The data identifier unique to that object"
}
},

"type": {
"prototype": "core/meta/property-descriptor",
"values": {
Expand Down
Loading