Search in sources :

Example 71 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project records-management by Alfresco.

the class RMAfterInvocationProvider method decide.

private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config, PagingLuceneResultSet returnedObject) {
    ResultSet raw = returnedObject.getWrapped();
    ResultSet filteredForPermissions = decide(authentication, object, config, raw);
    return new PagingLuceneResultSet(filteredForPermissions, returnedObject.getResultSetMetaData().getSearchParameters(), nodeService);
}
Also used : PagingLuceneResultSet(org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet) ResultSet(org.alfresco.service.cmr.search.ResultSet) FilteringResultSet(org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet) PagingLuceneResultSet(org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet)

Example 72 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project records-management by Alfresco.

the class DispositionLifecycleJobExecuter method executeImpl.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJobExecuter#execute()
 */
public void executeImpl() {
    try {
        logger.debug("Job Starting");
        if (dispositionActions != null && !dispositionActions.isEmpty()) {
            boolean hasMore = true;
            int skipCount = 0;
            while (hasMore) {
                SearchParameters params = new SearchParameters();
                params.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
                params.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
                params.setQuery(getQuery());
                params.setSkipCount(skipCount);
                // execute search
                ResultSet results = searchService.query(params);
                List<NodeRef> resultNodes = results.getNodeRefs();
                hasMore = results.hasMore();
                // increase by page size
                skipCount += resultNodes.size();
                results.close();
                if (logger.isDebugEnabled()) {
                    logger.debug("Processing " + resultNodes.size() + " nodes");
                }
                // process search results
                for (NodeRef node : resultNodes) {
                    executeAction(node);
                }
            }
        }
        logger.debug("Job Finished");
    } catch (AlfrescoRuntimeException exception) {
        if (logger.isDebugEnabled()) {
            logger.debug(exception);
        }
    }
}
Also used : SearchParameters(org.alfresco.service.cmr.search.SearchParameters) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ResultSet(org.alfresco.service.cmr.search.ResultSet) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 73 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project records-management by Alfresco.

the class PublishUpdatesJobExecuter method getUpdatedNodes.

/**
 * Get a list of the nodes with updates pending publish
 * @return  List<NodeRef>   list of node refences with updates pending publication
 */
private List<NodeRef> getUpdatedNodes() {
    RetryingTransactionCallback<List<NodeRef>> execution = new RetryingTransactionHelper.RetryingTransactionCallback<List<NodeRef>>() {

        @Override
        public List<NodeRef> execute() {
            // Build the query string
            StringBuilder sb = new StringBuilder();
            sb.append("ASPECT:\"rma:").append(ASPECT_UNPUBLISHED_UPDATE.getLocalName()).append("\"");
            String query = sb.toString();
            if (logger.isDebugEnabled()) {
                logger.debug("Executing query " + query);
            }
            // Execute query to find updates awaiting publishing
            List<NodeRef> resultNodes = null;
            SearchParameters searchParameters = new SearchParameters();
            searchParameters.setQuery(query);
            searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
            searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
            try {
                ResultSet results = searchService.query(searchParameters);
                try {
                    resultNodes = results.getNodeRefs();
                } finally {
                    results.close();
                }
            } catch (AlfrescoRuntimeException exception) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Error executing query, " + exception.getMessage());
                }
                throw exception;
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Found " + resultNodes.size() + " disposition action definitions updates awaiting publishing.");
            }
            return resultNodes;
        }
    };
    return retryingTransactionHelper.doInTransaction(execution, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SearchParameters(org.alfresco.service.cmr.search.SearchParameters) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) ResultSet(org.alfresco.service.cmr.search.ResultSet) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) List(java.util.List)

Example 74 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project records-management by Alfresco.

the class ScheduledDispositionJob method execute.

/**
 * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
 */
