use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class SecurityAuthorizationsMetadataProviderImpl method getLocalMidToRequest.
@Override
protected String getLocalMidToRequest(final ItdTypeDetails itdTypeDetails) {
// Determine the governor for this ITD, and whether any metadata is even
// hoping to hear about changes to that JavaType and its ITDs
final JavaType governor = itdTypeDetails.getName();
final String localMid = domainTypeToServiceMidMap.get(governor);
if (localMid != null) {
return localMid;
}
final MemberHoldingTypeDetails memberHoldingTypeDetails = getTypeLocationService().getTypeDetails(governor);
if (memberHoldingTypeDetails != null) {
for (final JavaType type : memberHoldingTypeDetails.getLayerEntities()) {
final String localMidType = domainTypeToServiceMidMap.get(type);
if (localMidType != null) {
return localMidType;
}
}
}
return null;
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class PushInOperationsImpl method pushInMethod.
/**
* Makes push-in of a method defined on a provided class
*
* @param klass
* class to make the push-in operation
* @param weiteOnDisk
* indicates if pushed elements should be writed on .java file
*
* @return list of objects with all the pushed elements.
*/
public List<Object> pushInMethod(JavaType klass, MethodMetadata method, boolean writeOnDisk) {
List<Object> pushedElements = new ArrayList<Object>();
// Check if current klass exists
Validate.notNull(klass, "ERROR: You must specify a valid class to continue with push-in action");
// Getting class details
ClassOrInterfaceTypeDetails classDetails = getTypeLocationService().getTypeDetails(klass);
Validate.notNull(klass, "ERROR: You must specify a valid class to continue with push-in action");
Validate.notNull(method, "ERROR: You must provide a valid method");
// Getting member details
MemberDetails memberDetails = getMemberDetailsScanner().getMemberDetails(getClass().getName(), classDetails);
// Check if the provided class is a test to be able to select valid
// class path
Path path = classDetails.getAnnotation(RooJavaType.ROO_JPA_UNIT_TEST) == null ? Path.SRC_MAIN_JAVA : Path.SRC_TEST_JAVA;
// Getting current class .java file metadata ID
final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(klass, getPathResolver().getPath(klass.getModule(), path));
// Getting detailsBuilder
ClassOrInterfaceTypeDetailsBuilder detailsBuilder = new ClassOrInterfaceTypeDetailsBuilder(classDetails);
// Avoid AspectJ error when push-in from *RepositoryImpl classes
AnnotationMetadata rooRepositoryCustomImplAnnotation = classDetails.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA_CUSTOM_IMPL);
JavaType relatedRepositoryCustom = null;
if (rooRepositoryCustomImplAnnotation != null) {
AnnotationAttributeValue<Object> attribute = rooRepositoryCustomImplAnnotation.getAttribute("repository");
Validate.notNull(attribute, "Unable to find 'repository' attribute of @RooJpaRepositoryCustomImpl on '%s'", classDetails.getType().getSimpleTypeName());
relatedRepositoryCustom = (JavaType) attribute.getValue();
}
// Getting all details
for (final MemberHoldingTypeDetails memberHoldingTypeDetails : memberDetails.getDetails()) {
// Avoid AspectJ error when push-in from *RepositoryImpl classes
if (rooRepositoryCustomImplAnnotation != null && memberHoldingTypeDetails.getImplementsTypes().contains(relatedRepositoryCustom)) {
detailsBuilder.addImplementsType(relatedRepositoryCustom);
pushedElements.add(relatedRepositoryCustom);
}
// this .java file
if (!memberHoldingTypeDetails.getType().equals(classDetails.getType())) {
continue;
}
// Getting all declared methods (including declared on ITDs
// and .java files)
List<MethodMetadata> allDeclaredMethods = memberHoldingTypeDetails.getMethods();
// Checking if is necessary to make push-in for all declared methods
for (MethodMetadata declaredMethod : allDeclaredMethods) {
// If method exists on .aj file, add it!
if (!method.getDeclaredByMetadataId().equals(declaredByMetadataId) && declaredMethod.equals(method)) {
// Add method to .java file
MethodMetadata newMethod = getNewMethod(declaredByMetadataId, method);
detailsBuilder.addMethod(newMethod);
// Save changes to be pushed
pushedElements.add(newMethod);
}
}
// Getting all imports registered on .aj file to move to .java file
Set<ImportMetadata> allRegisteredImports = memberHoldingTypeDetails.getImports();
detailsBuilder.addImports(allRegisteredImports);
// Save imports to be pushed only if some method has been pushed
if (!pushedElements.isEmpty()) {
pushedElements.addAll(allRegisteredImports);
}
}
// Updating .java file if write on disdk
if (writeOnDisk) {
getTypeManagementService().createOrUpdateTypeOnDisk(detailsBuilder.build());
}
return pushedElements;
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class ServiceMetadataProviderImpl method getLocalMidToRequest.
@Override
protected String getLocalMidToRequest(final ItdTypeDetails itdTypeDetails) {
// Determine the governor for this ITD, and whether any metadata is even
// hoping to hear about changes to that JavaType and its ITDs
final JavaType governor = itdTypeDetails.getName();
final String localMid = domainTypeToServiceMidMap.get(governor);
if (localMid != null) {
return localMid;
}
final MemberHoldingTypeDetails memberHoldingTypeDetails = getTypeLocationService().getTypeDetails(governor);
if (memberHoldingTypeDetails != null) {
for (final JavaType type : memberHoldingTypeDetails.getLayerEntities()) {
final String localMidType = domainTypeToServiceMidMap.get(type);
if (localMidType != null) {
return localMidType;
}
}
}
return null;
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class ThymeleafMainControllerMetadataProviderImpl method getLocalMidToRequest.
@Override
protected String getLocalMidToRequest(final ItdTypeDetails itdTypeDetails) {
// Determine the governor for this ITD, and whether any metadata is even
// hoping to hear about changes to that JavaType and its ITDs
final JavaType governor = itdTypeDetails.getName();
final String localMid = domainTypeToServiceMidMap.get(governor);
if (localMid != null) {
return localMid;
}
final MemberHoldingTypeDetails memberHoldingTypeDetails = getTypeLocationService().getTypeDetails(governor);
if (memberHoldingTypeDetails != null) {
for (final JavaType type : memberHoldingTypeDetails.getLayerEntities()) {
final String localMidType = domainTypeToServiceMidMap.get(type);
if (localMidType != null) {
return localMidType;
}
}
}
return null;
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class ThymeleafUIConfigurationMetadataProviderImpl method getLocalMidToRequest.
@Override
protected String getLocalMidToRequest(final ItdTypeDetails itdTypeDetails) {
// Determine the governor for this ITD, and whether any metadata is even
// hoping to hear about changes to that JavaType and its ITDs
final JavaType governor = itdTypeDetails.getName();
final String localMid = domainTypeToServiceMidMap.get(governor);
if (localMid != null) {
return localMid;
}
final MemberHoldingTypeDetails memberHoldingTypeDetails = getTypeLocationService().getTypeDetails(governor);
if (memberHoldingTypeDetails != null) {
for (final JavaType type : memberHoldingTypeDetails.getLayerEntities()) {
final String localMidType = domainTypeToServiceMidMap.get(type);
if (localMidType != null) {
return localMidType;
}
}
}
return null;
}
Aggregations