1// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 2 3package parser2v3 4 5import ( 6 "fmt" 7 8 gordfParser "github.com/spdx/gordf/rdfloader/parser" 9 "github.com/spdx/gordf/rdfwriter" 10 "github.com/spdx/tools-golang/spdx/v2_3" 11) 12 13func (parser *rdfParser2_3) getExtractedLicensingInfoFromNode(node *gordfParser.Node) (lic ExtractedLicensingInfo, err error) { 14 associatedTriples := rdfwriter.FilterTriples(parser.gordfParserObj.Triples, &node.ID, nil, nil) 15 var restTriples []*gordfParser.Triple 16 for _, triple := range associatedTriples { 17 switch triple.Predicate.ID { 18 case SPDX_EXTRACTED_TEXT: 19 lic.extractedText = triple.Object.ID 20 default: 21 restTriples = append(restTriples, triple) 22 } 23 } 24 lic.SimpleLicensingInfo, err = parser.getSimpleLicensingInfoFromTriples(restTriples) 25 if err != nil { 26 return lic, fmt.Errorf("error setting simple licensing information of extracted licensing info: %s", err) 27 } 28 return lic, nil 29} 30 31func (parser *rdfParser2_3) extractedLicenseToOtherLicense(extLicense ExtractedLicensingInfo) (othLic v2_3.OtherLicense) { 32 othLic.LicenseIdentifier = extLicense.licenseID 33 othLic.ExtractedText = extLicense.extractedText 34 othLic.LicenseComment = extLicense.comment 35 othLic.LicenseCrossReferences = extLicense.seeAlso 36 othLic.LicenseName = extLicense.name 37 return othLic 38} 39