@JsonCreator public static FieldType fromString(String key) { return key == null ? null : FieldType.valueOf(key.toUpperCase()); }
@Override public Map<String, List<SchemaField>> getCollections(String project) { QueryResult query = dynamoDBClient.query(new QueryRequest() .withTableName(tableConfig.getTableName()) .withKeyConditions(ImmutableMap.of("project", new Condition() .withComparisonOperator(EQ) .withAttributeValueList(new AttributeValue(project))))); Map<String, List<SchemaField>> builder = new HashMap(); for (Map<String, AttributeValue> entry : query.getItems()) { if (entry.get("id").getS().equals("|")) { continue; } builder.computeIfAbsent(entry.get("collection").getS(), (k) -> new ArrayList<>()).add(new SchemaField( entry.get("name").getS(), FieldType.valueOf(entry.get("type").getS()))); } return builder; }
@Override public List<SchemaField> getCollection(String project, String collection) { QueryResult query = dynamoDBClient.query(new QueryRequest() .withTableName(tableConfig.getTableName()) .withKeyConditions(ImmutableMap.of("project", new Condition().withComparisonOperator(EQ).withAttributeValueList(new AttributeValue(project)))) .withQueryFilter( ImmutableMap.of("collection", new Condition().withComparisonOperator(EQ) .withAttributeValueList(new AttributeValue(collection))))); return query.getItems().stream() .filter(e -> !e.get("id").getS().equals("|")) .map(e -> new SchemaField(e.get("name").getS(), FieldType.valueOf(e.get("type").getS()))) .collect(Collectors.toList()); }