Search in sources :

Example 1 with DefaultCustomFieldDao

use of org.killbill.billing.util.customfield.dao.DefaultCustomFieldDao in project killbill by killbill.

the class DefaultCustomFieldUserApi method addCustomFields.

@Override
public void addCustomFields(final List<CustomField> customFields, final CallContext context) throws CustomFieldApiException {
    if (!customFields.isEmpty()) {
        final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(customFields.get(0).getObjectId(), customFields.get(0).getObjectType(), context);
        final Iterable<CustomFieldModelDao> transformed = Iterables.transform(customFields, new Function<CustomField, CustomFieldModelDao>() {

            @Override
            public CustomFieldModelDao apply(final CustomField input) {
                // TODO See https://github.com/killbill/killbill/issues/35
                if (input.getId() != null) {
                    return new CustomFieldModelDao(input.getId(), context.getCreatedDate(), context.getCreatedDate(), input.getFieldName(), input.getFieldValue(), input.getObjectId(), input.getObjectType());
                } else {
                    return new CustomFieldModelDao(context.getCreatedDate(), input.getFieldName(), input.getFieldValue(), input.getObjectId(), input.getObjectType());
                }
            }
        });
        ((DefaultCustomFieldDao) customFieldDao).create(transformed, internalCallContext);
    }
}
Also used : CustomFieldModelDao(org.killbill.billing.util.customfield.dao.CustomFieldModelDao) DefaultCustomFieldDao(org.killbill.billing.util.customfield.dao.DefaultCustomFieldDao) StringCustomField(org.killbill.billing.util.customfield.StringCustomField) CustomField(org.killbill.billing.util.customfield.CustomField) InternalCallContext(org.killbill.billing.callcontext.InternalCallContext)

Aggregations

InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)1 CustomField (org.killbill.billing.util.customfield.CustomField)1 StringCustomField (org.killbill.billing.util.customfield.StringCustomField)1 CustomFieldModelDao (org.killbill.billing.util.customfield.dao.CustomFieldModelDao)1 DefaultCustomFieldDao (org.killbill.billing.util.customfield.dao.DefaultCustomFieldDao)1