Skip to content

Commit

Permalink
chore: Move changelog into tracker [DHIS2-17714] (#18430)
Browse files Browse the repository at this point in the history
* chore: Move changelog into tracker [DHIS2-17714]

* chore: Make administration module be dependant on tracker module [DHIS2-17714]

* Test fixes

* Make data value store package private
  • Loading branch information
enricocolasante authored Sep 2, 2024
1 parent 6d3e39b commit 8907027
Show file tree
Hide file tree
Showing 38 changed files with 271 additions and 400 deletions.

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions dhis-2/dhis-services/dhis-service-administration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-core</artifactId>
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-tracker</artifactId>
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-acl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hisp.dhis.common.DeleteNotAllowedException;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.common.event.ApplicationCacheClearedEvent;
import org.hisp.dhis.commons.util.PageRange;
import org.hisp.dhis.dataapproval.DataApprovalAuditService;
Expand All @@ -42,6 +41,7 @@
import org.hisp.dhis.datavalue.DataValueAuditService;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.tracker.export.event.EventChangeLogService;
import org.hisp.dhis.user.CurrentUserUtil;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserInvitationStatus;
Expand Down Expand Up @@ -78,7 +78,7 @@ public class DefaultMaintenanceService implements MaintenanceService {

private final ApplicationEventPublisher eventPublisher;

private final IdentifiableObjectManager manager;
private final EventChangeLogService trackedEntityDataValueChangelogService;

// -------------------------------------------------------------------------
// MaintenanceService implementation
Expand Down Expand Up @@ -169,7 +169,7 @@ public boolean pruneData(DataElement dataElement) {
return false;
}

manager.delete(dataElement);
trackedEntityDataValueChangelogService.deleteTrackedEntityDataValueChangeLog(dataElement);
dataValueAuditService.deleteDataValueAudits(dataElement);
dataValueService.deleteDataValues(dataElement);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
import org.hisp.dhis.programrule.ProgramRuleActionStore;
import org.hisp.dhis.programrule.ProgramRuleVariable;
import org.hisp.dhis.programrule.ProgramRuleVariableStore;
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueChangeLog;
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueChangeLogStore;
import org.hisp.dhis.tracker.export.event.EventChangeLogService;
import org.hisp.dhis.tracker.export.event.TrackedEntityDataValueChangeLog;
import org.springframework.stereotype.Service;

/**
Expand All @@ -76,7 +76,7 @@ public class TrackerDataElementMergeHandler {
private final ProgramRuleActionStore programRuleActionStore;
private final ProgramIndicatorStore programIndicatorStore;
private final EventStore eventStore;
private final TrackedEntityDataValueChangeLogStore teDataValueChangeLogStore;
private final EventChangeLogService teDataValueChangeLogService;

/**
* Method retrieving {@link ProgramIndicator}s which have a source {@link DataElement} reference
Expand Down Expand Up @@ -286,7 +286,7 @@ public void handleTrackedEntityDataValueChangelog(
if (mergeRequest.isDeleteSources()) {
log.info(
"Deleting source tracked entity data value change log records as source DataElements are being deleted");
sources.forEach(teDataValueChangeLogStore::deleteTrackedEntityDataValueChangeLog);
sources.forEach(teDataValueChangeLogService::deleteTrackedEntityDataValueChangeLog);
} else {
log.info(
"Leaving source tracked entity data value change log records as is, source DataElements are not being deleted");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,24 @@
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.system.deletion.IdObjectDeletionHandler;
import org.hisp.dhis.system.deletion.JdbcDeletionHandler;
import org.springframework.stereotype.Component;

/**
* @author Zubair Asghar
*/
@Component
@RequiredArgsConstructor
public class TrackedEntityDataValueChangeLogDeletionHandler
extends IdObjectDeletionHandler<DataElement> {
public class TrackedEntityDataValueChangeLogDeletionHandler extends JdbcDeletionHandler {

@Override
protected void registerHandler() {
protected void register() {
whenDeleting(DataElement.class, this::deleteDataElement);
}

private void deleteDataElement(DataElement dataElement) {
delete(
"delete from trackedentitydatavalueaudit d where d.dataelementid = :de",
Map.of("de", dataElement.getId()));
"delete from trackedentitydatavalueaudit where dataelementid = :id",
Map.of("id", dataElement.getId()));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueChangeLog"
<class name="org.hisp.dhis.tracker.export.trackedentity.TrackedEntityAttributeValueChangeLog"
table="trackedentityattributevalueaudit">

<id name="id" column="trackedentityattributevalueauditid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueChangeLog" table="trackedEntityDataValueAudit">
<class name="org.hisp.dhis.tracker.export.event.TrackedEntityDataValueChangeLog" table="trackedEntityDataValueAudit">

<id name="id" column="trackedentitydatavalueauditid">
<generator class="sequence">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
import org.hisp.dhis.security.acl.AclService;
import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueChangeLog;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueChangeLogStore;
import org.hisp.dhis.tracker.export.trackedentity.TrackedEntityAttributeValueChangeLog;
import org.hisp.dhis.tracker.export.trackedentity.TrackedEntityAttributeValueChangeLogStore;
import org.hisp.dhis.user.CurrentUserUtil;
import org.hisp.dhis.user.User;
import org.springframework.context.ApplicationEventPublisher;
Expand Down Expand Up @@ -300,26 +300,25 @@ public void auditMerge(DeduplicationMergeParams params) {
mergeObject
.getRelationships()
.forEach(
rel -> {
duplicate.getRelationshipItems().stream()
.map(RelationshipItem::getRelationship)
.filter(r -> r.getUid().equals(rel))
.findAny()
.ifPresent(
relationship ->
auditManager.send(
Audit.builder()
.auditScope(AuditScope.TRACKER)
.auditType(AuditType.UPDATE)
.createdAt(LocalDateTime.now())
.object(relationship)
.klass(
HibernateProxyUtils.getRealClass(relationship)
.getCanonicalName())
.uid(rel)
.auditableEntity(
new AuditableEntity(Relationship.class, relationship))
.build()));
});
rel ->
duplicate.getRelationshipItems().stream()
.map(RelationshipItem::getRelationship)
.filter(r -> r.getUid().equals(rel))
.findAny()
.ifPresent(
relationship ->
auditManager.send(
Audit.builder()
.auditScope(AuditScope.TRACKER)
.auditType(AuditType.UPDATE)
.createdAt(LocalDateTime.now())
.object(relationship)
.klass(
HibernateProxyUtils.getRealClass(relationship)
.getCanonicalName())
.uid(rel)
.auditableEntity(
new AuditableEntity(Relationship.class, relationship))
.build())));
}
}
Loading

0 comments on commit 8907027

Please sign in to comment.