-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0f8c01
commit c595c60
Showing
6 changed files
with
123 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,109 @@ | ||
package org.dependencytrack.util; | ||
|
||
import org.dependencytrack.model.Classifier; | ||
import org.dependencytrack.model.Component; | ||
import org.dependencytrack.model.ComponentMetaInformation; | ||
import org.dependencytrack.model.IntegrityMatchStatus; | ||
import org.dependencytrack.model.License; | ||
import org.dependencytrack.model.Project; | ||
import org.dependencytrack.model.sqlMapping.ComponentProjection; | ||
|
||
import java.util.UUID; | ||
|
||
public class ComponentUtil { | ||
|
||
public static final Component mapToComponent(ComponentProjection result) { | ||
Component componentPersistent = new Component(); | ||
componentPersistent.setAuthor(result.author); | ||
componentPersistent.setBlake2b_256(result.blake2b_256); | ||
componentPersistent.setBlake2b_384(result.blake2b_384); | ||
componentPersistent.setBlake2b_512(result.blake2b_512); | ||
componentPersistent.setBlake3(result.blake3); | ||
if (result.classifier != null) { | ||
componentPersistent.setClassifier(Classifier.valueOf(result.classifier)); | ||
} | ||
componentPersistent.setCopyright(result.copyright); | ||
componentPersistent.setCpe(result.cpe); | ||
componentPersistent.setDescription(result.description); | ||
componentPersistent.setDirectDependencies(result.directDependencies); | ||
componentPersistent.setExtension(result.extension); | ||
componentPersistent.setGroup(result.group); | ||
componentPersistent.setId(result.id); | ||
if (result.internal != null) { | ||
componentPersistent.setInternal(result.internal); | ||
} | ||
componentPersistent.setSwidTagId(result.swidTagId); | ||
componentPersistent.setLastInheritedRiskScore(result.lastInheritedRiskscore); | ||
componentPersistent.setLicense(result.licenseName); | ||
componentPersistent.setLicenseUrl(result.licenseUrl); | ||
componentPersistent.setLicenseExpression(result.licenseExpression); | ||
componentPersistent.setName(result.name); | ||
if (result.uuid != null) { | ||
componentPersistent.setUuid(UUID.fromString(result.uuid)); | ||
} | ||
// componentPersistent.setExternalReferences(); | ||
componentPersistent.setPurl(result.purl); | ||
componentPersistent.setPurlCoordinates(result.purlCoordinates); | ||
componentPersistent.setVersion(result.version); | ||
componentPersistent.setMd5(result.md5); | ||
componentPersistent.setSha1(result.sha1); | ||
componentPersistent.setSha256(result.sha256); | ||
componentPersistent.setSha384(result.sha384); | ||
componentPersistent.setSha512(result.sha512); | ||
componentPersistent.setSha3_256(result.sha3_256); | ||
componentPersistent.setSha3_384(result.sha3_384); | ||
componentPersistent.setSha3_512(result.sha3_512); | ||
|
||
var project = new Project(); | ||
if (result.projectId != null) { | ||
project.setId(result.projectId); | ||
} | ||
project.setAuthor(result.projectAuthor); | ||
if (result.projectActive != null) { | ||
project.setActive(result.projectActive); | ||
} | ||
project.setDescription(result.projectDescription); | ||
project.setCpe(result.projectCpe); | ||
project.setPurl(result.projectPurl); | ||
project.setSwidTagId(result.projectSwidTagId); | ||
project.setPublisher(result.projectPublisher); | ||
// project.setExternalReferences(); | ||
project.setLastInheritedRiskScore(result.projectLastInheritedRiskScore); | ||
if (result.projectClassifier != null) { | ||
project.setClassifier(Classifier.valueOf(result.projectClassifier)); | ||
} | ||
project.setDirectDependencies(result.projectDirectDependencies); | ||
project.setLastBomImport(result.lastBomImport); | ||
project.setLastBomImportFormat(result.lastBomImportFormat); | ||
project.setName(result.projectName); | ||
if (result.projectUuid != null) { | ||
project.setUuid(UUID.fromString(result.projectUuid)); | ||
} | ||
project.setVersion(result.projectVersion); | ||
componentPersistent.setProject(project); | ||
|
||
var license = new License(); | ||
if (result.licenseUuid != null) { | ||
license.setUuid(UUID.fromString(result.licenseUuid)); | ||
} | ||
if (result.isCustomLicense != null) { | ||
license.setCustomLicense(result.isCustomLicense); | ||
} | ||
if (result.isFsfLibre != null) { | ||
license.setFsfLibre(result.isFsfLibre); | ||
} | ||
license.setLicenseId(result.licenseId); | ||
if (result.isOsiApproved != null) { | ||
license.setOsiApproved(result.isOsiApproved); | ||
} | ||
license.setName(result.licenseName); | ||
componentPersistent.setResolvedLicense(license); | ||
|
||
var componentMetaInformation = new ComponentMetaInformation(result.publishedAt, | ||
result.integrityCheckStatus != null ? IntegrityMatchStatus.valueOf(result.integrityCheckStatus) : null, | ||
result.lastFetch, result.integrityRepoUrl); | ||
componentPersistent.setComponentMetaInformation(componentMetaInformation); | ||
|
||
return null; | ||
return componentPersistent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters