Search in sources :

Example 1 with AttributeDescription

use of org.molgenis.data.postgresql.identifier.AttributeDescription in project molgenis by molgenis.

the class PostgreSqlExceptionTranslator method getAttributeName.

/**
 * Returns the attribute name for this table name
 *
 * @param tableName table name
 * @param colName   column name
 * @return attribute name
 */
private String getAttributeName(String tableName, String colName) {
    EntityTypeDescription entityTypeDescription = entityTypeRegistry.getEntityTypeDescription(tableName);
    if (entityTypeDescription == null) {
        throw new RuntimeException(format("Unknown entity for table name [%s]", tableName));
    }
    AttributeDescription attrDescription = entityTypeDescription.getAttributeDescriptionMap().get(colName);
    if (attrDescription == null) {
        throw new RuntimeException(format("Unknown attribute for column name [%s]", colName));
    }
    return attrDescription.getName();
}
Also used : EntityTypeDescription(org.molgenis.data.postgresql.identifier.EntityTypeDescription) AttributeDescription(org.molgenis.data.postgresql.identifier.AttributeDescription)

Aggregations

AttributeDescription (org.molgenis.data.postgresql.identifier.AttributeDescription)1 EntityTypeDescription (org.molgenis.data.postgresql.identifier.EntityTypeDescription)1