WorkflowServiceSolrIndex implements WorkflowServiceIndex { protected String createQuery(WorkflowQuery query, String action, boolean applyPermissions) throws WorkflowDatabaseException { String orgId = securityService.getOrganization().getId(); StringBuilder sb = new StringBuilder().append(ORG_KEY).append(":").append(escapeQueryChars(orgId)); append(sb, ID_KEY, query.getId(), false); append(sb, MEDIAPACKAGE_KEY, query.getMediaPackageId(), false); append(sb, SERIES_ID_KEY, query.getSeriesId(), false); appendFuzzy(sb, SERIES_TITLE_KEY, query.getSeriesTitle()); appendFuzzy(sb, FULLTEXT_KEY, query.getText()); append(sb, WORKFLOW_DEFINITION_KEY, query.getWorkflowDefinitionId(), false); append(sb, CREATED_KEY, query.getFromDate(), query.getToDate()); appendFuzzy(sb, CREATOR_KEY, query.getCreator()); appendFuzzy(sb, CONTRIBUTOR_KEY, query.getContributor()); appendFuzzy(sb, LANGUAGE_KEY, query.getLanguage()); appendFuzzy(sb, LICENSE_KEY, query.getLicense()); appendFuzzy(sb, TITLE_KEY, query.getTitle()); appendFuzzy(sb, SUBJECT_KEY, query.getSubject()); appendMap(sb, OPERATION_KEY, query.getCurrentOperations()); appendMap(sb, STATE_KEY, query.getStates()); if (applyPermissions) { appendSolrAuthFragment(sb, action); } logger.debug(sb.toString()); return sb.toString(); }  @Activate void activate(ComponentContext cc); void activate(String systemUserName); @Deactivate void deactivate(); void index(final WorkflowInstance instance); @Override long countWorkflowInstances(WorkflowState state, String operation); @Override WorkflowStatistics getStatistics(); @Override WorkflowSet getWorkflowInstances(WorkflowQuery query, String action, boolean applyPermissions); @Override void remove(long id); @Override void update(WorkflowInstance instance); void clear(); static final String CONFIG_SOLR_URL; static final String CONFIG_SOLR_ROOT; static final Fn<Job, Boolean> operationIsStartWorkflow; }
@Test public void testBuildSimpleQuery() throws Exception { WorkflowQuery q = new WorkflowQuery().withMediaPackage("123").withSeriesId("series1"); String solrQuery = dao.createQuery(q, Permissions.Action.READ.toString(), true); String expected = "oc_org:mh_default_org AND mediapackageid:123 AND seriesid:series1"; assertEquals(expected, solrQuery); }
@Test public void testBuildMultiStateQuery() throws Exception { WorkflowQuery q = new WorkflowQuery().withSeriesId("series1").withState(WorkflowState.RUNNING) .withState(WorkflowState.PAUSED); String solrQuery = dao.createQuery(q, Permissions.Action.READ.toString(), true); String expected = "oc_org:mh_default_org AND seriesid:series1 AND (state:running OR state:paused)"; assertEquals(expected, solrQuery); }
@Test public void testBuildNegativeStatesQuery() throws Exception { WorkflowQuery q = new WorkflowQuery().withSeriesId("series1").withoutState(WorkflowState.RUNNING) .withoutState(WorkflowState.PAUSED); String solrQuery = dao.createQuery(q, Permissions.Action.READ.toString(), true); String expected = "oc_org:mh_default_org AND seriesid:series1 AND (-state:running AND -state:paused AND *:*)"; assertEquals(expected, solrQuery); }
@Test public void testBuildNegativeStateQuery() throws Exception { WorkflowQuery q = new WorkflowQuery().withSeriesId("series1").withoutState(WorkflowState.RUNNING); String solrQuery = dao.createQuery(q, Permissions.Action.READ.toString(), true); String expected = "oc_org:mh_default_org AND seriesid:series1 AND (-state:running AND *:*)"; assertEquals(expected, solrQuery); }