Package org.apache.cayenne.access

Examples of org.apache.cayenne.access.DataNode$TempBatchAction


        if (objEntity == null) {
            throw new CayenneRuntimeException(
                    "No ObjEntity mapping found for DataObject " + getClass().getName());
        }

        DataNode node = getDataContext().getParentDataDomain().lookupDataNode(
                objEntity.getDataMap());
        if (node == null) {
            throw new CayenneRuntimeException("No DataNode found for objEntity: "
                    + objEntity.getName());
        }

        ExtendedTypeMap types = node.getAdapter().getExtendedTypes();

        // validate mandatory attributes

        // handling a special case - meaningful mandatory FK... defer failures until
        // relationship validation is done... This is just a temporary solution, as
View Full Code Here


        for (Iterator it = Configuration
                .getSharedConfiguration()
                .getDomain()
                .getDataNodes()
                .iterator(); it.hasNext();) {
            DataNode dn = (DataNode) it.next();

            EntityResolver er = dn.getEntityResolver();
            object = er.lookupObjEntity(getClass());

            if (null != object) {
                break;
            }
View Full Code Here

        if (sort) {
            nodes = Util.sortedIterator(nodes, ProjectTraversal.dataNodeComparator);
        }

        while (nodes.hasNext()) {
            DataNode node = (DataNode) nodes.next();
            ProjectPath nodePath = path.appendToPath(node);
            handler.projectNode(nodePath);

            if (handler.shouldReadChildren(node, path)) {
                this.traverseMaps(node.getDataMaps().iterator(), nodePath);
            }
        }
    }
View Full Code Here

        return obj instanceof DataMap;
    }

    protected boolean requiresNodeFile(Object obj) {
        if (obj instanceof DataNode) {
            DataNode node = (DataNode) obj;

            // only driver datasource factory requires a file
            if (DriverDataSourceFactory.class.getName().equals(
                    node.getDataSourceFactory())) {
                return true;
            }
        }

        return false;
View Full Code Here

            return "UntitledDataNode";
        }

        @Override
        protected Object create(String name, Object namingContext) {
            return new DataNode(name);
        }
View Full Code Here

    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 {
      // Check if the schema is up to par
      boolean schemaValid = checkSchema(dataSource);
      if(conn != null) {
View Full Code Here

        // 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
View Full Code Here

        String template = "SELECT #result('id' 'int') FROM SUS1";
        SQLTemplate query = new SQLTemplate(Object.class, template);
        DataMap map = getDataMap();
        assertNotNull(map);
        DataNode dataNode = createDataNode(map);
        int sizeDB = getNameTablesInDB(dataNode).size();
        MockOperationObserver observer = new MockOperationObserver();
        try {

            generateDBWithDBGeneratorStrategy(dataNode, query, observer);
            int sizeDB2 = getNameTablesInDB(dataNode).size();
            assertEquals(2, sizeDB2 - sizeDB);
            dataNode.performQueries(Collections.singletonList((Query) query), observer);
            int sizeDB3 = getNameTablesInDB(dataNode).size();
            assertEquals(sizeDB2, sizeDB3);
        }
        finally {
            DataNode dataNode2 = createDataNode(map);
            dataNode2.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
                    dataNode2.getSchemaUpdateStrategyName()).newInstance());
            dropTables(map, dataNode2, observer);
        }
        assertEquals(getNameTablesInDB(dataNode).size(), sizeDB);
    }
View Full Code Here

        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
        SQLTemplate query = new SQLTemplate(Object.class, template);
        DataMap map = getDataMap();
        assertNotNull(map);
        MockOperationObserver observer = new MockOperationObserver();
        DataNode dataNode = createDataNode(map);

        setStrategy(ThrowOnPartialSchemaStrategy.class.getName(), dataNode);

        try {
            dataNode.performQueries(Collections.singletonList((Query) query), observer);
        }
        catch (CayenneRuntimeException e) {
            assertNotNull(e);
        }

        try {
            dataNode.performQueries(Collections.singletonList((Query) query), observer);
        }
        catch (CayenneRuntimeException e) {
            assertNotNull(e);
        }
    }
View Full Code Here

        String template = "SELECT #result('id' 'int') FROM SUS1";
        SQLTemplate query = new SQLTemplate(Object.class, template);
        DataMap map = getDataMap();
        assertNotNull(map);
        DataNode dataNode = createDataNode(map);
        int sizeDB = getNameTablesInDB(dataNode).size();
        MockOperationObserver observer = new MockOperationObserver();

        setStrategy(ThrowOnPartialOrCreateSchemaStrategy.class.getName(), dataNode);

        try {
            dataNode.performQueries(Collections.singletonList((Query) query), observer);
            Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
            assertTrue(nameTables.get("sus1") != null || nameTables.get("SUS1") != null);
            int sizeDB2 = getNameTablesInDB(dataNode).size();
            assertEquals(2, sizeDB2 - sizeDB);
            dataNode.performQueries(Collections.singletonList((Query) query), observer);
            int sizeDB3 = getNameTablesInDB(dataNode).size();
            assertEquals(sizeDB2, sizeDB3);
        }
        finally {
            DataNode dataNode2 = createDataNode(map);
            dataNode2.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
                    dataNode2.getSchemaUpdateStrategyName()).newInstance());
            dropTables(map, dataNode2, observer);
        }
        assertEquals(getNameTablesInDB(dataNode).size(), sizeDB);

    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.access.DataNode$TempBatchAction

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.