@Override public Long insertTimelineChunk(final TimelineChunk timelineChunk, final InternalCallContext context) throws UnableToObtainConnectionException, CallbackFailedException { final Long result = delegate.inTransaction(new Transaction<Long, TimelineSqlDao>() { @Override public Long inTransaction(final TimelineSqlDao transactional, final TransactionStatus status) throws Exception { transactional.insertTimelineChunk(timelineChunk, context); final long timelineChunkId = transactional.getLastInsertedRecordId(context); return timelineChunkId; } }); return result; }
@Override public synchronized int getOrAddMetric(final Integer eventCategoryId, final String metric, final InternalCallContext context) throws UnableToObtainConnectionException, CallbackFailedException { final Integer result = delegate.inTransaction(new Transaction<Integer, TimelineSqlDao>() { @Override public Integer inTransaction(final TimelineSqlDao transactional, final TransactionStatus status) throws Exception { return getOrAddWithRetry(new Callable<Integer>() { @Override public Integer call() throws Exception { Integer metricId = transactional.getMetricRecordId(eventCategoryId, metric, context); if (metricId == null) { transactional.addMetric(eventCategoryId, metric, context); metricId = transactional.getMetricRecordId(eventCategoryId, metric, context); } return metricId; } }); } }); return result; }
@Override public int getOrAddSource(final String source, final InternalCallContext context) throws UnableToObtainConnectionException, CallbackFailedException { final Integer result = delegate.inTransaction(new Transaction<Integer, TimelineSqlDao>() { @Override public Integer inTransaction(final TimelineSqlDao transactional, final TransactionStatus status) throws Exception { return getOrAddWithRetry(new Callable<Integer>() { @Override public Integer call() throws Exception { Integer sourceId = transactional.getSourceRecordId(source, context); if (sourceId == null) { transactional.addSource(source, context); sourceId = transactional.getSourceRecordId(source, context); } return sourceId; } }); } }); return result; }
@Override public int getOrAddEventCategory(final String eventCategory, final InternalCallContext context) throws UnableToObtainConnectionException, CallbackFailedException { final Integer result = delegate.inTransaction(new Transaction<Integer, TimelineSqlDao>() { @Override public Integer inTransaction(final TimelineSqlDao transactional, final TransactionStatus status) throws Exception { return getOrAddWithRetry(new Callable<Integer>() { @Override public Integer call() throws Exception { Integer eventCategoryId = transactional.getCategoryRecordId(eventCategory, context); if (eventCategoryId == null) { transactional.addCategory(eventCategory, context); eventCategoryId = transactional.getCategoryRecordId(eventCategory, context); } return eventCategoryId; } }); } }); return result; }