Search in sources :

Example 1 with SpringSchedule

use of com.mercedesbenz.sechub.docgen.spring.SpringScheduleExtractor.SpringSchedule in project sechub by mercedes-benz.

the class ScheduleDescriptionGenerator method generate.

public String generate(ClasspathDataCollector collector) {
    if (collector == null) {
        return "";
    }
    List<DocAnnotationData> list = collector.fetchMustBeDocumentParts();
    if (list == null || list.isEmpty()) {
        return "";
    }
    StringBuilder sb = new StringBuilder();
    Map<String, SortedSet<TableRow>> rowMap = new TreeMap<>();
    for (DocAnnotationData data : list) {
        if (data.springScheduled == null) {
            continue;
        }
        SpringSchedule extracted = springScheduledExtractor.extract(data.springScheduled);
        TableRow row = new TableRow();
        row.scheduleType = extracted.getScheduleType().getText();
        row.scheduleDefinition = extracted.getScheduleDefinition();
        row.description = data.description;
        row.location = locationExtractor.extractLocation(data);
        SortedSet<TableRow> rows = rowMap.get(data.scope);
        if (rows == null) {
            rows = new TreeSet<>();
            rowMap.put(data.scope, rows);
        }
        rows.add(row);
    }
    if (rowMap.isEmpty()) {
        return "";
    }
    for (Map.Entry<String, SortedSet<TableRow>> entries : rowMap.entrySet()) {
        SortedSet<TableRow> table = entries.getValue();
        sb.append("[options=\"header\",cols=\"1,6,6\"]\n");
        sb.append(".").append(buildTitle(entries.getKey()));
        sb.append("\n|===\n");
        sb.append("|Type   |Definition   |Description\n");
        sb.append("//----------------------\n");
        for (TableRow row : table) {
            sb.append("|").append(row.scheduleType);
            sb.append("|").append(row.scheduleDefinition);
            sb.append("|").append(row.description);
            sb.append("\n");
        }
        sb.append("\n|===\n\n");
    }
    return sb.toString();
}
Also used : DocAnnotationData(com.mercedesbenz.sechub.docgen.DocAnnotationData) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) SpringSchedule(com.mercedesbenz.sechub.docgen.spring.SpringScheduleExtractor.SpringSchedule) TreeMap(java.util.TreeMap) Map(java.util.Map)

Aggregations

DocAnnotationData (com.mercedesbenz.sechub.docgen.DocAnnotationData)1 SpringSchedule (com.mercedesbenz.sechub.docgen.spring.SpringScheduleExtractor.SpringSchedule)1 Map (java.util.Map)1 SortedSet (java.util.SortedSet)1 TreeMap (java.util.TreeMap)1