Package org.apache.cayenne.configuration

Examples of org.apache.cayenne.configuration.DataChannelDescriptor


    public static void jumpToResult(Object path) {
        EditorView editor = ((CayenneModelerFrame) Application
                .getInstance()
                .getFrameController()
                .getView()).getView();
        DataChannelDescriptor domain = (DataChannelDescriptor) Application
                .getInstance()
                .getProject()
                .getRootNode();
        if (path instanceof Entity) {
View Full Code Here


            }
            else {

                getProjectModel().nodeChanged(node);

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

                // check for DataMap additions/removals...
                Object[] mapsName = e.getDataNode().getDataMapNames().toArray();
                int mapCount = mapsName.length;

                // DataMap was linked
                if (mapCount > node.getChildCount()) {

                    for (int i = 0; i < mapCount; i++) {
                        boolean found = false;
                        for (int j = 0; j < node.getChildCount(); j++) {
                            DefaultMutableTreeNode child = (DefaultMutableTreeNode) node
                                    .getChildAt(j);
                            if (domain.getDataMap(mapsName[i].toString()) == child
                                    .getUserObject()) {
                                found = true;
                                break;
                            }
                        }

                        if (!found) {
                            DefaultMutableTreeNode newMapNode = new DefaultMutableTreeNode(
                                    domain.getDataMap(mapsName[i].toString()),
                                    false);
                            positionNode(node, newMapNode, Comparators
                                    .getNamedObjectComparator());
                            break;
                        }
                    }
                }
                // DataMap was unlinked
                else if (mapCount < node.getChildCount()) {
                    for (int j = 0; j < node.getChildCount(); j++) {
                        boolean found = false;
                        DefaultMutableTreeNode child;
                        child = (DefaultMutableTreeNode) node.getChildAt(j);
                        Object obj = child.getUserObject();
                        for (int i = 0; i < mapCount; i++) {
                            if (domain.getDataMap(mapsName[i].toString()) == obj) {
                                found = true;
                                break;
                            }
                        }
                        if (!found) {
View Full Code Here

        Resource rootSource = new URLResource(url);

        Project project = loader.loadProject(rootSource);
        assertNotNull(project);

        DataChannelDescriptor rootNode = (DataChannelDescriptor) project.getRootNode();
        assertNotNull(rootNode);
        assertSame(rootSource, rootNode.getConfigurationSource());
       
        assertNotNull(project.getConfigurationResource());
        assertEquals(project.getConfigurationResource(), rootSource);
    }
View Full Code Here

        FileProjectSaver saver = new FileProjectSaver();
        Injector injector = DIBootstrap.createInjector(testModule);
        injector.injectMembers(saver);

        DataChannelDescriptor rootNode = new DataChannelDescriptor();
        rootNode.setName("test");

        // add maps and nodes in reverse alpha order. Check that they are saved in alpha
        // order
        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");

        rootNode.getNodeDescriptors().addAll(Arrays.asList(nodes));

        Project project = new Project(new ConfigurationTree<DataChannelDescriptor>(
                rootNode));

        saver.saveAs(project, new URLResource(testFolder.toURL()));
View Full Code Here

        final RuntimeProperties properties = mock(RuntimeProperties.class);
        when(properties.get(Constants.JDBC_DRIVER_PROPERTY)).thenReturn(
                "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);
View Full Code Here

        if (Util.isEmptyString(name)) {
            addFailure(validationResult, node, "Unnamed DataNode");
            return;
        }

        DataChannelDescriptor dataChannelDescriptor = node.getDataChannelDescriptor();

        // check for duplicate names in the parent context
        for (DataNodeDescriptor otherNode : dataChannelDescriptor.getNodeDescriptors()) {
            if (otherNode == node) {
                continue;
            }

            if (name.equals(otherNode.getName())) {
View Full Code Here

    protected Resource doPerformUpgrade() throws ConfigurationException {

        List<DataChannelDescriptor> domains = projectLoader.load(projectSource);
        if (domains.isEmpty()) {
            // create a single domain dummy project if a noop config is being upgraded
            DataChannelDescriptor descriptor = new DataChannelDescriptor();
            descriptor.setName("DEFAULT");
            domains.add(descriptor);
        }

        // collect resources to delete before the upgrade...
        Collection<Resource> resourcesToDelete = new ArrayList<Resource>();
        for (DataChannelDescriptor descriptor : domains) {
            for (DataNodeDescriptor node : descriptor.getNodeDescriptors()) {
                Resource nodeResource = node.getConfigurationSource();
                if (nodeResource != null) {
                    resourcesToDelete.add(nodeResource);
                }
            }
View Full Code Here

                break;
            }
        }

        // check for duplicates in other DataMaps
        DataChannelDescriptor domain = map.getDataChannelDescriptor();
        if (domain != null) {
            for (DataMap nextMap : domain.getDataMaps()) {
                if (nextMap == map) {
                    continue;
                }

                // note that lookuo below will return the same embeddable due to the
View Full Code Here

        validateName(map, validationResult);
        validateNodeLinks(map, validationResult);
    }

    void validateNodeLinks(DataMap map, ValidationResult validationResult) {
        DataChannelDescriptor domain = map.getDataChannelDescriptor();
        if (domain == null) {
            return;
        }

        boolean unlinked = true;
        int nodeCount = 0;
        for (DataNodeDescriptor node : domain.getNodeDescriptors()) {
            nodeCount++;
            if (node.getDataMapNames().contains(map.getName())) {
                unlinked = false;
                break;
            }
View Full Code Here

        if (Util.isEmptyString(name)) {
            addFailure(validationResult, map, "Unnamed DataMap");
            return;
        }

        DataChannelDescriptor domain = map.getDataChannelDescriptor();
        if (domain == null) {
            return;
        }

        // check for duplicate names in the parent context
        for (DataMap otherMap : domain.getDataMaps()) {
            if (otherMap == map) {
                continue;
            }

            if (name.equals(otherMap.getName())) {
View Full Code Here

TOP

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

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.