Search in sources :

Example 1 with XMLDataChannelDescriptorLoader

use of org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader in project cayenne by apache.

the class DBCleaner method clean.

public void clean() throws SQLException {
    XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
    injector.injectMembers(loader);
    URL url = getClass().getClassLoader().getResource(location);
    ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
    for (DataMap map : tree.getRootNode().getDataMaps()) {
        List<DbEntity> entities = schemaBuilder.dbEntitiesInDeleteOrder(map);
        for (DbEntity entity : entities) {
            dbHelper.deleteAll(entity.getName());
        }
    }
}
Also used : XMLDataChannelDescriptorLoader(org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader) URLResource(org.apache.cayenne.resource.URLResource) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DbEntity(org.apache.cayenne.map.DbEntity) URL(java.net.URL) DataMap(org.apache.cayenne.map.DataMap)

Example 2 with XMLDataChannelDescriptorLoader

use of org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader in project cayenne by apache.

the class ManyToManyCandidateEntityTest method setUp.

@Before
public void setUp() throws Exception {
    Module testModule = binder -> {
        binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class);
        binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
        binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
        binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
        binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
        binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
        binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
    };
    Injector injector = DIBootstrap.createInjector(testModule);
    // create and initialize loader instance to test
    XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
    injector.injectMembers(loader);
    String testConfigName = "relationship-optimisation";
    URL url = getClass().getResource("cayenne-" + testConfigName + ".xml");
    ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
    map = tree.getRootNode().getDataMap(testConfigName);
}
Also used : Injector(org.apache.cayenne.di.Injector) ObjEntity(org.apache.cayenne.map.ObjEntity) HandlerFactory(org.apache.cayenne.configuration.xml.HandlerFactory) XMLReaderProvider(org.apache.cayenne.configuration.xml.XMLReaderProvider) DefaultClassLoaderManager(org.apache.cayenne.di.spi.DefaultClassLoaderManager) Relationship(org.apache.cayenne.map.Relationship) URL(java.net.URL) ConfigurationNameMapper(org.apache.cayenne.configuration.ConfigurationNameMapper) Module(org.apache.cayenne.di.Module) DefaultConfigurationNameMapper(org.apache.cayenne.configuration.DefaultConfigurationNameMapper) AdhocObjectFactory(org.apache.cayenne.di.AdhocObjectFactory) ArrayList(java.util.ArrayList) DataMapLoader(org.apache.cayenne.configuration.DataMapLoader) XMLDataChannelDescriptorLoader(org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader) DefaultObjectNameGenerator(org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator) XMLReader(org.xml.sax.XMLReader) DefaultHandlerFactory(org.apache.cayenne.configuration.xml.DefaultHandlerFactory) ConfigurationTree(org.apache.cayenne.configuration.ConfigurationTree) NoopDataChannelMetaData(org.apache.cayenne.configuration.xml.NoopDataChannelMetaData) NoStemStemmer(org.apache.cayenne.dbsync.naming.NoStemStemmer) XMLDataMapLoader(org.apache.cayenne.configuration.xml.XMLDataMapLoader) DIBootstrap(org.apache.cayenne.di.DIBootstrap) Before(org.junit.Before) URLResource(org.apache.cayenne.resource.URLResource) DefaultAdhocObjectFactory(org.apache.cayenne.di.spi.DefaultAdhocObjectFactory) Test(org.junit.Test) DataChannelMetaData(org.apache.cayenne.configuration.xml.DataChannelMetaData) ClassLoaderManager(org.apache.cayenne.di.ClassLoaderManager) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) Assert(org.junit.Assert) DataMap(org.apache.cayenne.map.DataMap) DefaultAdhocObjectFactory(org.apache.cayenne.di.spi.DefaultAdhocObjectFactory) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DefaultConfigurationNameMapper(org.apache.cayenne.configuration.DefaultConfigurationNameMapper) XMLDataMapLoader(org.apache.cayenne.configuration.xml.XMLDataMapLoader) URL(java.net.URL) NoopDataChannelMetaData(org.apache.cayenne.configuration.xml.NoopDataChannelMetaData) XMLDataChannelDescriptorLoader(org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader) XMLReaderProvider(org.apache.cayenne.configuration.xml.XMLReaderProvider) URLResource(org.apache.cayenne.resource.URLResource) DefaultHandlerFactory(org.apache.cayenne.configuration.xml.DefaultHandlerFactory) Injector(org.apache.cayenne.di.Injector) Module(org.apache.cayenne.di.Module) DefaultClassLoaderManager(org.apache.cayenne.di.spi.DefaultClassLoaderManager) XMLReader(org.xml.sax.XMLReader) Before(org.junit.Before)

Aggregations

URL (java.net.URL)2 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)2 XMLDataChannelDescriptorLoader (org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader)2 DataMap (org.apache.cayenne.map.DataMap)2 URLResource (org.apache.cayenne.resource.URLResource)2 ArrayList (java.util.ArrayList)1 ConfigurationNameMapper (org.apache.cayenne.configuration.ConfigurationNameMapper)1 ConfigurationTree (org.apache.cayenne.configuration.ConfigurationTree)1 DataMapLoader (org.apache.cayenne.configuration.DataMapLoader)1 DefaultConfigurationNameMapper (org.apache.cayenne.configuration.DefaultConfigurationNameMapper)1 DataChannelMetaData (org.apache.cayenne.configuration.xml.DataChannelMetaData)1 DefaultHandlerFactory (org.apache.cayenne.configuration.xml.DefaultHandlerFactory)1 HandlerFactory (org.apache.cayenne.configuration.xml.HandlerFactory)1 NoopDataChannelMetaData (org.apache.cayenne.configuration.xml.NoopDataChannelMetaData)1 XMLDataMapLoader (org.apache.cayenne.configuration.xml.XMLDataMapLoader)1 XMLReaderProvider (org.apache.cayenne.configuration.xml.XMLReaderProvider)1 DefaultObjectNameGenerator (org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator)1 NoStemStemmer (org.apache.cayenne.dbsync.naming.NoStemStemmer)1 AdhocObjectFactory (org.apache.cayenne.di.AdhocObjectFactory)1 ClassLoaderManager (org.apache.cayenne.di.ClassLoaderManager)1