Skip to content

Commit f6efc43

Browse files
authored
Merge pull request #2074 from davidmundelius/add-field-waspreferred
Add wasPreferred field to package info and schemas
2 parents e8a5fc7 + e3ddfe3 commit f6efc43

File tree

12 files changed

+35
-16
lines changed

12 files changed

+35
-16
lines changed

example-files/opossum_input.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@
233233
"licenseName": "The MIT License (MIT)",
234234
"copyright": "Copyright (c) 2013-present, Yuxi (Evan) You\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
235235
"licenseText": "The MIT License (MIT)\n\nCopyright (c) 2013-present, Yuxi (Evan) You\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
236-
"originId": "1eb75f3b-fc84-e781-ad9d-d46d6d61abf2"
236+
"originId": "1eb75f3b-fc84-e781-ad9d-d46d6d61abf2",
237+
"wasPreferred": true
237238
},
238239
"5f1948d6-63fa-4f7e-b02b-7799083511fc": {
239240
"source": {

src/ElectronBackend/input/OpossumInputFileSchema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
"items": {
161161
"type": "string"
162162
}
163+
},
164+
"wasPreferred":{
165+
"type": "boolean",
166+
"description": "Indicates that the attribution had previously been marked as preferred."
163167
}
164168
},
165169
"required": ["source"],

src/ElectronBackend/input/OpossumOutputFileSchema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
"items": {
121121
"type": "string"
122122
}
123+
},
124+
"wasPreferred":{
125+
"type": "boolean",
126+
"description": "Indicates that the attribution had previously been marked as preferred."
123127
}
124128
},
125129
"required": [],

