public CmisObject ToCmis(object o, bool includeRelationships) { CmisObject cmisObject = new CmisObject(); MediaContent content = (MediaContent)o; cmisObject.Id = ObjectService.GetObjectId(content); cmisObject.Properties = new CmisProperties() { Items = content.Keys.Select(key => CmisPropertyHelper.CreateProperty(key, content[key])).ToArray() }; cmisObject.Properties.Items = cmisObject.Properties.Items.Concat(new CmisProperty[] { CmisPropertyHelper.CreateCmisPropertyCreatedBy(new [] { content.UserId }), CmisPropertyHelper.CreateCmisPropertyCreationDate(new [] { content.UtcCreationDate }), CmisPropertyHelper.CreateCmisPropertyLastModificationDate(new [] { content.UtcLastModificationDate }), CmisPropertyHelper.CreateCmisPropertyName(new [] { content.UserKey }), CmisPropertyHelper.CreateCmisPropertyObjectId(new [] { cmisObject.Id }), CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new [] { "cmis:document" }), CmisPropertyHelper.CreateCmisPropertyObjectTypeId(new [] { content.FolderName }), }).ToArray(); if (includeRelationships) { var categories = Services.ServiceFactory.TextContentManager.QueryCategories(content.GetRepository(), content.FolderName, content.UUID); cmisObject.Relationship = categories.Select(it => it.Contents).SelectMany(it => it.Select(c => ObjectConvertor.ToCmis(c, includeRelationships))).ToArray(); } return(cmisObject); }
public object ToCms(CmisObject cmisObject) { TextContent content = new TextContent(); content.UUID = cmisObject.Id; if (cmisObject.Properties != null) { foreach (var property in cmisObject.Properties.Items) { content[property.LocalName] = CmisPropertyHelper.GetPropertyValue(property); } } return(content); }
public CmisObject ToCmis(object o, bool includeRelationships) { var textFolder = (TextFolder)o; CmisObject cmisObject = new CmisObject(); cmisObject.Id = ObjectService.GetObjectId(textFolder); cmisObject.Properties = new CmisProperties() { Items = new CmisProperty[] { CmisPropertyHelper.CreateCmisPropertyAllowedChildObjectTypeIds(null), CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new string[] { "cmis:folder" }), CmisPropertyHelper.CreateCmisPropertyCreatedBy(new string[] { textFolder.UserId }), CmisPropertyHelper.CreateCmisPropertyCreationDate(new DateTime[] { textFolder.UtcCreationDate == DateTime.MinValue? DateTime.UtcNow:textFolder.UtcCreationDate }), CmisPropertyHelper.CreateCmisPropertyLastModificationDate(new DateTime[] { DateTime.UtcNow }), CmisPropertyHelper.CreateCmisPropertyLastModifiedBy(new string[] { textFolder.UserId }), CmisPropertyHelper.CreateCmisPropertyName(new string[] { textFolder.Name }), CmisPropertyHelper.CreateCmisPropertyObjectId(new string[] { cmisObject.Id }), CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new string[] { "cmis:folder" }), CmisPropertyHelper.CreateCmisPropertyObjectTypeId(new string[] { textFolder.SchemaName }), CmisPropertyHelper.CreateCmisPropertyParentId(new string[] { textFolder.Parent == null?CmisFolderHelper.RootFolderName:textFolder.Parent.FullName }), CmisPropertyHelper.CreateCmisPropertyPath(new string[] { string.Join("/", textFolder.NamePath.ToArray()) }), new CmisPropertyString() { DisplayName = "Display Name", LocalName = "DispalyName", PropertyDefinitionId = "DisplayName", Value = new string[] { textFolder.DisplayName } }, new CmisPropertyString() { DisplayName = "Schema Name", LocalName = "SchemaName", PropertyDefinitionId = "SchemaName", Value = new string[] { textFolder.SchemaName } }, new CmisPropertyString() { DisplayName = "Category Folders", LocalName = "CategoryFolders", PropertyDefinitionId = "CategoryFolders", Value = new string[] { textFolder.CategoryFolders == null?"":string.Join(",", textFolder.CategoryFolders.ToArray()) } } } }; return(cmisObject); }
//public static T ToCms<T>(CmisObject cmisObject) //{ // return (T)(convertors[typeof(T)].ToCms(cmisObject)); //} public static CmisObject EmptyCmisObject() { return(new CmisObject() { Properties = new CmisProperties() { Items = new CmisProperty[] { CmisPropertyHelper.CreateCmisPropertyAllowedChildObjectTypeIds(null), CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new string[] { "cmis:empty" }), CmisPropertyHelper.CreateCmisPropertyCreatedBy(new string[] { "" }), CmisPropertyHelper.CreateCmisPropertyCreationDate(new DateTime[] { DateTime.UtcNow }), CmisPropertyHelper.CreateCmisPropertyLastModificationDate(new DateTime[] { DateTime.UtcNow }), CmisPropertyHelper.CreateCmisPropertyLastModifiedBy(new string[] { "" }), CmisPropertyHelper.CreateCmisPropertyName(new string[] { "" }), CmisPropertyHelper.CreateCmisPropertyObjectId(new string[] { "" }), CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new string[] { "cmis:empty" }), CmisPropertyHelper.CreateCmisPropertyObjectTypeId(new string[] { "" }) } } }); }
public static CmisObject CreateSystemFolderObject(string systemFolder, string rootFolder) { return(new CmisObject() { Id = systemFolder, Properties = new CmisProperties() { Items = new CmisProperty[] { CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new string[] { "cmis:folder" }), CmisPropertyHelper.CreateCmisPropertyCreatedBy(new string[] { "system" }), CmisPropertyHelper.CreateCmisPropertyCreationDate(new DateTime[] { DateTime.UtcNow }), CmisPropertyHelper.CreateCmisPropertyLastModificationDate(new DateTime[] { DateTime.UtcNow }), CmisPropertyHelper.CreateCmisPropertyLastModifiedBy(new string[] { "system" }), CmisPropertyHelper.CreateCmisPropertyName(new string[] { systemFolder }), CmisPropertyHelper.CreateCmisPropertyObjectId(new string[] { systemFolder }), CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new string[] { "cmis:folder" }), CmisPropertyHelper.CreateCmisPropertyObjectTypeId(new string[] { "" }), CmisPropertyHelper.CreateCmisPropertyParentId(new string[] { rootFolder }), CmisPropertyHelper.CreateCmisPropertyPath(new string[] { string.Join("/", new [] { rootFolder, systemFolder }) }) } } }); }