Package org.apache.cayenne.access

Examples of org.apache.cayenne.access.DbLoader


        ResultSet rs = null;
        try {
            conn = dataSource.getConnection();

            final DbMerger merger = this;
            DbLoader dbLoader = new DbLoader(conn, adapter, new LoaderDelegate()) {

                @Override
                public boolean includeTableName(String tableName) {
                    return merger.includeTableName(tableName);
                }
            };
           
            DataMap detectedDataMap = dbLoader.loadDataMapFromDB(
                    null,
                    null,
                    new DataMap());

            Map<String, DbEntity> dbEntityToDropByName = new HashMap<String, DbEntity>(
View Full Code Here


        ResultSet rs = null;
        try {
            conn = dataSource.getConnection();

            final DbMerger merger = this;
            DbLoader dbLoader = new DbLoader(conn, adapter, new LoaderDelegate()) {

                @Override
                public boolean includeTableName(String tableName) {
                    return merger.includeTableName(tableName);
                }
            };
           
            DataMap detectedDataMap = dbLoader.loadDataMapFromDB(
                    null,
                    null,
                    new DataMap());

            Map<String, DbEntity> dbEntityToDropByName = new HashMap<String, DbEntity>(
View Full Code Here

        ResultSet rs = null;
        try {
            conn = dataSource.getConnection();

            final DbMerger merger = this;
            DbLoader dbLoader = new DbLoader(conn, adapter, new LoaderDelegate()) {

                @Override
                public boolean includeTableName(String tableName) {
                    return merger.includeTableName(tableName);
                }
            };
           
            DataMap detectedDataMap = dbLoader.loadDataMapFromDB(
                    null,
                    null,
                    new DataMap());
           
            detectedDataMap.setQuotingSQLIdentifiers(dataMap.isQuotingSQLIdentifiers());
View Full Code Here

        ResultSet rs = null;
        try {
            conn = dataSource.getConnection();

            final DbMerger merger = this;
            DbLoader dbLoader = new DbLoader(conn, adapter, new LoaderDelegate()) {

                @Override
                public boolean includeTableName(String tableName) {
                    return merger.includeTableName(tableName);
                }
            };
           
            DataMap detectedDataMap = dbLoader.loadDataMapFromDB(
                    null,
                    null,
                    new DataMap());
           
            detectedDataMap.setQuotingSQLIdentifiers(dataMap.isQuotingSQLIdentifiers());
View Full Code Here

        Connection conn = null;
        ResultSet rs = null;
        try {
            conn = dataSource.getConnection();

            DbLoader dbLoader = new DbLoader(conn, adapter, new LoaderDelegate());
            DataMap detectedDataMap = dbLoader.loadDataMapFromDB(
                    null,
                    null,
                    new DataMap());

            Map<String, DbEntity> dbEntityToDropByName = new HashMap<String, DbEntity>(
View Full Code Here

        DbImportParameters parameters = new DbImportParameters();

        Connection connection = mock(Connection.class);

        DbLoader loader = action.createLoader(parameters, mock(DbAdapter.class), connection,
                mock(DbLoaderDelegate.class));
        assertNotNull(loader);
        assertSame(connection, loader.getConnection());
        assertTrue(loader.includeTableName("dummy"));
    }
View Full Code Here

        DbImportAction action = i.getInstance(DbImportAction.class);

        DbImportParameters parameters = new DbImportParameters();
        parameters.setIncludeTables("a,b,c*");

        DbLoader loader1 = action.createLoader(parameters, mock(DbAdapter.class), mock(Connection.class),
                mock(DbLoaderDelegate.class));

        assertFalse(loader1.includeTableName("dummy"));
        assertFalse(loader1.includeTableName("ab"));
        assertTrue(loader1.includeTableName("a"));
        assertTrue(loader1.includeTableName("b"));
        assertTrue(loader1.includeTableName("cd"));

        parameters.setExcludeTables("cd");

        DbLoader loader2 = action.createLoader(parameters, mock(DbAdapter.class), mock(Connection.class),
                mock(DbLoaderDelegate.class));

        assertFalse(loader2.includeTableName("dummy"));
        assertFalse(loader2.includeTableName("ab"));
        assertTrue(loader2.includeTableName("a"));
        assertTrue(loader2.includeTableName("b"));
        assertFalse(loader2.includeTableName("cd"));
        assertTrue(loader2.includeTableName("cx"));
    }
View Full Code Here

        DbImportAction action = i.getInstance(DbImportAction.class);

        DbImportParameters parameters = new DbImportParameters();
        assertNull(parameters.getMeaningfulPkTables());

        DbLoader loader1 = action.createLoader(parameters, mock(DbAdapter.class), mock(Connection.class),
                mock(DbLoaderDelegate.class));

        DataMap map = new DataMap();

        DbEntity e1 = new DbEntity("e1");
        DbAttribute pk = new DbAttribute("pk", Types.INTEGER, e1);
        pk.setPrimaryKey(true);
        e1.addAttribute(pk);
        DbAttribute nonPk = new DbAttribute("nonPk", Types.INTEGER, e1);
        e1.addAttribute(nonPk);

        map.addDbEntity(e1);

        // DbLoader is so ugly and hard to test..
        Field dbEntityList = DbLoader.class.getDeclaredField("dbEntityList");
        dbEntityList.setAccessible(true);
        List<DbEntity> entities = (List<DbEntity>) dbEntityList.get(loader1);
        entities.add(e1);

        loader1.loadObjEntities(map);

        ObjEntity oe1 = map.getObjEntity("E1");
        assertEquals(1, oe1.getAttributes().size());
        assertNotNull(oe1.getAttribute("nonPk"));
    }
View Full Code Here

        DbImportAction action = i.getInstance(DbImportAction.class);

        DbImportParameters parameters = new DbImportParameters();
        parameters.setMeaningfulPkTables("a*");

        DbLoader loader1 = action.createLoader(parameters, mock(DbAdapter.class), mock(Connection.class),
                mock(DbLoaderDelegate.class));

        // DbLoader is so ugly and hard to test..
        Field dbEntityList = DbLoader.class.getDeclaredField("dbEntityList");
        dbEntityList.setAccessible(true);
        List<DbEntity> entities = (List<DbEntity>) dbEntityList.get(loader1);

        DataMap map = new DataMap();

        DbEntity e1 = new DbEntity("e1");
        DbAttribute pk = new DbAttribute("pk", Types.INTEGER, e1);
        pk.setPrimaryKey(true);
        e1.addAttribute(pk);
        DbAttribute nonPk = new DbAttribute("nonPk", Types.INTEGER, e1);
        e1.addAttribute(nonPk);

        map.addDbEntity(e1);
        entities.add(e1);

        DbEntity a1 = new DbEntity("a1");
        DbAttribute apk = new DbAttribute("pk", Types.INTEGER, a1);
        apk.setPrimaryKey(true);
        a1.addAttribute(apk);
        DbAttribute anonPk = new DbAttribute("nonPk", Types.INTEGER, a1);
        a1.addAttribute(anonPk);

        map.addDbEntity(a1);
        entities.add(a1);

        loader1.loadObjEntities(map);

        ObjEntity oe1 = map.getObjEntity("E1");
        assertEquals(1, oe1.getAttributes().size());
        assertNotNull(oe1.getAttribute("nonPk"));

View Full Code Here

        DbImportAction action = i.getInstance(DbImportAction.class);

        DbImportParameters parameters = new DbImportParameters();
        parameters.setUsePrimitives(false);

        DbLoader loader1 = action.createLoader(parameters, mock(DbAdapter.class), mock(Connection.class),
                mock(DbLoaderDelegate.class));

        DataMap map = new DataMap();

        DbEntity e1 = new DbEntity("e1");
        DbAttribute nonPk = new DbAttribute("nonPk", Types.INTEGER, e1);
        e1.addAttribute(nonPk);

        map.addDbEntity(e1);

        // DbLoader is so ugly and hard to test..
        Field dbEntityList = DbLoader.class.getDeclaredField("dbEntityList");
        dbEntityList.setAccessible(true);
        List<DbEntity> entities = (List<DbEntity>) dbEntityList.get(loader1);
        entities.add(e1);

        loader1.loadObjEntities(map);

        ObjEntity oe1 = map.getObjEntity("E1");

        ObjAttribute oa1 = (ObjAttribute) oe1.getAttribute("nonPk");
        assertEquals("java.lang.Integer", oa1.getType());
View Full Code Here

TOP

Related Classes of org.apache.cayenne.access.DbLoader

Copyright © 2018 www.massapicom. 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.