Search in sources :

Example 31 with Pom

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

the class ApplicationModuleFeature method getModules.

@Override
public List<Pom> getModules() {
    List<Pom> modules = new ArrayList<Pom>();
    Pom module;
    for (String moduleName : getModuleNames()) {
        module = getProjectOperations().getPomFromModuleName(moduleName);
        if (module == null) {
            throw new NullPointerException(String.format("ERROR: Pom not found for module %s", moduleName));
        }
        modules.add(module);
    }
    return modules;
}
Also used : ArrayList(java.util.ArrayList) Pom(org.springframework.roo.project.maven.Pom)

Example 32 with Pom

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

the class TypeLocationServiceImpl method getPhysicalTypeCanonicalPath.

public String getPhysicalTypeCanonicalPath(final String physicalTypeId) {
    final LogicalPath logicalPath = PhysicalTypeIdentifier.getPath(physicalTypeId);
    final JavaType javaType = PhysicalTypeIdentifier.getJavaType(physicalTypeId);
    final Pom pom = getProjectOperations().getPomFromModuleName(logicalPath.getModule());
    final String canonicalFilePath = pom.getPathLocation(logicalPath.getPath()) + javaType.getRelativeFileName();
    if (getFileManager().exists(canonicalFilePath)) {
        getTypeCache().cacheTypeAgainstModule(pom, javaType);
        getTypeCache().cacheFilePathAgainstTypeIdentifier(canonicalFilePath, physicalTypeId);
    }
    return canonicalFilePath;
}
Also used : JavaType(org.springframework.roo.model.JavaType) LogicalPath(org.springframework.roo.project.LogicalPath) Pom(org.springframework.roo.project.maven.Pom)

Example 33 with Pom

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

the class TypeLocationServiceImpl method getPhysicalPath.

private PhysicalPath getPhysicalPath(final JavaType javaType) {
    Validate.notNull(javaType, "Java type required");
    final String parentPath = getParentPath(javaType);
    if (parentPath == null) {
        return null;
    }
    for (final Pom pom : getProjectOperations().getPoms()) {
        for (final PhysicalPath physicalPath : pom.getPhysicalPaths()) {
            if (physicalPath.isSource()) {
                final String pathLocation = FileUtils.ensureTrailingSeparator(physicalPath.getLocationPath());
                if (pathLocation.startsWith(parentPath)) {
                    getTypeCache().cacheTypeAgainstModule(pom, javaType);
                    return physicalPath;
                }
            }
        }
    }
    return null;
}
Also used : PhysicalPath(org.springframework.roo.project.PhysicalPath) Pom(org.springframework.roo.project.maven.Pom)

Example 34 with Pom

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

the class ViewCommands method getControllerMVCResponseTypes.

/**
 * This method gets all implementations of ControllerMVCResponseService interface to be able
 * to locate all ControllerMVCResponseService. Uses param installed to obtain only the installed
 * or not installed response types.
 *
 * @param installed indicates if returned responseType should be installed or not.
 *
 * @return Map with responseTypes identifier and the ControllerMVCResponseService implementation
 */
public Map<String, ControllerMVCResponseService> getControllerMVCResponseTypes(boolean installed) {
    Map<String, ControllerMVCResponseService> responseTypes = new HashMap<String, ControllerMVCResponseService>();
    try {
        ServiceReference<?>[] references = this.context.getAllServiceReferences(ControllerMVCResponseService.class.getName(), null);
        for (ServiceReference<?> ref : references) {
            ControllerMVCResponseService responseTypeService = (ControllerMVCResponseService) this.context.getService(ref);
            boolean isAbleToInstall = false;
            for (Pom module : getProjectOperations().getPoms()) {
                if (responseTypeService.isInstalledInModule(module.getModuleName()) == installed) {
                    isAbleToInstall = true;
                    break;
                }
            }
            if (isAbleToInstall) {
                responseTypes.put(responseTypeService.getResponseType(), responseTypeService);
            }
        }
        return responseTypes;
    } catch (InvalidSyntaxException e) {
        LOGGER.warning("Cannot load ControllerMVCResponseService on ViewCommands.");
        return null;
    }
}
Also used : ControllerMVCResponseService(org.springframework.roo.addon.web.mvc.controller.addon.responses.ControllerMVCResponseService) HashMap(java.util.HashMap) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) ServiceReference(org.osgi.framework.ServiceReference) Pom(org.springframework.roo.project.maven.Pom)

Example 35 with Pom

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

the class ControllerOperationsImpl method isSetupAvailable.

/**
 * This operation will check if setup operation is available
 *
 * @return true if setup operation is available. false if not.
 */
@Override
public boolean isSetupAvailable() {
    Collection<Pom> applicationModules = getTypeLocationService().getModules(ModuleFeatureName.APPLICATION);
    boolean notInstalledInSomeModule = false;
    for (Pom module : applicationModules) {
        if (!isInstalledInModule(module.getModuleName())) {
            notInstalledInSomeModule = true;
            break;
        }
    }
    return getProjectOperations().isFocusedProjectAvailable() && notInstalledInSomeModule;
}
Also used : Pom(org.springframework.roo.project.maven.Pom)

Aggregations

Pom (org.springframework.roo.project.maven.Pom)86 Element (org.w3c.dom.Element)19 JavaType (org.springframework.roo.model.JavaType)16 Document (org.w3c.dom.Document)16 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)9 ClassOrInterfaceTypeDetailsBuilder (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder)9 AnnotationMetadataBuilder (org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder)9 Dependency (org.springframework.roo.project.Dependency)9 RooJavaType (org.springframework.roo.model.RooJavaType)7 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)5 ServiceReference (org.osgi.framework.ServiceReference)5 ControllerMVCResponseService (org.springframework.roo.addon.web.mvc.controller.addon.responses.ControllerMVCResponseService)5 JavaPackage (org.springframework.roo.model.JavaPackage)5 List (java.util.List)4 Plugin (org.springframework.roo.project.Plugin)4 Completion (org.springframework.roo.shell.Completion)4 HashMap (java.util.HashMap)3 DataOnDemandCreatorProvider (org.springframework.roo.addon.test.providers.DataOnDemandCreatorProvider)3