use of org.openforis.collect.manager.RecordIndexException in project collect by openforis.
the class DataService method updateActiveRecord.
@Transactional
@Secured(ENTRY_LIMITED)
public NodeChangeSetProxy updateActiveRecord(NodeUpdateRequestSetProxy requestSet) throws RecordPersistenceException, RecordIndexException {
sessionManager.checkIsActiveRecordLocked();
CollectRecord activeRecord = getActiveRecord();
NodeUpdateRequestSet reqSet = requestSet.toNodeUpdateRequestSet(codeListManager, sessionManager, activeRecord);
NodeChangeSet changeSet = updateRecord(activeRecord, reqSet);
if (!changeSet.isEmpty() && isCurrentRecordIndexable()) {
recordIndexService.temporaryIndex(activeRecord);
}
String userName = sessionManager.getSessionState().getUser().getUsername();
List<RecordEvent> events = new EventProducer().produceFor(changeSet, userName);
sessionManager.onEvents(events);
NodeChangeSetProxy result = new NodeChangeSetProxy(activeRecord, changeSet, getProxyContext());
if (requestSet.isAutoSave()) {
try {
saveActiveRecord();
result.setRecordSaved(true);
} catch (Exception e) {
result.setRecordSaved(false);
}
}
return result;
}
use of org.openforis.collect.manager.RecordIndexException in project collect by openforis.
the class RecordIndexService method search.
public List<String> search(SearchType searchType, Survey survey, int attributeDefnId, int fieldIndex, String queryText, int maxResults) throws RecordIndexException {
Schema schema = survey.getSchema();
AttributeDefinition defn = (AttributeDefinition) schema.getDefinitionById(attributeDefnId);
String indexName = defn.getAnnotation(Annotation.AUTOCOMPLETE.getQName());
if (StringUtils.isNotBlank(indexName)) {
try {
// search in ram directory
List<String> tempResult = volatileIndexManager.search(searchType, survey, attributeDefnId, fieldIndex, queryText, maxResults);
// search in file system index
List<String> committedResult = persistedIndexManager.search(searchType, survey, attributeDefnId, fieldIndex, queryText, maxResults);
List<String> result = mergeSearchResults(maxResults, tempResult, committedResult);
return result;
} catch (Exception e) {
throw new RecordIndexException(e);
}
} else {
throw new RecordIndexException("Index name is not defined for attribute with id: " + attributeDefnId);
}
}
use of org.openforis.collect.manager.RecordIndexException in project collect by openforis.
the class VolatileRecordIndexManager method index.
@Override
public void index(CollectRecord record) throws RecordIndexException {
IndexWriter indexWriter = null;
try {
indexWriter = createIndexWriter();
// temporary index is relative only to one record
clean(indexWriter);
index(indexWriter, record);
} catch (Exception e) {
throw new RecordIndexException(e);
} finally {
close(indexWriter);
}
}
Aggregations