use of org.springframework.roo.model.JavaType in project spring-roo by spring-projects.
the class JpaOperationsImpl method getFieldChildPartOfCompositionRelation.
@Override
public Pair<FieldMetadata, RelationInfo> getFieldChildPartOfCompositionRelation(ClassOrInterfaceTypeDetails entityCdi) {
JavaType domainType = entityCdi.getType();
List<Pair<FieldMetadata, RelationInfo>> relations = getFieldChildPartOfRelation(entityCdi);
if (relations.isEmpty()) {
return null;
}
JpaEntityMetadata parent;
JavaType parentType;
RelationInfo info;
List<Pair<FieldMetadata, RelationInfo>> compositionRelation = new ArrayList<Pair<FieldMetadata, RelationInfo>>();
for (Pair<FieldMetadata, RelationInfo> field : relations) {
if (field.getRight().type == JpaRelationType.COMPOSITION) {
compositionRelation.add(field);
}
}
Validate.isTrue(compositionRelation.size() <= 1, "Entity %s has more than one relations of composition as child part: ", domainType, StringUtils.join(getFieldNamesOfRelationList(compositionRelation), ","));
if (compositionRelation.isEmpty()) {
return null;
}
return compositionRelation.get(0);
}
use of org.springframework.roo.model.JavaType in project spring-roo by spring-projects.
the class JpaOperationsImpl method updateEmbeddableToIdentifier.
@Override
public void updateEmbeddableToIdentifier(final JavaType identifierType, final String identifierField, final String identifierColumn) {
Validate.notNull(identifierType, "Identifier type required");
// Get details from existing JavaType
ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(getTypeLocationService().getTypeDetails(identifierType));
// Create @RooIdentifier with getters and setters
AnnotationMetadataBuilder rooIdentifier = new AnnotationMetadataBuilder(ROO_IDENTIFIER);
rooIdentifier.addBooleanAttribute("settersByDefault", true);
final List<AnnotationMetadataBuilder> identifierAnnotations = Arrays.asList(new AnnotationMetadataBuilder(ROO_TO_STRING), new AnnotationMetadataBuilder(ROO_EQUALS), rooIdentifier);
cidBuilder.setAnnotations(identifierAnnotations);
// Set implement Serializable
List<JavaType> implementTypes = new ArrayList<JavaType>();
implementTypes.add(JdkJavaType.SERIALIZABLE);
cidBuilder.setImplementsTypes(implementTypes);
getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
}
use of org.springframework.roo.model.JavaType in project spring-roo by spring-projects.
the class EntityProjectionMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = EntityProjectionMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = EntityProjectionMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
use of org.springframework.roo.model.JavaType in project spring-roo by spring-projects.
the class EqualsMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = EqualsMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = EqualsMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
use of org.springframework.roo.model.JavaType in project spring-roo by spring-projects.
the class EqualsMetadataProviderImpl method getMetadata.
@Override
protected ItdTypeDetailsProvidingMetadataItem getMetadata(final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) {
final EqualsAnnotationValues annotationValues = new EqualsAnnotationValues(governorPhysicalTypeMetadata);
if (!annotationValues.isAnnotationFound()) {
return null;
}
final MemberDetails memberDetails = getMemberDetails(governorPhysicalTypeMetadata);
if (memberDetails == null) {
return null;
}
AnnotationMetadata javaBeanAnnotation = memberDetails.getAnnotation(ROO_JAVA_BEAN);
if (javaBeanAnnotation != null) {
// Return an empty metadata as @RooJavaBean do the work
return new EqualsMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, new ArrayList<FieldMetadata>(), null, true);
}
final JavaType javaType = governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getName();
final List<FieldMetadata> equalityFields = locateFields(javaType, annotationValues.getExcludeFields(), memberDetails.getFields(), metadataIdentificationString);
FieldMetadata identifierField = getIdentifier(governorPhysicalTypeMetadata);
return new EqualsMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, equalityFields, identifierField, false);
}
Aggregations