Skip to content

Commit

Permalink
NMS-16510: [ci skip] issue fix, added assets.
Browse files Browse the repository at this point in the history
  • Loading branch information
MusaidAli committed Oct 1, 2024
1 parent a538508 commit 52d0293
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,39 @@ public String constructJoinExprForTables(final List<Table> tables) {
*/
public String addColumn(final List<Table> tables, final String column) throws FilterParseException {
getReadLock().lock();
try {
final Table table = findTableByVisibleColumn(column);
if(table == null) {
final String message = "Could not find the column '" + column +"' in filter rule";
throw new FilterParseException(message);
if (doesColumnExist(column)) {
try {
final Table table = findTableByVisibleColumn(column);
if (table == null) {
final String message = "Could not find the column '" + column + "' in filter rule";
throw new FilterParseException(message);
}
if (!tables.contains(table)) {
tables.add(table);
}
return table.getName() + "." + column;
} finally {
getReadLock().unlock();
}
if (!tables.contains(table)) {
tables.add(table);
}
return "";
}
/**
* Validate that a column is in the schema.
* @return boolean
*
*/
public boolean doesColumnExist(String colName) {
for (final Table t : getDatabaseSchema().getTables()) {
for (final Column col : t.getColumns()) {
if (col.getVisible() == null || col.getVisible().equalsIgnoreCase("true")) {
if (col.getName().equalsIgnoreCase(colName)) {
return true; // Column found
}
}
}
return table.getName() + "." + column;
} finally {
getReadLock().unlock();
}
return false; // Column not found
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ public String getNodeMappingStatement(final String rule) throws FilterParseExcep
columns.append(m_databaseSchemaConfigFactory.addColumn(tables, "nodeID"));
columns.append(", " + m_databaseSchemaConfigFactory.addColumn(tables, "nodeLabel"));

//added table assets column
columns.append(", " + m_databaseSchemaConfigFactory.addColumn(tables, "city"));
columns.append(", " + m_databaseSchemaConfigFactory.addColumn(tables, "department"));
columns.append(", " + m_databaseSchemaConfigFactory.addColumn(tables, "address1"));

final String where = parseRule(tables, rule);
final String from = m_databaseSchemaConfigFactory.constructJoinExprForTables(tables);

Expand Down Expand Up @@ -708,6 +713,7 @@ private String parseRule(final List<Table> tables, final String rule) throws Fil
}
regex.appendTail(tempStringBuff);
sqlRule = tempStringBuff.toString();
if(!sqlRule.isEmpty())
return "WHERE " + sqlRule;
}
return "";
Expand Down

0 comments on commit 52d0293

Please sign in to comment.