Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created ImpactTree class #128

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/com/jfrog/ide/common/nodes/DependencyNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.jfrog.ide.common.nodes.subentities.ImpactTreeNode;
import com.jfrog.ide.common.nodes.subentities.ImpactTree;
import com.jfrog.ide.common.nodes.subentities.License;
import com.jfrog.ide.common.nodes.subentities.Severity;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -22,7 +22,7 @@ public class DependencyNode extends SortableChildrenTreeNode implements Subtitle
@JsonProperty()
private boolean indirect;
@JsonProperty()
private ImpactTreeNode impactPaths;
private ImpactTree impactTree;
@JsonProperty()
private List<License> licenses;

Expand Down Expand Up @@ -74,13 +74,13 @@ public Severity getSeverity() {

@JsonGetter()
@SuppressWarnings("unused")
public ImpactTreeNode getImpactPaths() {
return impactPaths;
public ImpactTree getImpactTree() {
return impactTree;
}

@SuppressWarnings("unused")
public void setImpactPaths(ImpactTreeNode impactPaths) {
this.impactPaths = impactPaths;
public void setImpactTree(ImpactTree impactTree) {
this.impactTree = impactTree;
}

public void addIssue(IssueNode issue) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.jfrog.ide.common.nodes.subentities;

import com.fasterxml.jackson.annotation.JsonProperty;

public class ImpactTree {
@JsonProperty
private ImpactTreeNode root;
@JsonProperty
private int impactPathsCount = 0;

// Empty constructor for deserialization
@SuppressWarnings("unused")
public ImpactTree() {
}

public ImpactTree(ImpactTreeNode root) {
this.root = root;
}

public boolean contains(String name) {
return root.contains(name);
}

public ImpactTreeNode getRoot() {
return root;
}

@SuppressWarnings("unused")
public int getImpactPathsCount() {
return impactPathsCount;
}

@SuppressWarnings("unused")
public void incImpactPathsCount() {
this.impactPathsCount++;
}
}
9 changes: 4 additions & 5 deletions src/main/java/com/jfrog/ide/common/persistency/ScanCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
import com.jfrog.ide.common.log.Utils;
import com.jfrog.ide.common.nodes.FileTreeNode;
import lombok.Getter;
import org.jfrog.build.api.util.Log;

import java.io.File;
Expand All @@ -27,6 +28,7 @@
public class ScanCache {
private final File file;
private final ObjectMapper objectMapper;
@Getter
private ScanCacheObject scanCacheObject;

/**
Expand Down Expand Up @@ -68,10 +70,6 @@ public void cacheNodes(List<FileTreeNode> nodes) throws IOException {
objectMapper.writeValue(file, scanCacheObject);
}

public ScanCacheObject getScanCacheObject() {
return scanCacheObject;
}

public void deleteScanCacheObject() throws IOException {
if (file.exists()) {
if (!file.delete()) {
Expand All @@ -84,7 +82,8 @@ private void readCachedNodes(Log logger) throws IOException {
try {
scanCacheObject = objectMapper.readValue(file, ScanCacheObject.class);
if (scanCacheObject.getVersion() != ScanCacheObject.CACHE_VERSION) {
logger.warn("Invalid cache version " + scanCacheObject.getVersion() + ". Ignoring the old cache and starting a new one.");
logger.info("Invalid cache version " + scanCacheObject.getVersion() + ". Ignoring the old cache and starting a new one.");
scanCacheObject = null;
}
} catch (JsonParseException | JsonMappingException e) {
Utils.logError(logger, "Failed reading cache file. Ignoring the old cache and starting a new one.", e, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
@Getter
public class ScanCacheObject {
static int CACHE_VERSION = 4;
static int CACHE_VERSION = 5;

@JsonProperty("version")
int version = CACHE_VERSION;
Expand Down
Loading