Examples of JpaActiveRecordMetadata


Examples of org.springframework.roo.addon.jpa.activerecord.JpaActiveRecordMetadata

                .getPath(metadataIdentificationString);
        final String jpaActiveRecordMetadataKey = JpaActiveRecordMetadata
                .createIdentifier(javaType, path);

        // We need to lookup the metadata we depend on
        final JpaActiveRecordMetadata jpaActiveRecordMetadata = (JpaActiveRecordMetadata) metadataService
                .get(jpaActiveRecordMetadataKey);
        if (jpaActiveRecordMetadata == null
                || !jpaActiveRecordMetadata.isValid()) {
            return null;
        }

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

        // We do not need to monitor the parent, as any changes to the java type
        // associated with the parent will trickle down to
        // the governing java type
        final JavaType identifierType = persistenceMemberLocator
                .getIdentifierType(javaType);
        if (identifierType == null) {
            return null;
        }

        final MethodMetadata identifierAccessor = persistenceMemberLocator
                .getIdentifierAccessor(javaType);
        if (identifierAccessor == null) {
            return null;
        }

        final MethodMetadata findMethod = jpaActiveRecordMetadata
                .getFindMethod();

        return new EditorMetadata(metadataIdentificationString, aspectName,
                governorPhysicalTypeMetadata, javaType, identifierType,
                identifierAccessor, findMethod);
View Full Code Here

Examples of org.springframework.roo.addon.jpa.activerecord.JpaActiveRecordMetadata

                .createIdentifier(javaType, path);

        // We want to be notified if the getter info changes in any way
        metadataDependencyRegistry.registerDependency(
                jpaActiveRecordMetadataKey, metadataIdentificationString);
        final JpaActiveRecordMetadata jpaActiveRecordMetadata = (JpaActiveRecordMetadata) metadataService
                .get(jpaActiveRecordMetadataKey);

        // Abort if we don't have getter information available
        if (jpaActiveRecordMetadata == null
                || !jpaActiveRecordMetadata.isValid()) {
            return null;
        }

        // Otherwise go off and create the Solr metadata
        String beanPlural = javaType.getSimpleTypeName() + "s";
View Full Code Here

Examples of org.springframework.roo.addon.jpa.activerecord.JpaActiveRecordMetadata

        final LogicalPath path = PhysicalTypeIdentifier.getPath(id);
        final String entityMid = JpaActiveRecordMetadata.createIdentifier(
                javaType, path);

        // Get the entity metadata
        final JpaActiveRecordMetadata jpaActiveRecordMetadata = (JpaActiveRecordMetadata) metadataService
                .get(entityMid);
        if (jpaActiveRecordMetadata == null) {
            LOGGER.warning("Cannot provide finders because '"
                    + typeName.getFullyQualifiedTypeName()
                    + "' is not an entity - " + entityMid);
            return;
        }

        // We know the file exists, as there's already entity metadata for it
        final ClassOrInterfaceTypeDetails cid = typeLocationService
                .getTypeDetails(id);
        if (cid == null) {
            throw new IllegalArgumentException("Cannot locate source for '"
                    + javaType.getFullyQualifiedTypeName() + "'");
        }

        // We know there should be an existing RooEntity annotation
        final List<? extends AnnotationMetadata> annotations = cid
                .getAnnotations();
        final AnnotationMetadata jpaActiveRecordAnnotation = MemberFindingUtils
                .getAnnotationOfType(annotations, ROO_JPA_ACTIVE_RECORD);
        if (jpaActiveRecordAnnotation == null) {
            LOGGER.warning("Unable to find the entity annotation on '"
                    + typeName.getFullyQualifiedTypeName() + "'");
            return;
        }

        // Confirm they typed a valid finder name
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(getClass().getName(), cid);
        if (dynamicFinderServices.getQueryHolder(memberDetails, finderName,
                jpaActiveRecordMetadata.getPlural(),
                jpaActiveRecordMetadata.getEntityName()) == null) {
            LOGGER.warning("Finder name '" + finderName.getSymbolName()
                    + "' either does not exist or contains an error");
            return;
        }
View Full Code Here

