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);
}
}
Aggregations