Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/9.0' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/9.0
  • Loading branch information
metaventis-build committed Oct 22, 2024
2 parents eaf0af1 + b2b0b4a commit 412e93c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import co.elastic.clients.elasticsearch._types.Result;
import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import co.elastic.clients.elasticsearch._types.query_dsl.*;
import co.elastic.clients.elasticsearch.core.*;
import co.elastic.clients.elasticsearch.core.search.Hit;
import co.elastic.clients.elasticsearch.core.search.HitsMetadata;
Expand All @@ -14,11 +14,13 @@
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.log4j.Logger;
import org.edu_sharing.alfrescocontext.gate.AlfAppContextGate;
import org.edu_sharing.repository.server.jobs.quartz.annotation.JobDescription;
import org.edu_sharing.repository.server.jobs.quartz.annotation.JobFieldDescription;
import org.edu_sharing.repository.server.tools.ApplicationInfoList;
import org.edu_sharing.service.search.ReadableWrapperQueryBuilder;
import org.edu_sharing.service.search.SearchServiceElastic;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
Expand All @@ -36,7 +38,7 @@ public class FixElasticSearchDeletedNodes extends AbstractJob{
@JobFieldDescription(description = "if false (default) no changes will be done.")
boolean execute;

@JobFieldDescription(description = "query that delivers a result of nodes that have to be checked. optional. if not set all nodes will be searched.",sampleValue = "{\"query\":\"{\\\"term\\\":{\\\"type\\\":\\\"ccm:io\\\"}}\"}")
@JobFieldDescription(description = "query that delivers a result of nodes that have to be checked. optional. if not set all nodes will be searched.",sampleValue = "{\"term\":{\"type\":\"ccm:io\"}}")
String query;

SearchServiceElastic searchServiceElastic = new SearchServiceElastic(ApplicationInfoList.getHomeRepository().getAppId());
Expand All @@ -50,29 +52,32 @@ public class FixElasticSearchDeletedNodes extends AbstractJob{
NodeService nodeService = serviceRegistry.getNodeService();
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
execute = Boolean.parseBoolean( (String) jobExecutionContext.getJobDetail().getJobDataMap().get("execute"));
execute = (Boolean)jobExecutionContext.getJobDetail().getJobDataMap().get("execute");
query = (String)jobExecutionContext.getJobDetail().getJobDataMap().get("query");
query = StringEscapeUtils.unescapeJson(query);
logger.info("query:" + query);

AuthenticationUtil.runAsSystem(()->{
try {
ObjectBuilder<Query> queryBuilder = (query == null) ? new Query.Builder().matchAll(x -> x) : new Query.Builder().wrapper(wrapper -> wrapper.query(query));
search(queryBuilder, new DeletedNodesHandler());
} catch (IOException e) {
logger.error(e.getMessage(),e);
}
return null;
});
AuthenticationUtil.runAsSystem(()->{
try {
Query elQuery = (query == null) ? new Query.Builder().bool(new BoolQuery.Builder().must(q -> q.matchAll(all -> all)).build()).build() : new Query.Builder().wrapper(new ReadableWrapperQueryBuilder(query).build()).build();

search(elQuery, new DeletedNodesHandler());
} catch (IOException e) {
logger.error(e.getMessage(),e);
}
return null;
});
}

private void search(ObjectBuilder<Query> queryBuilder, SearchResultHandler searchResultHandler) throws IOException{
private void search(Query query, SearchResultHandler searchResultHandler) throws IOException{
logger.info("search with handler: "+searchResultHandler.getClass().getName());

Time scroll = Time.of(time->time.time("4h"));
ResponseBody<Map> response = null;
int page = 0;
do{
if(response == null) {
response = search(SearchServiceElastic.WORKSPACE_INDEX, queryBuilder, scroll);
response = search(SearchServiceElastic.WORKSPACE_INDEX, query, scroll);
}else {
response = scroll(scroll,response.scrollId());
}
Expand All @@ -92,12 +97,13 @@ private void search(ObjectBuilder<Query> queryBuilder, SearchResultHandler searc



private SearchResponse<Map> search(String index, ObjectBuilder<Query> queryBuilder, Time scroll) throws IOException {
private SearchResponse<Map> search(String index, Query query, Time scroll) throws IOException {
return searchServiceElastic.searchNative(SearchRequest.of(req->req
.index(index)
.size(pageSize)
.source(src->src.filter(filter->filter.excludes("preview")))
.scroll(scroll)));
.scroll(scroll)
.query(query)));
}

private ScrollResponse<Map> scroll(Time scroll, String scrollId) throws IOException {
Expand Down Expand Up @@ -162,7 +168,7 @@ public void handleSearchHit(Hit<Map> searchHit) throws IOException {
private void syncNestedCollections(String dbid) throws IOException {
ObjectBuilder<Query> ioCollectionQuery = new Query.Builder().term(term -> term.field("collections.dbid").value(dbid));

search(ioCollectionQuery, searchHit -> {
search(ioCollectionQuery.build(), searchHit -> {
List<Map<String, Object>> collections = (List<Map<String, Object>>) searchHit.source().get("collections");

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public String formatDate(Long time,Integer dateStyle, Integer timeStyle){
}else{
df = DateFormat.getDateTimeInstance(dateStyle, timeStyle, new Locale(splittedLocale[0],splittedLocale[1]));
}

df.setTimeZone(TimeZone.getTimeZone("CET"));


try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<mat-select
#select
[formControl]="formControl"
[placeholder]="widget.definition.placeholder"
[placeholder]="
showBulkMixedValues() ? ('MDS.DIFFERENT_VALUES' | translate) : widget.definition.placeholder
"
esOnAttributeChange="aria-activedescendant"
(attributeChange)="onActiveDescendantChanges($event)"
(blur)="onBlur.emit()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export class MdsEditorWidgetSelectComponent extends MdsEditorWidgetBase implemen
this.matSelect.open();
}

showBulkMixedValues() {
return this.widget.getInitialValues() && this.mdsEditorInstance.editorBulkMode?.isBulk;
}
async ngOnInit() {
this.formControl = new UntypedFormControl(null, this.getStandardValidators());
const initialValue = (await this.widget.getInitalValuesAsync()).jointValues[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export class AuthoritySearchInputComponent {
label: 'WORKSPACE.INVITE_GLOBAL_RESULTS',
values: this.convertData(authorities),
})),
catchError(() => of({ values: [] } as SuggestionGroup)),
),
);
}
Expand Down

0 comments on commit 412e93c

Please sign in to comment.