Search in sources :

Example 1 with DiagramLayout

use of org.camunda.bpm.engine.repository.DiagramLayout in project camunda-bpm-platform by camunda.

the class ProcessDiagramLayoutFactory method getBpmnProcessDiagramLayout.

/**
 * Provides positions and dimensions of elements in a BPMN process diagram as
 * provided by {@link RepositoryService#getProcessDiagram(String)}.
 *
 * @param bpmnXmlStream
 *          BPMN 2.0 XML document
 * @param imageStream
 *          BPMN 2.0 diagram in PNG format (JPEG and other formats supported
 *          by {@link ImageIO} may also work)
 * @return Layout of the process diagram
 * @return null when parameter imageStream is null
 */
public DiagramLayout getBpmnProcessDiagramLayout(Document bpmnModel, InputStream imageStream) {
    if (imageStream == null) {
        return null;
    }
    DiagramNode diagramBoundsXml = getDiagramBoundsFromBpmnDi(bpmnModel);
    DiagramNode diagramBoundsImage;
    if (isExportedFromAdonis50(bpmnModel)) {
        // Adonis header
        int offsetTop = 29;
        // Adonis footer
        int offsetBottom = 61;
        diagramBoundsImage = getDiagramBoundsFromImage(imageStream, offsetTop, offsetBottom);
    } else {
        diagramBoundsImage = getDiagramBoundsFromImage(imageStream);
    }
    Map<String, DiagramNode> listOfBounds = new HashMap<String, DiagramNode>();
    listOfBounds.put(diagramBoundsXml.getId(), diagramBoundsXml);
    // listOfBounds.putAll(getElementBoundsFromBpmnDi(bpmnModel));
    listOfBounds.putAll(fixFlowNodePositionsIfModelFromAdonis(bpmnModel, getElementBoundsFromBpmnDi(bpmnModel)));
    Map<String, DiagramElement> listOfBoundsForImage = transformBoundsForImage(diagramBoundsImage, diagramBoundsXml, listOfBounds);
    return new DiagramLayout(listOfBoundsForImage);
}
Also used : DiagramElement(org.camunda.bpm.engine.repository.DiagramElement) DiagramNode(org.camunda.bpm.engine.repository.DiagramNode) HashMap(java.util.HashMap) DiagramLayout(org.camunda.bpm.engine.repository.DiagramLayout)

Example 2 with DiagramLayout

use of org.camunda.bpm.engine.repository.DiagramLayout in project camunda-bpm-platform by camunda.

the class ProcessDefinitionAuthorizationTest method testGetProcessDiagramLayout.

public void testGetProcessDiagramLayout() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
    // when
    DiagramLayout diagramLayout = repositoryService.getProcessDiagramLayout(processDefinitionId);
    // then
    // no process diagram deployed
    assertNull(diagramLayout);
}
Also used : DiagramLayout(org.camunda.bpm.engine.repository.DiagramLayout)

Example 3 with DiagramLayout

use of org.camunda.bpm.engine.repository.DiagramLayout in project camunda-bpm-platform by camunda.

the class MultiTenancyProcessDefinitionCmdsTenantCheckTest method getProcessDiagramLayoutDisabledTenantCheck.

@Test
public void getProcessDiagramLayoutDisabledTenantCheck() {
    processEngineConfiguration.setTenantCheckEnabled(false);
    identityService.setAuthentication("user", null, null);
    DiagramLayout diagramLayout = repositoryService.getProcessDiagramLayout(processDefinitionId);
    assertThat(diagramLayout, notNullValue());
}
Also used : DiagramLayout(org.camunda.bpm.engine.repository.DiagramLayout) Test(org.junit.Test)

Example 4 with DiagramLayout

use of org.camunda.bpm.engine.repository.DiagramLayout in project camunda-bpm-platform by camunda.

the class MultiTenancyProcessDefinitionCmdsTenantCheckTest method getProcessDiagramLayoutWithAuthenticatedTenant.

@Test
public void getProcessDiagramLayoutWithAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    DiagramLayout diagramLayout = repositoryService.getProcessDiagramLayout(processDefinitionId);
    assertThat(diagramLayout, notNullValue());
}
Also used : DiagramLayout(org.camunda.bpm.engine.repository.DiagramLayout) Test(org.junit.Test)

Example 5 with DiagramLayout

use of org.camunda.bpm.engine.repository.DiagramLayout in project camunda-bpm-platform by camunda.

the class ProcessDiagramRetrievalTest method testGetProcessDiagramLayout.

/**
 * Tests {@link RepositoryService#getProcessDiagramLayout(String)} and
 * {@link ProcessDiagramLayoutFactory#getProcessDiagramLayout(InputStream, InputStream)}.
 */
@Test
public void testGetProcessDiagramLayout() throws Exception {
    DiagramLayout processDiagramLayout;
    if (1 == processDefinitionQuery.count()) {
        ProcessDefinition processDefinition = processDefinitionQuery.singleResult();
        assertNotNull(processDefinition);
        processDiagramLayout = repositoryService.getProcessDiagramLayout(processDefinition.getId());
    } else {
        // some test diagrams do not contain executable processes
        // and are therefore ignored by the engine
        InputStream bpmnXmlStream = new FileInputStream("src/test/resources/org/camunda/bpm/engine/test/api/repository/diagram/" + xmlFileName);
        InputStream imageStream = new FileInputStream("src/test/resources/org/camunda/bpm/engine/test/api/repository/diagram/" + imageFileName);
        assertNotNull(bpmnXmlStream);
        assertNotNull(imageStream);
        processDiagramLayout = new ProcessDiagramLayoutFactory().getProcessDiagramLayout(bpmnXmlStream, imageStream);
    }
    assertLayoutCorrect(processDiagramLayout);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) DiagramLayout(org.camunda.bpm.engine.repository.DiagramLayout) ProcessDiagramLayoutFactory(org.camunda.bpm.engine.impl.bpmn.diagram.ProcessDiagramLayoutFactory) FileInputStream(java.io.FileInputStream)

Aggregations

DiagramLayout (org.camunda.bpm.engine.repository.DiagramLayout)5 Test (org.junit.Test)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 ProcessDiagramLayoutFactory (org.camunda.bpm.engine.impl.bpmn.diagram.ProcessDiagramLayoutFactory)1 DiagramElement (org.camunda.bpm.engine.repository.DiagramElement)1 DiagramNode (org.camunda.bpm.engine.repository.DiagramNode)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1