Move resources between files

In any large ontology project, models should be split into multiple modules. Each module would be a separate file, and owl:imports statements would link them together. In these settings, it is a very common requirement to move resource definitions between files. While it is always possible to manually copy resource definitions for example with a text editor on RDF source level, this is extremely inconvenient and error prone. In particular it is easy to break references within an RDF graph. TopBraid Composer therefore helps you perform several refactorings in the user interface.

Depending on your project configuration, you have two options to move resources between files:

  1. If you want to move resources from one imported module into another module (within the current model), use the Triples View.
  2. If you need to move resources from a model into an external file (not necessarily connected via imports), use the Project Explorer.

Both options are described below. Note that moving resources between models is fundamentally different from moving resources into namespaces. While namespaces are typically used to identify a certain model, RDF allows you to use resources from any namespace in any file. This means, if you move a resource from one model to another, you may also consider to change its namespace to the default namespace in that target model, but you are not forced to.

 

Option 1: Moving resources using the Triples View

The upper part of the Triples View shows a list of all modules (sub-graphs) of the current model. You can drag and drop triples from the lower part, or for example from the Basket View onto the models. With the Basket, the steps are similar to the procedure described in Option 2 below, but drag them over the target graph in the Triples View instead of the target file in the Project Explorer. You should see something like the screenshot below:

Alternatively, you can select one or more triples from the lower part and then drag them into the target model. For example, in an ontology about units, assume you have started with one large model (containing all units such as meters and katal) and later you find that you should simplify the model. You could for example create a submodel for all chemistry units, one for physics etc. You would create the domain specific models (here: abbreviated with n2unitsChem for the chemistry ontology) and then import the base ontology (n1units) into it. As the next step, we can move all chemistry related units into the new, empty chemistry ontology.

In order to prepare this, we should first identify those resources that shall be moved, and change their namespace. The Batch Operation "Change Namespace" can do this for all resources in the basket. After this, the triples related to the chemistry domain can easily identified in the Triples View, as shown below. Select them and then drag them into the target file as shown.

 

Option 2: Moving resources using the Project Explorer

TopBraid Composer can be used to move resources (and their depending triples) from the currently open file to another file in the Project Explorer. To do so, you can simply drag a resource onto the name of the file in the Project Explorer. However, in most cases users may want to move multiple resources at the same time, so that their cross-references can be maintained correctly. We therefore suggest to use the Basket View to collect all resources that shall be moved (e.g., using the Add all individuals item in its drop down menu).

Let's assume we want to move all individuals from a file countries.ttl into a new file europe.ttl.

  1. Create a new (empty) file with a new namespace:


  2. Collect all individuals from the current file into the basket.
  3. Select all resources from the basket and drag them onto the new file:


  4. A dialog will pop up to ask you to change the namespaces (often "No" is the best choice):


  5. Now when you open the new file you should add countries.ttl to its imports, so that it can resolve the type of the individuals.