Search in sources :

Example 51 with LogicalPath

use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.

the class IdentifierMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.

@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
    final JavaType javaType = IdentifierMetadata.getJavaType(metadataIdentificationString);
    final LogicalPath path = IdentifierMetadata.getPath(metadataIdentificationString);
    return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) LogicalPath(org.springframework.roo.project.LogicalPath)

Example 52 with LogicalPath

use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.

the class IdentifierMetadataProviderImpl method getMetadata.

@Override
protected ItdTypeDetailsProvidingMetadataItem getMetadata(final String metadataIdentificationString, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String itdFilename) {
    if (projectOperations == null) {
        projectOperations = getProjectOperations();
    }
    Validate.notNull(projectOperations, "ProjectOperations is required");
    final IdentifierAnnotationValues annotationValues = new IdentifierAnnotationValues(governorPhysicalTypeMetadata);
    if (!annotationValues.isAnnotationFound()) {
        return null;
    }
    // We know governor type details are non-null and can be safely cast
    final JavaType javaType = IdentifierMetadata.getJavaType(metadataIdentificationString);
    final List<Identifier> identifierServiceResult = getIdentifiersForType(javaType);
    final LogicalPath path = PhysicalTypeIdentifierNamingUtils.getPath(metadataIdentificationString);
    if (projectOperations.isProjectAvailable(path.getModule())) {
        // If the project itself changes, we want a chance to refresh this
        // item
        getMetadataDependencyRegistry().registerDependency(ProjectMetadata.getProjectIdentifier(path.getModule()), metadataIdentificationString);
    }
    return new IdentifierMetadata(metadataIdentificationString, aspectName, governorPhysicalTypeMetadata, annotationValues, identifierServiceResult);
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) PhysicalTypeIdentifier(org.springframework.roo.classpath.PhysicalTypeIdentifier) LogicalPath(org.springframework.roo.project.LogicalPath)

Example 53 with LogicalPath

use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.

the class JpaUnitTestMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.

@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
    final JavaType javaType = JpaUnitTestMetadata.getJavaType(metadataIdentificationString);
    final LogicalPath path = JpaUnitTestMetadata.getPath(metadataIdentificationString);
    return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
Also used : JavaType(org.springframework.roo.model.JavaType) RooJavaType(org.springframework.roo.model.RooJavaType) LogicalPath(org.springframework.roo.project.LogicalPath)

Example 54 with LogicalPath

use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.

the class SecurityFiltersMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.

@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
    final JavaType javaType = SecurityFiltersMetadata.getJavaType(metadataIdentificationString);
    final LogicalPath path = SecurityFiltersMetadata.getPath(metadataIdentificationString);
    return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
Also used : AnnotatedJavaType(org.springframework.roo.classpath.details.annotations.AnnotatedJavaType) RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) LogicalPath(org.springframework.roo.project.LogicalPath)

Example 55 with LogicalPath

use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.

the class ExceptionsOperationsImpl method addExceptionLabel.

/**
 * Writes a label with a default exception message on messages.properties files
 *
 * @param exception
 * @param moduleName
 */
private void addExceptionLabel(JavaType exception, String moduleName) {
    if (getProjectOperations().isMultimoduleProject()) {
        Validate.notBlank(moduleName, "Module name is required");
    }
    final LogicalPath resourcesPath = LogicalPath.getInstance(Path.SRC_MAIN_RESOURCES, moduleName);
    final String targetDirectory = getPathResolver().getIdentifier(resourcesPath, "");
    final String exceptionName = exception.getSimpleTypeName();
    final String labelKey = LABEL_PREFIX.concat(exceptionName.toLowerCase());
    Set<I18n> supportedLanguages = getI18nSupport().getSupportedLanguages();
    for (I18n i18n : supportedLanguages) {
        String messageBundle = String.format("messages_%s.properties", i18n.getLocale().getLanguage());
        String bundlePath = String.format("%s%s%s", targetDirectory, AntPathMatcher.DEFAULT_PATH_SEPARATOR, messageBundle);
        if (getFileManager().exists(bundlePath)) {
            getPropFilesManager().addPropertyIfNotExists(resourcesPath, messageBundle, labelKey, String.format(LABEL_MESSAGE, exceptionName), true);
        }
    }
    // Always update english message bundles
    getPropFilesManager().addPropertyIfNotExists(resourcesPath, "messages.properties", labelKey, String.format(LABEL_MESSAGE, exceptionName), true);
}
Also used : LogicalPath(org.springframework.roo.project.LogicalPath) I18n(org.springframework.roo.addon.web.mvc.i18n.components.I18n)

Aggregations

LogicalPath (org.springframework.roo.project.LogicalPath)85 JavaType (org.springframework.roo.model.JavaType)62 RooJavaType (org.springframework.roo.model.RooJavaType)55 ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)13 JpaJavaType (org.springframework.roo.model.JpaJavaType)12 ClassOrInterfaceTypeDetailsBuilder (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder)10 AnnotatedJavaType (org.springframework.roo.classpath.details.annotations.AnnotatedJavaType)9 AnnotationMetadataBuilder (org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder)9 SpringJavaType (org.springframework.roo.model.SpringJavaType)9 ArrayList (java.util.ArrayList)8 InputStream (java.io.InputStream)7 AnnotationMetadata (org.springframework.roo.classpath.details.annotations.AnnotationMetadata)6 MemberDetails (org.springframework.roo.classpath.scanner.MemberDetails)5 BufferedInputStream (java.io.BufferedInputStream)4 IOException (java.io.IOException)4 OutputStream (java.io.OutputStream)4 ZipInputStream (java.util.zip.ZipInputStream)4 I18n (org.springframework.roo.addon.web.mvc.i18n.components.I18n)4 FieldMetadata (org.springframework.roo.classpath.details.FieldMetadata)3 JavaSymbolName (org.springframework.roo.model.JavaSymbolName)3