@include("../commons/styles.html") @include("../commons/images.html") @args() { List location_ids String client_name List client_ids List BACKUP_TYPES_L2 List BACKUP_TYPES_L3 List> items Map info Locale locale String date_column String fromDate String toDate String defaultDataSize de.sep.sesam.util.RendererUtils rendererUtils } @returnIf(location_ids == null || location_ids.isEmpty()) @returnIf(client_ids == null || client_ids.isEmpty()) @returnIf(items == null || items.isEmpty()) @*Queries: * [ * { * "paramName" : "client_name", * "query" : [ * "SELECT", * "name", * "FROM", * "clients", * "WHERE", * "client_id = 0" * ], * "converter" : [ * "toString(name)" * ] * }, * { * "paramName" : "location_ids", * "condition" : [ * "@returnIf(@(exist:location_ids))" * ], * "query" : [ * "SELECT", * "id", * "FROM", * "locations", * "WHERE", * "parent IS NULL", * "ORDER BY", * "id" * ], * "converter" : [ * "toList(id)" * ] * }, * { * "paramName" : "client_ids", * "condition" : [ * "@returnIf(location_ids == null || location_ids.isEmpty())" * ], * "query" : [ * "SELECT", * "client_id", * "FROM", * "clients", * "WHERE", * "location in (WITH RECURSIVE children(id) AS (SELECT l.id FROM locations l WHERE l.id IN @(sqlList:@(location_ids)", * "UNION ALL SELECT l.id from children c,locations l where l.parent=c.id) SELECT * FROM children)" * ], * "converter" : [ * "toList(client_id)" * ] * }, * { * "paramName" : "items", * "condition" : [ * "@returnIf(client_ids == null || client_ids.isEmpty())" * ], * "query" : [ * "SELECT", * "c.location,", * "l.name AS location_name,", * "c.client_id,", * "c.name,", * "CASE", * "WHEN c.accessmode = 'VIRTUAL' THEN true", * "WHEN c.vm_host IS NOT NULL AND c.vm_host != '' AND c.vm_name IS NOT NULL AND c.vm_name != '' THEN true", * "ELSE false", * "END AS is_virtual_machine,", * "(select count(*) from tasks where tasks.client_id = c.client_id) AS total_tasks,", * "(select count(*) from tasks where tasks.client_id = c.client_id and tasks.backup_type in @(sqlList:@(BACKUP_TYPES_L2)) ) AS level2_tasks,", * "(select count(*) from tasks where tasks.client_id = c.client_id and tasks.backup_type in @(sqlList:@(BACKUP_TYPES_L3)) ) AS level3_tasks", * "FROM", * "clients c", * "LEFT OUTER JOIN", * "(WITH RECURSIVE children (id, name) AS", * "(SELECT l.id, l.name FROM locations l WHERE l.id IN @(sqlList:@(location_ids)", * " UNION ALL SELECT l.id, c.name from children c,locations l where l.parent=c.id)", * "SELECT * FROM children) AS l", * "ON", * "l.id = c.location", * "WHERE", * "c.client_id IN @(sqlList:@(client_ids)", * "ORDER BY", * "l.name,", * "c.client_id" * ] * } * ] *@ @include("../commons/tags.html") @include("../commons/functions.html") @sepReportHeader("SEP Report")

@sepTitleBox("Title", sepFnGetToday(locale), client_name)

@{ Integer location_id = null; String location_name = null; long total = 0; long noTask = 0; long vms = 0; long l1 = 0; long l2 = 0; long l3 = 0; boolean print = false; } @for (Map item : items) { @{ Integer id = (Integer) item.get("location"); String name = (String) item.get("location_name"); if (location_id == null) { location_id = id; } if (location_name == null) { location_name = name; } if (!location_name.equals(name)) { print = true; } else { total++; boolean isLevel2 = ((Integer) item.get("level2_tasks")).intValue() > 0; boolean isLevel3 = ((Integer) item.get("level3_tasks")).intValue() > 0; boolean isNoTask = ((Integer) item.get("total_tasks")).intValue() == 0; boolean isVm = Boolean.valueOf((String) item.get("is_virtual_machine")).booleanValue(); // When the client is a VM, check for tasks. // If tasks exists for this client, then the client // is "upgraded" to level 2. if (isVm && !isNoTask) { isLevel2 = true; isVm = false; } if (isLevel3) { l3++; } else if (isLevel2) { l2++; } else if (isVm) { vms++; } else if (isNoTask) { noTask++; } else { l1++; } } } @if(print) { @i18n("Location.Name"): @(location_name)

@i18n("Label.Total") @(total)
@i18n("Label.NoTask") @(noTask)
@i18n("Label.VMS") @(vms)
@i18n("Label.L1") @(l1)
@i18n("Label.L2") @(l2)
@i18n("Label.L3") @(l3)

@{ print = false; location_id = id; location_name = name; boolean isLevel2 = ((Integer) item.get("level2_tasks")).intValue() > 0; boolean isLevel3 = ((Integer) item.get("level3_tasks")).intValue() > 0; boolean isNoTask = ((Integer) item.get("total_tasks")).intValue() == 0; boolean isVm = Boolean.valueOf((String) item.get("is_virtual_machine")).booleanValue(); total = 1; noTask = 0; vms = 0; l1 = 0; l2 = 0; l3 = 0; if (isVm && !isNoTask) { isLevel2 = true; isVm = false; } if (isLevel3) { l3++; } else if (isLevel2) { l2++; } else if (isVm) { vms++; } else if (isNoTask) { noTask++; } else { l1++; } } } } @if(location_id != null || print) { @i18n("Location.Name"): @(location_name)

@i18n("Label.Total") @(total)
@i18n("Label.NoTask") @(noTask)
@i18n("Label.VMS") @(vms)
@i18n("Label.L1") @(l1)
@i18n("Label.L2") @(l2)
@i18n("Label.L3") @(l3)

}