Search in sources :

Example 16 with CustomField

use of org.killbill.billing.util.customfield.CustomField in project killbill by killbill.

the class JaxRsResourceBase method createCustomFieldResponse.

protected Response createCustomFieldResponse(final Iterable<CustomField> fields, final AuditMode auditMode, final TenantContext context) {
    final Collection<CustomFieldJson> result = new LinkedList<CustomFieldJson>();
    for (final CustomField cur : fields) {
        // TODO PIERRE - Bulk API
        final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(cur.getId(), ObjectType.CUSTOM_FIELD, auditMode.getLevel(), context);
        result.add(new CustomFieldJson(cur, auditLogs));
    }
    return Response.status(Response.Status.OK).entity(result).build();
}
Also used : StringCustomField(org.killbill.billing.util.customfield.StringCustomField) CustomField(org.killbill.billing.util.customfield.CustomField) CustomFieldJson(org.killbill.billing.jaxrs.json.CustomFieldJson) LinkedList(java.util.LinkedList) AuditLog(org.killbill.billing.util.audit.AuditLog)

Example 17 with CustomField

use of org.killbill.billing.util.customfield.CustomField in project killbill by killbill.

the class DefaultCustomFieldUserApi method removeCustomFields.

@Override
public void removeCustomFields(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<UUID> curstomFieldIds = Iterables.transform(customFields, new Function<CustomField, UUID>() {

            @Override
            public UUID apply(final CustomField input) {
                return input.getId();
            }
        });
        customFieldDao.deleteCustomFields(curstomFieldIds, internalCallContext);
    }
}
Also used : StringCustomField(org.killbill.billing.util.customfield.StringCustomField) CustomField(org.killbill.billing.util.customfield.CustomField) InternalCallContext(org.killbill.billing.callcontext.InternalCallContext) UUID(java.util.UUID)

Aggregations

CustomField (org.killbill.billing.util.customfield.CustomField)17 StringCustomField (org.killbill.billing.util.customfield.StringCustomField)13 CustomFieldJson (org.killbill.billing.jaxrs.json.CustomFieldJson)7 Test (org.testng.annotations.Test)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 TenantContext (org.killbill.billing.util.callcontext.TenantContext)4 TimedResource (org.killbill.commons.metrics.TimedResource)4 URI (java.net.URI)3 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)3 CustomFieldApiException (org.killbill.billing.util.api.CustomFieldApiException)3 AuditLog (org.killbill.billing.util.audit.AuditLog)2 CustomFieldModelDao (org.killbill.billing.util.customfield.dao.CustomFieldModelDao)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1