Package org.springframework.roo.project

Examples of org.springframework.roo.project.PathResolver


    @Override
    public void addServiceToXmlConfiguration(
            ClassOrInterfaceTypeDetails serviceInterface,
            ClassOrInterfaceTypeDetails serviceClass) {
        final PathResolver pathResolver = projectOperations.getPathResolver();

        final String fileIdentifier = pathResolver.getFocusedIdentifier(
                Path.SPRING_CONFIG_ROOT, "applicationContext-services.xml");

        if (!fileManager.exists(fileIdentifier)) {
            InputStream inputStream = null;
            OutputStream outputStream = null;
View Full Code Here


    }

    @Override
    public void removeServiceFromXmlConfiguration(
            ClassOrInterfaceTypeDetails serviceInterface) {
        final PathResolver pathResolver = projectOperations.getPathResolver();

        final String fileIdentifier = pathResolver.getFocusedIdentifier(
                Path.SPRING_CONFIG_ROOT, "applicationContext-services.xml");

        if (!fileManager.exists(fileIdentifier)) {
            return;
        }
View Full Code Here

                            .getTemplateTypeDetailsMap().get(gwtType),
                            extendsTypes, moduleName));

            if (gwtType.isCreateUiXml()) {
                final GwtPath gwtPath = gwtType.getPath();
                final PathResolver pathResolver = projectOperations
                        .getPathResolver();
                final String webappPath = pathResolver.getIdentifier(
                        LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP,
                                moduleName), moduleName);
                final String packagePath = pathResolver
                        .getIdentifier(LogicalPath.getInstance(
                                Path.SRC_MAIN_JAVA, moduleName), gwtPath
                                .getPackagePath(topLevelPackage));

                final String targetDirectory = gwtPath == GwtPath.WEB ? webappPath
