-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathICoreDefaultConfig.json
83 lines (83 loc) · 10.1 KB
/
ICoreDefaultConfig.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
"templates": {
"coreTraverse": {
"displayName": "Traverse Model",
"description": "Illustrates how to use core.traverse to visit each node in a sub-tree.",
"script": "function (callback) {\n var activeNode = this.activeNode,\n core = this.core,\n logger = this.logger;\n\n function atNode(node, done) {\n try {\n var metaNode = core.getBaseType(node),\n name = core.getAttribute(node, 'name'),\n path = core.getPath(node),\n metaType;\n\n if (metaNode) {\n metaType = core.getAttribute(metaNode, 'name');\n } else {\n // The root-node does not have a meta node.\n metaType = 'undefined';\n }\n\n logger.info('[', path, '] - ', name, 'is of type', metaType); \n done();\n } catch (err) {\n done(err);\n }\n }\n\n core.traverse(activeNode, null, atNode, callback);\n}",
"default": false
},
"blobClient": {
"displayName": "BlobClient - store and return files",
"description": "Illustrates how to use the blob-client and link to the artifacts in the result.",
"script": "function (callback) {\n var self = this,\n activeNode = this.activeNode,\n core = this.core,\n logger = this.logger,\n blobClient = this.blobClient,\n artifact;\n \n artifact = self.blobClient.createArtifact('MyArtifact');\n \n artifact.addFiles({\n 'hello.txt': 'Hello world!',\n 'dir/hello2.txt': 'Hello from folder!'\n })\n .then(function (fileMetadataHashes) {\n // We can link to each individual file\n self.logger.info('Added files to blob-storage', fileMetadataHashes);\n self.result.addArtifact(fileMetadataHashes[0]);\n self.result.addArtifact(fileMetadataHashes[1]);\n // and/or save the full artifact and link to it (will be a zip file).\n return artifact.save();\n })\n .then(function (artifactHash) {\n self.result.addArtifact(artifactHash);\n self.logger.info('Added complex artifact to blob-storage', artifactHash);\n self.result.setSuccess(true);\n // A plugin should always return with a result, in iCore it's optional and\n // used only to display the plugin result dialog.\n callback(null, self.result);\n })\n .catch(function (err) {\n callback(err);\n });\n}",
"default": false
},
"activeNode": {
"displayName": "Minimal",
"description": "Minimal example logging the name of the active node.",
"script": "function (callback) {\n var activeNode = this.activeNode,\n core = this.core,\n logger = this.logger;\n \n logger.debug('path:', core.getPath(activeNode));\n logger.info('name:', core.getAttribute(activeNode, 'name'));\n logger.warn('pos :', core.getRegistry(activeNode, 'position'));\n logger.error('guid:', core.getGuid(activeNode));\n callback();\n}",
"default": true
},
"meta": {
"displayName": "Meta nodes",
"description": "Example showing how to get info about the meta-model.",
"script": "function (callback) {\n var activeNode = this.activeNode,\n core = this.core,\n logger = this.logger,\n msg,\n path2MetaNode,\n metaNode,\n baseNode,\n metaName,\n metaJson;\n \n // The 'plugin' is initialized with a map from name to the meta-node in this.META\n // from the core we can get a map from unique paths to the meta-node.\n path2MetaNode = core.getAllMetaNodes(activeNode);\n\n for (metaName in this.META) {\n logger.info('====== ', metaName, ' ======');\n metaNode = this.META[metaName];\n logger.info('name', core.getAttribute(metaNode, 'name'));\n logger.info('path', core.getPath(metaNode));\n baseNode = core.getBase(metaNode);\n\n if (baseNode) {\n logger.info('base', core.getAttribute(baseNode, 'name'), '[', core.getPath(baseNode), ']');\n } else {\n logger.info('base None');\n }\n\n logger.debug('Defines meta definitions :', JSON.stringify(core.getOwnJsonMeta(metaNode), null, 2));\n metaJson = core.getJsonMeta(metaNode);\n logger.debug('Resolved meta definitions:', JSON.stringify(metaJson, null, 2));\n\n if (metaJson.children.items.length > 0) {\n msg = 'Can contain (and their derived types): ';\n metaJson.children.items.forEach(function (childPath) {\n var childType = path2MetaNode[childPath];\n // We check in case the meta is inconsisent.\n if (childType) {\n msg += '\"' + core.getAttribute(childType, 'name') + '\" ';\n } else {\n msg += '[' + childPath + '] ';\n }\n });\n \n logger.info(msg);\n }\n\n //TODO: Similar for pointers and sets, aspects and constraints..\n }\n\n callback();\n}",
"default": false
},
"loadNodeMap": {
"displayName": "Preload nodes",
"description": "Example showing how to preload and retrieve a map of all nodes in a subtree.",
"script": "function (callback) {\n var self = this,\n activeNode = this.activeNode,\n core = this.core,\n logger = this.logger;\n\n this.loadNodeMap(activeNode)\n .then(function (nodes) {\n var path;\n for (path in nodes) {\n logger.debug('[', path, '] has name', core.getAttribute(nodes[path], 'name'));\n }\n\n logger.info('Total number of nodes in subtree:', Object.keys(nodes).length);\n\n callback();\n }).catch(function (err) {\n self.logger.error(err.stack);\n callback(err);\n });\n}",
"default": false
},
"pyActiveNode": {
"displayName": "Minimal",
"description": "Minimal example logging the name of the active node.",
"script": "class PythonPlugin(PluginBase):\n def main(self):\n active_node = self.active_node\n core = self.core\n logger = self.logger\n logger.debug('path: {0}'.format(core.get_path(active_node)))\n logger.info('name: {0}'.format(core.get_attribute(active_node, 'name')))\n logger.warn('pos : {0}'.format(core.get_registry(active_node, 'position')))\n logger.error('guid: {0}'.format(core.get_guid(active_node)))\n",
"default": true,
"language": "python"
},
"pyMeta": {
"displayName": "Meta nodes",
"description": "Example showing how to get info about the meta-model.",
"script": "class PythonPlugin(PluginBase):\n def main(self):\n core = self.core\n root_node = self.root_node\n active_node = self.active_node\n logger = self.logger\n path_2_meta_node = core.get_all_meta_nodes(active_node)\n for meta_name in self.META:\n logger.info('====== {0} ======'.format(meta_name))\n meta_node = self.META[meta_name]\n logger.info('name {0}'.format(core.get_attribute(meta_node, 'name')))\n logger.info('path {0}'.format(core.get_path(meta_node)))\n\n base_node = core.get_base(meta_node)\n if base_node:\n logger.info('base {0} [{1}]'.format(core.get_attribute(base_node, 'name'), core.get_path(base_node)))\n else:\n logger.info('base None')\n\n logger.debug('Defines meta definitions: {0}'.format(core.get_own_json_meta(meta_node)))\n meta_json = core.get_json_meta(meta_node)\n logger.info('Resolved meta definitions: {0}'.format(meta_json))\n\n if len(meta_json['children']['items']) > 0:\n msg = 'Can contain (and their derived types): '\n for child_path in meta_json['children']['items']:\n child_type = path_2_meta_node[child_path]\n if child_type:\n msg += '\"{0}\"'.format(core.get_attribute(child_type, 'name'))\n else:\n msg += '[{0}]'.format(child_path)\n\n logger.info(msg)\n",
"default": false,
"language": "python"
},
"pyLoadNodeMap": {
"displayName": "Preload nodes",
"description": "Example showing how to preload and retrieve a map of all nodes in a subtree.",
"script": "class PythonPlugin(PluginBase):\n def main(self):\n active_node = self.active_node\n core = self.core\n logger = self.logger\n nodes = core.load_sub_tree(active_node)\n for node in nodes:\n logger.debug('[{0}] has name: {1}'.format(core.get_path(node),core.get_attribute(node, 'name')))\n\n logger.info('Total number of nodes in the subtree: {0}'.format(len(nodes)))\n",
"default": false,
"language": "python"
},
"pyCoreTraverse": {
"displayName": "Traverse Model",
"description": "Illustrates how to use core.traverse to visit each node in a sub-tree.",
"script": "class PythonPlugin(PluginBase):\n def main(self):\n active_node = self.active_node\n core = self.core\n logger = self.logger\n\n def at_node(node):\n meta_node = core.get_base_type(node)\n name = core.get_attribute(node, 'name')\n path = core.get_path(node)\n meta_type = 'undefined'\n if meta_node:\n meta_type = core.get_attribute(meta_node, 'name')\n logger.info('[{0}] - {1} is of type \"{2}\"'.format(path, name, meta_type))\n\n self.util.traverse(active_node, at_node)\n",
"default": false,
"language": "python"
},
"pyBlobClient": {
"displayName": "BlobClient - store and return files",
"description": "Illustrates how to use the blob-client and link to the artifacts in the result.",
"script": "class PythonPlugin(PluginBase):\n def main(self):\n active_node = self.active_node\n core = self.core\n logger = self.logger\n \n # Saves multiple files and bundles and attaches them to the result.\n artifact_hash = self.add_artifact('MyArtifact', {\n 'hello.txt': 'Hello world!',\n 'dir/hello2.txt': 'Hello from folder!'\n })\n\n logger.info('The artifact is stored under hash: {0}'.format(artifact_hash))\n\n # Saves a single text file and attaches it to the result.\n file_hash = self.add_file('myFile.txt', 'Hello again!')\n logger.info('The file is stored under hash: {0}'.format(file_hash))\n",
"default": false,
"language": "python"
}
},
"consoleWindow": {
"verticalOrientation": true,
"logLevel": "debug"
},
"codeEditor": {
"autoSave": false,
"autoSaveInterval": 2000,
"scriptCodeAttribute": {
"javascript": "scriptCode",
"python": "pythonCode"
},
"language": "javascript"
},
"defaultPluginId": ""
}