@Transactional(readOnly = true)
public XYModel getChartData(Set<AdvanceAssignment> selectedAdvances) {
XYModel xymodel = new SimpleXYModel();
for (AdvanceAssignment each : selectedAdvances) {
DirectAdvanceAssignment directAdvanceAssignment;
if (each instanceof DirectAdvanceAssignment) {
directAdvanceAssignment = (DirectAdvanceAssignment) each;
} else {
directAdvanceAssignment = calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) each);
}
if (directAdvanceAssignment != null) {
String title = getInfoAdvanceAssignment(directAdvanceAssignment);
SortedSet<AdvanceMeasurement> listAdvanceMeasurements = directAdvanceAssignment
.getAdvanceMeasurements();
if (listAdvanceMeasurements.size() > 1) {
for (AdvanceMeasurement advanceMeasurement : listAdvanceMeasurements) {
BigDecimal value = advanceMeasurement.getValue();
if ((selectedAdvances.size() > 1) && (value != null) && (value.compareTo(BigDecimal.ZERO) > 0)) {
BigDecimal maxValue = directAdvanceAssignment
.getMaxValue();
value = value.setScale(2).divide(maxValue,
RoundingMode.DOWN);
}
LocalDate date = advanceMeasurement.getDate();