use of com.servoy.j2db.persistence.IColumn 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.IColumn in project servoy-client by Servoy.
the class NGUtils method getDataProviderPropertyDescription.
public static PropertyDescription getDataProviderPropertyDescription(String dataProviderName, ITable table, IApplication app, boolean parseHTML, boolean useLocalDateTime) {
if (table == null || dataProviderName == null)
return null;
IColumn column = table.getColumn(dataProviderName);
int dpType = 0;
if (column != null) {
ColumnInfo ci = column.getColumnInfo();
if (ci != null && ci.hasFlag(IBaseColumn.UUID_COLUMN)) {
return UUID_DATAPROVIDER_CACHED_PD;
}
if (app != null)
dpType = app.getFoundSetManager().getConvertedTypeForColumn(column, true);
else
dpType = table.getColumnType(dataProviderName);
}
return getDataProviderPropertyDescription(dpType, parseHTML, useLocalDateTime);
}
use of com.servoy.j2db.persistence.IColumn 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;
}
use of com.servoy.j2db.persistence.IColumn in project servoy-client by Servoy.
the class ViewFoundSet method determineSortColumns.
private List<SortColumn> determineSortColumns() {
List<IQuerySort> sorts = select.getSorts();
if (sorts != null) {
return sorts.stream().filter(QuerySort.class::isInstance).map(QuerySort.class::cast).map(sort -> {
String name = sort.getColumn().getAliasOrName();
IColumn column = getTable().getColumnBySqlname(name);
if (column != null) {
return new SortColumn(column, sort.isAscending() ? SortColumn.ASCENDING : SortColumn.DESCENDING);
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toList());
}
return null;
}
use of com.servoy.j2db.persistence.IColumn in project servoy-client by Servoy.
the class DataProviderEditor method fillDataProviderList.
protected void fillDataProviderList() {
try {
ITable table = null;
if (definedTable == null) {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getCurrentMainShowingFormController();
if (fc != null) {
Form form = fc.getForm();
table = application.getFlattenedSolution().getTable(form.getDataSource());
}
} else {
if (!showRelatedOptionsOnly)
table = definedTable;
}
DefaultListModel model = (DefaultListModel) list.getModel();
model.removeAllElements();
if (showNoneOption)
model.addElement("-none-");
if (!showColumnsOnly)
model.addElement("*columns");
Object o = relationsComboBox.getSelectedItem();
if (o != null) {
if (o instanceof String) {
// table = form.getTable();
} else {
table = application.getFlattenedSolution().getTable(((Relation) o).getForeignDataSource());
}
if (table != null) {
Iterator<Column> it = table.getColumnsSortedByName();
while (it.hasNext()) {
IColumn c = it.next();
ColumnInfo ci = c.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
if (hideMediaColumns) {
// use dataprovider type as defined by column converter
ComponentFormat componentFormat = ComponentFormat.getComponentFormat(null, c, application);
if (componentFormat.dpType == IColumnTypes.MEDIA) {
continue;
}
}
model.addElement(c);
}
}
}
FlattenedSolution s = application.getFlattenedSolution();
if (table != null && !showColumnsOnly) {
Iterator it = s.getScriptCalculations(table, true);
if (it.hasNext()) {
model.addElement("*calculations");
}
while (it.hasNext()) {
ScriptCalculation sc = (ScriptCalculation) it.next();
for (int i = 0; i < model.size(); i++) {
Object obj = model.elementAt(i);
if (obj instanceof IDataProvider) {
IDataProvider dp = (IDataProvider) obj;
if (dp.getDataProviderID().equals(sc.getDataProviderID())) {
// remove the column from the list if use by
model.remove(i);
// stored calc
break;
}
}
}
model.addElement(sc);
}
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
Iterator it3 = s.getAggregateVariables(table, true);
if (it3.hasNext()) {
model.addElement("*aggregates");
}
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (table != null && showColumnsOnly && showSortableOnly) {
Iterator it3 = s.getAggregateVariables(table, true);
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (showGlobalsOption && showColumnsOnly) {
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
}
} catch (Exception ex) {
Debug.error(ex);
}
}
Aggregations