protected void initializeExchangeRateDescriptor() { MWClass exchangeRateClass = refreshedTypeNamed( "org.eclipse.persistence.tools.workbench.test.models.currency.ExchangeRate"); MWTable exchangeRateTable = getProject().getDatabase().tableNamed("EXCHANGE_RATE"); MWTableDescriptor descriptor; try { descriptor = (MWTableDescriptor) getProject().addDescriptorForType(exchangeRateClass); } catch (InterfaceDescriptorCreationException e) { throw new RuntimeException(e); } descriptor.setPrimaryTable(exchangeRateTable); // Caching Policy descriptor.getCachingPolicy().setCacheSize(405); descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL); descriptor .getCachingPolicy() .setExistenceChecking(MWCachingPolicy.EXISTENCE_CHECKING_CHECK_DATABASE); // Direct to field mappings addDirectMapping(descriptor, "id", exchangeRateTable, "ID"); addDirectMapping(descriptor, "periodLength", exchangeRateTable, "PERIOD"); // Aggregate mappings MWAggregateMapping currencyRangeMapping = descriptor.addAggregateMapping(descriptor.getMWClass().attributeNamed("currencyRange")); MWClass currencyRangeClass = refreshedTypeNamed( "org.eclipse.persistence.tools.workbench.test.models.currency.CurrencyRange"); MWAggregateDescriptor currencyRangeDescriptor = (MWAggregateDescriptor) getProject().descriptorForType(currencyRangeClass); currencyRangeMapping.setReferenceDescriptor(currencyRangeDescriptor); Iterator fieldAssociations = CollectionTools.sort(currencyRangeMapping.pathsToFields()).iterator(); String[] fieldNames = new String[] {"HI_UNIT", "HI_VALUE", "LO_UNIT", "LO_VALUE", "TREND"}; for (int i = 0; i < fieldNames.length; i++) { MWAggregatePathToColumn association = (MWAggregatePathToColumn) fieldAssociations.next(); association.setColumn(exchangeRateTable.columnNamed(fieldNames[i])); } }
protected void initializeCommodityPriceDescriptor() { MWClass commodityPriceClass = refreshedTypeNamed( "org.eclipse.persistence.tools.workbench.test.models.currency.CommodityPrice"); MWTableDescriptor descriptor; try { descriptor = (MWTableDescriptor) getProject().addDescriptorForType(commodityPriceClass); } catch (InterfaceDescriptorCreationException e) { throw new RuntimeException(e); } MWTable table = tableNamed("COMMODITY_PRICE"); descriptor.setPrimaryTable(table); descriptor.setActive(true); // Direct to field mappings addDirectMapping(descriptor, "id", table, "ID"); addDirectMapping(descriptor, "type", table, "TYPE"); addDirectMapping(descriptor, "periodLength", table, "PERIOD"); // Aggregate mappings MWAggregateMapping currencyRangeMapping = descriptor.addAggregateMapping(descriptor.getMWClass().attributeNamed("currencyRange")); MWClass currencyRangeClass = refreshedTypeNamed( "org.eclipse.persistence.tools.workbench.test.models.currency.CurrencyRange"); currencyRangeMapping.setReferenceDescriptor(getProject().descriptorForType(currencyRangeClass)); Iterator fieldAssociations = CollectionTools.sort(currencyRangeMapping.pathsToFields()).iterator(); String[] fieldNames = new String[] {"HIGH_UNIT", "HIGH_VALUE", "LOW_UNIT", "LOW_VALUE", "TREND"}; for (int i = 0; i < fieldNames.length; i++) { MWAggregatePathToColumn association = (MWAggregatePathToColumn) fieldAssociations.next(); association.setColumn(table.columnNamed(fieldNames[i])); } }