浏览代码

Merge branch 'testing' of msdl.uantwerpen.be:yentl/modelverse into testing

Yentl Van Tendeloo 8 年之前
父节点
当前提交
240fb26de6
共有 6 个文件被更改,包括 76 次插入354 次删除
  1. 1 1
      doc/Makefile
  2. 1 0
      doc/index.rst
  3. 0 98
      doc/mini_modify.rst
  4. 0 211
      doc/mvc.rst
  5. 28 22
      doc/wrappers.rst
  6. 46 22
      wrappers/modelverse.py

+ 1 - 1
doc/Makefile

@@ -3,7 +3,7 @@
 
 # You can set these variables from the command line.
 SPHINXOPTS    =
-SPHINXBUILD   = sphinx-build
+SPHINXBUILD   = python -m sphinx
 PAPER         =
 BUILDDIR      = _build
 

+ 1 - 0
doc/index.rst

@@ -18,4 +18,5 @@ Contents:
    Modelling Language <modellanguage>
    Wrappers <wrappers>
    Common problems and solutions <problems>
+   Interfaces <interface>
    Internals <internal>

+ 0 - 98
doc/mini_modify.rst

@@ -1,98 +0,0 @@
-Model Modification Interface
-============================
-
-Model operations are grouped into a separate category of operations, as they work at the model-level instead of the root-level.
-In the MvC, these operations can only be executed after a *model_modify* operation.
-We distinguish two modes of access: read/write, and read-only.
-Read-only commands are always available (given that the model itself can be opened in the MvC layer), whereas read/write operations are only optionally visible.
-
-Read-only
----------
-
-The first set of operations are the read-only operations.
-
-list
-^^^^
-
-Get a list of all elements in the model.
-Ignores hidden elements (*i.e.*, name starts with __), as these are artefacts of other operations.
-
-list_full
-^^^^^^^^^
-
-Get a full list of all elements in the model.
-
-nice_list
-^^^^^^^^^
-
-Get a pretty-printed list of alle elements in the model, including the value of their attributes.
-
-types
-^^^^^
-
-Get a list of all elements that can be instantiated in the metamodel.
-Ignores hidden elements of the metamodel.
-
-read
-^^^^
-
-Get detailed information on a specific element.
-
-verify
-^^^^^^
-
-Check if the model conforms to its resolved metamodel.
-
-exit
-^^^^
-
-Exit the model modification interface.
-
-Read/Write
-----------
-
-The second set of operations are the read/write operations, which are able to alter the model.
-Note that in the Modelverse, changes are immediately visible to other users as well.
-
-instantiate
-^^^^^^^^^^^
-
-Instantiate an element of the metamodel.
-This only creates the raw element, without any of its slots filled in or any associations.
-Used for both nodes and edges (classes and associations).
-
-delete
-^^^^^^
-
-Delete an element of the model.
-For nodes (classes), all related associations are removed as well.
-
-attr_add
-^^^^^^^^
-
-Instantiate a new attribute for this element.
-
-attr_add_code
-^^^^^^^^^^^^^
-
-Instantiate a new attribute for this element, using the code constructors for the value.
-
-attr_del
-^^^^^^^^
-
-Remove an attribute value of this element.
-
-attr_modify
-^^^^^^^^^^^
-
-Modify an existing attribute of this element.
-
-retype
-^^^^^^
-
-Change the type of an element.
-
-upload
-^^^^^^
-
-Overwrite the current model with an uploaded model through the model constructors.

+ 0 - 211
doc/mvc.rst

