Skip to content
Permalink
Browse files

ROO-3712: Generating ReadOnlyRepository if needed

  • Loading branch information
jcagarcia committed Feb 17, 2016
1 parent da37589 commit fb1ce6fd90162ddf0baed0dc5a544bfaec1684fb
@@ -13,11 +13,12 @@
*
* @author Stefan Schmidt
* @author Andrew Swan
* @author Juan Carlos García
* @since 1.2.0
*/
public class RepositoryJpaAnnotationValues extends AbstractAnnotationValues {

@AutoPopulate private JavaType domainType;
@AutoPopulate private JavaType entity;

/**
* Constructor
@@ -31,11 +32,11 @@ public RepositoryJpaAnnotationValues(
}

/**
* Returns the domain type managed by the annotated repository
* Returns the entity type managed by the annotated repository
*
* @return a non-<code>null</code> type
*/
public JavaType getDomainType() {
return domainType;
public JavaType getEntity() {
return entity;
}
}
@@ -32,7 +32,7 @@ public boolean isRepositoryCommandAvailable() {
@CliCommand(value = "repository jpa", help = "Generates new Spring Data repository for specified entity.")
public void repository(
@CliOption(key = "class", mandatory = true, help = "The java Spring Data repository to generate (Will be an interface.)") final JavaType interfaceType,
@CliOption(key = "entity", unspecifiedDefaultValue = "*", optionContext = PROJECT, mandatory = false, help = "The domain entity this repository should expose") final JavaType domainType) {
@CliOption(key = "entity", mandatory = true, unspecifiedDefaultValue = "*", optionContext = PROJECT, help = "The domain entity this repository should expose") final JavaType domainType) {

repositoryJpaOperations.addRepository(interfaceType, domainType);
}
@@ -49,8 +49,8 @@
typeLocationService
.getPhysicalTypeCanonicalPath(cid
.getDeclaredByMetadataId()), cid));
if (annotationValues.getDomainType() != null
&& annotationValues.getDomainType().equals(domainType)) {
if (annotationValues.getEntity() != null
&& annotationValues.getEntity().equals(domainType)) {
toReturn.put(cid.getDeclaredByMetadataId(), cid);
}
}
@@ -82,13 +82,13 @@ public RepositoryJpaMetadata(final String identifier,
// JpaRepository interface if it doesn't already
ensureGovernorExtends(new JavaType(SPRING_JPA_REPOSITORY, 0,
DataType.TYPE, null, Arrays.asList(
annotationValues.getDomainType(), identifierType)));
annotationValues.getEntity(), identifierType)));

// ... and likewise extend JpaSpecificationExecutor<Foo>, to allow query
// by specification
ensureGovernorExtends(new JavaType(SPRING_JPA_SPECIFICATION_EXECUTOR,
0, DataType.TYPE, null, Arrays.asList(annotationValues
.getDomainType())));
.getEntity())));

builder.addAnnotation(new AnnotationMetadataBuilder(
SpringJavaType.REPOSITORY));
@@ -74,7 +74,7 @@ protected void activate(final ComponentContext cContext) {

this.keyDecoratorTracker = new CustomDataKeyDecoratorTracker(context, getClass(),
new LayerTypeMatcher(ROO_REPOSITORY_JPA, new JavaSymbolName(
RooJpaRepository.DOMAIN_TYPE_ATTRIBUTE)));
RooJpaRepository.ENTITY_ATTRIBUTE)));
this.keyDecoratorTracker.open();
}

@@ -151,7 +151,7 @@ protected ItdTypeDetailsProvidingMetadataItem getMetadata(
final String itdFilename) {
final RepositoryJpaAnnotationValues annotationValues = new RepositoryJpaAnnotationValues(
governorPhysicalTypeMetadata);
final JavaType domainType = annotationValues.getDomainType();
final JavaType domainType = annotationValues.getEntity();
final JavaType identifierType = getPersistenceMemberLocator()
.getIdentifierType(domainType);
if (identifierType == null) {

0 comments on commit fb1ce6f

Please sign in to comment.
You can’t perform that action at this time.