@Override public boolean isEntityProjectionPossible() { return typeLocationService.findTypesWithAnnotation(RooJavaType.ROO_JPA_ENTITY).size() > 0; }
@Override public JavaType getDataOnDemandConfiguration() { Set<JavaType> dodConfigurationTypes = typeLocationService .findTypesWithAnnotation(RooJavaType.ROO_JPA_DATA_ON_DEMAND_CONFIGURATION); if (!dodConfigurationTypes.isEmpty()) { return dodConfigurationTypes.iterator().next(); } return null; }
@Override public JavaType getDataOnDemandConfiguration(String moduleName) { Set<JavaType> dodConfigurationTypes = typeLocationService .findTypesWithAnnotation(RooJavaType.ROO_JPA_DATA_ON_DEMAND_CONFIGURATION); Iterator<JavaType> it = dodConfigurationTypes.iterator(); while (it.hasNext()) { JavaType dodConfigType = it.next(); if (dodConfigType.getModule().equals(moduleName)) { return dodConfigType; } } return null; }
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata(final String dodMetadataId, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { SortedSet<JavaType> dataOnDemandTypes = new TreeSet<JavaType>(); dataOnDemandTypes.addAll(getTypeLocationService().findTypesWithAnnotation( RooJavaType.ROO_JPA_DATA_ON_DEMAND)); return new JpaDataOnDemandConfigurationMetadata(dodMetadataId, aspectName, governorPhysicalTypeMetadata, dataOnDemandTypes); }
@Override public boolean isIntegrationTestCreationAvailable() { Set<JavaType> jsonControllers = typeLocationService.findTypesWithAnnotation(RooJavaType.ROO_JSON); return projectOperations.isFocusedProjectAvailable() && projectOperations.isFeatureInstalled(FeatureNames.MVC) && !jsonControllers.isEmpty(); }
@Override public boolean isIntegrationTestCreationAvailable() { Set<JavaType> thymeleafControllers = typeLocationService.findTypesWithAnnotation(RooJavaType.ROO_THYMELEAF); return projectOperations.isFocusedProjectAvailable() && projectOperations.isFeatureInstalled(FeatureNames.MVC) && !thymeleafControllers.isEmpty(); }
@Override public boolean isIntegrationTestCreationAvailable() { Set<JavaType> repositories = typeLocationService.findTypesWithAnnotation(RooJavaType.ROO_REPOSITORY_JPA); return projectOperations.isFocusedProjectAvailable() && projectOperations.isFeatureInstalled(FeatureNames.JPA) && !repositories.isEmpty(); }
/** * Returns a String with the JavaPackage name to show. It will return a full * name if provided package doesn't contain the module top level JavaPackage. * Otherwise, the package name will be shortened using `~`. * * @param module the String with the module name. * @param javaPackage the JavaPackage to extract the String to return. * @return a String with the value to show for the java package. */ private String getPackageStringValue(String module, String javaPackageName) { // Get project top level package from application class Set<JavaType> applicationTypes = typeLocationService.findTypesWithAnnotation(SpringJavaType.SPRING_BOOT_APPLICATION); Validate.isTrue(!applicationTypes.isEmpty(), "Couldn't find a main class " + "annotated with `@SpringBootApplication` in the project."); String topLevelPackage = projectOperations.getTopLevelPackage(module).getFullyQualifiedPackageName(); // If package name contains top level package name, shorten it if (javaPackageName.contains(topLevelPackage)) { javaPackageName = javaPackageName.replace(topLevelPackage, "~"); } return javaPackageName; }
@CliOptionAutocompleteIndicator(param = "entity", command = "web mvc finder", help = "--entity parameter should be completed with classes annotated with @RooJpaEntity.") public List<String> getEntityValues(ShellContext context) { // Get current value of class String currentText = context.getParameters().get("entity"); // Create results to return List<String> results = new ArrayList<String>(); for (JavaType entity : getTypeLocationService().findTypesWithAnnotation( RooJavaType.ROO_JPA_ENTITY)) { ClassOrInterfaceTypeDetails repository = repositoryJpaLocator.getFirstRepository(entity); if (repository == null) { continue; } AnnotationMetadata repositoryAnnotation = repository.getAnnotation(RooJavaType.ROO_REPOSITORY_JPA); if (repositoryAnnotation.getAttribute("finders") == null) { continue; } String name = replaceTopLevelPackageString(entity, currentText); if (!results.contains(name)) { results.add(name); } } if (results.isEmpty()) { results.add(""); } return results; }
getTypeLocationService().findTypesWithAnnotation(RooJavaType.ROO_READ_ONLY_REPOSITORY);
@Override public boolean isInstalledInModule(String moduleName) { Pom module = getProjectOperations().getPomFromModuleName(moduleName); for (JavaType javaType : getTypeLocationService().findTypesWithAnnotation( RooJavaType.ROO_WEB_MVC_CONFIGURATION)) { if (javaType.getModule().equals(moduleName) && module.hasDependencyExcludingVersion(new Dependency("org.springframework.boot", "spring-boot-starter-web", null))) { return true; } } return 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); }
/** * Creates the Factory class of the child entity of relationship, only if parent entity has JPA unit tests. * * @param childType * @param parentType */ private void createChildEntityFactory(JavaType childType, JavaType parentType) { // Find current JPA unit tests Set<JavaType> unitTestTypes = typeLocationService.findTypesWithAnnotation(RooJavaType.ROO_JPA_UNIT_TEST); for (JavaType unitTestType : unitTestTypes) { // Get the annotation @RooJpaUnitTest ClassOrInterfaceTypeDetails cid = typeLocationService.getTypeDetails(unitTestType); AnnotationMetadata rooUnitTestAnnotation = cid.getAnnotation(RooJavaType.ROO_JPA_UNIT_TEST); // Check if parent entity has JPA unit test class AnnotationAttributeValue<Object> targetClass = rooUnitTestAnnotation.getAttribute("targetClass"); Validate.notNull(targetClass, String.format( "'targetClass' attribute can't be found for annotation @RooJpaUnitTest in class %s", unitTestType.getSimpleTypeName())); if (parentType.equals(targetClass.getValue())) { if (jpaEntityFactoryLocator.getFirstJpaEntityFactoryForEntity(childType) == null) { // Create factory class for child entity if doesn't exist dataOnDemandCreatorProvider.createEntityFactory(childType); } break; } } }
.findTypesWithAnnotation(RooJavaType.ROO_REPOSITORY_JPA_CUSTOM_IMPL);
getTypeLocationService().findTypesWithAnnotation( RooJavaType.ROO_JPA_REPOSITORY_CONFIGURATION); Validate
getTypeLocationService().findTypesWithAnnotation(RooJavaType.ROO_REPOSITORY_JPA); if (!repositoryTypes.isEmpty()) { Iterator<JavaType> repositoryIterator = repositoryTypes.iterator();
@Override public JavaType getDataOnDemandConfiguration() { Set<JavaType> dodConfigurationTypes = typeLocationService .findTypesWithAnnotation(RooJavaType.ROO_JPA_DATA_ON_DEMAND_CONFIGURATION); if (!dodConfigurationTypes.isEmpty()) { return dodConfigurationTypes.iterator().next(); } return null; }
public void annotateAll(final boolean deepSerialize, final boolean iso8601Dates) { for (final JavaType type : typeLocationService .findTypesWithAnnotation(ROO_JAVA_BEAN)) { annotateType(type, "", deepSerialize, iso8601Dates); } }
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata(final String dodMetadataId, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) { SortedSet<JavaType> dataOnDemandTypes = new TreeSet<JavaType>(); dataOnDemandTypes.addAll(getTypeLocationService().findTypesWithAnnotation( RooJavaType.ROO_JPA_DATA_ON_DEMAND)); return new JpaDataOnDemandConfigurationMetadata(dodMetadataId, aspectName, governorPhysicalTypeMetadata, dataOnDemandTypes); }
/** {@inheritDoc} */ public void bindStringTrimmerAll(boolean emptyAsNull) { setup(); // Use the TypeLocationService to scan project for all types with a // specific annotation for (JavaType type : typeLocationService .findTypesWithAnnotation(new JavaType( "org.springframework.stereotype.Controller"))) { addBindStringTrimmer(type, emptyAsNull); } }