use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by dbeaver.
the class MySQLIndexConfigurator method configureObject.
@Override
public MySQLTableIndex configureObject(DBRProgressMonitor monitor, Object parent, MySQLTableIndex index) {
return UITask.run(() -> {
MyEditIndexPage editPage = new MyEditIndexPage(index);
if (!editPage.edit()) {
return null;
}
StringBuilder idxName = new StringBuilder(64);
idxName.append(CommonUtils.escapeIdentifier(index.getParentObject().getName()));
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
if (colIndex == 1) {
// $NON-NLS-1$
idxName.append("_").append(CommonUtils.escapeIdentifier(tableColumn.getName()));
}
Integer length = (Integer) editPage.getAttributeProperty(tableColumn, MyEditIndexPage.PROP_LENGTH);
index.addColumn(new MySQLTableIndexColumn(index, (MySQLTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC)), false, length == null ? null : String.valueOf(length)));
}
// $NON-NLS-1$
idxName.append("_IDX");
index.setName(DBObjectNameCaseTransformer.transformObjectName(index, idxName.toString()));
index.setName(idxName.toString());
index.setIndexType(editPage.getIndexType());
index.setUnique(editPage.isUnique());
return index;
});
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by dbeaver.
the class SQLGeneratorSelect method generateSQL.
@Override
public void generateSQL(DBRProgressMonitor monitor, StringBuilder sql, DBSEntity object) throws DBException {
sql.append("SELECT ");
boolean hasAttr = false;
if (columnList) {
for (DBSEntityAttribute attr : getAllAttributes(monitor, object)) {
if (DBUtils.isHiddenObject(attr)) {
continue;
}
if (hasAttr)
sql.append(", ");
sql.append(DBUtils.getObjectFullName(attr, DBPEvaluationContext.DML));
hasAttr = true;
}
if (hasAttr) {
sql.append(getLineSeparator());
}
}
if (!hasAttr) {
sql.append("* ");
}
sql.append("FROM ").append(getEntityName(object));
sql.append(";\n");
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by dbeaver.
the class SQLGeneratorUpdate method generateSQL.
@Override
public void generateSQL(DBRProgressMonitor monitor, StringBuilder sql, DBSEntity object) throws DBException {
Collection<? extends DBSEntityAttribute> keyAttributes = getKeyAttributes(monitor, object);
sql.append("UPDATE ").append(getEntityName(object)).append(getLineSeparator()).append("SET ");
boolean hasAttr = false;
for (DBSAttributeBase attr : getValueAttributes(monitor, object, keyAttributes)) {
if (DBUtils.isPseudoAttribute(attr) || DBUtils.isHiddenObject(attr)) {
continue;
}
if (hasAttr)
sql.append(", ");
sql.append(DBUtils.getObjectFullName(attr, DBPEvaluationContext.DML)).append("=");
appendDefaultValue(sql, attr);
hasAttr = true;
}
if (!CommonUtils.isEmpty(keyAttributes)) {
sql.append(getLineSeparator()).append("WHERE ");
hasAttr = false;
for (DBSEntityAttribute attr : keyAttributes) {
if (hasAttr)
sql.append(" AND ");
sql.append(DBUtils.getObjectFullName(attr, DBPEvaluationContext.DML)).append("=");
appendDefaultValue(sql, attr);
hasAttr = true;
}
}
sql.append(";\n");
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by dbeaver.
the class SQLGeneratorDelete method generateSQL.
@Override
public void generateSQL(DBRProgressMonitor monitor, StringBuilder sql, DBSEntity object) throws DBException {
sql.append("DELETE FROM ").append(getEntityName(object)).append(getLineSeparator()).append("WHERE ");
Collection<? extends DBSEntityAttribute> keyAttributes = getKeyAttributes(monitor, object);
if (CommonUtils.isEmpty(keyAttributes)) {
keyAttributes = getAllAttributes(monitor, object);
}
boolean hasAttr = false;
for (DBSEntityAttribute attr : keyAttributes) {
if (hasAttr)
sql.append(" AND ");
sql.append(DBUtils.getObjectFullName(attr, DBPEvaluationContext.DML)).append("=");
appendDefaultValue(sql, attr);
hasAttr = true;
}
sql.append(";\n");
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by dbeaver.
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());
}
Aggregations