@@ -1,211 +0,0 @@
-Modelverse Core
-===============
-
-The Modelverse Core (MvC) is an example (meta-)modelling interface that can be used with a plethora of tools.
-While the MvC itself is rather simple and its interface is kind of hard to use, wrappers can be put in front of it to make the behaviour much friendlier.
-For example, a simple call to instantiate a specific class requires several XML/HTTPRequest calls back and forth.
-A simple wrapper can abstract from this complexity, while retaining the elegance of the versatile interface.
-
-The MvC at the moment is written for a simple textual interface, but can easily be augmented with additional information to make it more computer-readable.
-For example, requests and replies can make use of IDs to distinguish or identify the information being passed around, or perform context switches.
-
-The MvC manages the Modelverse information visible to all users.
-Since all information in the Modelverse is stored as a model, this user and model management information is stored as a model as well: the Core model.
-The core model is a mega-model that provides links to all other models stored in the Modelverse (including itself!).
-For each of these models, additional meta-information is stored within the Core model.
-Only admin users have read and write permission to the Core model by default: this model is used for all other operations.
-While some operations are allowed for other users, such as modifying the permissions of your own file, this write must be done with administrator permissions.
-Therefore, this MvC interface provides some specialized operations which check for the necessary permissions (*e.g.*, owner of the model), and then apply the requested operation with admin permissions.
-
-An overview of the MvC interface is shown below.
-A complete overview of the code is shown in the :download:`MvC core algorithm <../core/core_algorithm.alc>`
-None of these operations manipulate the model at a finer granularity: for that we use the :download:`Mini-Modify <../core/mini_modify.alc>` code, which is sometimes called.
-A detailed explanation of its operations is shown later.
-
-Model operations
-----------------
-
-The first set of operations are basic model management operations.
-
-model_add
-^^^^^^^^^
-
-Adds a new model to the Modelverse.
-Model content is specified using model constructors, which can be generated with the model compiler.
-
-model_modify
-^^^^^^^^^^^^
-
-Switches the interface to model-scope operations of a specific model.
-
-model_list
-^^^^^^^^^^
-
-Give an overview list of all models, showing their name and type.
-
-model_list_full
-^^^^^^^^^^^^^^^
-
-Give a detailed overview list of all models, showing their name, type, permissions, owner, and group.
-
-model_overwrite
-^^^^^^^^^^^^^^^
-
-Overwrite an existing model. Similar to *model_add*, but keeps existing meta-information to the model intact.
-
-verify
-^^^^^^
-
-Verify whether a model conforms to the specified metamodels.
-
-Transformation-specific operations
-----------------------------------
-
-The second set of operations are specific to model transformations.
-
-transformation_add_MT_language
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Create a new RAMified metamodel out of several existing metamodels.
-The generated metamodel can be used to instantiate a model transformation.
-
-transformation_add_MT
-^^^^^^^^^^^^^^^^^^^^^
-
-Add a new model transformation schedule, including the rules.
-
-transformation_add_AL
-^^^^^^^^^^^^^^^^^^^^^
-
-Add a new action language model that operates on models.
-
-transformation_add_MANUAL
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Add a new manual model transformation.
-
-transformation_execute
-^^^^^^^^^^^^^^^^^^^^^^
-
-Execute an existing transformation. Automatically finds out the type and executes the relevant interface.
-
-transformation_list
-^^^^^^^^^^^^^^^^^^^
-
-List known transformations and their type.
-
-transformation_list_full
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-List known transformations and their type, as well as permissions, owner, and group.
-
-transformation_detail
-^^^^^^^^^^^^^^^^^^^^^
-
-Give details on a single transformation, such as the source and target formalisms.
-
-transformation_RAMify
-^^^^^^^^^^^^^^^^^^^^^
-
-RAMify an existing metamodel again.
-Useful if the related metamodel has changed.
-
-Process operations
-------------------
-
-The third set of operations is related to the execution and operation on an FTG+PM.
-
-process_execute
-^^^^^^^^^^^^^^^
-
-Execute an existing process model.
-
-Model permission operations
----------------------------
-
-The fourth set of operations is related to model access control management.
-
-permission_modify
-^^^^^^^^^^^^^^^^^
-
-Modifies the permission of a specified model.
-
-permission_owner
-^^^^^^^^^^^^^^^^
-
-Modifies the owner of a specified model.
-
-permission_group
-^^^^^^^^^^^^^^^^
-
-Modifies the group of a specified model.
-
-Group operations
-----------------
-
-The fifth set of operations is related to the management of groups.
-
-group_create
-^^^^^^^^^^^^
-
-Create a new group, and become its administrator.
-
-group_delete
-^^^^^^^^^^^^
-
-Delete a group for which you are administrator.
-
-group_owner_add
-^^^^^^^^^^^^^^^
-
-Add a new user as administrator to a group of which you are an administrator.
-
-group_owner_delete
-^^^^^^^^^^^^^^^^^^
-
-Remove a user as administrator from a group of which you are an administrator.
-
-group_join
-^^^^^^^^^^
-
-Add a new user to a group of which you are an administrator.
-
-group_kick
-^^^^^^^^^^
-
-Remove a user from a group of which you are an administrator.
-
-group_list
-^^^^^^^^^^
-
-List all known groups.
-
-Admin operations
-----------------
-
-The sixth set of operations is related to administrator operations.
-
-admin_promote
-^^^^^^^^^^^^^
-
-Promote another user as administrator as well.
-
-admin_demote
-^^^^^^^^^^^^
-
-Demote another user from administrator status.
-
-General operations
-------------------
-
-The final set of operations consists of miscellaneous operations.
-
-self-destruct
-^^^^^^^^^^^^^
-
-Destroy the current user, revoking all permissions of owning models.
-
-exit
-^^^^
-
-Exit the current task, while keeping the user intact.

+ 28 - 22
doc/wrappers.rst

