Skip to content

Commit f1117f1

Browse files
feat: Add createdBy and lastUpdatedBy (#511)
1 parent e0efbbc commit f1117f1

30 files changed

+92
-33
lines changed

src/main/java/org/hisp/dhis/api/ApiFields.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ApiFields {
4646

4747
/** Identifiable object extended fields. */
4848
public static final String ID_EXT_FIELDS =
49-
String.format("%s,translations,sharing,access", ID_FIELDS);
49+
String.format("%s,createdBy,lastUpdatedBy,translations,sharing,access", ID_FIELDS);
5050

5151
/** Nameable object fields. */
5252
public static final String NAME_FIELDS = String.format("%s,shortName,description", ID_FIELDS);
@@ -334,8 +334,8 @@ public class ApiFields {
334334
/** Program indicator fields. */
335335
public static final String PROGRAM_INDICATOR_FIELDS =
336336
String.format(
337-
"%1$s,program[%1$s],expression,filter,decimals,aggregationType,analyticsType",
338-
NAME_FIELDS);
337+
"%1$s,program[%2$s],expression,filter,decimals,aggregationType,analyticsType",
338+
NAME_EXT_FIELDS, NAME_FIELDS);
339339

340340
/** Program section fields. */
341341
public static final String PROGRAM_SECTION_FIELDS =

src/main/java/org/hisp/dhis/model/IdentifiableObject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.hisp.dhis.model.acl.Access;
4141
import org.hisp.dhis.model.sharing.Sharing;
4242
import org.hisp.dhis.model.translation.Translation;
43+
import org.hisp.dhis.model.user.User;
4344

4445
@Getter
4546
@Setter
@@ -54,8 +55,12 @@ public class IdentifiableObject implements Serializable {
5455

5556
@JsonProperty protected Date created;
5657

58+
@JsonProperty protected User createdBy;
59+
5760
@JsonProperty protected Date lastUpdated;
5861

62+
@JsonProperty protected User lastUpdatedBy;
63+
5964
/** Attribute values. */
6065
@JsonProperty protected Set<AttributeValue> attributeValues = new HashSet<>();
6166

src/test/java/org/hisp/dhis/ApiFieldsTest.java

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,23 @@ class ApiFieldsTest {
4040
void testProgramStageFields() {
4141
String expected =
4242
"""
43-
id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
43+
id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
44+
translations,sharing,access,shortName,description,formName,\
4445
program[id,code,name,created,lastUpdated,attributeValues],\
45-
programStageDataElements[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
46+
programStageDataElements[id,code,name,created,lastUpdated,attributeValues,\
47+
createdBy,lastUpdatedBy,translations,sharing,access,shortName,description,formName,\
4648
programStage[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
47-
dataElement[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
48-
aggregationType,valueType,domainType,url,categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
49+
dataElement[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
50+
translations,sharing,access,shortName,description,formName,\
51+
aggregationType,valueType,domainType,url,categoryCombo[id,code,name,created,\
52+
lastUpdated,attributeValues,shortName,description],\
4953
legendSets[id,code,name,created,lastUpdated,\
5054
attributeValues,shortName,description],\
51-
optionSet[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,valueType,version]],\
55+
optionSet[id,code,name,created,lastUpdated,attributeValues,createdBy,\
56+
lastUpdatedBy,translations,sharing,access,valueType,version]],\
5257
compulsory,displayInReports,skipSynchronization,skipAnalytics,allowFutureDate,sortOrder],\
53-
programStageSections[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,\
58+
programStageSections[id,code,name,created,lastUpdated,attributeValues,\
59+
createdBy,lastUpdatedBy,translations,sharing,access,\
5460
shortName,description,formName,programStage[id,code,name,created,lastUpdated,\
5561
attributeValues,shortName,description],sortOrder,\
5662
dataElements[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
@@ -67,30 +73,39 @@ void testProgramStageFields() {
6773
void testProgramExtFields() {
6874
String expected =
6975
"""
70-
id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
71-
trackedEntityType[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
76+
id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
77+
translations,sharing,access,shortName,description,formName,\
78+
trackedEntityType[id,code,name,created,lastUpdated,attributeValues,\
79+
createdBy,lastUpdatedBy,translations,sharing,access,shortName,description,formName,\
7280
trackedEntityTypeAttributes[id,\
7381
trackedEntityAttribute[id,code,name,created,lastUpdated,attributeValues,shortName,description,valueType,\
7482
aggregationType,confidential,unique,orgunitScope],displayInList,mandatory,searchable]],\
7583
categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description,\
76-
categories[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,dataDimensionType,dataDimension,\
84+
categories[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,\
85+
sharing,access,shortName,description,formName,dataDimensionType,dataDimension,\
7786
categoryOptions[id,code,name,created,lastUpdated,attributeValues],\
7887
categoryCombos[id,code,name,created,lastUpdated,attributeValues]]],\
7988
organisationUnits[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
80-
programSections[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,sortOrder,\
89+
programSections[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
90+
translations,sharing,access,shortName,description,formName,sortOrder,\
8191
program[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
8292
trackedEntityAttributes[id,code,name,created,lastUpdated,attributeValues,shortName,description]],\
83-
programStages[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
93+
programStages[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
94+
translations,sharing,access,shortName,description,formName,\
8495
program[id,code,name,created,lastUpdated,attributeValues],\
85-
programStageDataElements[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
96+
programStageDataElements[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
97+
translations,sharing,access,shortName,description,formName,\
8698
programStage[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
87-
dataElement[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
88-
aggregationType,valueType,domainType,url,categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
99+
dataElement[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,\
100+
sharing,access,shortName,description,formName,aggregationType,valueType,domainType,url,\
101+
categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
89102
legendSets[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
90-
optionSet[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,valueType,version]],\
103+
optionSet[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
104+
translations,sharing,access,valueType,version]],\
91105
compulsory,displayInReports,skipSynchronization,skipAnalytics,allowFutureDate,sortOrder],\
92-
programStageSections[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,\
93-
shortName,description,formName,programStage[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
106+
programStageSections[id,code,name,created,lastUpdated,attributeValues,createdBy,\
107+
lastUpdatedBy,translations,sharing,access,shortName,description,formName,\
108+
programStage[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
94109
sortOrder,dataElements[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
95110
programIndicators[id,code,name,created,lastUpdated,attributeValues,shortName,description]],\
96111
executionDateLabel,dueDateLabel,programStageLabel,eventLabel,\
@@ -99,11 +114,11 @@ void testProgramExtFields() {
99114
hideDueDate,enableUserAssignment,referral,featureType],\
100115
programTrackedEntityAttributes[id,code,name,program[id,code,name,created,lastUpdated,\
101116
attributeValues,shortName,description],\
102-
trackedEntityAttribute[id,code,name,created,lastUpdated,attributeValues,shortName,\
103-
description,valueType,aggregationType,confidential,unique,orgunitScope],\
117+
trackedEntityAttribute[id,code,name,created,lastUpdated,attributeValues,\
118+
shortName,description,valueType,aggregationType,confidential,unique,orgunitScope],\
104119
sortOrder,displayInList,mandatory,allowFutureDate,searchable],\
105-
programRuleVariables[id,code,name,created,lastUpdated,attributeValues,translations,\
106-
sharing,access,program[id,code,name,created,lastUpdated,attributeValues],\
120+
programRuleVariables[id,code,name,created,lastUpdated,attributeValues,createdBy,\
121+
lastUpdatedBy,translations,sharing,access,program[id,code,name,created,lastUpdated,attributeValues],\
107122
programRuleVariableSourceType,valueType,programStage[id,code,name,created,\
108123
lastUpdated,attributeValues],trackedEntityAttribute[id,code,name,created,\
109124
lastUpdated,attributeValues],useCodeForOptionSet,\
@@ -124,7 +139,7 @@ void testProgramExtFields() {
124139
void testProgramMinFields() {
125140
String expected =
126141
"""
127-
id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,\
142+
id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,sharing,access,shortName,description,\
128143
formName,trackedEntityType[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
129144
categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
130145
programSections[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
@@ -150,11 +165,11 @@ void testProgramMinFields() {
150165
void testUserFields() {
151166
String expected =
152167
"""
153-
id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,\
168+
id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,sharing,access,\
154169
username,firstName,surname,email,phoneNumber,externalAuth,lastLogin,disabled,interests,\
155170
organisationUnits[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
156-
groups[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access],\
157-
userRoles[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access],\
171+
groups[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,sharing,access],\
172+
userRoles[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,sharing,access],\
158173
dataViewOrganisationUnits[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
159174
teiSearchOrganisationUnits[id,code,name,created,lastUpdated,attributeValues,shortName,description]""";
160175

src/test/java/org/hisp/dhis/AttributeApiTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void testGetAttribute() {
5757
assertEquals("Classification", attribute.getName());
5858
assertEquals("CLASSIFICATION", attribute.getCode());
5959
assertNotNull(attribute.getCreated());
60+
assertNotNull(attribute.getCreatedBy());
6061
assertNotNull(attribute.getLastUpdated());
6162
}
6263

@@ -115,6 +116,7 @@ void testCreateUpdateAndDeleteAttributes() {
115116
assertEquals(uidA, attribute.getDescription());
116117
assertFalse(attribute.getUnique());
117118
assertFalse(attribute.getMandatory());
119+
assertNotNull(attribute.getCreatedBy());
118120

119121
attribute.setName(uidB);
120122

@@ -129,6 +131,7 @@ void testCreateUpdateAndDeleteAttributes() {
129131
assertNotNull(attribute);
130132
assertEquals(attributeUid, attribute.getId());
131133
assertEquals(uidB, attribute.getName());
134+
assertNotNull(attribute.getLastUpdatedBy());
132135

133136
// Remove
134137
ObjectResponse removeRespA = dhis2.removeAttribute(attributeUid);

src/test/java/org/hisp/dhis/CategoryApiTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void testGetCategory() {
5353
assertEquals("EC40NXmsTVu", category.getId());
5454
assertNotBlank(category.getName());
5555
assertNotNull(category.getCreated());
56+
assertNotNull(category.getCreatedBy());
5657
assertNotNull(category.getLastUpdated());
5758
assertNotNull(category.getSharing());
5859
assertNotNull(category.getAccess());

src/test/java/org/hisp/dhis/CategoryComboApiTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void testGetCategoryCombo() {
5555
assertEquals("m2jTvAj5kkm", categoryCombo.getId());
5656
assertEquals("Births", categoryCombo.getName());
5757
assertNotNull(categoryCombo.getCreated());
58+
assertNotNull(categoryCombo.getCreatedBy());
5859
assertNotNull(categoryCombo.getLastUpdated());
5960
assertNotNull(categoryCombo.getSharing());
6061
assertNotNull(categoryCombo.getAccess());

src/test/java/org/hisp/dhis/CategoryOptionApiTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void getCategoryOption() {
5656
assertNotBlank(categoryOption.getName());
5757
assertEquals("K4gwuiVvW3z", categoryOption.getId());
5858
assertNotNull(categoryOption.getCreated());
59+
assertNotNull(categoryOption.getCreatedBy());
5960
assertNotNull(categoryOption.getLastUpdated());
6061
assertNotNull(categoryOption.getSharing());
6162
assertNotNull(categoryOption.getAccess());
@@ -119,5 +120,6 @@ void testUpdateCategoryOption() {
119120
assertEquals(Status.OK, response.getStatus());
120121
categoryOption = dhis2.getCategoryOption("jRbMi0aBjYn");
121122
assertEquals("Male gender", categoryOption.getDescription());
123+
assertNotNull(categoryOption.getLastUpdatedBy());
122124
}
123125
}

src/test/java/org/hisp/dhis/DashboardApiTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void testGetDashboard() {
5252
assertEquals("L1BtjXgpUpd", dashboard.getId());
5353
assertNotBlank(dashboard.getName());
5454
assertNotNull(dashboard.getCreated());
55+
assertNotNull(dashboard.getCreatedBy());
5556
assertNotNull(dashboard.getLastUpdated());
5657
assertNotNull(dashboard.getSharing());
5758
assertNotNull(dashboard.getAccess());

src/test/java/org/hisp/dhis/DataElementApiTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ void testGetDataElement() {
6969
assertNotNull(dataElement.getId());
7070
assertNotBlank(dataElement.getName());
7171
assertNotNull(dataElement.getCreated());
72+
assertNotNull(dataElement.getCreatedBy());
7273
assertNotNull(dataElement.getLastUpdated());
7374
assertNotNull(dataElement.getSharing());
7475
assertNotNull(dataElement.getAccess());

src/test/java/org/hisp/dhis/DataElementGroupApiTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void testGetDataElementGroup() {
5555
assertEquals("Lassa Fever", deg.getName());
5656
assertEquals("Lassa Fever", deg.getShortName());
5757
assertNotNull(deg.getCreated());
58+
assertNotNull(deg.getCreatedBy());
5859
assertNotNull(deg.getLastUpdated());
5960
assertNotNull(deg.getSharing());
6061
assertNotNull(deg.getAccess());

0 commit comments

Comments
 (0)