Package org.apache.cayenne.configuration

Examples of org.apache.cayenne.configuration.DataNodeDescriptor


    }

    public void testNameChange() throws Exception {
        MapEvent event = new DataNodeEvent(
                new Object(),
                new DataNodeDescriptor("someName"),
                "someOldName");
        assertEquals("someName", event.getNewName());
        assertTrue(event.isNameChange());
    }
View Full Code Here


            return;
        }

        DataChannelDescriptor domain = new DataChannelDescriptor();
        domain.setName("aa");
        DataNodeDescriptor node = action.buildDataNode(domain);

        assertNotNull(node);
        assertNotNull(node.getName());

        DataSourceInfo ds1 = new DataSourceInfo();
        node.setDataSourceDescriptor(ds1);

        assertSame("Project DataNode must not wrap the DataSource", ds1, node
                .getDataSourceDescriptor());
    }
View Full Code Here

    /**
     * Returns preferences object for the current DataMap, throwing an exception if no
     * DataMap is selected.
     */
    public DataNodeDefaults getDataNodePreferences() {
        DataNodeDescriptor node = getCurrentDataNode();
        if (node == null) {
            throw new CayenneRuntimeException("No DataNode selected");
        }

        return (DataNodeDefaults) application
                .getCayenneProjectPreferences()
                .getProjectDetailObject(
                        DataNodeDefaults.class,
                        getPreferenceForDataDomain()
                                .node("DataNode")
                                .node(node.getName()));

    }
View Full Code Here

    /**
     * @see org.apache.cayenne.modeler.util.CayenneAction#performAction(ActionEvent)
     */
    public void performAction(ActionEvent e) {
        DataNodeDescriptor node = buildDataNode();
        createDataNode(node);
        application.getUndoManager().addEdit(
                new CreateNodeUndoableEdit(application, node));
    }
View Full Code Here

        ProjectController mediator = getProjectController();
        DataChannelDescriptor domain = (DataChannelDescriptor) mediator
                .getProject()
                .getRootNode();

        DataNodeDescriptor node = buildDataNode(domain);

        DataSourceInfo src = new DataSourceInfo();
        node.setDataSourceDescriptor(src);

        // by default create JDBC Node
        node.setDataSourceFactoryType(XMLPoolingDataSourceFactory.class.getName());
        node.setSchemaUpdateStrategyType(SkipSchemaUpdateStrategy.class.getName());

        return node;
    }
View Full Code Here

    DataNodeDescriptor buildDataNode(DataChannelDescriptor domain) {
        String name = NamedObjectFactory.createName(
                DataNodeDescriptor.class,
                domain);

        DataNodeDescriptor node = new DataNodeDescriptor(name);
        node.setDataChannelDescriptor(domain);

        return node;
    }
View Full Code Here

            CreateNodeAction nodeBuilder = (CreateNodeAction) getApplication().getActionManager().getAction(
                    CreateNodeAction.class);

            // this should make created node current, resulting in the new map being added
            // to the node automatically once it is loaded
            DataNodeDescriptor node = nodeBuilder.buildDataNode();

            // configure node...
            if ("JNDI".equalsIgnoreCase(adapter)) {
                node.setDataSourceFactoryType(JNDIDataSourceFactory.class.getName());
                node.setParameters((String) connection.get("serverUrl"));
            }
            else {
                // guess adapter from plugin or driver
                AdapterMapping adapterDefaults = getApplication().getAdapterMapping();
                String cayenneAdapter = adapterDefaults.adapterForEOFPluginOrDriver(
                        (String) connection.get("plugin"),
                        (String) connection.get("driver"));
                if (cayenneAdapter != null) {
                    try {
                        Class<DbAdapter> adapterClass = getApplication()
                                .getClassLoadingService()
                                .loadClass(DbAdapter.class, cayenneAdapter);
                        node.setAdapterType(adapterClass.toString());
                    }
                    catch (Throwable ex) {
                        // ignore...
                    }
                }

                node
                        .setDataSourceFactoryType(XMLPoolingDataSourceFactory.class
                                .getName());

                DataSourceInfo dsi = node.getDataSourceDescriptor();

                dsi.setDataSourceUrl(keyAsString(connection, "URL"));
                dsi.setJdbcDriver(keyAsString(connection, "driver"));
                dsi.setPassword(keyAsString(connection, "password"));
                dsi.setUserName(keyAsString(connection, "username"));
View Full Code Here

        domain.getDataMaps().remove(map);
       
        Iterator<DataNodeDescriptor> iterator = domain.getNodeDescriptors().iterator();
        while(iterator.hasNext()){
            DataNodeDescriptor node = iterator.next();
            if(node.getDataMapNames().contains(map.getName())){
                removeDataMapFromDataNode(node, map);
            }
        }
      
        mediator.fireDataMapEvent(e);
View Full Code Here

        DefaultComboBoxModel model = new DefaultComboBoxModel(objects);

        // find selected node
        for (int i = 0; i < nodes.length; i++) {
            DataNodeDescriptor node = (DataNodeDescriptor) nodes[i];
            if (node.getDataMapNames().contains(map.getName())) {
                model.setSelectedItem(node);
                break;
            }
        }
View Full Code Here

        pref.copyPreferences(newName);
        eventController.fireDataMapEvent(e);
    }

    void setDataNode() {
        DataNodeDescriptor node = (DataNodeDescriptor) nodeSelector.getSelectedItem();
        DataMap map = eventController.getCurrentDataMap();

        // no change?
        if (node != null && node.getDataMapNames().contains(map.getName())) {
            return;
        }

        // unlink map from any nodes

        for (DataNodeDescriptor nextNode : ((DataChannelDescriptor) eventController
                .getProject()
                .getRootNode()).getNodeDescriptors()) {

            // Theoretically only one node may contain a datamap at each given time.
            // Being paranoid, we will still scan through all.
            if (nextNode != node && nextNode.getDataMapNames().contains(map.getName())) {
                nextNode.getDataMapNames().remove(map.getName());

                // announce DataNode change
                eventController.fireDataNodeEvent(new DataNodeEvent(this, nextNode));
            }
        }

        // link to a selected node
        if (node != null) {
            node.getDataMapNames().add(map.getName());

            // announce DataNode change
            eventController.fireDataNodeEvent(new DataNodeEvent(this, node));
        }
    }
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.