protected void createGraphics(final ExternalNetElementType element) throws CanoniserException { final GraphicsType graphics = ANF_FACTORY.createGraphicsType(); graphics.setCpfId(generateUUID(CONTROLFLOW_ID_PREFIX, element.getId())); graphics.setId(generateUUID()); // Convert Vertex to ANF convertVertexLayout(getContext().getLayoutVertexForElement(element.getId()), graphics); // Add YAWL specific extensions final Collection<LayoutDecoratorFactsType> layoutDecorators = getContext().getLayoutDecoratorForElement(element.getId()); if (layoutDecorators != null) { for (final LayoutDecoratorFactsType decorator : layoutDecorators) { graphics .getAny() .add( ExtensionUtils.marshalYAWLFragment( ExtensionUtils.DECORATOR, decorator, LayoutDecoratorFactsType.class)); } } if (getContext().getLayoutLabelForElement(element.getId()) != null) { graphics .getAny() .add( ExtensionUtils.marshalYAWLFragment( ExtensionUtils.LABEL, getContext().getLayoutLabelForElement(element.getId()), LayoutLabelFactsType.class)); } getContext().getAnnotationResult().getAnnotation().add(graphics); }
protected void createDocumentation( final ExternalNetElementType element, final String documentation) throws CanoniserException { final DocumentationType d = ANF_FACTORY.createDocumentationType(); d.setCpfId(generateUUID(CONTROLFLOW_ID_PREFIX, element.getId())); d.setId(generateUUID()); d.getAny() .add( ExtensionUtils.marshalYAWLFragment( ExtensionUtils.DOCUMENTATION, documentation, String.class)); getContext().getAnnotationResult().getAnnotation().add(d); }
/** * Create the graphical annotation for a YAWL edge. * * @param sourceId of the YAWL source * @param targetId of the YAWL target * @throws CanoniserException */ protected void createGraphicsForFlow(final String sourceId, final String targetId) throws CanoniserException { final GraphicsType graphics = ANF_FACTORY.createGraphicsType(); graphics.setCpfId( generateUUID(CONTROLFLOW_ID_PREFIX, getContext().buildEdgeId(sourceId, targetId))); graphics.setId(generateUUID()); final LayoutFlowFactsType flowLayout = getContext().getLayoutFlow(getContext().buildEdgeId(sourceId, targetId)); // Convert and add YAWL specific extension if (flowLayout != null) { graphics .getAny() .add( ExtensionUtils.marshalYAWLFragment( ExtensionUtils.FLOW, getContext().getLayoutFlow(getContext().buildEdgeId(sourceId, targetId)), LayoutFlowFactsType.class)); graphics.setLine(convertFlowLineStyle(flowLayout)); try { graphics.getPosition().addAll(convertFlowPositions(flowLayout)); if (graphics.getPosition().isEmpty()) { // Calculate start and end position LayoutVertexFactsType sourceVertex = getContext().getLayoutVertexForElement(sourceId); LayoutVertexFactsType targetVertex = getContext().getLayoutVertexForElement(targetId); if (sourceVertex != null && targetVertex != null) { try { graphics .getPosition() .add(calculateFlowPosition(sourceVertex, flowLayout.getPorts().getOut())); graphics .getPosition() .add(calculateFlowPosition(targetVertex, flowLayout.getPorts().getIn())); } catch (ParseException e) { throw new CanoniserException( "Could not calculate default position for flow from " + sourceId + " to " + targetId, e); } } } } catch (final ParseException e) { throw new CanoniserException( "Could not convert layout of flow from " + sourceId + " to " + targetId, e); } } getContext().getAnnotationResult().getAnnotation().add(graphics); }
@Test public void testAddAnnotations() throws CanoniserException { context.addToAnnotations( ExtensionUtils.marshalYAWLFragment("test", new MetaDataType(), MetaDataType.class)); }