Search in sources :

Example 31 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.

the class DefExplorerQueryServiceImpl method resolveQuery.

private DefExplorerQueryResult resolveQuery(final DefExplorerQuery query) {
    final DefExplorerQueryResult result = new DefExplorerQueryResult();
    // load the organizational units.
    final Collection<OrganizationalUnit> organizationalUnits = resolveOrganizationalUnits();
    // piggyback the organizational units.
    result.getOrganizationalUnits().addAll(organizationalUnits);
    if (query.getOrganizationalUnit() == null || !containsOU(organizationalUnits, query.getOrganizationalUnit())) {
        // if no OU was set for filtering or the selected OU has been removed or has changed in backend.
        return result;
    }
    // set the repositories for current OU.
    final Map<String, Repository> repositories = resolveRepositories(query.getOrganizationalUnit());
    // piggyback the repositories.
    result.getRepositories().addAll(repositories.values());
    if (query.getRepository() == null || !repositories.containsKey(query.getRepository().getAlias())) {
        // changed in backend.
        return result;
    }
    // load the modules for current OU/Repository and the selected branch.
    final Map<String, Module> modules = resolveModules(repositories, query.getBranchName());
    result.getModules().addAll(modules.values());
    if (query.getModule() == null || !modules.containsKey(query.getModule().getModuleName())) {
        // changed in backend.
        return result;
    }
    // get the data sources and drivers for the selected module.
    result.setDataSourceDefs(queryService.findModuleDataSources(query.getModule()));
    result.setDriverDefs(queryService.findModuleDrivers(query.getModule()));
    return result;
}
Also used : Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Module(org.guvnor.common.services.project.model.Module) DefExplorerQueryResult(org.kie.workbench.common.screens.datasource.management.service.DefExplorerQueryResult)

Example 32 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.

the class ModuleSelector method loadOptions.

public void loadOptions(final Collection<OrganizationalUnit> organizationalUnits, final OrganizationalUnit activeOrganizationalUnit, final Collection<Repository> repositories, final Repository activeRepository, final Collection<Module> modules, final Module activeModule) {
    this.organizationUnits.clear();
    if (organizationalUnits != null) {
        if (activeOrganizationalUnit != null) {
            this.organizationUnits.setText(activeOrganizationalUnit.getName());
        }
        for (final OrganizationalUnit ou : organizationalUnits) {
            this.organizationUnits.add(new AnchorListItem(ou.getName()) {

                {
                    addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            onOrganizationalUnitSelected(ou);
                        }
                    });
                }
            });
        }
    }
    this.repos.clear();
    if (repositories != null) {
        if (activeRepository != null) {
            this.repos.setText(activeRepository.getAlias());
        } else {
            this.repos.setText(ProjectExplorerConstants.INSTANCE.nullEntry());
        }
        for (final Repository repository : repositories) {
            this.repos.add(new AnchorListItem(repository.getAlias()) {

                {
                    addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            onRepositorySelected(repository);
                        }
                    });
                }
            });
        }
    }
    this.modules.clear();
    if (modules != null) {
        if (activeModule != null) {
            this.modules.setText(activeModule.getModuleName());
        } else {
            this.modules.setText(ProjectExplorerConstants.INSTANCE.nullEntry());
        }
        for (final Module module : modules) {
            this.modules.add(new AnchorListItem(module.getModuleName()) {

                {
                    addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            onModuleSelected(module);
                        }
                    });
                }
            });
        }
    }
    if (organizationalUnits != null && organizationalUnits.isEmpty()) {
        this.organizationUnits.setText(ProjectExplorerConstants.INSTANCE.nullEntry());
        this.organizationUnits.add(new AnchorListItem(ProjectExplorerConstants.INSTANCE.nullEntry()));
        this.repos.setText(ProjectExplorerConstants.INSTANCE.nullEntry());
        this.repos.add(new AnchorListItem(ProjectExplorerConstants.INSTANCE.nullEntry()));
        this.modules.setText(ProjectExplorerConstants.INSTANCE.nullEntry());
        this.modules.add(new AnchorListItem(ProjectExplorerConstants.INSTANCE.nullEntry()));
    } else if (repositories != null && repositories.isEmpty()) {
        this.repos.setText(ProjectExplorerConstants.INSTANCE.nullEntry());
        this.repos.add(new AnchorListItem(ProjectExplorerConstants.INSTANCE.nullEntry()));
        this.modules.setText(ProjectExplorerConstants.INSTANCE.nullEntry());
        this.modules.add(new AnchorListItem(ProjectExplorerConstants.INSTANCE.nullEntry()));
    } else if (modules != null && modules.isEmpty()) {
        this.modules.setText(ProjectExplorerConstants.INSTANCE.nullEntry());
        this.modules.add(new AnchorListItem(ProjectExplorerConstants.INSTANCE.nullEntry()));
    }
    if (!isAlreadyInitialized) {
        container.clear();
        setupNavigatorBreadcrumbs();
        addDivToAlignComponents();
        isAlreadyInitialized = true;
    }
}
Also used : AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem) Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Module(org.guvnor.common.services.project.model.Module)

