public CMISType GetTypeByPath(string path) { CMISType result = new CMISType("3", path); result.Versionable = VersionableType; return(result); }
public List <CMISProperty> GetPropertyDefinitions(CMISType type) { return(new List <CMISProperty>() { new CMISProperty() // Should be ignored by LoadProperties() { Id = "cmis:name", DisplayName = "Name", Type = CMISClientType.String, }, new CMISProperty() { Id = "Field-String", DisplayName = "Prop 1", Type = CMISClientType.String, }, new CMISProperty() { Id = "Field-Integer", DisplayName = "Prop 2", Type = CMISClientType.Integer, }, new CMISProperty() { Id = "Field-Boolean", DisplayName = "Prop 3", Type = CMISClientType.Boolean, }, new CMISProperty() { Id = "Field-Decimal", DisplayName = "Prop 4", Type = CMISClientType.Decimal, }, new CMISProperty() { Id = "Field-DateTime", DisplayName = "Prop 5", Type = CMISClientType.DateTime, }, new CMISProperty() { Id = "Field-DateTime", DisplayName = "Prop 5", Type = CMISClientType.DateTime, IsMulti = true, }, }); }
public CMISType GetRootType() { CMISType result = new CMISType("1", "Root type"); result.Versionable = VersionableType; return(result); }
public CMISType GetTypeFromId(string typeId) { CMISType result = new CMISType("type-1", "Root type"); result.Versionable = VersionableType; return(result); }
private void storeAndVerifyDocument( CMISFolder folder, string documentName, CMISType type, List <CMISTestProperty> properties) { CultureInfo ci = new CultureInfo("en-US"); Dictionary <string, object> props = new Dictionary <string, object>(); foreach (CMISTestProperty ctp in properties) { props[ctp.Property.Id] = ctp.Property.ConvertValue(ctp.TestValue, ci); } bool description = type.Type.PropertyDefinitions.Where(n => n.Id == "cmis:description").Count() > 0; if (description) { props["cmis:description"] = "Hello World"; } props["cmis:objectTypeId"] = type.Id; cmisClient.StoreDocument(folder, sampleDocument, documentName, props, null); CMISDocument cmisDocument = cmisClient.GetDocument(folder, documentName); if (description) { Assert.AreEqual("Hello World", cmisClient.GetPropertyValue(cmisDocument, "cmis:description")); } //foreach (CMISProperty p in properties.Keys) foreach (CMISTestProperty ctp in properties) { object expected = ctp.TestValue; object result = cmisClient.GetPropertyValue(cmisDocument, ctp.Property.Id); Assert.AreEqual(expected, result); break; } }
public override List <TVIModel> GetChildren() { List <TVIModel> result = new List <TVIModel>(); foreach (CMISType co in CMISType.GetAllSubTypes()) { result.Add((TVIModel) new CMISTypeNode(this, co)); } return(result); }
public CMISType GetTypeFromId(string typeId) { CMISType result = GetRootType(); result.Type = session.GetTypeDefinition(typeId) as IObjectType; result.Id = result.Type.Id; result.DisplayName = result.Type.DisplayName; result.Versionable = (result.Type as IDocumentType).IsVersionable; return(result); }
private void t05_Versionable(CMISTestSystem con) { if (!con.VersionableTest) { return; } initializeClient(con); CMISType type = cmisClient.GetTypeFromId(con.TypesType); Assert.IsTrue(type.Versionable != true); type = cmisClient.GetTypeFromId(con.VersioningType); Assert.IsTrue(type.Versionable == true); }
private void t04_Documents(CMISTestSystem con) { initializeClient(con); string checkinComment = "Test check-in comment"; CMISFolder folder = cmisClient.GetFolderFromPath(con.SubFolder); folder = cmisClient.GetSubfolder(folder, sieeSubPath, con.FolderType); CMISType type = cmisClient.GetTypeFromId(con.StoreType); deleteDocument(folder, documentName); storeAndVerifyDocument(folder, documentName, type, con.Properties); if (con.VersioningType != null) { CMISDocument cmisDocument; deleteDocument(folder, documentName); Dictionary <string, object> props = new Dictionary <string, object>(); props["cmis:objectTypeId"] = cmisClient.GetTypeFromId(con.VersioningType).Id; cmisClient.StoreDocument(folder, sampleDocument, documentName, props, true); cmisDocument = cmisClient.GetDocument(folder, documentName); Assert.AreEqual(con.V1_Major, getVersionString(cmisDocument)); cmisClient.UpdateDocument(folder, sampleDocument, documentName, props, true, checkinComment); cmisDocument = cmisClient.GetObjectOfLatestVersion(cmisDocument, major: true); Assert.AreEqual(con.V2_Major, getVersionString(cmisDocument)); Assert.AreEqual(checkinComment, cmisClient.GetCheckinComent(cmisDocument)); if (con.SupportsMinorVersions) { deleteDocument(folder, documentName); cmisClient.StoreDocument(folder, sampleDocument, documentName, props, false); cmisDocument = cmisClient.GetDocument(folder, documentName); Assert.AreEqual(con.V1_Minor, getVersionString(cmisDocument)); cmisClient.UpdateDocument(folder, sampleDocument, documentName, props, false, checkinComment); cmisDocument = cmisClient.GetObjectOfLatestVersion(cmisDocument, major: false); Assert.AreEqual(con.V2_Minor, getVersionString(cmisDocument)); Assert.AreEqual(checkinComment, cmisClient.GetCheckinComent(cmisDocument)); } } deleteDocument(folder, documentName); cmisClient.DeleteFolder(folder); }
private void t06_Performance(CMISTestSystem con) { if (!runPerformaceTest) { return; } initializeClient(con); string documentName = "Sample document"; string folderName = con.SubFolder + "/" + sieeSubPath; CMISFolder folder = cmisClient.GetSubfolder(cmisClient.GetRootFolder(), folderName, con.FolderType); CMISType type = cmisClient.GetTypeFromId(con.StoreType); deleteDocument(folder, documentName); // pre-upload a few documents to warm up the system ... for (int i = 0; i != 5; i++) { doOneDocument(folder, documentName, type, con); } // do the real test Process p = Process.GetCurrentProcess(); long memBefore = p.PeakWorkingSet64 / 1000; int nofCycles = 100; int[] times = new int[nofCycles]; for (int i = 0; i != nofCycles; i++) { DateTime start = DateTime.Now; doOneDocument(folder, documentName, type, con); times[i] = (int)(DateTime.Now - start).TotalMilliseconds; Console.WriteLine(i + " = " + times[i]); } long memAfter = p.PeakWorkingSet64 / 1000; Assert.AreEqual(memBefore, memAfter); Assert.AreEqual(true, nofCycles > 20); double avgStart = average(times, 0, 9); double avgEnd = average(times, nofCycles - 10, nofCycles - 1); double deviation = Math.Abs(avgEnd - avgStart) / avgStart; Assert.AreEqual(true, deviation <= .25, "deviates (avgStart=" + avgStart + " ,avgEnd=" + avgEnd + ")"); }
private void t03_Types(CMISTestSystem con) { initializeClient(con); CMISType root = cmisClient.GetRootType(); Assert.AreEqual(con.RootType, root.Id); CMISType type = cmisClient.GetTypeFromId(con.TypesType); List <CMISProperty> props = cmisClient.GetPropertyDefinitions(type); Assert.AreEqual(con.NumberOfProperties, props.Count); foreach (CMISProperty p in con.ExpectedProperties) { CMISProperty p1 = props.Where(n => n.Id == p.Id).First(); Assert.AreEqual(p.DisplayName, p1.DisplayName); Assert.AreEqual(p.Type, p1.Type); } }
public List <CMISProperty> GetPropertyDefinitions(CMISType type) { List <CMISProperty> result = new List <CMISProperty>(); foreach (IPropertyDefinition p in type.Type.PropertyDefinitions) { if ((p.Updatability == Updatability.ReadWrite || p.Updatability == Updatability.OnCreate) && typeMap.Keys.Contains(p.PropertyType)) { result.Add(new CMISProperty() { Id = p.Id, DisplayName = p.DisplayName, Type = typeMap[p.PropertyType], IsMulti = p.Cardinality == Cardinality.Multi, }); } } return(result); }
public void LoadProperties() { Properties.Clear(); try { CMISTypeNode tn = (TVIViewModel.deSerialize(settings.SerializedTypePath.Last(), typeof(CMISTypeNode)) as CMISTypeNode); CMISType type = vm.CMISClient.GetTypeFromId(tn.Id); foreach (CMISProperty pd in vm.CMISClient.GetPropertyDefinitions(type)) { if (pd.Id != "cmis:name") { Properties.Add(pd); } } settings.SelectedType = type.Id; RaisePropertyChanged(PropertiesLoadedd_name); LoadedType = type; } catch (Exception e) { throw new Exception( "Could not load " + SelectedTypePath + ". Reason:\n" + e.Message); } }
} // for xml serializer public CMISTypeNode(CMISTypeNode parent, CMISType iType) { CMISType = iType; TypePath = parent == null ? iType.DisplayName : parent.TypePath + GetPathConcatenationString() + iType.DisplayName; }
private void doOneDocument(CMISFolder folder, string documentName, CMISType type, CMISTestSystem con) { storeAndVerifyDocument(folder, documentName, type, con.Properties); deleteDocument(folder, documentName); }