PropertyGroup samples
Basics
Section titled “Basics”In almost all methods, you’ll see the parameter named “nodeId”. The value of this parameter can be the UUID of a valid document, folder, mail, or record.
Suggested code sample
Section titled “Suggested code sample”First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(host);Then you should log in using the “login” method. You can access the “login” method from the webservice object “ws” as shown below:
ws.login(user, password);At this point you can use all the Property Group methods from the “propertyGroup” class as shown below:
ws.propertyGroup.addGroup("8cd1e072-8595-4dd3-b121-41d622c43f08", "okg:consulting", propertiesMap);Methods
Section titled “Methods”addGroup
Section titled “addGroup”Description:
| Method | Return values | Description |
|---|---|---|
| addGroup(String nodeId, String grpName, Dictionary<String, String> propertiesMap) | void | Adds a metadata group to a node. |
The grpName should be a valid Metadata group name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.util;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Dictionary<string, string> props = new Dictionary<string, string>();DateTime date = DateTime.Now;props.Add("okp:consulting.name", "test");props.Add("okp:consulting.date", ISO8601.formatBasic(date));props.Add("okp:consulting.important", "true");props.Add("okp:consulting.comment", "test");ws.propertyGroup.addGroup("f0064cf3-4776-44c2-868a-f08697a6957e", "okg:consulting", props);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}removeGroup
Section titled “removeGroup”Description:
| Method | Return values | Description |
|---|---|---|
| removeGroup(String nodeId, String grpName) | void | Removes a metadata group from a node. |
The grpName should be a valid Metadata group name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.propertyGroup.removeGroup("f123a950-0329-4d62-8328-0ff500fd42db", "okg:consulting");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getGroups
Section titled “getGroups”Description:
| Method | Return values | Description |
|---|---|---|
| getGroups(String nodeId) | List |
Retrieves a list of metadata groups assigned to a node. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (PropertyGroup pGroup in ws.propertyGroup.getGroups("f123a950-0329-4d62-8328-0ff500fd42db")){ System.Console.WriteLine(pGroup.name); }}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getAllGroups
Section titled “getAllGroups”Description:
| Method | Return values | Description |
|---|---|---|
| getAllGroups() | List |
Retrieves a list of all metadata groups configured in the application. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (PropertyGroup pGroup in ws.propertyGroup.getAllGroups()){System.Console.WriteLine(pGroup.name); }}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getAllGroups
Section titled “getAllGroups”Description:
| Method | Return values | Description |
|---|---|---|
| getAllGroups(String uuid) | List |
Retrieves a list of all metadata groups defined in the application. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (PropertyGroup pGroup in ws.propertyGroup.getAllGroups("8cd1e072-8595-4dd3-b121-41d622c43f08")){System.Console.WriteLine(pGroup.name); }}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getPropertyGroupForm
Section titled “getPropertyGroupForm”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertyGroupForm(String uuid, String grpName) | List |
Retrieves a list of all metadata group element definitions. |
The grpName should be a valid Metadata group name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.bean.form;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (FormElement fElement in ws.propertyGroup.getPropertyGroupForm("f123a950-0329-4d62-8328-0ff500fd42db","okg:consulting")){System.Console.WriteLine(fElement);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getPropertyGroupFormDefinition
Section titled “getPropertyGroupFormDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertyGroupFormDefinition(String grpName) | List |
Retrieves a list of all metadata group element definitions. |
The grpName should be a valid Metadata group name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.bean.form;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (FormElement fElement in ws.propertyGroup.getPropertyGroupFormDefinition("okg:consulting")){System.Console.WriteLine(fElement);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getPropertyGroupFormDefinition
Section titled “getPropertyGroupFormDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertyGroupFormDefinition(String uuid, String grpName) | List |
Retrieves a list of all metadata group element definitions. |
The grpName should be a valid Metadata group name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.bean.form;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (FormElement fElement in ws.propertyGroup.getPropertyGroupFormDefinition("afe29d6e-7769-4d48-a4db-c5a24edfd5df", "okg:consulting"));{System.Console.WriteLine(fElement);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}setProperties
Section titled “setProperties”Description:
| Method | Return values | Description |
|---|---|---|
| setProperties(String nodeId, String grpName, Dictionary<String, String> properties) | void | Changes the metadata group values of a node. |
The grpName should be a valid Metadata group name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.util;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8180/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Dictionary<String, String> properties = new Dictionary<String, String>();properties.Add("okp:consulting.name", "new name");
//The date fields must be saved with basic ISO 8601 format properties.Add("okp:consulting.date", ISO8601.formatBasic(DateTime.Now)); ws.propertyGroup.setProperties("f123a950-0329-4d62-8328-0ff500fd42db","okg:consulting", properties);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}hasGroup
Section titled “hasGroup”Description:
| Method | Return values | Description |
|---|---|---|
| hasGroup(String nodeId, String grpName) | Boolean | Returns a boolean that indicates whether the node has a metadata group. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine("Have metadata group:"+ ws.propertyGroup.hasGroup("f123a950-0329-4d62-8328-0ff500fd42db","okg:consulting").ToString());}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getRegisteredDefinition
Section titled “getRegisteredDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| getRegisteredDefinition() | String | Returns the XML metadata groups definition. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine(ws.propertyGroup.getRegisteredDefinition());}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}registerDefinition
Section titled “registerDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| registerDefinition(InputStream is, String pgName) | void | Sets the XML metadata groups definition into the repository. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using System.IO;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8180/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);FileStream fs = new FileStream("E:\\PropertyGroups.xml",FileMode.Open);ws.propertyGroup.registerDefinition(fs,"okg:testing");fs.Dispose();}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getSuggestions
Section titled “getSuggestions”Description:
| Method | Return values | Description |
|---|---|---|
| getSuggestions(String nodeId, String grpName, String propName) | List |
Retrieves a list of suggested metadata field values. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach(String value in ws.propertyGroup.getSuggestions("f123a950-0329-4d62-8328-0ff500fd42db","okg:technology", "okp:technology.language")){System.Console.WriteLine(value);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getProperties
Section titled “getProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getProperties(String nodeId, String grpName) | Dictionary<String, String> | Retrieves a dictionary of (key, value) pairs with metadata group values for a node. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Dictionary<String, String> properties = new Dictionary<String, String>();properties = ws.propertyGroup.getProperties("f123a950-0329-4d62-8328-0ff500fd42db","okg:technology");
foreach (KeyValuePair<String, String> pair in properties){System.Console.WriteLine(pair.Key + "-> " + pair.Value);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getPropertiesByVersion
Section titled “getPropertiesByVersion”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertiesByVersion(String nodeId, String grpName,String versionName) | Dictionary<String, String> | Retrieves a dictionary of (key, value) pairs with metadata group values for a node. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Dictionary<String, String> properties = new Dictionary<String, String>();properties = ws.propertyGroup.getPropertiesByVersion("f123a950-0329-4d62-8328-0ff500fd42db","okg:technology","1.1");
foreach (KeyValuePair<String, String> pair in properties){System.Console.WriteLine(pair.Key + "-> " + pair.Value);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getGroupsByVersion
Section titled “getGroupsByVersion”Description:
| Method | Return values | Description |
|---|---|---|
| getGroupsByVersion(String nodeId, String versionName) | List |
Retrieves a list of metadata groups assigned to a node. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (PropertyGroup pGroup in ws.propertyGroup.getGroupsByVersion("f123a950-0329-4d62-8328-0ff500fd42db","1.1")){ System.Console.WriteLine(pGroup.name, "1.1"); }}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getGroup
Section titled “getGroup”Description:
| Method | Return values | Description |
|---|---|---|
| getGroup(String grpName) | PropertyGroup | Gets the property group definition. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);PropertyGroup pg = ws.propertyGroup.getGroup("okg:consulting");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getSuggestBoxKeyValue
Section titled “getSuggestBoxKeyValue”Description:
| Method | Return values | Description |
|---|---|---|
| getSuggestBoxKeyValue(String grpName, String propertyName, String key) | String | Returns the suggestBox value for a key. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);String grpName = "okg:consulting";String propertyName = "okp:consulting.suggestbox";String key = "es";String result = ws.propertyGroup.getSuggestBoxKeyValue(grpName, propertyName, key); Console.WriteLine("Value: " + result);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getSuggestBoxKeyValuesFiltered
Section titled “getSuggestBoxKeyValuesFiltered”Description:
| Method | Return values | Description |
|---|---|---|
| getSuggestBoxKeyValuesFiltered(String grpName, String propertyName, String filter) | Dictionary<String, String> | Retrieves a dictionary (key, value) pairs with suggestBox values. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);String grpName = "okg:consulting";String propertyName = "okp:consulting.suggestbox";String filter = "Port";Dictionary<String, String> result = ws.propertyGroup.getSuggestBoxKeyValuesFiltered(grpName, propertyName, filter);foreach(var item in result){Console.WriteLine(item.key + ":" + item.value);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}validateField
Section titled “validateField”| Method | Return values | Description |
|---|---|---|
| validateField(String value, String className, List |
String | Returns the validation message. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);List<String> uuids = new List<string>();uuids.Add("28ece92f-9708-4d3f-8033-18dc98b9e7f5");uuids.Add("5484b622-7c5f-425a-9451-7611c0caf227");
String value = "test";String className = "com.openkm.plugin.form.validator.DuplicateDocumentNumberValidator";String message = ws.propertyGroup.validateField(value, className, uuids);Console.WriteLine("Validate: " + message);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}