Skip to content

Commit

Permalink
Merge pull request #1280 from dcleao/8.1.0.0-BACKLOG-22986
Browse files Browse the repository at this point in the history
[BACKLOG-22986] Fixing case where the input field of a EntityWithTime…
  • Loading branch information
pamval authored Apr 30, 2018
2 parents 4563e83 + 9422b02 commit 7adc706
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,9 @@ define([

// Only re-evaluate the visual role if it has changed since previousAdaptationModel was created.
var change = changeset !== null ? changeset.getChange(propType) : null;
if(change !== null && !change.hasChanges) {
change = null;
}

// If no externalData (and data has not changed),
// then all reused roleInfo already have null strategyApplication and strategy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,31 @@ define([

var rowIndex = dataTable.getNumberOfRows();
while(rowIndex--) {
var cellIndex = inputFieldIndexes.length;
var inputCells = new Array(cellIndex);
var inputFieldCount = inputFieldIndexes.length;
var inputCells = new Array(inputFieldCount);

var cellLabels = new Array(cellIndex);
while(cellIndex--) {
var cellLabels = [];
var cellIndex = -1;
while(++cellIndex < inputFieldCount) {
inputCells[cellIndex] = dataTable.getCell(rowIndex, inputFieldIndexes[cellIndex]);
cellLabels[cellIndex] = inputCells[cellIndex].label;
var label = inputCells[cellIndex].label;
if(label) {
cellLabels.push(label);
}
}

var mainInputCell = inputCells[this.mainInputPosition];

var dateValue = dateUtil.parseDateEcma262v7(mainInputCell.referent.property("startDateTime"));
var inputValue = mainInputCell.value;
var dateValue = inputValue !== null
? dateUtil.parseDateEcma262v7(mainInputCell.referent.property("startDateTime"))
: null;

var outputCell = dataTable.getCell(rowIndex, outputColIndex);
outputCell.value = dateValue;
outputCell.label = cellLabels.join(", ");

this.__backIndex[this.__keyFun.call(null, dateValue)] = rowIndex;
this.__forwardIndex[mainInputCell.value] = rowIndex;
this.__forwardIndex[inputValue === null ? "" : inputValue] = rowIndex;
}

instSpec = Object.create(instSpec);
Expand All @@ -170,7 +176,7 @@ define([
map: function(inputValues) {
var lookupValue = dataUtil.getCellValue(inputValues[this.mainInputPosition]);

var rowIndex = this.__forwardIndex[lookupValue];
var rowIndex = this.__forwardIndex[lookupValue === null ? "" : lookupValue];
if(rowIndex != null) {
return this._getDataRowCells(rowIndex, this.outputFieldIndexes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,35 @@ define([
expect(strategy2).not.toBe(strategy1);
});

it("should update the strategy even if the fields have also changed, but to the same value", function() {

var strategy1 = modelAdapter.roleA.strategy;
expect(strategy1).not.toBe(null);

modelAdapter.$type.context.enterChange().using(function(scope) {

// Create a changeset, but with no changes...
modelAdapter.roleA.fields = modelAdapter.roleA.fields.toArray(function(mappingField) {
return mappingField.name;
});

expect(modelAdapter.$changeset.getChange("roleA")).not.toBe(null);

// ---

modelAdapter.data = new Table(getDataSpec1());

scope.accept();
});

// ---

var strategy2 = modelAdapter.roleA.strategy;
expect(strategy2).not.toBe(null);

expect(strategy2).not.toBe(strategy1);
});

it("should not update the modeFixed of the internal mapping", function() {

var internalMode1 = modelAdapter.model.roleA.modeFixed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ define([
"pentaho/visual/role/adaptation/entityWithTimeIntervalKeyStrategy"
], function(_Strategy) {
Strategy = _Strategy;
});
});
});
});

Expand Down Expand Up @@ -373,6 +373,19 @@ define([
}
);

it("should deal with null input cells", function() {

dataTable.getCell(1, datasetFieldIndexes.months).value = null;

var strategy = Strategy.type.apply(dataTable, [datasetFieldIndexes.years, datasetFieldIndexes.months]);

var newColIndex = strategy.outputFieldIndexes[0];

var newCell = dataTable.getCell(1, newColIndex);

expect(newCell.value).toEqual(null);
});

it("should deal with cells missing startDateTime value", function() {
dataTable.getColumnAttribute(datasetFieldIndexes.months).members[1].property("startDateTime", null);

Expand Down

0 comments on commit 7adc706

Please sign in to comment.