Skip to content

Commit

Permalink
issue #111
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed May 19, 2016
1 parent 70fc96d commit 1a9c910
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ public static ItemCollection cloneWorkitem(ItemCollection aWorkitem) {
clone.replaceItemValue("$isAuthor", aWorkitem.getItemValue("$isAuthor"));

clone.replaceItemValue("txtWorkflowStatus", aWorkitem.getItemValue("txtWorkflowStatus"));
clone.replaceItemValue("txtWorkflowSummary", aWorkitem.getItemValue("txtWorkflowSummary"));
clone.replaceItemValue("txtWorkflowAbstract", aWorkitem.getItemValue("txtWorkflowAbstract"));
clone.replaceItemValue("txtEmail", aWorkitem.getItemValue("txtEmail"));
clone.replaceItemValue("namdeputy", aWorkitem.getItemValue("namdeputy"));
clone.replaceItemValue("txtusericon", aWorkitem.getItemValue("txtusericon"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.imixs.workflow.ItemCollectionComparator;
import org.imixs.workflow.exceptions.AccessDeniedException;
import org.imixs.workflow.jee.ejb.WorkflowService;
import org.imixs.workflow.lucene.LuceneSearchService;

/**
* The UserInputController provides suggest-box behavior based on the JSF 2.0
Expand Down Expand Up @@ -74,6 +75,10 @@ public class UserInputController implements Serializable {

@EJB
protected WorkflowService workflowService;

@EJB
protected LuceneSearchService luceneSearchService;


private List<ItemCollection> searchResult = null;

Expand Down Expand Up @@ -157,30 +162,37 @@ public List<ItemCollection> searchProfile(String phrase) {
if (phrase == null || phrase.isEmpty())
return searchResult;

phrase = "%" + phrase.trim() + "%";

String sQuery = "SELECT DISTINCT profile FROM Entity as profile "
+ " JOIN profile.textItems AS t0"
+ " JOIN profile.textItems AS t1"
+ " JOIN profile.textItems AS t2"
+ " WHERE profile.type= 'profile' " + " AND "
+ " ( (t1.itemName = 'txtusername' "
+ " AND t1.itemValue LIKE '" + phrase + "') "
+ " OR (t2.itemName = 'txtemail' "
+ " AND t2.itemValue LIKE '" + phrase + "') "
+ " OR (t0.itemName = 'txtname' " + " AND t0.itemValue LIKE '"
+ phrase + "') " + " )";
phrase = phrase.trim();

// String sQuery = "SELECT DISTINCT profile FROM Entity as profile "
// + " JOIN profile.textItems AS t0"
// + " JOIN profile.textItems AS t1"
// + " JOIN profile.textItems AS t2"
// + " WHERE profile.type= 'profile' " + " AND "
// + " ( (t1.itemName = 'txtusername' "
// + " AND t1.itemValue LIKE '" + phrase + "') "
// + " OR (t2.itemName = 'txtemail' "
// + " AND t2.itemValue LIKE '" + phrase + "') "
// + " OR (t0.itemName = 'txtname' " + " AND t0.itemValue LIKE '"
// + phrase + "') " + " )";

String sQuery= "(type:\"profile\") AND ( *" + phrase + "* )";

logger.finest("searchprofile: " + sQuery);

Collection<ItemCollection> col = workflowService.getEntityService()
.findAllEntities(sQuery, 0, maxSearchCount);
// start lucene search
Collection<ItemCollection> col = null;
try {
logger.fine("searchWorkitems: " + sQuery);
col = luceneSearchService.search(sQuery, workflowService);
} catch (Exception e) {
logger.warning(" lucene error!");
e.printStackTrace();
}

for (ItemCollection profile : col) {
searchResult.add(ProfileService.cloneWorkitem(profile));

}

// sort by username..
Collections.sort(searchResult, new ItemCollectionComparator("txtUserName",
true));
Expand Down

0 comments on commit 1a9c910

Please sign in to comment.