use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by serge-rider.
the class EditDictionaryPage method handleColumnsChange.
@Override
protected void handleColumnsChange() {
descColumns = getSelectedAttributes();
StringBuilder custom = new StringBuilder();
for (DBSEntityAttribute column : descColumns) {
if (custom.length() > 0) {
custom.append(",");
}
custom.append(DBUtils.getQuotedIdentifier(column));
}
criteriaText.setText(custom.toString());
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by serge-rider.
the class MySQLConstraintConfigurator method configureObject.
@Override
public MySQLTableConstraint configureObject(DBRProgressMonitor monitor, Object parent, MySQLTableConstraint constraint) {
MySQLDataSource dataSource = constraint.getDataSource();
return UITask.run(() -> {
EditConstraintPage editPage;
if (dataSource.supportsCheckConstraints()) {
editPage = new EditConstraintPage(MySQLUIMessages.edit_constraint_manager_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY, DBSEntityConstraintType.CHECK });
} else {
editPage = new EditConstraintPage(MySQLUIMessages.edit_constraint_manager_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY });
}
if (!editPage.edit()) {
return null;
}
constraint.setName(editPage.getConstraintName());
constraint.setConstraintType(editPage.getConstraintType());
if (editPage.getConstraintType() == DBSEntityConstraintType.CHECK && dataSource.supportsCheckConstraints()) {
constraint.setCheckClause(editPage.getConstraintExpression());
} else {
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
constraint.addColumn(new MySQLTableConstraintColumn(constraint, (MySQLTableColumn) tableColumn, colIndex++));
}
}
return constraint;
});
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by serge-rider.
the class SQLGeneratorInsert method generateSQL.
@Override
public void generateSQL(DBRProgressMonitor monitor, StringBuilder sql, DBSEntity object) throws DBException {
sql.append("INSERT INTO ").append(getEntityName(object)).append(getLineSeparator()).append("(");
boolean hasAttr = false;
for (DBSEntityAttribute attr : getAllAttributes(monitor, object)) {
if (DBUtils.isPseudoAttribute(attr) || DBUtils.isHiddenObject(attr) || attr.isAutoGenerated()) {
continue;
}
if (hasAttr)
sql.append(", ");
sql.append(DBUtils.getObjectFullName(attr, DBPEvaluationContext.DML));
hasAttr = true;
}
sql.append(")").append(getLineSeparator()).append("VALUES(");
hasAttr = false;
for (DBSEntityAttribute attr : getAllAttributes(monitor, object)) {
if (DBUtils.isPseudoAttribute(attr) || DBUtils.isHiddenObject(attr) || attr.isAutoGenerated()) {
continue;
}
if (hasAttr)
sql.append(", ");
appendDefaultValue(sql, attr);
hasAttr = true;
}
sql.append(");\n");
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by serge-rider.
the class ComplexTypeAttributeTransformer method createNestedTypeBindings.
static void createNestedTypeBindings(DBCSession session, DBDAttributeBinding attribute, List<Object[]> rows, DBSEntity dataType) throws DBException {
List<DBDAttributeBinding> nestedBindings = new ArrayList<>();
for (DBSEntityAttribute nestedAttr : CommonUtils.safeCollection(dataType.getAttributes(session.getProgressMonitor()))) {
DBDAttributeBindingType nestedBinding = new DBDAttributeBindingType(attribute, nestedAttr, nestedBindings.size());
nestedBinding.lateBinding(session, rows);
nestedBindings.add(nestedBinding);
}
if (!nestedBindings.isEmpty()) {
attribute.setNestedBindings(nestedBindings);
}
}
Aggregations