Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
Merge pull request #391 from sw360/fix/spreadsheetDuplicateColNames#354
Browse files Browse the repository at this point in the history
Add prefixes to duplicate column headers in spreadsheet exports
review-by: [email protected]
tested-by: [email protected]
  • Loading branch information
alexbrdn authored May 10, 2017
2 parents a37363b + 98386e0 commit 14654e0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Siemens AG, 2013-2015. Part of the SW360 Portal Project.
* Copyright Siemens AG, 2013-2017. Part of the SW360 Portal Project.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -72,7 +72,7 @@ public ComponentExporter(ComponentService.Iface componentClient, boolean extende
.map(n -> SW360Utils.displayNameFor(n, nameToDisplayName))
.collect(Collectors.toList());
if(extendedByReleases){
HEADERS.addAll(releaseHelper.getHeaders());
addSubheadersWithPrefixesAsNeeded(HEADERS, releaseHelper.getHeaders(), "release: ");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Siemens AG, 2014-2015. Part of the SW360 Portal Project.
* Copyright Siemens AG, 2014-2017. Part of the SW360 Portal Project.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.stream.Collectors;

/**
* Created on 06/02/15.
Expand Down Expand Up @@ -117,4 +118,13 @@ private static CellStyle createHeaderStyle(Workbook workbook) {
headerCellStyle.setFont(font);
return headerCellStyle;
}

protected List<String> addSubheadersWithPrefixesAsNeeded(List<String> headers, List<String> subheaders, String prefix) {
List<String> prefixedSubheaders = subheaders
.stream()
.map(h -> headers.contains(h) ? prefix + h : h)
.collect(Collectors.toList());
headers.addAll(prefixedSubheaders);
return headers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public ProjectExporter(ComponentService.Iface componentClient, ProjectService.If
.map(n -> SW360Utils.displayNameFor(n, nameToDisplayName))
.collect(Collectors.toList());
if (extendedByReleases) {
((ArrayList) HEADERS).addAll(releaseHelper.getHeaders());
addSubheadersWithPrefixesAsNeeded(HEADERS, releaseHelper.getHeaders(), "release: ");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Siemens AG, 2013-2015. Part of the SW360 Portal Project.
* Copyright Siemens AG, 2013-2017. Part of the SW360 Portal Project.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -49,6 +49,7 @@ public class ReleaseExporter extends ExcelExporter<Release> {
nameToDisplayName.put(Release._Fields.MAIN_LICENSE_IDS.getFieldName(), "main license IDs");
nameToDisplayName.put(Release._Fields.DOWNLOADURL.getFieldName(), "downloadurl");
nameToDisplayName.put(Release._Fields.RELEASE_ID_TO_RELATIONSHIP.getFieldName(), "releases with relationship");
nameToDisplayName.put(Release._Fields.OPERATING_SYSTEMS.getFieldName(), "operating systems");
}

private static final List<Release._Fields> RELEASE_IGNORED_FIELDS = ImmutableList.<Release._Fields>builder()
Expand Down

0 comments on commit 14654e0

Please sign in to comment.