75 | | You can also use all [[SemanticQuery|querying]] and [[RefactoringSteps|refactoring functionalities]]. |
| 85 | = Graph operations example = |
| 86 | With the NIF database, you may have more graphs. |
| 87 | The graphs does not affect each other, so every graph has its own database, and |
| 88 | backups, etc. After restarting the tool, the last used graph will be loaded. |
| 89 | Let's see an example: |
| 90 | |
| 91 | {{{ |
| 92 | % By default a refactorerl_0 named graph created. |
| 93 | % So after the first startup, the ri:actual_graph/0 |
| 94 | % operation should print refactorerl_0. |
| 95 | ri:actual_graph(). |
| 96 | refactorerl_0 |
| 97 | |
| 98 | % Now create a graph. The name of the graph must be an atom. |
| 99 | ri:create_graph(graph_name). |
| 100 | |
| 101 | % You can list the created graphs. |
| 102 | ri:ls_graphs(). |
| 103 | [graph_name, refactorerl_0] |
| 104 | |
| 105 | % Load the previously created graph. |
| 106 | ri:load_graph(graph_name). |
| 107 | ok |
| 108 | ri:actual_graph(). |
| 109 | graph_name |
| 110 | |
| 111 | % You may want rename the refactorerl_0 graph to someting else. |
| 112 | % You can even rename the actual graph. |
| 113 | ri:rename_graph(refactorerl_0, some_other_name). |
| 114 | ok |
| 115 | ri:ls_graphs(). |
| 116 | [graph_name, some_other_name] |
| 117 | |
| 118 | % Now delete the graph which is not loaded. |
| 119 | % Of course, you cannot delete the actual graph. |
| 120 | % Warning: It deletes the whole graph from the disk, |
| 121 | % so it cannot be recovered later. |
| 122 | ri:delete_graph(some_other_name). |
| 123 | |
| 124 | % Or you can just delete all graphs. |
| 125 | % After the deletion, it creates the default refactorerl_0 graph. |
| 126 | ri:delete_all_graphs(). |
| 127 | ok |
| 128 | ri:ls_graphs(). |
| 129 | refactorerl_0 |
| 130 | |
| 131 | }}} |
| 132 | |
| 133 | If something happened to database, then after startup you will get a message about it |
| 134 | and a new default graph will be created. If refactorerl_0 exists, then refactorerl_1 will |
| 135 | be created, and so on. The corrupted database will not be deleted by the system. |
| 136 | If the user wants to load a corrupted backup, then the system will print an error message, |
| 137 | and the backup will have a 'corrutped_' prefix (so the system renames it), and the graph |
| 138 | will remain the same. |