use of com.att.aro.core.packetanalysis.pojo.TimeRange.TimeRangeType in project VideoOptimzer by attdevsupport.
the class AROFileMenu method openTraceFolder.
/**
* Choose a trace folder for direct analysis
*
* @param aEvent
* @param isRecent
* @return
*/
private void openTraceFolder(ActionEvent aEvent, boolean isRecent) {
File traceFolder = null;
Object event = aEvent.getSource();
if (event instanceof JMenuItem) {
if ((traceFolder = selectTraceFolder(aEvent, isRecent)) != null) {
File trj;
TimeRange timeRange = null;
if ((trj = new File(traceFolder, "time-range.json")).exists()) {
try {
String jsonData = fileManager.readAllData(trj.getPath());
if (!jsonData.contains("\"timeRangeType\" : \"DEFAULT\",")) {
JDialog splash = new TransitionDialog(parent.getFrame(), "Time-Range file detected\n", "Preparing to open in Time-Range chooser/editor dialog");
TimeRangeEditorDialog dialog;
try {
if ((dialog = displayTimeRangeEditor(traceFolder, true, splash)) != null && dialog.isContinueWithAnalyze()) {
timeRange = dialog.getTimeRange();
} else {
LOG.debug("Time-Range, Selection cancelled by user");
splash.dispose();
return;
}
} catch (Exception e) {
LOG.error("Exception in TimeRangeDialog:", e);
new MessageDialogFactory().showErrorDialog(null, "Exception in TimeRangeDialog:" + e.getMessage());
return;
}
} else {
TraceTimeRange traceTimeRange;
if ((traceTimeRange = timeRangeReadWrite.readData(traceFolder)) != null) {
if (traceTimeRange.getTimeRangeList().stream().filter(a -> a.getTimeRangeType().equals(TimeRangeType.DEFAULT)).count() > 1) {
LOG.error("Too many TimeRanges set to AUTO");
MessageDialogFactory.getInstance().showErrorDialog(parent.getFrame(), "Too many TimeRanges set to AUTO, please fix the selections");
return;
}
Optional<TimeRange> optionalTimeRange = traceTimeRange.getTimeRangeList().stream().filter(p -> p.getTimeRangeType().equals(TimeRange.TimeRangeType.DEFAULT)).findFirst();
if (optionalTimeRange.isPresent()) {
timeRange = optionalTimeRange.get();
}
}
}
} catch (IOException e) {
LOG.error("Problem reading time-range.json", e);
}
}
if (timeRange != null) {
launchTraceFolderAnalysis(traceFolder, timeRange);
} else {
launchTraceFolderAnalysis(traceFolder);
}
} else {
LOG.error("Invalid trace folder selected, no traffic file");
}
}
}
Aggregations