Examples of DataDomain


Examples of org.apache.cayenne.access.DataDomain

  public static boolean validate() {
    DatabaseSettings settings = new DatabaseSettings();
    settings.load();

    // Get the Cayenne map
    DataDomain domain = Configuration.getSharedConfiguration().getDomain("BNUBotDomain");
    DataNode dataNode = domain.getNode("BNUBotDataNode");
    DataMap dataMap = domain.getMap("BNUBotMap");

    DataSource dataSource = dataNode.getDataSource();
    DbAdapter adapter = dataNode.getAdapter();

    try {
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

    }

    @Override
    protected DataDomain createAndInitDataDomain() throws Exception {

        DataDomain domain = super.createAndInitDataDomain();

        // add nodes dynamically
        // TODO: andrus, 06/14/2010 should probably map them in XML to avoid this mess...
        for (DataMap dataMap : domain.getDataMaps()) {

            DataNode node = new DataNode(dataMap.getName());
            node.setDataSource(dataSource);
            node.setAdapter(adapter);
            node.addDataMap(dataMap);
            node.setSchemaUpdateStrategy(new SkipSchemaUpdateStrategy());

            // customizations from SimpleAccessStackAdapter that are not yet ported...
            // those can be done better now

            // node
            // .getAdapter()
            // .getExtendedTypes()
            // .registerType(new StringET1ExtendedType());
            //
            // // tweak mapping with a delegate
            // for (Procedure proc : map.getProcedures()) {
            // getAdapter(node).tweakProcedure(proc);
            // }

            // use shared data source in all cases but the multi-node...
            // if (MultiNodeCase.NODE1.equals(node.getName())
            // || MultiNodeCase.NODE2.equals(node.getName())) {
            // node.setDataSource(resources.createDataSource());
            // }
            // else {
            // node.setDataSource(resources.getDataSource());
            // }

            domain.addNode(node);
        }

        return domain;
    }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

        ServletContext servletContext = sce.getServletContext();

        ServletUtil.initializeSharedConfiguration(servletContext);

        try {
            DataDomain cayenneDomain =
                Configuration.getSharedConfiguration().getDomain();
            DataMap dataMap = cayenneDomain.getMap("cayenneMap");
            DataNode dataNode = cayenneDomain.getNode("cayenneNode");

            initDatabaseSchema(dataNode, dataMap);

            loadDatabase();
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

public class DataContextFactoryTest extends TestCase {

    public void testCreateDataContextWithDedicatedCache() throws Exception {

        final EventManager eventManager = new MockEventManager();
        final DataDomain domain = new DataDomain("d1");

        domain.setSharedCacheEnabled(false);

        Module testModule = new Module() {

            public void configure(Binder binder) {
                binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
                binder.bind(DataDomain.class).toInstance(domain);
                binder.bind(EventManager.class).toInstance(eventManager);
                binder.bind(QueryCache.class).toInstance(new MapQueryCache(5));
                binder
                        .bind(
                                Key.get(
                                        QueryCache.class,
                                        BaseContext.QUERY_CACHE_INJECTION_KEY))
                        .toInstance(new MapQueryCache(5));
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DataContextFactory factory = new DataContextFactory();
        injector.injectMembers(factory);

        DataContext c3 = (DataContext) factory.createContext();
        assertNotNull(c3.getObjectStore().getDataRowCache());
        assertNull(domain.getSharedSnapshotCache());
        assertNotSame(c3.getObjectStore().getDataRowCache(), domain
                .getSharedSnapshotCache());
    }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

                .getSharedSnapshotCache());
    }

    public void testCreateDataContextValidation() throws Exception {
        final EventManager eventManager = new MockEventManager();
        final DataDomain domain = new DataDomain("d1");

        domain.setValidatingObjectsOnCommit(true);

        Module testModule = new Module() {

            public void configure(Binder binder) {
                binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
                binder.bind(DataDomain.class).toInstance(domain);
                binder.bind(EventManager.class).toInstance(eventManager);
                binder.bind(QueryCache.class).toInstance(new MapQueryCache(5));
                binder
                        .bind(
                                Key.get(
                                        QueryCache.class,
                                        BaseContext.QUERY_CACHE_INJECTION_KEY))
                        .toInstance(new MapQueryCache(5));
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DataContextFactory factory = new DataContextFactory();
        injector.injectMembers(factory);

        DataContext c1 = (DataContext) factory.createContext();
        assertTrue(c1.isValidatingObjectsOnCommit());

        domain.setValidatingObjectsOnCommit(false);

        DataContext c2 = (DataContext) factory.createContext();
        assertFalse(c2.isValidatingObjectsOnCommit());
    }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

        DataChannel channel = provider.get();
        assertNotNull(channel);

        assertTrue(channel instanceof DataDomain);

        DataDomain domain = (DataDomain) channel;
        assertSame(eventManager, domain.getEventManager());
        assertEquals(2, domain.getDataMaps().size());
        assertTrue(domain.getDataMaps().contains(map1));
        assertTrue(domain.getDataMaps().contains(map2));

        assertEquals(2, domain.getDataNodes().size());
        DataNode node1 = domain.getNode("node1");
        assertNotNull(node1);
        assertEquals(1, node1.getDataMaps().size());
        assertSame(map1, node1.getDataMaps().iterator().next());
        assertSame(node1, domain.lookupDataNode(map1));
        assertEquals(nodeDescriptor1.getDataSourceFactoryType(), node1
                .getDataSourceFactory());
        assertNotNull(node1.getDataSource());
        assertEquals(nodeDescriptor1.getParameters(), node1.getDataSourceLocation());

        assertEquals(nodeDescriptor1.getSchemaUpdateStrategyType(), node1
                .getSchemaUpdateStrategyName());
        assertNotNull(node1.getSchemaUpdateStrategy());
        assertEquals(nodeDescriptor1.getSchemaUpdateStrategyType(), node1
                .getSchemaUpdateStrategy()
                .getClass()
                .getName());

        assertNotNull(node1.getAdapter());
        assertEquals(OracleAdapter.class, node1.getAdapter().getClass());

        DataNode node2 = domain.getNode("node2");
        assertNotNull(node2);
        assertEquals(1, node2.getDataMaps().size());
        assertSame(map2, node2.getDataMaps().iterator().next());
        assertSame(node2, domain.lookupDataNode(map2));
        assertNull(node2.getDataSourceFactory());
        assertNotNull(node2.getDataSource());
        assertEquals(nodeDescriptor2.getParameters(), node2.getDataSourceLocation());
        assertEquals(SkipSchemaUpdateStrategy.class.getName(), node2
                .getSchemaUpdateStrategyName());
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

     *
     * @return a pooled SQL connection
     * @throws SQLException if a database connection could not be obtained
     */
    protected Connection getConnection() throws SQLException {
        DataDomain domain = Configuration.getSharedConfiguration().getDomain();

        DataNode node = (DataNode) domain.getDataNodes().iterator().next();

        return node.getDataSource().getConnection();
    }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

            if (namingContext == null) {
                return false;
            }

            if (namingContext instanceof DataDomain) {
                DataDomain domain = (DataDomain) namingContext;
                return domain.getDataMap(name) != null;
            }

            if (namingContext instanceof DataChannelDescriptor) {
                DataChannelDescriptor domain = (DataChannelDescriptor) namingContext;
                return domain.getDataMap(name) != null;
            }
            return false;

        }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

            return new DataNode(name);
        }

        @Override
        protected boolean isNameInUse(String name, Object namingContext) {
            DataDomain domain = (DataDomain) namingContext;
            return domain.getNode(name) != null;
        }
View Full Code Here

Examples of org.apache.cayenne.access.DataDomain

        node = new DataNode("mergenode");
        node.setAdapter(orgNode.getAdapter());
        node.setDataSource(orgNode.getDataSource());
        node.addDataMap(map);
       
        domain = new DataDomain("mergetestdomain");
        domain.setEntitySorter(new AshwoodEntitySorter());
        domain.addNode(node);

        filterDataMap(node, map);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.