aboutsummaryrefslogtreecommitdiff
path: root/jsonsaver/saver2v2/save_annotations.go
blob: 0a69c2cab334a08ebba6a2838c58fd53576e2c3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later

package saver2v2

import (
	"fmt"

	"github.com/spdx/tools-golang/spdx"
)

func renderAnnotations2_2(annotations []*spdx.Annotation2_2, eID spdx.DocElementID) ([]interface{}, error) {

	var ann []interface{}
	for _, v := range annotations {
		if v.AnnotationSPDXIdentifier == eID {
			annotation := make(map[string]interface{})
			annotation["annotationDate"] = v.AnnotationDate
			annotation["annotationType"] = v.AnnotationType
			annotation["annotator"] = fmt.Sprintf("%s: %s", v.AnnotatorType, v.Annotator)
			if v.AnnotationComment != "" {
				annotation["comment"] = v.AnnotationComment
			}
			ann = append(ann, annotation)
		}
	}
	return ann, nil
}