src/ElectronBackend/input/__tests__/importFromFile.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const inputFileContent: ParsedOpossumInputFile = {
9494
criticality: Criticality.High,
9595
preferred: true,
9696
preferredOverOriginIds: ['test-id'],
97+
wasPreferred: true,
9798
},
9899
},
99100
frequentLicenses: [
@@ -142,6 +143,7 @@ const expectedFileContent: ParsedFileContent = {
142143
criticality: Criticality.High,
143144
preferred: true,
144145
preferredOverOriginIds: ['test-id'],
146+
wasPreferred: true,
145147
},
146148
},
147149
resourcesToAttributions: {

src/ElectronBackend/output/__tests__/writeCsvToFile.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { createTempFolder, deleteFolder } from '../../test-helpers';
1919
const testCsvHeader =
2020
'"Index";"Confidence";"Comment";"Package Name";"Package Version";"Package Namespace";' +
2121
'"Package Type";"PURL Appendix";"URL";"Copyright";"License Name";"License Text (truncated)";"Source";"First Party";' +
22-
'"Follow-up";"Origin Attribution IDs";"pre-selected";"exclude-from-notice";"criticality";"needs-review";"preferred";"preferred-over-origin-ids";"Resources"';
22+
'"Follow-up";"Origin Attribution IDs";"pre-selected";"exclude-from-notice";"criticality";"needs-review";"preferred";"preferred-over-origin-ids";"was-preferred";"Resources"';
2323

2424
describe('writeCsvToFile', () => {
2525
it('writeCsvToFile short', async () => {
@@ -46,13 +46,13 @@ describe('writeCsvToFile', () => {
4646
const content = await fs.promises.readFile(csvPath, 'utf8');
4747
expect(content).toContain(testCsvHeader);
4848
expect(content).toContain(
49-
'"1";"";"";"";"";"";"";"";"";"";"";"license text, with; commas";"";"true";"";"";"";"";"";"";"";"";"/test.file"',
49+
'"1";"";"";"";"";"";"";"";"";"";"";"license text, with; commas";"";"true";"";"";"";"";"";"";"";"";"";"/test.file"',
5050
);
5151
expect(content).toContain(
52-
'"2";"";"";"Fancy name,: tt";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/c/bla.mm"',
52+
'"2";"";"";"Fancy name,: tt";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/c/bla.mm"',
5353
);
5454
expect(content).toContain(
55-
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/b"',
55+
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/b"',
5656
);
5757
deleteFolder(temporaryPath);
5858
});
@@ -117,10 +117,10 @@ describe('writeCsvToFile', () => {
117117
const content = await fs.promises.readFile(csvPath, 'utf8');
118118
expect(content).toContain(testCsvHeader);
119119
expect(content).toContain(
120-
'"1";"";"";"";"";"";"";"";"";"";"";"license text, with; commas";"";"true";"";"";"";"";"";"";"";"";"/test.file"',
120+
'"1";"";"";"";"";"";"";"";"";"";"";"license text, with; commas";"";"true";"";"";"";"";"";"";"";"";"";"/test.file"',
121121
);
122122
expect(content).toContain(
123-
'"2";"";"";"Fancy name,: tt";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/c/bla.mm\n' +
123+
'"2";"";"";"Fancy name,: tt";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/c/bla.mm\n' +
124124
'/b"',
125125
);
126126
deleteFolder(temporaryPath);
@@ -163,10 +163,10 @@ describe('writeCsvToFile', () => {
163163
const content = await fs.promises.readFile(csvPath, 'utf8');
164164
expect(content).toContain(testCsvHeader);
165165
expect(content).toContain(
166-
'"1";"";"";"";"";"";"";"";"";"";"";"license text, with; commas";"";"true";"";"";"";"";"";"";"";"";"/test.file"',
166+
'"1";"";"";"";"";"";"";"";"";"";"";"license text, with; commas";"";"true";"";"";"";"";"";"";"";"";"";"/test.file"',
167167
);
168168
expect(content).toContain(
169-
`"2";"";"";"Fancy name,: tt";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"${expectedResources}"`,
169+
`"2";"";"";"Fancy name,: tt";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"${expectedResources}"`,
170170
);
171171
deleteFolder(temporaryPath);
172172
});
@@ -453,25 +453,25 @@ describe('writeCsvToFile', () => {
453453
const content = await fs.promises.readFile(csvPath, 'utf8');
454454
expect(content).toContain(testCsvHeader);
455455
expect(content).toContain(
456-
'"1";"";"";"";"";"";"";"";"";"";"";"license text, with; commas";"";"true";"";"";"";"";"";"";"";"";"/test.file"',
456+
'"1";"";"";"";"";"";"";"";"";"";"";"license text, with; commas";"";"true";"";"";"";"";"";"";"";"";"";"/test.file"',
457457
);
458458
expect(content).toContain(
459-
`"2";"";"";"Fancy name with long license";"";"";"";"";"";"";"";"${expectedLicenseText}";"";"";"";"";"";"";"";"";"";"";"/a"`,
459+
`"2";"";"";"Fancy name with long license";"";"";"";"";"";"";"";"${expectedLicenseText}";"";"";"";"";"";"";"";"";"";"";"";"/a"`,
460460
);
461461
expect(content).toContain(
462-
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/b"',
462+
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/b"',
463463
);
464464
expect(content).toContain(
465-
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/b/c"',
465+
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/b/c"',
466466
);
467467
expect(content).toContain(
468-
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/b/c/testi.bla"',
468+
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/b/c/testi.bla"',
469469
);
470470
expect(content).toContain(
471-
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/b/c/testi.blub"',
471+
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/a/b/c/testi.blub"',
472472
);
473473
expect(content).toContain(
474-
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/other"',
474+
'"2";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"/other"',
475475
);
476476
deleteFolder(temporaryPath);
477477
});

src/ElectronBackend/output/writeCsvToFile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export function getHeadersFromColumns(columns: Array<KeysOfAttributionInfo>): {
9393
needsReview: 'needs-review',
9494
preferred: 'preferred',
9595
preferredOverOriginIds: 'preferred-over-origin-ids',
96+
wasPreferred: 'was-preferred',
9697
};
9798

9899
const headers: { [key: string]: string } = {};

src/ElectronBackend/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ interface RawPackageInfo {
6363
needsReview?: boolean;
6464
preferred?: boolean;
6565
preferredOverOriginIds?: Array<string>;
66+
wasPreferred?: boolean;
6667
}
6768

6869
export interface RawAttributions {

src/Frontend/Components/ReportTableItem/report-table-item-helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function getFormattedCellData(
3131
case 'needsReview':
3232
case 'excludeFromNotice':
3333
case 'preferred':
34+
case 'wasPreferred':
3435
cellData = attributionInfo[config.attributionProperty] ? 'Yes' : 'No';
3536
break;
3637
case 'icons':

src/Frontend/util/__tests__/convert-package-info.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('convertPackageInfoToDisplayPackageInfo', () => {
5555
'needsReview',
5656
'preferred',
5757
'preferredOverOriginIds',
58+
'wasPreferred',
5859
];
5960
expect(testKeysOfPackageInfo).toEqual(expectedKeysOfPackageInfo);
6061
});
@@ -137,6 +138,7 @@ describe('convertDisplayPackageInfoToPackageInfo', () => {
137138
'attributionIds',
138139
'preferred',
139140
'preferredOverOriginIds',
141+
'wasPreferred',
140142
];
141143
expect(testKeysOfDisplayPackageInfo).toEqual(
142144
expectedKeysOfDisplayPackageInfo,

src/Frontend/util/get-display-package-info-keys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function getDisplayPackageInfoKeys(): Array<KeysOfDisplayPackageInfo> {
3131
attributionIds: true,
3232
preferred: true,
3333
preferredOverOriginIds: true,
34+
wasPreferred: true,
3435
};
3536
return Object.keys(
3637
displayPackageInfoKeysObject,

0 commit comments

Comments
 (0)