Examples of MemberDetails


Examples of org.springframework.roo.classpath.scanner.MemberDetails

        final JavaType entity = annotationValues.getEntity();
        if (!annotationValues.isAnnotationFound() || entity == null) {
            return null;
        }

        final MemberDetails memberDetails = getMemberDetails(entity);
        if (memberDetails == null) {
            return null;
        }

        final MethodMetadata identifierAccessor = persistenceMemberLocator
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

                        final MethodMetadata applicationTypeVersionAccessor = persistenceMemberLocator
                                .getVersionAccessor(entity);
                        final List<FieldMetadata> applicationTypeFields = new ArrayList<FieldMetadata>();

                        int dropDownFields = 0;
                        final MemberDetails applicationTypeMemberDetails = getMemberDetails(fieldType);
                        for (final MethodMetadata applicationTypeMethod : applicationTypeMemberDetails
                                .getMethods()) {
                            if (!BeanInfoUtils
                                    .isAccessorMethod(applicationTypeMethod)) {
                                continue;
                            }
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

        // We need to be informed if our dependent metadata changes
        metadataDependencyRegistry.registerDependency(
                formBackingTypeDetails.getDeclaredByMetadataId(),
                metadataIdentificationString);

        final MemberDetails formBackingObjectMemberDetails = getMemberDetails(formBackingTypeDetails);
        final Set<FinderMetadataDetails> dynamicFinderMethods = webMetadataService
                .getDynamicFinderMethodsAndFields(formBackingType,
                        formBackingObjectMemberDetails,
                        metadataIdentificationString);
        if (dynamicFinderMethods == null) {
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

                "Type %s is not a class", entity.getFullyQualifiedTypeName());
        Validate.isTrue(!Modifier.isAbstract(cid.getModifier()),
                "Type %s is abstract", entity.getFullyQualifiedTypeName());

        // Check if the requested entity is a JPA @Entity
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(DataOnDemandOperationsImpl.class.getName(),
                        cid);
        final AnnotationMetadata entityAnnotation = memberDetails
                .getAnnotation(ENTITY);
        final AnnotationMetadata persistentAnnotation = memberDetails
                .getAnnotation(PERSISTENT);
        Validate.isTrue(entityAnnotation != null
                || persistentAnnotation != null,
                "Type %s must be a persistent type",
                entity.getFullyQualifiedTypeName());
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

        final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();

        final ClassOrInterfaceTypeDetails cid = typeLocationService
                .getTypeDetails(entity);
        if (cid != null) {
            final MemberDetails memberDetails = memberDetailsScanner
                    .getMemberDetails(
                            IntegrationTestOperationsImpl.class.getName(), cid);
            final List<MethodMetadata> countMethods = memberDetails
                    .getMethodsWithTag(CustomDataKeys.COUNT_ALL_METHOD);
            if (countMethods.size() == 1) {
                final String countMethod = entity.getSimpleTypeName() + "."
                        + countMethods.get(0).getMethodName().getSymbolName()
                        + "()";
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

        // Get the class so we can hopefully make a demo method that will be
        // usable
        final ClassOrInterfaceTypeDetails governorTypeDetails = typeLocationService
                .getTypeDetails(javaType);
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(this.getClass().getName(),
                        governorTypeDetails);
        for (final MemberHoldingTypeDetails typeDetails : memberDetails
                .getDetails()) {
            if (!(typeDetails.getCustomData().keySet()
                    .contains(CustomDataKeys.PERSISTENT_TYPE) || typeDetails
                    .getDeclaredByMetadataId()
                    .startsWith(
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

        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) {
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

                .get(PluralMetadata.createIdentifier(javaType, path));
        if (pluralMetadata != null && pluralMetadata.isValid()) {
            beanPlural = pluralMetadata.getPlural();
        }

        final MemberDetails memberDetails = getMemberDetails(governorPhysicalTypeMetadata);
        final Map<MethodMetadata, FieldMetadata> accessorDetails = new LinkedHashMap<MethodMetadata, FieldMetadata>();
        for (final MethodMetadata method : memberDetails.getMethods()) {
            if (BeanInfoUtils.isAccessorMethod(method)
                    && !method.getMethodName().getSymbolName().startsWith("is")) {
                final FieldMetadata field = BeanInfoUtils
                        .getFieldForJavaBeanMethod(memberDetails, method);
                if (field != null) {
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

                .get(PhysicalTypeIdentifier.createIdentifier(jsonObject,
                        typeLocationService.getTypePath(jsonObject)));
        Validate.notNull(backingObjectPhysicalTypeMetadata,
                "Unable to obtain physical type metadata for type %s",
                jsonObject.getFullyQualifiedTypeName());
        final MemberDetails formBackingObjectMemberDetails = getMemberDetails(backingObjectPhysicalTypeMetadata);
        final MemberHoldingTypeDetails backingMemberHoldingTypeDetails = MemberFindingUtils
                .getMostConcreteMemberHoldingTypeDetailsWithTag(
                        formBackingObjectMemberDetails,
                        CustomDataKeys.PERSISTENT_TYPE);
        if (backingMemberHoldingTypeDetails == null) {
View Full Code Here

Examples of org.springframework.roo.classpath.scanner.MemberDetails

            return null;
        }

        final JavaType formBackingType = webScaffoldMetadata
                .getAnnotationValues().getFormBackingObject();
        final MemberDetails memberDetails = webMetadataService
                .getMemberDetails(formBackingType);
        final JavaTypeMetadataDetails formBackingTypeMetadataDetails = webMetadataService
                .getJavaTypeMetadataDetails(formBackingType, memberDetails,
                        jspMetadataId);
        Validate.notNull(formBackingTypeMetadataDetails,
                "Unable to obtain metadata for type %s",
                formBackingType.getFullyQualifiedTypeName());

        formBackingObjectTypesToLocalMids.put(formBackingType, jspMetadataId);

        final SortedMap<JavaType, JavaTypeMetadataDetails> relatedTypeMd = webMetadataService
                .getRelatedApplicationTypeMetadata(formBackingType,
                        memberDetails, jspMetadataId);
        final JavaTypeMetadataDetails formbackingTypeMetadata = relatedTypeMd
                .get(formBackingType);
        Validate.notNull(formbackingTypeMetadata,
                "Form backing type metadata required");
        final JavaTypePersistenceMetadataDetails formBackingTypePersistenceMetadata = formbackingTypeMetadata
                .getPersistenceDetails();
        if (formBackingTypePersistenceMetadata == null) {
            return null;
        }
        final ClassOrInterfaceTypeDetails formBackingTypeDetails = typeLocationService
                .getTypeDetails(formBackingType);
        final LogicalPath formBackingTypePath = PhysicalTypeIdentifier
                .getPath(formBackingTypeDetails.getDeclaredByMetadataId());
        metadataDependencyRegistry.registerDependency(PhysicalTypeIdentifier
                .createIdentifier(formBackingType, formBackingTypePath),
                JspMetadata.createIdentifier(formBackingType,
                        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 {
            final File file = new File(destinationDirectory);
            Validate.isTrue(file.isDirectory(),
                    "%s is a file, when a directory was expected",
                    destinationDirectory);
        }

        // By now we have a directory to put the JSPs inside
        final String listPath1 = destinationDirectory + "/list.jspx";
        xmlRoundTripFileManager.writeToDiskIfNecessary(listPath1,
                viewManager.getListDocument());
        tilesOperations.addViewDefinition(controllerPath, webappPath,
                controllerPath + "/" + "list",
                TilesOperations.DEFAULT_TEMPLATE, WEB_INF_VIEWS
                        + controllerPath + "/list.jspx");

        final String showPath = destinationDirectory + "/show.jspx";
        xmlRoundTripFileManager.writeToDiskIfNecessary(showPath,
                viewManager.getShowDocument());
        tilesOperations.addViewDefinition(controllerPath, webappPath,
                controllerPath + "/" + "show",
                TilesOperations.DEFAULT_TEMPLATE, WEB_INF_VIEWS
                        + controllerPath + "/show.jspx");

        final Map<String, String> properties = new LinkedHashMap<String, String>();

        final JavaSymbolName categoryName = new JavaSymbolName(
                formBackingType.getSimpleTypeName());
        properties.put("menu_category_"
                + categoryName.getSymbolName().toLowerCase() + "_label",
                categoryName.getReadableSymbolName());

        final JavaSymbolName newMenuItemId = new JavaSymbolName("new");
        properties.put("menu_item_"
                + categoryName.getSymbolName().toLowerCase() + "_"
                + newMenuItemId.getSymbolName().toLowerCase() + "_label",
                new JavaSymbolName(formBackingType.getSimpleTypeName())
                        .getReadableSymbolName());

        if (webScaffoldMetadata.getAnnotationValues().isCreate()) {
            final String listPath = destinationDirectory + "/create.jspx";
            xmlRoundTripFileManager.writeToDiskIfNecessary(listPath,
                    viewManager.getCreateDocument());
            // Add 'create new' menu item
            menuOperations.addMenuItem(categoryName, newMenuItemId,
                    "global_menu_new", "/" + controllerPath + "?form",
                    MenuOperations.DEFAULT_MENU_ITEM_PREFIX, webappPath);
            tilesOperations.addViewDefinition(controllerPath, webappPath,
                    controllerPath + "/" + "create",
                    TilesOperations.DEFAULT_TEMPLATE, WEB_INF_VIEWS
                            + controllerPath + "/create.jspx");
        }
        else {
            menuOperations
                    .cleanUpMenuItem(categoryName, new JavaSymbolName("new"),
                            MenuOperations.DEFAULT_MENU_ITEM_PREFIX, webappPath);
            tilesOperations.removeViewDefinition(controllerPath + "/"
                    + "create", controllerPath, webappPath);
        }
        if (webScaffoldMetadata.getAnnotationValues().isUpdate()) {
            final String listPath = destinationDirectory + "/update.jspx";
            xmlRoundTripFileManager.writeToDiskIfNecessary(listPath,
                    viewManager.getUpdateDocument());
            tilesOperations.addViewDefinition(controllerPath, webappPath,
                    controllerPath + "/" + "update",
                    TilesOperations.DEFAULT_TEMPLATE, WEB_INF_VIEWS
                            + controllerPath + "/update.jspx");
        }
        else {
            tilesOperations.removeViewDefinition(controllerPath + "/"
                    + "update", controllerPath, webappPath);
        }

        // Setup labels for i18n support
        final String resourceId = XmlUtils.convertId("label."
                + formBackingType.getFullyQualifiedTypeName().toLowerCase());
        properties.put(resourceId,
                new JavaSymbolName(formBackingType.getSimpleTypeName())
                        .getReadableSymbolName());

        final String pluralResourceId = XmlUtils.convertId(resourceId
                + ".plural");
        final String plural = formBackingTypeMetadataDetails.getPlural();
        properties.put(pluralResourceId,
                new JavaSymbolName(plural).getReadableSymbolName());

        final JavaTypePersistenceMetadataDetails javaTypePersistenceMetadataDetails = formBackingTypeMetadataDetails
                .getPersistenceDetails();
        Validate.notNull(javaTypePersistenceMetadataDetails,
                "Unable to determine persistence metadata for type %s",
                formBackingType.getFullyQualifiedTypeName());

        if (!javaTypePersistenceMetadataDetails.getRooIdentifierFields()
                .isEmpty()) {
            for (final FieldMetadata idField : javaTypePersistenceMetadataDetails
                    .getRooIdentifierFields()) {
                properties.put(
                        XmlUtils.convertId(resourceId
                                + "."
                                + javaTypePersistenceMetadataDetails
                                        .getIdentifierField().getFieldName()
                                        .getSymbolName()
                                + "."
                                + idField.getFieldName().getSymbolName()
                                        .toLowerCase()), idField.getFieldName()
                                .getReadableSymbolName());
            }
        }

        // If no auto generated value for id, put name in i18n
        if (javaTypePersistenceMetadataDetails.getIdentifierField()
                .getAnnotation(JpaJavaType.GENERATED_VALUE) == null) {
            properties.put(
                    XmlUtils.convertId(resourceId
                            + "."
                            + javaTypePersistenceMetadataDetails
                                    .getIdentifierField().getFieldName()
                                    .getSymbolName().toLowerCase()),
                    javaTypePersistenceMetadataDetails.getIdentifierField()
                            .getFieldName().getReadableSymbolName());
        }

        for (final MethodMetadata method : memberDetails.getMethods()) {
            if (!BeanInfoUtils.isAccessorMethod(method)) {
                continue;
            }

            final FieldMetadata field = BeanInfoUtils
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.