Package org.apache.cayenne.configuration

Examples of org.apache.cayenne.configuration.DataChannelDescriptor


        final RuntimeProperties properties = mock(RuntimeProperties.class);
        when(properties.get(PropertyDataSourceFactory.JDBC_DRIVER_PROPERTY)).thenReturn(
                "x");
        when(properties.get(PropertyDataSourceFactory.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


    public void testGet() {

        // create dependencies
        final String testConfigName = "testConfig";
        final DataChannelDescriptor testDescriptor = new DataChannelDescriptor();

        DataMap map1 = new DataMap("map1");
        testDescriptor.getDataMaps().add(map1);

        DataMap map2 = new DataMap("map2");
        testDescriptor.getDataMaps().add(map2);

        DataNodeDescriptor nodeDescriptor1 = new DataNodeDescriptor();
        nodeDescriptor1.setName("node1");
        nodeDescriptor1.getDataMapNames().add("map1");
        nodeDescriptor1.setAdapterType(OracleAdapter.class.getName());
        nodeDescriptor1.setDataSourceFactoryType(MockDataSourceFactory.class.getName());
        nodeDescriptor1.setParameters("jdbc/testDataNode1");
        nodeDescriptor1
                .setSchemaUpdateStrategyType(ThrowOnPartialOrCreateSchemaStrategy.class
                        .getName());
        testDescriptor.getNodeDescriptors().add(nodeDescriptor1);

        DataNodeDescriptor nodeDescriptor2 = new DataNodeDescriptor();
        nodeDescriptor2.setName("node2");
        nodeDescriptor2.getDataMapNames().add("map2");
        nodeDescriptor2.setParameters("testDataNode2.driver.xml");
        testDescriptor.getNodeDescriptors().add(nodeDescriptor2);

        final ResourceLocator locator = new ResourceLocator() {

            public Collection<Resource> findResources(String name) {
                assertEquals(testConfigName, name);
View Full Code Here

            return "UntitledDomain";
        }

        @Override
        protected Object create(String name, Object namingContext) {
            DataChannelDescriptor dataChDes = new DataChannelDescriptor();
            dataChDes.setName(name);
            return dataChDes;
        }
View Full Code Here

                DataDomain domain = (DataDomain) namingContext;
                return domain.getDataMap(name) != null;
            }

            if (namingContext instanceof DataChannelDescriptor) {
                DataChannelDescriptor domain = (DataChannelDescriptor) namingContext;
                return domain.getDataMap(name) != null;
            }
            return false;

        }
View Full Code Here

            return new DataNodeDescriptor(name);
        }

        @Override
        protected boolean isNameInUse(String name, Object namingContext) {
            DataChannelDescriptor domain = (DataChannelDescriptor) namingContext;
            Iterator<DataNodeDescriptor> nodeIt = domain.getNodeDescriptors().iterator();
            while (nodeIt.hasNext()) {
                if (nodeIt.next().getName().equals(name)) {
                    return true;
                }
            }
View Full Code Here

                    + " in "
                    + (t1 - t0)
                    + " ms.");
        }

        DataChannelDescriptor descriptor = tree.getRootNode();
        DataDomain dataDomain = createDataDomain(descriptor.getName());

        dataDomain.setEntitySorter(injector.getInstance(EntitySorter.class));
        dataDomain.setEventManager(injector.getInstance(EventManager.class));

        dataDomain.initWithProperties(descriptor.getProperties());

        for (DataMap dataMap : descriptor.getDataMaps()) {
            dataDomain.addDataMap(dataMap);
        }
       
        dataDomain.getEntityResolver().applyDBLayerDefaults();
        dataDomain.getEntityResolver().applyObjectLayerDefaults();

        for (DataNodeDescriptor nodeDescriptor : descriptor.getNodeDescriptors()) {
            DataNode dataNode = new DataNode(nodeDescriptor.getName());

            dataNode.setDataSourceLocation(nodeDescriptor.getParameters());

            DataSource dataSource = dataSourceFactory.getDataSource(nodeDescriptor);
View Full Code Here

        DataMap map = eventController.getCurrentDataMap();

        // search for matching map name across domains, as currently they have to be
        // unique globally
        DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application
                .getInstance()
                .getProject()
                .getRootNode();

        DataMap matchingMap = dataChannelDescriptor.getDataMap(newName);

        if (matchingMap != null && !matchingMap.equals(map)) {

            // there is an entity with the same name
            throw new ValidationException("There is another DataMap named '"
View Full Code Here

                break;
            }
        }

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

                ObjEntity conflictingEntity = nextMap.getObjEntity(name);
View Full Code Here

                    return locator;
                }
            };

            DataMap newMap = mapLoader.loadDataMap(dataMapFile.getAbsolutePath());
            DataChannelDescriptor domain = (DataChannelDescriptor)getProjectController().getProject().getRootNode();

            if (newMap.getName() != null) {
                newMap.setName(NamedObjectFactory.createName(
                        DataMap.class,
                        domain,
                        newMap.getName()));
            }
            else {
                newMap.setName(NamedObjectFactory.createName(DataMap.class, domain));
            }
           
            Resource baseResource = domain.getConfigurationSource();

            if (baseResource != null) {
                Resource dataMapResource = baseResource.getRelativeResource(newMap.getName());
                newMap.setConfigurationSource(dataMapResource);
            }
View Full Code Here

            return "project";
        }

        @Override
        protected Object create(String name, Object namingContext) {
            DataChannelDescriptor dataChDes = new DataChannelDescriptor();
            dataChDes.setName(name);
            return dataChDes;
        }
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.