Skip to content

Commit

Permalink
wip make test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
cmangeat committed Feb 7, 2024
1 parent 375fe52 commit 0a91198
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@

package org.fao.geonet.kernel.datamanager.base;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
@@ -33,6 +35,7 @@
import jeeves.transaction.TransactionTask;
import jeeves.xlink.Processor;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.search.SearchResponse;
import org.fao.geonet.ApplicationContextHolder;
import org.fao.geonet.constants.Edit;
import org.fao.geonet.constants.Geonet;
@@ -747,6 +750,32 @@ public synchronized AbstractMetadata updateMetadata(final ServiceContext context
getSearchManager().delete(String.format("+uuid:\"%s\"", uuidBeforeUfo));
}
metadataIndexer.indexMetadata(metadataId, true, indexingMode);

if (metadata.getDataInfo().getType() == MetadataType.SUB_TEMPLATE) {
ObjectMapper objectMapper = new ObjectMapper();

JsonNode query = objectMapper.createObjectNode()
.set("nested", objectMapper.createObjectNode()
.put("path", "contactForResource")
.set("query", objectMapper.createObjectNode()
.set("bool", objectMapper.createObjectNode().set("must", objectMapper.createArrayNode()
.add(objectMapper.createObjectNode().set("match", objectMapper.createObjectNode().put("xlink", String.format("%s", metadata.getUuid()))))
.add(objectMapper.createObjectNode().set("match", objectMapper.createObjectNode().put("contactForResource.individual", "babar"))))))
);

SearchResponse reponse = this.searchManager.query(query, Collections.emptySet(), 0, 10, null);

/*
Element parameters = new Element(Jeeves.Elem.REQUEST);
parameters.addContent(new Element(Geonet.SearchResult.BUILD_SUMMARY).setText("false"));
parameters.addContent(new Element(SearchParameter.ISADMIN).addContent("true"));
parameters.addContent(new Element(SearchParameter.ISTEMPLATE).addContent("y or n"));
for (Integer id: result.keySet()) {
IndexingList list = context.getBean(IndexingList.class);
list.add(id);
}
*/
}
}
}

0 comments on commit 0a91198

Please sign in to comment.