Package org.springframework.roo.support.util

Examples of org.springframework.roo.support.util.XmlElementBuilder


            location = URLDecoder.decode(location, "UTF-8");
        }
        catch (final UnsupportedEncodingException ignore) {
        }
        installTagx("map");
        final Element map = new XmlElementBuilder("embed:map", XmlUtils
                .getDocumentBuilder().newDocument())
                .addAttribute("id", "map_" + viewName)
                .addAttribute("location", location).build();
        map.setAttribute("z", XmlRoundTripUtils.calculateUniqueKeyFor(map));
        installJspx(
View Full Code Here


                || !options.containsKey("id")) {
            return false;
        }
        final String id = options.get("id");
        installTagx("wave");
        final Element wave = new XmlElementBuilder("embed:wave", XmlUtils
                .getDocumentBuilder().newDocument())
                .addAttribute("id", "wave_" + id).addAttribute("waveId", id)
                .build();
        wave.setAttribute("z", XmlRoundTripUtils.calculateUniqueKeyFor(wave));
        installJspx(
View Full Code Here

            searchTerm = URLDecoder.decode(searchTerm, "UTF-8");
        }
        catch (final UnsupportedEncodingException ignore) {
        }
        installTagx("microblogging");
        final Element twitter = new XmlElementBuilder("embed:microblogging",
                XmlUtils.getDocumentBuilder().newDocument())
                .addAttribute("id", "twitter_" + searchTerm)
                .addAttribute("searchTerm", searchTerm).build();
        twitter.setAttribute("z",
                XmlRoundTripUtils.calculateUniqueKeyFor(twitter));
View Full Code Here

        installTagx("document");
        if (DocumentProvider.SLIDESHARE.name().equals(provider)
                && id.startsWith("http")) {
            id = getSlideShareId(id);
        }
        final Element document = new XmlElementBuilder("embed:document",
                XmlUtils.getDocumentBuilder().newDocument())
                .addAttribute("id", "doc_" + id).addAttribute("documentId", id)
                .addAttribute("provider", provider.toLowerCase()).build();
        document.setAttribute("z",
                XmlRoundTripUtils.calculateUniqueKeyFor(document));
View Full Code Here

        if (!isProviderSupported(provider, VideoStreamProvider.values())) {
            return false;
        }
        final String id = options.get("id");
        installTagx("videostream");
        final Element video = new XmlElementBuilder("embed:videostream",
                XmlUtils.getDocumentBuilder().newDocument())
                .addAttribute("id", "video_stream_" + id)
                .addAttribute("streamId", id)
                .addAttribute("provider", provider.toLowerCase()).build();
        video.setAttribute("z", XmlRoundTripUtils.calculateUniqueKeyFor(video));
