ラベル blueprint の投稿を表示しています。 すべての投稿を表示
ラベル blueprint の投稿を表示しています。 すべての投稿を表示

2026年6月19日金曜日

APEX BlueprintsからAPEXlang形式のAPEXアプリケーションを生成する

Oracle APEX 26.1の新機能にBlueprintsが含まれています。以下の記事で、Oracle CorporationがGitHubで公開しているOrdery Entryの機能要件定義書や、自前で作成した従業員管理の機能要件定義書からブループリントを生成し、そのブループリントをAPEXワークスペースにインポートしてAPEXのアプリケーションを生成しています。

Order Entry版: Oracle APEX 26.1のBlueprintの生成とインポートを試してみる

現状ではブループリントからAPEXのアプリケーションを生成するには、アプリケーション・ビルダーからブループリントをインポートする必要があります。ブラウザでの作業になるため、スクリプトに組み込んで実行できません。

APEX 26.1には、ブループリントからAPEXlang形式のアプリケーションを生成するパッケージAPEX_GENDEVが含まれています。

APEX 26.1のAPI Referenceにはまだ記載されていません。そのため、仕様については今後変わる可能性がありますが、このパッケージを呼び出してブループリントからAPEXアプリケーションを生成するORDS RESTサービスを作成してみます。

ORDSモジュールとしてblueprint、テンプレートとしてprocessを作成し、マークダウンのテキストを受け付け、APEXアプリケーションのZIPファイルを返すPOSTハンドラを作成します。

以下のスクリプトを実行します。


APEXワークスペースに紐づく、パーシング・スキーマに接続して実行します。こちらの記事「サンプル・データセットのEMP/DEPTを元にAPEX Blueprintを作成しBlueprintからAPEXアプリケーションを生成する」から継続して作業を行なっていることを前提としています。

sql -name local-26ai-apexdev @ords-blueprint-process.sql

RESTサービスを呼び出すURLは以下になります。

https://ホスト名/ords/<ORDS別名=APEXワークスペース>/blueprint/process

blueprint-emp-dept % sql -name local-26ai-apexdev @ords-blueprint-process.sql


SQLcl: 金 6月 19 15:12:24 2026のリリース26.1 Production


Copyright (c) 1982, 2026, Oracle.  All rights reserved.


接続先:

Oracle AI Database 26ai Free Release 23.26.1.0.0 - Develop, Learn, and Run for Free

Version 23.26.1.0.0



PL/SQLプロシージャが正常に完了しました。


SQL> exit

Oracle AI Database 26ai Free Release 23.26.1.0.0 - Develop, Learn, and Run for Free

Version 23.26.1.0.0から切断されました

blueprint-emp-dept % 


作業ディレクトリにブループリントとしてemployees-management-blueprint.mdがあるとします。

curlコマンドを実行してブループリントをアップロードし、生成されたAPEXアプリケーションをapp.zipとして保存します。
curl -X POST -H "Content-Type: text/markdown; charset=UTF-8" -o app.zip \
--data-binary @employees-management-blueprint.md \
http://localhost:8181/ords/apexdev/blueprint/process

blueprint-emp-dept % curl -X POST -H "Content-Type: text/markdown; charset=UTF-8" -o app.zip --data-binary @employees-management-blueprint.md http://localhost:8181/ords/apexdev/blueprint/process

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100 55533    0 49375  100  6158    99k  12720 --:--:-- --:--:-- --:--:--  112k

blueprint-emp-dept % 


出力されたapp.zipの内容を確認します。

unzip -l app.zip

blueprint-emp-dept % unzip -l app.zip

Archive:  app.zip

  Length      Date    Time    Name

---------  ---------- -----   ----

      974  06-19-2026 06:19   application.apx

       33  06-19-2026 06:19   .apex/apexlang.json

       32  06-19-2026 06:19   deployments/default.json

     1619  06-19-2026 06:19   shared-components/themes/universal-theme/theme.apx

     4780  06-19-2026 06:19   shared-components/static-files/icons/app-icon-144-rounded.png

     5951  06-19-2026 06:19   shared-components/static-files/icons/app-icon-192.png

     9655  06-19-2026 06:19   shared-components/static-files/icons/app-icon-256-rounded.png

      643  06-19-2026 06:19   shared-components/static-files/icons/app-icon-32.png

    20119  06-19-2026 06:19   shared-components/static-files/icons/app-icon-512.png

      101  06-19-2026 06:19   shared-components/authentications.apx

       55  06-19-2026 06:19   shared-components/build-options.apx

      405  06-19-2026 06:19   shared-components/static-files.apx

     1483  06-19-2026 06:19   shared-components/lists.apx

      290  06-19-2026 06:19   shared-components/breadcrumbs.apx

      336  06-19-2026 06:19   shared-components/lovs.apx

      222  06-19-2026 06:19   page-groups.apx

     8634  06-19-2026 06:19   pages/p00001-employee-list.apx

    10582  06-19-2026 06:19   pages/p00002-employee-form.apx

     5665  06-19-2026 06:19   pages/p09999-login.apx

