Search in sources :

Example 1 with ColumnInfo

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);
}
Also used : ColumnInfo(com.servoy.j2db.persistence.ColumnInfo)

Example 2 with ColumnInfo

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();
}
Also used : ITable(com.servoy.j2db.persistence.ITable) Table(com.servoy.j2db.persistence.Table) Column(com.servoy.j2db.persistence.Column) IPersist(com.servoy.j2db.persistence.IPersist) TableNode(com.servoy.j2db.persistence.TableNode) ColumnInfo(com.servoy.j2db.persistence.ColumnInfo) ITable(com.servoy.j2db.persistence.ITable) IDataProvider(com.servoy.j2db.persistence.IDataProvider)

Example 3 with ColumnInfo

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;
}
Also used : QueryColumn(com.servoy.j2db.query.QueryColumn) Column(com.servoy.j2db.persistence.Column) IColumn(com.servoy.j2db.persistence.IColumn) IPersist(com.servoy.j2db.persistence.IPersist) TableNode(com.servoy.j2db.persistence.TableNode) ColumnInfo(com.servoy.j2db.persistence.ColumnInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IDataProvider(com.servoy.j2db.persistence.IDataProvider)

Example 4 with ColumnInfo

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);
}
Also used : IColumn(com.servoy.j2db.persistence.IColumn) ColumnInfo(com.servoy.j2db.persistence.ColumnInfo)

Example 5 with ColumnInfo

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;
}
Also used : IColumn(com.servoy.j2db.persistence.IColumn) FormAndTableDataProviderLookup(com.servoy.j2db.FormAndTableDataProviderLookup) ColumnWrapper(com.servoy.j2db.persistence.ColumnWrapper) ColumnInfo(com.servoy.j2db.persistence.ColumnInfo) RepositoryException(com.servoy.j2db.persistence.RepositoryException) IDataProvider(com.servoy.j2db.persistence.IDataProvider)

Aggregations

ColumnInfo (com.servoy.j2db.persistence.ColumnInfo)21 Column (com.servoy.j2db.persistence.Column)14 RepositoryException (com.servoy.j2db.persistence.RepositoryException)9 IBaseColumn (com.servoy.base.persistence.IBaseColumn)8 IColumn (com.servoy.j2db.persistence.IColumn)8 IOException (java.io.IOException)6 ITable (com.servoy.j2db.persistence.ITable)5 QueryColumn (com.servoy.j2db.query.QueryColumn)5 IDataProvider (com.servoy.j2db.persistence.IDataProvider)4 Table (com.servoy.j2db.persistence.Table)4 ServoyException (com.servoy.j2db.util.ServoyException)4 ArrayList (java.util.ArrayList)4 IServer (com.servoy.j2db.persistence.IServer)3 Placeholder (com.servoy.j2db.query.Placeholder)3 QuerySelect (com.servoy.j2db.query.QuerySelect)3 QueryTable (com.servoy.j2db.query.QueryTable)3 TablePlaceholderKey (com.servoy.j2db.query.TablePlaceholderKey)3 SafeArrayList (com.servoy.j2db.util.SafeArrayList)3 RemoteException (java.rmi.RemoteException)3 BaseQueryColumn (com.servoy.base.query.BaseQueryColumn)2