# データベースのマスターデータ取得

<div align="left"><figure><img src="/files/ejBZZeDrq5sOKCU38C1E" alt=""><figcaption></figcaption></figure></div>

以下の説明で使用されている画像は、PostgreSQL連携のイメージとなります。\
他のデータベース連携も同じ画面構成です。

## 機能概要

* **データベースのマスターデータ取得**はデータベースからi-Reporterへ**i-Repo Gatewayを利用**して連携を行います。\
  本機能は、マスター選択クラスターのGateway連携で利用するGatewayのアクションファイルの作成までを行います。

<table><thead><tr><th>連携方向</th><th width="214.33333333333331">機能説明</th><th>実行タイミング</th></tr></thead><tbody><tr><td>データベース→i-Reporter連携</td><td>データベースのデータをi-Repo Gatewayを利用してi-Reporter入力帳票のマスター選択クラスターへ取得します。</td><td>i-Reporterのマスター選択クラスターのデータ取得</td></tr></tbody></table>

## マッピング設定の手順

以下の手順に従ってマッピング設定を行ってください。

### 1. データベースの連携パターンの選択

* **データベースのマスターデータ取得**メニューをクリックして新規のマッピングを追加します。

<figure><img src="/files/lw8tlgSxVzHE3QbPDozx" alt=""><figcaption></figcaption></figure>

### 2. マッピングコード・名称の設定

* **マッピングコード**と**マッピング名称**を設定します。
* マッピングコードは、**i-Repo Link環境内の全てのマッピング設定を一意に識別するキー**になります。

<figure><img src="/files/I68RpEiGOgGWjd318IUA" alt=""><figcaption></figcaption></figure>

### 3. 連携元のデータベースのデータソースとテーブル／ビューの選択

* 連携元としてデータベースの**データソース**と**テーブルまたはビュー**を選択します。

<figure><img src="/files/Q1dN79y7S5vrY2r4afDp" alt=""><figcaption></figcaption></figure>

* データソースの追加・設定は、以下のページを参照してください。

{% content-ref url="/pages/Mr8iIh9WBLvgsGDHpX6I" %}
[データソース管理](/i-repo-link-manual/system/2/1.md)
{% endcontent-ref %}

### 4. データベースから取得するマスターデータのフィールド構成を作成

* i-Repo Designerでマスター選択クラスターのGateway連携に使用するマスターデータのフィールド構成を作成します。（カスタムマスターのテーブルレイアウトの作成）

<figure><img src="/files/MNtFHmNuioEhZfYm5iKj" alt=""><figcaption></figcaption></figure>

### 5. Gatewayの設定

* i-Repo Gatewayの**アクションファイルのダウンロードまたはGatewayサーバーへアクションファイルを配置**します。\
  Gatewayサーバーへアクションファイルを配置する場合は、**事前にシステム管理のi-Repo Gateway設定**を行ってください。

{% content-ref url="/pages/j3pUvgktmFXnQz641Jhv" %}
[i-Repo Gateway設定/i-RepoLink Gateway設定](/i-repo-link-manual/system/2/3.md)
{% endcontent-ref %}

* i-Repo Linkから対象の帳票定義のマスター選択クラスターのGateway設定は更新されません。\
  **作成されたアクションファイルを利用して**[**Designerで設定**](https://cimtops.gitbook.io/custom-master-gateway/designer/parameter-description)を行ってください。

<figure><img src="/files/fKFegblkZfTCryaYzH9M" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
**「Gatewayへ配置」ボタンを利用するためのi-Repo GatewayのConfigファイルの設定について**

i-Repo Gatewa 2.1.230200 以降のバージョンを利用する必要があります。\
Gatewayへ配置を行うためには、i-Repo GatewayのConfigファイルの設定を変更してください。\
Configファイルをメモ帳などで開き以下の末尾に記載した **runMode** の設定を「true」に変更してください。\
なお、default.json の修正を反映させる場合は、一度i-RepoGatewayサービスの再起動が必要となります。\
※default.json に runMode の設定の記載がない場合、以下の末尾に記載した **runMode** の設定を追加してください。

**default.jsonファイル設定**

```json
{
  "port": 3000,
  "ssl": false,
  "sslkey": "./ssl/cert.key",
  "sslcert": "./ssl/cert.pem",
  "authType": "default",
  "token": "トークン",
  "pythonShell": {
    "mode": "text",
    "encoding": "utf8",
    "pythonOptions": ["-X", "utf8"]
  },
  "uploadFileTypes": {
    "binary": "bmp;gif;jpg;tif;png;wav",
    "text": ""
  },
  "customMaster": {
    "limit": 500
  }
  ここから追加（先頭にカンマを付けてください）
  ,
    "runMode": {
    "maintenance": true
  }
  ここまで追加
}
```

{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cimtops.gitbook.io/i-repo-link-manual/dtassudtabsu/meny/dtabsunomasutdta.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