---------                     -------

    71579                     19 files

blueprint-emp-dept % 


application.apxが含まれており、正常なAPEXアプリケーションになっていることが確認できます。

app.zipはAPEXアプリケーションなので、SQLclを使用してAPEXワークスペースにインポートできます。

apex import -input app.zip

SQL> apex import -input app.zip

アプリケーションID: 101をワークスペース: APEXDEVにインポートしています

インポートに成功しました。


SQL> 


ブループリントからAPEXアプリケーションを生成する作業を、コマンドラインから実行できるようになりました。

機能要件定義書の修正からAPEXアプリケーションの生成までを、人手を解さずに実行することで、作業の繰り返しが楽になりました。

この実装では、ORDS RESTサービスを保護していません。必要に応じて、OAuthなどで保護を追加する必要があります。

今回の記事は以上になります。

完

2026年6月18日木曜日

サンプル・データセットのEMP/DEPTを元にAPEX Blueprintを作成しBlueprintからAPEXアプリケーションを生成する

オラクル社の公式ブログに、Oracle APEX 26.1の新機能であるBlueprintに関する記事が投稿されています。

Scaffolding Oracle APEX Applications using Blueprints

本ブログもAPEX Blueprintについて、こちらの記事で紹介しています。公式ブログの記事を読んでいて気が付いたのですが、GitHubで公開されているBlueprintsのexamplesにsupply-chain-managementが追加されています。


本ブログの過去記事はorder-entryを扱っていました。オラクルの公式ブログの記事はsupply-chain-managementを扱っています。order-entryとsupply-chain-managementはfunctional requirementsは異なりますが、両方ともにBlueprintを出力するために、prompt以下のblueprint-prompt.mdおよびapex-fa-icons-allowlist.txtを参照しています。

つまり、prompt以下のファイルを使って、order-entryやsupply-chain-managementではない、自分で定義した機能要件定義書に基づいたAPEX Blueprintが生成できるはずです。

サンプル・データセットのEMP/DEPTを元に、従業員を管理するAPEXアプリケーションのBlueprintを作成し、それを元にAPEXアプリケーションを作ってみます。Blueprintの生成にOpenAI Codex(デスクトップ・アプリ)を使用します。

作業環境としてMacbook Proのコンテナ環境で実行しているOracle AI Database 26ai FreeとOracle APEX 26.1.1を使用します。

サンプル・データセットのEMP/DEPTをインストールしたのち、記事「APEX 26.1に含まれるパッケージAPEX_DB_DICTIONARYを使って表の説明を生成する」で紹介した、表にコメントやアノテーションを追加するスクリプトを実行しておきます。

作業ディレクトリとしてblueprint-emp-deptを作成します。

mkdir blueprint-emp-dept
cd blueprint-emp-dept

% mkdir blueprint-emp-dept 

% cd blueprint-emp-dept

blueprint-emp-dept % 


Gitで管理しませんが、Codexが認識するためgit initを実行しておきます。

git init

blueprint-emp-dept % git init

Initialized empty Git repository in /Users/______/Documents/blueprint-emp-dept/.git/

blueprint-emp-dept % 


Blueprintの生成には不要だと思いますが、念のためにAPEXlangのスキルとSQLcl MCPサーバーを構成します。Microsoft APMを使用します。

ファイルapm.ymlを作成します。
name: emp-dept
version: 0.1.0
description: Oracle APEX 26.1のAPEXlangを使ってアプリケーションを作成する。
author: Yuji
dependencies:
  apm:
    # Oracle Database Skills
    - git: https://github.com/oracle/skills
      path: db
      ref: main
    # Oracle APEXlang Skills
    - git: https://github.com/oracle/skills
      path: apex
      ref: main
  mcp:
    - name: oracle-apexdev
      registry: false
      transport: stdio
      command: /opt/homebrew/Caskroom/sqlcl/26.1.2.132.1334/sqlcl/bin/sql
      args:
        - -R
        - "4"
        - -mcp
Codex向けにスキルとMCPサーバーをインストールします。Claude Codeで作業を行なう方は、targetの指定はclaudeになります。

apm install --target codex

blueprint-emp-dept % apm install --target codex

[>] Installing dependencies from apm.yml...

[>] Resolving skills-db...

[>] Resolving skills-apex...

[i] Targets: codex  (source: --target flag)

  [+] github.com/oracle/skills/apex#main #main @b31c5175

  |-- Skill integrated -> .agents/skills/

  [+] github.com/oracle/skills/db#main #main @b31c5175

  |-- Skill integrated -> .agents/skills/

[i] Added apm_modules/ to .gitignore

+- MCP Servers (1)

