use of com.att.aro.core.bestpractice.pojo.MinificationEntry in project VideoOptimzer by attdevsupport.
the class BPConnectionsSimultnsTablePanel method getContentTable.
/**
* Initializes and returns the RequestResponseTable.
*/
@Override
@SuppressWarnings("unchecked")
public DataTable<MultipleConnectionsEntry> getContentTable() {
if (contentTable == null) {
contentTable = new DataTable<MinificationEntry>(tableModel);
contentTable.setName(ResourceBundleHelper.getMessageString("connections.multiple.simultaneous.tableName"));
contentTable.setAutoCreateRowSorter(true);
contentTable.setGridColor(Color.LIGHT_GRAY);
contentTable.setRowHeight(ROW_HEIGHT);
contentTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
TableRowSorter<TableModel> sorter = new TableRowSorter<>(tableModel);
contentTable.setRowSorter(sorter);
sorter.setComparator(SimultnsConnTableModel.COL_2, Util.getDomainSorter());
sorter.setComparator(SimultnsConnTableModel.COL_3, Util.getDomainSorter());
sorter.setComparator(SimultnsConnTableModel.COL_4, Util.getIntSorter());
sorter.toggleSortOrder(SimultnsConnTableModel.COL_1);
DataTablePopupMenu popupMenu = (DataTablePopupMenu) contentTable.getPopup();
popupMenu.initialize();
}
return contentTable;
}
use of com.att.aro.core.bestpractice.pojo.MinificationEntry in project VideoOptimzer by attdevsupport.
the class BpFileMinificationTablePanel method getContentTable.
/**
* Initializes and returns the RequestResponseTable.
*/
@SuppressWarnings("unchecked")
public DataTable<MinificationEntry> getContentTable() {
if (contentTable == null) {
contentTable = new DataTable<MinificationEntry>(tableModel);
contentTable.setName(ResourceBundleHelper.getMessageString("file.minify.tableName"));
contentTable.setAutoCreateRowSorter(true);
contentTable.setGridColor(Color.LIGHT_GRAY);
contentTable.setRowHeight(ROW_HEIGHT);
contentTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
DataTablePopupMenu popupMenu = (DataTablePopupMenu) contentTable.getPopup();
popupMenu.initialize();
}
return contentTable;
}
use of com.att.aro.core.bestpractice.pojo.MinificationEntry in project VideoOptimzer by attdevsupport.
the class MinificationImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
htmlCompressor = null;
MinificationResult result = new MinificationResult();
initHtmlCompressor();
List<MinificationEntry> minificationEntryList = new ArrayList<MinificationEntry>();
String contentType = null;
int totalSavingInBytes = 0;
int totalBytes = 0;
final ExecutorService executorService = Executors.newFixedThreadPool(50);
Collection<Worker> workers = new ArrayList<Worker>();
for (Session session : tracedata.getSessionlist()) {
HttpRequestResponseInfo lastRequestObj = null;
for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
if (req.getDirection() == HttpDirection.REQUEST) {
lastRequestObj = req;
}
contentType = req.getContentType();
if (req.getDirection() == HttpDirection.RESPONSE && req.getContentLength() > 0 && contentType != null) {
workers.add(new Worker(contentType, req, lastRequestObj, session));
// if (reqhelper.isJavaScript(contentType)) {
// entry = calculateSavingMinifiedJavascript(req, lastRequestObj, session);
// } else if (reqhelper.isCss(contentType)) {
// workers.add(new Worker(req, lastRequestObj, session));
// // Future<MinificationEntry> res1 = executorService.submit(new Worker(req, lastRequestObj, session);
// // entry = calculateSavingMinifiedCss(req, lastRequestObj, session);
// } else if (reqhelper.isHtml(contentType)) {
// entry = calculateSavingMinifiedHtml(req, lastRequestObj, session);
// } else if (reqhelper.isJSON(contentType)) {
// entry = calculateSavingMinifiedJson(req, lastRequestObj, session);
// }
// if (entry != null) {
// totalSavingInBytes += entry.getSavingsSizeInByte();
// minificationEntryList.add(entry);
// }
}
}
}
try {
List<Future<MinificationEntry>> list = executorService.invokeAll(workers);
for (Future<MinificationEntry> future : list) {
if (future != null && future.get() != null) {
totalSavingInBytes += future.get().getSavingsSizeInByte();
totalBytes += future.get().getOriginalSizeInByte();
minificationEntryList.add(future.get());
}
}
} catch (InterruptedException | ExecutionException ee) {
LOGGER.error(ee.getMessage(), ee);
}
executorService.shutdown();
int savingInKb = totalSavingInBytes / 1024;
result.setTotalSavingsInKb(savingInKb);
result.setTotalSavingsInByte(totalSavingInBytes);
result.setMinificationEntryList(minificationEntryList);
int numberOfFiles = minificationEntryList.size();
String text = "";
if (minificationEntryList.isEmpty()) {
result.setResultType(BPResultType.PASS);
text = MessageFormat.format(textResultPass, numberOfFiles, savingInKb);
result.setResultText(text);
result.setResultExcelText(BPResultType.PASS.getDescription());
} else if (savingInKb < 1) {
result.setResultType(BPResultType.FAIL);
text = MessageFormat.format(textResultFail, ApplicationConfig.getInstance().getAppShortName(), numberOfFiles);
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResultsFail, BPResultType.FAIL.getDescription(), numberOfFiles));
} else {
result.setResultType(BPResultType.FAIL);
String percentageSaving = String.valueOf(Math.round(((double) totalSavingInBytes / totalBytes) * 100));
text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), numberOfFiles, savingInKb, percentageSaving);
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), numberOfFiles, savingInKb, percentageSaving));
}
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
result.setExportAllNumberOfMinifyFiles(exportAllNumberOfMinifyFiles);
return result;
}
Aggregations