use of com.servoy.j2db.persistence.ColumnInfo in project servoy-client by Servoy.
the class DatabaseUtils method createNewColumnInfo.
public static void createNewColumnInfo(IPersistFactory persistFactory, Column c, boolean createMissingServoySequence) throws RepositoryException {
int element_id = persistFactory.getNewElementID(null);
ColumnInfo ci = new ColumnInfo(element_id, false);
if (createMissingServoySequence && c.getRowIdentType() != IBaseColumn.NORMAL_COLUMN && c.getSequenceType() == ColumnInfo.NO_SEQUENCE_SELECTED && (Column.mapToDefaultType(c.getConfiguredColumnType().getSqlType()) == IColumnTypes.INTEGER || Column.mapToDefaultType(c.getConfiguredColumnType().getSqlType()) == IColumnTypes.NUMBER)) {
ci.setAutoEnterType(ColumnInfo.SEQUENCE_AUTO_ENTER);
ci.setAutoEnterSubType(ColumnInfo.SERVOY_SEQUENCE);
ci.setSequenceStepSize(1);
}
if (c.isUUID() && c.isDatabasePK())
c.setSequenceType(ColumnInfo.UUID_GENERATOR);
// when column has no columninfo and no flags it will return Column.PK_COLUMN for db pk column.
ci.setFlags(c.getFlags());
c.setColumnInfo(ci);
}
use of com.servoy.j2db.persistence.ColumnInfo in project servoy-client by Servoy.
the class WebCellAdapter method isDBDataprovider.
private boolean isDBDataprovider() {
if (isDBDataproviderObj == null) {
isDBDataproviderObj = Boolean.FALSE;
ITable table = view.getDataAdapterList().getFormController().getTable();
if (table instanceof Table) {
Table tableObj = (Table) table;
Iterator<Column> columns = tableObj.getColumns().iterator();
while (columns.hasNext()) {
Column col = columns.next();
ColumnInfo ci = col.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
if (col.getDataProviderID() == dataprovider) {
isDBDataproviderObj = Boolean.TRUE;
break;
}
}
Iterator<TableNode> tableNodes = view.getDataAdapterList().getApplication().getFlattenedSolution().getTableNodes(table);
while (tableNodes.hasNext()) {
TableNode tableNode = tableNodes.next();
if (tableNode != null) {
Iterator<IPersist> it2 = tableNode.getAllObjects();
while (it2.hasNext()) {
IPersist persist = it2.next();
if (persist instanceof IDataProvider && (((IDataProvider) persist).getDataProviderID() == dataprovider)) {
isDBDataproviderObj = Boolean.FALSE;
}
}
}
}
}
}
return isDBDataproviderObj.booleanValue();
}
use of com.servoy.j2db.persistence.ColumnInfo in project servoy-client by Servoy.
the class FlattenedSolution method getAllDataProvidersForTable.
public Map<String, IDataProvider> getAllDataProvidersForTable(ITable table) throws RepositoryException {
if (table == null)
return null;
synchronized (this) {
if (allProvidersForTable == null)
allProvidersForTable = new ConcurrentHashMap<ITable, Map<String, IDataProvider>>(64, 0.9f, 16);
}
Map<String, IDataProvider> dataProvidersMap = allProvidersForTable.get(table);
if (dataProvidersMap == null) {
dataProvidersMap = new HashMap<String, IDataProvider>(16, 0.9f);
// 1) first the columns
Iterator<Column> columns = table.getColumns().iterator();
while (columns.hasNext()) {
Column col = columns.next();
ColumnInfo ci = col.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
dataProvidersMap.put(col.getDataProviderID(), col);
}
// 2) last the scriptcalculations and aggregates so the overlap the columns in case of stored calcs
Iterator<TableNode> tableNodes = getTableNodes(table);
while (tableNodes.hasNext()) {
TableNode tableNode = tableNodes.next();
if (tableNode != null) {
Iterator<IPersist> it2 = tableNode.getAllObjects();
while (it2.hasNext()) {
IPersist persist = it2.next();
if (persist instanceof IDataProvider) {
dataProvidersMap.put(((IDataProvider) persist).getDataProviderID(), (IDataProvider) persist);
}
}
}
}
Map<String, IDataProvider> currentValue = allProvidersForTable.putIfAbsent(table, dataProvidersMap);
if (currentValue != null)
dataProvidersMap = currentValue;
}
return dataProvidersMap;
}
use of com.servoy.j2db.persistence.ColumnInfo 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.ColumnInfo 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