use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method getActiveRecord.
protected CollectRecord getActiveRecord() {
SessionState sessionState = getSessionState();
CollectRecord activeRecord = sessionState.getActiveRecord();
return activeRecord;
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method assignOwner.
@Secured(CLEANSING)
public void assignOwner(int recordId, Integer ownerId) throws RecordLockedException, MultipleEditException {
SessionState sessionState = sessionManager.getSessionState();
recordManager.assignOwner(sessionState.getActiveSurvey(), recordId, ownerId, sessionState.getUser(), sessionState.getSessionId());
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method moveRecords.
@Secured(CLEANSING)
public SurveyLockingJobProxy moveRecords(String rootEntity, int fromStepNumber, final boolean promote) {
BulkRecordMoveJob job = collectJobManager.createJob(BulkRecordMoveJob.class);
SessionState sessionState = getSessionState();
final String userName = sessionState.getUser().getUsername();
job.setSurvey(sessionState.getActiveSurvey());
job.setRootEntity(rootEntity);
job.setPromote(promote);
final Step fromStep = Step.valueOf(fromStepNumber);
job.setFromStep(fromStep);
job.setUser(sessionState.getUser());
job.setRecordMovedCallback(new BulkRecordMoveJob.Callback() {
@Override
public void recordMoved(CollectRecord record) {
if (promote) {
publishRecordPromotedEvents(record, userName);
} else {
publishRecordDeletedEvent(record, fromStep.toRecordStep(), userName);
}
}
});
collectJobManager.startSurveyJob(job);
return new SurveyLockingJobProxy(job);
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class DataService method loadRecordSummaries.
@Secured(USER)
public Map<String, Object> loadRecordSummaries(RecordFilterProxy filterProxy, List<RecordSummarySortField> sortFields, String localeStr) {
Map<String, Object> result = new HashMap<String, Object>();
CollectSurvey survey;
if (filterProxy.getSurveyId() > 0) {
survey = surveyManager.getById(filterProxy.getSurveyId());
} else {
SessionState sessionState = sessionManager.getSessionState();
survey = sessionState.getActiveSurvey();
}
RecordFilter filter = filterProxy.toFilter(survey);
// load summaries
List<CollectRecordSummary> summaries = recordManager.loadSummaries(filter, sortFields);
Locale locale = LocaleUtils.toLocale(localeStr);
ProxyContext proxyContext = new ProxyContext(locale, messageSource, surveyContext);
List<RecordSummaryProxy> proxies = RecordSummaryProxy.fromList(summaries, proxyContext);
result.put("records", proxies);
// count total records
int count = recordManager.countRecords(filter);
result.put("count", count);
return result;
}
use of org.openforis.collect.web.session.SessionState in project collect by openforis.
the class ModelService method getActiveLanguageCode.
protected String getActiveLanguageCode() {
SessionState sessionState = sessionManager.getSessionState();
Locale locale = sessionState.getLocale();
String lang;
if (locale != null) {
lang = locale.getLanguage();
} else {
lang = "en";
}
return lang;
}
Aggregations