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

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


        final JavaType fieldType = new JavaType(
                SET.getFullyQualifiedTypeName(), 0, DataType.TYPE, null, params);

        // Add annotations to field
        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
        final AnnotationMetadataBuilder manyToManyBuilder = new AnnotationMetadataBuilder(
                MANY_TO_MANY);
        manyToManyBuilder.addStringAttribute(MAPPED_BY,
                mappedByFieldName.getSymbolName());
        addCascadeType(manyToManyBuilder, onUpdate, onDelete);
        annotations.add(manyToManyBuilder);

        return new FieldMetadataBuilder(getId(), Modifier.PRIVATE, annotations,
View Full Code Here


        // Add annotations to field
        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();

        // Add @ManyToMany annotation
        final AnnotationMetadataBuilder manyToManyBuilder = new AnnotationMetadataBuilder(
                MANY_TO_MANY);
        annotations.add(manyToManyBuilder);

        // Add @JoinTable annotation
        final AnnotationMetadataBuilder joinTableBuilder = new AnnotationMetadataBuilder(
                JOIN_TABLE);
        final List<AnnotationAttributeValue<?>> joinTableAnnotationAttributes = new ArrayList<AnnotationAttributeValue<?>>();
        joinTableAnnotationAttributes.add(new StringAttributeValue(
                new JavaSymbolName(NAME), joinTable.getName()));

        final Iterator<ForeignKey> iter = joinTable.getImportedKeys()
                .iterator();

        // Add "joinColumns" attribute containing nested @JoinColumn annotations
        final List<NestedAnnotationAttributeValue> joinColumnArrayValues = new ArrayList<NestedAnnotationAttributeValue>();
        final Set<Reference> firstKeyReferences = iter.next().getReferences();
        for (final Reference reference : firstKeyReferences) {
            final AnnotationMetadataBuilder joinColumnBuilder = getJoinColumnAnnotation(
                    reference, firstKeyReferences.size() > 1);
            joinColumnArrayValues.add(new NestedAnnotationAttributeValue(
                    new JavaSymbolName(VALUE), joinColumnBuilder.build()));
        }
        joinTableAnnotationAttributes
                .add(new ArrayAttributeValue<NestedAnnotationAttributeValue>(
                        new JavaSymbolName("joinColumns"),
                        joinColumnArrayValues));

        // Add "inverseJoinColumns" attribute containing nested @JoinColumn
        // annotations
        final List<NestedAnnotationAttributeValue> inverseJoinColumnArrayValues = new ArrayList<NestedAnnotationAttributeValue>();
        final Set<Reference> lastKeyReferences = iter.next().getReferences();
        for (final Reference reference : lastKeyReferences) {
            final AnnotationMetadataBuilder joinColumnBuilder = getJoinColumnAnnotation(
                    reference, lastKeyReferences.size() > 1);
            inverseJoinColumnArrayValues
                    .add(new NestedAnnotationAttributeValue(new JavaSymbolName(
                            VALUE), joinColumnBuilder.build()));
        }
        joinTableAnnotationAttributes
                .add(new ArrayAttributeValue<NestedAnnotationAttributeValue>(
                        new JavaSymbolName("inverseJoinColumns"),
                        inverseJoinColumnArrayValues));
View Full Code Here

        final JavaType fieldType = new JavaType(
                SET.getFullyQualifiedTypeName(), 0, DataType.TYPE, null,
                Arrays.asList(element));
        // Add @OneToMany annotation
        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
        final AnnotationMetadataBuilder oneToManyBuilder = new AnnotationMetadataBuilder(
                ONE_TO_MANY);
        oneToManyBuilder.addStringAttribute(MAPPED_BY,
                mappedByFieldName.getSymbolName());
        addCascadeType(oneToManyBuilder, onUpdate, onDelete);
        annotations.add(oneToManyBuilder);

        return new FieldMetadataBuilder(getId(), Modifier.PRIVATE, annotations,
View Full Code Here

    private FieldMetadataBuilder getOneToOneMappedByField(
            final JavaSymbolName fieldName, final JavaType fieldType,
            final JavaSymbolName mappedByFieldName,
            final CascadeAction onUpdate, final CascadeAction onDelete) {
        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
        final AnnotationMetadataBuilder oneToOneBuilder = new AnnotationMetadataBuilder(
                ONE_TO_ONE);
        oneToOneBuilder.addStringAttribute(MAPPED_BY,
                mappedByFieldName.getSymbolName());
        addCascadeType(oneToOneBuilder, onUpdate, onDelete);
        annotations.add(oneToOneBuilder);

        return new FieldMetadataBuilder(getId(), Modifier.PRIVATE, annotations,
View Full Code Here

            final boolean referencedColumn) {
        // Add annotations to field
        final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();

        // Add annotation
        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                annotationType);
        if (foreignKey.isExported()) {
            addCascadeType(annotationBuilder, foreignKey.getOnUpdate(),
                    foreignKey.getOnDelete());
        }
View Full Code Here

            // Create annotation @RequestMapping("/myobject/**")
            final List<AnnotationAttributeValue<?>> requestMappingAttributes = new ArrayList<AnnotationAttributeValue<?>>();
            requestMappingAttributes.add(new StringAttributeValue(VALUE, "/"
                    + path));
            annotations = new ArrayList<AnnotationMetadataBuilder>();
            annotations.add(new AnnotationMetadataBuilder(REQUEST_MAPPING,
                    requestMappingAttributes));

            // Create annotation @Controller
            final List<AnnotationAttributeValue<?>> controllerAttributes = new ArrayList<AnnotationAttributeValue<?>>();
            annotations.add(new AnnotationMetadataBuilder(CONTROLLER,
                    controllerAttributes));

            // Create annotation @RooWebScaffold(path = "/test",
            // formBackingObject = MyObject.class)
            annotations.add(getRooWebScaffoldAnnotation(entity,
View Full Code Here

                new JavaSymbolName("formBackingObject"), entity));
        for (final String operation : disallowedOperations) {
            rooWebScaffoldAttributes.add(new BooleanAttributeValue(
                    new JavaSymbolName(operation), false));
        }
        return new AnnotationMetadataBuilder(ROO_WEB_SCAFFOLD,
                rooWebScaffoldAttributes);
    }
View Full Code Here

                return candidate;
            }

            // Candidate not found, so let's create one
            final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
            final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                    PERSISTENCE_CONTEXT);
            if (StringUtils.isNotBlank(crudAnnotationValues
                    .getPersistenceUnit())) {
                annotationBuilder.addStringAttribute("unitName",
                        crudAnnotationValues.getPersistenceUnit());
            }
            annotations.add(annotationBuilder);

            return new FieldMetadataBuilder(getId(), Modifier.TRANSIENT,
View Full Code Here

    }

    private void addTransactionalAnnotation(
            final List<AnnotationMetadataBuilder> annotations,
            final boolean isPersistMethod) {
        final AnnotationMetadataBuilder transactionalBuilder = new AnnotationMetadataBuilder(
                TRANSACTIONAL);
        if (StringUtils
                .isNotBlank(crudAnnotationValues.getTransactionManager())) {
            transactionalBuilder.addStringAttribute("value",
                    crudAnnotationValues.getTransactionManager());
        }
        if (isGaeEnabled && isPersistMethod) {
            transactionalBuilder.addEnumAttribute("propagation",
                    new EnumDetails(PROPAGATION, new JavaSymbolName(
                            "REQUIRES_NEW")));
        }
        annotations.add(transactionalBuilder);
    }
View Full Code Here

    bodyBuilder.appendFormalLine("this." + CS_FIELD + " = " + CS_FIELD
        + ";");

    final ConstructorMetadataBuilder constructorBuilder = new ConstructorMetadataBuilder(
        getId());
    constructorBuilder.addAnnotation(new AnnotationMetadataBuilder(
        AUTOWIRED));
    constructorBuilder.addParameterType(AnnotatedJavaType
        .convertFromJavaType(CONVERSION_SERVICE));
    constructorBuilder.addParameterName(CS_FIELD);
    constructorBuilder.setModifier(Modifier.PUBLIC);
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.