use of org.openforis.collect.model.SurveySummary in project collect by openforis.
the class SurveyWorkDao method loadSurveySummary.
@Transactional
public SurveySummary loadSurveySummary(int id) {
Record record = dsl().select().from(OFC_SURVEY_WORK).where(OFC_SURVEY_WORK.ID.equal(id)).fetchOne();
SurveySummary result = processSurveySummaryRow(record);
return result;
}
use of org.openforis.collect.model.SurveySummary in project collect by openforis.
the class SurveyWorkDao method processSurveySummaryRow.
@Override
protected SurveySummary processSurveySummaryRow(Record row) {
if (row == null) {
return null;
}
Integer id = row.getValue(OFC_SURVEY_WORK.ID);
String name = row.getValue(OFC_SURVEY_WORK.NAME);
String uri = row.getValue(OFC_SURVEY.URI);
SurveySummary survey = new SurveySummary(id, name, uri, null);
survey.setTarget(SurveyTarget.fromCode(row.getValue(OFC_SURVEY.TARGET)));
survey.setCreationDate(row.getValue(OFC_SURVEY.DATE_CREATED));
survey.setModifiedDate(row.getValue(OFC_SURVEY.DATE_MODIFIED));
survey.setWork(true);
survey.setPublished(false);
return survey;
}
use of org.openforis.collect.model.SurveySummary in project collect by openforis.
the class SurveyWorkDao method loadSurveySummaryByUri.
@Transactional
public SurveySummary loadSurveySummaryByUri(String uri) {
Record record = dsl().select().from(OFC_SURVEY_WORK).where(OFC_SURVEY_WORK.URI.equal(uri)).fetchOne();
SurveySummary result = processSurveySummaryRow(record);
return result;
}
use of org.openforis.collect.model.SurveySummary in project collect by openforis.
the class SurveyNameValidator method validateNameUniqueness.
private boolean validateNameUniqueness(ValidationContext ctx) {
String name = getValue(ctx, surveyNameField);
SurveySummary existingSurveySummary = loadExistingSurveySummaryByName(ctx, name);
if (existingSurveySummary == null) {
return true;
} else {
this.addInvalidMessage(ctx, surveyNameField, Labels.getLabel(DUPLICATE_NAME_MESSAGE_KEY));
return false;
}
}
use of org.openforis.collect.model.SurveySummary in project collect by openforis.
the class SurveyController method loadSurveys.
@SuppressWarnings("unchecked")
@RequestMapping(method = GET)
@ResponseBody
public List<?> loadSurveys(@RequestParam(value = "userId", required = false) Integer userId, @RequestParam(value = "groupId", required = false) Integer groupId, @RequestParam(value = "full", required = false) boolean fullSurveys, @RequestParam(value = "includeCodeListValues", required = false) boolean includeCodeListValues, @RequestParam(value = "includeTemporary", required = false) boolean includeTemporary) throws Exception {
String languageCode = Locale.ENGLISH.getLanguage();
if (userId == null) {
userId = sessionManager.getLoggedUser().getId();
}
Set<Integer> groupIds = getAvailableUserGroupIds(userId, groupId);
List<SurveySummary> summaries = new ArrayList<SurveySummary>(surveyManager.getSurveySummaries(languageCode, groupIds));
if (includeTemporary) {
summaries.addAll(surveyManager.loadTemporarySummaries(languageCode, true, groupIds));
}
List<Object> views = new ArrayList<Object>();
for (SurveySummary surveySummary : summaries) {
if (fullSurveys) {
CollectSurvey survey = surveyManager.getOrLoadSurveyById(surveySummary.getId());
views.add(generateView(survey, includeCodeListValues));
} else {
views.add(surveySummary);
}
}
views.sort(Collections.reverseOrder(new BeanComparator("modifiedDate")));
return views;
}
Aggregations