protected void checkChartSelectionValidity() { try { chartedEvtDef = EventDefinition.valueOfEventInfo(chartedEvtDef.getEventDefinitionRef()); } catch (NoSuchFieldException e) { LOGGER.warn( "Event info as been disabled or deleted. Removing from chart indicators selection : " + chartedEvtDef); chartedEvtDef = EventDefinition.ZERO; } SortedSet<EventInfo> updatedChartedEvtDefsTrends = initChartedEvtDefsTrendsSet(); for (EventInfo eventInfo : chartedEvtDefsTrends) { try { updatedChartedEvtDefsTrends.add( EventDefinition.valueOfEventInfo(eventInfo.getEventDefinitionRef())); } catch (NoSuchFieldException e) { LOGGER.warn( "Event info as been disabled or deleted. Removing from chart trend selection : " + eventInfo); } } chartedEvtDefsTrends = updatedChartedEvtDefsTrends; }
public TuningResDTO buildTuningRes( Date startDate, Date endDate, Stock stock, String analyseName, SortedMap<Date, double[]> calcOutput, EventInfo evtDef, Observer observer, Boolean isEventsPersisted) throws NotEnoughDataException { if (calcOutput == null) calcOutput = new TreeMap<Date, double[]>(); if (!calcOutput.isEmpty() && calcOutput.firstKey().before(startDate)) calcOutput = calcOutput.tailMap(startDate); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy MM dd"); String noResMsg = "No estimate is available for " + stock.getName() + " between " + dateFormat.format(startDate) + " and " + dateFormat.format(endDate) + " with " + evtDef + ".\n"; try { Date endCalcRes = (calcOutput.size() > 0 && calcOutput.lastKey().after(endDate)) ? calcOutput.lastKey() : endDate; // Grab calculated events HashSet<EventInfo> eventDefinitions = new HashSet<EventInfo>(); eventDefinitions.add(evtDef); SymbolEvents eventsCalculated = EventsResources.getInstance() .crudReadEventsForStock( stock, startDate, endCalcRes, isEventsPersisted, eventDefinitions, analyseName); // Init event def list NavigableSet<EventValue> eventListForEvtDef = new TreeSet<EventValue>( new Comparator<EventValue>() { @Override public int compare(EventValue o1, EventValue o2) { return o1.getDate().compareTo(o2.getDate()); } }); eventListForEvtDef.addAll(eventsCalculated.getDataResultMap().values()); return buildTuningRes( stock, startDate, endDate, endCalcRes, analyseName, calcOutput, eventListForEvtDef, noResMsg, evtDef.info(), observer); } catch (NoQuotationsException e) { LOGGER.warn(noResMsg, e); throw new NotEnoughDataException(stock, noResMsg, e); } catch (NotEnoughDataException e) { LOGGER.warn(noResMsg, e); throw e; } catch (Exception e) { LOGGER.error(noResMsg, e); throw new NotEnoughDataException(stock, noResMsg, e); } }
private void eventsRecalculationAck( final Stock selectedShare, Date slidingStartDate, Date slidingEndDate, final HashSet<EventInfo> notUpToDateEI, Calendar minDate) { final RefreshableView parentView = (RefreshableView) chartTarget.getParent().getParent(); final EventRefreshController ctrller = new EventRefreshController( chartTarget.getHightlitedEventModel(), parentView, ConfigThreadLocal.get(EventSignalConfig.EVENT_SIGNAL_NAME)) { @Override public void widgetSelected(SelectionEvent evt) { LOGGER.guiInfo("Cleaning and Recalculating. Thanks for waiting ..."); EventTaskQueue.getSingleton().invalidateTasksCreationDates(TaskId.Analysis); this.updateEventRefreshModelState( 0l, TaskId.FetchQuotations, TaskId.Clean, TaskId.Analysis); super.widgetSelected(evt); } }; @SuppressWarnings("unchecked") boolean isValidTask = ctrller.isValidTask( TaskId.Analysis, selectedShare, new HashSet[] {notUpToDateEI}, slidingStartDate, slidingEndDate); if (isValidTask) { chartTarget.getHightlitedEventModel().setViewParamRoot(selectedShare); chartTarget.getHightlitedEventModel().setViewParam(0, notUpToDateEI); String msg = "Analysis are not up to date for " + selectedShare.getName() + ", the selected time frame and the requested trends."; String click = "Click to update calculations"; if (minDate.after(new Date(0))) msg = msg + "\nMinimun calculation date reached for this stock : " + new SimpleDateFormat("MMM dd yyyy").format(minDate); for (EventInfo eventInfo : notUpToDateEI) { if (chartTarget.getChartedEvtDefsTrends().contains(eventInfo) || chartTarget.getChartedEvtDef().equals(eventInfo)) { msg = msg + "\n'" + eventInfo.getEventReadableDef() + "' may be a candidate for update"; } } ActionDialogAction action = new ActionDialogAction() { @Override public void action(Control targetControl) { ctrller.widgetSelected(null); } }; showPopupDialog(msg, click, null, action); } else { // hidePopupDialog(); } }