Skip to content
Permalink
Browse files

OrtResult: Make getDeclaredLicensesForId() return processed licenses

Both mapped (to SPDX expressions) and unmappable licenses are returned.
This way declared licenses in reports are better comparable to detected
licenses, which always are SPDX expressions.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch-si.com>
  • Loading branch information...
sschuberth committed Aug 12, 2019
1 parent d2b1e09 commit 49c462370a625401adb1445f89a5c6dd2f53e954
@@ -283,12 +283,12 @@ data class OrtResult(
getPackage(id)?.pkg?.concludedLicense

/**
* Return the declared licenses for the given [id] which may either refer to a project or to a package. If [id] is
* not found an empty set is returned.
* Return the processed declared licenses for the given [id] which may either refer to a project or to a package. If
* [id] is not found an empty set is returned.
*/
fun getDeclaredLicensesForId(id: Identifier): SortedSet<String> =
getProject(id)?.declaredLicenses
?: getPackage(id)?.pkg?.declaredLicenses
getProject(id)?.declaredLicensesProcessed?.allLicenses?.toSortedSet()
?: getPackage(id)?.pkg?.declaredLicensesProcessed?.allLicenses?.toSortedSet()
?: sortedSetOf()

/**
@@ -582,7 +582,7 @@ <h3 class="">Packages</h3>
</ul>
</td><td><em>Declared Licenses:</em>
<dl>
<dd>Eclipse Public License 1.0</dd>
<dd>EPL-1.0</dd>
</dl>
</td><td>
<ul></ul>
@@ -598,7 +598,7 @@ <h3 class="">Packages</h3>
</ul>
</td><td><em>Declared Licenses:</em>
<dl>
<dd>"Apache License, Version 2.0"</dd>
<dd>Apache-2.0</dd>
</dl>
</td><td>
<ul></ul>
@@ -614,7 +614,7 @@ <h3 class="">Packages</h3>
</ul>
</td><td><em>Declared Licenses:</em>
<dl>
<dd>"Apache License, Version 2.0"</dd>
<dd>Apache-2.0</dd>
</dl>
</td><td>
<ul></ul>
@@ -629,7 +629,7 @@ <h3 class="">Packages</h3>
</ul>
</td><td><em>Declared Licenses:</em>
<dl>
<dd>New BSD License</dd>
<dd>BSD-3-Clause</dd>
</dl>
</td><td>
<ul></ul>
@@ -21,6 +21,7 @@ package com.here.ort.utils

import ch.frankel.slf4k.*

import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonInclude

import com.here.ort.spdx.SpdxDeclaredLicenseMapping
@@ -76,4 +77,10 @@ data class ProcessedDeclaredLicense(
unmapped = emptyList()
)
}

/**
* The list of all mapped and unmapped licenses.
*/
@JsonIgnore
val allLicenses = spdxExpression?.licenses().orEmpty() + unmapped
}

0 comments on commit 49c4623

Please sign in to comment.
You can’t perform that action at this time.