use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class ThymeleafMVCViewResponseService method addMainController.
/**
* This method add new MainController.java class annotated
* with @RooThymeleafMainController
*
* This controller will be used to return index page.
*
* @param module
*/
private void addMainController(Pom module) {
// Check if already exists other main controller annotated with @RooThymeleafMainController
if (getMainController() != null) {
return;
}
// If not, define new JavaType
JavaType mainController = new JavaType(String.format("%s.web.MainController", getProjectOperations().getTopLevelPackage(module.getModuleName())), module.getModuleName());
// Check that new JavaType doesn't exists
ClassOrInterfaceTypeDetails mainControllerDetails = getTypeLocationService().getTypeDetails(mainController);
if (mainControllerDetails != null) {
AnnotationMetadata mainControllerThymeleafAnnotation = mainControllerDetails.getAnnotation(getMainControllerAnnotation());
// Maybe, this controller already exists
if (mainControllerThymeleafAnnotation != null) {
return;
} else {
throw new RuntimeException("ERROR: You are trying to generate more than one MainController.");
}
}
ClassOrInterfaceTypeDetailsBuilder cidBuilder = null;
final LogicalPath controllerPath = getPathResolver().getPath(mainController.getModule(), Path.SRC_MAIN_JAVA);
final String resourceIdentifier = getTypeLocationService().getPhysicalTypeCanonicalPath(mainController, controllerPath);
final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(mainController, getPathResolver().getPath(resourceIdentifier));
List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
annotations.add(new AnnotationMetadataBuilder(getMainControllerAnnotation()));
cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, Modifier.PUBLIC, mainController, PhysicalTypeCategory.CLASS);
cidBuilder.setAnnotations(annotations);
getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class ThymeleafMVCViewResponseService method copyStaticResources.
/**
* This method copy and generate all necessary resources to be able
* to use THYMELEAF.
*
* @param module
*/
private void copyStaticResources(Pom module) {
LogicalPath resourcesPath = LogicalPath.getInstance(Path.SRC_MAIN_RESOURCES, module.getModuleName());
// copy all necessary styles inside SRC_MAIN_RESOURCES/static/public/css
copyDirectoryContents("static/css/*.css", getPathResolver().getIdentifier(resourcesPath, "/static/public/css"), true);
// copy all necessary fonts inside SRC_MAIN_RESOURCES/static/public/fonts
copyDirectoryContents("static/fonts/*.eot", getPathResolver().getIdentifier(resourcesPath, "/static/public/fonts"), true);
copyDirectoryContents("static/fonts/*.svg", getPathResolver().getIdentifier(resourcesPath, "/static/public/fonts"), true);
copyDirectoryContents("static/fonts/*.ttf", getPathResolver().getIdentifier(resourcesPath, "/static/public/fonts"), true);
copyDirectoryContents("static/fonts/*.woff", getPathResolver().getIdentifier(resourcesPath, "/static/public/fonts"), true);
copyDirectoryContents("static/fonts/*.woff2", getPathResolver().getIdentifier(resourcesPath, "/static/public/fonts"), true);
// copy all necessary images inside SRC_MAIN_RESOURCES/static/public/img
copyDirectoryContents("static/img/*.ico", getPathResolver().getIdentifier(resourcesPath, "/static/public/img"), false);
copyDirectoryContents("static/img/*.jpg", getPathResolver().getIdentifier(resourcesPath, "/static/public/img"), false);
copyDirectoryContents("static/img/*.png", getPathResolver().getIdentifier(resourcesPath, "/static/public/img"), false);
copyDirectoryContents("static/img/*.gif", getPathResolver().getIdentifier(resourcesPath, "/static/public/img"), false);
// copy all necessary scripts inside SRC_MAIN_RESOURCES/static/public/js
copyDirectoryContents("static/js/*.js", getPathResolver().getIdentifier(resourcesPath, "/static/public/js"), true);
// copy all necessary scripts inside SRC_MAIN_RESOURCES/templates/fragments/js
copyDirectoryContents("templates/fragments/js/*.html", getPathResolver().getIdentifier(resourcesPath, "/templates/fragments/js"), true);
copyDirectoryContents("templates/fragments/js/*.js", getPathResolver().getIdentifier(resourcesPath, "/templates/fragments/js"), true);
// copy default JasperReports template
copyDirectoryContents("templates/reports/*.jrxml", getPathResolver().getIdentifier(resourcesPath, "/templates/reports"), true);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class ThymeleafControllerIntegrationTestMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.
@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
final JavaType javaType = ThymeleafControllerIntegrationTestMetadata.getJavaType(metadataIdentificationString);
final LogicalPath path = ThymeleafControllerIntegrationTestMetadata.getPath(metadataIdentificationString);
return PhysicalTypeIdentifier.createIdentifier(javaType, path);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class I18nOperationsImpl method addOrUpdateLabels.
/**
* Add labels to all installed languages
*
* @param moduleName
* @param labels
*/
@Override
public void addOrUpdateLabels(String moduleName, final Map<String, String> labels) {
final LogicalPath resourcesPath = LogicalPath.getInstance(Path.SRC_MAIN_RESOURCES, moduleName);
final String targetDirectory = getPathResolver().getIdentifier(resourcesPath, "");
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)) {
// Adding labels if not exists already
getPropFilesManager().addPropertiesIfNotExists(resourcesPath, messageBundle, labels, true, false);
}
}
// Allways update english message bundles if label not exists already
getPropFilesManager().addPropertiesIfNotExists(resourcesPath, "messages.properties", labels, true, false);
}
use of org.springframework.roo.project.LogicalPath in project spring-roo by spring-projects.
the class PhysicalTypeIdentifierNamingUtilsTest method testGetLogicalPathFromMetadataInstanceId.
@Test
public void testGetLogicalPathFromMetadataInstanceId() {
// Invoke
final LogicalPath logicalPath = PhysicalTypeIdentifierNamingUtils.getPath(METADATA_INSTANCE_ID);
// Check
assertEquals(LogicalPath.getInstance(PATH, MODULE), logicalPath);
}
Aggregations