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


    /**
     * @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

                .getProject()
                .getRootNode();

        // use domain name as DataNode base, as node names must be unique across the
        // project...
        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

        String name = NamedObjectFactory.createName(
                DataNodeDescriptor.class,
                domain,
                domain.getName() + "Node");

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

        return node;
    }
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

            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

                if (nodeName == null) {
                    // TODO: assign dummy name?
                    throw new ConfigurationException("Error: <node> without 'name'.");
                }

                DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
                nodeDescriptor.setName(nodeName);

                String dataSourceFactory = attributes.getValue("", "factory");
                String dataSourceFactory6 = convertDataSourceFactory(dataSourceFactory);
                nodeDescriptor.setDataSourceFactoryType(dataSourceFactory6);

                // depending on the factory, "datasource" attribute is interpreted
                // differently
                String datasource = attributes.getValue("", "datasource");
                if (XMLPoolingDataSourceFactory.class
                        .getName()
                        .equals(dataSourceFactory6)) {
                    Resource baseResource = descriptor.getConfigurationSource();
                    Resource dataNodeResource = baseResource
                            .getRelativeResource(datasource);
                    nodeDescriptor.setConfigurationSource(dataNodeResource);

                    DataSourceInfo dataSourceInfo = dataSourceInfoLoader
                            .load(dataNodeResource);
                    nodeDescriptor.setDataSourceDescriptor(dataSourceInfo);
                }
                else {
                    nodeDescriptor.setParameters(datasource);
                }

                descriptor.getNodeDescriptors().add(nodeDescriptor);
                nodeDescriptor.setAdapterType(attributes.getValue("", "adapter"));
                nodeDescriptor.setSchemaUpdateStrategyType(attributes.getValue(
                        "",
                        "schema-update-strategy"));

                return new DataNodeChildrenHandler(parser, this, nodeDescriptor);
            }
View Full Code Here

/**
*/
public class DataNodeEventTest extends TestCase {

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

        MapEvent event = new DataNodeEvent(new Object(), new DataNodeDescriptor("someName"));
        assertEquals("someName", event.getNewName());
    }

    public void testNoNameChange() throws Exception {
        MapEvent event = new DataNodeEvent(new Object(), new DataNodeDescriptor("someName"));
        assertFalse(event.isNameChange());
       
        event.setOldName("someOldName");
        assertTrue(event.isNameChange());
    }
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.