You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Paul Santa Maria <pa...@rgbprojects.com> on 2015/11/27 22:09:13 UTC

Re[2]: Unable to access "Choices" in DotCMIS 0.7

Thank you, Florian!

The problem was that I needed to cast the property definition I was 
looking for to "IPropertyStringDefinition" before I could see the choice 
list.

Here is the corrected, working code (in C# - VB.Net will work exactly 
the same):

        private void getChoiceList(string docClassName, string propName)
         {
             logMsg("Querying TypeDefinition(" + docClassName + ")...");
             ITypeDefinition docClassDef = 
m_session.GetTypeDefinition(docClassName);

             logMsg("Searching for PropertyDefinition(" + propName + 
")...");
             IPropertyDefinition propDef = null;
             foreach (IPropertyDefinition pd in 
docClassDef.PropertyDefinitions)
             {
                 if (pd.Id.Equals(propName))
                 {
                     propDef = pd;
                     break;
                 }
             }

             logMsg("Choices:");
             IPropertyStringDefinition stringPropDef = 
(IPropertyStringDefinition)propDef;
             int i = 0;
             foreach (IChoice<string> ch in stringPropDef.Choices)
             {
                 logMsg("  ch[" + i + "]: " + ch.DisplayName + "=" + 
ch.Value);
                 i++;
             }
         }

     - Output =>
