Commit 31895628 authored by Maxym Borodenko's avatar Maxym Borodenko
Browse files

Admin action: relink dataset accessions

parent 2c057440
...@@ -28,6 +28,7 @@ import javax.persistence.PersistenceContext; ...@@ -28,6 +28,7 @@ import javax.persistence.PersistenceContext;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.lang.time.StopWatch; import org.apache.commons.lang.time.StopWatch;
import org.genesys.catalog.service.DatasetService;
import org.genesys2.server.persistence.AccessionRepository; import org.genesys2.server.persistence.AccessionRepository;
import org.genesys2.server.service.ContentService; import org.genesys2.server.service.ContentService;
import org.genesys2.server.service.CountryNamesUpdater; import org.genesys2.server.service.CountryNamesUpdater;
...@@ -94,6 +95,9 @@ public class AdminController { ...@@ -94,6 +95,9 @@ public class AdminController {
@Autowired @Autowired
private CropService cropService; private CropService cropService;
@Autowired
private DatasetService datasetService;
@PersistenceContext @PersistenceContext
private EntityManager entityManager; private EntityManager entityManager;
...@@ -154,6 +158,12 @@ public class AdminController { ...@@ -154,6 +158,12 @@ public class AdminController {
return "redirect:/admin/"; return "redirect:/admin/";
} }
@RequestMapping(method = RequestMethod.POST, value = "/relinkDatasetAccessions")
public String rematchDatasetAccessions() {
datasetService.rematchDatasetAccessions();
return "redirect:/admin/";
}
@RequestMapping(method = RequestMethod.POST, value = "/updateSGSV") @RequestMapping(method = RequestMethod.POST, value = "/updateSGSV")
public String updateSGSV() { public String updateSGSV() {
sgsvUpdater.updateSGSV(); sgsvUpdater.updateSGSV();
......
...@@ -30,7 +30,6 @@ import org.genesys.catalog.persistence.PartnerRepository; ...@@ -30,7 +30,6 @@ import org.genesys.catalog.persistence.PartnerRepository;
import org.genesys.catalog.persistence.dataset.DatasetRepository; import org.genesys.catalog.persistence.dataset.DatasetRepository;
import org.genesys.catalog.persistence.traits.DescriptorListRepository; import org.genesys.catalog.persistence.traits.DescriptorListRepository;
import org.genesys.catalog.persistence.traits.DescriptorRepository; import org.genesys.catalog.persistence.traits.DescriptorRepository;
import org.genesys.catalog.service.DatasetService;
import org.genesys2.server.model.UserRole; import org.genesys2.server.model.UserRole;
import org.genesys2.server.model.impl.User; import org.genesys2.server.model.impl.User;
import org.genesys2.server.persistence.UserRepository; import org.genesys2.server.persistence.UserRepository;
...@@ -111,11 +110,9 @@ public class ApplicationStartup implements InitializingBean, ApplicationListener ...@@ -111,11 +110,9 @@ public class ApplicationStartup implements InitializingBean, ApplicationListener
*/ */
@Override @Override
public void onApplicationEvent(ContextRefreshedEvent event) { public void onApplicationEvent(ContextRefreshedEvent event) {
rematchDatasetAccessions();
aclService.cleanupAcl(); aclService.cleanupAcl();
if (reindexElastic) { if (reindexElastic) {
reindexElasticsearch(); reindexElasticsearch();
} }
} }
...@@ -133,7 +130,6 @@ public class ApplicationStartup implements InitializingBean, ApplicationListener ...@@ -133,7 +130,6 @@ public class ApplicationStartup implements InitializingBean, ApplicationListener
ensure1OAuthClient(); ensure1OAuthClient();
} }
@Autowired @Autowired
private PasswordEncoder passwordEncoder; private PasswordEncoder passwordEncoder;
...@@ -205,8 +201,6 @@ public class ApplicationStartup implements InitializingBean, ApplicationListener ...@@ -205,8 +201,6 @@ public class ApplicationStartup implements InitializingBean, ApplicationListener
// aclService.removeAclAwareModel(descriptor)); // aclService.removeAclAwareModel(descriptor));
descriptorRepository.findAll().stream().forEach(descriptor -> aclService.addCreatorPermissions(descriptor)); descriptorRepository.findAll().stream().forEach(descriptor -> aclService.addCreatorPermissions(descriptor));
} }
@Autowired @Autowired
private ElasticsearchService elasticsearch; private ElasticsearchService elasticsearch;
...@@ -217,12 +211,4 @@ public class ApplicationStartup implements InitializingBean, ApplicationListener ...@@ -217,12 +211,4 @@ public class ApplicationStartup implements InitializingBean, ApplicationListener
private void reindexElasticsearch() { private void reindexElasticsearch() {
elasticsearch.reindexAll(); elasticsearch.reindexAll();
} }
@Autowired
private DatasetService datasetService;
private void rematchDatasetAccessions() {
datasetService.rematchDatasetAccessions();
}
} }
...@@ -87,6 +87,14 @@ ...@@ -87,6 +87,14 @@
<!-- CSRF protection --> <!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" /> <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form> </form>
<h3>Dataset</h3>
<form method="post" action="<c:url value="/admin/relinkDatasetAccessions" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Relink dataset accessions" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>C&amp;E</h3> <h3>C&amp;E</h3>
<form method="post" action="<c:url value="/admin/refreshMetadataMethods" />"> <form method="post" action="<c:url value="/admin/refreshMetadataMethods" />">
<input type="submit" class="btn btn-default" class="btn btn-default" value="Recalculate metadata methods" /> <input type="submit" class="btn btn-default" class="btn btn-default" value="Recalculate metadata methods" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment