Skip to content

Commit

Permalink
feat: last updated in data approval responses [DHIS2-5075] (dhis2#8949)
Browse files Browse the repository at this point in the history
* chore: lombok for ApprovalStatusDto [DHIS2-5075]

* chore: use stream map instead of for to convert data approval status to DTO [DHIS2-5075]

* chore: lombok for DataApprovalStateResponse [DHIS2-5075]

* feat: adds lastUpdated info to data approval API [DHIS2-5075]

* fix: adds back wrongly removed setters for data approval [DHIS2-5075]

* fix: undo adding last updated to data approval DTO (would always be null) [DHIS2-5075]

* fix: undo removal of setCurrentUserService (reflection callers) [DHIS2-5075]

* fix: data approval (tests failing - wrong setup?) [DHIS2-5075]

* fix: test data approval process (approval stage) [DHIS2-5075]

* chore: sonar code complexity issue [DHIS2-5075]

* fix: only add accepted by info with permission [DHIS2-5075]

* fix: DA two level test scenario with accept [DHIS2-5075]

* fix: data approval last updated in status API [DHIS2-5075]

* chore: undo some no longer needed changes [DHIS2-5075]

* fix: add accepted info to data approval permission [DHIS2-5075]

* fix: next time I ask Chuck Norris to fix data approval [DHIS2-5075]

* fix: hide field, correct eval for can read approved by [DHIS2-5075]
  • Loading branch information
jbee authored Oct 26, 2021
1 parent e5d7c0c commit b8a8a00
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 553 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@

import java.util.Date;

import lombok.Setter;

import org.hisp.dhis.common.DxfNamespaces;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

@Setter
@JacksonXmlRootElement( localName = "dataApprovalPermissions", namespace = DxfNamespaces.DXF_2_0 )
public class DataApprovalPermissions
{
Expand All @@ -47,73 +50,57 @@ public class DataApprovalPermissions

private boolean mayReadData;

private transient String state;
private boolean mayReadAcceptedBy;

private transient String approvedBy;
private String state;

private transient Date approvedAt;
private String approvedBy;

public DataApprovalPermissions()
{
}
private Date approvedAt;

private String acceptedBy;

// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
private Date acceptedAt;

@JsonProperty
public boolean isMayApprove()
{
return mayApprove;
}

public void setMayApprove( boolean mayApprove )
{
this.mayApprove = mayApprove;
}

@JsonProperty
public boolean isMayUnapprove()
{
return mayUnapprove;
}

public void setMayUnapprove( boolean mayUnapprove )
{
this.mayUnapprove = mayUnapprove;
}

@JsonProperty
public boolean isMayAccept()
{
return mayAccept;
}

public void setMayAccept( boolean mayAccept )
{
this.mayAccept = mayAccept;
}

@JsonProperty
public boolean isMayUnaccept()
{
return mayUnaccept;
}

public void setMayUnaccept( boolean mayUnaccept )
{
this.mayUnaccept = mayUnaccept;
}

@JsonProperty
public boolean isMayReadData()
{
return mayReadData;
}

public void setMayReadData( boolean mayReadData )
/**
* OBS! Note that this field is intentionally not serialised to JSON as the
* user should not know if he can or can't read.
*
* @return whether the user can read who accepted the DA
*/
public boolean isMayReadAcceptedBy()
{
this.mayReadData = mayReadData;
return mayReadAcceptedBy;
}

@JsonProperty
Expand All @@ -122,31 +109,28 @@ public String getState()
return state;
}

public void setState( String state )
{
this.state = state;
}

@JsonProperty
public String getApprovedBy()
{
return approvedBy;
}

public void setApprovedBy( String approvedBy )
@JsonProperty
public Date getApprovedAt()
{
this.approvedBy = approvedBy;
return approvedAt;
}

@JsonProperty
public Date getApprovedAt()
public String getAcceptedBy()
{
return approvedAt;
return acceptedBy;
}

public void setApprovedAt( Date approvedAt )
@JsonProperty
public Date getAcceptedAt()
{
this.approvedAt = approvedAt;
return acceptedAt;
}

// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

import java.util.Date;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;

import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.dataset.DataSet;
Expand All @@ -40,35 +44,30 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

@Builder
@AllArgsConstructor( access = AccessLevel.PRIVATE )
@JacksonXmlRootElement( localName = "dataApprovalStateResponse", namespace = DxfNamespaces.DXF_2_0 )
public class DataApprovalStateResponse
{
private DataSet dataSet;

private Period period;
private final DataSet dataSet;

private OrganisationUnit organisationUnit;
private final Period period;

private String state;
private final OrganisationUnit organisationUnit;

private String createdByUsername;
private final String state;

private Date createdDate;
private final String createdByUsername;

private DataApprovalPermissions permissions;
private final Date createdDate;

public DataApprovalStateResponse( DataSet dataSet, Period period, OrganisationUnit organisationUnit, String state,
Date createdDate, String createdByUsername,
DataApprovalPermissions permissions )
{
this.dataSet = dataSet;
this.period = period;
this.organisationUnit = organisationUnit;
this.state = state;
this.createdDate = createdDate;
this.createdByUsername = createdByUsername;
this.permissions = permissions;
}
private final DataApprovalPermissions permissions;

/*
* OBS! Getter annotations are needed because of field filtering based on
* schema
*/

@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
Expand All @@ -78,11 +77,6 @@ public DataSet getDataSet()
return dataSet;
}

public void setDataSet( DataSet dataSet )
{
this.dataSet = dataSet;
}

@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
Expand All @@ -91,11 +85,6 @@ public Period getPeriod()
return period;
}

public void setPeriod( Period period )
{
this.period = period;
}

@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
Expand All @@ -104,56 +93,31 @@ public OrganisationUnit getOrganisationUnit()
return organisationUnit;
}

public void setOrganisationUnit( OrganisationUnit organisationUnit )
{
this.organisationUnit = organisationUnit;
}

@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getState()
{
return state;
}

public void setState( String state )
{
this.state = state;
}

@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public DataApprovalPermissions getPermissions()
{
return permissions;
}

public void setPermissions( DataApprovalPermissions permissions )
{
this.permissions = permissions;
}

@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getCreatedByUsername()
{
return createdByUsername;
}

public void setCreatedByUsername( String createdByUsername )
{
this.createdByUsername = createdByUsername;
}

@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Date getCreatedDate()
{
return createdDate;
}

public void setCreatedDate( Date createdDate )
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public DataApprovalPermissions getPermissions()
{
this.createdDate = createdDate;
return permissions;
}
}

This file was deleted.

Loading

0 comments on commit b8a8a00

Please sign in to comment.