Package org.apache.cayenne.configuration

Examples of org.apache.cayenne.configuration.DataNodeDescriptor


        final Object src = this;
        final DataChannelDescriptor domain = (DataChannelDescriptor) getProjectController()
                .getProject()
                .getRootNode();
        final DataNodeDescriptor node = getProjectController().getCurrentDataNode();

        final ModelMergeDelegate delegate = new ModelMergeDelegate() {

            public void dbAttributeAdded(DbAttribute att) {
                if (c.getCurrentDbEntity() == att.getEntity()) {
View Full Code Here


        if (node == null) {
            return;
        }

        DataNodeDescriptor dataNode = e.getDataNode();
        DefaultMutableTreeNode currentNode = ProjectTreeFactory.wrapProjectNode(dataNode);
        positionNode(node, currentNode, Comparators.getDataDomainChildrenComparator());
        showNode(currentNode);
    }
View Full Code Here

    // ==== Guessing user preferences... *****

    protected DataNodeDescriptor getPreferredNode() {
        ProjectController projectController = getProjectController();
        DataNodeDescriptor node = projectController.getCurrentDataNode();

        // try a node that belongs to the current DataMap ...
        if (node == null) {
            DataMap map = projectController.getCurrentDataMap();
            if (map != null) {
View Full Code Here

    protected String preferredDataSourceLabel(DBConnectionInfo nodeInfo) {
        if (nodeInfo == null) {

            // only driver nodes have meaningful connection info set
            DataNodeDescriptor node = getPreferredNode();
            return (node != null && XMLPoolingDataSourceFactory.class.getName().equals(
                    node.getDataSourceFactoryType())) ? "DataNode Connection Info" : null;
        }

        return nodeInfo.getNodeName();
    }
View Full Code Here

    /**
     * Determines the most reasonable default DataSource choice.
     */
    protected DBConnectionInfo preferredDataSource() {
        DataNodeDescriptor node = getPreferredNode();

        // no current node...
        if (node == null) {
            return null;
        }

        // if node has local DS set, use it
        DataNodeDefaults nodeDefaults = (DataNodeDefaults) getApplication()
                .getCayenneProjectPreferences()
                .getProjectDetailObject(
                        DataNodeDefaults.class,
                        getProjectController().getPreferenceForDataDomain().node(
                                "DataNode").node(node.getName()));

        String key = (nodeDefaults != null) ? nodeDefaults.getLocalDataSource() : null;
        if (key != null) {
            DBConnectionInfo info = (DBConnectionInfo) getApplication()
                    .getCayenneProjectPreferences()
                    .getDetailObject(DBConnectionInfo.class)
                    .getObject(key);

            if (info != null) {
                return info;
            }
        }

        // extract data from the node
        if (!XMLPoolingDataSourceFactory.class.getName().equals(
                node.getDataSourceFactoryType())) {
            return null;
        }

        // create transient object..
        DBConnectionInfo nodeInfo = new DBConnectionInfo();

        nodeInfo.copyFrom(node.getDataSourceDescriptor());

        nodeInfo.setDbAdapter(node.getAdapterType());

        return nodeInfo;
    }
View Full Code Here

        rootNode.getDataMaps().add(new DataMap("C"));
        rootNode.getDataMaps().add(new DataMap("B"));
        rootNode.getDataMaps().add(new DataMap("A"));

        DataNodeDescriptor[] nodes = new DataNodeDescriptor[3];
        nodes[0] = new DataNodeDescriptor("Z");
        nodes[1] = new DataNodeDescriptor("Y");
        nodes[2] = new DataNodeDescriptor("X");

        nodes[0].getDataMapNames().add("C");
        nodes[0].getDataMapNames().add("B");
        nodes[0].getDataMapNames().add("A");
View Full Code Here

public class DefaultDataSourceFactoryLoaderTest extends TestCase {

    public void testGetDataSourceFactory_Implicit() throws Exception {

        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
        nodeDescriptor.setName("node1");
        nodeDescriptor.setDataSourceDescriptor(new DataSourceInfo());

        Module testModule = new Module() {

            public void configure(Binder binder) {
                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
View Full Code Here

        assertTrue(factory instanceof XMLPoolingDataSourceFactory);
    }

    public void testGetDataSourceFactory_Explicit() throws Exception {

        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
        nodeDescriptor.setName("node1");
        nodeDescriptor.setDataSourceFactoryType(MockDataSourceFactory1.class.getName());

        Module testModule = new Module() {

            public void configure(Binder binder) {
                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
View Full Code Here

                "x");
        when(properties.get(Constants.JDBC_URL_PROPERTY)).thenReturn("y");

        DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
        channelDescriptor.setName("X");
        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
        nodeDescriptor.setName("node1");
        nodeDescriptor.setDataSourceFactoryType(MockDataSourceFactory1.class.getName());
        nodeDescriptor.setDataChannelDescriptor(channelDescriptor);

        Module testModule = new Module() {

            public void configure(Binder binder) {
                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
View Full Code Here

    @Inject
    private Injector injector;

    public void testGetDataSource_NameBound() throws Exception {

        DataNodeDescriptor descriptor = new DataNodeDescriptor();
        descriptor.setParameters("jdbc/TestDS");

        JNDISetup.doSetup();

        MockDataSource dataSource = new MockDataSource();
        InitialContext context = new InitialContext();
        context.bind(descriptor.getParameters(), dataSource);

        try {

            JNDIDataSourceFactory factory = new JNDIDataSourceFactory();
            injector.injectMembers(factory);
            assertSame(dataSource, factory.getDataSource(descriptor));
        }
        finally {
            // since the context is shared, must clear it after the test
            context.unbind(descriptor.getParameters());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.configuration.DataNodeDescriptor

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.