use of com.servoy.j2db.persistence.ScriptVariable in project servoy-client by Servoy.
the class FoundSetManager method getRelationWhereArgs.
/**
* Get relation where-args, not using column converters
* @param state
* @param relation
* @param testForCalcs
* @return
* @throws RepositoryException
*/
public Object[] getRelationWhereArgs(IRecordInternal state, Relation relation, boolean testForCalcs) throws RepositoryException {
boolean isNull = true;
IDataProvider[] args = relation.getPrimaryDataProviders(application.getFlattenedSolution());
Column[] columns = relation.getForeignColumns(application.getFlattenedSolution());
Object[] array = new Object[args.length];
for (int i = 0; i < args.length; i++) {
Object value = null;
if (args[i] instanceof LiteralDataprovider) {
value = ((LiteralDataprovider) args[i]).getValue();
} else if (args[i] instanceof EnumDataProvider) {
value = getScopesScopeProvider().getDataProviderValue(args[i].getDataProviderID());
} else {
String dataProviderID = args[i].getDataProviderID();
if (testForCalcs && state.getRawData().containsCalculation(dataProviderID) && state.getRawData().mustRecalculate(dataProviderID, true)) {
// else this can just cascade through..
return null;
}
// unconverted (todb value)
value = state.getValue(dataProviderID, false);
}
if (value != Scriptable.NOT_FOUND) {
array[i] = columns[i].getAsRightType(value);
}
if (array[i] != null) {
isNull = false;
} else {
// Because null columns can't have a relation.
if (args[i] instanceof IColumn) {
return null;
}
if (isNull) {
isNull = !(args[i] instanceof ScriptVariable);
}
}
}
// optimize for null keys (multiple all null!) but not empty pk (db ident)
if (isNull)
return null;
return array;
}
Aggregations