001/* 002 * Copyright 2023 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.workflow.readers; 017 018import java.util.Set; 019 020import org.apache.cocoon.environment.Request; 021 022import org.ametys.runtime.i18n.I18nizableText; 023 024import com.opensymphony.workflow.loader.ActionDescriptor; 025import com.opensymphony.workflow.loader.StepDescriptor; 026import com.opensymphony.workflow.loader.WorkflowDescriptor; 027 028/** 029 * Read action mindMap from plantUML 030 */ 031public class PlantUmlMindMapSVGReader extends AbstractPlantUMLMindmapSVGReader 032{ 033 /** The color for incoming step nodes */ 034 public static final String __INCOMING_STEP_NODE_COLOR = "#fcf0f7"; 035 036 @Override 037 protected String _getPlantUMLStyle() 038 { 039 StringBuilder style = new StringBuilder(); 040 041 style.append("<style> \n"); 042 style.append("mindmapDiagram { \n"); 043 style.append("node { \n"); 044 style.append("HyperLinkColor black \n"); 045 style.append("hyperlinkUnderlineThickness 0 \n"); //workaround until HyperlinkUnderline false is fixed 046 style.append("} \n"); 047 style.append("} \n"); 048 style.append("</style> \n"); 049 050 return style.toString(); 051 } 052 053 @Override 054 protected String _getPlantUMLGraphContent(Request request, WorkflowDescriptor workflowDescriptor) 055 { 056 StringBuilder content = new StringBuilder(); 057 058 int actionId = Integer.valueOf((String) request.get("actionId")); 059 ActionDescriptor action = workflowDescriptor.getAction(actionId); 060 String workflowName = workflowDescriptor.getName(); 061 062 // Graph for central action node 063 String actionContent = _getMindMapNodeContent( 064 "+", 065 _getActionLabel(action), 066 _workflowStepDAO.getActionIconPathAsBase64(action), 067 null, 068 null, 069 null, 070 true 071 ); 072 content.append(actionContent); 073 074 // Graph for incoming steps 075 Set<StepDescriptor> incomingSteps = _workflowStepDAO.getIncomingSteps(actionId, workflowDescriptor); 076 for (StepDescriptor step : incomingSteps) 077 { 078 int stepId = step.getId(); 079 String stepNode = _getMindMapNodeContent( 080 "--", 081 _getStepNodeLabel(workflowDescriptor, stepId), 082 _workflowStepDAO.getStepIconPathAsBase64(workflowDescriptor, stepId), 083 __INCOMING_STEP_NODE_COLOR, 084 _getJsFunction(workflowName, String.valueOf(stepId), null), 085 _i18nUtils.translate(new I18nizableText("plugin.workflow", "PLUGIN_WORKFLOW_LINK_SEE_STEP")), 086 false 087 ); 088 content.append(stepNode); 089 } 090 091 //Graph for outgoing steps 092 Set<StepDescriptor> outgoingSteps = _workflowStepDAO.getOutgoingSteps(action, workflowDescriptor); 093 for (StepDescriptor step : outgoingSteps) 094 { 095 int stepId = step.getId(); 096 String stepNode = _getMindMapNodeContent( 097 "++", 098 _getStepNodeLabel(workflowDescriptor, stepId), 099 _workflowStepDAO.getStepIconPathAsBase64(workflowDescriptor, stepId), 100 __MAIN_STEP_NODE_COLOR, 101 _getJsFunction(workflowName, String.valueOf(stepId), null), 102 _i18nUtils.translate(new I18nizableText("plugin.workflow", "PLUGIN_WORKFLOW_LINK_SEE_STEP")), 103 false 104 ); 105 content.append(stepNode); 106 } 107 return content.toString(); 108 } 109 110}