forked from avniproject/avni-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avniproject#762 | Dataset Request Body Created
- Loading branch information
1 parent
74ec09d
commit 19b66fd
Showing
6 changed files
with
65 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
avni-server-api/src/main/java/org/avni/server/domain/metabase/DatasetRequestBody.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.avni.server.domain.metabase; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
public class DatasetRequestBody { | ||
|
||
private final Database database; | ||
private final TableDetails table; | ||
|
||
public DatasetRequestBody(Database database, TableDetails table) { | ||
this.database = database; | ||
this.table = table; | ||
} | ||
|
||
public ObjectNode toJson(ObjectMapper objectMapper) { | ||
ObjectNode rootNode = objectMapper.createObjectNode(); | ||
rootNode.put("database", database.getId()); | ||
|
||
ObjectNode queryNode = objectMapper.createObjectNode(); | ||
queryNode.put("source-table", table.getId()); | ||
|
||
rootNode.set("query", queryNode); | ||
rootNode.put("type", "query"); | ||
rootNode.set("parameters", objectMapper.createArrayNode()); | ||
|
||
return rootNode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
avni-server-api/src/main/java/org/avni/server/service/metabase/QuestionCreationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package org.avni.server.service.metabase; | ||
import org.avni.server.domain.metabase.FieldDetails; | ||
import org.avni.server.domain.metabase.TableDetails; | ||
|
||
public interface QuestionCreationService { | ||
void createQuestionForTable(TableDetails tableDetails, TableDetails addressTableDetails, String addressField, String tableField) throws Exception; | ||
void createQuestionForTable(TableDetails tableDetails, TableDetails addressTableDetails, FieldDetails addressFieldDetails, FieldDetails tableFieldDetails) throws Exception; | ||
void createQuestionForTable(String tableName, String schema) throws Exception; | ||
} |