Search in sources :

Example 1 with DiagramLookupRequest

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest in project kie-wb-common by kiegroup.

the class ClientDiagramServicesTest method testLookup.

@Test
@SuppressWarnings("unchecked")
public void testLookup() {
    DiagramLookupRequest request = mock(DiagramLookupRequest.class);
    ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>> callback = mock(ServiceCallback.class);
    tested.lookup(request, callback);
    verify(diagramLookupService, times(1)).lookup(eq(request));
    verify(callback, times(1)).onSuccess(any(LookupManager.LookupResponse.class));
    verify(callback, times(0)).onError(any(ClientRuntimeError.class));
}
Also used : DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest) Test(org.junit.Test)

Example 2 with DiagramLookupRequest

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest in project kie-wb-common by kiegroup.

the class ShowcaseDiagramService method loadByName.

public void loadByName(final String name, final ServiceCallback<Diagram> callback) {
    final DiagramLookupRequest request = new DiagramLookupRequest.Builder().withName(name).build();
    clientDiagramServices.lookup(request, new ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>>() {

        @Override
        public void onSuccess(LookupManager.LookupResponse<DiagramRepresentation> diagramRepresentations) {
            if (null != diagramRepresentations && !diagramRepresentations.getResults().isEmpty()) {
                final Path path = diagramRepresentations.getResults().get(0).getPath();
                loadByPath(path, callback);
            }
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            callback.onError(error);
        }
    });
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) Path(org.uberfire.backend.vfs.Path) LookupManager(org.kie.workbench.common.stunner.core.lookup.LookupManager) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)

Example 3 with DiagramLookupRequest

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest in project kie-wb-common by kiegroup.

the class ShowcaseDiagramService method loadByName.

public void loadByName(final String name, final ServiceCallback<Diagram> callback) {
    final DiagramLookupRequest request = new DiagramLookupRequest.Builder().withName(name).build();
    clientDiagramServices.lookup(request, new ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>>() {

        @Override
        public void onSuccess(LookupManager.LookupResponse<DiagramRepresentation> diagramRepresentations) {
            if (null != diagramRepresentations && !diagramRepresentations.getResults().isEmpty()) {
                final Path path = diagramRepresentations.getResults().get(0).getPath();
                loadByPath(path, callback);
            }
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            callback.onError(error);
        }
    });
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) Path(org.uberfire.backend.vfs.Path) LookupManager(org.kie.workbench.common.stunner.core.lookup.LookupManager) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)

Example 4 with DiagramLookupRequest

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest in project kie-wb-common by kiegroup.

the class AbstractClientDiagramServiceTest method testLookup.

@Test
@SuppressWarnings("unchecked")
public void testLookup() {
    final DiagramLookupRequest request = mock(DiagramLookupRequest.class);
    final ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>> callback = mock(ServiceCallback.class);
    tested.lookup(request, callback);
    verify(diagramLookupService, times(1)).lookup(eq(request));
    verify(callback, times(1)).onSuccess(Mockito.<LookupManager.LookupResponse>any());
    verify(callback, times(0)).onError(Mockito.<ClientRuntimeError>any());
}
Also used : LookupManager(org.kie.workbench.common.stunner.core.lookup.LookupManager) DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest) Test(org.junit.Test)

Example 5 with DiagramLookupRequest

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest in project kie-wb-common by kiegroup.

the class DiagramsNavigatorImpl method show.

public DiagramsNavigatorImpl show() {
    // Notify some processing starts.
    fireProcessingStarted();
    clear();
    final DiagramLookupRequest request = new DiagramLookupRequest.Builder().build();
    clientDiagramServices.lookup(request, new ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>>() {

        @Override
        public void onSuccess(final LookupManager.LookupResponse<DiagramRepresentation> response) {
            final List<DiagramRepresentation> items = response.getResults();
            if (null != items && !items.isEmpty()) {
                for (final DiagramRepresentation diagram : items) {
                    addEntry(diagram);
                }
            }
            // Notify some processing ends.
            fireProcessingCompleted();
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            showError(error);
        }
    });
    return this;
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) LookupManager(org.kie.workbench.common.stunner.core.lookup.LookupManager) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) LinkedList(java.util.LinkedList) List(java.util.List) DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)

Aggregations

DiagramLookupRequest (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)6 LookupManager (org.kie.workbench.common.stunner.core.lookup.LookupManager)5 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)4 DiagramRepresentation (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation)4 Path (org.uberfire.backend.vfs.Path)3 Test (org.junit.Test)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1