From 4024a4fb174061230af114a6ed54bf3219ec49eb Mon Sep 17 00:00:00 2001 From: Gary O'Neall Date: Wed, 10 Feb 2021 17:04:35 -0800 Subject: [PATCH 1/2] Intemediate checkin - failing unit tests Signed-off-by: Gary O'Neall --- src/main/java/org/spdx/tag/BuildDocument.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/spdx/tag/BuildDocument.java b/src/main/java/org/spdx/tag/BuildDocument.java index ddb7ba0..fb8a565 100644 --- a/src/main/java/org/spdx/tag/BuildDocument.java +++ b/src/main/java/org/spdx/tag/BuildDocument.java @@ -65,6 +65,7 @@ import org.spdx.library.referencetype.ListedReferenceTypes; import org.spdx.storage.IModelStore; import org.spdx.storage.IModelStore.IdType; +import org.spdx.storage.simple.InMemSpdxStore; /** @@ -295,6 +296,7 @@ public void setProjectUri(String projectUri) throws InvalidSPDXAnalysisException private IModelStore modelStore; private String lastFileId = null; private String lastPackageId = null; + private IModelStore tempModelStore = new InMemSpdxStore(); public BuildDocument(IModelStore modelStore, Properties constants, List warnings) { this.constants = constants; @@ -696,7 +698,7 @@ private void buildDocumentProperties(String tag, String value, int lineNumber) t inSnippetDefinition = false; inExtractedLicenseDefinition = false; addLastPackage(); - this.lastPackage = new SpdxPackage(modelStore, documentNamespace, modelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later + this.lastPackage = new SpdxPackage(tempModelStore, documentNamespace, tempModelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later copyManager, true); this.lastPackage.setName(value); lastPackageLineNumber = lineNumber; @@ -712,7 +714,7 @@ private void buildDocumentProperties(String tag, String value, int lineNumber) t inSnippetDefinition = false; inExtractedLicenseDefinition = false; - this.lastFile = new SpdxFile(modelStore, documentNamespace, modelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later + this.lastFile = new SpdxFile(tempModelStore, documentNamespace, tempModelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later copyManager, true); this.lastFile.setName(value); lastFileLineNumber = lineNumber; @@ -741,7 +743,6 @@ private void addLastPackage() throws InvalidSPDXAnalysisException { } SpdxPackage newPkg = new SpdxPackage(modelStore, documentNamespace, lastPackageId, copyManager, true); newPkg.copyFrom(lastPackage); - modelStore.delete(documentNamespace, lastPackage.getId()); this.lastPackage = newPkg; elementIdLineNumberMap.put(lastPackageId, lastPackageLineNumber); lastPackageId = null; @@ -761,7 +762,6 @@ private void addLastFile() throws InvalidSPDXAnalysisException { } SpdxFile newFile = new SpdxFile(modelStore, documentNamespace, lastFileId, copyManager, true); newFile.copyFrom(this.lastFile); - modelStore.delete(documentNamespace, lastFile.getId()); for (String depdendeFileName:lastFileDependencies) { addFileDependency(newFile, depdendeFileName); } From 428defb3b14b9bf02e93afdf44434bb47f510837 Mon Sep 17 00:00:00 2001 From: Gary O'Neall Date: Wed, 10 Feb 2021 17:32:04 -0800 Subject: [PATCH 2/2] Add additional file creates to temporary model - still not working Signed-off-by: Gary O'Neall --- src/main/java/org/spdx/tag/BuildDocument.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spdx/tag/BuildDocument.java b/src/main/java/org/spdx/tag/BuildDocument.java index fb8a565..2135d40 100644 --- a/src/main/java/org/spdx/tag/BuildDocument.java +++ b/src/main/java/org/spdx/tag/BuildDocument.java @@ -743,7 +743,6 @@ private void addLastPackage() throws InvalidSPDXAnalysisException { } SpdxPackage newPkg = new SpdxPackage(modelStore, documentNamespace, lastPackageId, copyManager, true); newPkg.copyFrom(lastPackage); - this.lastPackage = newPkg; elementIdLineNumberMap.put(lastPackageId, lastPackageLineNumber); lastPackageId = null; this.lastPackage = null; @@ -765,6 +764,7 @@ private void addLastFile() throws InvalidSPDXAnalysisException { for (String depdendeFileName:lastFileDependencies) { addFileDependency(newFile, depdendeFileName); } + lastFileDependencies.clear(); lastFileId = null; if (lastPackage != null) { @@ -980,7 +980,7 @@ private void buildPackage(SpdxPackage pkg, String tag, String value, int lineNum lastRelationship.setComment(value); } else if (tag.equals(constants.getProperty("PROP_FILE_NAME"))) { addLastFile(); - this.lastFile = new SpdxFile(modelStore, documentNamespace, modelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later + this.lastFile = new SpdxFile(tempModelStore, documentNamespace, tempModelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later copyManager, true); this.lastFile.setName(value); this.inFileDefinition = true;