private static SearchIndexDefinition findIndexDefinitionByKeyConcept( final DtDefinition keyConceptDtDefinition) { for (final SearchIndexDefinition indexDefinition : Home.getApp().getDefinitionSpace().getAll(SearchIndexDefinition.class)) { if (indexDefinition.getKeyConceptDtDefinition().equals(keyConceptDtDefinition)) { return indexDefinition; } } return null; }
/** {@inheritDoc} */ @Override public void start() { for (final SearchIndexDefinition indexDefinition : Home.getApp().getDefinitionSpace().getAll(SearchIndexDefinition.class)) { final List<URI<? extends KeyConcept>> dirtyElements = new ArrayList<>(); dirtyElementsPerIndexName.put(indexDefinition.getName(), dirtyElements); executorService.scheduleWithFixedDelay( new ReindexTask(indexDefinition, dirtyElements, this), 1, 1, TimeUnit.SECONDS); // on dépile les dirtyElements toutes les 1 secondes } }
/** {@inheritDoc} */ @Override public void removeAll(final SearchIndexDefinition indexDefinition, final ListFilter listFilter) { try (AnalyticsTracker tracker = analyticsManager.startTracker(ANALYTICS_TYPE, indexDefinition.getName() + "/removeAll")) { searchServicesPlugin.remove(indexDefinition, listFilter); tracker.markAsSucceeded(); } }
/** {@inheritDoc} */ @Override public <S extends KeyConcept> void remove( final SearchIndexDefinition indexDefinition, final URI<S> uri) { try (AnalyticsTracker tracker = analyticsManager.startTracker(ANALYTICS_TYPE, indexDefinition.getName() + "/remove")) { searchServicesPlugin.remove(indexDefinition, uri); tracker.setMeasure("nbModifiedRow", 1).markAsSucceeded(); } }
/** {@inheritDoc} */ @Override public long count(final SearchIndexDefinition indexDefinition) { try (AnalyticsTracker tracker = analyticsManager.startTracker(ANALYTICS_TYPE, indexDefinition.getName() + "/count")) { final long result = searchServicesPlugin.count(indexDefinition); tracker.markAsSucceeded(); return result; } }
/** {@inheritDoc} */ @Override public <S extends KeyConcept, I extends DtObject> void put( final SearchIndexDefinition indexDefinition, final SearchIndex<S, I> index) { try (AnalyticsTracker tracker = analyticsManager.startTracker(ANALYTICS_TYPE, indexDefinition.getName() + "/put")) { searchServicesPlugin.put(indexDefinition, index); tracker.setMeasure("nbModifiedRow", 1).markAsSucceeded(); } }
/** {@inheritDoc} */ @Override public void markAsDirty(final List<URI<? extends KeyConcept>> keyConceptUris) { Assertion.checkNotNull(keyConceptUris); Assertion.checkArgument(!keyConceptUris.isEmpty(), "dirty keyConceptUris cant be empty"); // ----- final DtDefinition keyConceptDefinition = keyConceptUris.get(0).getDefinition(); final SearchIndexDefinition searchIndexDefinition = findIndexDefinitionByKeyConcept(keyConceptDefinition); Assertion.checkNotNull( searchIndexDefinition, "No SearchIndexDefinition was defined for this keyConcept : {0}", keyConceptDefinition.getName()); // ----- final List<URI<? extends KeyConcept>> dirtyElements = dirtyElementsPerIndexName.get(searchIndexDefinition.getName()); synchronized (dirtyElements) { dirtyElements.addAll(keyConceptUris); // TODO : doublons ? } }
/** {@inheritDoc} */ @Override public <R extends DtObject> FacetedQueryResult<R, SearchQuery> loadList( final SearchIndexDefinition indexDefinition, final SearchQuery searchQuery, final DtListState listState) { try (AnalyticsTracker tracker = analyticsManager.startTracker(ANALYTICS_TYPE, indexDefinition.getName() + "/load")) { final FacetedQueryResult<R, SearchQuery> result = searchServicesPlugin.loadList(indexDefinition, searchQuery, listState); tracker.setMeasure("nbSelectedRow", result.getCount()).markAsSucceeded(); return result; } }