Example 33 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.

the class LibraryServiceImpl method getOrganizationalUnitRepositoryInfo.

@Override
public OrganizationalUnitRepositoryInfo getOrganizationalUnitRepositoryInfo(final OrganizationalUnit selectedOrganizationalUnit) {
    if (selectedOrganizationalUnit == null) {
        return null;
    }
    final List<OrganizationalUnit> organizationalUnits = getOrganizationalUnits();
    final OrganizationalUnit organizationalUnit = getOrganizationalUnit(selectedOrganizationalUnit.getIdentifier(), organizationalUnits).get();
    final List<Repository> repositories = new ArrayList<>(organizationalUnit.getRepositories());
    return new OrganizationalUnitRepositoryInfo(organizationalUnits, organizationalUnit, repositories);
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) OrganizationalUnitRepositoryInfo(org.kie.workbench.common.screens.library.api.OrganizationalUnitRepositoryInfo) ArrayList(java.util.ArrayList)

Example 34 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method importDefaultProjectTest.

@Test
public void importDefaultProjectTest() {
    final Repository repository = mock(Repository.class);
    when(repository.getAlias()).thenReturn("example");
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getName()).thenReturn("ou");
    when(organizationalUnit.getIdentifier()).thenReturn("ou");
    when(organizationalUnit.getRepositories()).thenReturn(singletonList(repository));
    when(ouService.getOrganizationalUnits()).thenReturn(singletonList(organizationalUnit));
    final ExampleProject exampleProject = mock(ExampleProject.class);
    doReturn("example").when(exampleProject).getName();
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Module module = mock(Module.class);
    doReturn(module).when(project).getMainModule();
    final WorkspaceProjectContextChangeEvent projectContextChangeEvent = mock(WorkspaceProjectContextChangeEvent.class);
    doReturn(project).when(projectContextChangeEvent).getWorkspaceProject();
    doReturn(projectContextChangeEvent).when(examplesService).setupExamples(any(ExampleOrganizationalUnit.class), anyList());
    final WorkspaceProject importedProject = libraryService.importProject(organizationalUnit, exampleProject);
    assertEquals(module, importedProject.getMainModule());
    verify(examplesService).setupExamples(new ExampleOrganizationalUnit(organizationalUnit.getName()), singletonList(exampleProject));
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Module(org.guvnor.common.services.project.model.Module) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 35 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method createGAV.

@Test
public void createGAV() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getDefaultGroupId()).thenReturn("ouGroupID");
    when(preferences.getProjectPreferences().getVersion()).thenReturn("1.0");
    GAV gav = libraryService.createGAV("proj", organizationalUnit);
    assertEquals(organizationalUnit.getDefaultGroupId(), gav.getGroupId());
    assertEquals("proj", gav.getArtifactId());
    assertEquals(preferences.getProjectPreferences().getVersion(), gav.getVersion());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) GAV(org.guvnor.common.services.project.model.GAV) Test(org.junit.Test)

Aggregations

OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)60 Test (org.junit.Test)33 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)19 ArrayList (java.util.ArrayList)18 Repository (org.guvnor.structure.repositories.Repository)17 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)13 Module (org.guvnor.common.services.project.model.Module)11 POM (org.guvnor.common.services.project.model.POM)10 Branch (org.guvnor.structure.repositories.Branch)10 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)10 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)9 Before (org.junit.Before)8 Path (org.uberfire.backend.vfs.Path)7 OrganizationalUnitImpl (org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl)6 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)6 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)5 NewProjectEvent (org.guvnor.common.services.project.events.NewProjectEvent)3 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Command (org.uberfire.mvp.Command)3