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

WBIMetadataTreeImpl samples

WBIMetadataTreeImpl represents the object that holds the metadataObject nodes of the tree that IBM Integration Designer displays for enterprise metadata discovery.

Extend the WBIMetadataTreeImpl class and implement the methods described below.


Constructor

The constructor takes MetadataConnection as an argument. The constructor can also return properties from MetadataConnection that were used to start the discovery service; for example, prefix, directory name, and those properties that populate the MetadataObject nodes in the tree.

public EISSAMetadataTree(MetadataConnection connection,PropertyNameHelper helper) {
		super(connection,helper);
		this.helper = helper;
		
		WBIOutboundConnectionConfigurationImpl conf = 
(WBIOutboundConnectionConfigurationImpl)
 connection.getConnectionCofiguration();
		PropertyGroup pg = conf.getAppliedProperties();
		WBIFolderProperty xsdFilesPathProp =
(WBIFolderProperty) pg.getProperty("XSDFolder");
		xsdFolderPath = xsdFilesPathProp.getValue().toString();
		
	}


createMetadataSelection

The createMetadataSelection() method returns an instance of the specific MetadataSelection class. The enterprise metadata discovery implementation extends WBIMetadataSelectionImpl and returns an instance of that class in this method.

public MetadataSelection createMetaDataSelection() {
		return new EISSAMetadataSelection();
	}


createFilterProperties

The createFilterProperties() method returns a property group instance used to perform filtering for nodes of the tree. This filter is used for displaying top-level nodes on the tree only.

public PropertyGroup createFilterProperties() {
WBIPropertyGroupImpl propertyGroup = null;
try {
propertyGroup = new WBIPropertyGroupImpl
(Constants.SELECTION_PROPERTIES);
propertyGroup.setDisplayName
(WBIMetadataDiscoveryImpl.getPropertyName
(Constants.SELECTIONPROPERTIES));
propertyGroup.setDescription
(WBIMetadataDiscoveryImpl.getPropertyDescription
(Constants.SELECTIONPROPERTIES));
WBISingleValuedPropertyImpl typeProp = 
new WBISingleValuedPropertyImpl
(Constants.SERVICETYPE, String.class);
String[] values = { Constants.INBOUND, Constants.OUTBOUND };
typeProp.setValidValues(values);
typeProp.setDefaultValue(Constants.OUTBOUND);
typeProp.setDisplayName
(WBIMetadataDiscoveryImpl.getPropertyName
(Constants.SERVICETYPE));
typeProp.setDescription
(WBIMetadataDiscoveryImpl.getPropertyDescription
(Constants.SERVICETYPE));
propertyGroup.addProperty(typeProp);
WBISingleValuedPropertyImpl nameSpaceProp =
new WBISingleValuedPropertyImpl
(Constants.NAMESPACE, String.class);
nameSpaceProp.setDefaultValue(Constants.TB_DEFAULT_NAMESPACE);
propertyGroup.addProperty(nameSpaceProp);
nameSpaceProp.setDisplayName
(WBIMetadataDiscoveryImpl.getPropertyName
(Constants.NAMESPACE));
nameSpaceProp.setDescription
(WBIMetadataDiscoveryImpl.getPropertyDescription
(Constants.NAMESPACE));
ServiceTypeSingleProperty operationProp =
new ServiceTypeSingleProperty
(Constants.OPERATIONS, String.class);
String[] operations = 
<AdapterPrefixName>Operations.getOutboundOperations(); 
operationProp.setValidValues(operations);
operationProp.setDisplayName
(WBIMetadataDiscoveryImpl.getPropertyName
 (Constants.OPERATIONS)); 
operationProp.setDescription 
(WBIMetadataDiscoveryImpl.getPropertyDescription 
(Constants.OPERATIONS)); 
propertyGroup.addProperty(operationProp); }  catch (MetadataException e) { throw new RuntimeException(e); } return propertyGroup; } 


getMetadataObject

The getMetadataObject() method returns an instance of MetadataObject for a specific location. Each MetadataObject instance that is added to the MetadataTree should have a unique location such that when the tool calls this method, the enterprise metadata discovery implementation can find the corresponding MetadataObject and return it.

Tip: A sample implementation might usefully maintain a HashTable in MetadataTree and add the location and corresponding MetadataObject to it whenever a new instance of MetadataObject is added. Then this method could return an object corresponding to the key value from Hashtable .

public MetadataObject getMetadataObject(String locationId) {
		return (MetadataObject) treeNodes.get(locationId);
	}


listMetadataObjects

The listMetadataObjects() method returns an instance of WBIMetadataObjectResponseImpl. The instance should be populated with MetadataObjects using method setObjects(). The logic should use filter properties, if supported by the implementation. Any metadataObjects that can be selected for import should be set as true with the setIsSelectableForImport() method.

	public MetadataObjectResponse listMetadataObjects(PropertyGroup filterParameters)
throws MetadataException {

		WBIMetadataObjectResponseImpl response =
new WBIMetadataObjectResponseImpl();
		ArrayList objects = new ArrayList();

		String[] fileNames = getFileNames(this.xsdFolderPath);
		String directory = new File(this.xsdFolderPath).getAbsolutePath();
		if (!directory.endsWith(File.separator)) {
			directory = directory + File.separator;
		} 		String fileLocation = null;
		ArrayList objectsRegular = null;
		if (fileNames != null && fileNames.length > 0) {
			for (int i = 0; i < fileNames.length; i++) {
				try {
					fileLocation = directory + fileNames[i];
					BOSchema schema = new BOSchema(fileLocation, WBIBiDiConstants.EMPTY_STR);
					Hashtable types = schema.getBOTypes();
					File file = new File(fileLocation);
					FileInputStream fs = new FileInputStream(file);
					int size = fs.available();
					byte[] bytes = new byte[size];
					fs.read(bytes);
					objectsRegular = 
prepareSelectionObjectList(bytes, types, fileLocation);
					objects.addAll(objectsRegular);
				} catch (Exception e) {
					
						
					throw new MetadataException
("Unable to load objects " + e.getMessage(), e);
				}				
			} 		} 		response.setObjects(objects);
		
		return response;
	}

Enterprise metadata discovery implementation samples