在Alfresco One 5.x Developer's Guide中有一个data list的例子。
我希望在我的项目中使用此功能。例如,有一些业务流程为其预定义了执行者。每个部门都有自己的业务流程。可以读取传入合同的元数据(来自电子邮件或扫描程序 - 并不重要)并自动运行业务流程,具体取决于部门。在我看来,数据清单的概念是合适的......
问题在于我无法获得联想。就我而言,这是类型cm:person
。
例如,数据列表模型定义描述如下:
<?xml version="1.0" encoding="UTF-8"?>
<model name="mspdl:MSpredefinedAssigneesDataListModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<description>...</description>
<author>...</author>
<version>...</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl" />
</imports>
<namespaces>
<namespace uri="http://www.....com/model/datalist/3.0" prefix="mspdl"/>
</namespaces>
<types>
<type name="mspdl:assigneesListItem">
<title>...</title>
<parent>dl:dataListItem</parent>
<properties>
<property name="mspdl:serviceName">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
<associations>
<association name="mspdl:projectMember1">
<source>
<mandatory>true</mandatory>
<many>false</many>
</source>
<target>
<class>cm:person</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
<association name="mspdl:projectMember2">
<source>
<mandatory>true</mandatory>
<many>false</many>
</source>
<target>
<class>cm:person</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
...
<association name="mspdl:projectMemberN">
<source>
<mandatory>true</mandatory>
<many>false</many>
</source>
<target>
<class>cm:person</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
</associations>
</type>
</types>
</model>
我正在尝试检索关联的网络脚本:
public class DataListAssignmentsRetriever extends DeclarativeWebScript {
private final String DATA_LIST_SITE_CONTAINER = "dataLists";
private final String NAMESPACE_URI = "http://www.......com/model/datalist/3.0";
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
QName ASSOC_NAME_PROJECT_MEMBER_1 = QName.createQName(NAMESPACE_URI, "projectMember1");
List<AssociationRef> temp00List = serviceRegistry.getNodeService().getSourceAssocs(dataListNodeRef, ASSOC_NAME_PROJECT_MEMBER_1);
// temp00List.size() == 0 ???
List<AssociationRef> temp01List = serviceRegistry.getNodeService().getTargetAssocs(dataListNodeRef, ASSOC_NAME_PROJECT_MEMBER_1);
// temp01List.size() == 0 ???
List<ChildAssociationRef> temp02List = serviceRegistry.getNodeService().getChildAssocs(dataListNodeRef);
// temp02List == 1 < -- Allows to find just only the property 'serviceName'.
List<ChildAssociationRef> temp03List =
serviceRegistry.getNodeService().getChildAssocs(dataListNodeRef, RegexQNamePattern.MATCH_ALL, ASSOC_NAME_PROJECT_MEMBER_1);
// temp03List.size() == 0 ???
List<AssociationRef> temp04List.size() =
serviceRegistry.getNodeService().getSourceAssocs(dataListNodeRef, RegexQNamePattern.MATCH_ALL);
// temp04List.size() == 0 ???
List<AssociationRef> temp05List = serviceRegistry.getNodeService().getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL);
// temp05List.size() == 0 ???
...
}
}
正确注入服务serviceRegistry
。
我做错了什么?如何从数据列表中获取关联?。
我将非常感谢这些信息。谢谢大家。
更新
我的数据列表的 NodeRef
为workspace://SpacesStore/b136bebc-fe2c-40fb-aec6-93d9fd22533d
。当我在节点浏览器中搜索它时,我得到以下内容:
因此,我通过链接查看以下内容:缺少关联。
然后我浏览了对child元素的引用(显示在屏幕截图的顶部),并看到以下内容:
当我通过这个链接时,我看到了我的联想:
更新
感谢您的咨询,Gagravarr和ratik.singhal _。通过使用以下代码,我可以获得对数据列表项的引用:
List<ChildAssociationRef> childAssociationRefs = serviceRegistry.getNodeService().getChildAssocs(
dataListNodeRef,
ContentModel.ASSOC_CONTAINS,
RegexQNamePattern.MATCH_ALL
);
NodeRef dataListItemNodeRef = childAssociationRefs.get(0).getChildRef();
在这里,我可以看到属性和关联:
属性:
社团:
我可以使用以下代码访问属性:
Map<QName, Serializable> properties = serviceRegistry.getNodeService().getProperties(dataListItemNodeRef);
Iterator iterator = properties.entrySet().iterator();
while(iterator.hasNext()) {
Map.Entry keyValuePairs = (Map.Entry)iterator.next();
Object key = keyValuePairs.getKey();
Object value = keyValuePairs.getValue();
...
}
但如何获得协会?...
答案 0 :(得分:1)
Angel Borroy给了excellent example帮助我:
当然,Gagravarr给出了一个很好的例子:
解决方案可能如下所示:
...
NodeRef dataListContainer =
siteService.getContainer("contracts-site", "dataLists");
List<ChildAssociationRef> dataListsNodes =
nodeService.getChildAssocs(dataListContainer);
for(ChildAssociationRef dataList : dataListsNodes) {
if (dataList.getTypeQName().isMatch(ContentModel.ASSOC_CONTAINS)) {
if(nodeService.getProperty(
dataList.getChildRef(),
ContentModel.PROP_TITLE).toString().equals("Data list title here")) {
List<ChildAssociationRef> childAssocsRef =
nodeService.getChildAssocs(dataList.getChildRef());
for(ChildAssociationRef childAssocRef : childAssocsRef) {
List<AssociationRef> customAssocs = nodeService.getTargetAssocs(
childAssocRef.getChildRef(),
QName.createQName(DATALIST_MODEL_URI, "projectMember1"));
NodeRef nodeRef = customAssocs.get(0).getTargetRef();
if(ContentModel.TYPE_PERSON.equals(nodeService.getType(nodeRef))) {
nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME);
}
...
}
} else continue;
}
}
...
这解决了我的问题。