LoadTopobase

Syntax

<web service URL>/LoadTopobase?mon=<folder moniker>

Description

The LoadTopobase operation is used to load a topobase from file to repository using POST request.

Comments

Operation parameters contain a moniker of the parent folder in repository, to which a topobase is to be loaded. The moniker is specified in the following format: <repository connection moniker>!<folder id/key>. A topobase to be loaded should be included in the POST request.

The operation results in the key of created repository object.

Example

Below is the example of code of HTML page that is used to load a topobase file to repository. A form implemented on the HTML page is sent as a value. This form contains a control that opens the topobase file. The data is sent by clicking the hyperlink.

To reduce the example, the PostRequest function script is excluded from the code, the function is used to execute operations in JSON format. See code of this function in the Connecting to Repository article.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Use of the LoadTopobase operation</title>
</head>
<body>
    <script type="text/javascript">
        var svc = "http://localhost:9090/axis2/services/PP.SOM.Som";
        var folderId = "F_TOPOBASE";
        function getFormElement(id) {
            var res = document.getElementById(id);
            return res;
        }
        function sendForm(form, url) {
            var sta = getFormElement('status');
            sta.innerHTML = '';
            var xhr = new XMLHttpRequest();
            xhr.open('POST', url, false);
            var data = new FormData(form);
            xhr.send(data);
            if (xhr.status == 200) {
                sta.innerHTML = "Response:<p>" + xhr.responseText + "<p>";
            } else {
                sta.innerHTML = "Request execution error:<p>" + xhr.responseText +  "<p>";
            }
        }
        // Connect to repository and send request to execute the LoadTopobase operation
        function LoadTopobase(form) {
            var OpenMetabase = { "OpenMetabase": { "tDef": { "id": "Warehouse" }, "tCreds": { "user": { "id": "User" }, "pass": "Password" } } };
            //Repository connection
            var OpenMetabaseResult = PostRequest(svc, OpenMetabase);
            //Send data to server
            return sendForm(form, svc + "/LoadTopobase?mon=" + OpenMetabaseResult.OpenMetabaseResult.id + "!" + folderId);
        }
        /*
            PostRequest script
        */
    </script>
    <!--A form, which data is sent to server-->
    <form id="fileForm" action="" method="" enctype="multipart/form-data" onsubmit="LoadTopobase(this)">
        <div>
            <input type="file" name="file" id="file" />
        </div>
    </form>
    <!--Hyperlink for sending data-->
    <div>
        <a href="javascript:LoadTopobase(getFormElement('fileForm'))">LoadTopobase</a>
    </div>
    <!--A field for creating operation execution state-->
    <div id="status"></div>
</body>
</html>

See also:

Additional Operations