Skip to content

GEM: ソート時に補助的なソート列を追加#1959

Draft
xtakahashi-hiroyuki wants to merge 14 commits intomasterfrom
feature/1795-gem-sort-fix
Draft

GEM: ソート時に補助的なソート列を追加#1959
xtakahashi-hiroyuki wants to merge 14 commits intomasterfrom
feature/1795-gem-sort-fix

Conversation

@xtakahashi-hiroyuki
Copy link
Copy Markdown
Contributor

@xtakahashi-hiroyuki xtakahashi-hiroyuki commented Feb 25, 2026

対応内容

GEMの検索時に
ソート時に補助的なソート列を追加(∵ 結果が一意になるように)

  • ソート列 = (アプリ画面でユーザーが指定したソート列) + (補助列)
  • (補助列) = (あれば)(AdminConsole上のソート設定列) or (OID/更新日)

closes #1795

動作確認・スクリーンショット(任意)

レビュー観点・補足情報(任意)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

GEM の検索結果ソートにおいて、ユーザーが画面上で指定したソート条件だけでは順序が一意にならないケースを改善し、ページング等の安定性を上げるために「補助的なソート列」を末尾に追加できるようにするPRです(Issue #1795 対応)。

Changes:

  • EntityView 系(SearchContextBase)で、画面ソート時に補助キーとして OID を末尾に追加
  • TopView の検索結果パーツ(SearchListContext)で、画面ソート時に Admin 側のソート設定 or updateDate を末尾に追加
  • 固定検索(FixedSearchContext)でも、画面ソート+フィルタ定義ソートの合成と補助ソート追加の流れを整理

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
iplass-gem/src/main/java/org/iplass/mtp/view/generic/element/section/SearchConditionSection.java displayNameKey 行に TODO コメントを追加
iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchListContext.java 画面ソートにフィルタ/設定ソートや updateDate を追加できるよう OrderBy 組み立てを変更
iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java 画面ソート時の順序一意化のため OID を補助キーとして追加
iplass-gem/src/main/java/org/iplass/gem/command/generic/search/FixedSearchContext.java 画面ソート→フィルタ定義ソート→補助ソート、の順で OrderBy を構築するよう変更

Comment on lines +281 to +284
// 参照プロパティの場合、画面上の表示項目でソート
// TODO: 上のロジックのコピペ。解消できないか
if (pd instanceof ReferenceProperty) {
if (property.getPropertyName().equals(sortKey)) {
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[imo] 参照プロパティのソートキー解決ロジックが「ソート設定あり」と「なし」でほぼ重複しており(ここでは TODO でコピペと言及)、将来の仕様変更で片側だけ修正されるリスクがあります。共通メソッド化して1箇所に寄せることを検討してください。

Copilot uses AI. Check for mistakes.
@MetaFieldInfo(
displayName="詳細条件の表示件数",
displayNameKey="generic_element_section_SearchConditionSection_conditionDispCountDisplayNameKey",
displayNameKey="generic_element_section_SearchConditionSection_conditionDispCountDisplayNameKey", //TODO: locale_ja.jsにキー追加
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[imo] displayNameKey 行に TODO コメントが追加されていますが、このリポジトリ内には locale_ja.js が見当たらず(少なくとも iplass-gem 配下には存在しません)、どこにキーを追加すべきかが不明確です。マージ前にキー定義の配置先を明確化して実際に追加するか、参照先が別リポジトリ/別モジュールならその前提をコメントで補足してください。

Suggested change
displayNameKey="generic_element_section_SearchConditionSection_conditionDispCountDisplayNameKey", //TODO: locale_ja.jsにキー追加
displayNameKey="generic_element_section_SearchConditionSection_conditionDispCountDisplayNameKey", // NOTE: 本キーのロケール定義はクライアント側リソース(本モジュール外)で管理する前提

Copilot uses AI. Check for mistakes.
return orderBy;
NullOrderingSpec nullOrderingSpec = getNullOrderingSpec(property.getNullOrderType());
// ソート順序を一意にするため、OIDをソートキーの末尾に追加
return new OrderBy().add(sortKey, getSortType(), nullOrderingSpec).add(Entity.OID, SortType.ASC);
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[must] sortKey が参照プロパティのネスト未設定等で Entity.OID にフォールバックした場合でも、末尾でさらに Entity.OID を add しているため、ORDER BY OID <dir>, OID ASC のように同一キーが重複します(方向が異なる可能性もあり、意図が不明瞭です)。sortKey が OID に確定したケースでは補助キー追加をスキップする等、OID の二重追加を避けてください。

Suggested change
return new OrderBy().add(sortKey, getSortType(), nullOrderingSpec).add(Entity.OID, SortType.ASC);
boolean isOidSortKey = Entity.OID.equals(sortKey);
OrderBy orderBy = new OrderBy().add(sortKey, getSortType(), nullOrderingSpec);
if (!isOidSortKey) {
orderBy.add(Entity.OID, SortType.ASC);
}
return orderBy;

Copilot uses AI. Check for mistakes.
@xtakahashi-hiroyuki
Copy link
Copy Markdown
Contributor Author

要確認

ドキュメントへの記載も必要か

@xtakahashi-hiroyuki xtakahashi-hiroyuki force-pushed the feature/1795-gem-sort-fix branch from 5ce9f1a to 5828b57 Compare April 6, 2026 08:27
@xtakahashi-hiroyuki xtakahashi-hiroyuki force-pushed the feature/1795-gem-sort-fix branch from 631a6e5 to a9f16bc Compare April 7, 2026 12:04
@xtakahashi-hiroyuki xtakahashi-hiroyuki force-pushed the feature/1795-gem-sort-fix branch from 007700d to 5eeadf5 Compare April 7, 2026 14:06
@xtakahashi-hiroyuki xtakahashi-hiroyuki force-pushed the feature/1795-gem-sort-fix branch from fafc7fc to e2d39f9 Compare April 7, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GEM: 画面上でEntityの検索結果をソートする際のソート条件改善

2 participants