Skip to content

Commit

Permalink
- Implementing Geographical unit versioning and form
Browse files Browse the repository at this point in the history
  • Loading branch information
DevSeg committed Dec 13, 2024
1 parent d46fa7c commit bacc15f
Show file tree
Hide file tree
Showing 27 changed files with 1,226 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,25 @@ public CampaignFormBuilder(List<CampaignFormElement> formElements, List<Campaign
} else {
List<DistrictReferenceDto> districtsList = FacadeProvider.getDistrictFacade()
.getAllActiveByRegion(e.getValue().getUuid());

System.out.println(districtsList + "districtsListdistrictsListdistrictsListdistrictsList============================");
List<DistrictReferenceDto> allDistrictList = new ArrayList<>();

popDto.forEach(popDtoc -> allDistrictList.add(popDtoc.getDistrict()));

System.out.println(allDistrictList + "allDistrictListallDistrictListallDistrictList=============2222222222222222222222");


List<DistrictReferenceDto> filteredDistrictListwithDup = districtsList.stream()
.filter(allDistrictList::contains).collect(Collectors.toList());


// Remove duplicates using Set
Set<DistrictReferenceDto> uniqueSet = new HashSet<>(filteredDistrictListwithDup);

// Convert the set back to a list (if needed)
List<DistrictReferenceDto> filteredDistrictList = new ArrayList<>(uniqueSet);
System.out.println(filteredDistrictList + "filteredDistrictListfilteredDistrictListfilteredDistrictList=============3333333333333333");

districts = filteredDistrictList;
// districts = FacadeProvider.getDistrictFacade().getAllActiveByRegion(e.getValue().getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ public static StreamResource createTransposedDataFromIndexList(CampaignFormDataC
individualTransposedFormData.getCreatingUser() != null
? individualTransposedFormData.getCreatingUser().toString()
: "");
row.set(14, day);
row.set(14, day.split("_")[1]);

