• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision2467 (tree)
Time2022-10-20 19:36:20
Authort_nakayama1971

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/framework/pjWeb/src/main/java/project/web/generic/master/UpdateAction.java (revision 2466)
+++ trunk/framework/pjWeb/src/main/java/project/web/generic/master/UpdateAction.java (revision 2467)
@@ -1,6 +1,7 @@
11 package project.web.generic.master;
22
33 import java.sql.Types;
4+import java.util.ArrayList;
45
56 import core.config.Factory;
67 import core.util.bean.CamelCase;
@@ -8,6 +9,7 @@
89 import online.annotation.SessionExit;
910 import online.annotation.SessionReserved;
1011 import online.context.check.InputCheck;
12+import online.context.check.ItemCheck;
1113 import online.struts.action.BrowseAction;
1214 import online.struts.action.UniForm;
1315 import project.check.TopMessage;
@@ -88,20 +90,15 @@
8890 public String update(final UniForm model) {
8991
9092 // テーブル情報取得
91- final var dmd = Factory.create(DBMetaData.class);
92- final var info = dmd.getColumnInfo(this.table);
93+ final var info = Factory.create(DBMetaData.class).getColumnInfo(this.table);
9394
9495 // 入力チェック
95- final var ro = InstanceFactory.create(RecordOperate.class, model);
9696 final var ic = InstanceFactory.create(InputCheck.class, model);
9797 ic.onError(new TopMessage("ZZ000000005"));
9898 for (final var ent : info.entrySet()) {
9999 final var name = CamelCase.convert(ent.getKey());
100- if (!ID.equals(name) && !ro.isMaintenance(name)) {
101- addChecks(name, ent.getValue(), ic);
102- }
100+ ic.add(name, getChecks(model, name, ent.getValue()));
103101 }
104-
105102 ic.add("FooCheck", new HankakuCheck());
106103 ic.add("FooCheck2", new HankakuCheck());
107104 ic.populate();
@@ -142,31 +139,38 @@
142139 }
143140
144141 /**
145- * 入力チェック追加
142+ * 入力チェック取得
146143 *
144+ * @param model 汎用モデル
147145 * @param name 項目名
148146 * @param info テーブル情報
149- * @param ic 入力チェッカー
147+ * @return 入力チェック
150148 */
151- private void addChecks(final String name, final DBColumnInfo info, final InputCheck ic) {
152- // 必須入力
153- if (info.isNotNull()) {
154- ic.add(name, new MustCheck("ZZ000000006", info.getComment()));
149+ private ItemCheck[] getChecks(final UniForm model, final String name, final DBColumnInfo info) {
150+
151+ final var checks = new ArrayList<ItemCheck>();
152+
153+ final var ro = InstanceFactory.create(RecordOperate.class, model);
154+ if (!ID.equals(name) && !ro.isMaintenance(name)) {
155+ // 必須入力
156+ if (info.isNotNull()) {
157+ checks.add(new MustCheck("ZZ000000006", info.getComment()));
158+ }
159+ // タイプと長さ
160+ if (info.getType() == Types.CHAR) {
161+ checks.add(new HanEisuCheck("ZZ000000007", info.getComment()));
162+ checks.add(new LengthRangeCheck(0, info.getSize(), "ZZ000000008", info.getComment()));
163+ } else if (info.getType() == Types.VARCHAR) {
164+ checks.add(new LengthRangeCheck(0, info.getSize(), "ZZ000000009", info.getComment()));
165+ } else if (info.getType() == Types.DATE) {
166+ checks.add(new DateCheck("ZZ000000010", info.getComment()));
167+ } else if (info.getType() == Types.TIMESTAMP) {
168+ checks.add(new TimestampCheck("ZZ000000011", info.getComment()));
169+ } else {
170+ checks.add(new DecimalCheck(info.getSize(), info.getScale(), "ZZ000000012", info.getComment()));
171+ }
155172 }
156173
157- // タイプと長さ
158- if (info.getType() == Types.CHAR) {
159- ic.add(name, new HanEisuCheck("ZZ000000007", info.getComment()));
160- ic.add(name, new LengthRangeCheck(0, info.getSize(), "ZZ000000008", info.getComment()));
161- } else if (info.getType() == Types.VARCHAR) {
162- ic.add(name, new LengthRangeCheck(0, info.getSize(), "ZZ000000009", info.getComment()));
163- } else if (info.getType() == Types.DATE) {
164- ic.add(name, new DateCheck("ZZ000000010", info.getComment()));
165- } else if (info.getType() == Types.TIMESTAMP) {
166- ic.add(name, new TimestampCheck("ZZ000000011", info.getComment()));
167- } else {
168- ic.add(name, new DecimalCheck(
169- info.getSize(), info.getScale(), "ZZ000000012", info.getComment()));
170- }
174+ return checks.toArray(ItemCheck[]::new);
171175 }
172176 }