Codota Logo
EntitySqlDaoWrapperFactory
Code IndexAdd Codota to your IDE (free)

How to use
EntitySqlDaoWrapperFactory
in
org.killbill.billing.util.entity.dao

Best Java code snippets using org.killbill.billing.util.entity.dao.EntitySqlDaoWrapperFactory (Showing top 20 results out of 315)

Refine searchRefine arrow

  • UUID
  • InternalCallContext
  • Handle
  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: killbill/killbill

  @Override
  public List<SubscriptionBaseBundle> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final List<SubscriptionBundleModelDao> models = entitySqlDaoWrapperFactory.become(BundleSqlDao.class).getBundleFromAccount(accountId.toString(), context);
    return new ArrayList<SubscriptionBaseBundle>(Collections2.transform(models, new Function<SubscriptionBundleModelDao, SubscriptionBaseBundle>() {
      @Override
      public SubscriptionBaseBundle apply(@Nullable final SubscriptionBundleModelDao input) {
        return SubscriptionBundleModelDao.toSubscriptionBundle(input);
      }
    }));
  }
});
origin: killbill/killbill

@VisibleForTesting
<T extends OverdueCheckNotificationKey> Iterable<NotificationEventWithMetadata<T>> getFutureNotificationsForAccountInTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory,
                                                                 final NotificationQueue checkOverdueQueue,
                                                                 final Class<T> clazz,
                                                                 final InternalCallContext context) {
  return checkOverdueQueue.getFutureNotificationFromTransactionForSearchKeys(context.getAccountRecordId(), context.getTenantRecordId(), entitySqlDaoWrapperFactory.getHandle().getConnection());
}
origin: killbill/killbill

  @Override
  public ReturnType inTransaction(final EntitySqlDao<M, E> transactionalSqlDao, final TransactionStatus status) throws Exception {
    final EntitySqlDaoWrapperFactory factoryEntitySqlDao = new EntitySqlDaoWrapperFactory(h, clock, cacheControllerDispatcher, internalCallContextFactory);
    return entitySqlDaoTransactionWrapper.inTransaction(factoryEntitySqlDao);
  }
}
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws EntityPersistenceException, EventBusException {
    final AccountSqlDao transactional = entitySqlDaoWrapperFactory.become(AccountSqlDao.class);
    final AccountModelDao currentAccount = transactional.getById(accountId.toString(), context);
    if (currentAccount == null) {
      throw new EntityPersistenceException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_ID, accountId);
    }
    // Check if an update is really needed. If not, bail early to avoid sending an extra event on the bus
    if ((currentAccount.getPaymentMethodId() == null && paymentMethodId == null) ||
      (currentAccount.getPaymentMethodId() != null && currentAccount.getPaymentMethodId().equals(paymentMethodId))) {
      return null;
    }
    final String thePaymentMethodId = paymentMethodId != null ? paymentMethodId.toString() : null;
    final AccountModelDao account = (AccountModelDao) transactional.updatePaymentMethod(accountId.toString(), thePaymentMethodId, context);
    final AccountChangeInternalEvent changeEvent = new DefaultAccountChangeEvent(accountId, currentAccount, account,
                                           context.getAccountRecordId(),
                                           context.getTenantRecordId(),
                                           context.getUserToken(),
                                           context.getCreatedDate());
    try {
      eventBus.postFromTransaction(changeEvent, entitySqlDaoWrapperFactory.getHandle().getConnection());
    } catch (final EventBusException e) {
      log.warn("Failed to post account change event for accountId='{}'", accountId, e);
    }
    return null;
  }
});
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final SubscriptionSqlDao transactionalDao = entitySqlDaoWrapperFactory.become(SubscriptionSqlDao.class);
    transactionalDao.updateChargedThroughDate(subscription.getId().toString(), ctd, contextWithUpdatedDate);
    final BundleSqlDao bundleSqlDao = entitySqlDaoWrapperFactory.become(BundleSqlDao.class);
    final String bundleId = subscription.getBundleId().toString();
    bundleSqlDao.updateBundleLastSysTime(bundleId, context.getCreatedDate().toDate(), contextWithUpdatedDate);
    return null;
  }
});
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final TenantKVModelDao tenantKVModelDao = new TenantKVModelDao(UUIDs.randomUUID(), context.getCreatedDate(), context.getUpdatedDate(), key, value);
    final TenantKVSqlDao tenantKVSqlDao = entitySqlDaoWrapperFactory.become(TenantKVSqlDao.class);
    // Retrieve all values for key ordered with recordId (last at the end)
    final List<TenantKVModelDao> tenantKV = tenantKVSqlDao.getTenantValueForKey(key, context);
    final String id;
    final TenantKVModelDao rehydrated;
    if (!tenantKV.isEmpty()) {
      id = tenantKV.get(tenantKV.size() - 1).getId().toString();
      rehydrated = (TenantKVModelDao) tenantKVSqlDao.updateTenantValueKey(id, value, context);
    } else {
      id = tenantKVModelDao.getId().toString();
      rehydrated = createAndRefresh(tenantKVSqlDao, tenantKVModelDao, context);
    }
    broadcastConfigurationChangeFromTransaction(rehydrated.getRecordId(), key, entitySqlDaoWrapperFactory, context);
    return null;
  }
});
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final TagDefinitionModelDao tagDefinition = getTagDefinitionFromTransaction(tagDefinitionId, entitySqlDaoWrapperFactory, context);
    final TagSqlDao transactional = entitySqlDaoWrapperFactory.become(TagSqlDao.class);
    final List<TagModelDao> tags = transactional.getTagsForObject(objectId, objectType, context);
    TagModelDao tag = null;
    for (final TagModelDao cur : tags) {
      if (cur.getTagDefinitionId().equals(tagDefinitionId)) {
        tag = cur;
        break;
      }
    }
    if (tag == null) {
      throw new TagApiException(ErrorCode.TAG_DOES_NOT_EXIST, tagDefinition.getName());
    }
    // Delete the tag
    transactional.markTagAsDeleted(tag.getId().toString(), context);
    postBusEventFromTransaction(tag, tag, ChangeType.DELETE, entitySqlDaoWrapperFactory, context);
    return null;
  }
});
origin: org.kill-bill.billing/killbill-invoice

