新規 UDI スーパーセットの属性ポピュレータ
この章では、既成の UDI スーパーセット属性ポピュレータを拡張し、UDI スーパーセットと UDI スーパーセット詳細のカスタム属性を設定する方法について説明します。
com.ptc.qualitymanagement.udi.superset パッケージには、既成の登録済み属性ポピュレータが 2 つ含まれています。テンプレートが指定されている場合、これらのポピュレータを使用して UDI スーパーセットが作成されます。このパッケージでは、オーバーライドすることでカスタム属性の設定が可能になるメソッドも提供されています。上書きする属性は対象部品から派生し、追加の UDI スーパーセット詳細の作成を含めることができます。
以降の各セクションでは、UDI スーパーセットの作成時に属性を設定するときのカスタムロジックを作成する方法について説明します。これは次の 2 つの主な手順から成ります。
既成の UDI スーパーセット属性ポピュレータを拡張するカスタムクラスの作成
カスタムクラスを登録する xconf エントリの作成
必要条件
Java クラスおよびクラス拡張などの基本的な概念についての知識
サービスクラスを登録する xconf メカニズムの知識
以下のテーブルに、各種ソリューションエレメントの説明を示します。
エレメント
タイプ
説明
com.ptc.qualitymanagement.udi.superset.StandardUdiSuperSetAttributePopulator
Java クラス
改訂不可能な単純な UDI スーパーセット (UdiSuperSet) を作成する際にテンプレートから属性を設定するために登録されている既成のポピュレータ。
com.ptc.qualitymanagement.udi.superset.StandardUdiSuperSet2AttributePopulator
Java クラス
改訂可能な UDI スーパーセット (UdiSuperSet2) を作成する際にテンプレートから属性を設定するために登録されている既成のポピュレータ。
populateFromAttributes(UDISubmission submission, Map attributes)
API
属性名と属性値を含むマップに基づいて属性を UDISubmission に設定します。
createUDISubmissionDetail(UDISubmission submission, String typeName, Map attributes)
API
UdiSuperSetDetail タイプ、および属性名と属性値を含むマップに基づいて UDISubmission に関連する新しい UdiSuperSetDetail を作成します。
createUDIPackagingDetail(UDISubmission submission, UDIPackaging parent, Map attributes)
API
UDIPackaging、および属性名と属性値を含むマップに基づいて UDISubmission に関連する新しい UDIPackaging を作成します。
populateFromSouce(UDISubmission submission, Map attributes)
API
カスタムクラスでオーバーライドされるメソッド。既成の属性ポピュレータを拡張し、これを使用することでカスタマイズが可能になります。
getPart()
API
UdiSuperSet2 の対象である WTPart を返します。属性の設定で WTPart を参照するためにオーバーライドされた populateFromSource メソッドで使用されます。
getAttributeValue(Typed typedObject, String attributeName)
API
Typed オブジェクトに定義されているハード属性またはソフト属性の値を返します。
デフォルトの動作
属性は既成では設定されません。
カスタムクラスの作成
単純な UdiSuperSet または改訂可能な UdiSuperSet2 を作成する際の属性の設定をカスタマイズするには、StandardUdiSuperSetAttributePopulator または StandardUdiSuperSet2AttributePopulator を拡張して populateFromSource メソッドをオーバーライドする新規 Java クラス (ポピュレータ) を作成する必要があります。オーバーライドされた populateFromSource メソッドの最小要件を満たす新規カスタムクラスの例を以下に示します。
public class CustomStandardUdiSuperSet2AttributePopulator extends StandardUdiSuperSet2AttributePopulator {
/**
* @param submission
* @param attributes
* @return details
* @throws WTException
* @throws WTPropertyVetoException
*/
@Override
public List <UDISubmissionDetailsIfc> populateFromSouce(UDISubmission submission,Map attributes) throws WTPropertyVetoException, WTException {
/*
* Overriding this method provides the means to add custom attribute
* population to any hard or soft attribute on the UdiSuperSet or
* UdiSuperSet2 passed into this method, and also adds a means to create and populate
* UdiSuperSetDetails for any hard or soft Type defined for UdiSuperSetDetails
*
* This method returns a List of UDISubmissionDetailsIfc and
* as such the details List should be created in this method and
* returned so that the UdiSuperSetDetails can be persisted.
* Created UdiSuperSetDetails should be added to the details list.
*/
List <UDISubmissionDetailsIfc> details = new ArrayList<>();
return details;
}
}
getPart() API を使用して、Part オブジェクトから UDISubmission に属性を設定するロジックを追加できます。Part からの属性のカスタム設定での populateFromSource メソッドのオーバーライドの例を以下に示します。
@Override
public List<UDISubmissionDetailsIfc> populateFromSouce(UDISubmission submission, Map attributes) throws WTPropertyVetoException, WTException {
/*
* The getPart() API retrieves the WTPart that was set in the StandardUDICreatorService.
* Attributes from the Part can be used to populate attributes defined on the UDI.
* In this example the attributes brandName, modelNumber, lotControlled, and serialControlled
* are placed into a map for population. The populateFromAttributes API is used
* to load the attributes to the UDISubmission Type.
*/
List<UDISubmissionDetailsIfc> details = new ArrayList<>();
WTPart thePart = getPart();
Map<String, Object> sourceAttributes = new HashMap<>();
sourceAttributes.put("brandName", thePart.getName());
StandardVersionedDisplayIdentity verId = (StandardVersionedDisplayIdentity) ((RevisionControlled) thePart).getDisplayIdentity();
LocalizableMessage identifier = verId.getIterationDisplayIdentity().getDisplayIdentifier();
String modelNumber = thePart.getNumber() + ", " + identifier.getLocalizedMessage(SessionHelper.getLocale());
sourceAttributes.put("modelNumber", modelNumber);
TraceCode defaultTraceCode = thePart.getDefaultTraceCode();
if (TraceCode.LOT_NUMBER.equals(defaultTraceCode) || TraceCode.LOT_SERIAL_NUMBER.equals(defaultTraceCode)) {
sourceAttributes.put("lotControlled", true);
}
if (TraceCode.SERIAL_NUMBER.equals(defaultTraceCode) || TraceCode.LOT_SERIAL_NUMBER.equals(defaultTraceCode)) {
sourceAttributes.put("serialControlled", true);
}
populateFromAttributes(submission, sourceAttributes);
return details;
}
getAttributeValue API を使用してハード属性値またはソフト属性値を読み込んで、UDISubmission に定義されている属性に設定できます。例を以下に示します。
@Override
public List<UDISubmissionDetailsIfc> populateFromSouce(UDISubmission submission, Map attributes)
throws WTPropertyVetoException, WTException {
/*
* The getAttributeValue(Typed typedObject, String attributeName) API retrieves the value
* of a hard or soft attribute from a Typed object. In this example there is a Soft
* attribute named reusableAtt1 which is retrieved from the Part and set on the UDI
* brandName attribute. The contractNumber hard attribute is retreived from the Part
* and set on the UDI catalogNumber.
*/
List<UDISubmissionDetailsIfc> details = new ArrayList<>();
WTPart thePart = getPart();
Object partBrandName = getAttributeValue(thePart, "reusableAtt1");
Object partContractNumber = getAttributeValue(thePart, "contractNumber");
Map<String, Object> sourceAttributes = new HashMap<>();
sourceAttributes.put("brandName", partBrandName);
sourceAttributes.put("catalogNumber", partContractNumber);
populateFromAttributes(submission, sourceAttributes);

return details;
}
createUDISubmissionDetail API を使用して、UDIPackaging 以外の UDISubmissionDetail タイプに UDISubmissionDetail を作成して設定できます。例を以下に示します。
@Override
public List<UDISubmissionDetailsIfc> populateFromSource(UDISubmission submission, Map attributes)
throws WTPropertyVetoException, WTException {
/*
* The createUDISubmissionDetail(UDISubmission submission, String typeName,
* Map<String, Object> attributes) API provides a method to create and
* populate a UDISubmissionDetail object for any UDISubmissionDetail Type
* other than UDIPackaging.
* In this example a UDISubmissionDetail object is created for the
* com.ptc.qualitymanagement.udi.superset.FDAListingNumber Type, populating the
* udiss_fdaListingNumber attribute, and a UDISubmissionDetail object is created
* for the com.ptc.qualitymanagement.udi.superset.FDAPremarketAuthorizationNumber
* Type, populating the udiss_fdaPremarketAuthorizationNumber attribute and
* udiss_fdaBadSupplementNumber attribute
*/
List<UDISubmissionDetailsIfc> details = new ArrayList<>();
Map<String, Object> detailsAttributes = new HashMap<>();
UDISubmissionDetailsIfc detail = null;
detailsAttributes.put("udiss_fdaListingNumber", "12345");
detail = createUDISubmissionDetail(submission,
"com.ptc.qualitymanagement.udi.superset.FDAListingNumber",
detailsAttributes);
if (detail != null) {
details.add(detail);
}
detailsAttributes = new HashMap<>();
detailsAttributes.put("udiss_fdaPremarketAuthorizationNumber", "98765");
detailsAttributes.put("udiss_fdaBadSupplementNumber", "54321");
detail = createUDISubmissionDetail(submission,
"com.ptc.qualitymanagement.udi.superset.FDAPremarketAuthorizationNumber",
detailsAttributes);
if (detail != null) {
details.add(detail);
}

return details;
}
createUDIPackagingDetail API を使用して、UDISubmissionUDIPackaging 構造を作成できます。UDISUbmission、親 UDIPackaging オブジェクト、および属性のマップがこの API に渡されます。最上位の UDIPackaging オブジェクトの親オブジェクトは常に Null であり、参照を確立するため、以降の createUDIPackagingDetail の呼び出しに適切な親オブジェクトが渡されます。Carton に含まれている Box に含まれている Glove に作成されるパッケージング構造の例を以下に示します。
@Override
public List<UDISubmissionDetailsIfc> populateFromSouce(UDISubmission submission, Map attributes)
throws WTPropertyVetoException, WTException {
/*
* The createUDIPackagingDetail(UDISubmission submission, UDIPackaging parent,
* Map<String, Object> attributes) API provides a method to create and
* populate UDIPackaging objects.
* In this example a UDIPackaging object is created for the
* Top packaging object, gloves. with a null Parent reference.
* A packaging object is then created passing the gloves packaging object
* as the parent, which creates a Box packaging object that contains a
* number of Gloves. Then a packaging object is created passing the Box packaging object
* as the parent, which creates a Carton packaging object that contains a
* number of Boxes
*/
List<UDISubmissionDetailsIfc> details = new ArrayList<>();
Map<String, Object> detailsAttributes = new HashMap<>();
detailsAttributes = new HashMap<>();
detailsAttributes.put("packageDescription", "Gloves");
detailsAttributes.put("packageDeviceIdentifer", "98765432101256");
detailsAttributes.put("packageQuantity", "1");
Date date = new Date();
detailsAttributes.put("discontinuedDate", new Timestamp(date.getTime()));
UDISubmissionDetailsIfc parent = createUDIPackagingDetail(submission, null, detailsAttributes);
if (parent != null) {
details.add(parent);
}

detailsAttributes = new HashMap<>();
detailsAttributes.put("packageDescription", "Box");
detailsAttributes.put("packageDeviceIdentifer", "96385274102589");
detailsAttributes.put("packageQuantity", "120");
UDISubmissionDetailsIfc glovesBox = createUDIPackagingDetail(submission, (UDIPackaging) parent, detailsAttributes);
if (glovesBox != null) {
details.add(glovesBox);
}
detailsAttributes = new HashMap<>();
detailsAttributes.put("packageDescription", "Carton");
detailsAttributes.put("packageDeviceIdentifer", "35715965485214");
detailsAttributes.put("packageQuantity", "50");
UDISubmissionDetailsIfc glovesCarton = createUDIPackagingDetail(submission,
(UDIPackaging) glovesBox, detailsAttributes);
if (glovesCarton != null) {
details.add(glovesCarton);
}

return details;
}
XConf エントリの作成
特定の UdiSuperSet または UdiSuperSet2 タイプおよびサブタイプに対してカスタムポピュレータを登録するには、カスタム service.properties.xconf ファイルにエントリを作成します。
UdiSuperSet に対して登録する xconf エントリの例:
<Service name="com.ptc.qualitymanagement.udi.UDIAttributePopulatorService">
<Option
requestor="null"
serviceClass="com.ptc.qualitymanagement.udi.superset.CustomUdiSuperSetAttributePopulator"
selector="com.ptc.qualitymanagement.udi.superset.UdiSuperSet"
cardinality="duplicate"
/>
</Service>
UdiSuperSet2 に対して登録する xconf エントリの例:
<Service name="com.ptc.qualitymanagement.udi.UDIAttributePopulatorService">
<Option
requestor="null"
serviceClass="com.ptc.qualitymanagement.udi.superset.CustomUdiSuperSet2AttributePopulator"
selector="com.ptc.qualitymanagement.udi.superset.UdiSuperSet2"
cardinality="duplicate"
/>
</Service>
UdiSuperSet サブタイプに対して登録する xconf エントリの例:
<Service name="com.ptc.qualitymanagement.udi.UDIAttributePopulatorService">
<Option
requestor="null"
serviceClass="com.ptc.qualitymanagement.udi.superset.CustomUdiSuperSetSubType1AttributePopulator"
selector="com.ptc.qualitymanagement.udi.superset.UdiSuperSet|com.acme.UdiSuperSetSubtype1"
cardinality="duplicate"
/>
</Service>
UdiSuperSet2 サブタイプに対して登録する xconf エントリの例:
<Service name="com.ptc.qualitymanagement.udi.UDIAttributePopulatorService">
<Option
requestor="null"
serviceClass="com.ptc.qualitymanagement.udi.superset.CustomUdiSuperSet2SubType1AttributePopulator"
selector="com.ptc.qualitymanagement.udi.superset.UdiSuperSet2|com.acme.UdiSuperSet2Subtype1"
cardinality="duplicate"
/>
</Service>
* 
サブタイプにサービスクラスが存在しない場合、サービスクラスが見つかるまでサブタイプの親タイプがチェックされます。サービスクラスが見つからない場合、サービスクラスが定義されていないクラスとタイプがトレースログエントリで報告されます。ログエントリを表示するには、com.ptc.qualitymanagement.qms.util.helper.QMSServiceClassHelper のトレースログを有効にします。サービスクラスが見つからない場合、属性ポピュレータは呼び出されません。
オーバーライドされた populateFromSource メソッドで設定対象になっている属性名が処理中のタイプに存在しない場合、その属性はスキップされ、エラーが属性とタイプの情報とともにログに記録されます。
これは役に立ちましたか?