@Override public String toString() { final ToStringBuilder builder = new ToStringBuilder(this); builder.append("identifier", getId()); builder.append("valid", valid); builder.append("aspectName", aspectName); builder.append("destinationType", destination); builder.append("governor", governorPhysicalTypeMetadata.getId()); builder.append("itdTypeDetails", itdTypeDetails); return builder.toString(); } }
@Override public void createEmbeddedField(JavaType typeName, JavaType fieldType, JavaSymbolName fieldName, boolean permitReservedWords, List<AnnotationMetadataBuilder> extraAnnotations) { // Check if the requested entity is a JPA @Entity final ClassOrInterfaceTypeDetails javaTypeDetails = typeLocationService.getTypeDetails(typeName); Validate.notNull(javaTypeDetails, "The type specified, '%s', doesn't exist", typeName); final String physicalTypeIdentifier = javaTypeDetails.getDeclaredByMetadataId(); final PhysicalTypeMetadata targetTypeMetadata = (PhysicalTypeMetadata) metadataService.get(physicalTypeIdentifier); Validate .notNull(targetTypeMetadata, "The specified target '--class' does not exist or can not be found. Please create this type first."); final PhysicalTypeDetails targetPtd = targetTypeMetadata.getMemberHoldingTypeDetails(); Validate.isInstanceOf(MemberHoldingTypeDetails.class, targetPtd); final ClassOrInterfaceTypeDetails targetTypeCid = (ClassOrInterfaceTypeDetails) targetPtd; final MemberDetails memberDetails = memberDetailsScanner.getMemberDetails(this.getClass().getName(), targetTypeCid); Validate .isTrue( memberDetails.getAnnotation(ENTITY) != null || memberDetails.getAnnotation(PERSISTENT) != null, "The field embedded command is only applicable to JPA @Entity or Spring Data @Persistent target types."); final EmbeddedField fieldDetails = new EmbeddedField(physicalTypeIdentifier, fieldType, fieldName); if (extraAnnotations != null && !extraAnnotations.isEmpty()) { fieldDetails.addAnnotations(extraAnnotations); } insertField(fieldDetails, permitReservedWords, false); }
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata( final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { // Get application main class Set<JavaType> applicationTypes = getTypeLocationService().findTypesWithAnnotation(SpringJavaType.SPRING_BOOT_APPLICATION); String repositoryConfigurationModuleName = governorPhysicalTypeMetadata.getType().getModule(); JavaType applicationMainType = null; for (JavaType applicationType : applicationTypes) { if (applicationType.getModule().equals(repositoryConfigurationModuleName)) { applicationMainType = applicationType; } } Validate.notNull(applicationMainType, "Unable to find a main application class on module %s", repositoryConfigurationModuleName); // Check if security is installed in module boolean isSpringletsSecurityEnabled = getProjectOperations() .isFeatureInstalled(applicationMainType.getModule(), "SPRINGLETS_JPA"); return new RepositoryJpaConfigurationMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, applicationMainType, isSpringletsSecurityEnabled); }
/** * Returns details of the given physical type's members * * @param physicalTypeMetadata the physical type for which to get the * members (can be <code>null</code>) * @return <code>null</code> if the member details are unavailable */ protected MemberDetails getMemberDetails(final PhysicalTypeMetadata physicalTypeMetadata) { MemberDetailsScanner memberDetailsScanner = getMemberDetailsScanner(); Validate.notNull(memberDetailsScanner, "MemberDetailsScanner is required"); // We need to abort if we couldn't find dependent metadata if (physicalTypeMetadata == null || !physicalTypeMetadata.isValid()) { return null; } final ClassOrInterfaceTypeDetails cid = physicalTypeMetadata.getMemberHoldingTypeDetails(); if (cid == null) { // Abort if the type's class details aren't available (parse error // etc) return null; } return memberDetailsScanner.getMemberDetails(getClass().getName(), cid); }
ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(entity); MemberDetails entityMemberDetails = getMemberDetailsScanner().getMemberDetails(this.getClass().getName(), entityDetails); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( ROO_READ_ONLY_REPOSITORY); .notEmpty( readOnlyRepositories, "ERROR: You should define a ReadOnlyRepository interface annotated with @RooReadOnlyRepository to be able to generate repositories of readOnly entities."); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( ROO_REPOSITORY_JPA_CUSTOM); annotationDefaultReturnType, governorPhysicalTypeMetadata.getType(), RooJavaType.ROO_REPOSITORY_JPA, RooJavaType.ROO_ENTITY_PROJECTION); Validate annotationDefaultReturnType, governorPhysicalTypeMetadata.getType(), RooJavaType.ROO_REPOSITORY_JPA, RooJavaType.ROO_ENTITY_PROJECTION); ClassOrInterfaceTypeDetails cid = governorPhysicalTypeMetadata.getMemberHoldingTypeDetails(); governorPhysicalTypeMetadata.getType().getModule(), parameter); checkDtoFieldsForFinder(formBeanDetails, finder, governorPhysicalTypeMetadata.getType());
governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getAnnotation( RooJavaType.ROO_DOMAIN_MODEL_MODULE); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( RooJavaType.ROO_JSON_MIXIN); entityDetails = getTypeLocationService().getTypeDetails(entity); Validate.notNull(entityDetails, "Can't get details of '%s' defined on '%s.@%s.entity'", entity.getFullyQualifiedTypeName(), mixin.getType(), RooJavaType.ROO_JSON_MIXIN.getSimpleTypeName()); .notNull( entityDetails.getAnnotation(RooJavaType.ROO_JPA_ENTITY), "Class '%s' defined on '%s.@%s.entity' has no @%s annotation. Only JPA entities can set as mixin", entity.getFullyQualifiedTypeName(), mixin.getType(), RooJavaType.ROO_JSON_MIXIN.getSimpleTypeName()); Validate.isTrue(previousMixin == null, "Found two classes annotates with @%s.entity = %s: %s and %s", RooJavaType.ROO_JSON_MIXIN.getSimpleTypeName(), entity.getFullyQualifiedTypeName(),
projectOperations = getProjectOperations(); Validate.notNull(projectOperations, "ProjectOperations is required"); getParentMetadata(governorPhysicalType.getMemberHoldingTypeDetails()); ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(entity); Map<String, FieldMetadata> relationsAsChild = new HashMap<String, FieldMetadata>(); for (FieldMetadata field : entityDetails.getDeclaredFields()) { if (field.getAnnotation(RooJavaType.ROO_JPA_RELATION) != null) { fieldsParent.add(field); List<FieldMetadata> identifierFields = entityDetails.getFieldsWithAnnotation(ID); List<FieldMetadata> embeddedIdentifierFields = entityDetails.getFieldsWithAnnotation(EMBEDDED_ID); Validate.isTrue(!(identifierFields.isEmpty() && embeddedIdentifierFields.isEmpty()), String .format("ERROR: The annotated entity '%s' doesn't contain any identifier field.", entityDetails.getType().getFullyQualifiedTypeName()));
Validate.notNull(fileManager, "FileManager is required"); Validate.notNull(metadataDependencyRegistry, "MetadataDependencyRegistry is required"); Validate.notNull(projectOperations, "ProjectOperations is required"); "Metadata id '%s' is not valid for this metadata provider", metadataIdentificationString); final String canonicalPath = typeLocationService.getPhysicalTypeCanonicalPath(metadataIdentificationString); if (StringUtils.isBlank(canonicalPath)) { return null; final ClassOrInterfaceTypeDetails details = result.getMemberHoldingTypeDetails(); if (details != null && details.getPhysicalTypeCategory() == PhysicalTypeCategory.CLASS && details.getExtendsTypes().size() == 1) { if (details.getSuperclass() != null) { final String superclassId = details.getSuperclass().getDeclaredByMetadataId(); metadataDependencyRegistry.registerDependency(superclassId, result.getId()); } else { final String possibleSuperclass = PhysicalTypeIdentifier.createIdentifier(details.getExtendsTypes().get(0), sourcePath); metadataDependencyRegistry.registerDependency(possibleSuperclass, result.getId());
public void addEnumConstant(final String physicalTypeIdentifier, final JavaSymbolName constantName) { Validate.notBlank(physicalTypeIdentifier, "Type identifier not provided"); Validate.notNull(constantName, "Constant name required"); // Obtain the physical type and itd mutable details final PhysicalTypeMetadata ptm = (PhysicalTypeMetadata) metadataService.get(physicalTypeIdentifier); Validate.notNull(ptm, "Java source code unavailable for type %s", PhysicalTypeIdentifier.getFriendlyName(physicalTypeIdentifier)); final PhysicalTypeDetails ptd = ptm.getMemberHoldingTypeDetails(); Validate.notNull(ptd, "Java source code details unavailable for type %s", PhysicalTypeIdentifier.getFriendlyName(physicalTypeIdentifier)); final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder((ClassOrInterfaceTypeDetails) ptd); // Ensure it's an enum Validate.isTrue(cidBuilder.getPhysicalTypeCategory() == PhysicalTypeCategory.ENUMERATION, "%s is not an enum", PhysicalTypeIdentifier.getFriendlyName(physicalTypeIdentifier)); cidBuilder.addEnumConstant(constantName); createOrUpdateTypeOnDisk(cidBuilder.build()); }
governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getAnnotation( ROO_EXCEPTION_HANDLERS); getTypeLocationService().getTypeDetails(exception); Validate.notNull(exception, "'exception' attribute in @RooExceptionHandler must not be null"); String errorView = getNestedAttributeValue(handlerAnnotation, "errorView"); governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getAnnotation( RooJavaType.ROO_CONTROLLER); boolean isController = rooControllerAnnotation != null; governorPhysicalTypeMetadata.getMemberHoldingTypeDetails()).getFields();
getTypeLocationService().getTypeDetails(jsonController); AnnotationMetadata rooControllerAnnotation = controllerCid.getAnnotation(RooJavaType.ROO_CONTROLLER); if (rooControllerAnnotation == null) { LOGGER.warning(String.format("Ignoring %s of %s as missing %s annotation in %s", ROO_THYMELEAF_CONTROLLER_INTEGRATION_TEST.getSimpleTypeName(), governorPhysicalTypeMetadata.getType().getFullyQualifiedTypeName(), RooJavaType.ROO_CONTROLLER.getSimpleTypeName(), jsonController.getSimpleTypeName())); return null; Validate.notNull(rooControllerAnnotation.getAttribute("entity"), "The @RooController must have an 'entity' attribute, targeting managed entity."); final JavaType managedEntity = JpaEntityMetadata.createIdentifier(getTypeLocationService().getTypeDetails(managedEntity)); JpaEntityMetadata entityMetadata = getMetadataService().get(jpaEntityIdentifier); if (entityMetadata == null) { entity.getSimpleTypeName(), this.getClass().getName())); } else { if (!relatedServices.contains(serviceDetails.getType())) { relatedServices.add(serviceDetails.getType());
ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(entity); JavaType service = serviceDetails.getType(); final String serviceMetadataId = ServiceMetadata.createIdentifier(serviceDetails); registerDependency(serviceMetadataId, metadataIdentificationString); governorPhysicalTypeMetadata.getMemberHoldingTypeDetails()); final String baseUrl = getControllerOperations().getBaseUrlForController( governorPhysicalTypeMetadata.getMemberHoldingTypeDetails()); governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getName(); governorPhysicalTypeMetadata.getMemberHoldingTypeDetails() .getAnnotation(RooJavaType.ROO_DETAIL).getAttribute("relationField"); Validate.notNull(relationFieldAttr, "ERROR: In %s controller, @RooDetail annotation must have relationField value", controller); Validate.isTrue(StringUtils.isNotBlank(detailAnnotaionFieldValue), "ERROR: In %s controller, @RooDetail annotation must have relationField value", controller);
governorPhysicalTypeMetadata.getMemberHoldingTypeDetails(); } else { JavaPackage controllerPackage = controllerDetail.getType().getPackage(); for (ClassOrInterfaceTypeDetails controller : itemControllers) { if (controllerPackage.equals(controller.getType().getPackage())) { itemController = controller.getType(); break; Validate.notNull(itemController, "ERROR: Can't find ITEM-type controller related to controller '%s'", controllerDetail .getType().getFullyQualifiedTypeName()); Validate.notNull(entity, "ERROR: You should provide a valid entity for controller '%s'", controllerDetail.getType().getFullyQualifiedTypeName()); getTypeLocationService().getTypeDetails(entity); Validate.notNull(entityDetails, "ERROR: Can't load details of %s", entity.getFullyQualifiedTypeName()); ClassOrInterfaceTypeDetails serviceDetails = getTypeLocationService().getTypeDetails(service); getTypeLocationService().addModuleDependency( governorPhysicalTypeMetadata.getType().getModule(), parameter);
List<FieldMetadata> toStringFields) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata identification string '%s' does not appear to be a valid", identifier); Validate.notNull(annotationValues, "Annotation values required"); Validate.notNull(declaredFields, "Declared fields required"); this.target = governorPhysicalTypeMetadata.getType(); this.annotationValues = annotationValues; this.declaredFields = declaredFields;
@Override public ClassOrInterfaceTypeDetails build() { Validate.notEmpty(compilationUnit.getTypes(), "No types in compilation unit, so unable to continue parsing"); if (name.getEnclosingType() != null) { sb.append(".").append(name.getEnclosingType().getSimpleTypeName()); Validate.notNull(physicalTypeCategory, "%s (%s for %s)", UNSUPPORTED_MESSAGE_PREFIX, typeDeclaration.getClass().getSimpleName(), name); final String superclassId = typeLocationService.getPhysicalTypeIdentifier(superclass); PhysicalTypeMetadata superPtm = null; if (superclassId != null) { superPtm = (PhysicalTypeMetadata) metadataService.get(superclassId); if (superPtm != null && superPtm.getMemberHoldingTypeDetails() != null) { cidBuilder.setSuperclass(superPtm.getMemberHoldingTypeDetails());
public final MetadataItem get(String metadataIdentificationString) { Validate.isTrue( MetadataIdentificationUtils.getMetadataClass( metadataIdentificationString).equals( || !governorPhysicalTypeMetadata.isValid()) { .getItdCanoncialPath(this); JavaType aspectName = governorPhysicalTypeMetadata.getItdJavaType(this); if (governorPhysicalTypeMetadata.getMemberHoldingTypeDetails() != null && governorPhysicalTypeMetadata.getMemberHoldingTypeDetails() instanceof ClassOrInterfaceTypeDetails) { cid = (ClassOrInterfaceTypeDetails) governorPhysicalTypeMetadata .getMemberHoldingTypeDetails(); && cid.getPhysicalTypeCategory() != PhysicalTypeCategory.CLASS) { produceMetadata = false; governorPhysicalTypeMetadata.getId(), metadataIdentificationString); Validate.notNull(mutableFile, "Could not create ITD file '" + itdFilename + "'");
.notNull( entity, "ERROR: Repository custom interface should be contain an entity on @RooJpaRepositoryCustom annotation"); ClassOrInterfaceTypeDetails cid = governorPhysicalTypeMetadata.getMemberHoldingTypeDetails(); String module = cid.getName().getModule(); getTypeLocationService().addModuleDependency(module, entity); getTypeLocationService().addModuleDependency(module, repositoryMetadata.getDefaultReturnType()); getTypeLocationService().addModuleDependency(module, fieldInfo.getLeft().getFieldType());
final JavaType mixinType = governorPhysicalTypeMetadata.getType(); getTypeLocationService().getTypeDetails(entity); Validate.notNull(entityDetails, "Can't get details of '%s' defined on '%s.@%s.entity'", entity.getFullyQualifiedTypeName(), mixinType, RooJavaType.ROO_JSON_MIXIN.getSimpleTypeName()); .notNull( entityDetails.getAnnotation(RooJavaType.ROO_JPA_ENTITY), "Class '%s' defined on '%s.@%s.entity' has no @%s annotation. Only JPA entities can set as mixin", entity.getFullyQualifiedTypeName(), mixinType, RooJavaType.ROO_JSON_MIXIN.getSimpleTypeName()); getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation( RooJavaType.ROO_DOMAIN_MODEL_MODULE); if (!domainModelModuleDetails.isEmpty()) { JavaType parentEntity = field.getFieldType().withoutParameters(); JavaType entityDeserializer = getEntityDeserializerFor(parentEntity); Validate.notNull(entityDeserializer, "Can't locate class with @%s.entity=%s required for %s entity Json Mixin (%s)", RooJavaType.ROO_DESERIALIZER, parentEntity, entity.getFullyQualifiedTypeName(),
getTypeLocationService().getTypeDetails(serviceInterface); final ServiceMetadata serviceMetadata = getServiceMetadata(metadataIdentificationString, serviceInterfaceDetails); serviceInterfaceDetails.getAnnotation(RooJavaType.ROO_SERVICE); Validate.notNull(serviceAnnotation, "ERROR: Provided service should be annotated with @RooService"); ClassOrInterfaceTypeDetails entityDetails = getTypeLocationService().getTypeDetails(entity); final String entityMetadataId = JpaEntityMetadata.createIdentifier(entityDetails.getType(), PhysicalTypeIdentifier.getPath(entityDetails.getDeclaredByMetadataId())); final JpaEntityMetadata entityMetadata = (JpaEntityMetadata) getMetadataService().get(entityMetadataId); List<JavaType> types = new ArrayList<JavaType>(); types.add(method.getReturnType()); types.addAll(method.getReturnType().getParameters()); types.addAll(AnnotatedJavaType.convertFromAnnotatedJavaType(parameter).getParameters()); getTypeLocationService().addModuleDependency( governorPhysicalTypeMetadata.getType().getModule(), parameter);
public void addField(final FieldMetadata field, boolean evict) { Validate.notNull(field, "Field metadata not provided"); ptm = (PhysicalTypeMetadata) metadataService.get(field.getDeclaredByMetadataId()); Validate.notNull(ptm, "Java source code unavailable for type %s", PhysicalTypeIdentifier.getFriendlyName(field.getDeclaredByMetadataId())); final PhysicalTypeDetails ptd = ptm.getMemberHoldingTypeDetails(); Validate.notNull(ptd, "Java source code details unavailable for type %s", PhysicalTypeIdentifier.getFriendlyName(field.getDeclaredByMetadataId())); final ClassOrInterfaceTypeDetailsBuilder cidBuilder = if (annotation.getAnnotationType().getFullyQualifiedTypeName().startsWith("javax.validation")) { jsr303Required = true; break;