PropertyGroup samples
Basics
Section titled “Basics”Suggested code sample
Section titled “Suggested code sample”First, you must create the web service object:
OKMWebservices ws = OKMWebservicesFactory.getInstance(host);Then you should log in using the “login” method. You can access the “login” method from the web service 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 uuid, String grpName, Map<String, String> propertiesMap) | void |
Adds an empty metadata group to a node. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import java.util.Calendar;import java.util.HashMap;import java.util.Map;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;import com.openkm.sdk4j.util.ISO8601;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); Map<String, String> properties = new HashMap<>(); properties.put("okp:technology.type", "[ \"t1\", \"t2\" ]"); Calendar cal = Calendar.getInstance(); // Value must be converted to String ISO 8601 compliant properties.put("okp:technology.date", ISO8601.formatBasic(cal)); properties.put("okp:technology.comment", "comment sample"); properties.put("okp:technology.description", "description sample"); properties.put("okp:technology.language", "[ \"java\" ]"); properties.put("okp:technology.important", String.valueOf(true)); ws.propertyGroup.addGroup("4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5", "okg:technology", properties); } catch (Exception e) { e.printStackTrace(); } }}removeGroup
Section titled “removeGroup”Description:
| Method | Return values | Description |
|---|---|---|
| removeGroup(String uuid, String grpName) | void |
Removes a metadata group from a node. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.propertyGroup.removeGroup("8cd1e072-8595-4dd3-b121-41d622c43f08", "okg:consulting"); } catch (Exception e) { e.printStackTrace(); } }}getGroups
Section titled “getGroups”Description:
| Method | Return values | Description |
|---|---|---|
| getGroups(String uuid) | List |
Retrieves a list of metadata groups assigned to a node. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.PropertyGroup;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (PropertyGroup pGroup : ws.propertyGroup.getGroups("8cd1e072-8595-4dd3-b121-41d622c43f08")) { System.out.println(pGroup); } } catch (Exception e) { e.printStackTrace(); } }}getAllGroups
Section titled “getAllGroups”Description:
| Method | Return values | Description |
|---|---|---|
| getAllGroups() | List |
Retrieves a list of all metadata groups defined in the application. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.PropertyGroup;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (PropertyGroup pGroup : ws.propertyGroup.getAllGroups()) { System.out.println(pGroup); } } catch (Exception e) { e.printStackTrace(); } }}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:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.PropertyGroup;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (PropertyGroup pGroup : ws.propertyGroup.getAllGroups("8cd1e072-8595-4dd3-b121-41d622c43f08")) { System.out.println(pGroup); } } catch (Exception e) { e.printStackTrace(); } }}getPropertyGroupForm
Section titled “getPropertyGroupForm”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertyGroupForm(String grpName) | List |
Retrieves a list of all metadata group element definitions. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.form.FormElement;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (FormElement fElement : ws.propertyGroup.getPropertyGroupForm("okg:consulting")) { System.out.println(fElement); } } catch (Exception e) { e.printStackTrace(); } }}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:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.form.FormElement;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (FormElement fElement : ws.propertyGroup.getPropertyGroupFormDefinition("okg:consulting")) { System.out.println(fElement); } } catch (Exception e) { e.printStackTrace(); } }}getPropertyGroupFormDefinition
Section titled “getPropertyGroupFormDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertyGroupFormDefinition(String grpName, String uuid) | List |
Retrieves a list of all metadata group element definitions. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.form.FormElement;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (FormElement fElement : ws.propertyGroup.getPropertyGroupFormDefinition("okg:consulting", "8cd1e072-8595-4dd3-b121-41d622c43f08")) { System.out.println(fElement); } } catch (Exception e) { e.printStackTrace(); } }}getPropertyGroupForm
Section titled “getPropertyGroupForm”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertyGroupForm(String uuid, String grpName) | List |
Retrieves a list of metadata values of a node. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.form.FormElement;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (FormElement fElement : ws.propertyGroup.getPropertyGroupForm("8cd1e072-8595-4dd3-b121-41d622c43f08","okg:consulting")) { System.out.println(fElement); } } catch (Exception e) { e.printStackTrace(); } }}setProperties
Section titled “setProperties”Description:
| Method | Return values | Description |
|---|---|---|
| setProperties(String uuid, String grpName, Map<String, String> properties) | void | Changes the metadata group values of a node. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import java.util.Calendar;import java.util.HashMap;import java.util.Map;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;import com.openkm.sdk4j.util.ISO8601;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); Map<String, String> properties = new HashMap<>(); properties.put("okp:technology.type", "[ \"t1\", \"t2\" ]"); Calendar cal = Calendar.getInstance(); // Value must be converted to String ISO 8601 compliant properties.put("okp:technology.date", ISO8601.formatBasic(cal)); properties.put("okp:technology.comment", "comment sample"); properties.put("okp:technology.description", "description sample"); properties.put("okp:technology.language", "[ \"java\" ]"); properties.put("okp:technology.important", String.valueOf(true)); ws.propertyGroup.setProperties("8cd1e072-8595-4dd3-b121-41d622c43f08", "okg:consulting", properties); } catch (Exception e) { e.printStackTrace(); } }}hasGroup
Section titled “hasGroup”Description:
| Method | Return values | Description |
|---|---|---|
| hasGroup(String uuid, String grpName) | Boolean | Returns a boolean that indicates whether the node has a metadata group. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); System.out.println("Have metadata group:" + ws.propertyGroup.hasGroup("8cd1e072-8595-4dd3-b121-41d622c43f08", "okg:consulting")); } catch (Exception e) { e.printStackTrace(); } }}getRegisteredDefinition
Section titled “getRegisteredDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| getRegisteredDefinition() | String | Returns the XML Metadata groups definition. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); System.out.println(ws.propertyGroup.getRegisteredDefinition()); } catch (Exception e) { e.printStackTrace(); } }}registerDefinition
Section titled “registerDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| registerDefinition(InputStream is, String name) | void | Sets the XML Metadata groups definition in the repository. |
Example:
package com.openkm;
import java.io.FileInputStream;import java.io.InputStream;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); InputStream is = new FileInputStream("/home/openkm/PropertyGroups.xml"); ws.propertyGroup.registerDefinition(is, "test"); } catch (Exception e) { e.printStackTrace(); } }}getSuggestions
Section titled “getSuggestions”Description:
| Method | Return values | Description |
|---|---|---|
| getSuggestions(String uuid, String grpName, String propName) | List |
Retrieves a list of suggested metadata field values. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (String value : ws.propertyGroup.getSuggestions("8cd1e072-8595-4dd3-b121-41d622c43f08", "okg:technology", "okp:technology.language")) { System.out.println(value); } } catch (Exception e) { e.printStackTrace(); } }}getProperties
Section titled “getProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getProperties(String uuid, String grpName) | Map<String, String> | Retrieves a map - (key, value) pairs - with Metadata group values of a node. |
Example:
package com.openkm;
import java.util.HashMap;import java.util.Map;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); Map<String, String> properties = new HashMap<>(); properties = ws.propertyGroup.getProperties("8cd1e072-8595-4dd3-b121-41d622c43f08", "okg:technology");
for (String key : properties.keySet()) { System.out.println(key + " > " + properties.get(key)); } } catch (Exception e) { e.printStackTrace(); } }}getGroupsByVersion
Section titled “getGroupsByVersion”Description:
| Method | Return values | Description |
|---|---|---|
| getGroupsByVersion(String uuid, String versionName) | List |
Retrieves a list of metadata groups assigned to a specific version of a node. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.PropertyGroup;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (PropertyGroup pGroup : ws.propertyGroup.getGroupsByVersion("118cb06b-9df7-4d59-bed9-ba986a4f8e0b", "1.3")) { System.out.println(pGroup); } } catch (Exception e) { e.printStackTrace(); } }}getPropertiesByVersion
Section titled “getPropertiesByVersion”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertiesByVersion(String uuid, String grpName, String versionName) | Map<String, String> | Retrieves a map - (key, value) pairs - with Metadata group values assigned to a specific version of a node. |
Example:
package com.openkm;
import java.util.HashMap;import java.util.Map;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); Map<String, String> properties = new HashMap<>(); properties = ws.propertyGroup.getPropertiesByVersion("118cb06b-9df7-4d59-bed9-ba986a4f8e0b", "okg:technology", "1.3");
for (String key : properties.keySet()) { System.out.println(key + " > " + properties.get(key)); } } catch (Exception e) { e.printStackTrace(); } }}getPropertiesByVersionForm
Section titled “getPropertiesByVersionForm”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertiesByVersionForm(String uuid, String grpName, String versionName) | List |
Retrieves a list of all metadata group element definitions for a specific version of a node. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.form.FormElement;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (FormElement fElement : ws.propertyGroup.getPropertiesByVersionForm("118cb06b-9df7-4d59-bed9-ba986a4f8e0b", "okg:consulting", "1.3")) { System.out.println(fElement); } } catch (Exception e) { e.printStackTrace(); } }}getGroup
Section titled “getGroup”Description:
| Method | Return values | Description |
|---|---|---|
| getGroup(String grpName) | PropertyGroup | Retrieves the metadata group. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); System.out.println(ws.propertyGroup.getGroup("okg:consulting")); } catch (Exception e) { e.printStackTrace(); } }}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:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); System.out.println(ws.propertyGroup.getPropertyGroup("okg:consulting")); } catch (Exception e) { e.printStackTrace(); } }}getSuggestBoxKeyValuesFiltered
Section titled “getSuggestBoxKeyValuesFiltered”Description:
| Method | Return values | Description |
|---|---|---|
| getSuggestBoxKeyValuesFiltered(String grpName, String propertyName, String filter) | Map<String, String> |
Retrieves a map - (key, value) pairs - with suggestBox values. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
import java.util.Map;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); Map<String, String> values = ws.propertyGroup.getSuggestBoxKeyValuesFiltered(Config.GROUP_CONSULTING, "okp:consulting.suggestbox", "pai"); for (String key : values.keySet()) { String value = values.get(key); System.out.println(key + ":" + value); } } catch (Exception e) { e.printStackTrace(); } }}validateField
Section titled “validateField”| Method | Return values | Description |
|---|---|---|
| validateField(String value, String className, List |
String | Returns the validation message. |
Example
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
import java.util.ArrayList;import java.util.List;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); List<String> uuids = new ArrayList<>(); uuids.add("26ece92f-9708-4d3f-8033-18dc98b9e7f5"); uuids.add("7984b622-7c5f-425a-9451-7611c0caf227");
String value = "test"; String className = "com.openkm.plugin.form.validator.DuplicateDocumentNumberValidator"; String message = ws.propertyGroup.validateField(value, className, uuids); System.out.println("Validate: " + message); } catch (Exception e) { e.printStackTrace(); } }}