Search in sources :

Example 1 with CollectSurvey

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);
    }
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 2 with CollectSurvey

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;
}
Also used : OfcCodeListRecord(org.openforis.collect.persistence.jooq.tables.records.OfcCodeListRecord) Record(org.jooq.Record) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 3 with CollectSurvey

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;
    }
}
Also used : OfcCodeListRecord(org.openforis.collect.persistence.jooq.tables.records.OfcCodeListRecord) Record(org.jooq.Record) CollectSurvey(org.openforis.collect.model.CollectSurvey) Record1(org.jooq.Record1)

Example 4 with CollectSurvey

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);
    }
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 5 with CollectSurvey

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);
}
Also used : OfcRecordRecord(org.openforis.collect.persistence.jooq.tables.records.OfcRecordRecord) CollectRecord(org.openforis.collect.model.CollectRecord) OfcRecordDataRecord(org.openforis.collect.persistence.jooq.tables.records.OfcRecordDataRecord) Record(org.jooq.Record) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Aggregations

CollectSurvey (org.openforis.collect.model.CollectSurvey)329 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)53 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)40 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)38 CollectRecord (org.openforis.collect.model.CollectRecord)30 RecordFilter (org.openforis.collect.model.RecordFilter)27 Transactional (org.springframework.transaction.annotation.Transactional)26 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)25 ArrayList (java.util.ArrayList)23 File (java.io.File)21 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)21 Secured (org.springframework.security.access.annotation.Secured)20 User (org.openforis.collect.model.User)19 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)19 SessionState (org.openforis.collect.web.session.SessionState)18 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)17 Test (org.junit.Test)16 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)15 CodeList (org.openforis.idm.metamodel.CodeList)15 Schema (org.openforis.idm.metamodel.Schema)15