Author: fmui Date: Sun Feb 6 22:32:06 2011 New Revision: 1067790 URL: http://svn.apache.org/viewvc?rev=1067790&view=rev Log: - refactored namespaces - added query implementation
Modified: incubator/chemistry/dotcmis/trunk/DotCMIS.suo incubator/chemistry/dotcmis/trunk/DotCMIS/DotCMIS.csproj incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-linkcache.cs incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-writer.cs incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-caches.cs incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-impl.cs incubator/chemistry/dotcmis/trunk/DotCMIS/binding/converter.cs incubator/chemistry/dotcmis/trunk/DotCMIS/binding/http.cs incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-caches.cs incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-impl.cs incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-intf.cs incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objectfactory.cs incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objects.cs incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-types.cs incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-utils.cs incubator/chemistry/dotcmis/trunk/DotCMIS/data/data-impl.cs incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/EnumeratorTest.cs incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/SmokeTest.cs incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/TestFramework.cs Modified: incubator/chemistry/dotcmis/trunk/DotCMIS.suo URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS.suo?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== Binary files - no diff available. Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/DotCMIS.csproj URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/DotCMIS.csproj?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/DotCMIS.csproj (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/DotCMIS.csproj Sun Feb 6 22:32:06 2011 @@ -21,6 +21,7 @@ <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> + <DocumentationFile>bin\Debug\DotCMIS.XML</DocumentationFile> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -29,6 +30,7 @@ <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> + <DocumentationFile>bin\Release\DotCMIS.XML</DocumentationFile> </PropertyGroup> <ItemGroup> <Reference Include="System" /> Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-linkcache.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-linkcache.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-linkcache.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-linkcache.cs Sun Feb 6 22:32:06 2011 @@ -31,11 +31,11 @@ namespace DotCMIS.Binding.AtomPub private const int CacheSizeTypes = 100; private const int CacheSizeLinks = 400; - private ICache linkCache; - private ICache typeLinkCache; - private ICache collectionLinkCache; - private ICache templateCache; - private ICache repositoryLinkCache; + private IBindingCache linkCache; + private IBindingCache typeLinkCache; + private IBindingCache collectionLinkCache; + private IBindingCache templateCache; + private IBindingCache repositoryLinkCache; public LinkCache(BindingSession session) { Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-writer.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-writer.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-writer.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub-writer.cs Sun Feb 6 22:32:06 2011 @@ -83,7 +83,10 @@ namespace DotCMIS.Binding.AtomPub public void Write(Stream outStream) { - using (XmlWriter writer = XmlWriter.Create(outStream)) + XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); + xmlWriterSettings.Encoding = new UTF8Encoding(false); + + using (XmlWriter writer = XmlWriter.Create(outStream, xmlWriterSettings)) { // start doc writer.WriteStartDocument(); @@ -213,16 +216,17 @@ namespace DotCMIS.Binding.AtomPub public void Write(Stream outStream) { - using (XmlWriter writer = XmlWriter.Create(outStream)) + XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); + xmlWriterSettings.Encoding = new UTF8Encoding(false); + + using (XmlWriter writer = XmlWriter.Create(outStream, xmlWriterSettings)) { // start doc writer.WriteStartDocument(); // start query writer.WriteStartElement(AtomWriter.PrefixCMIS, AtomPubConstants.TagQuery, AtomPubConstants.NamespaceCMIS); - writer.WriteAttributeString("xmlns", AtomWriter.PrefixAtom, null, AtomPubConstants.NamespaceAtom); writer.WriteAttributeString("xmlns", AtomWriter.PrefixCMIS, null, AtomPubConstants.NamespaceCMIS); - writer.WriteAttributeString("xmlns", AtomWriter.PrefixRestAtom, null, AtomPubConstants.NamespaceRestAtom); // cmis:statement writer.WriteStartElement(AtomWriter.PrefixCMIS, AtomPubConstants.TagStatement, AtomPubConstants.NamespaceCMIS); Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs Sun Feb 6 22:32:06 2011 @@ -25,8 +25,9 @@ using DotCMIS.Binding.Services; using DotCMIS.CMISWebServicesReference; using DotCMIS.Data; using DotCMIS.Data.Extensions; -using DotCMIS.Exceptions; +using DotCMIS.Data.Impl; using DotCMIS.Enums; +using DotCMIS.Exceptions; namespace DotCMIS.Binding.AtomPub { Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-caches.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-caches.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-caches.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-caches.cs Sun Feb 6 22:32:06 2011 @@ -29,7 +29,7 @@ namespace DotCMIS.Binding { // --- base cache implementation --- - internal interface ICache + internal interface IBindingCache { void Initialize(string[] cacheLevelConfig); @@ -46,7 +46,7 @@ namespace DotCMIS.Binding void Unlock(); } - internal interface ICacheLevel + internal interface IBindingCacheLevel { void Initialize(IDictionary<string, string> cacheLevelConfig); @@ -55,11 +55,11 @@ namespace DotCMIS.Binding void Remove(string key); } - internal class Cache : ICache + internal class Cache : IBindingCache { private IList<Type> cacheLevels; private IList<IDictionary<string, string>> cacheLevelParameters; - private ICacheLevel root; + private IBindingCacheLevel root; private string name; private object cacheLock = new object(); @@ -125,7 +125,7 @@ namespace DotCMIS.Binding Lock(); try { - ICacheLevel cacheLevel = root; + IBindingCacheLevel cacheLevel = root; // follow the branch for (int i = 0; i < keys.Length - 1; i++) @@ -140,7 +140,7 @@ namespace DotCMIS.Binding } // next level - cacheLevel = (ICacheLevel)level; + cacheLevel = (IBindingCacheLevel)level; } cacheLevel[keys[keys.Length - 1]] = value; @@ -167,7 +167,7 @@ namespace DotCMIS.Binding Lock(); try { - ICacheLevel cacheLevel = root; + IBindingCacheLevel cacheLevel = root; // follow the branch for (int i = 0; i < keys.Length - 1; i++) @@ -178,7 +178,7 @@ namespace DotCMIS.Binding if (level == null) { return null; } // next level - cacheLevel = (ICacheLevel)level; + cacheLevel = (IBindingCacheLevel)level; } // get the value @@ -199,7 +199,7 @@ namespace DotCMIS.Binding Lock(); try { - ICacheLevel cacheLevel = root; + IBindingCacheLevel cacheLevel = root; // follow the branch for (int i = 0; i < keys.Length - 1; i++) @@ -210,7 +210,7 @@ namespace DotCMIS.Binding if (level == null) { return; } // next level - cacheLevel = (ICacheLevel)level; + cacheLevel = (IBindingCacheLevel)level; } cacheLevel.Remove(keys[keys.Length - 1]); @@ -230,7 +230,7 @@ namespace DotCMIS.Binding Lock(); try { - ICacheLevel cacheLevel = root; + IBindingCacheLevel cacheLevel = root; // follow the branch for (int i = 0; i < keys.Length - 1; i++) @@ -241,7 +241,7 @@ namespace DotCMIS.Binding if (level == null) { return i; } // next level - cacheLevel = (ICacheLevel)level; + cacheLevel = (IBindingCacheLevel)level; } return keys.Length; @@ -277,7 +277,7 @@ namespace DotCMIS.Binding throw new ArgumentException("Class '" + typeName + "' not found!", e); } - if (!typeof(ICacheLevel).IsAssignableFrom(levelType)) + if (!typeof(IBindingCacheLevel).IsAssignableFrom(levelType)) { throw new ArgumentException("Class '" + typeName + "' does not implement the ICacheLevel interface!"); } @@ -309,7 +309,7 @@ namespace DotCMIS.Binding } } - private ICacheLevel CreateCacheLevel(int level) + private IBindingCacheLevel CreateCacheLevel(int level) { if ((level < 0) || (level >= cacheLevels.Count)) { @@ -318,10 +318,10 @@ namespace DotCMIS.Binding // get the class and create an instance Type levelType = cacheLevels[level]; - ICacheLevel cacheLevel = null; + IBindingCacheLevel cacheLevel = null; try { - cacheLevel = (ICacheLevel)Activator.CreateInstance(levelType); + cacheLevel = (IBindingCacheLevel)Activator.CreateInstance(levelType); } catch (Exception e) { @@ -350,7 +350,7 @@ namespace DotCMIS.Binding } } - internal abstract class AbstractDictionaryCacheLevel : ICacheLevel + internal abstract class AbstractDictionaryCacheLevel : IBindingCacheLevel { protected static string NullKey = ""; @@ -567,7 +567,7 @@ namespace DotCMIS.Binding { private const int CacheSizeRepositories = 10; - private ICache cache; + private IBindingCache cache; public RepositoryInfoCache(BindingSession session) { @@ -611,7 +611,7 @@ namespace DotCMIS.Binding private const int CacheSizeRepositories = 10; private const int CacheSizeTypes = 100; - private ICache cache; + private IBindingCache cache; public TypeDefinitionCache(BindingSession session) { Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-impl.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-impl.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-impl.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/binding/binding-impl.cs Sun Feb 6 22:32:06 2011 @@ -18,14 +18,11 @@ */ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using DotCMIS.Binding; -using DotCMIS.Binding.Services; using System.Threading; -using DotCMIS.Exceptions; +using DotCMIS.Binding.Services; using DotCMIS.Data; using DotCMIS.Data.Extensions; +using DotCMIS.Exceptions; namespace DotCMIS.Binding.Impl { @@ -424,7 +421,7 @@ namespace DotCMIS.Binding.Impl if (!hasExtension && (result != null)) { RepositoryInfoCache cache = session.GetRepositoryInfoCache(); - foreach (RepositoryInfo rid in result) + foreach (IRepositoryInfo rid in result) { cache.Put(rid); } Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/binding/converter.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/binding/converter.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/binding/converter.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/binding/converter.cs Sun Feb 6 22:32:06 2011 @@ -1,5 +1,4 @@ -using DotCMIS.CMISWebServicesReference; -/* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,15 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -using DotCMIS.Data; -using DotCMIS.Data.Extensions; -using System.Collections.Generic; -using System.Xml; -using DotCMIS.Enums; using System; +using System.Collections.Generic; +using System.IO; using System.Reflection; +using System.Xml; using System.Xml.Serialization; -using System.IO; +using DotCMIS.CMISWebServicesReference; +using DotCMIS.Data; +using DotCMIS.Data.Extensions; +using DotCMIS.Data.Impl; +using DotCMIS.Enums; namespace DotCMIS.Binding { Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/binding/http.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/binding/http.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/binding/http.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/binding/http.cs Sun Feb 6 22:32:06 2011 @@ -20,13 +20,12 @@ using System; using System.Diagnostics; using System.IO; using System.Net; -using DotCMIS.Binding.Impl; +using System.Text; +using System.Web; using DotCMIS.Enums; using DotCMIS.Exceptions; -using System.Web; -using System.Text; -namespace DotCMIS.Binding +namespace DotCMIS.Binding.Impl { internal static class HttpUtils { Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-caches.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-caches.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-caches.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-caches.cs Sun Feb 6 22:32:06 2011 @@ -21,7 +21,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace DotCMIS.Client +namespace DotCMIS.Client.Impl.Cache { /// <summary> /// Client cache interface. @@ -42,7 +42,7 @@ namespace DotCMIS.Client /// <summary> /// Cache implementation that doesn't cache. /// </summary> - internal class NoCache : ICache + public class NoCache : ICache { public void Initialize(ISession session, IDictionary<string, string> parameters) { } public bool ContainsId(string objectId, string cacheKey) { return false; } Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-impl.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-impl.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-impl.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-impl.cs Sun Feb 6 22:32:06 2011 @@ -18,17 +18,16 @@ */ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Threading; using DotCMIS.Binding; +using DotCMIS.Binding.Services; +using DotCMIS.Client.Impl.Cache; using DotCMIS.Data; -using DotCMIS.Exceptions; -using System.Threading; +using DotCMIS.Data.Impl; using DotCMIS.Enums; -using DotCMIS.Data.Extensions; -using DotCMIS.Binding.Services; +using DotCMIS.Exceptions; -namespace DotCMIS.Client +namespace DotCMIS.Client.Impl { /// <summary> /// Session factory implementation. @@ -550,7 +549,36 @@ namespace DotCMIS.Client } public IItemEnumerable<IQueryResult> Query(string statement, bool searchAllVersions, IOperationContext context) - { throw new CmisNotSupportedException("Client not implemented!"); } + { + IDiscoveryService service = Binding.GetDiscoveryService(); + IOperationContext ctxt = new OperationContext(context); + + PageFetcher<IQueryResult>.FetchPage fetchPageDelegate = delegate(long maxNumItems, long skipCount) + { + // fetch the data + IObjectList resultList = service.Query(RepositoryId, statement, searchAllVersions, ctxt.IncludeAllowableActions, + ctxt.IncludeRelationships, ctxt.RenditionFilterString, maxNumItems, skipCount, null); + + // convert query results + IList<IQueryResult> page = new List<IQueryResult>(); + if (resultList.Objects != null) + { + foreach (IObjectData objectData in resultList.Objects) + { + if (objectData == null) + { + continue; + } + + page.Add(ObjectFactory.ConvertQueryResult(objectData)); + } + } + + return new PageFetcher<IQueryResult>.Page<IQueryResult>(page, resultList.NumItems, resultList.HasMoreItems); + }; + + return new CollectionEnumerable<IQueryResult>(new PageFetcher<IQueryResult>(DefaultContext.MaxItemsPerPage, fetchPageDelegate)); + } public IChangeEvents GetContentChanges(string changeLogToken, bool includeProperties, long maxNumItems) { @@ -600,12 +628,12 @@ namespace DotCMIS.Client IObjectType type = null; if (source is ICmisObject) { - type = ((ICmisObject)source).Type; + type = ((ICmisObject)source).ObjectType; } else { ICmisObject sourceObj = GetObject(source); - type = sourceObj.Type; + type = sourceObj.ObjectType; } if (type.BaseTypeId != BaseTypeId.CmisDocument) Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-intf.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-intf.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-intf.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-intf.cs Sun Feb 6 22:32:06 2011 @@ -37,6 +37,9 @@ namespace DotCMIS.Client ISession CreateSession(); } + /// <summary> + /// Session interface. + /// </summary> public interface ISession { void Clear(); @@ -252,7 +255,7 @@ namespace DotCMIS.Client DateTime? LastModificationDate { get; } BaseTypeId BaseTypeId { get; } IObjectType BaseType { get; } - IObjectType Type { get; } + IObjectType ObjectType { get; } string ChangeToken { get; } } @@ -408,13 +411,31 @@ namespace DotCMIS.Client public interface IQueryResult { + IPropertyData this[string queryName] { get; } + IList<IPropertyData> Properties { get; } + IPropertyData GetPropertyById(string propertyId); + object GetPropertyValueByQueryName(string queryName); + object GetPropertyValueById(string propertyId); + IList<object> GetPropertyMultivalueByQueryName(string queryName); + IList<object> GetPropertyMultivalueById(string propertyId); + IAllowableActions AllowableActions { get; } + IList<IRelationship> Relationships { get; } + IList<IRendition> Renditions { get; } } - public interface IChangeEvent + public interface IChangeEvent : IChangeEventInfo { + string ObjectId { get; } + IDictionary<string, IList<object>> Properties { get; } + IList<string> PolicyIds { get; } + IAcl Acl { get; } } public interface IChangeEvents { + string LatestChangeLogToken { get; } + IList<IChangeEvent> ChangeEvents { get; } + bool HasMoreItems { get; } + long getTotalNumItems { get; } } } Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objectfactory.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objectfactory.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objectfactory.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objectfactory.cs Sun Feb 6 22:32:06 2011 @@ -17,16 +17,15 @@ * under the License. */ using System; +using System.Collections; using System.Collections.Generic; -using System.Linq; -using System.Text; -using DotCMIS.Data; using System.IO; +using DotCMIS.Data; +using DotCMIS.Data.Impl; using DotCMIS.Enums; using DotCMIS.Exceptions; -using System.Collections; -namespace DotCMIS.Client +namespace DotCMIS.Client.Impl { public class ObjectFactory : IObjectFactory { @@ -305,7 +304,7 @@ namespace DotCMIS.Client throw new ArgumentException("Properties must be set!"); } - return new List<IPropertyData>(properties.PropertyList); + return properties.PropertyList; } // objects @@ -333,7 +332,15 @@ namespace DotCMIS.Client } } - public IQueryResult ConvertQueryResult(IObjectData objectData) { return null; } + public IQueryResult ConvertQueryResult(IObjectData objectData) { + if (objectData == null) + { + throw new ArgumentException("Object data is null!"); + } + + return new QueryResult(session, objectData); + } + public IChangeEvent ConvertChangeEvent(IObjectData objectData) { return null; } public IChangeEvents ConvertChangeEvents(String changeLogToken, IObjectList objectList) { return null; } } Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objects.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objects.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objects.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-objects.cs Sun Feb 6 22:32:06 2011 @@ -18,18 +18,17 @@ */ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading; using DotCMIS.Binding; -using DotCMIS.Client; +using DotCMIS.Binding.Services; using DotCMIS.Data; using DotCMIS.Data.Extensions; +using DotCMIS.Data.Impl; using DotCMIS.Enums; using DotCMIS.Exceptions; -using DotCMIS.Binding.Services; -namespace DotCMIS.Client +namespace DotCMIS.Client.Impl { /// <summary> /// CMIS object base class. @@ -41,7 +40,7 @@ namespace DotCMIS.Client protected ICmisBinding Binding { get { return Session.Binding; } } private IObjectType objectType; - protected IObjectType ObjectType + public IObjectType ObjectType { get { @@ -81,7 +80,6 @@ namespace DotCMIS.Client private IList<IRelationship> relationships; private IDictionary<ExtensionLevel, IList<ICmisExtensionElement>> extensions; - private object objectLock = new object(); protected void Initialize(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context) @@ -304,8 +302,6 @@ namespace DotCMIS.Client public string ChangeToken { get { return GetPropertyValue(PropertyIds.ChangeToken) as string; } } - public IObjectType Type { get { return ObjectType; } } - public IList<IProperty> Properties { get @@ -1657,4 +1653,155 @@ namespace DotCMIS.Client return session.Binding.GetObjectService().GetContentStream(session.RepositoryInfo.Id, objectId, StreamId, null, null, null); } } + + public class QueryResult : IQueryResult + { + private IDictionary<string, IPropertyData> propertiesById; + private IDictionary<string, IPropertyData> propertiesByQueryName; + + public QueryResult(ISession session, IObjectData objectData) + { + if (objectData != null) + { + IObjectFactory of = session.ObjectFactory; + + // handle properties + if (objectData.Properties != null) + { + Properties = new List<IPropertyData>(); + propertiesById = new Dictionary<string, IPropertyData>(); + propertiesByQueryName = new Dictionary<string, IPropertyData>(); + + IList<IPropertyData> queryProperties = of.ConvertQueryProperties(objectData.Properties); + + foreach (IPropertyData property in queryProperties) + { + Properties.Add(property); + if (property.Id != null) + { + propertiesById[property.Id] = property; + } + if (property.QueryName != null) + { + propertiesByQueryName[property.QueryName] = property; + } + } + } + + // handle allowable actions + AllowableActions = objectData.AllowableActions; + + // handle relationships + if (objectData.Relationships != null) + { + Relationships = new List<IRelationship>(); + foreach (IObjectData rod in objectData.Relationships) + { + IRelationship relationship = of.ConvertObject(rod, session.DefaultContext) as IRelationship; + if (relationship != null) + { + Relationships.Add(relationship); + } + } + } + + // handle renditions + if (objectData.Renditions != null) + { + Renditions = new List<IRendition>(); + foreach (IRenditionData rd in objectData.Renditions) + { + Renditions.Add(of.ConvertRendition(null, rd)); + } + } + } + } + + public IPropertyData this[string queryName] + { + get + { + if (queryName == null) + { + return null; + } + + IPropertyData result; + if (propertiesByQueryName.TryGetValue(queryName, out result)) + { + return result; + } + + return null; + } + } + + public IList<IPropertyData> Properties { get; protected set; } + + public IPropertyData GetPropertyById(string propertyId) + { + if (propertyId == null) + { + return null; + } + + IPropertyData result; + if (propertiesById.TryGetValue(propertyId, out result)) + { + return result; + } + + return null; + } + + public object GetPropertyValueByQueryName(string queryName) + { + IPropertyData property = this[queryName]; + if (property == null) + { + return null; + } + + return property.FirstValue; + } + + public object GetPropertyValueById(string propertyId) + { + IPropertyData property = GetPropertyById(propertyId); + if (property == null) + { + return null; + } + + return property.FirstValue; + } + + public IList<object> GetPropertyMultivalueByQueryName(string queryName) + { + IPropertyData property = this[queryName]; + if (property == null) + { + return null; + } + + return property.Values; + } + + public IList<object> GetPropertyMultivalueById(string propertyId) + { + IPropertyData property = GetPropertyById(propertyId); + if (property == null) + { + return null; + } + + return property.Values; + } + + public IAllowableActions AllowableActions { get; protected set; } + + public IList<IRelationship> Relationships { get; protected set; } + + public IList<IRendition> Renditions { get; protected set; } + } } \ No newline at end of file Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-types.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-types.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-types.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-types.cs Sun Feb 6 22:32:06 2011 @@ -22,8 +22,9 @@ using System.Linq; using System.Text; using DotCMIS.Enums; using DotCMIS.Data; +using DotCMIS.Data.Impl; -namespace DotCMIS.Client +namespace DotCMIS.Client.Impl { /// <summary> /// Helper for all type implementations. Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-utils.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-utils.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-utils.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/client/client-utils.cs Sun Feb 6 22:32:06 2011 @@ -23,7 +23,7 @@ using System.Text; using DotCMIS.Enums; using System.Collections; -namespace DotCMIS.Client +namespace DotCMIS.Client.Impl { /// <summary> /// Operation context implementation. Modified: incubator/chemistry/dotcmis/trunk/DotCMIS/data/data-impl.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMIS/data/data-impl.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMIS/data/data-impl.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMIS/data/data-impl.cs Sun Feb 6 22:32:06 2011 @@ -23,7 +23,7 @@ using System.Text; using DotCMIS.Data.Extensions; using DotCMIS.Enums; -namespace DotCMIS.Data +namespace DotCMIS.Data.Impl { public class RepositoryInfo : ExtensionsData, IRepositoryInfo { Modified: incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/EnumeratorTest.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/EnumeratorTest.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/EnumeratorTest.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/EnumeratorTest.cs Sun Feb 6 22:32:06 2011 @@ -18,6 +18,7 @@ */ using System.Collections.Generic; using DotCMIS.Client; +using DotCMIS.Client.Impl; using NUnit.Framework; namespace DotCMISUnitTest Modified: incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/SmokeTest.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/SmokeTest.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/SmokeTest.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/SmokeTest.cs Sun Feb 6 22:32:06 2011 @@ -16,14 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; +using DotCMIS; using DotCMIS.Client; +using DotCMIS.Client.Impl; using DotCMIS.Enums; -using DotCMIS; +using NUnit.Framework; +using System; namespace DotCMISUnitTest { @@ -128,7 +127,7 @@ namespace DotCMISUnitTest } [Test] - public void SmokeRootFolder() + public void SmokeTestRootFolder() { ICmisObject rootFolderObject = Session.GetRootFolder(); @@ -144,6 +143,30 @@ namespace DotCMISUnitTest Assert.NotNull(rootFolder.AllowableActions); Assert.True(rootFolder.AllowableActions.Actions.Contains(Actions.CanGetProperties)); Assert.False(rootFolder.AllowableActions.Actions.Contains(Actions.CanGetFolderParent)); + + IItemEnumerable<ICmisObject> children = rootFolder.GetChildren(); + Assert.NotNull(children); + foreach (ICmisObject child in children) + { + Assert.NotNull(child); + Assert.NotNull(child.Id); + Assert.NotNull(child.Name); + Console.WriteLine(child.Name + " (" + child.Id + ")"); + } + } + + [Test] + public void SmokeTestQuery() + { + IItemEnumerable<IQueryResult> qr = Session.Query("SELECT * FROM cmis:document", false); + Assert.NotNull(qr); + + foreach (IQueryResult hit in qr) + { + Assert.NotNull(hit); + Assert.NotNull(hit["cmis:objectId"]); + Console.WriteLine(hit.GetPropertyValueById(PropertyIds.Name) + " (" + hit.GetPropertyValueById(PropertyIds.ObjectId) + ")"); + } } } } Modified: incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/TestFramework.cs URL: http://svn.apache.org/viewvc/incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/TestFramework.cs?rev=1067790&r1=1067789&r2=1067790&view=diff ============================================================================== --- incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/TestFramework.cs (original) +++ incubator/chemistry/dotcmis/trunk/DotCMISUnitTest/TestFramework.cs Sun Feb 6 22:32:06 2011 @@ -22,11 +22,13 @@ using System.Net; using System.Text; using DotCMIS; using DotCMIS.Binding; +using DotCMIS.Client; +using DotCMIS.Client.Impl; using DotCMIS.Data; +using DotCMIS.Data.Impl; using DotCMIS.Enums; using DotCMIS.Exceptions; using NUnit.Framework; -using DotCMIS.Client; namespace DotCMISUnitTest {