Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
[RELEASE]'release-1.4' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
drferreira committed Nov 14, 2017
2 parents d62d079 + 5688c8e commit 8b8c97c
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 19 deletions.
2 changes: 1 addition & 1 deletion survey-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>org.ccem.otus</groupId>
<artifactId>survey-model</artifactId>
<packaging>jar</packaging>
<version>1.3</version>
<version>1.4</version>
<name>survey-model</name>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import java.time.Instant;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

import org.ccem.otus.survey.datasource.DataSourceDefinition;
Expand Down Expand Up @@ -39,6 +37,7 @@ public List<String> getCustomIdItems() {
}

public List<String> getCustomIdOptions() {
// TODO: 28/09/17 incluir questões de grid nessa lista! Utilizar método getExtractionIDs de SurveyItem
return itemContainer.stream().filter(item -> item instanceof CheckboxQuestion)
.flatMap(item -> ((CheckboxQuestion) item).options.stream()).map(option -> option.customOptionID)
.collect(Collectors.toList());
Expand All @@ -51,6 +50,18 @@ public Set<String> getCustomIds() {
return customIds;
}

public Map<String, String> mapTemplateAndCustomIDS(){
Map<String, String> templateMap = new HashMap<>();
itemContainer.forEach(surveyItem -> {
templateMap.putAll(surveyItem.mapIDS());
});
return templateMap;
}

public Optional<SurveyItem> findSurveyItem(String templateID){
return itemContainer.stream().filter(surveyItem -> surveyItem.templateID.equals(templateID)).findFirst();
}

public static SurveyTemplate deserialize(String surveyJson) {
return getGsonBuilder().create().fromJson(surveyJson, SurveyTemplate.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ public static SurveyItemMapping getEnumByObjectType(String objectType) {

return aux;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
package org.ccem.otus.survey.template.item;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SurveyItem {

public String extents;
public String objectType;
public String templateID;
public String customID;
public String dataType;

public List<String> getExtractionIDs() {
List<String> ids = new ArrayList<>();
ids.add(this.customID);
return ids;
}

public Map<String, String> mapIDS(){
Map<String, String> map = new HashMap<>();
map.put(templateID, customID);
return map;
}

public String getTemplateID() {
return templateID;
}

public String getCustomID() {
return customID;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
import org.ccem.otus.survey.template.item.SurveyItem;
import org.ccem.otus.survey.template.item.label.Label;

import java.util.ArrayList;
import java.util.List;

public class ImageItem extends SurveyItem {

public String url;
public Label footer;

@Override
public List<String> getExtractionIDs(){
List<String> ids = new ArrayList<>();
return ids;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
import org.ccem.otus.survey.template.item.SurveyItem;
import org.ccem.otus.survey.template.item.label.Label;

import java.util.ArrayList;
import java.util.List;

public class TextItem extends SurveyItem {

public Label value;

@Override
public List<String> getExtractionIDs(){
List<String> ids = new ArrayList<>();
return ids;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ public class Question extends SurveyItem {
public FillingRules fillingRules;

}

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.ccem.otus.survey.template.item.questions.grid.integer;

import org.ccem.otus.survey.template.item.SurveyItem;
import org.ccem.otus.survey.template.item.label.Label;
import org.ccem.otus.survey.template.item.questions.Question;

public class GridInteger extends SurveyItem {
public class GridInteger extends Question {

public Label label;
public LayoutGridInteger layout;
public Label unit;

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
package org.ccem.otus.survey.template.item.questions.grid.integer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.ccem.otus.survey.template.item.questions.Question;

public class GridIntegerQuestion extends Question {

public List<GridIntegerLine> lines;

@Override
public List<String> getExtractionIDs(){
List<String> ids = new ArrayList<>();
lines.forEach(gridIntegerLine -> gridIntegerLine.gridIntegerList.forEach(gridInteger -> ids.add(gridInteger.customID)));
return ids;
}

@Override
public Map<String, String> mapIDS(){
Map<String, String> map = new HashMap<>();
map.put(templateID, customID);
for (GridIntegerLine line : lines) {
for (GridInteger gridInteger : line.gridIntegerList) {
map.put(gridInteger.templateID, gridInteger.customID);
}
}
return map;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package org.ccem.otus.survey.template.item.questions.grid.text;

import org.ccem.otus.survey.template.item.SurveyItem;
import org.ccem.otus.survey.template.item.label.Label;
import org.ccem.otus.survey.template.item.questions.Question;

public class GridText extends SurveyItem {
public class GridText extends Question {

public Label label;
public LayoutGridText layout;
public Label unit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
package org.ccem.otus.survey.template.item.questions.grid.text;

import java.util.List;

import org.ccem.otus.survey.template.item.questions.Question;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GridTextQuestion extends Question {

public List<GridTextLine> lines;
public List<GridTextLine> lines;

@Override
public List<String> getExtractionIDs(){
List<String> ids = new ArrayList<>();
lines.forEach(gridTextLine -> gridTextLine.gridTextList.forEach(gridText -> ids.add(gridText.customID)));
return ids;
}

@Override
public Map<String, String> mapIDS(){
Map<String, String> map = new HashMap<>();
map.put(templateID, customID);
for (GridTextLine line : lines) {
for (GridText gridText : line.gridTextList) {
map.put(gridText.templateID, gridText.customID);
}
}
return map;
}

}

Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package org.ccem.otus.survey.template.item.questions.metadata;

import java.util.List;
import java.util.Optional;

public class MetadataGroup {

public String extents;
public String objectType;
public List<MetadataOption> options;

public Optional<MetadataOption> getMetadataByValue(Integer value){
return options.stream().filter(metadata -> metadata.value.equals(value)).findFirst();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
public class NumericQuestion extends Question {

public Unit unit;

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
package org.ccem.otus.survey.template.item.questions.selectable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.ccem.otus.survey.template.item.questions.Question;
import org.ccem.otus.survey.template.item.questions.selectable.options.CheckboxOption;

public class CheckboxQuestion extends Question {

public List<CheckboxOption> options;


@Override
public List<String> getExtractionIDs(){
List<String> ids = new ArrayList<>();
options.forEach(checkboxOption -> ids.add(checkboxOption.customOptionID));
return ids;
}


@Override
public Map<String, String> mapIDS(){
Map<String, String> map = new HashMap<>();
map.put(templateID, customID);
for (CheckboxOption option : options) {
map.put(option.optionID, option.customOptionID);
}
return map;
}


}

0 comments on commit 8b8c97c

Please sign in to comment.