Examples of org.springframework.roo.addon.jpa.activerecord.JpaActiveRecordMetadata

        final LogicalPath path = PhysicalTypeIdentifier.getPath(id);
        final String entityMid = JpaActiveRecordMetadata.createIdentifier(
                javaType, path);

        // Get the entity metadata
        final JpaActiveRecordMetadata jpaActiveRecordMetadata = (JpaActiveRecordMetadata) metadataService
                .get(entityMid);
        if (jpaActiveRecordMetadata == null) {
            throw new IllegalArgumentException(
                    "Cannot provide finders because '"
                            + typeName.getFullyQualifiedTypeName()
                            + "' is not an 'active record' entity");
        }

        // Get the member details
        final PhysicalTypeMetadata physicalTypeMetadata = (PhysicalTypeMetadata) metadataService
                .get(PhysicalTypeIdentifier.createIdentifier(javaType, path));
        if (physicalTypeMetadata == null) {
            throw new IllegalStateException(
                    "Could not determine physical type metadata for type "
                            + javaType);
        }
        final ClassOrInterfaceTypeDetails cid = physicalTypeMetadata
                .getMemberHoldingTypeDetails();
        if (cid == null) {
            throw new IllegalStateException(
                    "Could not determine class or interface type details for type "
                            + javaType);
        }
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(getClass().getName(), cid);
        final List<FieldMetadata> idFields = persistenceMemberLocator
                .getIdentifierFields(javaType);
        final FieldMetadata versionField = persistenceMemberLocator
                .getVersionField(javaType);

        // Compute the finders (excluding the ID, version, and EM fields)
        final Set<JavaSymbolName> exclusions = new HashSet<JavaSymbolName>();
        exclusions.add(jpaActiveRecordMetadata.getEntityManagerField()
                .getFieldName());
        for (final FieldMetadata idField : idFields) {
            exclusions.add(idField.getFieldName());
        }

        if (versionField != null) {
            exclusions.add(versionField.getFieldName());
        }

        final SortedSet<String> result = new TreeSet<String>();

        final List<JavaSymbolName> finders = dynamicFinderServices.getFinders(
                memberDetails, jpaActiveRecordMetadata.getPlural(), depth,
                exclusions);
        for (final JavaSymbolName finder : finders) {
            // Avoid displaying problematic finders
            try {
                final QueryHolder queryHolder = dynamicFinderServices
                        .getQueryHolder(memberDetails, finder,
                                jpaActiveRecordMetadata.getPlural(),
                                jpaActiveRecordMetadata.getEntityName());
                final List<JavaSymbolName> parameterNames = queryHolder
                        .getParameterNames();
                final List<JavaType> parameterTypes = queryHolder
                        .getParameterTypes();
                final StringBuilder signature = new StringBuilder();
View Full Code Here

Examples of org.springframework.roo.addon.jpa.activerecord.JpaActiveRecordMetadata

                .getPath(metadataIdentificationString);
        final String jpaActiveRecordMetadataKey = JpaActiveRecordMetadata
                .createIdentifier(javaType, path);

        // We need to lookup the metadata we depend on
        final JpaActiveRecordMetadata jpaActiveRecordMetadata = (JpaActiveRecordMetadata) metadataService
                .get(jpaActiveRecordMetadataKey);
        if (jpaActiveRecordMetadata == null
                || !jpaActiveRecordMetadata.isValid()) {
            return new FinderMetadata(metadataIdentificationString, aspectName,
                    governorPhysicalTypeMetadata, null,
                    Collections.<JavaSymbolName, QueryHolder> emptyMap());
        }
        final MethodMetadata entityManagerMethod = jpaActiveRecordMetadata
                .getEntityManagerMethod();
        if (entityManagerMethod == null) {
            return null;
        }

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

        final String plural = jpaActiveRecordMetadata.getPlural();
        final String entityName = jpaActiveRecordMetadata.getEntityName();

        // Using SortedMap to ensure that the ITD emits finders in the same
        // order each time
        final SortedMap<JavaSymbolName, QueryHolder> queryHolders = new TreeMap<JavaSymbolName, QueryHolder>();
        for (final String methodName : jpaActiveRecordMetadata
                .getDynamicFinders()) {
            final JavaSymbolName finderName = new JavaSymbolName(methodName);
            final QueryHolder queryHolder = dynamicFinderServices
                    .getQueryHolder(memberDetails, finderName, plural,
                            entityName);
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.