return copyValuesForKnownBundle(from, null, null);
}
private ListGridRecord copyValuesForKnownBundle(Object from, Integer bundleGroupId, Integer bundleId) {
String parentID;
TreeNode node = new TreeNode();
String sortValue = "";
if (from instanceof BundleGroup) {
BundleGroup bundleGroup = (BundleGroup) from;
node.setIsFolder(true);
node.setIcon("subsystems/bundle/BundleGroup_16.png");
node.setID(String.valueOf(bundleGroup.getId()));
node.setName(StringUtility.escapeHtml(bundleGroup.getName()));
if (bundleGroup.getId() == 0) {
node.setEnabled(false);
sortValue = "\uFFFDZZZZ"; // always show this as the last folder node in the tree
} else{
sortValue = bundleGroup.getName();
}
} else if (from instanceof Bundle) {
Bundle bundle = (Bundle) from;
node.setIsFolder(true);
node.setIcon("subsystems/bundle/Bundle_16.png");
node.setID(String.valueOf(bundleGroupId) + "_" + bundle.getId());
node.setParentID(String.valueOf(bundleGroupId));
node.setName(StringUtility.escapeHtml(bundle.getName()));
sortValue = bundle.getName();
} else if (from instanceof BundleVersion) {
BundleVersion version = (BundleVersion) from;
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleVersion_16.png");
parentID = bundleGroupId.toString() + "_" + version.getBundle().getId() + "_versions";
node.setParentID(parentID);
node.setID(parentID + '_' + version.getId());
node.setName(version.getVersion());
sortValue = NumberFormat.getFormat("000000").format(version.getVersionOrder());
} else if (from instanceof BundleDeployment) {
BundleDeployment deployment = (BundleDeployment) from;
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleDeployment_16.png");
parentID = bundleGroupId.toString() + "_" + bundleId + "_destinations_" + deployment.getDestination().getId();
node.setParentID(parentID);
node.setID(bundleGroupId.toString() + "_" + bundleId + "_deployments_" + deployment.getId());
String name = StringUtility.escapeHtml(deployment.getName());
if (deployment.isLive()) {
node.setName("<span style=\"color: green; font-weight: bold\">(live)</span> " + name);
} else {
node.setName(name);
}
sortValue = deployment.getName();
} else if (from instanceof BundleDestination) {
BundleDestination destination = (BundleDestination) from;
node.setIsFolder(true);
node.setIcon("subsystems/bundle/BundleDestination_16.png");
parentID = bundleGroupId.toString() + "_" + destination.getBundle().getId() + "_destinations";
node.setParentID(parentID);
node.setID(parentID + '_' + destination.getId());
node.setName(StringUtility.escapeHtml(destination.getName()));
sortValue = destination.getName();
}
node.setAttribute(FIELD_SORT_VALUE, sortValue.toLowerCase());
return node;
}