Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

feat(csv): adding data model to csv analyzer #194

Merged
merged 1 commit into from
Jun 18, 2019

Conversation

neubs-bsi
Copy link
Contributor

corresponding issue: #193

Currently Included:

  • Observed License
  • Source URL
  • Release Artifact URL
  • Software Heritage URL
  • coordinate type

Missing:
Due to belonging exclusively to SW360 data model at the moment

  • Change Status
  • Clearing State

Due to unclear format

  • CopyrightStatement

@@ -2,8 +2,8 @@
This analyzer investigates a given *csv* file. The format of this csv file follows this format:

```
"Artifact Id","Group Id","Version","License Short Name","License Long Name","File Name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the quotes? In CSV they are commonly used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a breaking change or is this still able to parse the "old" CSV files?

private static final String SOURCE_URL = "Source URL";
private static final String RELEASE_ARTIFACT_URL = "Release Artifact URL";
private static final String SWH_URL = "Software Heritage URL";
// private static final String ClEARING_STATE = "Clearing State";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code

return license;
}

private void mapCoordinate(Artifact artifact, CSVRecord record) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of this style of coding with mutations it would maybe be more consistent to use the same pattern as for createLicense e.g.

Suggested change
private void mapCoordinate(Artifact artifact, CSVRecord record) {
private FactOrSomeOtherMatchingClass mapCoordinate(CSVRecord record) {

@@ -1,2 +1,2 @@
Artifact Id,Group Id,Version,License Short Name,License Long Name,File Name
commons-csv,org.apache.commons,1.4,Apache-2.0,Apache Software License 2.0,commons-csv.jar
Artifact Id,Group Id,Version,License Short Name,License Long Name,File Name,Coordinate Type,Observed License Short Name,Observed License Long Name,Source URL,Release Artifact URL,Software Heritage URL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a test, that the old CSV format is still supported?

@neubs-bsi neubs-bsi mentioned this pull request Jun 17, 2019
26 tasks
```

Note: In the previous documentation the format was given with the headers of the csv columns in quotation marks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note is unnecessary, this is common behaviour of csv.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the quotation marks again and took the note out

@neubs-bsi neubs-bsi force-pushed the neubs-bsi/csvAnalyzer/744 branch 2 times, most recently from 97cb581 to 5e56cbd Compare June 17, 2019 11:27
artifact.addFact(new ArtifactReleaseTagURL(record.get(RELEASE_ARTIFACT_URL)));
}
if(record.isMapped(SWH_URL)) {
artifact.addFact(new ArtifactSoftwareHeritageURL(record.get(SWH_URL)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatted. Also removed two redundant imports from CSVAnalyzerTest

@neubs-bsi neubs-bsi force-pushed the neubs-bsi/csvAnalyzer/744 branch 2 times, most recently from f4e459a to 8402d3b Compare June 18, 2019 07:27
Signed-off-by: Stephanie <stephanie.neubauer@bosch-si.com>
Signed-off-by: Stephanie Neubauer <Stephanie.Neubauer@bosch-si.com>
@neubs-bsi
Copy link
Contributor Author

It should work now, but @maxhbr do not merge yet, since I want to find out why MatchState is necessary before merging.

@neubs-bsi
Copy link
Contributor Author

Source of previous failing of Rule Engine has been determined:
https://github.com/eclipse/antenna/blob/17f055e7728ece7a0cbcc71189394b11962cb3f8/core/model/src/main/java/org/eclipse/sw360/antenna/model/artifact/Artifact.java#L79-L83
sets MatchState default to UNKNOWN and
assembly/common-rules/src/main/resources/policies/rules/A1_Unknown_Artifact.drl
fails when Matchstate is UNKNOWN.
This is okay. @maxhbr PR can be merged

@maxhbr maxhbr merged commit 298cd52 into eclipse-archived:master Jun 18, 2019
@blaumeiser-at-bosch blaumeiser-at-bosch deleted the neubs-bsi/csvAnalyzer/744 branch June 28, 2019 07:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants