Skip to content

Commit 9c4ec38

Browse files
committed
DM-9590 XY plot is unrecoverable after it fails
1 parent 68eff97 commit 9c4ec38

File tree

2 files changed

+54
-30
lines changed

2 files changed

+54
-30
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/util/QueryUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public static DataAccessException createEndUserException(String msg, String deta
623623
* @param decimateInfo DecimateInfo object
624624
* @return decimated data group
625625
*/
626-
public static DataGroup doDecimation(DataGroup dg, DecimateInfo decimateInfo) {
626+
public static DataGroup doDecimation(DataGroup dg, DecimateInfo decimateInfo) throws DataAccessException {
627627

628628
double xMax = Double.NEGATIVE_INFINITY, xMin = Double.POSITIVE_INFINITY, yMax = Double.NEGATIVE_INFINITY, yMin = Double.POSITIVE_INFINITY;
629629

@@ -633,7 +633,7 @@ public static DataGroup doDecimation(DataGroup dg, DecimateInfo decimateInfo) {
633633

634634
if (!xValGetter.isValid() || !yValGetter.isValid()) {
635635
System.out.println("QueryUtil.doDecimation: invalid x or y column.");
636-
return null; // TODO: handle null return in the caller?
636+
throw new DataAccessException("Invalid column or expression");
637637
}
638638

639639
int maxPoints = decimateInfo.getMaxPoints() == 0 ? DECI_DEF_MAX_POINTS : decimateInfo.getMaxPoints();

src/firefly/js/charts/dataTypes/XYColsCDT.js

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,19 @@ function serverParamsChanged(oldParams, newParams, chartDataElement) {
219219
} else {
220220
// 'x', 'y', 'sortBy', 'xErr', 'xErrLow', 'xErrHigh', 'yErr', 'yErrLow', 'yErrHigh'
221221
// server call parameters are present in the data
222-
const newOpts = omitBy({
223-
sortBy: newParams.sortColOrExpr,
224-
x: newParams.x.columnOrExpr,
225-
xErr: newParams.x.error,
226-
xErrLow: newParams.x.errorLow,
227-
xErrHigh: newParams.x.errorHigh,
228-
y: newParams.y.columnOrExpr,
229-
yErr: newParams.y.error,
230-
yErrLow: newParams.y.errorLow,
231-
yErrHigh: newParams.y.errorHigh
232-
}, isUndefined);
233-
return Object.keys(newOpts).some((o) => {
234-
return newOpts[o] !== data[o];
235-
});
222+
const newOpts = getServerCallParameters(newParams, false);
223+
if (data) {
224+
// if data available, see if the new parameters are different from those used to obtain the data
225+
return Object.keys(newOpts).some((o) => {
226+
return newOpts[o] !== data[o];
227+
});
228+
} else {
229+
// if data are not available, compare with the old parameters
230+
const oldOpts = getServerCallParameters(oldParams, false);
231+
return Object.keys(newOpts).some((o) => {
232+
return newOpts[o] !== oldOpts[o];
233+
});
234+
}
236235
}
237236
}
238237

@@ -249,22 +248,39 @@ function isLargeTable(tblId) {
249248
// xyPlotParams.x.errorHigh || xyPlotParams.y.errorHigh);
250249
//}
251250

252-
function getServerCallParameters(xyPlotParams) {
253-
if (!xyPlotParams) { return []; }
251+
function getServerCallParameters(xyPlotParams, isLargeTable=true) {
252+
if (isLargeTable) {
253+
if (!xyPlotParams) {
254+
return [];
255+
}
254256

255-
if (xyPlotParams.zoom) {
256-
var {xMin, xMax, yMin, yMax} = xyPlotParams.zoom;
257-
}
257+
if (xyPlotParams.zoom) {
258+
var {xMin, xMax, yMin, yMax} = xyPlotParams.zoom;
259+
}
258260

259-
let maxBins = 10000;
260-
let xyRatio = xyPlotParams.xyRatio || 1.0;
261-
if (xyPlotParams.nbins) {
262-
const {x, y} = xyPlotParams.nbins;
263-
maxBins = x*y;
264-
xyRatio = x/y;
261+
let maxBins = 10000;
262+
let xyRatio = xyPlotParams.xyRatio || 1.0;
263+
if (xyPlotParams.nbins) {
264+
const {x, y} = xyPlotParams.nbins;
265+
maxBins = x * y;
266+
xyRatio = x / y;
267+
}
268+
// order should match the order of the parameters in serializeDecimateInfo
269+
return [xyPlotParams.x.columnOrExpr, xyPlotParams.y.columnOrExpr, maxBins, xyRatio, xMin, xMax, yMin, yMax];
270+
} else {
271+
// smaller (not decimated) table
272+
return omitBy({
273+
sortBy: xyPlotParams.sortColOrExpr,
274+
x: xyPlotParams.x.columnOrExpr,
275+
xErr: xyPlotParams.x.error,
276+
xErrLow: xyPlotParams.x.errorLow,
277+
xErrHigh: xyPlotParams.x.errorHigh,
278+
y: xyPlotParams.y.columnOrExpr,
279+
yErr: xyPlotParams.y.error,
280+
yErrLow: xyPlotParams.y.errorLow,
281+
yErrHigh: xyPlotParams.y.errorHigh
282+
}, isUndefined);
265283
}
266-
// order should match the order of the parameters in serializeDecimateInfo
267-
return [xyPlotParams.x.columnOrExpr, xyPlotParams.y.columnOrExpr, maxBins, xyRatio, xMin, xMax, yMin, yMax];
268284
}
269285

270286
export function getDataBoundaries(xyPlotData) {
@@ -574,12 +590,20 @@ function fetchXYWithErrorsOrSort(dispatch, chartId, chartDataElementId) {
574590
function dispatchError(dispatch, chartId, chartDataElementId, reason) {
575591
const message = 'Failed to fetch XY plot data';
576592
logError(`${message}: ${reason}`);
593+
let reasonStr = `${reason}`.toLowerCase();
594+
if (reasonStr.match(/not supported/)) {
595+
reasonStr = 'Unsupported feature requested. Please choose valid options.';
596+
} else if (reasonStr.match(/invalid column/)) {
597+
reasonStr = 'Invalid column or expression. Please choose valid X and Y.';
598+
} else {
599+
reasonStr = 'Please check console for more information.';
600+
}
577601
dispatch(chartDataUpdate(
578602
{
579603
chartId,
580604
chartDataElementId,
581605
isDataReady: true,
582-
error: {message, reason},
606+
error: {message, reason: reasonStr},
583607
data: undefined
584608
}));
585609
}

0 commit comments

Comments
 (0)