Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 26 2017 20:07
    @remmeier banned @hibaymj
Remo
@remmeier
that should rather be "spanning across a request" to be precise. No multi-request transaction things, except when batching them with the operations module.
Steve Brush
@brushs
I have a ResourceRepository for a DTO, and presumably would like to inject a reference to repository for an actual Entity tied to my DB to perform the actual work for creating records. I can autowire the Entity's repository if I actually create a class for that repository. However, I would prefer not to -- currently spring boot auto-configures all the repositories. Is there to inject or get a reference into my DTO's repository without creating the Entity repository manually? I tried through the ResourceRegistry but that doesn't seem to work.
Remo
@remmeier
if the Entity repository is managed by Spring, an the DTO manually defined and also managed in Spring, should work? There is no mechanism as of yet that would expose all the Crnk internals to Spring, like all the contents of the ResourceRegistry. It is rather the other way around. It will discover everything from Spring and put it into the ResourceRegistry.
3 replies
duncanportelli
@duncanportelli
I have a generic question please. Is the CrnkClient capable of handling concurrent requests at the same time? i.e. should I create it as a singleton object or create multiple clients?
Joshua Bourquin
@jbourquin
I have a high level question, I have a POSTGRES database plugged into CRNK with some JSONB columns. How can I add a custom URL query filter to CRNK that would then execute some custom SQL against said JSONB columns?
heidiperaltacasebook
@heidiperaltacasebook

Hi @remmeier ! I'm using postman to query my java endpoint using nested filters like so:

{baseUrl}/entity?filter={"resourceType": "value"}

These are the properties on the model:

  @JsonProperty(value = "resource_type")
  @Column(name = "resource_type")
  private String resourceType;

  private String name;

I get Failed to resolve path to field 'resourceType' if I try snake case I get attribute resource_type not found in Entity

If I use the name property to filter by it works just fine, this happens across the entire API where it seems to only work when filtering on single-name properties that are not in camel/snake case. Is there anything we need to configure/fix on our end? Thank you!

Remo
@remmeier
@duncanportelli yes, it is thread-safe. In general there are no internal data structured shared between requests that could cause problem.s
@jbourquin a non-JSONAPI parameter? if you want to submit a generic sql query, maybe the "empty" ?filter=... will do
@heidiperaltacasebook with a current version? the json property should work, meaning resource_type. If not, there is an issue somewhere and the complete exception would be good.
Rehab Reda
@rehab-reda0
Hi Remo I want to change the serialize type to lazy for the relationships if the returned number of items of the main entity is more than 2 for example is there any way to do so ?
Weihua Hu
@jameshwh
@remmeier Hi Remo, is there any easy way to construct a request body for create request? can we generate it from a @JsonApiResource object? i want to do integration test and wondering if there is any existing tool for it, otherwise i need to construct the request body by myself
Weihua Hu
@jameshwh
it is found that we could use crnkBoot.getDocumentMapper().getResourceMapper() to do the conversion
Weihua Hu
@jameshwh
but didn't know if there is any way to convert a json string to JsonApiResource entity
Steve Brush
@brushs
@remmeier Are ResourceRepositories automatically scanned and created by Spring available to other Spring beans? I assume so -- but they do not seem to be available for injection and do not seem to show in Actuator?
Remo
@remmeier
@rehab-reda0 if you need custom logic, you could implement it in your repository (keep it lazy but to eager if fewer than 3 results available). But generally I would recommend against change ob behavior depending on the the number of results for the sake of consistency.
@brushs if they are setup like any other bean (by the application, not crnk). In doing so, it has all the usual Spring things like autowiring. Unlike the Spring Data repository, there is no magical and hard to customize default logic (except the JPA legacy expose-all code paths maybe). what would you like to see from the actuator? (personally I dont use them in favor of something else).
Remo
@remmeier
@jameshwh yes, exactly DocumentMapper. From that you get Document/Resource objects. Those you can (de)serialize) with Jackson's ObjectMapper.
Steve Brush
@brushs
@remmeier is there any way to mix the "exposeAll" behaviour and a manually created Repository? I have 300+ entities and need a handful of manually created Repositories?
Remo
@remmeier
Maybe with a look at JpaModule and its config. the expose all is just a loop and if there is a limitation, ciuld be customized. A bit harder would be if you make use of spring depency injection. in this case two unrelated codepaths would contribute the same thing. that will cause trouble. in this case probably best to not use exposeall and look for a spring-based solution
Atreyu79
@Atreyu79
Is there a way I can default Crnk-Compact to true in a resource repository? In my API I'm not persisting a particular resource, so it's never retrievable via GET... making self links misleading. I know we can intercept and force the header on a customer's behalf, but a more elegant solution is preferred if one exists. I'm unclear from the documentation what my options are here.
Rehab Reda
@rehab-reda0

Hi @remmeier any way to modify the related link here ?
"self": "http://example.com/articles/1/relationships/author"

