Search in sources :

Example 16 with OrganizationalUnit

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

the class OrganizationalUnitPopUpPresenter method saveCreation.

void saveCreation(final String name, final String defaultGroupId, final String owner) {
    final Command saveCommand = () -> {
        final Collection<Repository> repositories = new ArrayList<>();
        final List<String> contributors = contributorsManagementPresenter.getSelectedContributorsUserNames();
        final RemoteCallback<OrganizationalUnit> successCallback = (OrganizationalUnit newOrganizationalUnit) -> {
            afterCreateOrganizationalUnitEvent.fire(new AfterCreateOrganizationalUnitEvent(newOrganizationalUnit));
            view.hideBusyIndicator();
            notificationEvent.fire(new NotificationEvent(view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
            view.hide();
        };
        final HasBusyIndicatorDefaultErrorCallback errorCallback = new HasBusyIndicatorDefaultErrorCallback(view);
        organizationalUnitService.call(successCallback, errorCallback).createOrganizationalUnit(name, owner, defaultGroupId, repositories, contributors);
    };
    validateDuplicatedOrganizationalUnit(name, saveCommand);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Command(org.uberfire.mvp.Command) AfterCreateOrganizationalUnitEvent(org.guvnor.structure.events.AfterCreateOrganizationalUnitEvent) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 17 with OrganizationalUnit

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

the class LibraryPlaces method setupLibraryPerspective.

private void setupLibraryPerspective() {
    OrganizationalUnit activeOu = projectContext.getActiveOrganizationalUnit().orElseThrow(() -> new IllegalStateException("Cannot setup library perspective without active space."));
    PortablePreconditions.checkNotNull("libraryPerspective", libraryPerspective);
    final PlaceRequest placeRequest = new DefaultPlaceRequest(LibraryPlaces.LIBRARY_SCREEN);
    final PartDefinitionImpl part = new PartDefinitionImpl(placeRequest);
    part.setSelectable(false);
    if (!projectContext.getActiveWorkspaceProject().isPresent()) {
        projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(activeOu));
    }
    closeLibraryPlaces();
    placeManager.goTo(part, libraryPerspective.getRootPanel());
    setupLibraryBreadCrumbsWithoutProject();
    hideDocks();
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) PartDefinitionImpl(org.uberfire.workbench.model.impl.PartDefinitionImpl) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)

Example 18 with OrganizationalUnit

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

the class LibraryPlaces method goToLibrary.

public void goToLibrary() {
    if (!projectContext.getActiveOrganizationalUnit().isPresent()) {
        libraryService.call(new RemoteCallback<OrganizationalUnit>() {

            @Override
            public void callback(OrganizationalUnit organizationalUnit) {
                projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(organizationalUnit));
                setupLibraryPerspective();
            }
        }).getDefaultOrganizationalUnit();
    } else {
        setupLibraryPerspective();
    }
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 19 with OrganizationalUnit

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

the class LibraryScreenTest method organizationalUnitEditedTest.

@Test
public void organizationalUnitEditedTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final List<String> contributors = new ArrayList<>();
    contributors.add("admin");
    doReturn(contributors).when(organizationalUnit).getContributors();
    libraryScreen.organizationalUnitEdited(new AfterEditOrganizationalUnitEvent(mock(OrganizationalUnit.class), organizationalUnit));
    verify(view).setContributorsCount(contributors.size());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) AfterEditOrganizationalUnitEvent(org.guvnor.structure.events.AfterEditOrganizationalUnitEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 20 with OrganizationalUnit

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

the class LibraryScreenTest method setupTest.

@Test
public void setupTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn("name").when(organizationalUnit).getName();
    doReturn(Optional.of(organizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    doReturn(12).when(contributorsListPresenter).getContributorsCount();
    libraryScreen.init();
    verify(view).init(libraryScreen);
    verify(view).setTitle("name");
    verify(view).setContributorsCount(12);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) 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