use of com.servoy.j2db.persistence.ColumnInfo in project servoy-client by Servoy.
the class DatabaseUtils method updateColumnInfo.
public static void updateColumnInfo(int element_id, Column c, ColumnInfoDef cid) {
ColumnInfo ci = new ColumnInfo(element_id, true);
ci.setAutoEnterType(cid.autoEnterType);
ci.setAutoEnterSubType(cid.autoEnterSubType);
ci.setSequenceStepSize(cid.sequenceStepSize);
ci.setPreSequenceChars(cid.preSequenceChars);
ci.setPostSequenceChars(cid.postSequenceChars);
ci.setDefaultValue(cid.defaultValue);
ci.setLookupValue(cid.lookupValue);
ci.setDatabaseSequenceName(cid.databaseSequenceName);
ci.setTitleText(cid.titleText);
ci.setDescription(cid.description);
ci.setForeignType(cid.foreignType);
ci.setConverterName(cid.converterName);
ci.setConverterProperties(cid.converterProperties);
ci.setValidatorProperties(cid.validatorProperties);
ci.setValidatorName(cid.validatorName);
ci.setDefaultFormat(cid.defaultFormat);
ci.setElementTemplateProperties(cid.elementTemplateProperties);
ci.setDataProviderID(cid.dataProviderID);
ci.setContainsMetaData(cid.containsMetaData);
ci.setConfiguredColumnType(cid.columnType);
ci.setCompatibleColumnTypes(cid.compatibleColumnTypes);
ci.setFlags(cid.flags);
ci.setSortIgnorecase(cid.sortIgnorecase);
ci.setSortingNullprecedence(cid.sortingNullprecedence);
c.setDatabasePK((cid.flags & IBaseColumn.PK_COLUMN) != 0);
c.setColumnInfo(ci);
}
use of com.servoy.j2db.persistence.ColumnInfo in project servoy-client by Servoy.
the class DatabaseUtils method createNewColumnInfo.
public static void createNewColumnInfo(int element_id, Column c, boolean createMissingServoySequence) {
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 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);
}
}
use of com.servoy.j2db.persistence.ColumnInfo in project servoy-client by Servoy.
the class FoundSetManager method getSortOptions.
@Override
public SortOptions getSortOptions(IColumn column) {
boolean ignoreCase = false;
SortingNullprecedence sortingNullprecedence = SortingNullprecedence.databaseDefault;
if (column != null) {
try {
// First defined at server level
IServer server = application.getSolution().getServer(column.getTable().getServerName());
if (server != null) {
ignoreCase = server.getSettings().isSortIgnorecase();
sortingNullprecedence = server.getSettings().getSortingNullprecedence();
}
} catch (RepositoryException | RemoteException e) {
Debug.error("Exception getting server settings", e);
}
ColumnInfo columnInfo = column.getColumnInfo();
if (columnInfo != null) {
// Can be overridden at column level
if (columnInfo.getSortIgnorecase() != null) {
ignoreCase = columnInfo.getSortIgnorecase().booleanValue();
}
if (columnInfo.getSortingNullprecedence() != null && columnInfo.getSortingNullprecedence() != SortingNullprecedence.databaseDefault) {
sortingNullprecedence = columnInfo.getSortingNullprecedence();
}
}
}
return SortOptions.NONE.withIgnoreCase(ignoreCase).withNullprecedence(sortingNullprecedence);
}
use of com.servoy.j2db.persistence.ColumnInfo in project servoy-client by Servoy.
the class SQLGenerator method makeQueryColumns.
private static ArrayList<IQuerySelectValue> makeQueryColumns(Iterator<Column> it, QueryTable queryTable, QueryInsert insert) {
ArrayList<IQuerySelectValue> queryColumns = new ArrayList<IQuerySelectValue>();
List<QueryColumn> insertColumns = new ArrayList<QueryColumn>();
while (it.hasNext()) {
Column column = it.next();
ColumnInfo ci = column.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
QueryColumn queryColumn = column.queryColumn(queryTable);
if (isBlobColumn(column)) {
String alias = column.getDataProviderID().substring(0, Math.min(Column.MAX_SQL_OBJECT_NAME_LENGTH - (IDataServer.BLOB_MARKER_COLUMN_ALIAS.length() + 1), column.getDataProviderID().length())) + '_' + IDataServer.BLOB_MARKER_COLUMN_ALIAS;
// make sure the alias is unique (2 media columns starting with the same name may clash here)
char c = 'a';
for (int i = 0; i < queryColumns.size(); i++) {
IQuerySelectValue sv = queryColumns.get(i);
if (alias.equals(sv.getAlias())) {
// alias not unique, replace first char to make it unique
alias = (c++) + alias.substring(1);
// search again
i = 0;
}
}
queryColumns.add(new QueryColumnValue(Integer.valueOf(1), alias, true));
} else {
queryColumns.add(queryColumn);
}
if (insert != null && (ci == null || !ci.isDBManaged())) {
insertColumns.add(queryColumn);
}
}
if (insert != null) {
insert.setColumnValues(insertColumns.toArray(new QueryColumn[insertColumns.size()]), new Placeholder(new TablePlaceholderKey(queryTable, PLACEHOLDER_INSERT_KEY)));
}
return queryColumns;
}
Aggregations