final Iterable<NotificationEventWithMetadata<ParentInvoiceCommitmentNotificationKey>> futureNotifications = commitInvoiceQueue.getFutureNotificationFromTransactionForSearchKeys(internalCallContext.getAccountRecordId(), internalCallContext.getTenantRecordId(), entitySqlDaoWrapperFactory.getHandle().getConnection());
  while (iterator.hasNext()) {
    final NotificationEventWithMetadata<ParentInvoiceCommitmentNotificationKey> input = iterator.next();
    final LocalDate notificationEffectiveLocaleDate = internalCallContext.toLocalDate(futureNotificationTime);
    final LocalDate eventEffectiveLocaleDate = internalCallContext.toLocalDate(input.getEffectiveDate());
    if (notificationEffectiveLocaleDate.compareTo(eventEffectiveLocaleDate) == 0 && input.getEvent().getUuidKey().equals(invoiceId)) {
      existingFutureNotificationWithSameDateAndInvoiceId = true;
  log.info("Queuing parent invoice commitment notification at {} for invoiceId {}", futureNotificationTime.toString(), invoiceId.toString());
  commitInvoiceQueue.recordFutureNotificationFromTransaction(entitySqlDaoWrapperFactory.getHandle().getConnection(), futureNotificationTime,
                               new ParentInvoiceCommitmentNotificationKey(invoiceId), internalCallContext.getUserToken(),
                               internalCallContext.getAccountRecordId(), internalCallContext.getTenantRecordId());
} else if (log.isDebugEnabled()) {
  log.debug("*********************   SKIPPING Queuing parent invoice commitment notification at {} for invoiceId {} *******************", futureNotificationTime.toString(), invoiceId.toString());
origin: org.kill-bill.billing/killbill-invoice

@Override
public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
  final InvoicePaymentSqlDao transactional = entitySqlDaoWrapperFactory.become(InvoicePaymentSqlDao.class);
    final List<InvoicePaymentModelDao> invoicePayments = transactional.getAllPaymentsForInvoiceIncludedInit(invoicePayment.getInvoiceId().toString(), context);
    final InvoicePaymentModelDao existingAttempt = Iterables.tryFind(invoicePayments, new Predicate<InvoicePaymentModelDao>() {
      @Override
    } else {
      transactional.updateAttempt(existingAttempt.getRecordId(),
                    invoicePayment.getPaymentId().toString(),
                    invoicePayment.getPaymentDate().toDate(),
                    invoicePayment.getAmount(),
    final UUID accountId = nonEntityDao.retrieveIdFromObjectInTransaction(context.getAccountRecordId(), ObjectType.ACCOUNT, objectIdCacheController, entitySqlDaoWrapperFactory.getHandle());
    notifyBusOfInvoicePayment(entitySqlDaoWrapperFactory, invoicePayment, accountId, context.getUserToken(), context);
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final Iterable<NotificationEventWithMetadata<T>> futureNotifications = getFutureNotificationsForAccountInTransaction(entitySqlDaoWrapperFactory, checkOverdueQueue,
                                                               clazz, context);
    final Iterator<NotificationEventWithMetadata<T>> iterator = futureNotifications.iterator();
    try {
      while (iterator.hasNext()) {
        final NotificationEventWithMetadata<T> notification = iterator.next();
        checkOverdueQueue.removeNotificationFromTransaction(entitySqlDaoWrapperFactory.getHandle().getConnection(), notification.getRecordId());
      }
    } finally {
      // Go through all results to close the connection
      while (iterator.hasNext()) {
        iterator.next();
      }
    }
    return null;
  }
});
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final TenantKVModelDao tenantKVModelDao = new TenantKVModelDao(UUIDs.randomUUID(), context.getCreatedDate(), context.getUpdatedDate(), key, value);
    final TenantKVSqlDao tenantKVSqlDao = entitySqlDaoWrapperFactory.become(TenantKVSqlDao.class);
    if (uniqueKey) {
      deleteFromTransaction(key, entitySqlDaoWrapperFactory, context);
    }
    final TenantKVModelDao rehydrated = createAndRefresh(tenantKVSqlDao, tenantKVModelDao, context);
    broadcastConfigurationChangeFromTransaction(rehydrated.getRecordId(), key, entitySqlDaoWrapperFactory, context);
    return null;
  }
});
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final SubscriptionEventSqlDao transactional = entitySqlDaoWrapperFactory.become(SubscriptionEventSqlDao.class);
    createAndRefresh(transactional, new SubscriptionEventModelDao(bcdEvent), context);
    // Notify the Bus
    notifyBusOfRequestedChange(entitySqlDaoWrapperFactory, subscription, bcdEvent, SubscriptionBaseTransitionType.BCD_CHANGE, context);
    final boolean isBusEvent = bcdEvent.getEffectiveDate().compareTo(context.getCreatedDate()) <= 0;
    recordBusOrFutureNotificationFromTransaction(subscription, bcdEvent, entitySqlDaoWrapperFactory, isBusEvent, 0, catalog, context);
    return null;
  }
});
origin: killbill/killbill

  @Override
  public List<SubscriptionBaseBundle> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final List<SubscriptionBundleModelDao> models = entitySqlDaoWrapperFactory.become(BundleSqlDao.class).getBundlesForLikeKey(bundleKey, context);
    return new ArrayList<SubscriptionBaseBundle>(Collections2.transform(models, new Function<SubscriptionBundleModelDao, SubscriptionBaseBundle>() {
      @Override
      public SubscriptionBaseBundle apply(@Nullable final SubscriptionBundleModelDao input) {
        return SubscriptionBundleModelDao.toSubscriptionBundle(input);
      }
    }));
  }
});
origin: killbill/killbill

