Search in sources :

Example 26 with ValueList

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;
}
Also used : Relation(com.servoy.j2db.persistence.Relation) BaseQueryTable(com.servoy.base.query.BaseQueryTable) QueryTable(com.servoy.j2db.query.QueryTable) ITable(com.servoy.j2db.persistence.ITable) Table(com.servoy.j2db.persistence.Table) ValueList(com.servoy.j2db.persistence.ValueList) ArrayList(java.util.ArrayList) SafeArrayList(com.servoy.j2db.util.SafeArrayList) FlattenedSolution(com.servoy.j2db.FlattenedSolution)

Aggregations

ValueList (com.servoy.j2db.persistence.ValueList)26 IValueList (com.servoy.j2db.dataprocessing.IValueList)16 CustomValueList (com.servoy.j2db.dataprocessing.CustomValueList)10 LookupValueList (com.servoy.j2db.dataprocessing.LookupValueList)7 FlattenedSolution (com.servoy.j2db.FlattenedSolution)6 Form (com.servoy.j2db.persistence.Form)5 ISupportValueList (com.servoy.j2db.ui.ISupportValueList)5 ServoyException (com.servoy.j2db.util.ServoyException)5 GlobalMethodValueList (com.servoy.j2db.dataprocessing.GlobalMethodValueList)4 Relation (com.servoy.j2db.persistence.Relation)4 RepositoryException (com.servoy.j2db.persistence.RepositoryException)4 ArrayList (java.util.ArrayList)4 ApplicationException (com.servoy.j2db.ApplicationException)3 ExitScriptException (com.servoy.j2db.ExitScriptException)3 IRefreshValueList (com.servoy.j2db.IRefreshValueList)3 DBValueList (com.servoy.j2db.dataprocessing.DBValueList)3 Field (com.servoy.j2db.persistence.Field)3 ITable (com.servoy.j2db.persistence.ITable)3 INGApplication (com.servoy.j2db.server.ngclient.INGApplication)3 Point (java.awt.Point)3