Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
use hql query for project-wide search
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Nov 23, 2012
1 parent 6d3d0c9 commit 1a6d8aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Expand Up @@ -94,7 +94,7 @@ public class TextFlowSearchServiceImpl implements TextFlowSearchService
private FullTextSession session;

// Disabled for now, due to the need for a left join
private static final boolean ENABLE_HQL_SEARCH = false;
private static final boolean ENABLE_HQL_SEARCH = true;

@Override
public List<HTextFlow> findTextFlows(WorkspaceId workspace, FilterConstraints constraints)
Expand Down Expand Up @@ -169,19 +169,13 @@ private List<HTextFlow> findTextFlowsWithDatabaseSearch(String projectSlug, Stri
// TODO wrap in method for batching list of documents
// assuming doclist has already been batched before this method call

// FIXME this query needs to use a left join, at least when searching
// source strings, because there may not be HTextFlowTarget for the
// HTextFlow.

// FIXME constrain to only non-obsolete documents?
// check that this is not already handled by id list retrieval

HLocale loc = localeServiceImpl.getByLocaleId(validatedLocaleId);
Long locId = loc.getId();

ArrayList<String> projectDocStateConstraints = new ArrayList<String>();
projectDocStateConstraints.add("tf.document.projectIteration.project.slug = :project");
projectDocStateConstraints.add("tf.document.projectIteration.slug = :iteration");
projectDocStateConstraints.add("tf.document.obsolete = false");

boolean hasDocumentPaths = documentPaths != null && !documentPaths.isEmpty();
if (hasDocumentPaths)
Expand Down Expand Up @@ -243,7 +237,8 @@ private List<HTextFlow> findTextFlowsWithDatabaseSearch(String projectSlug, Stri
String[] contentChecks = contentCheckList.toArray(new String[contentCheckList.size()]);
String[] projectDocStateChecks = projectDocStateConstraints.toArray(new String[projectDocStateConstraints.size()]);

String queryStr = select("tf").from("HTextFlow tf")
String queryStr = select("distinct tf").from("HTextFlow tf")
.leftJoin("tf.targets tfts")
.where(and(and(projectDocStateChecks), or(contentChecks)))
.toQueryString();

Expand Down
Expand Up @@ -96,7 +96,7 @@ public GetProjectTransUnitListsResult execute(GetProjectTransUnitLists action, E
return new GetProjectTransUnitListsResult(action, docPaths, matchingTUs);
}

FilterConstraints filterConstraints = FilterConstraints.filterBy(action.getSearchString()).excludeNew().caseSensitive(action.isCaseSensitive());
FilterConstraints filterConstraints = FilterConstraints.filterBy(action.getSearchString()).includeNew().caseSensitive(action.isCaseSensitive());
if (!action.isSearchInSource())
{
filterConstraints.ignoreSource();
Expand Down

0 comments on commit 1a6d8aa

Please sign in to comment.