Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/org/hisp/dhis/api/ApiFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ApiFields {

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

/** Nameable object fields. */
public static final String NAME_FIELDS = String.format("%s,shortName,description", ID_FIELDS);
Expand Down Expand Up @@ -334,8 +334,8 @@ public class ApiFields {
/** Program indicator fields. */
public static final String PROGRAM_INDICATOR_FIELDS =
String.format(
"%1$s,program[%1$s],expression,filter,decimals,aggregationType,analyticsType",
NAME_FIELDS);
"%1$s,program[%2$s],expression,filter,decimals,aggregationType,analyticsType",
NAME_EXT_FIELDS, NAME_FIELDS);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since %1$s is used, you don't have to specify NAME_FIELDS twice. This is positional variable resolution.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I updated it


/** Program section fields. */
public static final String PROGRAM_SECTION_FIELDS =
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/hisp/dhis/model/IdentifiableObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.hisp.dhis.model.acl.Access;
import org.hisp.dhis.model.sharing.Sharing;
import org.hisp.dhis.model.translation.Translation;
import org.hisp.dhis.model.user.User;

@Getter
@Setter
Expand All @@ -54,8 +55,12 @@ public class IdentifiableObject implements Serializable {

@JsonProperty protected Date created;

@JsonProperty protected User createdBy;

@JsonProperty protected Date lastUpdated;

@JsonProperty protected User lastUpdatedBy;

/** Attribute values. */
@JsonProperty protected Set<AttributeValue> attributeValues = new HashSet<>();

Expand Down
65 changes: 40 additions & 25 deletions src/test/java/org/hisp/dhis/ApiFieldsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,23 @@ class ApiFieldsTest {
void testProgramStageFields() {
String expected =
"""
id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
translations,sharing,access,shortName,description,formName,\
program[id,code,name,created,lastUpdated,attributeValues],\
programStageDataElements[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
programStageDataElements[id,code,name,created,lastUpdated,attributeValues,\
createdBy,lastUpdatedBy,translations,sharing,access,shortName,description,formName,\
programStage[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
dataElement[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
aggregationType,valueType,domainType,url,categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
dataElement[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
translations,sharing,access,shortName,description,formName,\
aggregationType,valueType,domainType,url,categoryCombo[id,code,name,created,\
lastUpdated,attributeValues,shortName,description],\
legendSets[id,code,name,created,lastUpdated,\
attributeValues,shortName,description],\
optionSet[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,valueType,version]],\
optionSet[id,code,name,created,lastUpdated,attributeValues,createdBy,\
lastUpdatedBy,translations,sharing,access,valueType,version]],\
compulsory,displayInReports,skipSynchronization,skipAnalytics,allowFutureDate,sortOrder],\
programStageSections[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,\
programStageSections[id,code,name,created,lastUpdated,attributeValues,\
createdBy,lastUpdatedBy,translations,sharing,access,\
shortName,description,formName,programStage[id,code,name,created,lastUpdated,\
attributeValues,shortName,description],sortOrder,\
dataElements[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
Expand All @@ -67,30 +73,39 @@ void testProgramStageFields() {
void testProgramExtFields() {
String expected =
"""
id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
trackedEntityType[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
translations,sharing,access,shortName,description,formName,\
trackedEntityType[id,code,name,created,lastUpdated,attributeValues,\
createdBy,lastUpdatedBy,translations,sharing,access,shortName,description,formName,\
trackedEntityTypeAttributes[id,\
trackedEntityAttribute[id,code,name,created,lastUpdated,attributeValues,shortName,description,valueType,\
aggregationType,confidential,unique,orgunitScope],displayInList,mandatory,searchable]],\
categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description,\
categories[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,dataDimensionType,dataDimension,\
categories[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,\
sharing,access,shortName,description,formName,dataDimensionType,dataDimension,\
categoryOptions[id,code,name,created,lastUpdated,attributeValues],\
categoryCombos[id,code,name,created,lastUpdated,attributeValues]]],\
organisationUnits[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
programSections[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,sortOrder,\
programSections[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
translations,sharing,access,shortName,description,formName,sortOrder,\
program[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
trackedEntityAttributes[id,code,name,created,lastUpdated,attributeValues,shortName,description]],\
programStages[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
programStages[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
translations,sharing,access,shortName,description,formName,\
program[id,code,name,created,lastUpdated,attributeValues],\
programStageDataElements[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
programStageDataElements[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
translations,sharing,access,shortName,description,formName,\
programStage[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
dataElement[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,formName,\
aggregationType,valueType,domainType,url,categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
dataElement[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,\
sharing,access,shortName,description,formName,aggregationType,valueType,domainType,url,\
categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
legendSets[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
optionSet[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,valueType,version]],\
optionSet[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,\
translations,sharing,access,valueType,version]],\
compulsory,displayInReports,skipSynchronization,skipAnalytics,allowFutureDate,sortOrder],\
programStageSections[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,\
shortName,description,formName,programStage[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
programStageSections[id,code,name,created,lastUpdated,attributeValues,createdBy,\
lastUpdatedBy,translations,sharing,access,shortName,description,formName,\
programStage[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
sortOrder,dataElements[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
programIndicators[id,code,name,created,lastUpdated,attributeValues,shortName,description]],\
executionDateLabel,dueDateLabel,programStageLabel,eventLabel,\
Expand All @@ -99,11 +114,11 @@ void testProgramExtFields() {
hideDueDate,enableUserAssignment,referral,featureType],\
programTrackedEntityAttributes[id,code,name,program[id,code,name,created,lastUpdated,\
attributeValues,shortName,description],\
trackedEntityAttribute[id,code,name,created,lastUpdated,attributeValues,shortName,\
description,valueType,aggregationType,confidential,unique,orgunitScope],\
trackedEntityAttribute[id,code,name,created,lastUpdated,attributeValues,\
shortName,description,valueType,aggregationType,confidential,unique,orgunitScope],\
sortOrder,displayInList,mandatory,allowFutureDate,searchable],\
programRuleVariables[id,code,name,created,lastUpdated,attributeValues,translations,\
sharing,access,program[id,code,name,created,lastUpdated,attributeValues],\
programRuleVariables[id,code,name,created,lastUpdated,attributeValues,createdBy,\
lastUpdatedBy,translations,sharing,access,program[id,code,name,created,lastUpdated,attributeValues],\
programRuleVariableSourceType,valueType,programStage[id,code,name,created,\
lastUpdated,attributeValues],trackedEntityAttribute[id,code,name,created,\
lastUpdated,attributeValues],useCodeForOptionSet,\
Expand All @@ -124,7 +139,7 @@ void testProgramExtFields() {
void testProgramMinFields() {
String expected =
"""
id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,shortName,description,\
id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,sharing,access,shortName,description,\
formName,trackedEntityType[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
categoryCombo[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
programSections[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
Expand All @@ -150,11 +165,11 @@ void testProgramMinFields() {
void testUserFields() {
String expected =
"""
id,code,name,created,lastUpdated,attributeValues,translations,sharing,access,\
id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,sharing,access,\
username,firstName,surname,email,phoneNumber,externalAuth,lastLogin,disabled,interests,\
organisationUnits[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
groups[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access],\
userRoles[id,code,name,created,lastUpdated,attributeValues,translations,sharing,access],\
groups[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,sharing,access],\
userRoles[id,code,name,created,lastUpdated,attributeValues,createdBy,lastUpdatedBy,translations,sharing,access],\
dataViewOrganisationUnits[id,code,name,created,lastUpdated,attributeValues,shortName,description],\
teiSearchOrganisationUnits[id,code,name,created,lastUpdated,attributeValues,shortName,description]""";

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/hisp/dhis/AttributeApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void testGetAttribute() {
assertEquals("Classification", attribute.getName());
assertEquals("CLASSIFICATION", attribute.getCode());
assertNotNull(attribute.getCreated());
assertNotNull(attribute.getCreatedBy());
assertNotNull(attribute.getLastUpdated());
}

Expand Down Expand Up @@ -115,6 +116,7 @@ void testCreateUpdateAndDeleteAttributes() {
assertEquals(uidA, attribute.getDescription());
assertFalse(attribute.getUnique());
assertFalse(attribute.getMandatory());
assertNotNull(attribute.getCreatedBy());

attribute.setName(uidB);

Expand All @@ -129,6 +131,7 @@ void testCreateUpdateAndDeleteAttributes() {
assertNotNull(attribute);
assertEquals(attributeUid, attribute.getId());
assertEquals(uidB, attribute.getName());
assertNotNull(attribute.getLastUpdatedBy());

// Remove
ObjectResponse removeRespA = dhis2.removeAttribute(attributeUid);
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/hisp/dhis/CategoryApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void testGetCategory() {
assertEquals("EC40NXmsTVu", category.getId());
assertNotBlank(category.getName());
assertNotNull(category.getCreated());
assertNotNull(category.getCreatedBy());
assertNotNull(category.getLastUpdated());
assertNotNull(category.getSharing());
assertNotNull(category.getAccess());
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/hisp/dhis/CategoryComboApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void testGetCategoryCombo() {
assertEquals("m2jTvAj5kkm", categoryCombo.getId());
assertEquals("Births", categoryCombo.getName());
assertNotNull(categoryCombo.getCreated());
assertNotNull(categoryCombo.getCreatedBy());
assertNotNull(categoryCombo.getLastUpdated());
assertNotNull(categoryCombo.getSharing());
assertNotNull(categoryCombo.getAccess());
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/hisp/dhis/CategoryOptionApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void getCategoryOption() {
assertNotBlank(categoryOption.getName());
assertEquals("K4gwuiVvW3z", categoryOption.getId());
assertNotNull(categoryOption.getCreated());
assertNotNull(categoryOption.getCreatedBy());
assertNotNull(categoryOption.getLastUpdated());
assertNotNull(categoryOption.getSharing());
assertNotNull(categoryOption.getAccess());
Expand Down Expand Up @@ -119,5 +120,6 @@ void testUpdateCategoryOption() {
assertEquals(Status.OK, response.getStatus());
categoryOption = dhis2.getCategoryOption("jRbMi0aBjYn");
assertEquals("Male gender", categoryOption.getDescription());
assertNotNull(categoryOption.getLastUpdatedBy());
}
}
1 change: 1 addition & 0 deletions src/test/java/org/hisp/dhis/DashboardApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void testGetDashboard() {
assertEquals("L1BtjXgpUpd", dashboard.getId());
assertNotBlank(dashboard.getName());
assertNotNull(dashboard.getCreated());
assertNotNull(dashboard.getCreatedBy());
assertNotNull(dashboard.getLastUpdated());
assertNotNull(dashboard.getSharing());
assertNotNull(dashboard.getAccess());
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/hisp/dhis/DataElementApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void testGetDataElement() {
assertNotNull(dataElement.getId());
assertNotBlank(dataElement.getName());
assertNotNull(dataElement.getCreated());
assertNotNull(dataElement.getCreatedBy());
assertNotNull(dataElement.getLastUpdated());
assertNotNull(dataElement.getSharing());
assertNotNull(dataElement.getAccess());
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/hisp/dhis/DataElementGroupApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void testGetDataElementGroup() {
assertEquals("Lassa Fever", deg.getName());
assertEquals("Lassa Fever", deg.getShortName());
assertNotNull(deg.getCreated());
assertNotNull(deg.getCreatedBy());
assertNotNull(deg.getLastUpdated());
assertNotNull(deg.getSharing());
assertNotNull(deg.getAccess());
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/hisp/dhis/DataElementGroupSetApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void testGetDataElementGroupSet() {
assertEquals("Diagnosis", dataElementGroupSet.getName());
assertEquals("Diagnosis", dataElementGroupSet.getShortName());
assertNotNull(dataElementGroupSet.getCreated());
assertNotNull(dataElementGroupSet.getCreatedBy());
assertNotNull(dataElementGroupSet.getLastUpdated());
assertNotNull(dataElementGroupSet.getSharing());
assertNotNull(dataElementGroupSet.getAccess());
Expand Down Expand Up @@ -157,6 +158,7 @@ void testCreateUpdateAndDeleteDataElementGroupSet() {
assertNotNull(dataElementGroupSet);
assertEquals(dataElementGroupSetUid, dataElementGroupSet.getId());
assertEquals(uidB, dataElementGroupSet.getName());
assertNotNull(dataElementGroupSet.getLastUpdatedBy());

// Remove
ObjectResponse removeRespA = dhis2.removeDataElementGroupSet(dataElementGroupSetUid);
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/hisp/dhis/DataSetApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void testGetDataSet() {
assertEquals("Mortality < 5 years", dataSet.getName());
assertEquals("Mortality < 5 years", dataSet.getDisplayFormName());
assertNotNull(dataSet.getCreated());
assertNotNull(dataSet.getCreatedBy());
assertNotNull(dataSet.getLastUpdated());
assertNotNull(dataSet.getSharing());
assertNotNull(dataSet.getAccess());
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/org/hisp/dhis/DocumentApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ class DocumentApiTest {
void testGetDocument() {
Dhis2 dhis2 = new Dhis2(TestFixture.DEFAULT_CONFIG);

Document document = dhis2.getDocument("hKYLLpNinZR");
Document document = dhis2.getDocument("L2APFupqBU1");

assertNotNull(document);
assertEquals("hKYLLpNinZR", document.getId());
assertEquals("L2APFupqBU1", document.getId());
assertNotBlank(document.getName());
assertNotNull(document.getCreated());
assertNotNull(document.getCreatedBy());
assertNotNull(document.getLastUpdated());
assertNotBlank(document.getUrl());
assertTrue(document.getExternal());
assertTrue(document.isExternal());
assertFalse(document.getExternal());
assertFalse(document.isExternal());
assertFalse(document.isAttachment());
}

Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/hisp/dhis/EventFilterApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private void validateEventFilter(EventFilter eventFilter) {
assertNotNull(eventFilter.getSharing());
assertNotNull(eventFilter.getAccess());
assertNotNull(eventFilter.getCreated());
assertNotNull(eventFilter.getCreatedBy());
assertNotNull(eventFilter.getLastUpdated());
assertNotNull(eventFilter.getProgram());
assertNotNull(eventFilter.getEventQueryCriteria());
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/hisp/dhis/IndicatorApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void testGetIndicator() {
assertNotNull(indicator.getAccess());
assertEquals("ANC IPT 1 Coverage", indicator.getShortName());
assertNotNull(indicator.getCreated());
assertNotNull(indicator.getCreatedBy());
assertNotNull(indicator.getLastUpdated());
assertFalse(indicator.isAnnualized());
assertNotNull(indicator.getUrl());
Expand Down Expand Up @@ -180,6 +181,7 @@ void testCreateUpdateAndDeleteIndicator() {
assertNotNull(indicator);
assertEquals(indicatorUid, indicator.getId());
assertEquals(uidB, indicator.getName());
assertNotNull(indicator.getLastUpdatedBy());

// Remove
ObjectResponse removeRespA = dhis2.removeIndicator(indicatorUid);
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/hisp/dhis/IndicatorGroupApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void testGetIndicatorGroup() {
assertEquals("pKHOV0uwPJk", group.getId());
assertNotBlank(group.getName());
assertNotNull(group.getCreated());
assertNotNull(group.getCreatedBy());
assertNotNull(group.getLastUpdated());
assertNotNull(group.getSharing());
assertNotNull(group.getAccess());
Expand Down Expand Up @@ -116,6 +117,7 @@ void testCreateUpdateAndDeleteIndicatorGroup() {
assertNotNull(indicatorGroup);
assertEquals(indicatorGroupUid, indicatorGroup.getId());
assertEquals(uidB, indicatorGroup.getName());
assertNotNull(indicatorGroup.getLastUpdatedBy());

// Remove
ObjectResponse removeRespA = dhis2.removeIndicatorGroup(indicatorGroupUid);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/hisp/dhis/IndicatorGroupSetApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void testCreateUpdateAndDeleteIndicator() {
assertNotNull(indicatorGroupSet);
assertEquals(indicatorGroupSetUid, indicatorGroupSet.getId());
assertEquals(uidB, indicatorGroupSet.getName());

assertNotNull(indicatorGroupSet.getLastUpdatedBy());
// Remove
ObjectResponse removeRespA = dhis2.removeIndicatorGroupSet(indicatorGroupSetUid);

Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/hisp/dhis/IndicatorTypeApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void testCreateUpdateAndDeleteIndicatorType() {
assertNotNull(indicatorType);
assertEquals(indicatorTypeUid, indicatorType.getId());
assertEquals(updatedName, indicatorType.getName());
assertNotNull(indicatorType.getLastUpdatedBy());

// Remove
ObjectResponse removeRespA = dhis2.removeIndicatorType(indicatorTypeUid);
Expand Down
Loading
Loading