for (String variable : uniqueVariablePartsWithoutDaySuffixForColumnHeader) {
String key = variable + "_" + day;
String key = variable + day;
if (formDataMaxp.containsKey(key)) {
String keyValue = formDataMaxp.get(key);
int colIndex = columnNames.indexOf(variable);
Expand Down
13 changes: 13 additions & 0 deletions sormas-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>



<dependency>
<groupId>com.github.mpkorstanje</groupId>
Expand Down Expand Up @@ -106,6 +108,17 @@
<artifactId>log4j-core</artifactId>
<version>2.20.0</version>
</dependency>

<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-52</artifactId>
<version>2.21.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ List<CampaignFormMetaDto> getIndexList(CampaignFormCriteria campaignFormCriteria

List<CampaignFormMetaReferenceDto> getCampaignFormByCampaignAndFormType(String campaignUuid, String formType);

List<CampaignFormMetaHistoryExtractDto> getFormsMetaHistory(String formUuid);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
package de.symeda.sormas.api.campaign.form;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import javax.persistence.Column;
import javax.persistence.Entity;


import com.fasterxml.jackson.annotation.JsonInclude;
import com.vladmihalcea.hibernate.type.json.JsonStringType;

@JsonInclude(JsonInclude.Include.NON_NULL)

public class CampaignFormMetaHistoryExtractDto implements Serializable, Comparable<CampaignFormMetaHistoryExtractDto> {

private String uuid;
private String formname;

// private Map<String, Object> campaignFormElements = new HashMap<>();
// private List<CampaignFormElement> campaignFormElements; // To store JSON data
private String campaignFormElements;
private String formid;
private LocalDateTime start_date;
private LocalDateTime end_date;

// public CampaignFormMetaHistoryExtractDto(String uuid, String formName, Map<String, Object> campaignFormElements,
// String formId, LocalDateTime startDate, Object endDate) {
// this.uuid = uuid;
// this.formname = formName;
// this.campaignFormElements = campaignFormElements != null
// ? campaignFormElements
// : new HashMap<>(); // it's
// // never
// // null
// this.formid = formId;
// this.start_date = startDate;
// this.end_date = (endDate instanceof LocalDateTime) ? (LocalDateTime) endDate : null;
// }

// public CampaignFormMetaHistoryExtractDto(String uuid, String formName, List<CampaignFormElement> campaignFormElements, String formId,
// LocalDateTime startDate, Object endDate) {
// this.uuid = uuid;
// this.formname = formName;
// this.campaignFormElements = campaignFormElements; // Ensure it's never null
// this.formid = formId;
// this.start_date = startDate;
// this.end_date = (endDate instanceof LocalDateTime) ? (LocalDateTime) endDate : null;
// }

// public CampaignFormMetaHistoryExtractDto(String uuid, String formName,
// List<CampaignFormElement> campaignFormElements, // Change type
// String formId, LocalDateTime startDate, Object endDate) {
// this.uuid = uuid;
// this.formname = formName;
// this.campaignFormElements = campaignFormElements != null
// ? campaignFormElements
// : new ArrayList<>(); // Ensure never null
// this.formid = formId;
// this.start_date = startDate;
// this.end_date = (endDate instanceof LocalDateTime)
// ? (LocalDateTime) endDate
// : null;
// }


public CampaignFormMetaHistoryExtractDto(String uuid, String formName,
String campaignFormElements, // Change type
String formId, LocalDateTime startDate, Object endDate) {
this.uuid = uuid;
this.formname = formName;
this.campaignFormElements = campaignFormElements; // Ensure never null
this.formid = formId;
this.start_date = startDate;
this.end_date = (endDate instanceof LocalDateTime)
? (LocalDateTime) endDate
: null;
}




// Getters and setters
public String getCampaignFormElements() {
return campaignFormElements;
}

public void setCampaignFormElements(String campaignFormElements) {
this.campaignFormElements = campaignFormElements;
}



public String getUuid() {
return uuid;
}

public void setUuid(String uuid) {
this.uuid = uuid;
}

public String getFormname() {
return formname;
}

public void setFormname(String formname) {
this.formname = formname;
}

public String getFormid() {
return formid;
}

public void setFormid(String formid) {
this.formid = formid;
}

public LocalDateTime getStart_date() {
return start_date;
}

public void setStart_date(LocalDateTime start_date) {
this.start_date = start_date;
}

public LocalDateTime getEnd_date() {
return end_date;
}

public void setEnd_date(LocalDateTime end_date) {
this.end_date = end_date;
}
//
// public Map<String, Object> getCampaignFormElements() {
// return campaignFormElements;
// }
//
// public void setCampaignFormElements(Map<String, Object> campaignFormElements) {
// this.campaignFormElements = campaignFormElements;
// }
//
// public String getCampaignFormElementsx() {
// return campaignFormElementsx;
// }
//
// public void setCampaignFormElementsx(String campaignFormElementsx) {
// this.campaignFormElementsx = campaignFormElementsx;
// }

@Override
public int hashCode() {
return Objects.hash(campaignFormElements, end_date, formid, formname, start_date, uuid);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CampaignFormMetaHistoryExtractDto other = (CampaignFormMetaHistoryExtractDto) obj;
return Objects.equals(campaignFormElements, other.campaignFormElements)
&& Objects.equals(end_date, other.end_date) && Objects.equals(formid, other.formid)
&& Objects.equals(formname, other.formname) && Objects.equals(start_date, other.start_date)
&& Objects.equals(uuid, other.uuid);
}

@Override
public int compareTo(CampaignFormMetaHistoryExtractDto o) {
// TODO Auto-generated method stub
return 0;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.symeda.sormas.api.infrastructure.area;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -42,6 +44,10 @@ public class AreaDto extends EntityDto {
private Long areaid;
private String uuid_;
private boolean isDryRun;

private LocalDateTime startDate;
private LocalDateTime endDate;



//TODO check if you want to leave this here
Expand All @@ -64,6 +70,24 @@ public AreaDto(@Size(max = 512, message = "textTooLong") String name, Long popul
this.uuid_ = uuid_;
this.externalId = cxternalID;
}

public AreaDto(String uuid, String name, Boolean archived, Long externalID, LocalDateTime startDate, LocalDateTime endDate) {
this.uuid_ = uuid;
this.name = name;
this.archived = archived;
this.externalId = externalID;
this.startDate = startDate;
this.endDate = endDate;
}
public AreaDto(String string, String string2, Boolean boolean1, long l, LocalDateTime localDateTime, Object object) {
this.uuid_ = string;
this.name = string2;
this.archived = boolean1;
this.externalId = l;
this.startDate = localDateTime;
this.endDate = (object instanceof LocalDateTime) ? (LocalDateTime) object : null;
}


public AreaReferenceDto toReference() {
return new AreaReferenceDto(getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ public interface AreaFacade extends GeoLocationFacade<AreaDto, AreaDto, AreaRefe
AreaReferenceDto getAreaReferenceByUuid(String uuid);

ConfigurationChangeLogDto saveAreaChangeLog(ConfigurationChangeLogDto configurationChangeLogDto);

List<AreaHistoryExtractDto> getAreasHistory(String uuid);

}
Loading

0 comments on commit bacc15f

Please sign in to comment.