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;
}
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;
}
}
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);
}
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));
}
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());
}
Aggregations