【问题标题】:Get All documents that contains a particular attribute in Alfresco using dotcmis使用 dotcmis 获取 Alfresco 中包含特定属性的所有文档
【发布时间】:2014-02-10 04:12:39
【问题描述】:

今天我正在寻找一种使用 dotcmis 在 alfresco 中获取包含特定属性的所有文档的好方法。

我在想:

  • 使用 Ephesoft (http://www.ephesoft.com/) 捕获文档。
  • 使用 cmis 集成将 Ephesoft 与 Alfresco 连接起来。
  • 配置文档属性以匹配 alfresco 模型(元数据文档)
  • 在我的 webApplication (asp.net) 中开发一个模块来搜索所有具有特定属性的文档(元数据);使用 dotcmis (http://chemistry.apache.org/dotnet/dotcmis.html)

我找到了:

  • 如何创建会话。
  • 如何列出树形文件夹

除了...如何验证每个文档是否设置了特定属性(元数据)?

你知道怎么做吗?


谢谢帕布罗坎! 在这一刻,我有:

public ISession Connect(string user, string password, string servicesUrl, string repositoryId)
    {
        IDictionary<string, string> parameter = new Dictionary<string, string>();

        parameter.Add(DotCMIS.SessionParameter.User, user);
        parameter.Add(DotCMIS.SessionParameter.Password, password);
        parameter.Add(DotCMIS.SessionParameter.BindingType, DotCMIS.BindingType.WebServices);
        parameter.Add(DotCMIS.SessionParameter.WebServicesAclService, (servicesUrl + "ACLService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.WebServicesDiscoveryService, (servicesUrl + "DiscoveryService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.WebServicesMultifilingService, (servicesUrl + "MultiFilingService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.WebServicesNavigationService, (servicesUrl + "NavigationService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.WebServicesObjectService, (servicesUrl + "ObjectService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.WebServicesPolicyService, (servicesUrl + "PolicyService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.WebServicesRelationshipService, (servicesUrl + "RelationshipService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.WebServicesRepositoryService, (servicesUrl + "RepositoryService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.WebServicesVersioningService, (servicesUrl + "VersioningService?wsdl").ToString());
        parameter.Add(DotCMIS.SessionParameter.RepositoryId, (repositoryId));

        ISessionFactory factory = DotCMIS.Client.Impl.SessionFactory.NewInstance();
        return factory.CreateSession(parameter);
    }

    public List<CMISIntegrationResponse> GetFiles(CMISIntegrationRequest request)
    {
        List<CMISIntegrationResponse> cmisIntegrationResponseList = new List<CMISIntegrationResponse>();

        ISession session = Connect(request.UserName, request.Password, request.ServicesUrl, request.RepositoryId);

        IItemEnumerable<IQueryResult> result = session.Query(@"SELECT
                                                               cmis:name, cmis:objectId, cmis:baseTypeId, cmis:objectTypeId, cmis:createdBy,
                                                               cmis:lastModifiedBy, cmis:lastModificationDate,cmis:contentStreamMimeType,
                                                               cmis:contentStreamFileName,cmis:contentStreamId,cmis:contentStreamLength
                                                               FROM cmis:document
                                                               ORDER BY
                                                               cmis:name, cmis:createdBy", false);

        foreach(QueryResult item in result) 
        {
            if (item.AllowableActions.Actions.Contains(DotCMIS.Actions.CanGetContentStream))
            {
                foreach (DotCMIS.Data.IPropertyData property in item.Properties)
                {

                    /*AccountNumber will be a property/metadata of any document
                      In this point i can not see any property/metadata called  "AccountNumber"
                     */

                    if (property.DisplayName.Equals("AccountNumber"))
                    {
                        CMISIntegrationResponse response = new CMISIntegrationResponse();
                        response.Name = item.GetPropertyValueByQueryName("cmis:name").ToString();
                        response.ObjectId = item.GetPropertyValueByQueryName("cmis:objectId").ToString();
                        response.BaseTypeId = item.GetPropertyValueByQueryName("cmis:baseTypeId").ToString();
                        response.ObjectTypeId = item.GetPropertyValueByQueryName("cmis:objectTypeId").ToString();
                        response.CreatedBy = item.GetPropertyValueByQueryName("cmis:createdBy").ToString();
                        response.LastModifiedBy = item.GetPropertyValueByQueryName("cmis:lastModifiedBy").ToString();
                        response.LastModificationDate = item.GetPropertyValueByQueryName("cmis:lastModificationDate").ToString();
                        response.ContentStreamMimeType = item.GetPropertyValueByQueryName("cmis:contentStreamMimeType").ToString();
                        response.ContentStreamFileName = item.GetPropertyValueByQueryName("cmis:contentStreamFileName").ToString();
                        response.ContentStreamId = item.GetPropertyValueByQueryName("cmis:contentStreamId").ToString();
                        response.ContentStreamLength = item.GetPropertyValueByQueryName("cmis:contentStreamLength").ToString();

                        cmisIntegrationResponseList.Add(response);
                    }
                }
            }
        }

        session.Clear();
        return cmisIntegrationResponseList;
    }

在哪里可以看到 CMIS Alfresco 的虚拟表及其列的列表?

谢谢!

【问题讨论】:

    标签: .net alfresco cmis dotcmis


    【解决方案1】:

    您可以向 Alfresco 发送 CMIS 查询。我推荐reading about CMIS Query Language first。之后read the dotCMIS guide

    假设您的字段定义了一个类型或方面,例如my:aspect 和 my:field。

    查询可能如下所示:

    SELECT * FROM my:aspect WHERE my:field = "some value"
    

    代码是:

    session.Query("SELECT * FROM my:aspect WHERE my:field = 'some value'", false);
    

    编辑:

    好的,我阅读了您的代码,还有一件事我没有提到。您没有看到您的字段(帐号)的原因是查询结果仅包含为查询类型/方面定义的字段(在本例中为 cmis:object)。如果你想查询“AccountNumber”,你需要知道它定义的类型/方面。

    假设“AccountNumber”在“custom:myType”类型中定义。查询如下所示:

    SELECT * from custom:myType
    

    结果将包含“AccountNumber”。

    如果该字段是在一个方面中定义的,您可以使用 JOIN 进行查询:http://wiki.alfresco.com/wiki/CMIS#Aspect_Query

    我希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      在哪里可以看到 CMIS 的虚拟表及其列的列表 露天?

      最好的方法是从 Apache Chemistry 下载 OpenCMIS Workbench。启动它,连接到 Alfresco,然后单击 Types。然后,工作台将显示存储库知道的类型的分层列表。

      如果您随后单击您感兴趣的特定类型,Workbench 将显示该类型的属性。如果你滚动你会看到一个“可查询”列。如果该列为真,您可以编写查询来测试该属性的值。在查询中使用属性的“查询名称”。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-01-07
        • 2016-01-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-25
        • 1970-01-01
        相关资源
        最近更新 更多