Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-16246_2.41
Browse files Browse the repository at this point in the history
  • Loading branch information
d-bernat authored Jan 10, 2024
2 parents 75e0d38 + 34da9f9 commit 1c9ade4
Show file tree
Hide file tree
Showing 58 changed files with 1,166 additions and 1,063 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
* (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.common;
package org.hisp.dhis.changelog;

/**
* This class is deprecated in favor of new async auditing solution, do not use.
*
* @author Halvdan Hoem Grelland
* @author Luca Cambi split Changelog from Audit
*/
public enum AuditType {
public enum ChangeLogType {
CREATE,
UPDATE,
DELETE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.Date;
import java.util.Objects;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.common.AuditType;
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,15 +62,16 @@ public class DataValueAudit {

private Date created;

private AuditType auditType;
private ChangeLogType auditType;

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

public DataValueAudit() {}

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

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

public void setAuditType(AuditType auditType) {
public void setAuditType(ChangeLogType auditType) {
this.auditType = auditType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import lombok.Data;
import lombok.experimental.Accessors;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.common.AuditType;
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<AuditType> auditTypes = new ArrayList<>();
private List<ChangeLogType> auditTypes = new ArrayList<>();

private Pager pager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
* (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.audit.payloads;
package org.hisp.dhis.trackedentity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import org.hisp.dhis.common.AuditType;
import org.hisp.dhis.changelog.ChangeLogType;
import org.hisp.dhis.common.DxfNamespaces;

/**
Expand All @@ -42,7 +42,7 @@
* @author Abyot Asalefew Gizaw [email protected]
*/
@JacksonXmlRootElement(localName = "trackedEntityInstanceAudit", namespace = DxfNamespaces.DXF_2_0)
public class TrackedEntityAudit implements Serializable {
public class TrackedEntityChangeLog implements Serializable {
private static final long serialVersionUID = 4260110537887403524L;

private long id;
Expand All @@ -55,24 +55,28 @@ public class TrackedEntityAudit implements Serializable {

private String accessedBy;

private AuditType auditType;
private ChangeLogType auditType;

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

public TrackedEntityAudit() {}
public TrackedEntityChangeLog() {}

public TrackedEntityAudit(String trackedEntity, String accessedBy, AuditType auditType) {
public TrackedEntityChangeLog(String trackedEntity, String accessedBy, ChangeLogType auditType) {
this.trackedEntity = trackedEntity;
this.accessedBy = accessedBy;
this.created = new Date();
this.auditType = auditType;
}

public TrackedEntityAudit(
String trackedEntity, String comment, Date created, String accessedBy, AuditType auditType) {
this(trackedEntity, accessedBy, auditType);
public TrackedEntityChangeLog(
String trackedEntity,
String comment,
Date created,
String accessedBy,
ChangeLogType changeLogType) {
this(trackedEntity, accessedBy, changeLogType);
this.comment = comment;
this.created = created;
}
Expand All @@ -92,7 +96,7 @@ public boolean equals(Object obj) {
return false;
}

final TrackedEntityAudit other = (TrackedEntityAudit) obj;
final TrackedEntityChangeLog other = (TrackedEntityChangeLog) obj;

return Objects.equals(this.trackedEntity, other.trackedEntity)
&& Objects.equals(this.comment, other.comment)
Expand Down Expand Up @@ -155,11 +159,11 @@ public void setAccessedBy(String accessedBy) {

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

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

/**
* @author Abyot Asalefew Gizaw [email protected]
*/
@Data
@Accessors(chain = true)
public class TrackedEntityAuditQueryParams {
public class TrackedEntityChangeLogQueryParams {
private List<String> trackedEntities = new ArrayList<>();

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

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

private Date startDate = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,37 @@
package org.hisp.dhis.trackedentity;

import java.util.List;
import org.hisp.dhis.audit.payloads.TrackedEntityAudit;

/**
* @author Abyot Asalefew Gizaw [email protected]
*/
public interface TrackedEntityAuditService {
public interface TrackedEntityChangeLogService {

String ID = TrackedEntityAuditService.class.getName();
String ID = TrackedEntityChangeLogService.class.getName();

/**
* Adds tracked entity audit
*
* @param trackedEntityAudit the audit to add
* @param trackedEntityChangeLog the audit to add
*/
void addTrackedEntityAudit(TrackedEntityAudit trackedEntityAudit);
void addTrackedEntityChangeLog(TrackedEntityChangeLog trackedEntityChangeLog);

/** Adds multiple tracked entity audit */
void addTrackedEntityAudit(List<TrackedEntityAudit> trackedEntityAudits);

/**
* Deletes tracked entity audit for the given tracked entity
*
* @param trackedEntity the tracked entity
*/
void deleteTrackedEntityAudit(TrackedEntity trackedEntity);
void addTrackedEntityChangeLog(List<TrackedEntityChangeLog> trackedEntityChangeLogs);

/**
* Returns tracked entity audits matching query params
*
* @param params tracked entity audit query params
* @return matching TrackedEntityAudits
*/
List<TrackedEntityAudit> getTrackedEntityAudits(TrackedEntityAuditQueryParams params);
List<TrackedEntityChangeLog> getTrackedEntityChangeLogs(TrackedEntityChangeLogQueryParams params);

/**
* Returns count of tracked entity audits matching query params
*
* @param params tracked entity audit query params
* @return count of TrackedEntityAudits
*/
int getTrackedEntityAuditsCount(TrackedEntityAuditQueryParams params);
int getTrackedEntityChangeLogsCount(TrackedEntityChangeLogQueryParams params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,40 @@
package org.hisp.dhis.trackedentity;

import java.util.List;
import org.hisp.dhis.audit.payloads.TrackedEntityAudit;

/**
* @author Abyot Asalefew Gizaw [email protected]
*/
public interface TrackedEntityAuditStore {
String ID = TrackedEntityAuditStore.class.getName();
public interface TrackedEntityChangeLogStore {
String ID = TrackedEntityChangeLogStore.class.getName();

/**
* Adds the given tracked entity audit.
*
* @param trackedEntityAudit the {@link TrackedEntityAudit} to add.
* @param trackedEntityChangeLog the {@link TrackedEntityChangeLog} to add.
*/
void addTrackedEntityAudit(TrackedEntityAudit trackedEntityAudit);
void addTrackedEntityChangeLog(TrackedEntityChangeLog trackedEntityChangeLog);

/**
* Adds the given {@link TrackedEntityAudit}s.
* Adds the given {@link TrackedEntityChangeLog}s.
*
* @param trackedEntityAudit the list of {@link TrackedEntityAudit}.
* @param trackedEntityChangeLog the list of {@link TrackedEntityChangeLog}.
*/
void addTrackedEntityAudit(List<TrackedEntityAudit> trackedEntityAudit);

/**
* Deletes tracked entity audit for the given tracked entity.
*
* @param trackedEntity the {@link TrackedEntity}.
*/
void deleteTrackedEntityAudit(TrackedEntity trackedEntity);
void addTrackedEntityChangeLog(List<TrackedEntityChangeLog> trackedEntityChangeLog);

/**
* Returns tracked entity audits matching query params
*
* @param params tracked entity audit query params
* @return a list of {@link TrackedEntityAudit}.
* @return a list of {@link TrackedEntityChangeLog}.
*/
List<TrackedEntityAudit> getTrackedEntityAudits(TrackedEntityAuditQueryParams params);
List<TrackedEntityChangeLog> getTrackedEntityChangeLogs(TrackedEntityChangeLogQueryParams params);

/**
* Returns count of tracked entity audits matching query params
*
* @param params tracked entity audit query params
* @return count of audits.
*/
int getTrackedEntityAuditsCount(TrackedEntityAuditQueryParams params);
int getTrackedEntityChangeLogsCount(TrackedEntityChangeLogQueryParams params);
}
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.common.AuditType;
import org.hisp.dhis.changelog.ChangeLogType;
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dataelement.DataElement;
Expand All @@ -47,7 +47,7 @@
*/
@Data
@Accessors(chain = true)
public class TrackedEntityDataValueAuditQueryParams {
public class TrackedEntityDataValueChangeLogQueryParams {
private List<DataElement> dataElements = new ArrayList<>();

private List<OrganisationUnit> orgUnits = new ArrayList<>();
Expand All @@ -62,7 +62,7 @@ public class TrackedEntityDataValueAuditQueryParams {

private OrganisationUnitSelectionMode ouMode;

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

private Pager pager;

Expand Down
Loading

0 comments on commit 1c9ade4

Please sign in to comment.