[英]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数据的基本结构是DataMap
和DataList
,它们表示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.