简体   繁体   English

使用rest.li时如何重用现有数据模型

[英]How to reuse existing data models when using rest.li


We have a few existing data model classes but don't have a REST interface to these. 我们有一些现有的数据模型类,但没有这些的REST接口。 If we wish to use linkedin's rest.li framework, is it possible to reuse existing models without regenerating new model Java classes that extend RecordTemplate? 如果我们希望使用linkedin的rest.li框架,是否可以重用现有模型而无需重新生成扩展RecordTemplate的新模型Java类? Otherwise for every model we have along with nested associations, we might end up having one rest.li specific model class. 否则,对于我们拥有的每个模型以及嵌套的关联,我们最终可能会拥有一个rest.li特定的模型类。 It will also help if there is a link to pegasus plugin or the kind of customizations possible with this plugin, but I couldn't find one nor figure out after many attempts at project skeleton generation to try to customize this. 如果有指向飞马插件的链接或该插件可能的自定义类型,它也将有所帮助,但是经过多次尝试生成项目骨架以对其进行自定义之后,我找不到一个,也找不到了。 Any pointers will be of great help. 任何指针都会有很大帮助。

Thanks, 谢谢,
Padmanabhan Padmanabhan

Rest.li is tightly coupled with its data layer. Rest.li与它的数据层紧密相连。 There is no trivial way to use an arbitrary data model with Rest.li. 在Rest.li中没有使用任意数据模型的简单方法。 However, it is possible to come up with some conversion logic between Rest.li data and your existing data model. 但是,可以在Rest.li数据和您现有的数据模型之间提出一些转换逻辑。 Whether or not this conversion logic is lossy, complicated or not depends on the nature of your data model. 此转换逻辑是否有损,复杂与否取决于数据模型的性质。

For example, the fundamental structures in Rest.li data is DataMap and DataList , which represents JSON object and array. 例如,Rest.li数据的基本结构是DataMapDataList ,它们表示JSON对象和数组。 All DataMap keys must be string, and string is the only allowed data type in JSON object. 所有DataMap密钥都必须为字符串,字符串是JSON对象中唯一允许的数据类型。 If your existing data model is compatible with JSON, and you have some form of schema, this conversion could be lossless. 如果您现有的数据模型与JSON兼容,并且您具有某种形式的架构,则此转换可能是无损的。 Otherwise, it could be nontrivial to do. 否则,这可能并非易事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行Linkedin的Rest.li示例 - Running Linkedin's Rest.li example 如何在多线程中重用现有的WebDriver实例 - How to reuse existing WebDriver instances in multithreading 使用现有数据库(模型) - Using play with existing database ( models ) 如何在不同资源中重用REST方法? - How to reuse a REST methods in different resources? 如何使用Models实现简单的REST和ContentProvider架构? - How to implement a simple REST and ContentProvider architecture using Models? 如何在Spring Boot REST应用程序中重用类? - How to reuse classes in a Spring Boot REST application? 用于读取现有数据时,如何用数据库中的数据填充托管bean属性? - How to fill managed bean properties with data from DB when using for existing data read? 配置Activiti以重用Spring Boot中的现有用户/组数据 - Configure Activiti to reuse the existing user/group data in Spring Boot 使用Spring Data REST时如何更改Jacksons配置? - How can I change Jacksons Configuration when using Spring Data REST? 当使用 Quarkus rest 数据 Panache 如何在 @PrePersist 中从请求 header 访问用户名 - When using Quarkus rest data Panache how to access username from request header in @PrePersist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM