Search in sources :

Example 1 with RecordIndexException

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;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) NodeChangeSet(org.openforis.collect.model.NodeChangeSet) EventProducer(org.openforis.collect.event.EventProducer) RecordEvent(org.openforis.collect.event.RecordEvent) NodeChangeSetProxy(org.openforis.collect.model.proxy.NodeChangeSetProxy) RecordPromoteException(org.openforis.collect.manager.RecordPromoteException) RecordUnlockedException(org.openforis.collect.persistence.RecordUnlockedException) RecordIndexException(org.openforis.collect.manager.RecordIndexException) RecordLockedException(org.openforis.collect.persistence.RecordLockedException) MultipleEditException(org.openforis.collect.persistence.MultipleEditException) RecordPersistenceException(org.openforis.collect.persistence.RecordPersistenceException) Secured(org.springframework.security.access.annotation.Secured) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with RecordIndexException

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);
    }
}
Also used : Schema(org.openforis.idm.metamodel.Schema) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) RecordIndexException(org.openforis.collect.manager.RecordIndexException) RecordIndexException(org.openforis.collect.manager.RecordIndexException)

Example 3 with RecordIndexException

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);
    }
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) RecordIndexException(org.openforis.collect.manager.RecordIndexException) RecordIndexException(org.openforis.collect.manager.RecordIndexException)

Aggregations

RecordIndexException (org.openforis.collect.manager.RecordIndexException)3 IndexWriter (org.apache.lucene.index.IndexWriter)1 EventProducer (org.openforis.collect.event.EventProducer)1 RecordEvent (org.openforis.collect.event.RecordEvent)1 RecordPromoteException (org.openforis.collect.manager.RecordPromoteException)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 NodeChangeSet (org.openforis.collect.model.NodeChangeSet)1 NodeChangeSetProxy (org.openforis.collect.model.proxy.NodeChangeSetProxy)1 MultipleEditException (org.openforis.collect.persistence.MultipleEditException)1 RecordLockedException (org.openforis.collect.persistence.RecordLockedException)1 RecordPersistenceException (org.openforis.collect.persistence.RecordPersistenceException)1 RecordUnlockedException (org.openforis.collect.persistence.RecordUnlockedException)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 Schema (org.openforis.idm.metamodel.Schema)1 Secured (org.springframework.security.access.annotation.Secured)1 Transactional (org.springframework.transaction.annotation.Transactional)1