11/27/15 13:00:09 Querying TypeDefinition(RGBClass2)...
11/27/15 13:00:09 Searching for PropertyDefinition(RGBChoiceList)...
11/27/15 13:00:10 Choices:
11/27/15 13:00:10   ch[0]: 
Joe=System.Collections.Generic.List`1[System.String]
11/27/15 13:00:10   ch[1]: 
Dan=System.Collections.Generic.List`1[System.String]
11/27/15 13:00:10   ch[2]: 
Paul=System.Collections.Generic.List`1[System.String]
Problem solved - thank you!


------ Original Message ------
From: "Florian Müller" <fm...@apache.org>
To: "Paul Santa Maria" <pa...@rgbprojects.com>
Cc: dev@chemistry.apache.org
Sent: 11/27/2015 4:39:41 AM
Subject: Re: Unable to access "Choices" in DotCMIS 0.7

>Hi Paul,
>
>I don't know much ab VB. In C# the class definition of 
>PropertyStringDefinition looks like this:
>
>public class PropertyStringDefinition : PropertyDefinition, 
>IPropertyStringDefinition
>{
>     public IList<string> DefaultValue { get; set; }
>     public IList<IChoice<string>> Choices { get; set; }
>     public long? MaxLength { get; set; }
>}
>
>
>I would assume that "Choices" is also accessible in VB. I have no idea 
>why you can't see it.
>
>
>- Florian
>
>
>
>>I'm using DotCMIS version0.7 + AtomPub binding.  My server is
>>IBM/FileNet P8 5.2.  My client is VB.Net.
>>
>>I'm trying to access a ChoiceList I configured in my FileNet/P8 
>>repository.
>>
>>If I use Java/Chemistry, I can:
>>
>>   1. Query the FileNet Document class definition:
>>session.getTypeDefinition(docClassName)
>>
>>   2. Get the properties, and look for the property with the choice
>>list: docClassTypeDef.getPropertyDefinitions()/ropertyDefinition
>>propDef = propDefs.get(key);
>>
>>   3. Get the choice list from the property: List<?> ch = 
>>propDef.getChoices();
>>
>>PROBLEM:
>>There doesn't seem to be any equivalent to Java/Chemistry "List<?> ch
>>= propDef.getChoices();" in my v0.7 DotCMIS library.
>>
>>Specifically, I believe there should be a "Choices" property on
>>IPropertyDefinition.  I can't find one.
>>
>>ADDITiONAL NOTES:
>>1.  As I said above, the Java/Chemistry API seems to work fine.
>>      I can log on to my FileNet/P8 repository, query my DocClass, find
>>the DocProperty, call .getChoices(), and see the expected values in
>>the choice list.
>>
>>2. My DotCMIS/VB.Net client is successfully querying the FileNet/P8
>>repository for the DocClass and associated DocProperties: I can see
>>the choice list in the AtomPub XML:
>>
>>   ATOMPUB XML RETURNED FROM DOTCMIS QUERY:
>><?xml version="1.0" encoding="utf-8" standalone="yes"?>
>><atom:entry xmlns:app="http://www.w3.org/2007/app"
>>xmlns:atom="http://www.w3.org/2005/Atom"
>>xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/"
>>xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"
>>xmlns:p8ext="http://www.ibm.com/xmlns/prod/ecm/cmis/p8extensions"
>>xmlns:cmism="http://docs.oasis-open.org/ns/cmis/messaging/200908/">
>>     <cmisra:type xsi:type="cmis:cmisTypeDocumentDefinitionType"
>>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>         <cmis:id>RGBClass2</cmis:id>
>>         <cmis:localName>RGBClass2</cmis:localName>
>>         <cmis:localNamespace xsi:nil="true"/>
>>         ...
>>         <cmis:propertyStringDefinition>
>>             <cmis:id>RGBChoiceList</cmis:id>
>>             <cmis:localName>RGBChoiceList</cmis:localName>
>>             <cmis:displayName>RGBChoiceList</cmis:displayName>
>>             <cmis:queryName>RGBChoiceList</cmis:queryName>
>>             <cmis:description>RGBChoiceList</cmis:description>
>>             <cmis:propertyType>string</cmis:propertyType>
>>             <cmis:cardinality>single</cmis:cardinality>
>>             <cmis:updatability>readwrite</cmis:updatability>
>>             <cmis:inherited>false</cmis:inherited>
>>             <cmis:required>false</cmis:required>
>>             <cmis:queryable>true</cmis:queryable>
>>             <cmis:orderable>true</cmis:orderable>
>>             <cmis:openChoice>false</cmis:openChoice>
>>             <p8ext:isHidden>false</p8ext:isHidden>
>>
>><p8ext:ChoiceListSymbolicName>RGBChoice</p8ext:ChoiceListSymbolicName>
>>             
>><p8ext:ChoiceListDisplayName>RGBChoice</p8ext:ChoiceListDisplayName>
>>             <cmis:choice displayName="Joe">
>>                 <cmis:value>Joe</cmis:value>
>>             </cmis:choice>
>>             <cmis:choice displayName="Dan">
>>                 <cmis:value>Dan</cmis:value>
>>             </cmis:choice>
>>             <cmis:choice displayName="Paul">
>>                 <cmis:value>Paul</cmis:value>
>>             </cmis:choice>
>>         </cmis:propertyStringDefinition>
>>3. The problem is that the VB.Net IPropertyDefinition" object doesn't
>>have a "Choices" property:
>>
>>   IPROPERTYDEFINITION OBJECT IN MSVS DEBUGGER:
>>
>>?p
>>{DotCMIS.Data.Impl.PropertyStringDefinition}
>>     DotCMIS.Data.Impl.PropertyStringDefinition:
>>{DotCMIS.Data.Impl.PropertyStringDefinition}
>>     Cardinality: Single {0}
>>     Description: "RGBChoiceList"
>>     DisplayName: "RGBChoiceList"
>>     Id: "RGBChoiceList"
>>     IsInherited: False
>>     IsOpenChoice: False
>>     IsOrderable: True
>>     IsQueryable: True
>>     IsRequired: False
>>     LocalName: "RGBChoiceList"
>>     LocalNamespace: Nothing
>>     PropertyType: String {6}
>>     QueryName: "RGBChoiceList"
>>     Updatability: ReadWrite {1}
>>     <= No "Choices" VB object property available...
>>4. The last Jira bug relating to DotCMIS "Choices" was Jira
>>https://issues.apache.org/jira/browse/CMIS-380.
>>     This was fixed in 17/Oct/11, DotCMIS 0.3.
>>     The problem in CMIS-380 was  "IPropertyDefinition.Choices == 
>>null".
>>     My current problem is that I don't even *see* any
>>""IPropertyDefinition.Choices".
>>
>>5. I have not stepped through the DotCMIS library code yet.
>>
>>6. I have not tested to see if it works in C# yet (my client is 
>>VB.Net)
>>
>>Please let me know if you have any suggestions for what I can try, or
>>what I can do next.
>>
>>I'm new to the chemistry.apache.org community
>