aboutsummaryrefslogtreecommitdiff
path: root/rdfloader/parser2v2/types.go
blob: d1efe8d32ccd6c26b04b7fd1febd80bc447910ab (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
// copied from tvloader/parser2v2/types.go
package parser2v2

import (
	gordfParser "github.com/spdx/gordf/rdfloader/parser"
	"github.com/spdx/tools-golang/spdx"
)

type rdfParser2_2 struct {
	// fields associated with gordf project which
	// will be required by rdfloader
	gordfParserObj      *gordfParser.Parser
	nodeStringToTriples map[string][]*gordfParser.Triple

	// document into which data is being parsed
	doc *spdx.Document2_2

	// map of packages and files.
	files            map[spdx.ElementID]*spdx.File2_2
	assocWithPackage map[spdx.ElementID]bool
	packages         map[spdx.ElementID]*spdx.Package2_2

	// mapping of nodeStrings to parsed object to save double computation.
	cache map[string]interface{}
}

type AnyLicenseInfo interface {
	// ToLicenseString returns the representation of license about how it will
	// be stored in the tools-golang data model
	ToLicenseString() string
}

type SimpleLicensingInfo struct {
	AnyLicenseInfo
	comment   string
	licenseID string
	name      string
	seeAlso   []string
	example   string
}

type ExtractedLicensingInfo struct {
	SimpleLicensingInfo
	extractedText string
}

type OrLaterOperator struct {
	AnyLicenseInfo
	member SimpleLicensingInfo
}

type ConjunctiveLicenseSet struct {
	AnyLicenseInfo
	members []AnyLicenseInfo
}

type DisjunctiveLicenseSet struct {
	AnyLicenseInfo
	members []AnyLicenseInfo
}

type License struct {
	SimpleLicensingInfo
	isOsiApproved                 bool
	licenseText                   string
	standardLicenseHeader         string
	standardLicenseTemplate       string
	standardLicenseHeaderTemplate string
	isDeprecatedLicenseID         bool
	isFsfLibre                    bool
}

type ListedLicense struct {
	License
}

type LicenseException struct {
	licenseExceptionId   string
	licenseExceptionText string
	seeAlso              string // must be a valid uri
	name                 string
	example              string
	comment              string
}

type WithExceptionOperator struct {
	AnyLicenseInfo
	member           SimpleLicensingInfo
	licenseException LicenseException
}

// custom LicenseType to provide support for licences of
// type Noassertion, None and customLicenses
type SpecialLicense struct {
	AnyLicenseInfo
	value SpecialLicenseValue
}

type SpecialLicenseValue string

const (
	NONE        SpecialLicenseValue = "NONE"
	NOASSERTION SpecialLicenseValue = "NOASSERTION"
)

type RangeType string

const (
	BYTE_RANGE RangeType = "byteRange"
	LINE_RANGE RangeType = "lineRange"
)