Package org.springframework.roo.classpath.details

Examples of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails


            @CliOption(key = "fetch", mandatory = false, help = "The fetch semantics at a JPA level") final Fetch fetch,
            @CliOption(key = "comment", mandatory = false, help = "An optional comment for JavaDocs") final String comment,
            @CliOption(key = "transient", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates to mark the field as transient") final boolean transientModifier,
            @CliOption(key = "permitReservedWords", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates whether reserved words are ignored by Roo") final boolean permitReservedWords) {

        final ClassOrInterfaceTypeDetails cid = typeLocationService
                .getTypeDetails(fieldType);
        Validate.notNull(
                cid,
                "The specified target '--type' does not exist or can not be found. Please create this type first.");

        // Check if the requested entity is a JPA @Entity
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(this.getClass().getName(), cid);
        final AnnotationMetadata entityAnnotation = memberDetails
                .getAnnotation(ENTITY);
        final AnnotationMetadata persistentAnnotation = memberDetails
                .getAnnotation(PERSISTENT);

        if (entityAnnotation != null) {
            Validate.isTrue(cardinality == Cardinality.ONE_TO_MANY
                    || cardinality == Cardinality.MANY_TO_MANY,
                    "Cardinality must be ONE_TO_MANY or MANY_TO_MANY for the field set command");
        }
        else if (cid.getPhysicalTypeCategory() == PhysicalTypeCategory.ENUMERATION) {
            cardinality = null;
        }
        else if (persistentAnnotation != null) {
            // Yes, we can deal with that
        }
        else {
            throw new IllegalStateException(
                    "The field set command is only applicable to enum, JPA @Entity or Spring Data @Persistence elements");
        }

        final ClassOrInterfaceTypeDetails javaTypeDetails = typeLocationService
                .getTypeDetails(typeName);
        Validate.notNull(javaTypeDetails,
                "The type specified, '%s', doesn't exist", typeName);

        final String physicalTypeIdentifier = javaTypeDetails
                .getDeclaredByMetadataId();
        final SetField fieldDetails = new SetField(physicalTypeIdentifier,
                new JavaType(SET.getFullyQualifiedTypeName(), 0, DataType.TYPE,
                        null, Arrays.asList(fieldType)), fieldName, fieldType,
                cardinality);
View Full Code Here


        // Set up
        final File file = getResource(ENUM_FILE_PATH);
        final String fileContents = getResourceContents(file);
        final String filePath = file.getCanonicalPath();

        final ClassOrInterfaceTypeDetails enumDetails = typeParsingService
                .getTypeFromString(fileContents, ENUM_DECLARED_BY_MID,
                        ENUM_TYPE);

        // Invoke
        final String result = typeParsingService
                .updateAndGetCompilationUnitContents(filePath, enumDetails);

        saveResult(file, result);

        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                enumDetails);

        cidBuilder.addEnumConstant(new JavaSymbolName("ALIEN"));

        final ClassOrInterfaceTypeDetails enumDetails2 = cidBuilder.build();

        // Invoke
        final String result2 = typeParsingService
                .updateAndGetCompilationUnitContents(filePath, enumDetails2);
View Full Code Here

        // Set up
        final File file = getResource(SIMPLE_INTERFACE_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents,
                        SIMPLE_INTERFACE_DECLARED_BY_MID, SIMPLE_INTERFACE_TYPE);

        final File voidFile = new File(file.getCanonicalFile() + ".void");
View Full Code Here

            @CliOption(key = "fetch", mandatory = false, help = "The fetch semantics at a JPA level") final Fetch fetch,
            @CliOption(key = "comment", mandatory = false, help = "An optional comment for JavaDocs") final String comment,
            @CliOption(key = "transient", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates to mark the field as transient") final boolean transientModifier,
            @CliOption(key = "permitReservedWords", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates whether reserved words are ignored by Roo") final boolean permitReservedWords) {

        final ClassOrInterfaceTypeDetails cid = typeLocationService
                .getTypeDetails(fieldType);
        Validate.notNull(
                cid,
                "The specified target '--type' does not exist or can not be found. Please create this type first.");

        // Check if the requested entity is a JPA @Entity
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(this.getClass().getName(), cid);
        final AnnotationMetadata entityAnnotation = memberDetails
                .getAnnotation(ENTITY);
        final AnnotationMetadata persistentAnnotation = memberDetails
                .getAnnotation(PERSISTENT);

        if (entityAnnotation != null) {
            Validate.isTrue(cardinality == Cardinality.ONE_TO_MANY
                    || cardinality == Cardinality.MANY_TO_MANY,
                    "Cardinality must be ONE_TO_MANY or MANY_TO_MANY for the field list command");
        }
        else if (cid.getPhysicalTypeCategory() == PhysicalTypeCategory.ENUMERATION) {
            cardinality = null;
        }
        else if (persistentAnnotation != null) {
            // Yes, we can deal with that
        }
        else {
            throw new IllegalStateException(
                    "The field list command is only applicable to enum, JPA @Entity or Spring Data @Persistence elements");
        }

        final ClassOrInterfaceTypeDetails javaTypeDetails = typeLocationService
                .getTypeDetails(typeName);
        Validate.notNull(javaTypeDetails,
                "The type specified, '%s' doesn't exist", typeName);

        final String physicalTypeIdentifier = javaTypeDetails
                .getDeclaredByMetadataId();
        final ListField fieldDetails = new ListField(physicalTypeIdentifier,
                new JavaType(LIST.getFullyQualifiedTypeName(), 0,
                        DataType.TYPE, null, Arrays.asList(fieldType)),
                fieldName, fieldType, cardinality);
View Full Code Here

        // Set up
        final File file = getResource(SIMPLE_CLASS_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS_DECLARED_BY_MID,
                        SIMPLE_CLASS_TYPE);

        // Invoke
        final String result = typeParsingService
View Full Code Here

        // Set up
        final File file = getResource(SIMPLE_CLASS2_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS2_DECLARED_BY_MID,
                        SIMPLE_CLASS2_TYPE);

        // Invoke
        final String result = typeParsingService
View Full Code Here

        // Set up
        final File file = getResource(SIMPLE_CLASS3_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS3_DECLARED_BY_MID,
                        SIMPLE_CLASS3_TYPE);

        // Invoke
        final String result = typeParsingService
View Full Code Here

        // Set up
        final File file = getResource(ROO1505_CLASS_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, ROO1505_CLASS_DECLARED_BY_MID,
                        ROO1505_CLASS_TYPE);

        // Invoke
        final String result = typeParsingService
View Full Code Here

        // Set up
        final File file = getResource(SIMPLE_CLASS_FILE_PATH);
        final String fileContents = getResourceContents(file);

        final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
                .getTypeFromString(fileContents, SIMPLE_CLASS_DECLARED_BY_MID,
                        SIMPLE_CLASS_TYPE);

        final FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(
                SIMPLE_CLASS_DECLARED_BY_MID, Modifier.PRIVATE,
                new JavaSymbolName("newFieldAddedByCode"), new JavaType(
                        String.class), "\"Create by code\"");
        final ClassOrInterfaceTypeDetails newSimpleInterfaceDetails = addField(
                simpleInterfaceDetails, fieldBuilder.build());

        // Invoke
        final String result = typeParsingService
                .updateAndGetCompilationUnitContents(file.getCanonicalPath(),
View Full Code Here

            @CliOption(key = "transient", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates to mark the field as transient") final boolean transientModifier,
            @CliOption(key = "unique", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates whether to mark the field with a unique constraint") final boolean unique,
            @CliOption(key = "permitReservedWords", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates whether reserved words are ignored by Roo") final boolean permitReservedWords,
          @CliOption(key = "lob", mandatory = false, unspecifiedDefaultValue = "false", specifiedDefaultValue = "true", help = "Indicates that this field is a Large Object") final boolean lob) {

        final ClassOrInterfaceTypeDetails cid = typeLocationService
                .getTypeDetails(typeName);
        Validate.notNull(cid, "The type specified, '%s', doesn't exist",
                typeName);

        final String physicalTypeIdentifier = cid.getDeclaredByMetadataId();
        final StringField fieldDetails = new StringField(
                physicalTypeIdentifier, fieldName);
        fieldDetails.setNotNull(notNull);
        fieldDetails.setNullRequired(nullRequired);
        if (decimalMin != null) {
View Full Code Here

TOP

Related Classes of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails

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.