<dependency>
<groupId>com.gooddata</groupId>
<artifactId>gooddata-java</artifactId>
<version>${gooddata-java.version}</version>
</dependency>
The GoodData Java SDK uses the GoodData HTTP client (version 0.8.2 or later) and the Apache HTTP Client (version 4.3 or later).
GoodData gd = new GoodData("[email protected]", "Roman1");
gd.logout();
List projects, create a project,...
ProjectService projectService = gd.getProjectService();
Collection<Project> projects = projectService.getProjects();
Project project = projectService.createProject(new Project("my project", "MyToken"));
Create and update the project model, execute MAQL DDL,...
ModelService modelService = gd.getModelService();
ModelDiff diff = modelService.getProjectModelDiff(project, new FileInputStream("model.json");
modelService.updateProjectModel(project, diff);
modelService.updateProjectModel(project, "MAQL DDL EXPRESSION");
Query, create and update project metadata - attributes, facts, metrics, reports,...
MetadataService md = gd.getMetadataService();
String factUri = md.getObjUri(project, Fact.class, Restriction.title("myfact"));
Metric metric = new Metric("my sum", "SELECT SUM([" + factUri + "])", "#,##0");
Metric m = md.createObj(project, metric);
ReportDefinition definition = GridReportDefinition.create(
"my report",
asList("metricGroup"),
asList(new AttributeItem("/gdc/md/PROJECT_ID/obj/ID")),
asList(new Item("/gdc/md/PROJECT_ID/obj/ID"))
);
md.createMd(project, definition);
Upload data to datasets,..
DatasetService datasetService = gd.getDatasetService();
datasetService.loadDataset(project, "datasetId", new FileInputStream("data.csv"));
Execute and export reports.
ReportService reportService = gd.getReportService();
String imgUri = reportService.exportReport(reportDef, "png");
Manage files on the data store (currently backed by WebDAV) - user staging area.
DataStoreService dataStoreService = gd.getDataStoreService();
dataStoreService.upload("/dir/file.txt", new FileInputStream("file.txt"));
InputStream stream = dataStoreService.download("/dir/file.txt");
dataStoreService.delete("/dir/file.txt");