Skip to content

Instantly share code, notes, and snippets.

InputStream is = loadReportTemplate();
HashMap datasets = new HashMap();
datasets.put("APP_CONTEXT_KEY_MOCKCOMPANYDATASET", companyRepository.findAll().iterate());
// start enginee
EngineConfig config = new EngineConfig();
config.setEngineHome(System.getProperty("java.io.tmpdir"));
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
@l0co
l0co / dhs-frontend.xml
Last active August 29, 2015 14:23
Distributed Hibernate Search - Frontend app config
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
@l0co
l0co / dhs-integration-server.xml
Last active August 29, 2015 14:23
Distributed Hibernate Search - Integration server config
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Hibernate section -->
@l0co
l0co / RemoteHibernateSearchController.java
Last active December 28, 2016 22:53
RemoteHibernateSearchController
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.search.backend.impl.jms.AbstractJMSHibernateSearchController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.jms.MessageListener;
@Service
public class RemoteHibernateSearchController extends AbstractJMSHibernateSearchController implements MessageListener {
@l0co
l0co / AMQBackendQueueProcessor.java
Last active December 28, 2016 22:53
AMQBackendQueueProcessor
import org.hibernate.search.backend.impl.jms.JmsBackendQueueProcessor;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import java.util.Properties;
/**
* A bridge between {@link JmsBackendQueueProcessor} and spring-managed AMQ beans.
@l0co
l0co / ApplicationContextProvider.java
Last active December 28, 2016 22:53
ApplicationContextProvider
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class ApplicationContextProvider implements ApplicationContextAware {
protected static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
@l0co
l0co / angular-equals.js
Created July 18, 2015 09:52
Angular hard limit recursion in equals()
var currentEqualsLevel = 0;
var maxEqualsLevel = 10;
function equals(o1, o2) {
if (currentEqualsLevel>=maxEqualsLevel)
return true; // we consider objects equal to this level
if (o1 === o2) return true;
if (o1 === null || o2 === null) return false;
@l0co
l0co / modal.html
Last active August 29, 2015 14:25
Modal windows available by URL binding in AngularJS with ui-bootstrap and ui-router
<html>
<body ui-view="main">
</body>
</html>
@l0co
l0co / PostgresDateTrunc.java
Last active August 28, 2015 18:41
Statistics queries with time range for PostgreSQL and Hibernate - PostgresDateTrunc
public enum PostgresDateTrunc {
second,
minute,
hour,
day,
week,
month,
quarter,
year;
@l0co
l0co / GenericRepository.java
Last active August 28, 2015 18:39
Statistics queries with time range for PostgreSQL and Hibernate - GenericRepository
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.ProjectionList;
import org.hibernate.criterion.Projections;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;
import java.util.List;
public class GenericRepository {