public void execute(JobExecutionContext context) throws JobExecutionException {
    RecordsManagementActionService rmActionService = (RecordsManagementActionService) context.getJobDetail().getJobDataMap().get("recordsManagementActionService");
    NodeService nodeService = (NodeService) context.getJobDetail().getJobDataMap().get("nodeService");
    // Calculate the date range used in the query
    Calendar cal = Calendar.getInstance();
    String year = String.valueOf(cal.get(Calendar.YEAR));
    String month = String.valueOf(cal.get(Calendar.MONTH) + 1);
    String dayOfMonth = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
    // TODO These pad() calls are in RMActionExecuterAbstractBase. I've copied them
    // here as I have no access to that class.
    final String currentDate = padString(year, 2) + "-" + padString(month, 2) + "-" + padString(dayOfMonth, 2) + "T00:00:00.00Z";
    if (logger.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Executing ").append(this.getClass().getSimpleName()).append(" with currentDate ").append(currentDate);
        logger.debug(msg.toString());
    }
    // TODO Copied the 1970 start date from the old RM JavaScript impl.
    String dateRange = "[\"1970-01-01T00:00:00.00Z\" TO \"" + currentDate + "\"]";
    // Execute the query and process the results
    String query = "+ASPECT:\"rma:record\" +ASPECT:\"rma:dispositionSchedule\" +@rma\\:dispositionAsOf:" + dateRange;
    SearchService search = (SearchService) context.getJobDetail().getJobDataMap().get("searchService");
    ResultSet results = search.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS_ALFRESCO, query);
    List<NodeRef> resultNodes = results.getNodeRefs();
    results.close();
    if (logger.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Found ").append(resultNodes.size()).append(" records eligible for disposition.");
        logger.debug(msg.toString());
    }
    for (NodeRef node : resultNodes) {
        String dispActionName = (String) nodeService.getProperty(node, RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME);
        // destroy and transfer and anything else should be manual for now
        if (dispActionName != null && dispActionName.equalsIgnoreCase("cutoff")) {
            rmActionService.executeRecordsManagementAction(node, dispActionName);
            if (logger.isDebugEnabled()) {
                logger.debug("Performing " + dispActionName + " dispoition action on disposable item " + node.toString());
            }
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodeService(org.alfresco.service.cmr.repository.NodeService) Calendar(java.util.Calendar) SearchService(org.alfresco.service.cmr.search.SearchService) ResultSet(org.alfresco.service.cmr.search.ResultSet)

Example 75 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project alfresco-repository by Alfresco.

the class AbstractAlfrescoFtsQueryLanguage method executeQuery.

public ResultSet executeQuery(SearchParameters searchParameters) {
    String ftsExpression = searchParameters.getQuery();
    QueryModelFactory factory = queryEngine.getQueryModelFactory();
    AlfrescoFunctionEvaluationContext context = new AlfrescoFunctionEvaluationContext(namespaceService, dictionaryService, searchParameters.getNamespace());
    QueryOptions options = QueryOptions.create(searchParameters);
    FTSParser.Mode mode;
    if (options.getDefaultFTSConnective() == Connective.AND) {
        mode = FTSParser.Mode.DEFAULT_CONJUNCTION;
    } else {
        mode = FTSParser.Mode.DEFAULT_DISJUNCTION;
    }
    Constraint constraint = FTSQueryParser.buildFTS(ftsExpression, factory, context, null, null, mode, options.getDefaultFTSFieldConnective(), searchParameters.getQueryTemplates(), options.getDefaultFieldName(), FTSQueryParser.RerankPhase.SINGLE_PASS);
    org.alfresco.repo.search.impl.querymodel.Query query = factory.createQuery(null, null, constraint, buildOrderings(factory, searchParameters));
    QueryEngineResults results = queryEngine.executeQuery(query, options, context);
    ResultSet resultSet = results.getResults().values().iterator().next();
    return resultSet;
}
Also used : QueryEngineResults(org.alfresco.repo.search.impl.querymodel.QueryEngineResults) Constraint(org.alfresco.repo.search.impl.querymodel.Constraint) AlfrescoFunctionEvaluationContext(org.alfresco.repo.search.impl.parsers.AlfrescoFunctionEvaluationContext) FTSParser(org.alfresco.repo.search.impl.parsers.FTSParser) QueryOptions(org.alfresco.repo.search.impl.querymodel.QueryOptions) ResultSet(org.alfresco.service.cmr.search.ResultSet) QueryModelFactory(org.alfresco.repo.search.impl.querymodel.QueryModelFactory)

Aggregations

ResultSet (org.alfresco.service.cmr.search.ResultSet)112 NodeRef (org.alfresco.service.cmr.repository.NodeRef)57 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)49 ArrayList (java.util.ArrayList)25 HashMap (java.util.HashMap)22 SolrJSONResultSet (org.alfresco.repo.search.impl.lucene.SolrJSONResultSet)20 Test (org.junit.Test)20 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)17 QName (org.alfresco.service.namespace.QName)16 StoreRef (org.alfresco.service.cmr.repository.StoreRef)14 ResultSetRow (org.alfresco.service.cmr.search.ResultSetRow)14 HashSet (java.util.HashSet)13 EmptyResultSet (org.alfresco.repo.search.EmptyResultSet)13 SearchService (org.alfresco.service.cmr.search.SearchService)13 NodeService (org.alfresco.service.cmr.repository.NodeService)12 IOException (java.io.IOException)11 List (java.util.List)11 SearchRequestContext (org.alfresco.rest.api.search.context.SearchRequestContext)11 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)10 PagingLuceneResultSet (org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet)10