Page 1 of 1

Method getPropertyGroupProperties only returns elements

PostPosted:Mon May 20, 2019 2:27 pm
by zaans2
According to the Knowledge Center Page for the method `getPropertyGroupProperties` it should return all the elements for the group and node and its values (see https://docs.openkm.com/kcenter/view/sd ... Properties). It only returns the elements without their values.

The following code is what I expected to be able to do
Code: Select all
For Each group In metadataGroups
  Dim properties = ws.getPropertyGroupProperties(selectedDoc.path, group.name)
    For Each prop In properties
      TextBox6.AppendText(prop.label + vbCrLf)
      For Each value In prop.values
        TextBox6.AppendText("- " + value + vbCrLf)
      Next
  Next
Next
However the `getPropertyGroupProperties` returns a `List<FormElement>`. The class `FormElement` doesn't even contain a `values` or `value` field. It onlys has fields for `label`, `name`, `width`, `height`.

The `getPropertyGroupPropertiesSimple` does return values besides the names, but these are the names they are given within OpenKM and are those are not usefull for my application. I want the labels of the elements and values, which I expected to get with `getPropertyGroupProperties`

I am using the 1.2.2. .NET SDK with Visual Basic.NET

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Thu May 23, 2019 7:52 pm
by saulhidalgo
Good afternoon.

You need to check to what subclass the FormElement belongs to. Here is the API description.

https://docs.openkm.com/apidoc/com/okm/ ... ement.html

As you can see, FormElement has some subclasses, like Input, TextArea, etc. You need to check what instance you have in each element of the list, and then cast it accordingly. Inside those classes you will find the "getValue()" method wanted.

Please check it, and if you have any question or advice you can contact me:

Mail: saulhidalgoaular@gmail.com.
Skype: saulhidalgoaular@outlook.com
Phone: +58 426 517 94 59.

Best Regards.
Saul Hidalgo.

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Fri May 24, 2019 12:55 pm
by zaans2
Hi,

As you could have seen in my post I am talking about the v1.2.2 .NET SDK, not the internal Java API which you have linked to.

Here is a link to the `FormElement` doc of the SDK https://docs.openkm.com/apidoc/com/sdk/ ... ement.html

If I cast to for instance an `Select` element (https://docs.openkm.com/apidoc/com/sdk/ ... elect.html) it does have a field value. However this field has no actual value. For every `FormElement` it is empty.

If you check a later .NET SDK, lets say the latest v3.1.0, you can see that the actual method no longer returns a `List<FormElement>` but a `Dictionary<String, String>`, the same as the method `getPropertyGroupPropertiesSimple` does right now (https://docs.openkm.com/apidoc/pro/sdk/ ... e995871ffb)

I can't use the `getPropertyGroupPropertiesSimple` method from v1.2.2 of the .NET SDK because that only returns the name's of the properties and values, not the labels (which is what I need)

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Sat May 25, 2019 8:20 am
by jllort
You will have value in case of Input or TextArea, but in case of Select you have a list of options and one of them or several will be selected

https://docs.openkm.com/apidoc/com/okm/ ... elect.html
https://docs.openkm.com/apidoc/com/okm/ ... ption.html
https://docs.openkm.com/apidoc/com/okm/6.3.6/

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Mon Jul 01, 2019 7:58 am
by zaans2
If I check the values of the Select with a debugger it doesnt have any. the `List<Option>` called `options` has a single option without any values. I think this method wasn't implemented properly in the version if the .NET SDK I am using.

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Tue Jul 02, 2019 7:42 am
by jllort
You are using SDK version 1.2.2 with what OpenKM version?
Take a look at this table https://docs.openkm.com/kcenter/view/sdk4net/

For what I understood, the method always returns an empty list of options. Can you share us the XML definition for testing from our side?

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Tue Jul 02, 2019 7:47 am
by zaans2
Yes that is the version I am using. Unfortunately I am not able to share the XML definition of the metadata group on here as it contains confidential information.

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Thu Jul 04, 2019 8:40 am
by jllort
Can you create another metatada definition what fails for testing? I do not need real data, only something what is going wrong.

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Thu Jul 04, 2019 9:01 am
by zaans2
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.0//EN"
        "http://www.openkm.com/dtd/property-groups-2.0.dtd">
<property-groups>
    <property-group label="FooBar" name="okg:foobar">
        <select label="Foo" name="okp:foobar.foo" type="simple" >
            <option label="FooInternal" value="foo.intern"/>
            <option label="FooExternal" value="foo.extern"/>
        </select>
        <select label="Bar" name="okp:foobar.bar" type="multiple" >
            <option label="BarHR" value="bar.hr"/>
            <option label="BarIT" value="bar.it"/>
            <option label="BarMT" value="bar.mt"/>
            <option label="BarHD" value="bar.hd"/>
        </select>
    </property-group>
</property-groups>
So the siuation is that if I assign this group to a document and select values, lets say "FooInternal" for the "Foo" property and "BarHR" and "BarMT" for the "Bar" property if I call "getPropertyGroupProperties" I only get list with the "FormElement" for the different properties (In this case it would be two, one for "Foo" and one for "Bar"). The options list is empty, the value is empty etc.

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Sun Jul 07, 2019 10:47 am
by jllort
Share also the section of code what you are executing to get properties with SDK for .NET ( sorry I forget to ask for it in my previos answer )

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Mon Jul 08, 2019 8:53 am
by zaans2
Here you go
Code: Select all
For Each prop In ws.getMetadataGroupProperties(selectedDoc.path, "okg:foobar")
	Console.WriteLine(prop.label + ":" + vbCrLf)
	Dim options = CType(prop, [Select]).options
	
	For Each value In options
		If value.selected Then
			Console.WriteLine("- " + value.label + vbCrLf)
		End If
	Next
Next

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Mon Jul 15, 2019 4:06 pm
by pherrera
Hello,

There is a problem when deserializer with RestSharp, soon we will release a new version that will correct this issue.
Please try this version for now:
(68.54 KiB) Downloaded 177 times
Let me know if the problem has been solved.

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Tue Jul 16, 2019 6:53 am
by zaans2
This SDK version unfortunately doesn't solve the problem. The class 'FormElement' still only has the properties 'label', 'name', 'width' and 'height'. There is no property for the value(s) of the element

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Wed Jul 17, 2019 8:42 pm
by pherrera
Hi,

As mentioned in previous comments...
"You need to check what instance you have in each element of the list, and then cast it accordingly."
https://docs.openkm.com/apidoc/com/sdk/ ... ement.html

If I'm not wrong, for example:
Code: Select all
            For Each fe In ws.getPropertyGroupProperties("942516de-3fd9-4506-b7e4-9d01796dee57", "okg:technology")
                Dim t = fe.GetType()
                Console.WriteLine(fe.label + ":")
                If t.Equals(GetType([Select])) Then
                    Dim item = CType(fe, [Select])
                    For Each value In item.options
                        If value.selected Then
                            Console.WriteLine("- " + value.label)
                        End If
                    Next
                ElseIf t.Equals(GetType([TextArea])) Then
                    Dim item = CType(fe, [TextArea])
                    Console.WriteLine("- " + item.value)
                ElseIf t.Equals(GetType([Input])) Then
                    Dim item = CType(fe, [Input])
                    Console.WriteLine("- " + item.value)
                End If
            Next

Re: Method getPropertyGroupProperties only returns elements

PostPosted:Thu Jul 18, 2019 7:55 am
by zaans2
Sorry for my ignorance on needing to cast the elements to the correct types. It does indeed work now.