forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelExample.java
More file actions
98 lines (90 loc) · 4.16 KB
/
Copy pathModelExample.java
File metadata and controls
98 lines (90 loc) · 4.16 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
*/
package com.gooddata;
import com.gooddata.model.DiffRequest;
import com.gooddata.model.ModelDiff;
import com.gooddata.model.ModelService;
import com.gooddata.project.Project;
import org.codehaus.jackson.map.ObjectMapper;
import java.io.IOException;
/**
* TODO
*/
public class ModelExample {
public static void main(String... args) {
final GoodData gd = new GoodData("staging.getgooddata.com", "jiri.mikulasek@gooddata.com", "jindrisska");
final ModelService modelService = gd.getModelService();
final Project project = gd.getProjectService().getProjectById("amxhoeyj7oskijld63tajq0o9f4nhxy7");
final ModelDiff projectModelDiff = modelService.getProjectModelDiff(project, new DiffRequest(projectModelData));
modelService.updateProjectModel(project, projectModelDiff);
gd.logout();
}
public static final String projectModelData = "{\"projectModel\": {\"datasets\": [\n"
+ "{\n"
+ " \"dataset\": {\n"
+ " \"identifier\": \"dataset.person\",\n"
+ " \"title\": \"Person\",\n"
+ " \"description\": \"Dataset with Person-related data\",\n"
+ " \"anchor\": {\n"
+ " \"attribute\": {\n"
+ " \"identifier\": \"attr.person.id\",\n"
+ " \"title\": \"Person ID\",\n"
+ " \"labels\": [\n"
+ " {\n"
+ " \"label\": {\n"
+ " \"identifier\": \"attr.person.id.name\",\n"
+ " \"title\": \"Person Name\"\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " },\n"
+ " \"attributes\": [\n"
+ " {\n"
+ " \"attribute\": {\n"
+ " \"identifier\": \"attr.person.department\",\n"
+ " \"title\": \"Department\",\n"
+ " \"labels\": [\n"
+ " {\n"
+ " \"label\": {\n"
+ " \"identifier\": \"attr.person.xdepartment\",\n"
+ " \"title\": \"Department\"\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"attribute\": {\n"
+ " \"identifier\": \"attr.person.role\",\n"
+ " \"title\": \"Person Role\",\n"
+ " \"labels\": [\n"
+ " {\n"
+ " \"label\": {\n"
+ " \"identifier\": \"attr.person.xrole\",\n"
+ " \"title\": \"Person Role\"\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " }\n"
+ " ],\n"
+ " \"facts\": [\n"
+ " {\n"
+ " \"fact\": {\n"
+ " \"identifier\": \"fact.person.age\",\n"
+ " \"title\": \"Person Age\"\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"fact\": {\n"
+ " \"identifier\": \"fact.person.shoesize\",\n"
+ " \"title\": \"Person Shoe Size\"\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}"
+ "]}}";
}