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 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 serge-rider.
the class DBDAttributeBindingMeta method lateBinding.
@Override
public void lateBinding(@NotNull DBCSession session, List<Object[]> rows) throws DBException {
DBSEntityAttribute entityAttribute = getEntityAttribute();
if (entityAttribute != null) {
referrers = DBUtils.getAttributeReferrers(session.getProgressMonitor(), entityAttribute, true);
}
super.lateBinding(session, rows);
}
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 dbeaver.
the class SQLServerIndexConfigurator method configureObject.
@Override
public SQLServerTableIndex configureObject(DBRProgressMonitor monitor, Object container, SQLServerTableIndex index) {
return UITask.run(() -> {
EditIndexPage editPage = new EditIndexPage("Create index", index, Arrays.asList(SQLSERVER_INDEX_TYPES));
if (!editPage.edit()) {
return null;
}
index.setUnique(editPage.isUnique());
index.setIndexType(editPage.getIndexType());
index.setDescription(editPage.getDescription());
StringBuilder idxName = new StringBuilder(64);
idxName.append(CommonUtils.escapeIdentifier(index.getTable().getName()));
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
if (colIndex == 1) {
idxName.append("_").append(CommonUtils.escapeIdentifier(tableColumn.getName()));
}
index.addColumn(new SQLServerTableIndexColumn(index, 0, (SQLServerTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC))));
}
idxName.append("_IDX");
index.setName(DBObjectNameCaseTransformer.transformObjectName(index, idxName.toString()));
return index;
});
}
Aggregations