Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-18607_2.42
Browse files Browse the repository at this point in the history
  • Loading branch information
maikelarabori authored Dec 11, 2024
2 parents bfcee54 + 91bd27c commit cf3f6b3
Show file tree
Hide file tree
Showing 87 changed files with 651 additions and 1,353 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.tracker.export.trackedentity;

import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hisp.dhis.changelog.ChangeLogType;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
package org.hisp.dhis.audit;

/**
* Encapsulation of a web API request for tracked entity data value audit records.
*
* @author Lars Helge Overland
* @author Halvdan Hoem Grelland
* @author Luca Cambi split Changelog from Audit
*/
@Data
@Accessors(chain = true)
public class TrackedEntityAttributeValueChangeLogQueryParams {
private List<TrackedEntityAttribute> trackedEntityAttributes = new ArrayList<>();

private List<TrackedEntity> trackedEntities = new ArrayList<>();

private List<ChangeLogType> auditTypes = new ArrayList<>();

private Pager pager;

public boolean hasPager() {
return pager != null;
}
public enum AuditOperationType {
CREATE,
UPDATE,
DELETE,
READ,
SEARCH
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2022, University of Oslo
* Copyright (c) 2004-2024, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -27,14 +27,8 @@
*/
package org.hisp.dhis.changelog;

/**
* @author Halvdan Hoem Grelland
* @author Luca Cambi split Changelog from Audit
*/
public enum ChangeLogType {
CREATE,
UPDATE,
DELETE,
READ,
SEARCH
DELETE
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import com.google.common.base.MoreObjects;
import java.util.Date;
import java.util.Objects;
import org.hisp.dhis.audit.AuditOperationType;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.changelog.ChangeLogType;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.organisationunit.OrganisationUnit;
Expand Down Expand Up @@ -62,7 +62,7 @@ public class DataValueAudit {

private Date created;

private ChangeLogType auditType;
private AuditOperationType auditType;

// -------------------------------------------------------------------------
// Constructors
Expand All @@ -71,7 +71,7 @@ public class DataValueAudit {
public DataValueAudit() {}

public DataValueAudit(
DataValue dataValue, String value, String modifiedBy, ChangeLogType auditType) {
DataValue dataValue, String value, String modifiedBy, AuditOperationType auditType) {
this.dataElement = dataValue.getDataElement();
this.period = dataValue.getPeriod();
this.organisationUnit = dataValue.getSource();
Expand All @@ -91,7 +91,7 @@ public DataValueAudit(
CategoryOptionCombo attributeOptionCombo,
String value,
String modifiedBy,
ChangeLogType auditType) {
AuditOperationType auditType) {
this.dataElement = dataElement;
this.period = period;
this.organisationUnit = organisationUnit;
Expand Down Expand Up @@ -277,11 +277,11 @@ public void setCreated(Date created) {

@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public ChangeLogType getAuditType() {
public AuditOperationType getAuditType() {
return auditType;
}

public void setAuditType(ChangeLogType auditType) {
public void setAuditType(AuditOperationType auditType) {
this.auditType = auditType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import java.util.List;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hisp.dhis.audit.AuditOperationType;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.changelog.ChangeLogType;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.organisationunit.OrganisationUnit;
Expand All @@ -56,7 +56,7 @@ public class DataValueAuditQueryParams {

private CategoryOptionCombo attributeOptionCombo;

private List<ChangeLogType> auditTypes = new ArrayList<>();
private List<AuditOperationType> auditTypes = new ArrayList<>();

private Pager pager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
package org.hisp.dhis.trackedentity;

import org.hisp.dhis.changelog.ChangeLogType;
import org.hisp.dhis.audit.AuditOperationType;

/**
* @author Abyot Asalefew Gizaw [email protected]
Expand All @@ -38,5 +38,5 @@ public interface ApiTrackedEntityAuditService {
String ID = ApiTrackedEntityAuditService.class.getName();

void addTrackedEntityAudit(
TrackedEntity trackedEntity, String username, ChangeLogType changeLogType);
TrackedEntity trackedEntity, String username, AuditOperationType auditOperationType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import org.hisp.dhis.changelog.ChangeLogType;
import org.hisp.dhis.audit.AuditOperationType;
import org.hisp.dhis.common.DxfNamespaces;

/**
Expand All @@ -55,15 +55,15 @@ public class TrackedEntityAudit implements Serializable {

private String accessedBy;

private ChangeLogType auditType;
private AuditOperationType auditType;

// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------

public TrackedEntityAudit() {}

public TrackedEntityAudit(String trackedEntity, String accessedBy, ChangeLogType auditType) {
public TrackedEntityAudit(String trackedEntity, String accessedBy, AuditOperationType auditType) {
this.trackedEntity = trackedEntity;
this.accessedBy = accessedBy;
this.created = new Date();
Expand All @@ -75,8 +75,8 @@ public TrackedEntityAudit(
String comment,
Date created,
String accessedBy,
ChangeLogType changeLogType) {
this(trackedEntity, accessedBy, changeLogType);
AuditOperationType auditOperationType) {
this(trackedEntity, accessedBy, auditOperationType);
this.comment = comment;
this.created = created;
}
Expand Down Expand Up @@ -159,11 +159,11 @@ public void setAccessedBy(String accessedBy) {

@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public ChangeLogType getAuditType() {
public AuditOperationType getAuditType() {
return auditType;
}

public void setAuditType(ChangeLogType auditType) {
public void setAuditType(AuditOperationType auditType) {
this.auditType = auditType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.List;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hisp.dhis.changelog.ChangeLogType;
import org.hisp.dhis.audit.AuditOperationType;
import org.hisp.dhis.common.Pager;

/**
Expand All @@ -45,7 +45,7 @@ public class TrackedEntityAuditQueryParams {

private List<String> users = new ArrayList<>();

private List<ChangeLogType> auditTypes = new ArrayList<>();
private List<AuditOperationType> auditTypes = new ArrayList<>();

private Date startDate = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void initMergeHandlers() {

auditMergeHandlers =
ImmutableList.<DataElementAuditMergeHandler>builder()
.add(trackerMergeHandler::handleTrackedEntityDataValueChangelog)
.add(trackerMergeHandler::handleEventChangeLogs)
.add(dataDataElementMergeHandler::handleDataValueAuditDataElement)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import org.hisp.dhis.programrule.ProgramRuleVariableStore;
import org.hisp.dhis.tracker.export.event.EventChangeLog;
import org.hisp.dhis.tracker.export.event.EventChangeLogService;
import org.hisp.dhis.tracker.export.event.TrackedEntityDataValueChangeLog;
import org.springframework.stereotype.Component;

/**
Expand Down Expand Up @@ -275,14 +274,13 @@ private void setLastUpdatedAsTargetAndRemoveRemaining(
}

/**
* Method handling {@link TrackedEntityDataValueChangeLog}s and {@link EventChangeLog}s. Both of
* them will either be deleted or left as is, based on whether the source {@link DataElement}s are
* being deleted or not.
* Method handling {@link EventChangeLog}s. They will either be deleted or left as is, based on
* whether the source {@link DataElement}s are being deleted or not.
*
* @param sources source {@link DataElement}s used to retrieve {@link DataValueAudit}s
* @param mergeRequest merge request
*/
public void handleTrackedEntityDataValueChangelog(
public void handleEventChangeLogs(
@Nonnull List<DataElement> sources, @Nonnull MergeRequest mergeRequest) {
if (mergeRequest.isDeleteSources()) {
log.info("Deleting source event change log records as source DataElements are being deleted");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ checks:
- users/user_roles_no_authorities.yaml
- users/user_roles_with_no_users.yaml
- users/users_with_invalid_usernames.yaml
- file_resources/file_resources_no_icon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2004-2022, University of Oslo
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# Neither the name of the HISP project nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
---
name: file_resources_no_icon
description: File resources of type ICON that have no entry in the icon table
section: File resources
section_order: 1
summary_sql: >-
SELECT count(*) FROM fileresource f
WHERE domain = 'ICON'
AND NOT EXISTS (SELECT 1 FROM icon i WHERE i.fileresourceid = f.fileresourceid);
details_sql: >
SELECT f.uid, f.name as name, f.storagekey as comment FROM fileresource f
WHERE domain = 'ICON'
AND NOT EXISTS (SELECT 1 FROM icon i WHERE i.fileresourceid = f.fileresourceid);
details_id_type: fileResources
severity: SEVERE
introduction: >
A file resource of type ICON should always have a corresponding icon entry.
recommendation: >
If the missing icon belongs to a default (system) icon delete the file resource manually.
The icon will be recreated automatically.
If the missing icon is a custom (user provided) icon there are two options:
1. repair the icon by manually creating the icon entry linked to the existing file resource
2. discard the icon completely by deleting the file resource manually (image can not be recovered)
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void testReadDataIntegrityYaml() {

List<DataIntegrityCheck> checks = new ArrayList<>();
readYaml(checks, "data-integrity-checks.yaml", "data-integrity-checks", CLASS_PATH);
assertEquals(85, checks.size());
assertEquals(86, checks.size());

// Names should be unique
List<String> allNames = checks.stream().map(DataIntegrityCheck::getName).toList();
Expand Down
Loading

0 comments on commit cf3f6b3

Please sign in to comment.