"related": "http://example.com/articles/1/author"

Remo
@remmeier
it is possible to omit one or the other
@Atreyu79 no, not as of yet. was not deemed useful because it breaks discoverability in the broswer for developers/operators
should be more an optimization where needed
Rehab Reda
@rehab-reda0

I want for example to modify the url to be authors not author
"self": "http://example.com/articles/1/relationships/author"

"related": "http://example.com/articles/1/author"

@remmeier

Remo
@remmeier
@JsonProperty allows renaming
Rehab Reda
@rehab-reda0

I am having a problem we have a standarization that the url should be in kebab case
so If have account model which has a list of emailAddresses
I want the url to be like accounts/id/email-addresses

but the relationship in the response body should be in camelCase

I solved the first part by modifying the url in spring boot filter so if the user request accounts/id/email-addresses it is then converted to accounts/id/emailAddresses
but the links in the response how can i modify relationship links ?
Matt12432
@Matt12432
Hi all, I'm trying to get a url like this to work: /authors/{authorId}/books/{id} to return a specific book out of the list of books that belong to the author however I get an error saying "cannot add further url fragements after field". Should the above url be possible? I've also tried using a filter like /authors/{authorId}/books?filter["id"]={bookId} however that returns an error saying that the property id doesn't exist even though the call to beanInformationBase.findFieldByJsonName() appears to have an id property in the hashmap. Appreciate any help on this.
Rehab Reda
@rehab-reda0
@Matt12432 yes it is possible by applying the nested resources check here https://www.crnk.io/releases/stable/documentation/#_nested_resources
Matt12432
@Matt12432
Thanks @rehab-reda0 that has worked
Atreyu79
@Atreyu79
@remmeier Thanks
Remo
@remmeier
@rehab-reda0 having a
a Name and NamingStrategy would be nice sometime. the former hilding a java, json and path name. this used in the ResourceField class.
Rehab Reda
@rehab-reda0
Thank you @remmeier so how can I add this customized url builder class ?
from the boot configuration ?
I can't find a seturlbuilder function or from the setupmodule I can't find context.seturlbuilder
Remo
@remmeier
lmaxbe it has to be added, customizing it has not come up so far
Rehab Reda
@rehab-reda0
@remmeier so I will use just implement a class from the url builder and make it as a bean ?
fkohl04
@fkohl04
@DeafLight Quite a while ago you said, that you are trying to use crnk with Ktor. Have you been successful with this?
Justin Gottschalk
@justindevs
I am using the client to communicate communicate with a spring boot crnk api using the in memory storage. One of the keys I am filtering on can contains string with commas and that is getting split into a set in the filter and will not match on the whole string. Is there a way around crnk treating the commas as a list/set?
2 replies
Remo
@remmeier
@rehab-reda0 somewhere in the setup/CrnkBoot it should be possible to set a custom UrlBuilder.
Matt12432
@Matt12432
Hi sorry I have another query related to previous one, I'm not sure how the url for filtering on nested resources should be structured. For instance if I want to filter books for an author where the name is bookName. I've tried /authors/{authorId}/books?filter[book.name]=bookName which errors saying that there is no property book.name on the book object (its just called name). I've also tried /authors/{authorId}/books?filter[name]=bookName and /authors/{authorId}/books?filter[book][name]=bookName however these then go through authors findAll method instead of the books relationship repo. Once again I appreciate any help with this thanks.
Remo
@remmeier
books.name, there are some more advanced options in the docs, like filtering relationships only, not the requested roots
Matt12432
@Matt12432
Sorry yes the first scenario above should have said [books.name]. I'm not exactly sure where in the documentation I should be looking. Ideally in the above scenario it would still be possible to run a query like this /authors?filter[name]=authorName but filtering both at the same time wouldn't be required
Remo
@remmeier
Rehab Reda
@rehab-reda0

@rehab-reda0 somewhere in the setup/CrnkBoot it should be possible to set a custom UrlBuilder.

Can u please give me an example? I can't figure it out
@remmeier

Remo
@remmeier
I dont think it is currently possible. One would have to check the occurrences of new UrlBuilder(...) and maybe make it customizable.
Roy
@depzor
Hi all,
I have 1 resource type "users" which could reside in two repositories. Based on some parameter it should be retrieved from the current database or from an external system.
Currently I have one database table named "subscriptions" which has a ManyToOne relation with the UserEntity. In order to support an external user repository I am thinking about
adding a new field in the database table "subscriptions" like "externalUserId". Are there any best practices to support two dynamic "user" repositories with relationships to my "subscriptions" resource?
Roy
@depzor
Is there a maven plugin available for crnk-gen? https://github.com/crnk-project/crnk-framework/tree/master/crnk-gen
Remo
@remmeier
just gradle as of yet. but the gradle plugin is just a thing wrapper around a plain Java app. So a Maven plugin or Java main is possible with a few lines.