infomodel,ejb,dto の引っ越し:REST(5)
InfoModel
InitDatabase が成功したので,今度は全ての InfoModel を引っ越しする。- InitDatabase 作成時に UserModel と RoleModel の bi-directional reference を @JsonIdentityInfo で解消したが,同じように全ての InfoModel で bi-directional reference を調べる必要がある。そこで,Class Visualizer というのを使用した。
使い方- server の -classes.jar ファイルを読み込んで,open.dolphin.infomodel でフィルタをかける。
- class を一つずつダブルクリックして,矢印なしの線で結ばれたクラスを調べていく。
- KarteBean "entries" フィールドについて
このフィールドは便利で,型指定をしていないので,getKarte の際にアレルギーデータ,身長データ,体重データ,来院日,文書履歴,患者メモの6エントリーのリストなど,モデルのリスト,文字列のリストなど雑多な内容を入れることができるようになっていた。
ところが,取ってきた entry をキャストするところで json からの deserialize がうまくいかなかった。entry に型指定がされていないので,持ってきたオブジェクトをうまく変換できないようだった。仕方がないので,entries を型指定をした複数の entry に分けて書き直した。 - ModuleModel "model" フィールドについて
このフィールドは BndleMed, BundleDolphin, ProgressCourse が入れられるように IInfoModel で型指定されている。IInfoModel は interface なので,このままだと json がインスタンスを作ることができない。こういう場合は,@JsonTypeInfo を使うと,オブジェクトの class に応じてプロパティーを入れてくれる。@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY) private IInfoModel model;
以下のような json になる。{ "@id" : "f371a3c1-33e2-47d2-8537-2948aeec082d", "id" : 0, "linkId" : 0, "moduleInfo" : { "stampNumber" : 0, "editable" : true, "asp" : false, "turnIn" : false }, "model" : { "@class" : "open.dolphin.infomodel.BundleMed" } }
ejb
- RemoteSystemService → SystemService,RemoteSystemServiceImpl → SystemServiceImpl の改変と同じように,他の RemoteOOOService も変更する。ここで,引数に primitive 型を使っているものは以下の Exception が出ることが分かった。
java.lang.IllegalArgumentException: The type is incompatible with the class of the entity at javax.ws.rs.core.GenericEntity.checkTypeCompatibility(GenericEntity.java:173). at javax.ws.rs.core.GenericEntity.
GenericEntity を使っているようで,GenericEntity(GenericEntity.java:152) at org.jboss.resteasy.client.jaxrs.internal.proxy.processors.invocation.MessageBodyParameterProcessor.process(MessageBodyParameterProcessor.java:35) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.createRequest(ClientInvoker.java:135) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:101) at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:62) at com.sun.proxy.$Proxy38.getKarte(Unknown Source) の T のところに primitive を入れてしまっているようだ。引数の primitive 型を class 型に変更して対応した。(戻り値は primitive 型でも大丈夫)
dto
- dto については特に問題なく引っ越しできた。
« InitDatabase の実行まで:REST(4) | トップページ | Authorization:REST(6) »
「OpenDolphin」カテゴリの記事
- IME on/off の切換 - その2(2024.12.02)
- OrcaController オルコン(2024.11.28)
- OpenDolphin: java 21 / wildfly 34 への移行(2024.11.08)
- IME on/off の切り替え(2024.09.03)
- 促音拗音の検索(2024.09.01)