在不同 Lotus Notes 数据库中的文档之间创建多对多关系
我正在进行“传统”Lotus Notes 编程(自 R5 以来相同),并且需要实现驻留在不同数据库中的 2 种文档类型(表单)之间的链接。
数据库(A)中的类型(A)的文档可以引用数据库(B)中的多个类型(B)的文档。 并且文档(B)还应该显示其与文档(A)的关系,因为文档(B)可以与不同的文档(A)相关。 我们有多对多的关系。
目前它仅在一侧实现(一对多): 文件形式 (A) 包含特殊的嵌入视图 “链接”文档驻留在数据库 A 中。当用户从数据库 (B) 中选择文档时,该链接文档由 LotusScript 创建。当用户单击此嵌入视图中的某个项目时,它将打开文档 (B)。
客户希望能够在任何一方编辑此关系,以便如果他在表单 (A) 中编辑它,表单 (B) 就会更新。 表单 (B) 应该具有相同类型的嵌入视图或类型 (A) 的关联文档列表
实现它的最佳方法是什么?
客户的基础设施是Lotus Domino 8.5.2 + Lotus Notes 8.5.2,因此理论上,复合应用程序方法可能是一种选择。
我问这个问题的原因是,据我了解,Notes 中没有好的方法可以嵌入另一个数据库的视图。 要求是数据库应该存在于工作区中,并以某种狡猾的列表显示。 如果能够通过服务器和replicaID 为嵌入视图指定目标数据库,那就太好了,但我们却有一个奇怪的随机工作区数据库列表。
I am doing "traditional" lotus notes programming (same since R5) and need to implement linking between 2 document types (forms) residing in different databases.
Document of type (A) in database (A) can reference several documents of type (B) in database (B).
And document (B) should also display its relationships with document (A), as document (B) can be related to different documents (A).
We have Many to Many relationship.
At the moment it is implemented on one side only (one to many):
Form of Document (A) contains embedded view of special
"link" documents residing in database A. This link documents are created by lotusScript when user selects documents from database (B). When user clicks on an item in this embedded view, it opens document (B).
Client wants to be able to edit this relationship on any side, so that if he edits it in form (A), form (B) is updated.
Form (B) is supposed to have the same kind of embedded view or a list of associated documents of type (A)
What is the best way to implement it?
Client's infrastracture is Lotus Domino 8.5.2 + Lotus Notes 8.5.2, so theoretically, composite applications approach may be an option.
The reason why I ask this question is that as far as I understand there is no good way in Notes to embed a view from another database.
The requirement is that the database should be present on workspace to be displayed in some sort of dodgy list.
It would be great to be able to specify target database for embedded view by server and replicaID, but instead we have a weird list of random workspace databases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
主要问题是 Notes 的设计目的不是处理数据库之间的关系(也不是处理除父子关系之外的任何关系)。因此,解决方案必须是一种创造性的解决方案。
我的脑海中浮现出一些(古怪的,可能很糟糕的)想法。一种是将引用存储在文档本身中,并在保存文档时更新它们。这一切都可以在 LotusScript 中完成,并且需要搜索其他数据库的文档以更新其引用。
好处是阅读文档时的性能会非常好。如果数据库 B 不可用,则读取数据库 A 时不会出现任何问题。它将数据保存在每个数据库的本地。缺点包括保存冲突的可能性,以及如果文档没有“保存”而是通过代理更新等,引用可能会不同步的危险。
另一个想法是使用代理按计划管理链接。如果您不需要实时最新的引用,您可以运行一个代理来扫描数据库 B 并更新数据库 A 中的引用。使用此方法,您可以选择更新数据库 A 文档本身 - 或 -听起来您已经完成了,创建一组显示在嵌入视图中的链接文档。后者消除了保存冲突问题。
另一个想法是当您在数据库 A 中打开文档时隐藏任何引用,但提供一个按钮来“显示”或“更新”引用。当您单击该按钮时,它会触发 LotusScript 来搜索数据库 B 并即时构建列表。对于少于 10,000 个文档,这可能会很快起作用。该函数可以更新您存储在同一数据库中的链接文档,这些文档提供嵌入视图。
希望这有帮助!
The main problem is that Notes wasn't designed to handle relationships like that between databases (nor anything besides parent child relationships for that matter). So the solution will have to be a creative one.
A couple of (off-the wall, potentially awful) ideas come to mind. One is to store the references in the documents themselves, and update them whenever the document is saved. That could all be done in LotusScript, and would require searching through the other database's documents to update their references.
Upside is that the performance when reading the documents would be excellent. There'd be no issues while reading Database A if Database B was unavailable. It keeps data local to each database. The downsides include the likelihood of save conflicts and the danger that references could get out of sync if documents aren't "saved" but instead are updated via agents, etc.
Another thought is to use agents to manage the links on a scheduled basis. If you don't need real-time up-to-date references, you could run an agent that scans Database B and updates the references in Database A. With this method you could choose either to update the Database A documents themselves - or - as it sounds like you've already done, create a set of link documents that show up in an embedded view. The latter eliminates the save conflict problem.
One more idea is to hide any references when you open a document in Database A, but provide a button to "show" or "update" references. When you click that button, it fires off LotusScript to search Database B and build a list on the fly. This would probably work quickly with less than 10,000 documents. That function could update the link documents you store on the same database which feed the embedded view.
Hope this helps!
正如您提到的,创建复合应用程序可能允许您执行此操作,但仅限于窗口而不是表单中的设计级别。
例如。
如果您不熟悉这个系统,我做了一个解释基础知识的教程。
http://www-10.lotus.com /ldd/compappwiki.nsf/dx/ibm-my-first-wire
尽管教程回调到同一个数据库,但指向不同的数据库也很容易。
就我个人而言,我会通过 XPages 来完成。我个人发现通过经典风格笔记设计/比较应用程序更容易实现。它还允许您在同一屏幕区域内显示设计元素。
As you mention creating a composite application may allow you to do this, but would be restricted to windows rather then design level in the form.
eg.
If you are not familiar with this system I did a tutorial which explains the basics.
http://www-10.lotus.com/ldd/compappwiki.nsf/dx/ibm-my-first-wire
Although the tutorial calls back to the same database, it is easy enough to point to a different one.
Personally I'd do it through XPages. I personally find it much easier to implement then through classic style notes design/comp apps. It will also allow you to display design elements within the same screen area.
正如您已经听说的,Lotus Notes 没有内置的引用完整性约束,您必须自己完成。
我不会依赖文档链接,因为它们是围绕 UNID 进行调整的,如果您剪切并粘贴相同的文档,UNID 可能会发生变化,从而丢失链接。试试这个,
1/在每个文档上创建一个“ID”字段。您可以使用 @Unique 在计算字段中生成 ID,并将其保存到两个数据库中的文档中。您可以创建一个代理来在 LotusScript (LS) 或公式中执行此操作。 (如果在 LS 中执行,请考虑使用 evaluate 语句)
2/ 在每个数据库中创建一个查找视图,按新 ID 列出文档(不要忘记设置 ID 列的“排序顺序”。
3/ 使用操作按钮可以为两个数据库进行配置,您可以创建一个 LS 函数,该函数将打开相反的数据库视图并返回 ID 字段(NotesUIWorkspace.pickliststrings 将是选择文档的最简单方法,否则您可以构建一个 对话框 将结果列表存储在名为“linkedID”的字段中作为多值列表。
4/ 您可能想要存储更多信息,例如文档标题或作者,因此您需要使用 getdocumentbykey 然后询问在屏幕上显示信息所需的字段。
5/ 然后,您还可以在您引用的目标文档上添加一个新字段,将其称为“referrerID”,它是引用当前文档的文档列表。这将维持两国关系。
存储链接的字段必须是多值字段,否则循环遍历链接文档 ID 列表并管理它们会变得非常麻烦。
此方法使用静态密钥,因此您可以复制数据库,而不会丢失用户投入时间生成的文档之间的关系。如果您依赖文档通用 ID,您可能(并且可能会)失去这些关系(在 @documentUniqueID 文档),如果您剪切并粘贴文档,或者将数据库复制到其他位置,尽管复制了相同的字段,它们仍然会成为新文档,并且将被分配一个新的通用 ID,任何文档旧文档的链接将无效。
如果您从其他数据库显示的信息发生变化,您将需要能够定期刷新该数据,因此请考虑编写一个可以执行查找和刷新相关字段的计划代理。
如果用户打算取消链接或更改文档之间的关系,那么您需要添加循环关键字段的函数,并使列表与用户正在执行的操作保持一致。因此,正如我所说,Lotus Notes 的平面数据结构要求您自己管理所有完整性约束。
如果您想要一点奇特,您可以使用嵌入式视图,因为它们确实支持来自同一服务器上另一个数据库的引用。关于在 LotusScript 中处理它的一些提示此处。并使用一个附加视图,根据引用 ID 对数据进行分类。嵌入视图是可以的,只要它们所基于的视图不是太大,否则可能会影响其嵌入的表单的性能。
As you've already heard, Lotus Notes has no referential integrity constraints built-in, you have to do it yourself.
I wouldn't be relying on document links as they're geared around UNID's which can change if you cut and paste the same document, thus losing the link. Try this,
1/ Create an "ID" field on each document. You can populate it by using @Unique in a computed field to generate an ID, and save that to the documents in both databases. You can create an agent to do this in lotusScript (LS), or formula. (Consider using the evaluate statement if doing in LS)
2/ Create a lookup view in each database that lists the documents by the new ID (don't forget to set the "sort order" of the ID column.
3/ Using an action button that can be configured for both databases, you can create a LS function that will open the the opposing databases view and return the ID field. (NotesUIWorkspace.pickliststrings would be the simplest way to pick the documents, otherwise you could build a dialogbox. Store the list of results in a field called "linkedID" as multi-value list.
4/ There may be more info that you want to store like document title or author, so you'll need to then get a handle to those documents using getdocumentbykey and then interrogating the fields you'll need to display information on screen.
5/ You can then also add a new field on the target documents you're referring to, call it "referrerID", which is a list of documents that reference the current document. This will maintain the two-way relationship.
The field that stores links must be a multi-valued field, otherwise it gets quite cumbersome to loop through list of linked document ID's and manage them.
This approach uses a static key so you can copy databases around without losing the relationships between documents the user has invested time in producing. You can (and probably will) lose those relationships if you rely on document universal ID's (described well in the @documentUniqueID documentation), if you cut and paste the document, or copy the database somewhere else they become new documents despite copying the same fields, and will be assigned a new universal ID, any document links for the old document will be invalid.
If the information you're displaying from the other database changes, you'll need to be able to refresh that data regularly, so consider writing a scheduled agent that can do the look up and refresh the relevant fields.
If the user intends to un-link or change the relationships between documents, then you'll need to add functions that loop through the key fields and keep the lists consistent with what the user is doing. So, like I said, Lotus Notes' flat data structure requires you manage all integrity constraints yourself.
If you want to get a little fancy you can use embedded views as they do support references from another database on the same server. Some tips about handling it in LotusScript here. And use an additional view that categorises your data by the referring ID. Embedded views are ok, as long as the view they're based on is not too big, otherwise it may affect the performance of the form that it is embedded into.