/
XML コネクタでの動的属性の定義方法

XML コネクタでの動的属性の定義方法

ここでは、XML バックエンドに属性を動的に送信する方法を示します。

java

<FieldName Currency="<VALUE>">0</FieldName>

 

  1. SDK プロジェクトに新しいクラスを作成します。

このクラスで名前が値と異なるすべてのフィールドは、動的属性として生成されます。

例、動的属性として「通貨」 がある XmlEntityMeasuresRequest.java ファイル

package com.test_sdk.openlegacy; import java.math.BigDecimal; import org.openlegacy.core.annotations.common.Attribute; import org.openlegacy.core.annotations.common.FieldAttributes; import org.openlegacy.core.annotations.rpc.Direction; import org.openlegacy.core.annotations.rpc.RpcField; import org.openlegacy.core.annotations.rpc.RpcNumericField; import org.openlegacy.core.annotations.rpc.RpcPart; import org.openlegacy.core.rest.RestConst; @RpcPart(name = "XmlEntityMeasuresRequest") public class XmlEntityMeasuresRequest { @FieldAttributes(attributes = { @Attribute(key = RestConst.XML_ATTRIBUTE, value = "true") }) @RpcField(originalName = "Currency") private String currency; @FieldAttributes(attributes = { @Attribute(key = RestConst.XML_PARENT_VALUE, value = "true") }) @RpcField(direction = Direction.INPUT, originalName = "value") @RpcNumericField(decimalPlaces = 0) private BigDecimal value; }
  1.  フィールドには、以下の動的属性が必要です。

    1. 「DataType」属性を除く、すべての属性を削除します。

「DataType」属性名は、ol-xml.yml ファイルの「typeAttribute: データ型」で説明されています。

削除された属性はクラスに追加する必要があります。 

b.数値フィールドの @RpcNumericField アノテーション(注釈)を削除します。


例、BigDecimal データ型の measures フィールドは以下から変更されました。

java

    @FieldAttributes(attributes = {             @Attribute(key = "Currency", value = "2"),             @Attribute(key = "DataType", value = "Numeric")     })     @RpcField(direction = Direction.INPUT, originalName = "Measures")     @RpcNumericField(decimalPlaces = 0)     private BigDecimal measures;

以下へ変更:

java

    @FieldAttributes(attributes = {             @Attribute(key = "DataType", value = "Numeric")     })     @RpcField(direction = Direction.INPUT, originalName = "Measures")     private XmlEntityMeasuresRequest measures;

結果 - 通貨属性は動的となりました。

java

<Measures DataType="Numeric" Currency="<VALUE>">0</Measures>

 

 

 

Related content