Search in sources :

Example 36 with LogicalPath

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

the class CreatorOperationsImpl method writeAssemblyFile.

private void writeAssemblyFile(JavaPackage topLevelPackage, String templateName, String destinationFolder) {
    final InputStream templateInputStream = FileUtils.getInputStream(getClass(), "xml/" + templateName);
    final Document assemblyDoc = XmlUtils.readXml(templateInputStream);
    final Element root = assemblyDoc.getDocumentElement();
    String projectFolder = topLevelPackage.getFullyQualifiedPackageName().replaceAll("\\.", "/");
    XmlUtils.findRequiredElement("/assembly/moduleSets/moduleSet/binaries/outputDirectory", root).setTextContent(projectFolder + "/${module.artifactId}/${module.version}");
    // Add includes
    Element includes = XmlUtils.findFirstElement("moduleSets/moduleSet/includes", root);
    if (includes != null) {
        // Adding addon-advanced include
        Element includeAdvancedElement = assemblyDoc.createElement("include");
        includeAdvancedElement.setTextContent(topLevelPackage.getFullyQualifiedPackageName() + ":" + topLevelPackage.getFullyQualifiedPackageName() + ".addon-advanced");
        // Adding addon-simple include
        Element includeSimpleElement = assemblyDoc.createElement("include");
        includeSimpleElement.setTextContent(topLevelPackage.getFullyQualifiedPackageName() + ":" + topLevelPackage.getFullyQualifiedPackageName() + ".addon-simple");
        // Adding roo-addon-suite include
        Element includeSuiteElement = assemblyDoc.createElement("include");
        includeSuiteElement.setTextContent(topLevelPackage.getFullyQualifiedPackageName() + ":" + topLevelPackage.getFullyQualifiedPackageName() + ".roo-addon-suite");
        includes.appendChild(includeAdvancedElement);
        includes.appendChild(includeSimpleElement);
        includes.appendChild(includeSuiteElement);
    }
    LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, "");
    MutableFile assemblyFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, "src/main/assembly/repo-assembly.xml"));
    XmlUtils.writeXml(assemblyFile.getOutputStream(), assemblyDoc);
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ZipInputStream(java.util.zip.ZipInputStream) InputStream(java.io.InputStream) Element(org.w3c.dom.Element) LogicalPath(org.springframework.roo.project.LogicalPath) Document(org.w3c.dom.Document) MutableFile(org.springframework.roo.process.manager.MutableFile)

Example 37 with LogicalPath

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

the class CreatorOperationsImpl method copyFile.

private void copyFile(String fileName, String folder) {
    String file;
    LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, "");
    if (folder != null) {
        file = pathResolver.getIdentifier(rootPath, folder + "/src/main/resources/" + fileName);
    } else {
        file = pathResolver.getIdentifier(rootPath, fileName);
    }
    InputStream inputStream = null;
    OutputStream outputStream = null;
    try {
        inputStream = FileUtils.getInputStream(getClass(), "resources/" + fileName);
        if (!fileManager.exists(file)) {
            outputStream = fileManager.createFile(file).getOutputStream();
        }
        if (outputStream != null) {
            IOUtils.copy(inputStream, outputStream);
        }
    } catch (final IOException ioe) {
        throw new IllegalStateException(ioe);
    } finally {
        IOUtils.closeQuietly(inputStream);
        if (outputStream != null) {
            IOUtils.closeQuietly(outputStream);
        }
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ZipInputStream(java.util.zip.ZipInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) LogicalPath(org.springframework.roo.project.LogicalPath) IOException(java.io.IOException)

Example 38 with LogicalPath

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

the class ConfigurableMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.

@Override
protected String getGovernorPhysicalTypeIdentifier(final String metadataIdentificationString) {
    final JavaType javaType = ConfigurableMetadata.getJavaType(metadataIdentificationString);
    final LogicalPath path = ConfigurableMetadata.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 39 with LogicalPath

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

the class DtoMetadataProviderImpl method getGovernorPhysicalTypeIdentifier.

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

Example 40 with LogicalPath

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

the class AbstractItdMetadataProvider method getIdForPhysicalJavaType.

public final String getIdForPhysicalJavaType(final String physicalJavaTypeIdentifier) {
    Validate.isTrue(MetadataIdentificationUtils.getMetadataClass(physicalJavaTypeIdentifier).equals(MetadataIdentificationUtils.getMetadataClass(PhysicalTypeIdentifier.getMetadataIdentiferType())), "Expected a valid physical Java type instance identifier (not '%s')", physicalJavaTypeIdentifier);
    final JavaType javaType = PhysicalTypeIdentifier.getJavaType(physicalJavaTypeIdentifier);
    final LogicalPath path = PhysicalTypeIdentifier.getPath(physicalJavaTypeIdentifier);
    return createLocalIdentifier(javaType, path);
}
Also used : JavaType(org.springframework.roo.model.JavaType) LogicalPath(org.springframework.roo.project.LogicalPath)

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