[i] Skipped MCP config for claude  (active targets: codex)

|  [>]  oracle-apexdev (self-defined, stdio)

|     +- Configuring for Codex...

[*] Configured MCP server 'oracle-apexdev' for Codex CLI

  + oracle-apexdev

|  [+]  oracle-apexdev -> Codex (configured)

[*] Configured 1 server


[*] Installed 2 APM dependencies and 1 MCP server in 2.3s.

blueprint-emp-dept % 


GitHubよりBlueprintを生成するために参照するプロンプトを取得します。


blueprint-prompt.mdとapex-fa-icons-allowlist.txtをプロジェクトのディレクトリにコピーします。

blueprint-emp-dept % ls

apex-fa-icons-allowlist.txt apm.lock.yaml blueprint-prompt.md

apm_modules apm.yml

blueprint-emp-dept % 


EMP/DEPTのスキーマ定義をemployees-management-schema.mdとして作成します。

ユーティリティの表の説明を実行します。


説明の対象としEMP、DEPT、EMP_DEPT_Vを選択し、DESCRIBEを実行します。書式はMarkdownを選択します。

表に説明が出力されるのでダウンロードをクリックして、ファイルdescribe_tables.mdに出力します。


ダウンロードされたファイルdescribe_tables.mdをプロジェクト・フォルダ以下にemployees-management-schema.mdとして配置します。

blueprint-emp-dept % ls

apex-fa-icons-allowlist.txt apm.lock.yaml blueprint-prompt.md

apm_modules apm.yml employees-management-schema.md

blueprint-emp-dept % 


APEXアプリケーションを作成するために、この他に機能要件定義書が必要です。

詳細な機能要件定義書を一から書くのは大変なので、Codexに書いてもらいました。Codexのデスクトップ・アプリを起動し、プロジェクトとしてフォルダblueprint-emp-deptをアタッチします。

以下のプロンプトで機能要件定義書を生成します。

「従業員マネージメント・アプリケーションのブループリントを作りたい。

Oracle Databaseにemployees-management-schema.mdに記述されているスキーマが定義されていることを前提として、表EMPに登録されている従業員の一覧を表示するレポートのページと、レポート上に一覧されている従業員を選択し、所属(所属は表DEPTを参照する)、給与、手当を更新できるフォームを開く。

また、新規に従業員の登録と、既存の従業員の削除も可能とする。

これらの要件を機能要件定義書として、Markdown形式のファイルとして生成してください。

生成するファイルの名前はemployees-management-functional-requirements.mdとします。」


生成された機能要件定義書はこちらです。

この機能要件定義書からBlueprintを生成します。以下のプロンプトを与えます。

「blueprint-prompt.mdおよびapex-fa-icons-allowlist.txtより、Oracle APEXのblueprintをemployees-management-blueprint.mdとして生成してください。

以下のファイルの内容だけが、生成するAPEX blueprintの要件定義書になります。

employees-management-functional-requirements.md

employees-management-schema.md

Application Name, Region Name, Column Nameはすべて英語にしてください。

マークダウンの##、###、####に続くアプリケーション、ページ、リージョンなどの名前は、すべて英語にしてください。」

生成されるBlueprintのアプリケーション、ページおよびリージョンの名前に日本語が含まれていると、Blueprintから生成されたAPEXlangに日本語の識別子が含まれることになり、インポート時にエラーが発生します。そのため、プロンプトの末尾で英語にするよう指示しています。

blueprint-prompt.mdなどに追加するか、個別のスキルとして登録すると、毎回同じ指示をする必要は無くなるでしょう。


employees-management-blueprint.mdが出力されました。

APEXワークスペースに、ファイル・タイプとしてアプリケーション・ブループリントを選択してインポートします。


生成されたBlueprintに問題がなければ、アプリケーションのインポートに成功します。


アプリケーションを実行し、作成されたアプリケーションを確認します。

ページ1に対話モード・レポートが作成されていました。


従業員のフォームも開きます。


対話モード・レポートの列ラベルやフォームのアイテム・ラベルが英語になっています。これは、Blueprintを生成する際に「英語で」と指定したのが拡大解釈されたもようです。

以下のプロンプトを与えて、Blueprintを更新します。

「Description、Comments、Label、Titleとなる文字列は、スキーマ定義から参照できる日本語文字列にしてください。」


生成されたBlueprintをAPEXワークスペースにインポートし直し、アプリケーションを実行します。

出力されたemployees-management-blueprint.mdです。

ページ1の対話モード・レポートの列ラベルは日本語になりました。


フォームのアイテム・ラベルについても、日本語になりました。


概ね、従業員の作成、更新、削除は実装されているようです。

Blueprintから生成されたAPEXアプリケーションのエクスポートを以下に置きました。


今回の記事は以上になります。

Oracle APEXのアプリケーション作成の参考になれば幸いです。

完