diff options
Diffstat (limited to 'tvloader/parser2v1/parse_annotation.go')
-rw-r--r-- | tvloader/parser2v1/parse_annotation.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tvloader/parser2v1/parse_annotation.go b/tvloader/parser2v1/parse_annotation.go new file mode 100644 index 0000000..ca2e850 --- /dev/null +++ b/tvloader/parser2v1/parse_annotation.go @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +package parser2v1 + +import ( + "fmt" +) + +func (parser *tvParser2_1) parsePairForAnnotation2_1(tag string, value string) error { + if parser.ann == nil { + return fmt.Errorf("no annotation struct created in parser ann pointer") + } + + switch tag { + case "Annotator": + subkey, subvalue, err := extractSubs(value) + if err != nil { + return err + } + if subkey == "Person" || subkey == "Organization" || subkey == "Tool" { + parser.ann.Annotator.AnnotatorType = subkey + parser.ann.Annotator.Annotator = subvalue + return nil + } + return fmt.Errorf("unrecognized Annotator type %v", subkey) + case "AnnotationDate": + parser.ann.AnnotationDate = value + case "AnnotationType": + parser.ann.AnnotationType = value + case "SPDXREF": + deID, err := extractDocElementID(value) + if err != nil { + return err + } + parser.ann.AnnotationSPDXIdentifier = deID + case "AnnotationComment": + parser.ann.AnnotationComment = value + default: + return fmt.Errorf("received unknown tag %v in Annotation section", tag) + } + + return nil +} |