Merge pull request #5019 from raman-bt/5237-ig-dup-ds

5237: Duplicate datasources do not show in the ImageGallery Path grou…
This commit is contained in:
Richard Cordovano 2019-07-10 10:22:46 -04:00 committed by GitHub
commit 7065bd036f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -189,7 +189,7 @@ class GroupCellFactory {
@Override
public String getGroupName() {
return Optional.ofNullable(getItem())
.map(treeNode -> StringUtils.defaultIfBlank(treeNode.getPath(), DrawableGroup.getBlankGroupName()))
.map(treeNode -> StringUtils.defaultIfBlank(treeNode.getDisplayName(), DrawableGroup.getBlankGroupName()))
.orElse("");
}

View File

@ -158,6 +158,11 @@ final public class GroupTree extends NavPanel<TreeItem<GroupTreeNode>> {
String path = g.getGroupByValueDislpayName();
if (g.getGroupByAttribute() == DrawableAttribute.PATH) {
String[] cleanPathTokens = StringUtils.stripStart(path, "/").split("/");
// Append obj id to the top level data source name to allow for duplicate data source names
if (g.getGroupKey().getDataSourceObjId() > 0) {
cleanPathTokens[0] = cleanPathTokens[0].concat(String.format("(Id: %d)", g.getGroupKey().getDataSourceObjId()));
}
return Arrays.asList(cleanPathTokens);
} else {
String stripStart = StringUtils.strip(path, "/");

View File

@ -27,6 +27,7 @@ class GroupTreeNode {
private final String path;
private DrawableGroup group;
private final String dispName;
public String getPath() {
return path;
@ -36,9 +37,20 @@ class GroupTreeNode {
return group;
}
GroupTreeNode(String path, DrawableGroup group) {
public String getDisplayName() {
return dispName;
}
GroupTreeNode(String path, DrawableGroup group) {
this.path = path;
this.group = group;
// If the path has a obj id, strip it for display purpose.
if (path.toLowerCase().contains(("(Id: ").toLowerCase())) {
dispName = path.substring(0, path.indexOf("(Id: "));
} else {
dispName = path;
}
}
void setGroup(DrawableGroup g) {