View Full Code Here

        final Element scopeElement = XmlUtils.findFirstElement("scope",
                dependencyElement);
        final String descriptionOfChange;
        if (scopeElement == null) {
            if (dependencyScope != null) {
                dependencyElement.appendChild(new XmlElementBuilder("scope",
                        document).setText(dependencyScope.name().toLowerCase())
                        .build());
                descriptionOfChange = highlight(ADDED + " scope") + " "
                        + dependencyScope.name().toLowerCase()
                        + " to dependency " + dependency.getSimpleDescription();
View Full Code Here

            return;
        }
        annotationDriven.setAttribute("conversion-service",
                CONVERSION_SERVICE_BEAN_NAME);

        final Element conversionServiceBean = new XmlElementBuilder("bean",
                document)
                .addAttribute("id", CONVERSION_SERVICE_BEAN_NAME)
                .addAttribute(
                        "class",
                        destinationPackage.getFullyQualifiedPackageName() + "."
View Full Code Here

                .getInputStream(webFlowConfigPath));
        final Element root = document.getDocumentElement();

        if (XmlUtils.findFirstElement("/beans/bean[@id='"
                + CONVERSION_SERVICE_EXPOSING_INTERCEPTOR_NAME + "']", root) == null) {
            final Element conversionServiceExposingInterceptor = new XmlElementBuilder(
                    "bean", document)
                    .addAttribute(
                            "class",
                            CONVERSION_SERVICE_EXPOSING_INTERCEPTOR
                                    .getFullyQualifiedTypeName())
                    .addAttribute("id",
                            CONVERSION_SERVICE_EXPOSING_INTERCEPTOR_NAME)
                    .addChild(
                            new XmlElementBuilder("constructor-arg", document)
                                    .addAttribute("ref",
                                            CONVERSION_SERVICE_BEAN_NAME)
                                    .build()).build();
            root.appendChild(conversionServiceExposingInterceptor);
        }
        final Element flowHandlerMapping = XmlUtils.findFirstElement(
                "/beans/bean[@class='"
                        + FLOW_HANDLER_MAPPING.getFullyQualifiedTypeName()
                        + "']", root);
        if (flowHandlerMapping != null) {
            if (XmlUtils.findFirstElement(
                    "property[@name='interceptors']/array/ref[@bean='"
                            + CONVERSION_SERVICE_EXPOSING_INTERCEPTOR_NAME
                            + "']", flowHandlerMapping) == null) {
                final Element interceptors = new XmlElementBuilder("property",
                        document)
                        .addAttribute("name", "interceptors")
                        .addChild(
                                new XmlElementBuilder("array", document)
                                        .addChild(
                                                new XmlElementBuilder("ref",
                                                        document)
                                                        .addAttribute("bean",
                                                                CONVERSION_SERVICE_EXPOSING_INTERCEPTOR_NAME)
                                                        .build()).build())
                        .build();
View Full Code Here

                root.setAttribute(
                        "xsi:schemaLocation",
                        root.getAttribute("xsi:schemaLocation")
                                + "  http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd");
            }
            root.appendChild(new XmlElementBuilder("task:annotation-driven",
                    appContext).addAttribute("executor", "asyncExecutor")
                    .build());
            root.appendChild(new XmlElementBuilder("task:executor", appContext)
                    .addAttribute("id", "asyncExecutor")
                    .addAttribute("pool-size", "${executor.poolSize}").build());

            fileManager.createOrUpdateTextFileIfRequired(contextPath,
                    XmlUtils.nodeToString(appContext), false);
View Full Code Here

        final DocumentBuilder builder = XmlUtils.getDocumentBuilder();
        final Document document = builder.newDocument();

        // Add document namespaces
        final Element div = new XmlElementBuilder("div", document)
                .addAttribute("xmlns:page", "urn:jsptagdir:/WEB-INF/tags/form")
                .addAttribute("xmlns:fields",
                        "urn:jsptagdir:/WEB-INF/tags/form/fields")
                .addAttribute("xmlns:jsp", "http://java.sun.com/JSP/Page")
                .addAttribute("version", "2.0")
                .addChild(
                        new XmlElementBuilder("jsp:output", document)
                                .addAttribute("omit-xml-declaration", "yes")
                                .build()).build();
        document.appendChild(div);

        final Element pageSearch = new XmlElementBuilder("page:search",
                document)
                .addAttribute(
                        "id",
                        XmlUtils.convertId("ps:"
                                + webScaffoldMetadata.getAnnotationValues()
                                        .getFormBackingObject()
                                        .getFullyQualifiedTypeName()))
                .addAttribute("path",
                        webScaffoldMetadata.getAnnotationValues().getPath())
                .build();
        pageSearch.setAttribute("z",
                XmlRoundTripUtils.calculateUniqueKeyFor(pageSearch));

        final List<FieldMetadata> idFields = persistenceMemberLocator
                .getIdentifierFields(formbackingObject);
        if (idFields.isEmpty()) {
            return null;
        }
        final Element resultTable = new XmlElementBuilder("fields:table",
                document)
                .addAttribute(
                        "id",
                        XmlUtils.convertId("rt:"
                                + webScaffoldMetadata.getAnnotationValues()
                                        .getFormBackingObject()
                                        .getFullyQualifiedTypeName()))
                .addAttribute("data", "${searchResults}")
                .addAttribute("delete", "false")
                .addAttribute("update", "false")
                .addAttribute("path",
                        webScaffoldMetadata.getAnnotationValues().getPath())
                .addAttribute(
                        "typeIdFieldName",
                        formbackingObject.getSimpleTypeName().toLowerCase()
                                + "."
                                + idFields.get(0).getFieldName()
                                        .getSymbolName().toLowerCase()
                                + SolrUtils.getSolrDynamicFieldPostFix(idFields
                                        .get(0).getFieldType())).build();
        resultTable.setAttribute("z",
                XmlRoundTripUtils.calculateUniqueKeyFor(resultTable));

        final StringBuilder facetFields = new StringBuilder();
        int fieldCounter = 0;

        final ClassOrInterfaceTypeDetails formbackingClassOrInterfaceDetails = typeLocationService
                .getTypeDetails(formbackingObject);
        Validate.notNull(formbackingClassOrInterfaceDetails,
                "Unable to obtain physical type metadata for type %s",
                formbackingObject.getFullyQualifiedTypeName());
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(getClass().getName(),
                        formbackingClassOrInterfaceDetails);
        final MethodMetadata identifierAccessor = persistenceMemberLocator
                .getIdentifierAccessor(formbackingObject);
        final MethodMetadata versionAccessor = persistenceMemberLocator
                .getVersionAccessor(formbackingObject);

        for (final MethodMetadata method : memberDetails.getMethods()) {
            // Only interested in accessors
            if (!BeanInfoUtils.isAccessorMethod(method)) {
                continue;
            }
            if (++fieldCounter < 7) {
                if (method.getMethodName().equals(
                        identifierAccessor.getMethodName())
                        || method.getMethodName().equals(
                                versionAccessor.getMethodName())) {
                    continue;
                }
                if (method.hasSameName(identifierAccessor, versionAccessor)) {
                    continue;
                }

                final FieldMetadata field = BeanInfoUtils
                        .getFieldForJavaBeanMethod(memberDetails, method);
                if (field == null) {
                    continue;
                }

                facetFields
                        .append(formbackingObject.getSimpleTypeName()
                                .toLowerCase())
                        .append(".")
                        .append(field.getFieldName())
                        .append(SolrUtils.getSolrDynamicFieldPostFix(field
                                .getFieldType())).append(",");

                final Element columnElement = new XmlElementBuilder(
                        "fields:column", document)
                        .addAttribute(
                                "id",
                                XmlUtils.convertId("c:"
                                        + formbackingObject
                                                .getFullyQualifiedTypeName()
                                        + "."
                                        + field.getFieldName().getSymbolName()))
                        .addAttribute(
                                "property",
                                formbackingObject.getSimpleTypeName()
                                        .toLowerCase()
                                        + "."
                                        + field.getFieldName().getSymbolName()
                                                .toLowerCase()
                                        + SolrUtils
                                                .getSolrDynamicFieldPostFix(field
                                                        .getFieldType()))
                        .build();
                columnElement.setAttribute("z",
                        XmlRoundTripUtils.calculateUniqueKeyFor(columnElement));
                resultTable.appendChild(columnElement);
            }
        }

        final Element searchFacet = new XmlElementBuilder(
                "fields:search-facet", document)
                .addAttribute(
                        "id",
                        XmlUtils.convertId("sfacet:"
                                + webScaffoldMetadata.getAnnotationValues()
                                        .getFormBackingObject()
                                        .getFullyQualifiedTypeName()))
                .addAttribute("facetFields", facetFields.toString()).build();
        searchFacet.setAttribute("z",
                XmlRoundTripUtils.calculateUniqueKeyFor(searchFacet));
        pageSearch.appendChild(searchFacet);

        final Element searchField = new XmlElementBuilder(
                "fields:search-field", document).addAttribute(
                "id",
                XmlUtils.convertId("sfield:"
                        + webScaffoldMetadata.getAnnotationValues()
                                .getFormBackingObject()
View Full Code Here

TOP

Related Classes of org.springframework.roo.support.util.XmlElementBuilder

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.