use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class ItdDiscoveryServiceImpl method removeItdTypeDetails.
public void removeItdTypeDetails(final String itdTypeDetailsId) {
if (StringUtils.isBlank(itdTypeDetailsId)) {
return;
}
final String type = itdIdToTypeMap.get(itdTypeDetailsId);
if (type != null) {
final Map<String, MemberHoldingTypeDetails> typeDetailsHashMap = typeMap.get(type);
if (typeDetailsHashMap != null) {
typeDetailsHashMap.remove(itdTypeDetailsId);
}
updateChanges(new JavaType(type), true);
}
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class MethodMatcher method matches.
public List<MethodMetadata> matches(final List<MemberHoldingTypeDetails> memberHoldingTypeDetailsList, final Map<String, String> pluralMap) {
final List<FieldMetadata> fields = getFieldsInterestedIn(memberHoldingTypeDetailsList);
final List<MethodMetadata> methods = new ArrayList<MethodMetadata>();
final Set<JavaSymbolName> methodNames = new HashSet<JavaSymbolName>();
final JavaSymbolName userDefinedMethodName = getUserDefinedMethod(memberHoldingTypeDetailsList, pluralMap);
if (userDefinedMethodName == null) {
for (final FieldMetadata field : fields) {
methodNames.add(new JavaSymbolName(getPrefix() + StringUtils.capitalize(field.getFieldName().getSymbolName())));
}
} else {
methodNames.add(new JavaSymbolName(userDefinedMethodName.getSymbolName() + additionalSuffix));
}
for (final MemberHoldingTypeDetails memberHoldingTypeDetails : memberHoldingTypeDetailsList) {
for (final MethodMetadata method : memberHoldingTypeDetails.getDeclaredMethods()) {
if (methodNames.contains(method.getMethodName())) {
methods.add(method);
}
}
}
return methods;
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class MethodMatcher method getMostConcreteClassOrInterfaceTypeDetails.
private ClassOrInterfaceTypeDetails getMostConcreteClassOrInterfaceTypeDetails(final List<MemberHoldingTypeDetails> memberHoldingTypeDetailsList) {
ClassOrInterfaceTypeDetails cid = null;
// by the logic in MemberDetailsScannerImpl
for (final MemberHoldingTypeDetails memberHoldingTypeDetails : memberHoldingTypeDetailsList) {
if (memberHoldingTypeDetails instanceof ClassOrInterfaceTypeDetails) {
cid = (ClassOrInterfaceTypeDetails) memberHoldingTypeDetails;
}
}
Validate.notNull(cid, "No concrete type found; cannot continue");
return cid;
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class PartTree method extractReturnType.
/**
* Extracts the java type of the results to be returned by the PartTree query
*
* @param entityDetails the entity details to extract the object to return by default
* @return
*/
private JavaType extractReturnType(MemberDetails entityDetails) {
Integer maxResults = subject.getMaxResults();
Pair<Stack<FieldMetadata>, String> property = subject.getProperty();
JavaType type = null;
// Count subject returns Long
if (subject.isCountProjection()) {
return JavaType.LONG_OBJECT;
}
if (property != null && property.getLeft() != null) {
// Returns the property type if it is specified
type = property.getLeft().peek().getFieldType();
} else if (providedReturnType != null) {
type = providedReturnType;
} else {
// By default returns entity type
List<MemberHoldingTypeDetails> details = entityDetails.getDetails();
for (MemberHoldingTypeDetails detail : details) {
if (finderAutocomplete != null && finderAutocomplete.getEntityDetails(detail.getType()).equals(entityDetails)) {
type = detail.getType();
break;
} else {
type = detail.getType();
}
}
}
// Check number of results to return.
if (maxResults != null && maxResults == 1) {
// Unique result
return type;
}
// If it is not an unique result, returns a list
if (type.isPrimitive()) {
// Lists cannot return primitive types, so primitive types are transformed into their wrapper class
type = new JavaType(type.getFullyQualifiedTypeName(), type.getArray(), DataType.TYPE, type.getArgName(), type.getParameters(), type.getModule());
}
return new JavaType("org.springframework.data.domain.Page", 0, DataType.TYPE, null, Arrays.asList(type));
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class ServiceImplMetadataProviderImpl 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