use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity in project joynr by bmwcarit.
the class BounceProxyDatabase method updateBounceProxy.
@Override
public void updateBounceProxy(BounceProxyRecord bpRecord) throws IllegalArgumentException {
logger.trace("updateBounceProxy(bpid={})", bpRecord.getBounceProxyId());
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
BounceProxyEntity bpEntity = new BounceProxyEntity(bpRecord);
bpEntity.setFreshness(timestampProvider.getCurrentTime());
em.merge(bpEntity);
tx.commit();
} catch (RuntimeException ex) {
logger.error("Bounce proxy {} could not be updated. error: {}", bpRecord.getBounceProxyId(), ex.getMessage());
if (tx != null && tx.isActive())
tx.rollback();
throw ex;
}
}
use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity in project joynr by bmwcarit.
the class BounceProxyDatabase method getBounceProxyEntityList.
private List<BounceProxyEntity> getBounceProxyEntityList(String sqlWhereClause) {
String query;
if (sqlWhereClause == null) {
query = String.format("SELECT x FROM %s x", BounceProxyEntity.class.getSimpleName());
} else {
query = String.format("SELECT x FROM %s x WHERE %s", BounceProxyEntity.class.getSimpleName(), sqlWhereClause);
}
EntityManager em = emf.createEntityManager();
Query getBounceProxiesQuery = em.createQuery(query);
@SuppressWarnings("unchecked") List<BounceProxyEntity> queryResults = getBounceProxiesQuery.getResultList();
return queryResults;
}
use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity in project joynr by bmwcarit.
the class BounceProxyDatabase method getAssignableBounceProxies.
@Override
public List<BounceProxyRecord> getAssignableBounceProxies() {
logger.trace("getAssignableBounceProxies()");
List<BounceProxyRecord> bounceProxyList = new LinkedList<BounceProxyRecord>();
for (BounceProxyEntity entity : getBounceProxyEntityList(getSqlWhereClauseForAssignableBounceProxies())) {
bounceProxyList.add(entity.convertToBounceProxyRecord());
}
logger.debug("found {} assignable bounce proxies", bounceProxyList.size());
return bounceProxyList;
}
Aggregations