// ViewCycleExecutionSequenceDescriptor
@Override
public ViewCycleExecutionSequence createSequence(FunctionExecutionContext executionContext) {
LocalDate startDate = DateConstraint.evaluate(executionContext, _startDateDescriptor);
LocalDate endDate = DateConstraint.evaluate(executionContext, _endDateDescriptor);
if (!_includeStart) {
startDate = startDate.plusDays(1);
}
if (!_includeEnd) {
endDate = endDate.minusDays(1);
}
HolidaySourceCalendarAdapter calendar;
if (_currencyCalendars != null) {
Currency[] currencies = _currencyCalendars.toArray(new Currency[_currencyCalendars.size()]);
HolidaySource holidaySource = OpenGammaExecutionContext.getHolidaySource(executionContext);
calendar = new HolidaySourceCalendarAdapter(holidaySource, currencies);
} else {
calendar = null;
}
List<ViewCycleExecutionOptions> executionSequence = new LinkedList<ViewCycleExecutionOptions>();
LocalDate previousWorkingDate = null;
LocalDate currentDate = startDate;
while (!currentDate.isAfter(endDate)) {
if (calendar == null || calendar.isWorkingDay(currentDate)) {
MarketDataSpecification marketDataSpec = createMarketDataSpec(previousWorkingDate, currentDate, LocalDate.now(executionContext.getValuationClock()));
if (marketDataSpec != null) {
ViewCycleExecutionOptions executionOptions = ViewCycleExecutionOptions.builder()
.setMarketDataSpecification(marketDataSpec)
.create();
executionSequence.add(executionOptions);
}
previousWorkingDate = currentDate;
}
currentDate = currentDate.plusDays(1);
}
return new ArbitraryViewCycleExecutionSequence(executionSequence);
}