オラクル社の公式ブログに、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を使用します。
作業ディレクトリとして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ワークスペースにインポートし直し、アプリケーションを実行します。
ページ1の対話モード・レポートの列ラベルは日本語になりました。
フォームのアイテム・ラベルについても、日本語になりました。
概ね、従業員の作成、更新、削除は実装されているようです。
Blueprintから生成されたAPEXアプリケーションのエクスポートを以下に置きました。
今回の記事は以上になります。
Oracle APEXのアプリケーション作成の参考になれば幸いです。