Skip to content

Commit

Permalink
GEN-1836: Table custom property enhancements (#18239)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonika-shah authored and Sachin-chaurasiya committed Oct 15, 2024
1 parent 1252698 commit dfb7a3c
Show file tree
Hide file tree
Showing 36 changed files with 419 additions and 380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1556,12 +1556,6 @@ private void validateTableType(JsonNode fieldValue, String propertyConfig, Strin
+ undefinedColumns);
}

if (fieldValue.get("rows").size() > tableConfig.getRowCount()) {
throw new IllegalArgumentException(
"Number of rows should be less than or equal to the expected row count "
+ tableConfig.getRowCount());
}

Set<String> rowFieldNames = new HashSet<>();
fieldValue.get("rows").forEach(row -> row.fieldNames().forEachRemaining(rowFieldNames::add));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static org.openmetadata.service.util.EntityUtil.getCustomField;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -243,12 +242,6 @@ private void validateTableTypeConfig(CustomPropertyConfig config) {
JsonNode configNode = JsonUtils.valueToTree(config.getConfig());
TableConfig tableConfig = JsonUtils.convertValue(config.getConfig(), TableConfig.class);

// rowCount is optional, if not present set it to the default value
if (!configNode.has("rowCount")) {
((ObjectNode) configNode).put("rowCount", tableConfig.getRowCount());
config.setConfig(configNode);
}

List<String> columns = new ArrayList<>();
configNode.path("columns").forEach(node -> columns.add(node.asText()));
Set<String> uniqueColumns = new HashSet<>(columns);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,26 +342,6 @@ void put_patch_customProperty_table_200() throws IOException {
+ " and "
+ tableConfig.getMaxColumns());

tableTypeFieldA.setCustomPropertyConfig(
new CustomPropertyConfig()
.withConfig(
new TableConfig()
.withColumns(Set.of("column-1", "column-2", "column-3"))
.withRowCount(200)));
ChangeDescription change2 = getChangeDescription(databaseEntity, MINOR_UPDATE);
Type databaseEntity2 = databaseEntity;
assertResponseContains(
() ->
addCustomPropertyAndCheck(
databaseEntity2.getId(),
tableTypeFieldA,
ADMIN_AUTH_HEADERS,
MINOR_UPDATE,
change2),
Status.BAD_REQUEST,
"Custom Property table has invalid value rowCount must be less than or equal to "
+ tableConfig.getMaxRows());

ObjectMapper mapper = new ObjectMapper();
ObjectNode tableConfigJson = mapper.createObjectNode();
ArrayNode columnsArray = tableConfigJson.putArray("columns");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@
"type": "string",
"description": "The cell value of each column in the row."
}
},
"minItems": 1,
"maxItems": 10
}
}
},
"required": ["columns"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
"maxItems": 3,
"uniqueItems": true
},
"rowCount": {
"type": "integer",
"default": 10,
"description": "Number of rows. Defaults to maxRows if not explicitly set.",
"minimum": 1,
"maximum": 10
},
"minColumns": {
"type": "integer",
"default": 1,
Expand All @@ -33,16 +26,6 @@
"type": "integer",
"default": 3,
"$comment": "For internal use only: Maximum number of columns."
},
"minRows": {
"type": "integer",
"default": 1,
"$comment": "For internal use only: Minimum number of rows."
},
"maxRows": {
"type": "integer",
"default": 10,
"$comment": "For internal use only: Maximum number of rows."
}
},
"required": ["columns"],
Expand Down
Loading

0 comments on commit dfb7a3c

Please sign in to comment.