Search in sources :

Example 1 with PostgreAttribute

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute in project dbeaver by serge-rider.

the class PostgreEnumValueManager method getEnumValues.

@Override
protected List<String> getEnumValues(IValueController valueController) {
    final PostgreAttribute attribute = (PostgreAttribute) valueController.getValueType();
    if (attribute.getDataType() == null) {
        return null;
    }
    final Object[] values = attribute.getDataType().getEnumValues();
    if (values == null) {
        return null;
    }
    List<String> strValues = new ArrayList<>(values.length);
    for (Object value : values) {
        strValues.add(DBValueFormatting.getDefaultValueDisplayString(value, DBDDisplayFormat.UI));
    }
    return strValues;
}
Also used : ArrayList(java.util.ArrayList) PostgreAttribute(org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute)

Example 2 with PostgreAttribute

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute in project dbeaver by serge-rider.

the class PostgreConstraintConfigurator method configureObject.

@Override
public PostgreTableConstraint configureObject(DBRProgressMonitor monitor, Object parent, PostgreTableConstraint constraint) {
    return UITask.run(() -> {
        EditConstraintPage editPage = new EditConstraintPage(PostgreMessages.edit_constraint_page_add_constraint, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY, DBSEntityConstraintType.CHECK });
        if (!editPage.edit()) {
            return null;
        }
        constraint.setName(editPage.getConstraintName());
        constraint.setConstraintType(editPage.getConstraintType());
        if (constraint.getConstraintType().isCustom()) {
            constraint.setSource(editPage.getConstraintExpression());
        } else {
            int colIndex = 1;
            for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
                constraint.addColumn(new PostgreTableConstraintColumn(constraint, (PostgreAttribute) tableColumn, colIndex++));
            }
        }
        return constraint;
    });
}
Also used : DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) PostgreTableConstraintColumn(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraintColumn) EditConstraintPage(org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage) PostgreTableConstraint(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraint) PostgreAttribute(org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute)

Example 3 with PostgreAttribute

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute in project dbeaver by dbeaver.

the class PostgreEnumValueManager method getEnumValues.

@Override
protected List<String> getEnumValues(IValueController valueController) {
    final PostgreAttribute attribute = (PostgreAttribute) valueController.getValueType();
    if (attribute.getDataType() == null) {
        return null;
    }
    final Object[] values = attribute.getDataType().getEnumValues();
    if (values == null) {
        return null;
    }
    List<String> strValues = new ArrayList<>(values.length);
    for (Object value : values) {
        strValues.add(DBValueFormatting.getDefaultValueDisplayString(value, DBDDisplayFormat.UI));
    }
    return strValues;
}
Also used : ArrayList(java.util.ArrayList) PostgreAttribute(org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute)

Example 4 with PostgreAttribute

use of org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute in project dbeaver by dbeaver.

the class PostgreConstraintConfigurator method configureObject.

@Override
public PostgreTableConstraint configureObject(DBRProgressMonitor monitor, Object parent, PostgreTableConstraint constraint) {
    return UITask.run(() -> {
        EditConstraintPage editPage = new EditConstraintPage(PostgreMessages.edit_constraint_page_add_constraint, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY, DBSEntityConstraintType.CHECK });
        if (!editPage.edit()) {
            return null;
        }
        constraint.setName(editPage.getConstraintName());
        constraint.setConstraintType(editPage.getConstraintType());
        if (constraint.getConstraintType().isCustom()) {
            constraint.setSource(editPage.getConstraintExpression());
        } else {
            int colIndex = 1;
            for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
                constraint.addColumn(new PostgreTableConstraintColumn(constraint, (PostgreAttribute) tableColumn, colIndex++));
            }
        }
        return constraint;
    });
}
Also used : DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) PostgreTableConstraintColumn(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraintColumn) EditConstraintPage(org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage) PostgreTableConstraint(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraint) PostgreAttribute(org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute)

Aggregations

PostgreAttribute (org.jkiss.dbeaver.ext.postgresql.model.PostgreAttribute)4 ArrayList (java.util.ArrayList)2 PostgreTableConstraint (org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraint)2 PostgreTableConstraintColumn (org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraintColumn)2 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)2 EditConstraintPage (org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage)2