View Full Code Here

            if (type.isCreateUiXml()) {
                String moduleName = projectOperations.getFocusedModuleName();
                final GwtPath targetPath = type.getPath();
                final GwtPath sourcePath = GwtPath.MANAGED_UI;
                final PathResolver pathResolver = projectOperations
                        .getPathResolver();
                final String sourceDirectory = pathResolver
                        .getIdentifier(LogicalPath.getInstance(
                                Path.SRC_MAIN_JAVA, moduleName), sourcePath
                                .getPackagePath(topLevelPackage));
                final String targetDirectory = pathResolver
                        .getIdentifier(LogicalPath.getInstance(
                                Path.SRC_MAIN_JAVA, moduleName), targetPath
                                .getPackagePath(topLevelPackage));

                final String sourceFile = sourceDirectory + File.separatorChar
View Full Code Here

                        formBackingTypePath));
        final LogicalPath path = JspMetadata.getPath(jspMetadataId);

        // Install web artifacts only if Spring MVC config is missing
        // TODO: Remove this call when 'controller' commands are gone
        final PathResolver pathResolver = projectOperations.getPathResolver();
        final LogicalPath webappPath = LogicalPath.getInstance(
                Path.SRC_MAIN_WEBAPP, path.getModule());

        if (!fileManager.exists(pathResolver.getIdentifier(webappPath,
                WEB_INF_VIEWS))) {
            jspOperations.installCommonViewArtefacts(path.getModule());
        }

        installImage(webappPath, "images/show.png");
        if (webScaffoldMetadata.getAnnotationValues().isUpdate()) {
            installImage(webappPath, "images/update.png");
        }
        if (webScaffoldMetadata.getAnnotationValues().isDelete()) {
            installImage(webappPath, "images/delete.png");
        }

        final List<FieldMetadata> eligibleFields = webMetadataService
                .getScaffoldEligibleFieldMetadata(formBackingType,
                        memberDetails, jspMetadataId);
        if (eligibleFields.isEmpty()
                && formBackingTypePersistenceMetadata.getRooIdentifierFields()
                        .isEmpty()) {
            return null;
        }
       
        final JspViewManager viewManager = new JspViewManager(eligibleFields,
                webScaffoldMetadata.getAnnotationValues(), relatedTypeMd, typeLocationService);

        String controllerPath = webScaffoldMetadata.getAnnotationValues()
                .getPath();
        if (controllerPath.startsWith("/")) {
            controllerPath = controllerPath.substring(1);
        }

        // Make the holding directory for this controller
        final String destinationDirectory = pathResolver.getIdentifier(
                webappPath, WEB_INF_VIEWS + controllerPath);
        if (!fileManager.exists(destinationDirectory)) {
            fileManager.createDirectory(destinationDirectory);
        }
        else {
View Full Code Here

    public String getProvidesType() {
        return JspMetadata.getMetadataIdentiferType();
    }

    private void installImage(final LogicalPath path, final String imagePath) {
        final PathResolver pathResolver = projectOperations.getPathResolver();
        final String imageFile = pathResolver.getIdentifier(path, imagePath);
        if (!fileManager.exists(imageFile)) {
            InputStream inputStream = null;
            OutputStream outputStream = null;
            try {
                inputStream = FileUtils.getInputStream(getClass(), imagePath);
                outputStream = fileManager.createFile(
                        pathResolver.getIdentifier(path, imagePath))
                        .getOutputStream();
                IOUtils.copy(inputStream, outputStream);
            }
            catch (final Exception e) {
                throw new IllegalStateException(
View Full Code Here

                IOUtils.closeQuietly(inputStream);
                IOUtils.closeQuietly(outputStream);
            }
        }

        final PathResolver pathResolver = projectOperations.getPathResolver();

        final String menuPath = pathResolver.getIdentifier(logicalPath,
                "WEB-INF/tags/menu/menu.tagx");
        if (!fileManager.exists(menuPath)) {
            InputStream inputStream = null;
            try {
                inputStream = FileUtils.getInputStream(getClass(), "menu.tagx");
                fileManager.createOrUpdateTextFileIfRequired(menuPath,
                        IOUtils.toString(inputStream), false);
            }
            catch (final Exception e) {
                throw new IllegalStateException(
                        "Encountered an error during copying of menu.tagx for MVC Menu addon.",
                        e);
            }
            finally {
                IOUtils.closeQuietly(inputStream);
            }
        }

        final String itemPath = pathResolver.getIdentifier(logicalPath,
                "WEB-INF/tags/menu/item.tagx");
        if (!fileManager.exists(itemPath)) {
            InputStream inputStream = null;
            try {
                inputStream = FileUtils.getInputStream(getClass(), "item.tagx");
                fileManager.createOrUpdateTextFileIfRequired(menuPath,
                        IOUtils.toString(inputStream), false);
            }
            catch (final Exception e) {
                throw new IllegalStateException(
                        "Encountered an error during copying of item.tagx for MVC Menu addon.",
                        e);
            }
            finally {
                IOUtils.closeQuietly(inputStream);
            }
        }

        final String categoryPath = pathResolver.getIdentifier(logicalPath,
                "WEB-INF/tags/menu/category.tagx");
        if (!fileManager.exists(categoryPath)) {
            InputStream inputStream = null;
            try {
                inputStream = FileUtils.getInputStream(getClass(),
View Full Code Here

     */
    private void installView(final JavaSymbolName viewName,
            final String folderName, final String title, final String category,
            final boolean registerStaticController, final LogicalPath webappPath) {
        // Probe if common web artifacts exist, and install them if needed
        final PathResolver pathResolver = projectOperations.getPathResolver();
        if (!fileManager.exists(pathResolver.getIdentifier(webappPath,
                "WEB-INF/layouts/default.jspx"))) {
            installCommonViewArtefacts(webappPath.getModule());
        }

        final String lcViewName = viewName.getSymbolName().toLowerCase();

        // Update the application-specific resource bundle (i.e. default
        // translation)
        final String messageCode = "label"
                + folderName.replace("/", "_").toLowerCase() + "_" + lcViewName;
        propFileOperations
                .addPropertyIfNotExists(
                        pathResolver.getFocusedPath(Path.SRC_MAIN_WEBAPP),
                        "WEB-INF/i18n/application.properties", messageCode,
                        title, true);

        // Add the menu item
        final String relativeUrl = folderName + "/" + lcViewName;
        menuOperations.addMenuItem(new JavaSymbolName(category),
                new JavaSymbolName(folderName.replace("/", "_").toLowerCase()
                        + lcViewName + "_id"), title, "global_generic",
                relativeUrl, null, webappPath);

        // Add the view definition
        tilesOperations.addViewDefinition(folderName.toLowerCase(),
                pathResolver.getFocusedPath(Path.SRC_MAIN_WEBAPP), relativeUrl,
                TilesOperations.DEFAULT_TEMPLATE,
                "/WEB-INF/views" + folderName.toLowerCase() + "/" + lcViewName
                        + ".jspx");

        if (registerStaticController) {
View Full Code Here

     * @param service The service to be injected (if one exists)
     */
    @Override
    public void addLocatorToXmlConfiguration(
            ClassOrInterfaceTypeDetails locator, JavaType service) {
        final PathResolver pathResolver = projectOperations.getPathResolver();

        final String fileIdentifier = pathResolver.getFocusedIdentifier(
                Path.SPRING_CONFIG_ROOT, "applicationContext-locators.xml");

        if (!fileManager.exists(fileIdentifier)) {
            InputStream inputStream = null;
            OutputStream outputStream = null;
View Full Code Here

    }

    @Override
    public void removeLocatorFromXmlConfiguration(
            ClassOrInterfaceTypeDetails locator) {
        final PathResolver pathResolver = projectOperations.getPathResolver();

        final String fileIdentifier = pathResolver.getFocusedIdentifier(
                Path.SPRING_CONFIG_ROOT, "applicationContext-locators.xml");

        if (!fileManager.exists(fileIdentifier)) {
            return;
        }
View Full Code Here

TOP

Related Classes of org.springframework.roo.project.PathResolver

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.