001/*
002 * Copyright 2025 devteam@scivicslab.com
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,
011 * software distributed under the License is distributed on an
012 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied.  See the License for the
014 * specific language governing permissions and limitations
015 * under the License.
016 */
017
018package com.scivicslab.actoriac.report.sections.basic;
019
020import com.scivicslab.actoriac.report.SectionBuilder;
021
022/**
023 * POJO section builder that outputs the workflow description.
024 *
025 * <p>Pure business logic - no {@code CallableByActionName}.
026 * Use {@link WorkflowDescriptionSectionIIAR} to expose as an actor.</p>
027 *
028 * <h2>Output example:</h2>
029 * <pre>
030 * [Description]
031 *   Main workflow to collect Kubernetes cluster status.
032 *   This workflow gathers node, namespace, and pod information.
033 * </pre>
034 *
035 * @author devteam@scivicslab.com
036 * @since 2.16.0
037 */
038public class WorkflowDescriptionSection implements SectionBuilder {
039
040    private String description;
041
042    /**
043     * Sets the workflow description.
044     *
045     * @param description the workflow description from YAML
046     */
047    public void setDescription(String description) {
048        this.description = description;
049    }
050
051    @Override
052    public String generate() {
053        if (description == null || description.isEmpty()) {
054            return "";  // No description, skip this section
055        }
056
057        StringBuilder sb = new StringBuilder();
058        sb.append("[Description]\n");
059        for (String line : description.split("\n")) {
060            sb.append("  ").append(line.trim()).append("\n");
061        }
062        return sb.toString();
063    }
064
065    @Override
066    public String getTitle() {
067        return null;  // Title is embedded in content
068    }
069}