@@ -163,49 +163,55 @@ Functions
    Optionally, a dictionary of *callbacks* can be defined with as key the operation that is being executed, and value the actual callback.
    The callbacks must be similarly defined just like how they were defined in the individual *transformation_execute* operations.
 
-.. function:: permission_modify()
+.. function:: permission_modify(model_name, permissions)
 
-   Expl
+   Change the permissions of *model_name* to *permissions*.
+   The permissions is a string of three characters, each between 0 and 2.
+   The format is similar to the UNIX permission system: the leftmost character is the permission for the owning user, the middle character for members of the ownin group, and the rightmost character for all other users.
+   Character 0 signifies no access, 1 read-only access, and 2 full read/write access.
 
-.. function:: permission_owner()
+.. function:: permission_owner(model_name, owner)
 
-   Expl
+   Change the owner of the model *model_name* to *owner*.
 
-.. function:: permission_group()
+.. function:: permission_group(model_name, group)
 
-   Expl
+   Change the owning group of the model *model_name* to *group*.
 
-.. function:: group_create()
+.. function:: group_create(group_name)
 
-   Expl
+   Create a new group named *group_name*.
 
-.. function:: group_delete()
+.. function:: group_delete(group_name)
 
-   Expl
+   Delete the group named *group_name*.
 
-.. function:: group_owner_add()
+.. function:: group_owner_add(group_name, user_name)
 
-   Expl
+   Add user *user_name* as an owner of group *group_name*.
+   This automatically makes the user join the specified group if this was not yet the case.
 
-.. function:: group_owner_delete()
+.. function:: group_owner_delete(group_name, user_name)
 
-   Expl
+   Remove user *user_name* as an owner of group *group_name*.
 
-.. function:: group_join()
+.. function:: group_join(group_name, user_name)
 
-   Expl
+   Have user *user_name* join the group *group_name* as an ordinary user.
 
-.. function:: group_kick()
+.. function:: group_kick(group_name, user_name)
 
-   Expl
+   Remove user *user_name* from the group *group_name*.
+   If the user was an owner of the group, these permissions are also revoked.
 
-.. function:: admin_promote()
+.. function:: admin_promote(user_name)
 
-   Expl
+   Promote user *user_name* to admin status.
+   Admin status grants users access to all operations.
 
-.. function:: admin_demote()
+.. function:: admin_demote(user_name)
 
-   Expl
+   Demote user *user_name* to ordinary user.
 
 .. function:: element_list(model_name)
 

+ 46 - 22
wrappers/modelverse.py

@@ -624,53 +624,77 @@ def process_execute(process_name, prefix, callbacks):
                     _input("exit")
                     mode = MODE_MODELLING
 
-def permission_modify():
+def permission_modify(model_name, permissions):
     """Modify permissions of a model."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["permission_modify", model_name, permissions])
+    _handle_output("Success")
 
-def permission_owner():
+def permission_owner(model_name, owner):
     """Modify the owning user of a model."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["permission_owner", model_name, owner])
+    _handle_output("Success")
 
-def permission_group():
+def permission_group(model_name, group):
     """Modify the owning group of a model."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["permission_group", model_name, group])
+    _handle_output("Success")
 
-def group_create():
+def group_create(group_name):
     """Create a new group."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["group_create", group_name])
+    _handle_output("Success")
 
-def group_delete():
+def group_delete(group_name):
     """Delete a group of which you are an owner."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["group_delete", group_name])
+    _handle_output("Success")
 
-def group_owner_add():
+def group_owner_add(group_name, user_name):
     """Add a new owning user to a group you own."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["owner_add", group_name, user_name])
+    _handle_output("Success")
 
-def group_owner_delete():
+def group_owner_delete(group_name, user_name):
     """Delete an owning user to a group you own."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["owner_delete", group_name, user_name])
+    _handle_output("Success")
 
-def group_join():
+def group_join(group_name, user_name):
     """Add a new user to a group you own."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["group_join", group_name, user_name])
+    _handle_output("Success")
 
-def group_kick():
+def group_kick(group_name, user_name):
     """Delete a user from a group you own."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["group_kick", group_name, user_name])
+    _handle_output("Success")
 
 def group_list():
     """List existing groups."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["group_list"])
+    _handle_output("Success")
 
-def admin_promote():
+def admin_promote(user_name):
     """Promote a user to admin status."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["admin_promote", user_name])
+    _handle_output("Success")
 
 def admin_demote():
     """Demote a user from admin status."""
-    raise NotImplementedError()
+    _goto_mode(MODE_MODELLING)
+    _input(["admin_demote", user_name])
+    _handle_output("Success")
 
 # Actual operations on the model
 def element_list(model_name):