Skip to content

Commit f32694f

Browse files
author
gdgate
authored
Merge pull request #967 from anvuong119/anvuong-sd1212
Add "type" property to AttributeHeader so that the type of a display form can be passed to an AFM execution response Reviewed-by: Libor Ryšavý https://github.com/liry
2 parents ac293f0 + bc5ccad commit f32694f

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed

gooddata-java-model/src/main/java/com/gooddata/sdk/model/executeafm/response/AttributeHeader.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class AttributeHeader implements Header, LocallyIdentifiable {
3030
private final String localIdentifier;
3131
private final String uri;
3232
private final String identifier;
33+
private final String type;
3334
private final AttributeInHeader formOf;
3435

3536
private List<TotalHeaderItem> totalItems;
@@ -55,17 +56,38 @@ public AttributeHeader(final String name, final String localIdentifier, final St
5556
* @param formOf info about attribute which this header's display form is form of
5657
* @param totalHeaderItems total header items
5758
*/
59+
public AttributeHeader(@JsonProperty("name") final String name,
60+
@JsonProperty("localIdentifier") final String localIdentifier,
61+
@JsonProperty("uri") final String uri,
62+
@JsonProperty("identifier") final String identifier,
63+
@JsonProperty("formOf") final AttributeInHeader formOf,
64+
@JsonProperty("totalItems") final List<TotalHeaderItem> totalHeaderItems) {
65+
this(name, localIdentifier, uri, identifier, null, formOf, totalHeaderItems);
66+
}
67+
68+
/**
69+
* Creates new header
70+
* @param name name
71+
* @param localIdentifier local identifier
72+
* @param uri uri
73+
* @param identifier identifier
74+
* @param type type
75+
* @param formOf info about attribute which this header's display form is form of
76+
* @param totalHeaderItems total header items
77+
*/
5878
@JsonCreator
5979
public AttributeHeader(@JsonProperty("name") final String name,
6080
@JsonProperty("localIdentifier") final String localIdentifier,
6181
@JsonProperty("uri") final String uri,
6282
@JsonProperty("identifier") final String identifier,
83+
@JsonProperty("type") final String type,
6384
@JsonProperty("formOf") final AttributeInHeader formOf,
6485
@JsonProperty("totalItems") final List<TotalHeaderItem> totalHeaderItems) {
6586
this.name = notEmpty(name, "name");
6687
this.localIdentifier = notEmpty(localIdentifier, "localIdentifier");
6788
this.uri = notEmpty(uri, "uri");
6889
this.identifier = notEmpty(identifier, "identifier");
90+
this.type = type;
6991
this.formOf = notNull(formOf, "formOf");
7092
this.totalItems = totalHeaderItems;
7193
}
@@ -104,6 +126,14 @@ public String getIdentifier() {
104126
return identifier;
105127
}
106128

129+
/**
130+
* Metadata type of attribute's display form
131+
* @return type
132+
*/
133+
public String getType() {
134+
return type;
135+
}
136+
107137
public AttributeInHeader getFormOf() {
108138
return formOf;
109139
}

gooddata-java-model/src/test/groovy/com/gooddata/sdk/model/executeafm/response/AttributeHeaderTest.groovy

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@ import static spock.util.matcher.HamcrestSupport.that
1515
class AttributeHeaderTest extends Specification {
1616

1717
private static final String ATTRIBUTE_HEADER_JSON = 'executeafm/response/attributeHeader.json'
18+
private static final String ATTRIBUTE_HEADER_EXCEPT_TYPE_JSON = 'executeafm/response/attributeHeaderExceptType.json'
1819
private static final String ATTRIBUTE_HEADER_FULL_JSON = 'executeafm/response/attributeHeaderFull.json'
1920

2021
private static final AttributeInHeader FORM_OF = new AttributeInHeader('Some attr', '/gdc/md/project_id/obj/567', 'attr.some.id')
2122

2223
def "should serialize full"() {
2324
expect:
24-
that new AttributeHeader('Name', 'a1', '/gdc/md/project_id/obj/123', 'attr.dataset.name', FORM_OF, [new TotalHeaderItem('sum')]),
25+
that new AttributeHeader('Name', 'a1', '/gdc/md/project_id/obj/123', 'attr.dataset.name', 'GDC.time.day_us', FORM_OF, [new TotalHeaderItem('sum')]),
2526
jsonEquals(resource(ATTRIBUTE_HEADER_FULL_JSON))
2627
}
2728

29+
def "should serialize except type"() {
30+
expect:
31+
that new AttributeHeader('Name', 'a1', '/gdc/md/project_id/obj/123', 'attr.dataset.name', FORM_OF, [new TotalHeaderItem('sum')]),
32+
jsonEquals(resource(ATTRIBUTE_HEADER_EXCEPT_TYPE_JSON))
33+
}
34+
2835
def "should serialize"() {
2936
expect:
3037
that new AttributeHeader('Name', 'a1', '/gdc/md/project_id/obj/123', 'attr.dataset.name', FORM_OF),
@@ -43,6 +50,22 @@ class AttributeHeaderTest extends Specification {
4350
header.formOf == FORM_OF
4451
}
4552

53+
def "should deserialize except type"() {
54+
when:
55+
AttributeHeader header = readObjectFromResource("/$ATTRIBUTE_HEADER_EXCEPT_TYPE_JSON", AttributeHeader)
56+
57+
then:
58+
header.name == 'Name'
59+
header.localIdentifier == 'a1'
60+
header.uri == '/gdc/md/project_id/obj/123'
61+
header.identifier == 'attr.dataset.name'
62+
header.type == null
63+
header.formOf == FORM_OF
64+
header.totalItems.size() == 1
65+
header.totalItems.first().name == 'sum'
66+
header.toString()
67+
}
68+
4669
def "should deserialize full"() {
4770
when:
4871
AttributeHeader header = readObjectFromResource("/$ATTRIBUTE_HEADER_FULL_JSON", AttributeHeader)
@@ -52,6 +75,7 @@ class AttributeHeaderTest extends Specification {
5275
header.localIdentifier == 'a1'
5376
header.uri == '/gdc/md/project_id/obj/123'
5477
header.identifier == 'attr.dataset.name'
78+
header.type == 'GDC.time.day_us'
5579
header.formOf == FORM_OF
5680
header.totalItems.size() == 1
5781
header.totalItems.first().name == 'sum'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"attributeHeader": {
3+
"name": "Name",
4+
"localIdentifier": "a1",
5+
"uri": "/gdc/md/project_id/obj/123",
6+
"identifier": "attr.dataset.name",
7+
"formOf": {
8+
"name": "Some attr",
9+
"uri": "/gdc/md/project_id/obj/567",
10+
"identifier": "attr.some.id"
11+
},
12+
"totalItems": [
13+
{
14+
"totalHeaderItem": {
15+
"name": "sum"
16+
}
17+
}
18+
]
19+
}
20+
}

gooddata-java-model/src/test/resources/executeafm/response/attributeHeaderFull.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"localIdentifier": "a1",
55
"uri": "/gdc/md/project_id/obj/123",
66
"identifier": "attr.dataset.name",
7+
"type": "GDC.time.day_us",
78
"formOf": {
89
"name": "Some attr",
910
"uri": "/gdc/md/project_id/obj/567",

0 commit comments

Comments
 (0)