我正在使用Javascript从工作流程创建自定义数据列表项。如果我使用默认的Alfresco数据列表,而不是我的自定义数据列表,则Javascript有效。
Javascript摘自.bpmn文件
// Get the site name and dataLists
var site = siteService.getSite("Testing");
var dataLists = site.getContainer("dataLists");
// Check for data list existence
if (!dataLists) {
var dataLists = site.createNode("dataLists", "cm:folder");
var dataListProps = new Array(1);
dataListProps["st:componentId"] = "dataLists";
dataLists.addAspect("st:siteContainer", dataListProps);
dataLists.save();
}
var orpList = dataLists.childByNamePath("orplist1");
if (!orpList) {
var orpList = dataLists.createNode("orplist1","dl:dataList");
// tells Share which type of items to create
orpList.properties["dl:dataListItemType"] = "orpdl:orpDataListModel";
orpList.save();
var orpListProps = [];
orpListProps["cm:title"] = "ORP List";
orpListProps["cm:description"] = "A contact list generated by a javascript.";
orpList.addAspect("cm:titled", orpListProps);
}
var opportunity = orpList.createNode(null, "orpdl:orpDataListModel")
opportunity.properties["orpdl:name"] = "Florian";
opportunity.save();
模型摘录
<model name="orpdl:orpDataListModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<namespaces>
<namespace uri="http://www.test.com/model/orpDataListModel/1.0" prefix="orpdl" />
</namespaces>
Context bean
<!-- Data List Model Registration -->
<bean id="${project.artifactId}_dictionaryBootstrapOrp" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/module/${project.artifactId}/model/orpDataListModel.xml</value>
</list>
</property>
</bean>
错误
org.activiti.engine.ActivitiException:调用时出现异常 TaskListener:调用TaskListener时出现异常:06010019失败 执行提供的脚本:Class {http://www.test.com/model/orpDataListModel/1.0} orpDataListModel有 未在数据字典中定义
数据列表可以完全独立运行。这有什么问题?
答案 0 :(得分:1)
问题在于我的Javascript,因为您需要使用类型名称而不是型号名称。这是完成的工作代码,其中 orp:orpList 是模型中定义的类型名称:
// Get the site name and dataLists
var site = siteService.getSite("Testing");
var dataLists = site.getContainer("dataLists");
// Check for data list existence
if (!dataLists) {
var dataLists = site.createNode("dataLists", "cm:folder");
var dataListProps = new Array(1);
dataListProps["st:componentId"] = "dataLists";
dataLists.addAspect("st:siteContainer", dataListProps);
dataLists.save();
}
var orpList = dataLists.childByNamePath("orplist1");
if (!orpList) {
var orpList = dataLists.createNode("orplist1","dl:dataList");
// tells Share which type of items to create
orpList.properties["dl:dataListItemType"] = "orpdl:orpList";
orpList.save();
var orpListProps = [];
orpListProps["cm:title"] = "ORP List";
orpListProps["cm:description"] = "A contact list generated by a javascript.";
orpList.addAspect("cm:titled", orpListProps);
}
var opportunity = orpList.createNode(null, "orpdl:orpList")
opportunity.properties["orpdl:name"] = "Florian";
opportunity.save();
答案 1 :(得分:1)
Alfresco模型可以包含0种或更多种类型,以及约束,方面等其他内容。您可以在Alfresco documentation on the subject
中阅读有关内容建模的更多信息因此,当您创建类型或将类型设置到数据列表时,您需要使用类型的ID,而不是它来自的模型
因此,您的两个有问题的行是:
orpList.properties["dl:dataListItemType"] = "orpdl:orpDataListModel";
var opportunity = orpList.createNode(null, "orpdl:orpDataListModel");
对于qname orpdl:orpList
短的自定义数据列表类型,应改为:
orpList.properties["dl:dataListItemType"] = "orpdl:orpList";
var opportunity = orpList.createNode(null, "orpdl:orpList");
Alfresco的某些部分验证您在创建时提供了有效类型,但并非全部。 Datalist项目类型是一个在使用前无法验证的区域,这就是为什么你得到了尽可能多的原因!