/** * {@inheritDoc} */ @Override public void printStatusMessage() { super.printStatusMessage(); final int numPlots = this.getSuccessCount(); final long lastSuccessTracesId = this.getLastTraceIdSuccess(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Wrote " + numPlots + " sequence diagram" + (numPlots > 1 ? "s" : "") // NOCS (AvoidInlineConditionalsCheck) + " to file" + (numPlots > 1 ? "s" : "") + " with name pattern '" + this.outputFnBase + "-<traceId>.pic'"); // NOCS (Inline Conditional) LOGGER.debug("Pic files can be converted using the pic2plot tool (package plotutils)"); LOGGER.debug("Example: pic2plot -T svg " + this.outputFnBase + "-" + ((numPlots > 0) ? lastSuccessTracesId : "<traceId>") // NOCS (Inline Conditional) + ".pic > " + this.outputFnBase + "-" + ((numPlots > 0) ? lastSuccessTracesId : "<traceId>") + ".svg"); // NOCS (AvoidInlineConditionalsCheck) } }
/** * This method writes the pic code for the given message trace into the given file. * * @param msgTrace * The message trace to convert. * @param sdMode * The mode of the sequence diagram (allocation, assembly). * @param shortLabels * Determines whether to use short labels or not. * @param outputFilename * The name of the file in which the code will be written. * * @throws FileNotFoundException * If the given file is somehow invalid. * @throws UnsupportedEncodingException * If the used default encoding is not supported. */ public static void writePicForMessageTrace(final MessageTrace msgTrace, final SDModes sdMode, final String outputFilename, final boolean shortLabels) throws FileNotFoundException, UnsupportedEncodingException { final PrintStream ps = new PrintStream(new FileOutputStream(outputFilename), false, ENCODING); SequenceDiagramFilter.picFromMessageTrace(msgTrace, sdMode, ps, shortLabels); ps.flush(); ps.close(); }
@Override @InputPort(name = AbstractMessageTraceProcessingFilter.INPUT_PORT_NAME_MESSAGE_TRACES, description = "Receives the message traces to be processed", eventTypes = { MessageTrace.class }) public void inputMessageTraces(final MessageTrace mt) { try { SequenceDiagramFilter.writePicForMessageTrace(mt, SequenceDiagramFilter.this.sdmode, SequenceDiagramFilter.this.outputFnBase + "-" + ((AbstractTrace) mt).getTraceId() + ".pic", SequenceDiagramFilter.this.shortLabels); SequenceDiagramFilter.this.reportSuccess(((AbstractTrace) mt).getTraceId()); } catch (final FileNotFoundException ex) { SequenceDiagramFilter.this.reportError(((AbstractTrace) mt).getTraceId()); this.logger.error("File not found", ex); } catch (final UnsupportedEncodingException ex) { SequenceDiagramFilter.this.reportError(((AbstractTrace) mt).getTraceId()); this.logger.error("Encoding not supported", ex); } }
private void createPlotDeploymentSequenceDiagrams(final List<AbstractTraceProcessingFilter> allTraceProcessingComponents, final String pathPrefix, final TraceReconstructionFilter mtReconstrFilter, final TraceEventRecords2ExecutionAndMessageTraceFilter traceEvents2ExecutionAndMessageTraceFilter, final SystemModelRepository systemEntityFactory) throws IllegalStateException, AnalysisConfigurationException { final Configuration componentPlotAllocationSeqDiagrConfig = new Configuration(); componentPlotAllocationSeqDiagrConfig.setProperty(AbstractAnalysisComponent.CONFIG_NAME, VisualizationConstants.PLOTALLOCATIONSEQDIAGR_COMPONENT_NAME); componentPlotAllocationSeqDiagrConfig.setProperty( SequenceDiagramFilter.CONFIG_PROPERTY_NAME_OUTPUT_FN_BASE, pathPrefix + VisualizationConstants.ALLOCATION_SEQUENCE_DIAGRAM_FN_PREFIX); componentPlotAllocationSeqDiagrConfig.setProperty( SequenceDiagramFilter.CONFIG_PROPERTY_NAME_OUTPUT_SDMODE, SequenceDiagramFilter.SDModes.ALLOCATION.toString()); componentPlotAllocationSeqDiagrConfig.setProperty( SequenceDiagramFilter.CONFIG_PROPERTY_NAME_OUTPUT_SHORTLABES, this.booleanToString(this.settings.isShortLabels())); final SequenceDiagramFilter componentPlotAllocationSeqDiagr = new SequenceDiagramFilter(componentPlotAllocationSeqDiagrConfig, this.analysisController); this.analysisController.connect(mtReconstrFilter, TraceReconstructionFilter.OUTPUT_PORT_NAME_MESSAGE_TRACE, componentPlotAllocationSeqDiagr, AbstractMessageTraceProcessingFilter.INPUT_PORT_NAME_MESSAGE_TRACES); this.analysisController.connect(traceEvents2ExecutionAndMessageTraceFilter, TraceEventRecords2ExecutionAndMessageTraceFilter.OUTPUT_PORT_NAME_MESSAGE_TRACE, componentPlotAllocationSeqDiagr, AbstractMessageTraceProcessingFilter.INPUT_PORT_NAME_MESSAGE_TRACES); this.analysisController.connect(componentPlotAllocationSeqDiagr, AbstractTraceAnalysisFilter.REPOSITORY_PORT_NAME_SYSTEM_MODEL, systemEntityFactory); allTraceProcessingComponents.add(componentPlotAllocationSeqDiagr); }
@Override public Configuration getCurrentConfiguration() { final Configuration configuration = super.getCurrentConfiguration(); configuration.setProperty(CONFIG_PROPERTY_NAME_OUTPUT_FN_BASE, this.outputFnBase); configuration.setProperty(CONFIG_PROPERTY_NAME_OUTPUT_SHORTLABES, Boolean.toString(this.shortLabels)); configuration.setProperty(CONFIG_PROPERTY_NAME_OUTPUT_SDMODE, this.sdmode.toString()); return configuration; } }
if (!plottedComponentIds.contains(senderComponent.getId())) { ps.print("object(O" + senderComponent.getId() + ",\"" + senderComponent.getExecutionContainer().getName() + "::\",\"" + SequenceDiagramFilter.allocationComponentLabel(senderComponent, shortLabels) + "\");" + "\n"); plottedComponentIds.add(senderComponent.getId()); + SequenceDiagramFilter.allocationComponentLabel(receiverComponent, shortLabels) + "\");" + "\n"); plottedComponentIds.add(receiverComponent.getId()); final AssemblyComponent receiverComponent = me.getReceivingExecution().getAllocationComponent().getAssemblyComponent(); if (!plottedComponentIds.contains(senderComponent.getId())) { ps.print("object(O" + senderComponent.getId() + ",\"\",\"" + SequenceDiagramFilter.assemblyComponentLabel(senderComponent, shortLabels) + "\");" + "\n"); plottedComponentIds.add(senderComponent.getId()); ps.print("object(O" + receiverComponent.getId() + ",\"\",\"" + SequenceDiagramFilter.assemblyComponentLabel(receiverComponent, shortLabels) + "\");" + "\n"); plottedComponentIds.add(receiverComponent.getId());
final SequenceDiagramFilter sequenceDiagramFilter = new SequenceDiagramFilter(confSequenceDiagramFilter, analysisController);
/** * Creates a new instance of this class using the given parameters. * * @param configuration * The configuration to use for this filter. * @param projectContext * The project context to use for this filter. */ public SequenceDiagramFilter(final Configuration configuration, final IProjectContext projectContext) { super(configuration, projectContext); this.sdmode = SDModes.valueOf(configuration.getStringProperty(CONFIG_PROPERTY_NAME_OUTPUT_SDMODE)); this.outputFnBase = configuration.getStringProperty(CONFIG_PROPERTY_NAME_OUTPUT_FN_BASE); this.shortLabels = configuration.getBooleanProperty(CONFIG_PROPERTY_NAME_OUTPUT_SHORTLABES); }
componentPlotAssemblySeqDiagrConfig.setProperty( SequenceDiagramFilter.CONFIG_PROPERTY_NAME_OUTPUT_SDMODE, SequenceDiagramFilter.SDModes.ASSEMBLY.toString()); componentPlotAssemblySeqDiagrConfig.setProperty( SequenceDiagramFilter.CONFIG_PROPERTY_NAME_OUTPUT_SHORTLABES, this.booleanToString(this.settings.isShortLabels())); final SequenceDiagramFilter componentPlotAssemblySeqDiagr = new SequenceDiagramFilter(componentPlotAssemblySeqDiagrConfig, this.analysisController);