use of org.mycore.backend.jpa.MCRStreamQuery in project mycore by MyCoRe-Org.
the class MCRIFSCommands method moveContentToNewStore.
private static List<String> moveContentToNewStore(String source_store, String target_store, String select_key, String select_value) {
// check stores
MCRContentStore from_store = MCRContentStoreFactory.getStore(source_store);
@SuppressWarnings("unused") MCRContentStore to_store = MCRContentStoreFactory.getStore(target_store);
EntityManager em = MCREntityManagerProvider.getCurrentEntityManager();
MCRStreamQuery<MCRFSNODES> streamQuery = MCRStreamQuery.getInstance(em, "from MCRFSNODES where storeid=:storeid and " + select_key + "=:selectValue order by owner", MCRFSNODES.class).setParameter("storeid", from_store.getID()).setParameter("selectValue", select_value);
try (Stream<MCRFSNODES> resultStream = streamQuery.getResultStream()) {
return resultStream.peek(em::detach).map(MCRFSNODES::getId).map(ifsId -> String.format(Locale.ROOT, "move ifs node %s to store %s", ifsId, target_store)).collect(Collectors.toList());
}
}
Aggregations