private Builder<String> extractEntityIdsFromBatchArgument(final Iterable arg) { final Iterator iterator = arg.iterator(); final Builder<String> entityIds = new Builder<String>(); while (iterator.hasNext()) { final Object object = iterator.next(); if (!(object instanceof Entity)) { // No good - ignore return null; } else { entityIds.add(((Entity) object).getId().toString()); } } return entityIds; }
private DefaultSubscriptionBase getDefaultSubscriptionBase(final Entity subscriptionBase, final Catalog catalog, final InternalTenantContext context) throws CatalogApiException { if (subscriptionBase instanceof DefaultSubscriptionBase) { return (DefaultSubscriptionBase) subscriptionBase; } else { // Safe cast, see above return (DefaultSubscriptionBase) dao.getSubscriptionFromId(subscriptionBase.getId(), catalog, context); } } }
private void unactivateEventFromTransaction(final Entity event, final EntitySqlDaoWrapperFactory dao, final InternalCallContext context) { if (event != null) { final String eventId = event.getId().toString(); dao.become(SubscriptionEventSqlDao.class).unactiveEvent(eventId, context); } }
public EntityBase(final Entity target) { this.id = target.getId(); this.createdDate = target.getCreatedDate(); this.updatedDate = target.getUpdatedDate(); }
private List<String> retrieveEntityIdsFromArguments(final Method method, final Object[] args) { final Annotation[][] parameterAnnotations = getAnnotations(method); int i = -1; for (final Object arg : args) { i++; // Assume the first argument of type Entity is our type of Entity (type U here) // This is true for e.g. create calls if (arg instanceof Entity) { return ImmutableList.<String>of(((Entity) arg).getId().toString()); } // For Batch calls, the first argument will be of type List<Entity> if (arg instanceof Iterable) { final Builder<String> entityIds = extractEntityIdsFromBatchArgument((Iterable) arg); if (entityIds != null) { return entityIds.build(); } } for (final Annotation annotation : parameterAnnotations[i]) { if (arg instanceof String && Bind.class.equals(annotation.annotationType()) && ("id").equals(((Bind) annotation).value())) { return ImmutableList.<String>of((String) arg); } else if (arg instanceof Collection && BindIn.class.equals(annotation.annotationType()) && ("ids").equals(((BindIn) annotation).value())) { return ImmutableList.<String>copyOf((Collection) arg); } } } return ImmutableList.<String>of(); }
private Builder<String> extractEntityIdsFromBatchArgument(final Iterable arg) { final Iterator iterator = arg.iterator(); final Builder<String> entityIds = new Builder<String>(); while (iterator.hasNext()) { final Object object = iterator.next(); if (!(object instanceof Entity)) { // No good - ignore return null; } else { entityIds.add(((Entity) object).getId().toString()); } } return entityIds; }
private DefaultSubscriptionBase getDefaultSubscriptionBase(final Entity subscriptionBase, final Catalog catalog, final InternalTenantContext context) throws CatalogApiException { if (subscriptionBase instanceof DefaultSubscriptionBase) { return (DefaultSubscriptionBase) subscriptionBase; } else { // Safe cast, see above return (DefaultSubscriptionBase) dao.getSubscriptionFromId(subscriptionBase.getId(), catalog, context); } } }
private void unactivateEventFromTransaction(final Entity event, final EntitySqlDaoWrapperFactory dao, final InternalCallContext context) { if (event != null) { final String eventId = event.getId().toString(); dao.become(SubscriptionEventSqlDao.class).unactiveEvent(eventId, context); } }
public EntityBase(final Entity target) { this.id = target.getId(); this.createdDate = target.getCreatedDate(); this.updatedDate = target.getUpdatedDate(); }
private List<String> retrieveEntityIdsFromArguments(final Method method, final Object[] args) { final Annotation[][] parameterAnnotations = getAnnotations(method); int i = -1; for (final Object arg : args) { i++; // Assume the first argument of type Entity is our type of Entity (type U here) // This is true for e.g. create calls if (arg instanceof Entity) { return ImmutableList.<String>of(((Entity) arg).getId().toString()); } // For Batch calls, the first argument will be of type List<Entity> if (arg instanceof Iterable) { final Builder<String> entityIds = extractEntityIdsFromBatchArgument((Iterable) arg); if (entityIds != null) { return entityIds.build(); } } for (final Annotation annotation : parameterAnnotations[i]) { if (arg instanceof String && Bind.class.equals(annotation.annotationType()) && ("id").equals(((Bind) annotation).value())) { return ImmutableList.<String>of((String) arg); } else if (arg instanceof Collection && BindIn.class.equals(annotation.annotationType()) && ("ids").equals(((BindIn) annotation).value())) { return ImmutableList.<String>copyOf((Collection) arg); } } } return ImmutableList.<String>of(); }