Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #439 from fieldsight/438/bugfix-subsites-not-ordered
Browse files Browse the repository at this point in the history
Adds asc order substages (#438)
  • Loading branch information
yubarajpoudel authored Oct 31, 2019
2 parents c5ef08d + 4e19a0a commit 1fe8ec2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 247 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public List<Stage> apply(List<FieldsightFormDetailsv3> formDetailsv3s) throws Ex
String formDeployedFrom = form.getProject() == null ? Constant.FormDeploymentFrom.SITE : Constant.FormDeploymentFrom.PROJECT;
subStage.setFormDeployedFrom(formDeployedFrom);
subStage.setFsFormId(form.getId());
subStage.setOrder(Integer.valueOf(stageAndSubStage.getSubstageOrder()));

// Group subStage
int stageOrder = Integer.parseInt(stageAndSubStage.getStageOrder());
Expand All @@ -164,7 +165,16 @@ public List<Stage> apply(List<FieldsightFormDetailsv3> formDetailsv3s) throws Ex
// add subStage to stages
for (Stage stage1 : stages) {
Integer stageOrder = stage1.getOrder();
stage1.setSubStage((ArrayList<SubStage>) groupByStage.get(stageOrder));
ArrayList<SubStage> substages = (ArrayList<SubStage>) groupByStage.get(stageOrder);
Collections.sort(substages, new Comparator<SubStage>() {
@Override
public int compare(SubStage t1, SubStage t2) {
return t1.getOrder().compareTo(t2.getOrder());
}
});

stage1.setSubStage(substages);

}
return new ArrayList<>(stages);
}
Expand Down Expand Up @@ -195,27 +205,27 @@ public boolean test(FieldsightFormDetailsv3 formDetailsv3) {

try {
JSONObject jsonObject = new JSONObject(formDetailsv3.getMetaAttributes());
if(jsonObject.has("stage_type")) {
if (jsonObject.has("stage_type")) {
JSONArray jsonArray = jsonObject.optJSONArray("stage_type");
Timber.i("FieldsightFormlocalsourcev3, stageTypeArray = %s", jsonArray.toString());
for(int i = 0; i < jsonArray.length(); i ++) {
if(jsonArray.optInt(i) == newsiteTypeId) {
for (int i = 0; i < jsonArray.length(); i++) {
if (jsonArray.optInt(i) == newsiteTypeId) {
typeFound = true;
break;
}
}
}
if(jsonObject.has("stage_regions")) {
if (jsonObject.has("stage_regions")) {
JSONArray jsonArray = jsonObject.optJSONArray("stage_regions");
Timber.i("FieldsightFormlocalsourcev3, stageRegionArray = %s", jsonArray.toString());
for(int i = 0; i < jsonArray.length(); i ++) {
if(jsonArray.optInt(i) == newsiteRegionId) {
for (int i = 0; i < jsonArray.length(); i++) {
if (jsonArray.optInt(i) == newsiteRegionId) {
regionFound = true;
break;
}
}
}
}catch( Exception e) {
} catch (Exception e) {
Timber.e(e);
}
Timber.i("getSortedPages, typeFound = " + typeFound + " regionFound = " + regionFound);
Expand Down

0 comments on commit 1fe8ec2

Please sign in to comment.