private void broadcastConfigurationChangeFromTransaction(final Long kvRecordId, final String key, final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory,
                             final InternalCallContext context) throws EntityPersistenceException {
  if (isSystemKey(key)) {
    final TenantBroadcastModelDao broadcast = new TenantBroadcastModelDao(kvRecordId, key, context.getUserToken());
    final TenantBroadcastSqlDao tenantBroadcastSqlDao = entitySqlDaoWrapperFactory.become(TenantBroadcastSqlDao.class);
    createAndRefresh(tenantBroadcastSqlDao, broadcast, context);
  }
}
origin: killbill/killbill

/**
 * Get an instance of a specified EntitySqlDao class, sharing the same database session as the
 * initial sql dao class with which this wrapper factory was created.
 *
 * @param newSqlDaoClass the class to instantiate
 * @param <NewSqlDao>    EntitySqlDao type to create
 * @return instance of NewSqlDao
 */
public <NewSqlDao extends EntitySqlDao<NewEntityModelDao, NewEntity>,
    NewEntityModelDao extends EntityModelDao<NewEntity>,
    NewEntity extends Entity> NewSqlDao become(final Class<NewSqlDao> newSqlDaoClass) {
  final NewSqlDao newSqlDao = SqlObjectBuilder.attach(handle, newSqlDaoClass);
  return create(newSqlDaoClass, newSqlDao);
}
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws EventBusException, AccountApiException {
    final AccountSqlDao transactional = entitySqlDaoWrapperFactory.become(AccountSqlDao.class);
    final UUID accountId = specifiedAccount.getId();
    final AccountModelDao currentAccount = transactional.getById(accountId.toString(), context);
    if (currentAccount == null) {
      throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_ID, accountId);
    }
    specifiedAccount.validateAccountUpdateInput(currentAccount, treatNullValueAsReset);
    if (!treatNullValueAsReset) {
      // Set unspecified (null) fields to their current values
      specifiedAccount.mergeWithDelegate(currentAccount);
    }
    transactional.update(specifiedAccount, context);
    final AccountChangeInternalEvent changeEvent = new DefaultAccountChangeEvent(accountId,
                                           currentAccount,
                                           specifiedAccount,
                                           context.getAccountRecordId(),
                                           context.getTenantRecordId(),
                                           context.getUserToken(),
                                           context.getCreatedDate());
    try {
      eventBus.postFromTransaction(changeEvent, entitySqlDaoWrapperFactory.getHandle().getConnection());
    } catch (final EventBusException e) {
      log.warn("Failed to post account change event for accountId='{}'", accountId, e);
    }
    return null;
  }
});
origin: killbill/killbill

