Package org.apache.cayenne.resource

Examples of org.apache.cayenne.resource.Resource


                        .getRootNode(), mediator.getCurrentDataNode()));
            }
            else {
                DataChannelDescriptor currentDomain = (DataChannelDescriptor) mediator
                        .getProject().getRootNode();
                Resource baseResource = currentDomain.getConfigurationSource();

                // this will be new data map so need to set configuration source for it
                if (baseResource != null) {
                    Resource dataMapResource = baseResource.getRelativeResource(dataMap.getName());
                    dataMap.setConfigurationSource(dataMapResource);
                }
                mediator.addDataMap(Application.getFrame(), dataMap);
            }
        }
View Full Code Here


        }

        // Project - return the name of top file
        if (value instanceof Project) {

            Resource resource = ((Project) value).getConfigurationResource();
            return (resource != null) ? resource.getURL().getPath() : "";
        }

        // read name property
        try {
            if (value instanceof Embeddable) {
View Full Code Here

        DataMap map = (DataMap) NamedObjectFactory.createObject(
                DataMap.class,
                currentDomain);

        // set configuration source for new dataMap
        Resource baseResource = currentDomain.getConfigurationSource();

        if (baseResource != null) {
            Resource dataMapResource = baseResource.getRelativeResource(map.getName());

            map.setConfigurationSource(dataMapResource);
        }

        createDataMap(map);
View Full Code Here

                    .getInstance()
                    .getFrameController();
            controller.addToLastProjListAction(file.getAbsolutePath());

            URL url = file.toURL();
            Resource rootSource = new URLResource(url);

            ProjectUpgrader upgrader = getApplication().getInjector().getInstance(
                    ProjectUpgrader.class);
            UpgradeHandler handler = upgrader.getUpgradeHandler(rootSource);
            UpgradeMetaData md = handler.getUpgradeMetaData();

            if (UpgradeType.DOWNGRADE_NEEDED == md.getUpgradeType()) {
                JOptionPane
                        .showMessageDialog(
                                Application.getFrame(),
                                "Can't open project - it was created using a newer version of the Modeler",
                                "Can't Open Project",
                                JOptionPane.OK_OPTION);
                closeProject(false);
            }
            else if (UpgradeType.INTERMEDIATE_UPGRADE_NEEDED == md.getUpgradeType()) {
                JOptionPane
                        .showMessageDialog(Application.getFrame(),
                        // TODO: andrus 05/02/2010 - this message shows intermediate
                                // version of the project XML, not the Modeler code
                                // version that
                                // can be used for upgrade
                                "Can't upgrade project. Open the project in the Modeler v."
                                        + md.getIntermediateUpgradeVersion()
                                        + " to do an intermediate upgrade before you can upgrade to v."
                                        + md.getSupportedVersion(),
                                "Can't Upgrade Project",
                                JOptionPane.OK_OPTION);
                closeProject(false);
            }
            else if (UpgradeType.UPGRADE_NEEDED == md.getUpgradeType()) {
                if (processUpgrades(md)) {
                    // perform upgrade
                    logObj.info("Will upgrade project " + url.getPath());
                    Resource upgraded = handler.performUpgrade();
                    if (upgraded != null) {
                        Project project = openProjectResourse(upgraded, controller);

                        getProjectController().getProjectWatcher().pauseWatching();
                        getProjectController().getProjectWatcher().reconfigure();
View Full Code Here

        String testConfigName = "PROJECT1";
        String baseUrl = getClass().getPackage().getName().replace('.', '/');
        URL url = getClass().getClassLoader().getResource(
                baseUrl + "/cayenne-" + testConfigName + ".xml");

        Resource rootSource = new URLResource(url);

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

        DataChannelDescriptor rootNode = (DataChannelDescriptor) project.getRootNode();
View Full Code Here

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

        if (baseResource == null) {
            baseResource = unit.sourceConfiguration;
        }

        String targetLocation = nameMapper.configurationLocation(node);
        Resource targetResource = baseResource.getRelativeResource(targetLocation);

        // attempt to convert targetResource to a File... if that fails,
        // FileProjectSaver is not appropriate for handling a given project..

        URL targetUrl = targetResource.getURL();

        try {
            unit.targetFile = Util.toFile(targetUrl);
        }
        catch (IllegalArgumentException e) {
View Full Code Here

        String testConfigName = "PROJECT2";
        String baseUrl = getClass().getPackage().getName().replace('.', '/');
        URL url = getClass().getClassLoader().getResource(
                baseUrl + "/cayenne-" + testConfigName + ".xml");

        Resource source = new URLResource(url);
        Project project = injector.getInstance(ProjectLoader.class).loadProject(source);

        File outFile = setupTestDirectory("testSave");

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

        String testConfigName = "PROJECT2";
        String baseUrl = getClass().getPackage().getName().replace('.', '/');
        URL url = getClass().getClassLoader().getResource(
                baseUrl + "/cayenne-" + testConfigName + ".xml");

        Resource source = new URLResource(url);
        Project project = injector.getInstance(ProjectLoader.class).loadProject(source);

        File outFile = setupTestDirectory("testSaveAs_RecoverFromSaveError");
        assertEquals(0, outFile.list().length);
View Full Code Here

        ProjectUpgrader_V6 upgrader = new ProjectUpgrader_V6();
        Injector injector = DIBootstrap.createInjector(testModule);
        injector.injectMembers(upgrader);

        Resource source = new URLResource(url);
        UpgradeHandler handler = upgrader.getUpgradeHandler(source);

        assertNotNull(handler);
        assertSame(source, handler.getProjectSource());
View Full Code Here

TOP

Related Classes of org.apache.cayenne.resource.Resource

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.