@Override
public ListGridRecord copyValues(AlertDefinition from) {
ListGridRecord record = super.copyValues(from);
Integer parentId = from.getParentId(); // a valid non-zero number means the alert def came from a template
AlertDefinition groupAlertDefinition = from.getGroupAlertDefinition();
boolean readOnly = from.isReadOnly();
if ((parentId == null || parentId.intValue() == 0) && (groupAlertDefinition == null)) {
record.setAttribute(FIELD_PARENT, "");
record.setLinkText("");
record.setAttribute(FIELD_READONLY, MSG.common_val_na());
} else {
if (parentId != null && parentId.intValue() != 0) {
record.setAttribute(
FIELD_PARENT,
LinkManager.getAdminTemplatesEditLink(AlertDefinitionTemplateTypeView.VIEW_ID.getName(),
this.resource.getResourceType().getId()) + "/" + parentId);
record.setLinkText(MSG.view_alert_definition_for_type());
} else {
boolean isAutogroup = groupAlertDefinition.getGroup().getAutoGroupParentResource() != null;
if (isAutogroup) {
record.setAttribute(FIELD_PARENT, "#Resource/AutoGroup/"
+ groupAlertDefinition.getGroup().getId() + "/Alerts/Definitions/" + groupAlertDefinition.getId());
}
else {
boolean isAutoCluster = groupAlertDefinition.getGroup().getClusterResourceGroup() != null;
if (isAutoCluster) {
record.setAttribute(FIELD_PARENT, "#ResourceGroup/AutoCluster/"
+ groupAlertDefinition.getGroup().getId() + "/Alerts/Definitions/" + groupAlertDefinition.getId());
}
else {
record.setAttribute(FIELD_PARENT, "#ResourceGroup/"
+ groupAlertDefinition.getGroup().getId() + "/Alerts/Definitions/" + groupAlertDefinition.getId());
}
}
record.setLinkText(MSG.view_alert_definition_for_group());
}
record.setAttribute(FIELD_READONLY, (readOnly) ? MSG.common_val_yes() : MSG.common_val_no());