Search in sources :

Example 96 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class PluralServiceImpl method getPlural.

@Override
public String getPlural(JavaType type, Locale locale) {
    Validate.notNull(type, "ERROR: You must provide a valid JavaType");
    Validate.notNull(locale, "ERROR: You must provide a valid Locale");
    // Getting ClassOrInterfaceTypeDetails
    ClassOrInterfaceTypeDetails cid = getTypeLocationService().getTypeDetails(type);
    Validate.notNull(cid, "ERROR: You must provide an existing JavaType");
    return getPlural(cid, locale);
}
Also used : ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)

Example 97 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class RepositoryJpaCommands method getEntityPossibleResults.

@CliOptionAutocompleteIndicator(command = "repository jpa", param = "entity", help = "--entity option should be an entity.")
public List<String> getEntityPossibleResults(ShellContext shellContext) {
    // Get current value of class
    String currentText = shellContext.getParameters().get("entity");
    List<String> allPossibleValues = new ArrayList<String>();
    // Getting all existing entities
    Set<ClassOrInterfaceTypeDetails> entitiesInProject = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_JPA_ENTITY);
    for (ClassOrInterfaceTypeDetails entity : entitiesInProject) {
        String name = replaceTopLevelPackageString(entity, currentText);
        if (!allPossibleValues.contains(name)) {
            allPossibleValues.add(name);
        }
    }
    return allPossibleValues;
}
Also used : ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 98 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class RepositoryJpaCommands method getAssociatedProjectionResults.

/**
 * This indicator return all Projection classes associated to an entity specified
 * in the 'entity' parameter.
 *
 * @param shellContext the Roo ShellContext.
 * @return List<String> with fullyQualifiedNames of each associated Projection.
 */
@CliOptionAutocompleteIndicator(command = "repository jpa", param = "defaultReturnType", help = "--defaultReturnType option should be a Projection class associated to the entity specified in --entity.")
public List<String> getAssociatedProjectionResults(ShellContext shellContext) {
    List<String> allPossibleValues = new ArrayList<String>();
    // Get current value of 'defaultReturnType'
    String currentText = shellContext.getParameters().get("defaultReturnType");
    // Get current value of 'entity'
    JavaType entity = getTypeFromEntityParam(shellContext);
    Set<ClassOrInterfaceTypeDetails> projectionsInProject = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_ENTITY_PROJECTION);
    for (ClassOrInterfaceTypeDetails projection : projectionsInProject) {
        // Add only projections associated to the entity specified in the command
        if (projection.getAnnotation(RooJavaType.ROO_ENTITY_PROJECTION).getAttribute("entity").getValue().equals(entity)) {
            String name = replaceTopLevelPackageString(projection, currentText);
            if (!allPossibleValues.contains(name)) {
                allPossibleValues.add(name);
            }
        }
    }
    return allPossibleValues;
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 99 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class RepositoryJpaCommands method isDefaultReturnTypeParameterVisible.

/**
 * This indicator says if --defaultReturnType parameter should be visible or not.
 *
 * @param context ShellContext
 * @return false if domain entity specified in --entity parameter has no associated Projections.
 */
@CliOptionVisibilityIndicator(params = "defaultReturnType", command = "repository jpa", help = "--defaultReturnType parameter is not visible if domain entity specified in --entity parameter has no associated Projections.")
public boolean isDefaultReturnTypeParameterVisible(ShellContext shellContext) {
    // Get current value of 'entity'
    JavaType entity = getTypeFromEntityParam(shellContext);
    if (entity == null) {
        return false;
    }
    Set<ClassOrInterfaceTypeDetails> projectionsInProject = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_ENTITY_PROJECTION);
    boolean visible = false;
    for (ClassOrInterfaceTypeDetails projection : projectionsInProject) {
        // Add only projections associated to the entity specified in the command
        if (projection.getAnnotation(RooJavaType.ROO_ENTITY_PROJECTION).getAttribute("entity").getValue().equals(entity)) {
            visible = true;
            break;
        }
    }
    return visible;
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionVisibilityIndicator(org.springframework.roo.shell.CliOptionVisibilityIndicator)

Example 100 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class DbreDatabaseListenerImpl method deleteManagedType.

private void deleteManagedType(final ClassOrInterfaceTypeDetails managedEntity, final String reason) {
    if (!isEntityDeletable(managedEntity)) {
        return;
    }
    deleteJavaType(managedEntity.getName(), reason);
    final JavaType identifierType = getIdentifierType(managedEntity.getName());
    for (final ClassOrInterfaceTypeDetails managedIdentifier : getManagedIdentifiers()) {
        if (managedIdentifier.getName().equals(identifierType)) {
            deleteJavaType(identifierType, "managed identifier of deleted type " + managedEntity.getName());
            break;
        }
    }
}
Also used : JdkJavaType(org.springframework.roo.model.JdkJavaType) JavaType(org.springframework.roo.model.JavaType) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)

Aggregations

ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)232 JavaType (org.springframework.roo.model.JavaType)114 ArrayList (java.util.ArrayList)87 RooJavaType (org.springframework.roo.model.RooJavaType)86 AnnotationMetadata (org.springframework.roo.classpath.details.annotations.AnnotationMetadata)52 ClassOrInterfaceTypeDetailsBuilder (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder)43 AnnotationMetadataBuilder (org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder)42 FieldMetadata (org.springframework.roo.classpath.details.FieldMetadata)40 JavaSymbolName (org.springframework.roo.model.JavaSymbolName)39 MemberDetails (org.springframework.roo.classpath.scanner.MemberDetails)36 JpaJavaType (org.springframework.roo.model.JpaJavaType)34 SpringJavaType (org.springframework.roo.model.SpringJavaType)28 CliOptionAutocompleteIndicator (org.springframework.roo.shell.CliOptionAutocompleteIndicator)24 JpaEntityMetadata (org.springframework.roo.addon.jpa.addon.entity.JpaEntityMetadata)23 JdkJavaType (org.springframework.roo.model.JdkJavaType)22 Test (org.junit.Test)20 File (java.io.File)19 List (java.util.List)19 AnnotatedJavaType (org.springframework.roo.classpath.details.annotations.AnnotatedJavaType)19 MethodMetadata (org.springframework.roo.classpath.details.MethodMetadata)17