Commit a2b5f6fe authored by Matija Obreza's avatar Matija Obreza

Extended bsh controller to allow for GLIS update

parent d305d136
...@@ -29,8 +29,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -29,8 +29,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import org.genesys.glis.v1.api.GenesysApi; import org.genesys.glis.v1.api.GenesysApi;
import org.genesys2.server.service.AccessionService;
import org.genesys2.server.service.GenesysFilterService; import org.genesys2.server.service.GenesysFilterService;
import org.genesys2.server.service.GenesysService; import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.worker.AccessionModifiedAspect;
import org.genesys2.server.service.worker.AccessionProcessor;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
...@@ -71,6 +74,15 @@ public class BeanshellController implements InitializingBean { ...@@ -71,6 +74,15 @@ public class BeanshellController implements InitializingBean {
@Autowired @Autowired
private GenesysApi glisGenesys; private GenesysApi glisGenesys;
@Autowired
private AccessionProcessor accessionProcessor;
@Autowired
private AccessionModifiedAspect accessionsModifiedAspect;
@Autowired
private AccessionService accessionService;
@PersistenceContext @PersistenceContext
private EntityManager entityManager; private EntityManager entityManager;
...@@ -91,6 +103,9 @@ public class BeanshellController implements InitializingBean { ...@@ -91,6 +103,9 @@ public class BeanshellController implements InitializingBean {
this.exposedBeans.put("genesysService", genesysService); this.exposedBeans.put("genesysService", genesysService);
this.exposedBeans.put("filterService", filterService); this.exposedBeans.put("filterService", filterService);
this.exposedBeans.put("glisGenesys", glisGenesys); this.exposedBeans.put("glisGenesys", glisGenesys);
this.exposedBeans.put("accessionService", accessionService);
this.exposedBeans.put("accessionsModifiedAspect", accessionsModifiedAspect);
this.exposedBeans.put("accessionProcessor", accessionProcessor);
this.exposedBeans.put("entityManager", entityManager); this.exposedBeans.put("entityManager", entityManager);
this.exposedBeans.put("jdbc", jdbcTemplate); this.exposedBeans.put("jdbc", jdbcTemplate);
} }
......
...@@ -85,10 +85,10 @@ public class AccessionModifiedAspect implements InitializingBean { ...@@ -85,10 +85,10 @@ public class AccessionModifiedAspect implements InitializingBean {
} }
/** The Constant LOG. */ /** The Constant LOG. */
public static final Logger LOG = LoggerFactory.getLogger(AccessionModifiedAspect.class); private static final Logger LOG = LoggerFactory.getLogger(AccessionModifiedAspect.class);
@After(value = "execution(* org.genesys2.server.persistence.AccessionRepository.save(*)) && args(arg)") @After(value = "execution(* org.genesys2.server.persistence.AccessionRepository.save(*)) && args(arg)")
public void afterPersistAccession(JoinPoint joinPoint, Object arg) throws Throwable { protected void afterPersistAccession(JoinPoint joinPoint, Object arg) throws Throwable {
StopWatch stopWatch=StopWatch.createStarted(); StopWatch stopWatch=StopWatch.createStarted();
LOG.trace("After persist accession(s): {}", arg); LOG.trace("After persist accession(s): {}", arg);
...@@ -103,6 +103,16 @@ public class AccessionModifiedAspect implements InitializingBean { ...@@ -103,6 +103,16 @@ public class AccessionModifiedAspect implements InitializingBean {
LOG.debug("Persist notification for 1 accession took {}ms", stopWatch.getTime(TimeUnit.MILLISECONDS)); LOG.debug("Persist notification for 1 accession took {}ms", stopWatch.getTime(TimeUnit.MILLISECONDS));
} }
} }
/**
* Fake persist accession records to trigger listeners.
*
* @param accessions the accessions
*/
public void fakePersist(Collection<Accession> accessions) {
LOG.info("Fake-persisting {} accessions", accessions.size());
handlePersist(accessions);
}
private void handlePersist(Collection<Accession> accessions) { private void handlePersist(Collection<Accession> accessions) {
if (CollectionUtils.isEmpty(accessions)) { if (CollectionUtils.isEmpty(accessions)) {
...@@ -113,7 +123,7 @@ public class AccessionModifiedAspect implements InitializingBean { ...@@ -113,7 +123,7 @@ public class AccessionModifiedAspect implements InitializingBean {
} }
@Before(value = "execution(* org.genesys2.server.persistence.AccessionRepository.delete(*)) && args(arg)") @Before(value = "execution(* org.genesys2.server.persistence.AccessionRepository.delete(*)) && args(arg)")
public void beforeDeleteAccession(JoinPoint joinPoint, Object arg) throws Throwable { protected void beforeDeleteAccession(JoinPoint joinPoint, Object arg) throws Throwable {
StopWatch stopWatch=StopWatch.createStarted(); StopWatch stopWatch=StopWatch.createStarted();
LOG.trace("Before delete accession(s): {}", arg); LOG.trace("Before delete accession(s): {}", arg);
......
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