AgRest and Cayenne Generic Persistent Objects

21 views
Skip to first unread message

Dmitry Levichev

unread,
May 7, 2021, 9:28:25 AM5/7/21
to Agrest Framework User Group
Hello, everyone!

Is it possible to work with Cayenne generic persistent objects using AgRest endpoint? I mean something like that (hypothetical example):

@Path("dynamic")
@Produces(MediaType.APPLICATION_JSON)
public class DynamicResource {
    @Context
    private Configuration config;

    @GET
    public DataResponse<CayenneDataObject> getAll(@Context UriInfo uriInfo) {
        return Ag.select("MyDynamicEntity", config).uri(uriInfo).get();
    }
}

Is it possible at all? Could you please provide some example or workaround may be? Thank you!

Best Regards,
    Dmitrii Levichev

Andrus Adamchik

unread,
May 8, 2021, 1:50:15 AM5/8/21
to Agrest Framework User Group
Hi Dmitry,

While this should be fairly easy in theory, in practice entity resolving in Agrest (unlike Cayenne) is fully based on the entity Java class. So you can't achieve it without some framework changes.

This would be a very interesting feature though (e.g. it would allow to build a generic REST engine that can reverse-engineer an unknown DB in runtime). I've been thinking about it, but never had enough motivation to make it work.

So what is your scenario? Maybe this discussion will motivate us to make it happen :)

Andrus


--
You received this message because you are subscribed to the Google Groups "Agrest Framework User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to agrest-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/agrest-user/b34ca95e-5e95-49d9-9966-85aa1866bafcn%40googlegroups.com.

Dmitrii Levichev

unread,
May 8, 2021, 9:13:59 AM5/8/21
to agres...@googlegroups.com

Hi Andrus,

It's all about low-code/no-code solutions. Imagine a huge enterprise system, for example ERP or CRM, used by plenty of business users from many different departments. Let's assume that the system architecture is SOA or microservices. Some business users would like to extend system functionality as fast as possible, but they don't have enough time, resources or budget to fulfill their needs in a traditional way. I mean they can't request new feature from IT department and wait some months for a new release, because a week later this feature might become outdated. So, what exactly are the business user's needs? First of all, they have to define their own data structures on a conceptual level. Business people usually don't care about physical storage details. Next step is a GUI for the new structures. And the last step is a workflow. And most importantly, the new extension should be easily integrated with the enterprise system.

Another application may be fast prototyping. A sort of playground for business users and even for developers. Imagine building of PoC or even MVP of business application in hours without writing even a single line of code. Sounds great, isn't it?

So, I've got an idea how this conceptual data model (CDM) could be defined by a business user. It's very close to CayenneModeller object entity representation, a little bit simplified. I can convert my CDM into Cayenne DataMap and even create data structures on the fly. I also can build a dynamic GUI application that understands my CDM and works with data using REST endpoints. But the only missing link in this chain is the generic REST engine you mentioned.

Actually, company I'm working for already done a similar solution using another technology stack, so concept proved working.

Best regards,
  Dmitrii Levichev

07.05.2021 16:53, Andrus Adamchik пишет:

Andrus Adamchik

unread,
May 10, 2021, 2:14:19 AM5/10/21
to Agrest Framework User Group
Nice! Yeah, (low|no)-code is becoming all rage these days (again :)). And what you describe is very close to what I also had in mind as well. Except I didn't have an immediate business case, so for me it was somewhat theoretical. 

Let's explore/prototype this. AgEntity already has "name" property. So just need to make the stack work off of it internally instead of a Java class.

So if there is a POC of Agrest with generic entities, will you be able to give it run and provide feedback?

Andrus


Dmitrii Levichev

unread,
May 10, 2021, 7:45:35 AM5/10/21
to agres...@googlegroups.com

Andrus,

Of course I'll give it a try if you provide a prototype version with the feature we are talking about. Unfortunately I'm a sort of newbie in Java, hence you ought to be patient with my dumb questions and late feedbacks ;)

Best regards,
  Dmitrii Levichev

10.05.2021 9:14, Andrus Adamchik пишет:
Reply all
Reply to author
Forward
0 new messages