@include("../commons/styles.html") @include("../commons/images.html") @args() { List location_ids String client_name List client_ids List MSP_UNIT_BACKUP_TYPES_VIRT List MSP_UNIT_BACKUP_TYPES_L3 List> items Map info Locale locale String date_column String fromDate String toDate String defaultDataSize de.sep.sesam.util.RendererUtils rendererUtils } @*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 1", * "WHEN c.vm_host IS NOT NULL AND c.vm_host != '' AND c.vm_name IS NOT NULL AND c.vm_name != '' THEN 1", * "ELSE 0", * "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:@(MSP_UNIT_BACKUP_TYPES_VIRT)) ) AS virt_tasks,", * "(select count(*) from tasks where tasks.client_id = c.client_id and tasks.backup_type in @(sqlList:@(MSP_UNIT_BACKUP_TYPES_L3)) ) AS level3_tasks,", * "(select count(*) from tasks where tasks.client_id = c.client_id and tasks.backup_type not in @(sqlList:@(MSP_UNIT_BACKUP_TYPES_VIRT)) and tasks.backup_type not in @(sqlList:@(MSP_UNIT_BACKUP_TYPES_L3)) ) AS other_tasks,", * "(select count(distinct source) from tasks where tasks.client_id = c.client_id and tasks.backup_type in @(sqlList:@(MSP_UNIT_BACKUP_TYPES_VIRT)) ) AS distinct_sources", * "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)

@returnIf(location_ids == null || location_ids.isEmpty()) @returnIf(client_ids == null || client_ids.isEmpty()) @returnIf(items == null || items.isEmpty()) @{ Long location_id = null; String location_name = null; long noTask = 0; long l1 = 0; long l2 = 0; long l3 = 0; long total_noTask = 0; long total_l1 = 0; long total_l2 = 0; long total_l3 = 0; boolean print = false; } @for (Map item : items) { @{ Long id = (Long) 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 { long total_tasks = ((Long) item.get("total_tasks")).longValue(); long virt_tasks = ((Long) item.get("virt_tasks")).longValue(); long level3_tasks = ((Long) item.get("level3_tasks")).longValue(); long other_tasks = ((Long) item.get("other_tasks")).longValue(); long distinct_sources = ((Long) item.get("distinct_sources")).longValue(); long isVirtualMachine = ((Long) item.get("is_virtual_machine")).longValue(); // Client is a physical client -> Level 3 if (isVirtualMachine == 0) { l1++; l3++; if (distinct_sources > 0) { l1 += distinct_sources; } continue; } // Client without task -> Level 1 if (total_tasks == 0) { noTask++; l1++; continue; } // Client with only virtualization tasks -> count client and distinct sources as Level 1 if (total_tasks == virt_tasks && level3_tasks == 0 && other_tasks == 0) { l1++; l1 += distinct_sources; continue; } if (total_tasks > virt_tasks) { l1++; if (distinct_sources > 0) { l1 += distinct_sources; } if (level3_tasks == 0 && other_tasks > 0) { l2++; } else if (level3_tasks > 0) { l3++; } } } } @if(print) { @i18n("Location.Name"): @(location_name)

@i18n("Label.NoTask") @(noTask)
@i18n("Label.L1") @(l1)
@i18n("Label.L2") @(l2)
@i18n("Label.L3") @(l3)

@{ print = false; location_id = id; location_name = name; total_noTask += noTask; total_l1 += l1; total_l2 += l2; total_l3 += l3; noTask = 0; l1 = 0; l2 = 0; l3 = 0; long total_tasks = ((Long) item.get("total_tasks")).longValue(); long virt_tasks = ((Long) item.get("virt_tasks")).longValue(); long level3_tasks = ((Long) item.get("level3_tasks")).longValue(); long other_tasks = ((Long) item.get("other_tasks")).longValue(); long distinct_sources = ((Long) item.get("distinct_sources")).longValue(); long isVirtualMachine = ((Long) item.get("is_virtual_machine")).longValue(); // Client without task -> Level 1 if (total_tasks == 0) { noTask++; l1++; continue; } // Client with only virtualization tasks -> count client and distinct sources as Level 1 if (total_tasks == virt_tasks && level3_tasks == 0 && other_tasks == 0) { l1++; l1 += distinct_sources; continue; } if (total_tasks > virt_tasks) { l1++; if (distinct_sources > 0) { l1 += distinct_sources; } if (level3_tasks == 0 && other_tasks > 0) { l2++; } else if (level3_tasks > 0) { l3++; } } } } } @if(location_id != null || print) { @i18n("Location.Name"): @(location_name)

@i18n("Label.NoTask") @(noTask)
@i18n("Label.L1") @(l1)
@i18n("Label.L2") @(l2)
@i18n("Label.L3") @(l3)

@{ total_noTask += noTask; total_l1 += l1; total_l2 += l2; total_l3 += l3; } } @if(total_noTask != noTask) {
@i18n("Label.Total"):

@i18n("Label.NoTask") @(total_noTask)
@i18n("Label.L1") @(total_l1)
@i18n("Label.L2") @(total_l2)
@i18n("Label.L3") @(total_l3)

}