MetadataStore store = new MetadataStore();
// Create models
Schema salesforceModel = RealMetadataFactory.createPhysicalModel("SalesforceModel", store); //$NON-NLS-1$
// Create Account group
Table accountTable = RealMetadataFactory.createPhysicalGroup("Account", salesforceModel); //$NON-NLS-1$
accountTable.setNameInSource("Account"); //$NON-NLS-1$
accountTable.setProperty("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
accountTable.setProperty(Constants.SUPPORTS_RETRIEVE, Boolean.TRUE.toString());
// Create Account Columns
String[] acctNames = new String[] {
"ID", "Name", "Stuff", "Industry" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
};
String[] acctTypes = new String[] {
DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING
};
List<Column> acctCols = RealMetadataFactory.createElements(accountTable, acctNames, acctTypes);
acctCols.get(2).setNativeType("multipicklist"); //$NON-NLS-1$
acctCols.get(2).setSearchType(SearchType.Like_Only);
// Set name in source on each column
String[] accountNameInSource = new String[] {
"id", "AccountName", "Stuff", "Industry" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
};
for(int i=0; i<2; i++) {
Column obj = acctCols.get(i);
obj.setNameInSource(accountNameInSource[i]);
}
// Create Contact group
Table contactTable = RealMetadataFactory.createPhysicalGroup("Contacts", salesforceModel); //$NON-NLS-1$
contactTable.setNameInSource("Contact"); //$NON-NLS-1$
contactTable.setProperty("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
// Create Contact Columns
String[] elemNames = new String[] {
"ContactID", "Name", "AccountId", "InitialContact" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
};
String[] elemTypes = new String[] {