IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > Adapter Toolkit > Implementing code from the IBM WebSphere Adapter Toolkit > Enterprise metadata discovery general interfaces and implementation for application adapters > Enterprise metadata discovery implementation samples
WBIDataDescriptionImpl samples
WBIDataDescriptionImpl represents the data description interface. This interface maps business object definitions to Java™ objects.
prepareChildSchemaFiles
The prepareChildSchemaFiles() method creates child objects when a parent object cannot do so. If your adapter requires a separate and recursive creating of child objects, then implement this method. Its should call recursively as shown:
prepareChildSchemaFiles(); prepareSchemaFiles();public void prepareChildSchemaFiles() throws MetadataException { MetadataObjectResponse response = getMetadataObject().getChildren(null); EISSAMetadataObject child = null; Iterator i = response.getObjectIterator(); while (i.hasNext()) { child = (EISSAMetadataObject) i.next(); if (child.getBOType() != null) { if (child.getTargetNameSpace().equals(((EISSAMetadataObject) this.getMetadataObject()).getTargetNameSpace()) && child.isPartOfSameXSD()) { includeXSDs.append("<" + child.getAliasTag() + "include schemaLocation=\"" + child.getBOName() + ".xsd\" />\n"); } boolean found = false; for (int j = 0; j < selectedSet.length; j++) { EISSAMetadataObject selectedObj = (EISSAMetadataObject) ((EISSAMetadataImportConfiguration) selectedSet[j]).getMetadataObject(); if (selectedObj.getLocation().equals(child.getLocation())) { found = true; break; } } if (found) continue; // Generate the schemas for grand and following level children EISSADataDescription desc = new EISSADataDescription(child, selectedSet); desc.setRelativePath(this.getRelativePath()); desc.setAliasTag(child.getAliasTag()); desc.prepareChildSchemaFiles(); SchemaDefinition[] schemas = desc.getSchemaDefinitions(); for (int j = 0; j < schemas.length; j++) { SchemaDefinition defn = schemas[j]; put(defn.getNamespace(), defn.getLocation(), defn.getContent()); } // If not found continue to add the defn of the child object String complexTypeInfo = child.getContent().substring(0, child.getContent().indexOf(">") + 1) + System.getProperty("line.separator"); String header = child.getHeader(); int encoding = header.indexOf("encoding"); if (encoding != -1) { String encodingName = header.substring (encoding + 10, header.indexOf("\"", encoding + 10)); if (!encodingName.equalsIgnoreCase("UTF-8")) header = header.substring(0, encoding + 10) + "UTF-8" + header.substring(header.indexOf("\"", encoding + 10)); } String content = header + desc.getIncludeXSDs() + getSerializedImports(this.getImportNameSpaces()) + System.getProperty("line.separator") + getSerializedAnnotationForEMD(getASISchemaName()) + complexTypeInfo + getSerializedMetadata(this.getMetadataForBusinessObject()) + child.getContent().substring(child.getContent().indexOf(">") + 1); URI uri = null; try { uri = new URI(this.getRelativePath() + child.getBOName() + ".xsd"); } catch (URISyntaxException use) { throw new MetadataException(use.getMessage(),use); } put(child.getTargetNameSpace(), uri, content); } else { EISSADataDescription boDesc = new EISSADataDescription(child, selectedSet); boDesc.setRelativePath(this.getRelativePath()); boDesc.setAliasTag(child.getAliasTag()); boDesc.populateSchemaDefinitions(); SchemaDefinition[] schemas = boDesc.getSchemaDefinitions(); for (int j = 0; j < schemas.length; j++) { SchemaDefinition defn = schemas[j]; put(defn.getNamespace(), defn.getLocation(), defn.getContent()); } } }
getVerbs
The getVerbs() method returns a list of verbs when the data description represents a top-level object that supports verbs.
public List getVerbs() { ArrayList list = new ArrayList(); list.add(TopLevelVerbs.CREATE_TLV); list.add(TopLevelVerbs.UPDATE_TLV); list.add(TopLevelVerbs.DELETE_TLV); return list; }
getMetadataForAttribute
The getMetadataForAttribute() method returns an instance of the WBIMetadata object and represents application specific information for the element or field in the object definition. This corresponds to the annotation section for the element definition.
public WBIMetadata getMetadataForAttribute(String attrName) { WBIMetadata attributeMetadata = new WBIMetadata(); attributeMetadata.setSource(Constants.ASI_TARGET_NAMESPACE); attributeMetadata.setObjectNameSpace(Constants.ATTR_APPINFO_ASI_TYPE_TAG); QName asiNamespace = new QName (Constants.ASI_TARGET_NAMESPACE, Constants.ASI); attributeMetadata.setNameSpace(asiNamespace); attributeMetadata.setASI(Constants.FIELD_NAME, attrName); if (attrName.equalsIgnoreCase(Constants.PRIMARYKEY)) { attributeMetadata.setASI(Constants.PRIMARY_KEY, "true"); } return attributeMetadata; }
getMetadataForBusinessObject
The getMetadataForBusinessObject() method returns an instance of the WBIMetadata object and represents application specific information for the object definition. This corresponds to the annotation section for the complexType definition.
public WBIMetadata getMetadataForBusinessObject() { WBIMetadataDiscoveryImpl.getLogUtils().traceMethodEntrance (CLASSNAME, "getMetadataForBusinessObject"); WBIMetadata bometadata = new WBIMetadata(); bometadata.setSource(Constants.ASI_TARGET_NAMESPACE); QName namespace = new QName(Constants.ASI_TARGET_NAMESPACE, Constants.ASI); bometadata.setNameSpace(namespace); bometadata.setObjectNameSpace(Constants.BUS_OBJ_APPINFO_ASI_TYPE_TAG); bometadata.setASI(Constants.ASI_OBJECTNAME, this.getMetadataObject().getDisplayName()); WBIMetadataDiscoveryImpl.getLogUtils().traceMethodExit (CLASSNAME, "getMetadataForBusinessObject"); return bometadata; } // End of BO level metadata
isContainer
The isContainer() method returns true when the complexType definition requires a Container definition with the graph definition. The Container definition is used when the adapter supports a RetrieveAll operation.
public boolean isContainer() { WBIMetadataDiscoveryImpl.getLogUtils().traceMethodEntrance (CLASSNAME, "isContainer"); boolean retValue = false; String objName = getName().getLocalPart(); if (objName.endsWith("Container") && !objName.equals(getBOName())) retValue = true; WBIMetadataDiscoveryImpl.getLogUtils().traceMethodExit (CLASSNAME, "isContainer"); return retValue; }
getType
The getType() method returns the XML schema definition type that represents the element or field of the object definition.
public String getType(String attrName) { LinkedHashMap ht = this.getAttributeList(); EISSAAttributeType vtaAttrType = (EISSAAttributeType) ht.get(attrName); return vtaAttrType.getType(); }
getAttributeName
The getAttributeName() method returns the element name that represents the field in the object. This is the element name that would be used in the XML schema definition.
public String getAttributeName(String attrName) { return StringCaseChanger.toCamelCase(attrName); }
getImportNameSpaces
The getImportNameSpaces() method returns a list of ImportedNameSpace instances that should be imported in the business object schema.
public List getImportNameSpaces() throws MetadataException { WBIMetadataDiscoveryImpl.getLogUtils().traceMethodEntrance (CLASSNAME, "getImportNameSpaces"); ArrayList list = new ArrayList(); ImportedNameSpace namespace = new ImportedNameSpace(); namespace.setLocation(Constants.<AdapterPrefixName>ASI_XSD); namespace.setNameSpace(Constants.ASI_TARGET_NAMESPACE); list.add(namespace); 140 WebSphere Adapters: WebSphere Adapter Toolkit User Guide WBIMetadataDiscoveryImpl.getLogUtils().traceMethodExit (CLASSNAME, "getImportNameSpaces"); return list;}
getNameSpaces
The getNameSpaces() method returns the NameSpaces listed in the XML schema definition. Typically these are application specific information schema definition namespaces. If that this list is for outside namespaces only; child object namespaces are included by the Adapter Foundation Classes.
public List getNameSpaces() { WBIMetadataDiscoveryImpl.getLogUtils().traceMethodEntrance (CLASSNAME, "getNameSpaces"); ArrayList list = new ArrayList(); list.add(new QName(Constants.ASI_TARGET_NAMESPACE, Constants.ASI)); WBIMetadataDiscoveryImpl.getLogUtils().traceMethodExit (CLASSNAME, "getNameSpaces"); return list; }
getASISchemaName
The getASISchemaName() method returns the target namespace that represents the application specific information schema.
public String getASISchemaName() { return Constants.ASI_TARGET_NAMESPACE; }
getCardinality
The getCardinality() method returns the cardinality for an elements in the business object definition. This value is used to formulate the maxOccurs and minOccurs tag.
public String getCardinality(String name) { LinkedHashMap ht = this.getAttributeList(); EISSAAttributeType vtaAttrType = (EISSAAttributeType) ht.get(name); return vtaAttrType.getCardinality(); }
getMaxLength
The getMaxLength() method returns the maxLength for the elements in the business object definition. This is used to fill in the maxLength tag for the XML schema definition.
public int getMaxLength(String name) { return 0; }
getRequired
The getRequired() method returns true if the element is marked as required in the XML schema definition. Otherwise, this method returns false.
public boolean getRequired(String attrName) { return false; }
getChildList
The getChildList() method returns the Iterator for the child objects of the DataDescription.
public Iterator getChildList() throws MetadataException { return (this.getMetadataObject().getChildren(null)).getObjectIterator(); }