use of com.servoy.j2db.persistence.ColumnWrapper in project servoy-client by Servoy.
the class FlattenedSolution method getGlobalDataProviderEx.
private IDataProvider getGlobalDataProviderEx(String id, boolean quiet) throws RepositoryException {
if (id == null)
return null;
Pair<String, String> scope = ScopesUtils.getVariableScope(id);
if (scope.getLeft() != null) /* global scope */
{
// search all objects,will return globals
ScriptVariable global = AbstractBase.selectByName(getScriptVariables(scope.getLeft(), false), scope.getRight());
if (global != null) {
return global;
}
// try @enum global variables
return getEnumDataProvider(id);
}
// in case of multi-level relations we have more that 1 dot
int indx = id.lastIndexOf('.');
if (indx > 0) {
String rel_name = id.substring(0, indx);
String col = id.substring(indx + 1);
Relation[] relations = getRelationSequence(rel_name);
if (relations == null) {
return null;
}
Relation r = relations[relations.length - 1];
if (quiet) {
boolean missingSrv = true;
String ds = r.getForeignDataSource();
if (ds != null) {
String[] st = DataSourceUtilsBase.getDBServernameTablename(ds);
if (st != null && st.length == 2) {
try {
missingSrv = (r.getRootObject().getServer(st[0]) == null);
} catch (RemoteException e) {
// we are in developer here - shouldn't happen
}
}
}
if (missingSrv)
return null;
}
// TODO if this is refactord out to be resolved outside the relation also look at the DataProviderConverter
// the call from that class to flattenedSolution.getGlobalDataProvider(value);
Column[] cols = r.getForeignColumns(this);
if (cols == null || cols.length == 0)
return null;
IDataProvider c = getDataProviderForTable(getTable(r.getForeignDataSource()), col);
if (r != null && c instanceof IColumn) {
return new ColumnWrapper((IColumn) c, relations);
}
return c;
}
return null;
}
use of com.servoy.j2db.persistence.ColumnWrapper in project servoy-client by Servoy.
the class FoundSet method determineSortColumns.
/**
* @param sqlSelect
* @return
* @throws RepositoryException
*/
private List<SortColumn> determineSortColumns(QuerySelect sqlSelect) throws RepositoryException {
List<SortColumn> sortColumns = null;
for (IQuerySort qsort : iterate(sqlSelect.getSorts())) {
if (qsort instanceof QuerySort) {
IQuerySelectValue qcolumn = ((QuerySort) qsort).getColumn();
if (qcolumn instanceof QueryColumn) {
ColumnWrapper columnWrapper = findColumnWrapperForColumn(sqlSelect, (QueryColumn) qcolumn);
if (columnWrapper != null) {
if (sortColumns == null) {
sortColumns = new ArrayList<>();
}
SortColumn sortColumn = new SortColumn(columnWrapper);
sortColumn.setSortOrder(((QuerySort) qsort).isAscending() ? SortColumn.ASCENDING : SortColumn.DESCENDING);
sortColumns.add(sortColumn);
// otherwise stop searching
continue;
}
}
}
}
// stop searching when no match could be made to a valid column, return the ones found or null when nothing matched
return sortColumns;
}
use of com.servoy.j2db.persistence.ColumnWrapper in project servoy-client by Servoy.
the class DataProviderEditor method getValue.
public Object getValue() {
Object retval = null;
Object[] selections = list.getSelectedValues();
IDataProvider[] array = new IDataProvider[selections.length];
for (int i = 0; i < selections.length; i++) {
Object o = selections[i];
if (o instanceof IDataProvider) {
Object item = relationsComboBox.getSelectedItem();
if (item instanceof Relation && o instanceof IColumn) {
array[i] = new ColumnWrapper((IColumn) o, new Relation[] { ((Relation) item) });
} else {
array[i] = (IDataProvider) o;
}
}
}
if (selections.length == 1) {
retval = array[0];
} else {
retval = array;
}
if (// if used to setDataProviderID
returnValueAsString) {
if (array != null && array.length != 0 && array[0] != null) {
retval = array[0].getDataProviderID();
} else {
return null;
}
}
relation = null;
return retval;
}
use of com.servoy.j2db.persistence.ColumnWrapper in project servoy-client by Servoy.
the class SortModel method right.
private void right() {
flagChanged();
Object o = dpe.getValue();
if (o != null) {
int currentSize = model.getRowCount();
if (o instanceof Column) {
if (model.addRow(new SortColumn((Column) o)))
table.setRowSelectionInterval(currentSize, currentSize);
} else if (o instanceof ColumnWrapper) {
if (model.addRow(new SortColumn((ColumnWrapper) o)))
table.setRowSelectionInterval(currentSize, currentSize);
} else {
boolean clear = false;
IDataProvider[] array = (IDataProvider[]) o;
for (IDataProvider element : array) {
boolean added = false;
if (element instanceof ColumnWrapper) {
added = model.addRow(new SortColumn((ColumnWrapper) element));
} else if (element instanceof Column) {
added = model.addRow(new SortColumn((Column) element));
}
if (added) {
if (!clear) {
table.clearSelection();
clear = true;
}
table.addRowSelectionInterval(currentSize, currentSize);
currentSize++;
}
}
}
}
}
use of com.servoy.j2db.persistence.ColumnWrapper in project servoy-client by Servoy.
the class NGUtils method getDataProviderPropertyDescription.
public static PropertyDescription getDataProviderPropertyDescription(String dataProviderName, IApplication app, Form form, ITable table, boolean parseHTMLIfString, boolean useLocalDateTime) {
FormAndTableDataProviderLookup dpLookup = new FormAndTableDataProviderLookup(app.getFlattenedSolution(), form, table);
IDataProvider dp = null;
try {
dp = dpLookup.getDataProvider(dataProviderName);
} catch (RepositoryException e) {
Debug.error(e);
}
if (dp != null) {
int dpType;
if (dp instanceof IColumn || dp instanceof ColumnWrapper) {
IColumn column = (dp instanceof IColumn) ? (IColumn) dp : ((ColumnWrapper) dp).getColumn();
ColumnInfo ci = column.getColumnInfo();
if (ci != null && ci.hasFlag(IBaseColumn.UUID_COLUMN)) {
return UUID_DATAPROVIDER_CACHED_PD;
}
dpType = app.getFoundSetManager().getConvertedTypeForColumn(column, true);
} else
dpType = dp.getDataProviderType();
return getDataProviderPropertyDescription(dpType, parseHTMLIfString, useLocalDateTime);
}
return null;
}
Aggregations