Package org.springframework.roo.classpath.details.annotations

Examples of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder


        final String declaredByMetadataId = PhysicalTypeIdentifier
                .createIdentifier(identifierType,
                        pathResolver.getFocusedPath(Path.SRC_MAIN_JAVA));
        final List<AnnotationMetadataBuilder> identifierAnnotations = Arrays
                .asList(new AnnotationMetadataBuilder(ROO_TO_STRING),
                        new AnnotationMetadataBuilder(ROO_EQUALS),
                        new AnnotationMetadataBuilder(ROO_IDENTIFIER));
        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                declaredByMetadataId, Modifier.PUBLIC | Modifier.FINAL,
                identifierType, PhysicalTypeCategory.CLASS);
        cidBuilder.setAnnotations(identifierAnnotations);
View Full Code Here


            final JavaType entity) {
        // Create type annotation for new converter class
        final JavaType converterType = new JavaType(
                javaPackage.getFullyQualifiedPackageName() + "."
                        + entity.getSimpleTypeName() + "Converter");
        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                ROO_JSF_CONVERTER);
        annotationBuilder.addClassAttribute("entity", entity);
        final String declaredByMetadataId = PhysicalTypeIdentifier
                .createIdentifier(converterType,
                        pathResolver.getFocusedPath(Path.SRC_MAIN_JAVA));
        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                declaredByMetadataId, Modifier.PUBLIC, converterType,
View Full Code Here

                                .getDeclaredByMetadataId())));
        Validate.notNull(pluralMetadata,
                "The plural for type '%s' could not be resolved", entity);

        // Create type annotation for new managed bean
        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                ROO_JSF_MANAGED_BEAN);
        annotationBuilder.addClassAttribute("entity", entity);

        if (StringUtils.isBlank(beanName)) {
            beanName = StringUtils
                    .uncapitalize(managedBean.getSimpleTypeName());
        }
        annotationBuilder.addStringAttribute("beanName", beanName);

        if (!includeOnMenu) {
            annotationBuilder.addBooleanAttribute("includeOnMenu",
                    includeOnMenu);
        }

        final LogicalPath managedBeanPath = pathResolver
                .getFocusedPath(Path.SRC_MAIN_JAVA);
        final String resourceIdentifier = typeLocationService
                .getPhysicalTypeCanonicalPath(managedBean, managedBeanPath);
        final String declaredByMetadataId = PhysicalTypeIdentifier
                .createIdentifier(managedBean,
                        pathResolver.getPath(resourceIdentifier));

        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                declaredByMetadataId, Modifier.PUBLIC, managedBean,
                PhysicalTypeCategory.CLASS);
        cidBuilder
                .addAnnotation(new AnnotationMetadataBuilder(ROO_SERIALIZABLE));
        cidBuilder.addAnnotation(annotationBuilder);

        typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());

        shell.flash(Level.FINE,
View Full Code Here

        final String classMdId = PhysicalTypeIdentifier.createIdentifier(
                classType, pathResolver.getPath(classIdentifier));
        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                classMdId, Modifier.PUBLIC, classType,
                PhysicalTypeCategory.CLASS);
        cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
                RooJavaType.ROO_JAVA_BEAN));
        cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
                RooJavaType.ROO_TO_STRING));

        final List<AnnotationAttributeValue<?>> attributes = new ArrayList<AnnotationAttributeValue<?>>();
        if (!idType.equals(JdkJavaType.BIG_INTEGER)) {
            attributes.add(new ClassAttributeValue(new JavaSymbolName(
                    "identifierType"), idType));
        }
        cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
                RooJavaType.ROO_MONGO_ENTITY, attributes));
        typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());

        if (testAutomatically) {
            integrationTestOperations.newIntegrationTest(classType, false);
View Full Code Here

        if (fileManager.exists(interfaceIdentifier)) {
            return; // Type exists already - nothing to do
        }

        // Build interface type
        final AnnotationMetadataBuilder interfaceAnnotationMetadata = new AnnotationMetadataBuilder(
                ROO_REPOSITORY_MONGO);
        interfaceAnnotationMetadata.addAttribute(new ClassAttributeValue(
                new JavaSymbolName("domainType"), domainType));
        final String interfaceMdId = PhysicalTypeIdentifier.createIdentifier(
                interfaceType, pathResolver.getPath(interfaceIdentifier));
        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                interfaceMdId, Modifier.PUBLIC, interfaceType,
                PhysicalTypeCategory.INTERFACE);
        cidBuilder.addAnnotation(interfaceAnnotationMetadata.build());
        final JavaType listType = new JavaType(List.class.getName(), 0,
                DataType.TYPE, null, Arrays.asList(domainType));
        cidBuilder.addMethod(new MethodMetadataBuilder(interfaceMdId, 0,
                new JavaSymbolName("findAll"), listType,
                new InvocableMemberBodyBuilder()));
