Search in sources :

Example 26 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class NewContainerWizard method complete.

@Override
public void complete() {
    final Map<Capability, ContainerConfig> mapConfig = new HashMap<Capability, ContainerConfig>();
    if (getPages().size() == 2) {
        mapConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig());
    }
    mapConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED));
    final ContainerSpec newContainer = newContainerFormPresenter.buildContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), mapConfig);
    specManagementService.call(new RemoteCallback<Void>() {

        @Override
        public void callback(final Void o) {
            notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS));
            clear();
            NewContainerWizard.super.complete();
            serverTemplateSelectedEvent.fire(new ServerTemplateSelected(serverTemplate, newContainer.getId()));
        }
    }, new ErrorCallback<Object>() {

        @Override
        public boolean error(final Object o, final Throwable throwable) {
            notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerWizardSaveError(), NotificationEvent.NotificationType.ERROR));
            NewContainerWizard.this.pageSelected(0);
            NewContainerWizard.this.start();
            return false;
        }
    }).saveContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), newContainer);
}
Also used : Capability(org.kie.server.controller.api.model.spec.Capability) HashMap(java.util.HashMap) ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig)

Example 27 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class NewServerTemplateWizard method buildServerTemplate.

private ServerTemplate buildServerTemplate() {
    final Collection<String> capabilities = new ArrayList<String>();
    final Map<Capability, ServerConfig> capabilityConfig = new HashMap<Capability, ServerConfig>();
    final Map<Capability, ContainerConfig> capabilityContainerConfig = new HashMap<Capability, ContainerConfig>();
    final Collection<ContainerSpec> containersSpec = new ArrayList<ContainerSpec>();
    if (newTemplatePresenter.isProcessCapabilityChecked()) {
        capabilities.add(Capability.PROCESS.toString());
        if (!newContainerFormPresenter.isEmpty()) {
            capabilityContainerConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig());
        }
    }
    capabilityContainerConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED));
    if (newTemplatePresenter.isRuleCapabilityChecked()) {
        capabilities.add(Capability.RULE.toString());
    }
    if (newTemplatePresenter.isPlanningCapabilityChecked()) {
        capabilities.add(Capability.PLANNING.toString());
    }
    if (!newContainerFormPresenter.isEmpty()) {
        containersSpec.add(newContainerFormPresenter.buildContainerSpec(newTemplatePresenter.getTemplateName(), capabilityContainerConfig));
    }
    return new ServerTemplate(newTemplatePresenter.getTemplateName(), newTemplatePresenter.getTemplateName(), capabilities, capabilityConfig, containersSpec);
}
Also used : Capability(org.kie.server.controller.api.model.spec.Capability) HashMap(java.util.HashMap) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ArrayList(java.util.ArrayList) ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ServerConfig(org.kie.server.controller.api.model.spec.ServerConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig)

Example 28 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class ContainerRemoteStatusPresenterTest method testOnServerInstanceUpdated.

