use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class MemberDetailsBuilder method tag.
public <T> void tag(final T toModify, final CustomDataKey<T> key, final Object value) {
if (toModify instanceof FieldMetadata) {
final CustomDataBuilder customDataBuilder = new CustomDataBuilder();
customDataBuilder.put(key, value);
doModification((FieldMetadata) toModify, customDataBuilder.build());
} else if (toModify instanceof MethodMetadata) {
final CustomDataBuilder customDataBuilder = new CustomDataBuilder();
customDataBuilder.put(key, value);
doModification((MethodMetadata) toModify, customDataBuilder.build());
} else if (toModify instanceof ConstructorMetadata) {
final CustomDataBuilder customDataBuilder = new CustomDataBuilder();
customDataBuilder.put(key, value);
doModification((ConstructorMetadata) toModify, customDataBuilder.build());
} else if (toModify instanceof MemberHoldingTypeDetails) {
final CustomDataBuilder customDataBuilder = new CustomDataBuilder();
customDataBuilder.put(key, value);
doModification((MemberHoldingTypeDetails) toModify, customDataBuilder.build());
}
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class MemberDetailsBuilder method doModification.
private void doModification(final FieldMetadata field, final CustomData customData) {
final MemberHoldingTypeDetails memberHoldingTypeDetails = memberHoldingTypeDetailsMap.get(field.getDeclaredByMetadataId());
if (memberHoldingTypeDetails != null) {
final FieldMetadata matchedField = memberHoldingTypeDetails.getField(field.getFieldName());
if (matchedField != null && !matchedField.getCustomData().keySet().containsAll(customData.keySet())) {
final TypeDetailsBuilder typeDetailsBuilder = getTypeDetailsBuilder(memberHoldingTypeDetails);
typeDetailsBuilder.addDataToField(field, customData);
changed = true;
}
}
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class JpaEntityFactoryMetadataProviderImpl method getMetadata.
@Override
protected ItdTypeDetailsProvidingMetadataItem getMetadata(final String entityFactoryMetadata, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) {
// Get related entity
final JavaType entity = (JavaType) governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getAnnotation(ROO_JPA_ENTITY_FACTORY).getAttribute("entity").getValue();
if (entity == null) {
return null;
}
final MemberDetails memberDetails = getMemberDetails(entity);
if (memberDetails == null) {
return null;
}
final MemberHoldingTypeDetails persistenceMemberHoldingTypeDetails = MemberFindingUtils.getMostConcreteMemberHoldingTypeDetailsWithTag(memberDetails, PERSISTENT_TYPE);
if (persistenceMemberHoldingTypeDetails == null) {
return null;
}
// We need to be informed if our dependent metadata changes
getMetadataDependencyRegistry().registerDependency(persistenceMemberHoldingTypeDetails.getDeclaredByMetadataId(), entityFactoryMetadata);
final JavaType identifierType = getPersistenceMemberLocator().getIdentifierType(entity);
if (identifierType == null) {
return null;
}
// Identify all the fields we care about on the entity
final Map<FieldMetadata, JpaEntityFactoryMetadata> locatedFields = getLocatedFields(memberDetails, entityFactoryMetadata);
// Get the list of embedded metadata holders - may be an empty list if
// no embedded identifier exists
final List<EmbeddedHolder> embeddedHolders = getEmbeddedHolders(memberDetails, entityFactoryMetadata);
// Get the embedded identifier metadata holder - may be null if no
// embedded identifier exists
final EmbeddedIdHolder embeddedIdHolder = getEmbeddedIdHolder(memberDetails, entityFactoryMetadata);
Set<ClassOrInterfaceTypeDetails> entityFactoryClasses = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_JPA_ENTITY_FACTORY);
return new JpaEntityFactoryMetadata(entityFactoryMetadata, aspectName, governorPhysicalTypeMetadata, entity, locatedFields, embeddedHolders, entityFactoryClasses, embeddedIdHolder);
}
use of org.springframework.roo.classpath.details.MemberHoldingTypeDetails in project spring-roo by spring-projects.
the class SecurityFiltersMetadataProviderImpl 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 EntityDeserializerMetadataProviderImpl 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