public <T> String buildUrl(ResourceInformation resourceInformation, Object id, QuerySpec querySpec) { return buildUrl(resourceInformation, id, querySpec, null); }
public <T> String buildUrl(ResourceInformation resourceInformation, Object id, QuerySpec querySpec, String relationshipName) { return buildUrlInternal(resourceInformation, id, querySpec, relationshipName); }
private <T> String toUrl(QueryAdapter queryAdapter, RepositoryRequestSpec requestSpec) { JsonApiUrlBuilder urlBuilder = new JsonApiUrlBuilder(moduleRegistry.getResourceRegistry()); Object relationshipSourceId = requestSpec.getId(); ResourceField relationshipField = requestSpec.getRelationshipField(); ResourceInformation rootInfo; if (relationshipField == null) { rootInfo = queryAdapter.getResourceInformation(); } else { rootInfo = relationshipField.getParentResourceInformation(); } return urlBuilder.buildUrl(rootInfo, relationshipSourceId, queryAdapter, relationshipField != null ? relationshipField.getJsonName() : null); }
public KatharsisClient(ServiceUrlProvider serviceUrlProvider) { httpAdapter = detectHttpAdapter(); moduleRegistry = new ModuleRegistry(false); moduleRegistry.addModule(new ClientModule()); resourceRegistry = new ClientResourceRegistry(moduleRegistry, serviceUrlProvider); urlBuilder = new JsonApiUrlBuilder(resourceRegistry); objectMapper = new ObjectMapper(); objectMapper.enable(SerializationFeature.INDENT_OUTPUT); // consider use of katharsis module in the future JsonApiModuleBuilder moduleBuilder = new JsonApiModuleBuilder(); SimpleModule jsonApiModule = moduleBuilder.build(resourceRegistry, true); objectMapper.registerModule(jsonApiModule); documentMapper = new ClientDocumentMapper(moduleRegistry, objectMapper, null); setProxyFactory(new BasicProxyFactory()); }
public <T> String buildUrl(ResourceInformation resourceInformation, Object id, QueryParams queryParams) { return buildUrl(resourceInformation, id, queryParams, null); }
public <T> String buildUrl(ResourceInformation resourceInformation, Object id, QueryParams queryParams, String relationshipName) { return buildUrlInternal(resourceInformation, id, queryParams, relationshipName); }
@SuppressWarnings("unchecked") @Override public D findOneTarget(I sourceId, String fieldName, QueryParams queryParams) { String url = urlBuilder.buildUrl(sourceResourceInformation, sourceId, queryParams, fieldName); return (D) executeGet(url, ResponseType.RESOURCE); }
@Override public T findOne(I id, QuerySpec querySpec) { String url = urlBuilder.buildUrl(resourceInformation, id, querySpec); return findOne(url); }
@Override public DefaultResourceList<D> findManyTargets(I sourceId, String fieldName, QueryParams queryParams) { String url = urlBuilder.buildUrl(sourceResourceInformation, sourceId, queryParams, fieldName); return (DefaultResourceList<D>) executeGet(url, ResponseType.RESOURCES); }
@Override public DefaultResourceList<D> findManyTargets(I sourceId, String fieldName, QuerySpec querySpec) { String url = urlBuilder.buildUrl(sourceResourceInformation, sourceId, querySpec, fieldName); return (DefaultResourceList<D>) executeGet(url, ResponseType.RESOURCES); }
@Override public DefaultResourceList<T> findAll(Iterable<I> ids, QuerySpec queryPaquerySpecrams) { String url = urlBuilder.buildUrl(resourceInformation, ids, queryPaquerySpecrams); return findAll(url); }
public <T> String buildUrl(ResourceInformation resourceInformation, Object id, QueryAdapter queryAdapter, String relationshipName) { if(queryAdapter instanceof QuerySpecAdapter){ return buildUrl(resourceInformation, id, ((QuerySpecAdapter)queryAdapter).getQuerySpec(), relationshipName); }else{ return buildUrl(resourceInformation, id, ((QueryParamsAdapter)queryAdapter).getQueryParams(), relationshipName); } }
@Override public List<T> findAll(QueryParams queryParams) { String url = urlBuilder.buildUrl(resourceInformation, null, queryParams); return findAll(url); }
@Override public List<T> findAll(Iterable<I> ids, QueryParams queryParams) { String url = urlBuilder.buildUrl(resourceInformation, ids, queryParams); return findAll(url); }
@Override public T findOne(I id, QueryParams queryParams) { String url = urlBuilder.buildUrl(resourceInformation, id, queryParams); return findOne(url); }
@Override public void delete(I id) { String url = urlBuilder.buildUrl(resourceInformation, id, (QuerySpec) null); executeDelete(url); }
@Override public DefaultResourceList<T> findAll(QuerySpec querySpec) { String url = urlBuilder.buildUrl(resourceInformation, null, querySpec); return findAll(url); }
@SuppressWarnings("unchecked") @Override public D findOneTarget(I sourceId, String fieldName, QuerySpec querySpec) { String url = urlBuilder.buildUrl(sourceResourceInformation, sourceId, querySpec, fieldName); return (D) executeGet(url, ResponseType.RESOURCE); }
@Override public void setRelation(T source, J targetId, String fieldName) { Serializable sourceId = getSourceId(source); String url = urlBuilder.buildUrl(sourceResourceInformation, sourceId, (QuerySpec) null, fieldName); executeWithId(url, HttpMethod.PATCH, targetId); }
@Override public void setRelations(T source, Iterable<J> targetIds, String fieldName) { Serializable sourceId = getSourceId(source); String url = urlBuilder.buildUrl(sourceResourceInformation, sourceId, (QuerySpec) null, fieldName); executeWithIds(url, HttpMethod.PATCH, targetIds); }