Skip to content

OKMPropertyGroup

In most methods you’ll see a parameter named “nodeId”. The value of this parameter can be a valid document, folder, mail, or record UUID.

Also, in all methods you’ll see a parameter named “token”. Because Cron Tasks are executed in the background without authentication, the methods used in this scenario might use the token parameter. In the default application execution context, you must use the “null” value, which indicates that the application must use the “user session”.

Description:

Method Return values Description
addGroup(String token, String nodeId, String grpName, Map<String, String> properties) void Adds a metadata group and its values to a node.
  • The grpName should be a valid Metadata group name.

Example:

package com.openkm;
import com.google.gson.Gson;
import com.openkm.Config;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ISO8601;
import java.util.*;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
Map<String, String> properties = new HashMap<>();
Gson gson = new Gson();
List<String> values = new ArrayList<>();
values.add("t1");
values.add("t2");
properties.put("okp:technology.type", gson.toJson(values));
properties.put("okp:technology.language", "[ \"java\" ]");
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.important", String.valueOf(true));
okmPropertyGroup.addGroup(null, "4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5", "okg:technology", properties);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
removeGroup(String token, String nodeId, 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.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
okmPropertyGroup.removeGroup(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:consulting");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getGroups(String token, String nodeId) List Retrieves a list of metadata groups assigned to a node.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
import com.openkm.bean.PropertyGroup;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (PropertyGroup pg : okmPropertyGroup.getGroups(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338")) {
System.out.println(pg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getAllGroups(String token) List Retrieves a list of all metadata groups in the application.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
import com.openkm.bean.PropertyGroup;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (PropertyGroup pg : okmPropertyGroup.getAllGroups(null)) {
System.out.println(pg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getAllGroups(String token, String nodeId) List Retrieves a list of all metadata groups in the application.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
import com.openkm.bean.PropertyGroup;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (PropertyGroup pg : okmPropertyGroup.getAllGroups(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338")) {
System.out.println(pg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getUserGroups(String token) List Retrieves a list of all metadata groups for the user in the application.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
import com.openkm.bean.PropertyGroup;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (PropertyGroup pg : okmPropertyGroup.getUserGroups(null)) {
System.out.println(pg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getUserGroups(String token, String nodeId) List Retrieves a list of all metadata groups for the user, filtered for a specific node via automation rules.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.bean.PropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (PropertyGroup pg : okmPropertyGroup.getUserGroups(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338")) {
System.out.println(pg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getProperties(String token, String nodeId, String grpName) Map<String, String> Retrieves a list of all metadata group elements and their node values.
  • The grpName should be a valid Metadata group name.

Example:

package com.openkm;
import java.util.Map;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
Map<String, String> properties = okmPropertyGroup.getProperties(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:consulting");
for (String key : properties.keySet()) {
System.out.println(key + ": " + properties.get(key));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
setProperties(String token, String nodeId, 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 com.google.gson.Gson;
import com.openkm.Config;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
import com.openkm.util.ISO8601;
import java.util.*;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
Map<String, String> properties = new HashMap<>();
Gson gson = new Gson();
List<String> values = new ArrayList<>();
values.add("t1");
values.add("t2");
properties.put("okp:technology.type", gson.toJson(values));
properties.put("okp:technology.language", "[ \"java\" ]");
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.important", String.valueOf(true));
okmPropertyGroup.setProperties(null, "4a3b1c1b-c880-45a3-a6ff-2c8b7c5adfa5", "okg:technology", properties);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getPropertyGroupForm(String token, 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.api.OKMPropertyGroup;
import com.openkm.bean.form.FormElement;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (FormElement fe : okmPropertyGroup.getPropertyGroupForm(null, "okg:consulting")) {
System.out.println(fe);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getPropertyGroupForm(String token, String nodeId, String grpName) List Retrieves a list of all metadata group element definitions for a specific node. Allows automation rules to customize the form elements based on the node context.
  • The grpName should be a valid Metadata group name.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.bean.form.FormElement;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (FormElement fe : okmPropertyGroup.getPropertyGroupForm(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:consulting")) {
System.out.println(fe);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
hasGroup(String token, String nodeId, String grpName) boolean Returns a boolean indicating whether the node has a metadata group.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
boolean found = okmPropertyGroup.hasGroup(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:consulting");
System.out.println(found);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getSuggestions(String token, String nodeId, String grpName, String propName) List Retrieves a list of suggested metadata field values.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (String value : okmPropertyGroup.getSuggestions(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:technology",
"okp:technology.language")) {
System.out.println(value);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
registerDefinition(String token, String pgDef, String pgName) void Sets the XML Metadata groups definition into the repository.

Example:

package com.openkm;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
InputStream is = null;
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
is = new FileInputStream("/home/files/PropertyGroups.xml");
String pgDef = IOUtils.toString(is);
okmPropertyGroup.registerDefinition(null, pgDef, "test");
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
}
}
}

Description:

Method Return values Description
getRegisteredDefinition(String token) String Returns the XML Metadata groups definition.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
String pgDef = okmPropertyGroup.getRegisteredDefinition(null);
System.out.println(pgDef);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getGroups(String token, String nodeId, String versionName) List Retrieves a list of metadata groups assigned to a specific version of a node.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.bean.PropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
for (PropertyGroup pg : okmPropertyGroup.getGroups(null, "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801", "1.2")) {
System.out.println(pg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getGroupProperties(String token, Long pgdId) List Retrieves a list of metadata group properties.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.bean.PropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
long pgdId = 1;
for (PropertyGroup pg : okmPropertyGroup.getGroupProperties(null, pgdId)) {
System.out.println(pg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getProperties(String token, String nodeId, String grpName, String versionName) Map<String, String> Retrieves a map (key-value pairs) of metadata group values assigned to a specific version of a node.

Example:

package com.openkm;
import java.util.Map;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
Map<String, String> properties = okmPropertyGroup.getProperties(null, "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801", "okg:tpl", "1.2");
for (String key : properties.keySet()) {
System.out.println(key + ": " + properties.get(key));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getSuggestBoxKeyValue(String token, String nodeId, String grpName, String propertyName, String key) KeyValue Retrieves an object that contains the key and value of the suggest box.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;import com.openkm.bean.KeyValue;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
KeyValue kv = okmPropertyGroup.getSuggestBoxKeyValue(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:groupname", "okp:groupname.propertyname", "namekey");
System.out.println(kv.getKey() + ": " + kv.getValue());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getSuggestBoxKeyValuesFiltered(String token, String nodeId, String grpName, String propertyName, String filter) List Retrieves a list of objects that contain the key and value from the suggest box, filtered by value.

Example:

package com.openkm;
import java.util.List;
import com.openkm.api.OKMPropertyGroup;import com.openkm.bean.KeyValue;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
List<KeyValue> kvList = okmPropertyGroup.getSuggestBoxKeyValuesFiltered(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:groupname", "okp:groupname.propertyname", "filter");
for (KeyValue kv : kvList) {
System.out.println(kv.getKey() + ": " + kv.getValue());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
addOrSetPropertyGroupWithAI(String token, String nodeId, String grpName) void Uses AI to automatically extract and populate the metadata group values for a node. If the group is not yet assigned, it is added; otherwise, the existing values are updated.
  • The grpName should be a valid Metadata group name.

Example:

package com.openkm;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
okmPropertyGroup.addOrSetPropertyGroupWithAI(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:technology");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getExtractedPropertyGroupWithAI(String token, String nodeId, String grpName) Map<String, String> Uses AI to extract the metadata group values for a node and returns them as a map without saving to the repository.
  • The grpName should be a valid Metadata group name.

Example:

package com.openkm;
import java.util.Map;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMPropertyGroup okmPropertyGroup = ContextWrapper.getContext().getBean(OKMPropertyGroup.class);
Map<String, String> props = okmPropertyGroup.getExtractedPropertyGroupWithAI(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "okg:technology");
for (String key : props.keySet()) {
System.out.println(key + ": " + props.get(key));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}