@Test
public void testOnServerInstanceUpdated() {
    final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
    when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    when(presenterProvider.get()).thenReturn(cardPresenter);
    final ServerInstance serverInstance = new ServerInstance("templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container container = new Container("containerSpecId", "containerName", serverInstance, Collections.<Message>emptyList(), null, null);
    container.setStatus(KieContainerStatus.STARTED);
    final Container containerToBeRemoved = new Container("containerToBeRemovedSpecId", "containerToBeRemovedName", serverInstance, Collections.<Message>emptyList(), null, null);
    containerToBeRemoved.setStatus(KieContainerStatus.STARTED);
    serverInstance.addContainer(container);
    presenter.setup(new ContainerSpec(), Arrays.asList(container, containerToBeRemoved));
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
    // One container updated,  one removed
    verify(cardPresenter).updateContent(serverInstance, container);
    verify(cardPresenter).delete();
    final ArgumentCaptor<Container> containerCaptor = ArgumentCaptor.forClass(Container.class);
    verify(cardPresenter, times(2)).setup(eq(container.getServerInstanceKey()), containerCaptor.capture());
    final List<Container> containers = containerCaptor.getAllValues();
    assertEquals(2, containers.size());
    assertEquals(container, containers.get(0));
    assertEquals(containerToBeRemoved, containers.get(1));
}
Also used : ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Example 29 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class ContainerRemoteStatusPresenterTest method testOnServerInstanceUpdatedNewInstance.

@Test
public void testOnServerInstanceUpdatedNewInstance() {
    presenter = spy(new ContainerRemoteStatusPresenter(logger, view, presenterProvider));
    final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
    when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    final ContainerCardPresenter cardPresenter2 = mock(ContainerCardPresenter.class);
    when(cardPresenter2.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    final ContainerCardPresenter cardPresenter3 = mock(ContainerCardPresenter.class);
    when(cardPresenter3.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    doReturn(cardPresenter).doReturn(cardPresenter2).doReturn(cardPresenter3).when(presenterProvider).get();
    final ServerInstance serverInstance = new ServerInstance("templateId", "serverInstanceId", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container existingContainer = new Container("containerToBeRemovedSpecId", "containerToBeRemovedName", serverInstance, Collections.<Message>emptyList(), null, null);
    existingContainer.setStatus(KieContainerStatus.STARTED);
    final ServerInstance newServerInstance = new ServerInstance("templateId", "newserverInstanceId", "newserverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container newContainer = new Container("containerSpecId", "containerName", newServerInstance, Collections.<Message>emptyList(), null, null);
    newContainer.setStatus(KieContainerStatus.STARTED);
    newServerInstance.addContainer(newContainer);
    presenter.setup(new ContainerSpec("containerSpecId", "containerName", new ServerTemplateKey("templateId", "templateId"), new ReleaseId(), KieContainerStatus.STARTED, Collections.<Capability, ContainerConfig>emptyMap()), Arrays.asList(existingContainer));
    verify(cardPresenter).setup(toKey(serverInstance), existingContainer);
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(newServerInstance));
    // One container added
    verify(cardPresenter2).setup(toKey(newServerInstance), newContainer);
    final Container newContainer2 = new Container("containerSpecId", "containerNameX", newServerInstance, Collections.<Message>emptyList(), null, null);
    newContainer2.setStatus(KieContainerStatus.STARTED);
    newServerInstance.addContainer(newContainer2);
    // One new container added to existing server
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(newServerInstance));
    verify(cardPresenter3).setup(newContainer2.getServerInstanceKey(), newContainer2);
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Capability(org.kie.server.controller.api.model.spec.Capability) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Example 30 with ContainerSpec

use of org.kie.server.controller.api.model.spec.ContainerSpec in project kie-wb-common by kiegroup.

the class ServerTemplatePresenterTest method testSetup.

@Test
public void testSetup() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverTemplateId", "serverName", "serverInstanceId", "url");
    serverTemplate.addServerInstance(serverInstanceKey);
    final ReleaseId releaseId = new ReleaseId("org.kie", "container", "1.0.0");
    final ContainerSpec containerSpec = new ContainerSpec("containerId", "containerName", serverTemplate, releaseId, KieContainerStatus.CREATING, null);
    serverTemplate.addContainerSpec(containerSpec);
    final ContainerSpec containerSpec1 = new ContainerSpec("containerId1", "containerName1", serverTemplate, new ReleaseId("org.kie", "container2", "1.0.0"), KieContainerStatus.CREATING, null);
    serverTemplate.addContainerSpec(containerSpec1);
    presenter.setup(serverTemplate, containerSpec);
    assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
    verify(view).clear();
    verify(view).setTemplate(serverTemplate.getId(), serverTemplate.getName());
    verify(view).setProcessCapability(false);
    verify(view).setRulesCapability(false);
    verify(view).setPlanningCapability(false);
    verify(view).addContainer(eq(containerSpec.getServerTemplateKey().getId()), eq(containerSpec.getId()), eq(containerSpec.getContainerName()), any(Command.class));
    verify(view).addContainer(eq(containerSpec1.getServerTemplateKey().getId()), eq(containerSpec1.getId()), eq(containerSpec1.getContainerName()), any(Command.class));
    final ArgumentCaptor<ContainerSpecSelected> selectedCaptor = ArgumentCaptor.forClass(ContainerSpecSelected.class);
    verify(containerSpecSelectedEvent).fire(selectedCaptor.capture());
    assertEquals(containerSpec, selectedCaptor.getValue().getContainerSpecKey());
    verify(view).addServerInstance(eq(serverInstanceKey.getServerTemplateId()), eq(serverInstanceKey.getServerInstanceId()), eq(serverInstanceKey.getServerName()), any(Command.class));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ContainerSpecSelected(org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ReleaseId(org.kie.server.api.model.ReleaseId) Test(org.junit.Test)

Aggregations

ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)33 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)22 Test (org.junit.Test)20 ReleaseId (org.kie.server.api.model.ReleaseId)13 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)11 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)10 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)8 Container (org.kie.server.controller.api.model.runtime.Container)7 Capability (org.kie.server.controller.api.model.spec.Capability)7 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)7 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)6 HashMap (java.util.HashMap)5 Path (org.uberfire.java.nio.file.Path)5 ServerTemplateMigration (org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration)4 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)4 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 GAV (org.guvnor.common.services.project.model.GAV)3 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)3