private SubscriptionEventModelDao findFutureEventFromTransaction(final UUID subscriptionId, final EntitySqlDaoWrapperFactory dao, final EventType type,
                                 @Nullable final ApiEventType apiType, final InternalCallContext context) {
  SubscriptionEventModelDao futureEvent = null;
  final Date now = context.getCreatedDate().toDate();
  final List<SubscriptionEventModelDao> eventModels = dao.become(SubscriptionEventSqlDao.class).getFutureActiveEventForSubscription(subscriptionId.toString(), now, context);
  for (final SubscriptionEventModelDao cur : eventModels) {
    if (cur.getEventType() == type &&
      (apiType == null || apiType == cur.getUserType())) {
      if (futureEvent != null) {
        throw new SubscriptionBaseError(String.format("Found multiple future events for type %s for subscriptions %s",
                               type, subscriptionId.toString()));
      }
      futureEvent = cur;
      // To check that there is only one such event
      //break;
    }
  }
  return futureEvent;
}
origin: killbill/killbill

overdueQueue.removeNotificationFromTransaction(entitySqlDaoWrapperFactory.getHandle().getConnection(), cur.getRecordId());
origin: killbill/killbill

  @Override
  public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final TenantModelDao tenantModelDaoWithSecret = new TenantModelDao(entity.getId(), context.getCreatedDate(), context.getUpdatedDate(),
                                      entity.getExternalKey(), entity.getApiKey(),
                                      hashedPasswordBase64, salt.toBase64());
    final TenantSqlDao tenantSqlDao = entitySqlDaoWrapperFactory.become(TenantSqlDao.class);
    createAndRefresh(tenantSqlDao, tenantModelDaoWithSecret, context);
    return null;
  }
});
origin: killbill/killbill

  @Override
  public List<SubscriptionBaseEvent> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
    final SubscriptionSqlDao transactional = entitySqlDaoWrapperFactory.become(SubscriptionSqlDao.class);
    final SubscriptionEventSqlDao eventsDaoFromSameTransaction = entitySqlDaoWrapperFactory.become(SubscriptionEventSqlDao.class);
    final List<SubscriptionEventModelDao> createdEvents = new LinkedList<SubscriptionEventModelDao>();
    for (final SubscriptionBaseWithAddOns subscription : subscriptions) {
      for (final SubscriptionBase subscriptionBase : subscription.getSubscriptionBaseList()) {
        // Safe cast
        final DefaultSubscriptionBase defaultSubscriptionBase = (DefaultSubscriptionBase) subscriptionBase;
        createAndRefresh(transactional, new SubscriptionModelDao(defaultSubscriptionBase), context);
        final List<SubscriptionBaseEvent> initialEvents = initialEventsMap.get(defaultSubscriptionBase.getId());
        for (final SubscriptionBaseEvent cur : initialEvents) {
          createdEvents.add(createAndRefresh(eventsDaoFromSameTransaction, new SubscriptionEventModelDao(cur), context));
          final boolean isBusEvent = cur.getEffectiveDate().compareTo(context.getCreatedDate()) <= 0 && (cur.getType() == EventType.API_USER);
          recordBusOrFutureNotificationFromTransaction(defaultSubscriptionBase, cur, entitySqlDaoWrapperFactory, isBusEvent, 0, catalog, context);
        }
        // Notify the Bus of the latest requested change, if needed
        if (!initialEvents.isEmpty()) {
          notifyBusOfRequestedChange(entitySqlDaoWrapperFactory, defaultSubscriptionBase, initialEvents.get(initialEvents.size() - 1), SubscriptionBaseTransitionType.CREATE, context);
        }
      }
    }
    return toSubscriptionBaseEvents(createdEvents);
  }
});
org.killbill.billing.util.entity.daoEntitySqlDaoWrapperFactory

Javadoc

Factory to create wrapped EntitySqlDao objects. During a transaction, make sure to create other EntitySqlDao objects via the #become call.

Most used methods

  • become
    Get an instance of a specified EntitySqlDao class, sharing the same database session as the initial
  • getHandle
  • <init>
  • create

Popular in Java

  • Creating JSON documents from java classes using gson
  • findViewById (Activity)
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • ImageIO (javax.imageio)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now