use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class JpaAuditMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = JpaAuditMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = JpaAuditMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class JpaDataOnDemandCreator method createEntityFactory.
@Override
public JavaType createEntityFactory(JavaType currentEntity) {
Validate.notNull(currentEntity, "Entity to produce a data on demand provider for is required");
// Verify the requested entity actually exists as a class and is not
// abstract
final ClassOrInterfaceTypeDetails cid = getEntityDetails(currentEntity);
Validate.isTrue(cid.getPhysicalTypeCategory() == PhysicalTypeCategory.CLASS, "Type %s is not a class", currentEntity.getFullyQualifiedTypeName());
Validate.isTrue(!Modifier.isAbstract(cid.getModifier()), "Type %s is abstract", currentEntity.getFullyQualifiedTypeName());
// Check if the requested entity is a JPA @Entity
final MemberDetails memberDetails = memberDetailsScanner.getMemberDetails(JpaDataOnDemandCreator.class.getName(), cid);
final AnnotationMetadata entityAnnotation = memberDetails.getAnnotation(ENTITY);
Validate.isTrue(entityAnnotation != null, "Type %s must be a JPA entity type", currentEntity.getFullyQualifiedTypeName());
// Get related entities
List<JavaType> entities = getEntityAndRelatedEntitiesList(currentEntity);
// Get test Path for module
final LogicalPath path = LogicalPath.getInstance(Path.SRC_TEST_JAVA, currentEntity.getModule());
JavaType currentEntityFactory = null;
for (JavaType entity : entities) {
// Create the JavaType for the configuration class
JavaType factoryClass = new JavaType(String.format("%s.dod.%sFactory", entity.getPackage().getFullyQualifiedPackageName(), entity.getSimpleTypeName()), entity.getModule());
final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(factoryClass, path);
if (metadataService.get(declaredByMetadataId) != null) {
// The file already exists
continue;
}
// Create the CID builder
ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, factoryClass, PhysicalTypeCategory.CLASS);
// Add @RooEntityFactory annotation
AnnotationMetadataBuilder entityFactoryAnnotation = new AnnotationMetadataBuilder(RooJavaType.ROO_JPA_ENTITY_FACTORY);
entityFactoryAnnotation.addClassAttribute("entity", entity);
cidBuilder.addAnnotation(entityFactoryAnnotation);
// Write changes to disk
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
// First entity is current entity
if (currentEntityFactory == null) {
currentEntityFactory = cidBuilder.getName();
}
}
return currentEntityFactory;
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class JpaDataOnDemandMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = JpaDataOnDemandMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = JpaDataOnDemandMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class JpaDataOnDemandConfigurationMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = JpaDataOnDemandConfigurationMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = JpaDataOnDemandConfigurationMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class JpaEntityFactoryMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = JpaEntityFactoryMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = JpaEntityFactoryMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
Aggregations