forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.java
More file actions
55 lines (41 loc) · 2.11 KB
/
Copy pathExample.java
File metadata and controls
55 lines (41 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
*/
package com.gooddata;
import com.gooddata.account.Account;
import com.gooddata.account.AccountService;
import com.gooddata.dataset.DatasetManifest;
import com.gooddata.dataset.DatasetService;
import com.gooddata.md.Fact;
import com.gooddata.md.MetadataService;
import com.gooddata.md.Metric;
import com.gooddata.md.Restriction;
import com.gooddata.md.report.ReportDefinition;
import com.gooddata.project.Project;
import com.gooddata.project.ProjectService;
import com.gooddata.report.ReportService;
import java.util.Collection;
public class Example {
public static void main(String... args) {
final GoodData gd = new GoodData("roman@gooddata.com", "Roman1");
final AccountService accountService = gd.getAccountService();
final Account current = accountService.getCurrent();
System.out.println(current.getId());
final ProjectService projectService = gd.getProjectService();
final Collection<Project> projects = projectService.getProjects();
System.out.println(projects);
final Project project = projectService.createProject(new Project("sparkling", "pgroup2"));
System.out.println(project.getLinks().getSelf());
final MetadataService md = gd.getMetadataService();
final String factUri = md.getObjUri(project, Fact.class, Restriction.title("myfact"));
final Metric m = md.createObj(project, new Metric("my sum", "SELECT SUM([" + factUri + "])", "#,##0"));
final DatasetService datasetService = gd.getDatasetService();
final DatasetManifest manifest = datasetService.getDatasetManifest(project, "dataset.person");
datasetService.loadDataset(project, manifest, Example.class.getResourceAsStream("/person.csv"));
final ReportDefinition reportDef = md.getObjByUri("/gdc/md/GoodSalesDemoKokot1/obj/1962", ReportDefinition.class);
final ReportService reportService = gd.getReportService();
final String imgUri = reportService.exportReport(reportDef, "csv");
System.out.println(imgUri);
gd.logout();
}
}