use of com.servoy.j2db.persistence.ValueList in project servoy-client by Servoy.
the class DBValueList method getShowDataproviders.
public static List<String> getShowDataproviders(ValueList valueList, Table callingTable, String dataProviderID, IFoundSetManagerInternal foundSetManager) throws RepositoryException {
if (valueList == null) {
return null;
}
FlattenedSolution flattenedSolution = foundSetManager.getApplication().getFlattenedSolution();
// Find destination table in case dataProviderID is related
String[] split = dataProviderID.split("\\.");
String dataSource = callingTable.getDataSource();
for (// first parts are relation names, last part is column name
int i = 0; // first parts are relation names, last part is column name
i < split.length - 1; // first parts are relation names, last part is column name
i++) {
Relation relation = flattenedSolution.getRelation(split[i]);
if (relation == null || !relation.getPrimaryDataSource().equals(dataSource)) {
return null;
}
dataSource = relation.getForeignDataSource();
}
Table table = (Table) foundSetManager.getTable(dataSource);
String columnName = split[split.length - 1];
String prefix = dataProviderID.substring(0, dataProviderID.length() - columnName.length());
// first try fallback value list,
ValueList usedValueList = flattenedSolution.getValueList(valueList.getFallbackValueListID());
Relation valuelistSortRelation = flattenedSolution.getValuelistSortRelation(usedValueList, table, columnName, foundSetManager);
if (valuelistSortRelation == null) {
// then try regular value list
usedValueList = valueList;
valuelistSortRelation = flattenedSolution.getValuelistSortRelation(usedValueList, table, columnName, foundSetManager);
}
if (valuelistSortRelation == null) {
return null;
}
List<String> showDataproviders = new ArrayList<String>(3);
int showValues = usedValueList.getShowDataProviders();
if ((showValues & 1) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID1());
}
if ((showValues & 2) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID2());
}
if ((showValues & 4) != 0) {
showDataproviders.add(prefix + valuelistSortRelation.getName() + '.' + usedValueList.getDataProviderID3());
}
return showDataproviders;
}
Aggregations