@Override public DataNode createDataNode(DataNodeDescriptor nodeDescriptor) throws Exception { DataNode dataNode = new DataNode(nodeDescriptor.getName()); dataNode.setJdbcEventLogger(jdbcEventLogger); dataNode.setRowReaderFactory(rowReaderFactory); dataNode.setBatchTranslatorFactory(batchTranslatorFactory); dataNode.setDataSourceLocation(nodeDescriptor.getParameters()); DataSource dataSource = dataSourceFactory.getDataSource(nodeDescriptor); dataNode.setDataSourceFactory(nodeDescriptor.getDataSourceFactoryType()); dataNode.setDataSource(dataSource); // schema update strategy String schemaUpdateStrategyType = nodeDescriptor.getSchemaUpdateStrategyType(); if (schemaUpdateStrategyType == null) { dataNode.setSchemaUpdateStrategy(defaultSchemaUpdateStrategy); dataNode.setSchemaUpdateStrategyName(defaultSchemaUpdateStrategy.getClass().getName()); } else { SchemaUpdateStrategy strategy = objectFactory.newInstance(SchemaUpdateStrategy.class, schemaUpdateStrategyType); dataNode.setSchemaUpdateStrategyName(schemaUpdateStrategyType); dataNode.setSchemaUpdateStrategy(strategy); } // DbAdapter dataNode.setAdapter(adapterFactory.createAdapter(nodeDescriptor, dataSource)); return dataNode; }
private void setStrategy(String name, DataNode dataNode) { dataNode.setSchemaUpdateStrategyName(name); try { dataNode.setSchemaUpdateStrategy( (SchemaUpdateStrategy) Class.forName(dataNode.getSchemaUpdateStrategyName()).newInstance()); } catch (Exception e) { throw new CayenneRuntimeException(e); } }
private DataNode createDataNode(DataMap map) { Collection<DataMap> colection = new ArrayList<DataMap>(); colection.add(map); DataNode dataNode = new DataNode(); dataNode.setJdbcEventLogger(jdbcEventLogger); dataNode.setDataMaps(colection); dataNode.setAdapter(adapter); dataNode.setDataSource(dataSourceFactory.getSharedDataSource()); dataNode.setDataSourceFactory(node.getDataSourceFactory()); dataNode.setSchemaUpdateStrategyName(node.getSchemaUpdateStrategyName()); dataNode.setEntityResolver(new EntityResolver(colection)); return dataNode; }