View Full Code Here

      if (annotation.getAnnotationType().equals(ONE_TO_ONE)
          || annotation.getAnnotationType().equals(MANY_TO_ONE)
          || annotation.getAnnotationType().equals(ONE_TO_MANY)
          || annotation.getAnnotationType().equals(MANY_TO_MANY)) {
        builder.addFieldAnnotation(new DeclaredFieldAnnotationDetails(
            field, new AnnotationMetadataBuilder(annotation
                .getAnnotationType()).build(), true));
        builder.addFieldAnnotation(new DeclaredFieldAnnotationDetails(
            field, new AnnotationMetadataBuilder(TRANSIENT).build()));
        break;
      }
    }
  }
View Full Code Here

            final List<MethodParameter> parameters) {
        // Create a builder to hold the repository field to be copied into the
        // caller
        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                callerMID);
        final AnnotationMetadataBuilder autowiredAnnotation = new AnnotationMetadataBuilder(
                AUTOWIRED);
        final String repositoryFieldName = StringUtils
                .uncapitalize(repositoryType.getSimpleTypeName());
        cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0, Arrays
                .asList(autowiredAnnotation), new JavaSymbolName(
View Full Code Here

        }
        final JavaSymbolName idFieldName = governorTypeDetails
                .getUniqueFieldName("id");
        final FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(
                getId(), Modifier.PRIVATE, idFieldName, idType, null);
        fieldBuilder.addAnnotation(new AnnotationMetadataBuilder(
                SpringJavaType.DATA_ID));
        return fieldBuilder.build();
    }
View Full Code Here

                    else if (serviceAnnotationValues.requireAuthentication()) {
                      authorizeValue ="isAuthenticated()";
                    }

                    if (!authorizeValue.equals("")) {
                        final AnnotationMetadataBuilder annotationMetadataBuilder = new AnnotationMetadataBuilder(method.usesPostAuthorize() ? SpringJavaType.POST_AUTHORIZE : PRE_AUTHORIZE);
                        annotationMetadataBuilder.addStringAttribute("value",
                            authorizeValue.toString());
                        methodMetadataBuilder
                                .addAnnotation(annotationMetadataBuilder
                                        .build());
                    }

                    builder.addMethod(methodMetadataBuilder);
                }
            }
        }

        // If useXmlConfiguration is true, do not add @Service
        if (!serviceAnnotationValues.useXmlConfiguration()) {
            // Introduce the @Service annotation via the ITD if it's not already
            // on
            // the service's Java class
            final AnnotationMetadata serviceAnnotation = new AnnotationMetadataBuilder(
                    SERVICE).build();
            if (!governorDetails.isRequestingAnnotatedWith(serviceAnnotation,
                    getId())) {
                builder.addAnnotation(serviceAnnotation);
            }
        }

        // Introduce the @Transactional annotation via the ITD if it's not
        // already on the service's Java class
        if (serviceAnnotationValues.isTransactional()) {
            final AnnotationMetadata transactionalAnnotation = new AnnotationMetadataBuilder(
                    TRANSACTIONAL).build();
            if (!governorDetails.isRequestingAnnotatedWith(
                    transactionalAnnotation, getId())) {
                builder.addAnnotation(transactionalAnnotation);
            }
View Full Code Here

        super.decorateAnnotationsList(annotations);
        final List<AnnotationAttributeValue<?>> attributes = new ArrayList<AnnotationAttributeValue<?>>();

        if (cardinality == null) {
            // Assume set field is an enum
            annotations.add(new AnnotationMetadataBuilder(ELEMENT_COLLECTION));
        }
        else {
            attributes.add(new EnumAttributeValue(
                    new JavaSymbolName("cascade"), new EnumDetails(
                            CASCADE_TYPE, new JavaSymbolName("ALL"))));
            if (fetch != null) {
                JavaSymbolName value = new JavaSymbolName("EAGER");
                if (fetch == Fetch.LAZY) {
                    value = new JavaSymbolName("LAZY");
                }
                attributes.add(new EnumAttributeValue(new JavaSymbolName(
                        "fetch"), new EnumDetails(FETCH_TYPE, value)));
            }
            if (mappedBy != null) {
                attributes.add(new StringAttributeValue(new JavaSymbolName(
                        "mappedBy"), mappedBy.getSymbolName()));
            }

            switch (cardinality) {
            case ONE_TO_MANY:
                annotations.add(new AnnotationMetadataBuilder(ONE_TO_MANY,
                        attributes));
                break;
            case MANY_TO_MANY:
                annotations.add(new AnnotationMetadataBuilder(MANY_TO_MANY,
                        attributes));
                break;
            case ONE_TO_ONE:
                annotations.add(new AnnotationMetadataBuilder(ONE_TO_ONE,
                        attributes));
                break;
            default:
                annotations.add(new AnnotationMetadataBuilder(MANY_TO_ONE,
                        attributes));
                break;
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder

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.