Skip to content

Commit c58c091

Browse files
committed
- fix a bug on log message when logger does not yet exist
1 parent c7d1c6b commit c58c091

File tree

6 files changed

+202
-188
lines changed

6 files changed

+202
-188
lines changed

addons/system-admin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"models":{"138a81fa1f16435":{"_id":"138a81fa1f16435","_name":"RuntimeAdmin","_inherit":["RuntimeComponent"],"_core":true,"start":{},"designerWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null}},"135c71078810af2":{"_id":"135c71078810af2","_name":"RuntimeChannel","_inherit":["RuntimeComponent"],"sync":{},"loadSystem":{"params":[{"name":"system","type":"object"}]},"createSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"updateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"deleteSchema":{"params":[{"name":"id","type":"string"}]},"createModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"updateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"deleteModel":{"params":[{"name":"id","type":"string"}]},"createType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"updateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"deleteType":{"params":[{"name":"id","type":"string"}]},"createComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"updateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"deleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"createBehavior":{"params":[{"name":"behavior","type":"object"}]},"updateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"deleteBehavior":{"params":[{"name":"id","type":"string"}]},"_core":true}},"schemas":{"10374180581a41f":{"_id":"10374180581a41f","_name":"RuntimeAdmin","_inherit":["RuntimeComponent"],"_core":true,"designerWindow":"property","start":"method"},"104ad1f48518376":{"_id":"104ad1f48518376","_name":"RuntimeChannel","_core":true,"sync":"event","loadSystem":"event","createSchema":"event","updateSchema":"event","deleteSchema":"event","createModel":"event","updateModel":"event","deleteModel":"event","createType":"event","updateType":"event","deleteType":"event","createComponent":"event","updateComponent":"event","deleteComponent":"event","createBehavior":"event","updateBehavior":"event","deleteBehavior":"event"}},"types":{},"behaviors":{"1c00c107e01c9b3":{"_id":"1c00c107e01c9b3","component":"RuntimeAdmin","state":"start","action":"function start() {\n var RuntimeChannel = null,\n runtimeChannel = null;\n\n if (!this.require('channel-admin')) {\n RuntimeChannel = this.require('RuntimeChannel');\n runtimeChannel = new RuntimeChannel({\n '_id': 'channel-admin',\n '_core': true\n });\n \n runtimeChannel.on('send', function send(message) {\n this.require('admin').designerWindow().postMessage(JSON.stringify(message), '*');\n }, false, true);\n \n // schema change events\n runtimeChannel.on('createSchema', function createSchema(id, schema) {\n this.require('metamodel').schema(schema);\n this.require('metamodel').create();\n }, false, true);\n \n runtimeChannel.on('updateSchema', function updateSchema(id, schema) {\n this.require('metamodel').schema(schema);\n this.require('metamodel').create();\n }, false, true);\n \n runtimeChannel.on('deleteSchema', function deleteSchema(id) {\n var search = $db.RuntimeSchema.find({ '_id': id }),\n modelName = '',\n modelId = '';\n\n if (search.length) {\n modelName = search[0]._name;\n $db.RuntimeSchema.remove({ '_id': id });\n\n search = $db.RuntimeModel.find({ '_name': modelName });\n if (search.length) {\n modelId = search[0]._id;\n $db.RuntimeModel.remove({ '_id': modelId });\n $component.removeFromMemory(modelName);\n }\n\n search = $db.RuntimeGeneratedModel.find({ '_name': modelName });\n if (search.length) {\n modelId = search[0]._id;\n $db.RuntimeGeneratedModel.remove({ '_id': modelId });\n $component.removeFromMemory(modelName);\n }\n this.require('metamodel').create();\n }\n }, true, true);\n \n // model change events\n runtimeChannel.on('createModel', function createModel(id, model) {\n this.require('metamodel').model(model);\n this.require('metamodel').create();\n }, false, true);\n \n runtimeChannel.on('updateModel', function updateModel(id, model) {\n this.require('metamodel').model(model);\n this.require('metamodel').create();\n }, false, true);\n \n runtimeChannel.on('deleteModel', function deleteModel(id) {\n var search = $db.RuntimeModel.find({ '_id': id }),\n modelName = '',\n modelId = '';\n\n if (search.length) {\n modelName = search[0]._name;\n $db.RuntimeModel.remove({ '_id': id });\n $component.removeFromMemory(modelName);\n }\n\n search = $db.RuntimeGeneratedModel.find({ '_name': modelName });\n if (search.length) {\n modelId = search[0]._id;\n $db.RuntimeGeneratedModel.remove({ '_id': modelId });\n $component.removeFromMemory(modelName);\n }\n this.require('metamodel').create();\n }, true, true);\n \n // type change events\n runtimeChannel.on('createType', function createType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, false, true);\n \n runtimeChannel.on('updateType', function updateType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, false, true);\n \n runtimeChannel.on('deleteType', function deleteType(id) {\n $db.RuntimeType.remove({ 'name': id });\n this.require('metamodel').create();\n }, true, true);\n \n // component change events\n runtimeChannel.on('createComponent', function createComponent(model, component) {\n $db[model].insert(component);\n }, true, true);\n \n runtimeChannel.on('updateComponent', function updateComponent(id, collection, component) {\n $db[collection].update({'_id': id}, component, {'upsert': true});\n }, true, true);\n \n runtimeChannel.on('deleteComponent', function deleteComponent(id, collection) {\n $db[collection].remove({'_id': id});\n }, true, true);\n \n // behavior change events\n runtimeChannel.on('createBehavior', function createBehavior(component) {\n $db.RuntimeBehavior.insert(component);\n }, true, true);\n \n runtimeChannel.on('updateBehavior', function updateBehavior(id, behavior) {\n this.require(id).action(behavior.action);\n if (behavior.state === 'main') {\n this.require(behavior.component).main(); \n }\n }, false, true);\n \n runtimeChannel.on('deleteBehavior', function deleteBehavior(id) {\n $db.RuntimeBehavior.remove({'_id': id}); \n }, true, true);\n \n // System Designer event\n runtimeChannel.on('sync', function sync() {\n var designerWindow = this.require('admin').designerWindow(),\n system = null;\n \n this.require('admin').designerWindow(null);\n system = JSON.parse(this.require('db').system());\n designerWindow = this.require('admin').designerWindow(designerWindow);\n \n this.loadSystem(system);\n }, false, true);\n \n window.addEventListener('message', function (event) {\n var data = null;\n try {\n data = JSON.parse(event.data);\n if (data && \n typeof data.event !== 'undefined' && \n typeof data.from !== 'undefined' && \n typeof data.data !== 'undefined') {\n this.designerWindow(event.source);\n $db.RuntimeMessage.insert(data);\n }\n } catch(e) {\n }\n }.bind(this), false);\n \n this.require('logger').info('admin is started');\n } else {\n this.require('logger').info('admin is already started');\n }\n}","useCoreAPI":true,"core":true}},"components":{"RuntimeAdmin":{"admin":{"_id":"admin","_core":true,"designerWindow":null}}},"name":"system-admin","version":"0.8.1","description":"Runtime Component administration ","_id":"18ed81de331252c","master":false,"subsystem":false}
1+
{"models":{"138a81fa1f16435":{"_id":"138a81fa1f16435","_name":"RuntimeAdmin","_inherit":["RuntimeComponent"],"_core":true,"start":{},"designerWindow":{"type":"object","readOnly":false,"mandatory":false,"default":null}},"135c71078810af2":{"_id":"135c71078810af2","_name":"RuntimeChannel","_inherit":["RuntimeComponent"],"sync":{},"loadSystem":{"params":[{"name":"system","type":"object"}]},"createSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"updateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"deleteSchema":{"params":[{"name":"id","type":"string"}]},"createModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"updateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"deleteModel":{"params":[{"name":"id","type":"string"}]},"createType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"updateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"deleteType":{"params":[{"name":"id","type":"string"}]},"createComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"updateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"deleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"createBehavior":{"params":[{"name":"behavior","type":"object"}]},"updateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"deleteBehavior":{"params":[{"name":"id","type":"string"}]},"_core":true}},"schemas":{"10374180581a41f":{"_id":"10374180581a41f","_name":"RuntimeAdmin","_inherit":["RuntimeComponent"],"_core":true,"designerWindow":"property","start":"method"},"104ad1f48518376":{"_id":"104ad1f48518376","_name":"RuntimeChannel","_core":true,"sync":"event","loadSystem":"event","createSchema":"event","updateSchema":"event","deleteSchema":"event","createModel":"event","updateModel":"event","deleteModel":"event","createType":"event","updateType":"event","deleteType":"event","createComponent":"event","updateComponent":"event","deleteComponent":"event","createBehavior":"event","updateBehavior":"event","deleteBehavior":"event"}},"types":{},"behaviors":{"1c00c107e01c9b3":{"_id":"1c00c107e01c9b3","component":"RuntimeAdmin","state":"start","action":"function start() {\n var RuntimeChannel = null,\n runtimeChannel = null;\n\n if (!this.require('channel-admin')) {\n RuntimeChannel = this.require('RuntimeChannel');\n runtimeChannel = new RuntimeChannel({\n '_id': 'channel-admin',\n '_core': true\n });\n \n runtimeChannel.on('send', function send(message) {\n this.require('admin').designerWindow().postMessage(JSON.stringify(message), '*');\n }, false, true);\n \n // schema change events\n runtimeChannel.on('createSchema', function createSchema(id, schema) {\n this.require('logger').level('warn');\n this.require('metamodel').schema(schema);\n this.require('metamodel').create();\n this.require('logger').level('debug');\n }, false, true);\n \n runtimeChannel.on('updateSchema', function updateSchema(id, schema) {\n this.require('logger').level('warn');\n this.require('metamodel').schema(schema);\n this.require('metamodel').create();\n this.require('logger').level('debug');\n }, false, true);\n \n runtimeChannel.on('deleteSchema', function deleteSchema(id) {\n this.require('logger').level('warn');\n var search = $db.RuntimeSchema.find({ '_id': id }),\n modelName = '',\n modelId = '';\n\n if (search.length) {\n modelName = search[0]._name;\n $db.RuntimeSchema.remove({ '_id': id });\n\n search = $db.RuntimeModel.find({ '_name': modelName });\n if (search.length) {\n modelId = search[0]._id;\n $db.RuntimeModel.remove({ '_id': modelId });\n $component.removeFromMemory(modelName);\n }\n\n search = $db.RuntimeGeneratedModel.find({ '_name': modelName });\n if (search.length) {\n modelId = search[0]._id;\n $db.RuntimeGeneratedModel.remove({ '_id': modelId });\n $component.removeFromMemory(modelName);\n }\n this.require('metamodel').create();\n }\n this.require('logger').level('debug');\n }, true, true);\n \n // model change events\n runtimeChannel.on('createModel', function createModel(id, model) {\n this.require('logger').level('warn');\n this.require('metamodel').model(model);\n this.require('metamodel').create();\n this.require('logger').level('debug');\n }, false, true);\n \n runtimeChannel.on('updateModel', function updateModel(id, model) {\n this.require('logger').level('warn');\n this.require('metamodel').model(model);\n this.require('metamodel').create();\n this.require('logger').level('debug');\n }, false, true);\n \n runtimeChannel.on('deleteModel', function deleteModel(id) {\n this.require('logger').level('warn');\n var search = $db.RuntimeModel.find({ '_id': id }),\n modelName = '',\n modelId = '';\n\n if (search.length) {\n modelName = search[0]._name;\n $db.RuntimeModel.remove({ '_id': id });\n $component.removeFromMemory(modelName);\n }\n\n search = $db.RuntimeGeneratedModel.find({ '_name': modelName });\n if (search.length) {\n modelId = search[0]._id;\n $db.RuntimeGeneratedModel.remove({ '_id': modelId });\n $component.removeFromMemory(modelName);\n }\n this.require('metamodel').create();\n this.require('logger').level('debug');\n }, true, true);\n \n // type change events\n runtimeChannel.on('createType', function createType(id, type) {\n this.require('logger').level('warn');\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n this.require('logger').level('debug');\n }, false, true);\n \n runtimeChannel.on('updateType', function updateType(id, type) {\n this.require('logger').level('warn');\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n this.require('logger').level('debug');\n }, false, true);\n \n runtimeChannel.on('deleteType', function deleteType(id) {\n this.require('logger').level('warn');\n $db.RuntimeType.remove({ 'name': id });\n this.require('metamodel').create();\n this.require('logger').level('debug');\n }, true, true);\n \n // component change events\n runtimeChannel.on('createComponent', function createComponent(model, component) {\n $db[model].insert(component);\n }, true, true);\n \n runtimeChannel.on('updateComponent', function updateComponent(id, collection, component) {\n $db[collection].update({'_id': id}, component, {'upsert': true});\n }, true, true);\n \n runtimeChannel.on('deleteComponent', function deleteComponent(id, collection) {\n $db[collection].remove({'_id': id});\n }, true, true);\n \n // behavior change events\n runtimeChannel.on('createBehavior', function createBehavior(component) {\n $db.RuntimeBehavior.insert(component);\n }, true, true);\n \n runtimeChannel.on('updateBehavior', function updateBehavior(id, behavior) {\n this.require(id).action(behavior.action);\n if (behavior.state === 'main') {\n this.require(behavior.component).main(); \n }\n }, false, true);\n \n runtimeChannel.on('deleteBehavior', function deleteBehavior(id) {\n $db.RuntimeBehavior.remove({'_id': id}); \n }, true, true);\n \n // System Designer event\n runtimeChannel.on('sync', function sync() {\n var designerWindow = this.require('admin').designerWindow(),\n system = null;\n \n this.require('admin').designerWindow(null);\n system = JSON.parse(this.require('db').system());\n designerWindow = this.require('admin').designerWindow(designerWindow);\n \n this.loadSystem(system);\n }, false, true);\n \n window.addEventListener('message', function (event) {\n var data = null;\n try {\n data = JSON.parse(event.data);\n if (data && \n typeof data.event !== 'undefined' && \n typeof data.from !== 'undefined' && \n typeof data.data !== 'undefined') {\n this.designerWindow(event.source);\n $db.RuntimeMessage.insert(data);\n }\n } catch(e) {\n }\n }.bind(this), false);\n \n this.require('logger').info('admin is started');\n } else {\n this.require('logger').info('admin is already started');\n }\n}","useCoreAPI":true,"core":true}},"components":{"RuntimeAdmin":{"admin":{"_id":"admin","_core":true,"designerWindow":null}}},"name":"system-admin","version":"0.9.0","description":"Runtime Component administration ","_id":"18ed81de331252c","master":false,"subsystem":false}

0 commit comments

Comments
 (0)