Search in sources :

Example 1 with SessionStatus

use of org.openforis.collect.designer.session.SessionStatus in project collect by openforis.

the class CodeListImportService method start.

@Secured("ROLE_ADMIN")
public CodeListImportStatusProxy start(int codeListId, String tempFileName, CSVFileOptions fileOptions, boolean overwriteData) throws DataImportExeption {
    if (importProcess == null || !importProcess.getStatus().isRunning()) {
        File importFile = new File(tempFileName);
        SessionStatus designerSessionStatus = sessionManager.getDesignerSessionStatus();
        CollectSurvey survey = designerSessionStatus.getSurvey();
        String langCode = designerSessionStatus.getCurrentLanguageCode();
        CodeList codeList = survey.getCodeListById(codeListId);
        importProcess = new CodeListImportProcess(codeListManager, codeList, langCode, importFile, fileOptions, overwriteData);
        importProcess.init();
        CodeListImportStatus status = importProcess.getStatus();
        if (status != null && !importProcess.getStatus().isError()) {
            startProcessThread();
        }
    }
    return getStatus();
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) SessionStatus(org.openforis.collect.designer.session.SessionStatus) CodeListImportStatus(org.openforis.collect.manager.codelistimport.CodeListImportStatus) CollectSurvey(org.openforis.collect.model.CollectSurvey) File(java.io.File) CodeListImportProcess(org.openforis.collect.manager.codelistimport.CodeListImportProcess) Secured(org.springframework.security.access.annotation.Secured)

Example 2 with SessionStatus

use of org.openforis.collect.designer.session.SessionStatus in project collect by openforis.

the class BaseVM method getSessionStatus.

protected SessionStatus getSessionStatus() {
    Session session = getSession();
    String key = SessionStatus.SESSION_KEY;
    SessionStatus sessionStatus = (SessionStatus) session.getAttribute(key);
    if (sessionStatus == null) {
        sessionStatus = new SessionStatus();
        session.setAttribute(key, sessionStatus);
    }
    return sessionStatus;
}
Also used : SessionStatus(org.openforis.collect.designer.session.SessionStatus) Session(org.zkoss.zk.ui.Session)

Example 3 with SessionStatus

use of org.openforis.collect.designer.session.SessionStatus in project collect by openforis.

the class SchemaLayoutVM method setFormVersion.

public void setFormVersion(ModelVersion formVersion) {
    SessionStatus sessionStatus = getSessionStatus();
    sessionStatus.setLayoutFormVersion(formVersion);
}
Also used : SessionStatus(org.openforis.collect.designer.session.SessionStatus)

Example 4 with SessionStatus

use of org.openforis.collect.designer.session.SessionStatus in project collect by openforis.

the class SurveyEditVM method languageCodeSelected.

@Command
@NotifyChange({ "currentLanguageCode" })
public void languageCodeSelected(@BindingParam("code") final String selectedLanguageCode) {
    final SessionStatus sessionStatus = getSessionStatus();
    checkCanLeaveForm(new CanLeaveFormConfirmHandler() {

        @Override
        public void onOk(boolean confirmed) {
            sessionStatus.setCurrentLanguageCode(selectedLanguageCode);
            BindUtils.postGlobalCommand(null, null, SurveyLanguageVM.CURRENT_LANGUAGE_CHANGED_COMMAND, null);
            currentLanguageCode = sessionStatus.getCurrentLanguageCode();
        }
    });
}
Also used : SessionStatus(org.openforis.collect.designer.session.SessionStatus) NotifyChange(org.zkoss.bind.annotation.NotifyChange) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 5 with SessionStatus

use of org.openforis.collect.designer.session.SessionStatus in project collect by openforis.

the class SurveyLanguageVM method applyChanges.

@Command
public void applyChanges() {
    final SessionStatus sessionStatus = getSessionStatus();
    final CollectSurvey survey = sessionStatus.getSurvey();
    final List<String> newLanguageCodes = getSelectedLanguageCodes();
    final List<String> removedLanguages = calculateRemovedLanguages();
    if (removedLanguages.isEmpty()) {
        performLanguageUpdate(survey, newLanguageCodes);
    } else {
        ConfirmParams confirmParams = new ConfirmParams(new MessageUtil.ConfirmHandler() {

            @Override
            public void onOk() {
                performLanguageUpdate(survey, newLanguageCodes);
            }
        }, "survey.language.remove.confirm");
        confirmParams.setOkLabelKey("global.remove_item");
        confirmParams.setMessageArgs(new String[] { StringUtils.join(removedLanguages, ", ") });
        MessageUtil.showConfirm(confirmParams);
    }
}
Also used : ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) MessageUtil(org.openforis.collect.designer.util.MessageUtil) SessionStatus(org.openforis.collect.designer.session.SessionStatus) CollectSurvey(org.openforis.collect.model.CollectSurvey) Command(org.zkoss.bind.annotation.Command)

Aggregations

SessionStatus (org.openforis.collect.designer.session.SessionStatus)21 CollectSurvey (org.openforis.collect.model.CollectSurvey)9 Command (org.zkoss.bind.annotation.Command)3 CodeList (org.openforis.idm.metamodel.CodeList)2 ModelVersion (org.openforis.idm.metamodel.ModelVersion)2 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)2 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)2 NotifyChange (org.zkoss.bind.annotation.NotifyChange)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 MessageUtil (org.openforis.collect.designer.util.MessageUtil)1 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)1 CodeListImportProcess (org.openforis.collect.manager.codelistimport.CodeListImportProcess)1 CodeListImportStatus (org.openforis.collect.manager.codelistimport.CodeListImportStatus)1 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)1 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)1 Schema (org.openforis.idm.metamodel.Schema)1 Secured (org.springframework.security.access.annotation.Secured)1 Init (org.zkoss.bind.annotation.Init)1