use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class CodeListItemDao method deleteInvalidParentReferenceItems.
public void deleteInvalidParentReferenceItems(CodeList codeList) {
CollectSurvey survey = (CollectSurvey) codeList.getSurvey();
int codeListId = codeList.getId();
JooqDSLContext jf = dsl(null);
jf.delete(OFC_CODE_LIST).where(OFC_CODE_LIST.CODE_LIST_ID.eq(codeListId).and(OFC_CODE_LIST.SURVEY_ID.eq(survey.getId())).and(OFC_CODE_LIST.PARENT_ID.isNotNull()).and(OFC_CODE_LIST.PARENT_ID.notIn(jf.select(OFC_CODE_LIST.ID).from(OFC_CODE_LIST).where(OFC_CODE_LIST.CODE_LIST_ID.eq(codeListId))))).execute();
if (isCacheInUse(codeList)) {
cache.clearItemsByCodeList(codeList);
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class CodeListItemDao method createSelectFromCodeListQuery.
protected static SelectQuery<Record> createSelectFromCodeListQuery(JooqDSLContext dsl, CodeList codeList) {
SelectQuery<Record> select = dsl.selectQuery();
select.addFrom(OFC_CODE_LIST);
CollectSurvey survey = (CollectSurvey) codeList.getSurvey();
select.addConditions(OFC_CODE_LIST.SURVEY_ID.equal(survey.getId()), OFC_CODE_LIST.CODE_LIST_ID.equal(codeList.getId()));
return select;
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class CodeListItemDao method hasQualifiableItems.
public boolean hasQualifiableItems(CodeList codeList) {
JooqDSLContext jf = dsl(codeList);
CollectSurvey survey = (CollectSurvey) codeList.getSurvey();
SelectConditionStep<Record1<Integer>> q = jf.selectCount().from(OFC_CODE_LIST).where(OFC_CODE_LIST.SURVEY_ID.equal(survey.getId()), OFC_CODE_LIST.CODE_LIST_ID.equal(codeList.getId()), OFC_CODE_LIST.QUALIFIABLE.equal(Boolean.TRUE));
Record r = q.fetchOne();
if (r == null) {
return false;
} else {
Integer count = (Integer) r.getValue(0);
return count > 0;
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class CodeListItemDao method removeVersioningInfo.
public void removeVersioningInfo(CodeList codeList, ModelVersion version) {
JooqDSLContext jf = dsl(null);
CollectSurvey survey = (CollectSurvey) codeList.getSurvey();
int codeListId = codeList.getId();
jf.update(OFC_CODE_LIST).set(OFC_CODE_LIST.SINCE_VERSION_ID, (Integer) null).where(OFC_CODE_LIST.SURVEY_ID.eq(survey.getId()).and(OFC_CODE_LIST.CODE_LIST_ID.eq(codeListId)).and(OFC_CODE_LIST.SINCE_VERSION_ID.eq(version.getId()))).execute();
jf.update(OFC_CODE_LIST).set(OFC_CODE_LIST.DEPRECATED_VERSION_ID, (Integer) null).where(OFC_CODE_LIST.SURVEY_ID.eq(survey.getId()).and(OFC_CODE_LIST.CODE_LIST_ID.eq(codeListId)).and(OFC_CODE_LIST.DEPRECATED_VERSION_ID.eq(version.getId()))).execute();
if (isCacheInUse(codeList)) {
cache.clearItemsByCodeList(codeList);
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class RecordDao method loadSummaries.
public List<CollectRecordSummary> loadSummaries(RecordFilter filter, List<RecordSummarySortField> sortFields) {
CollectSurvey survey = filter.getSurvey();
SelectQuery<Record> q = createSelectSummariesQuery(filter, sortFields);
Result<Record> result = q.fetch();
return fromSummaryQueryResult(result, survey);
}
Aggregations