Search in sources :

Example 11 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class ExamplesServiceImpl method readDescription.

private String readDescription(final Module module) {
    final Path root = module.getRootPath();
    final POM pom = module.getPom();
    final org.uberfire.java.nio.file.Path nioRoot = Paths.convert(root);
    final org.uberfire.java.nio.file.Path nioDescription = nioRoot.resolve(PROJECT_DESCRIPTON);
    String description = "Example '" + module.getModuleName() + "' module";
    if (ioService.exists(nioDescription)) {
        description = ioService.readAllString(nioDescription);
    } else if (pom != null && pom.getDescription() != null && !pom.getDescription().isEmpty()) {
        description = pom.getDescription();
    }
    if (description != null) {
        return description.replaceAll("[\\s]+", " ");
    }
    return description;
}
Also used : Path(org.uberfire.backend.vfs.Path) POM(org.guvnor.common.services.project.model.POM)

Example 12 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class ExamplesServiceImpl method renameIfNecessary.

private WorkspaceProject renameIfNecessary(final OrganizationalUnit ou, final WorkspaceProject project) {
    String name = project.getName();
    Collection<WorkspaceProject> projectsWithSameName = projectService.getAllWorkspaceProjectsByName(ou, name);
    if (projectsWithSameName.size() > 1) {
        name = this.projectService.createFreshProjectName(ou, project.getName());
    }
    if (!name.equals(project.getName())) {
        final Path pomXMLPath = project.getMainModule().getPomXMLPath();
        final ProjectScreenModel model = projectScreenService.load(pomXMLPath);
        model.getPOM().setName(name);
        projectScreenService.save(pomXMLPath, model, "");
        return projectService.resolveProject(pomXMLPath);
    }
    return project;
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)

Example 13 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class WorkItemDefinitionBackendShowcaseRegistry method load.

@Override
public WorkItemDefinitionBackendRegistry load(final Metadata metadata) {
    final Path root = metadata.getRoot();
    if (!deployed.contains(root)) {
        deploy(root);
    }
    super.load(metadata);
    return this;
}
Also used : Path(org.uberfire.backend.vfs.Path)

Example 14 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class WorkItemDefinitionServiceImplTest method testPathAcceptor.

@Test
public void testPathAcceptor() {
    assertNotNull(pathAcceptor);
    Path p1 = mock(Path.class);
    when(p1.getFileName()).thenReturn("email.test");
    assertFalse(pathAcceptor.test(p1));
    Path p2 = mock(Path.class);
    when(p2.getFileName()).thenReturn("email.wid");
    assertTrue(pathAcceptor.test(p2));
    Path p3 = mock(Path.class);
    when(p3.getFileName()).thenReturn("email.WID");
    assertTrue(pathAcceptor.test(p3));
}
Also used : Path(org.uberfire.backend.vfs.Path) Test(org.junit.Test)

Example 15 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class CalledElementFormProviderTest method setup.

@Before
public void setup() {
    calledElementFormProvider.setQueryService(queryService);
    List<RefactoringPageRow> results = new ArrayList<RefactoringPageRow>();
    RefactoringMapPageRow refactoringMapPageRow = new RefactoringMapPageRow();
    Map<String, Path> map = new HashMap<String, Path>();
    map.put(ID1, path1);
    map.put(ID2, path2);
    refactoringMapPageRow.setValue(map);
    results.add(refactoringMapPageRow);
    when(queryService.query(anyString(), anyObject())).thenReturn(results);
}
Also used : Path(org.uberfire.backend.vfs.Path) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RefactoringMapPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringMapPageRow) Matchers.anyString(org.mockito.Matchers.anyString) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) Before(org.junit.Before)

Aggregations

Path (org.uberfire.backend.vfs.Path)607 Test (org.junit.Test)408 URL (java.net.URL)93 Package (org.guvnor.common.services.project.model.Package)87 KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)71 CreationalContext (javax.enterprise.context.spi.CreationalContext)66 Bean (javax.enterprise.inject.spi.Bean)66 ArrayList (java.util.ArrayList)63 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)51 Module (org.guvnor.common.services.project.model.Module)48 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)41 KieModule (org.kie.workbench.common.services.shared.project.KieModule)38 List (java.util.List)37 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)30 Branch (org.guvnor.structure.repositories.Branch)29 HashMap (java.util.HashMap)28 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)28 ObservablePath (org.uberfire.backend.vfs.ObservablePath)27 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)25 Before (org.junit.Before)25