Today i was looking for a good way for get all documents that contains a particular attribute in alfresco using dotcmis.
I was thinking in:
- Use Ephesoft (http://www.ephesoft.com/) to capture documents.
- Connect Ephesoft with Alfresco using cmis integration.
- Configure document properties to match with a alfresco model (metadata document)
- Develop a module in my webApplication (asp.net) to search all document with a particular property(metadata); using dotcmis (http://chemistry.apache.org/dotnet/dotcmis.html)
I finded:
- How create a session.
- How list tree folder
except... How verify every document if have setted a particular property (metadata)?
Do you know how do it?
Thanks pablochan! In this moment, i have:
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;
}
Where can i see a list of the virtual tables and their columns of CMIS Alfresco?
Thanks!
You can send a CMIS query to Alfresco. I recommend reading about CMIS Query Language first. After that read the dotCMIS guide.
Let's say that you have a type or aspect defined with your field e.g. my:aspect and my:field.
The query could look like this:
The code would be:
EDIT:
Ok, I read your code and there is one more thing I didn't mention. The reason you're not seeing your field (account number) is because the query result contains only the fields defined for the queried type/aspect (in this case cmis:object). If you want to query against "AccountNumber" you need to know the type/aspect it's defined in.
Let's say that "AccountNumber" is defined in the type "custom:myType". The query would look like this:
The result will contain "AccountNumber".
If the field is defined in an aspect, you can do a query with a JOIN: http://wiki.alfresco.com/wiki/CMIS#Aspect_Query
I hope this helps.