@Override public void removeTopiaEntityListener(TopiaEntityListener listener) { topiaFiresSupport.removeTopiaEntityListener(getEntityClass(), listener); }
protected HqlAndParametersBuilder<E> newHqlAndParametersBuilder() { HqlAndParametersBuilder<E> result = new HqlAndParametersBuilder<E>(getEntityClass()); return result; }
@Override public void addTopiaEntityVetoable(TopiaEntityVetoable vetoable) { topiaFiresSupport.addTopiaEntityVetoable(getEntityClass(), vetoable); }
@Override public void addTopiaEntityListener(TopiaEntityListener listener) { topiaFiresSupport.addTopiaEntityListener(getEntityClass(), listener); }
@Override public void removeTopiaEntityVetoable(TopiaEntityVetoable vetoable) { topiaFiresSupport.removeTopiaEntityVetoable(getEntityClass(), vetoable); }
/** * When AbstractTopiaContext create the TopiaDAOHibernate, it must call this * method just after. * * @param topiaJpaSupport FIXME * @param topiaHibernateSupport FIXME * @param topiaSqlSupport FIXME * @param topiaIdFactory FIXME * @param topiaFiresSupport FIXME * @param topiaDaoSupplier FIXME */ public void init( TopiaJpaSupport topiaJpaSupport, TopiaHibernateSupport topiaHibernateSupport, TopiaSqlSupport topiaSqlSupport, TopiaIdFactory topiaIdFactory, TopiaFiresSupport topiaFiresSupport, TopiaDaoSupplier topiaDaoSupplier) { if (log.isDebugEnabled()) { log.debug("init dao for " + getEntityClass()); } this.topiaJpaSupport = topiaJpaSupport; this.topiaHibernateSupport = topiaHibernateSupport; this.topiaSqlSupport = topiaSqlSupport; this.topiaIdFactory = topiaIdFactory; this.topiaFiresSupport = topiaFiresSupport; this.topiaDaoSupplier = topiaDaoSupplier; }
@Override @Deprecated public E findByTopiaId(String topiaId) throws TopiaNoResultException { // AThimel 30/10/13 Not using findUnique to avoid querying several elements (cf. findUnique implementation) try { E result = forTopiaIdEquals(topiaId).findAny(); return result; } catch (TopiaNoResultException tnre) { if (log.isWarnEnabled()) { String message = String.format("Unexpected behavior : entity '%s' not found with topiaId='%s'", getEntityClass().getName(), topiaId); log.warn(message); } throw tnre; } }
@Override public E newInstance() { if (log.isTraceEnabled()) { log.trace("entityClass = " + getEntityClass()); } Class<E> implementation = (Class<E>) getTopiaEntityEnum().getImplementation(); try { E newInstance = implementation.newInstance(); TopiaHibernateEventListener.attachContext(newInstance, topiaDaoSupplier, topiaFiresSupport); return newInstance; } catch (InstantiationException e) { throw new TopiaException( "Impossible de trouver ou d'instancier la classe " + implementation); } catch (IllegalAccessException e) { throw new TopiaException( "Impossible de trouver ou d'instancier la classe " + implementation); } }
@Override public E create(E entity) { // first set topiaId if (StringUtils.isBlank(entity.getTopiaId())) { // only set id if not already on String topiaId = topiaIdFactory.newTopiaId(getEntityClass(), entity); entity.setTopiaId(topiaId); } if (entity instanceof TopiaEntityContextable) { TopiaEntityContextable contextable = (TopiaEntityContextable) entity; contextable.setTopiaDaoSupplier(this.topiaDaoSupplier); } // save entity topiaJpaSupport.save(entity); topiaFiresSupport.notifyEntityCreated(entity); return entity; }