Alfresco: Class 尚未在数据字典中定义

Alfresco: Class has not been defined in the data dictionary

我正在使用 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>

上下文 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: Exception while invoking TaskListener: Exception while invoking TaskListener: 06010019 Failed to execute supplied script: Class {http://www.test.com/model/orpDataListModel/1.0}orpDataListModel has not been defined in the data dictionary

数据列表自行完美运行。这里有什么问题?

问题出在我的 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();

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 的一些位会验证您在创建时提供的类型是否有效,但不是全部。数据列表项目类型是一个在使用之前不会验证的区域,这就是为什么你能做到这一点!