OKMPropertyGroup
Basics
Section titled “Basics”On most methods you’ll see a parameter named “nodeId”. The value of this parameter can be a valid document, folder, mail or record UUID or path.
Also on all methods you’ll see parameter named “token”. When accessing application across SOAP the login process returns a token, what is used to identify the user on all the exposed methods. From default application execution context you must use “null” value what indicates to the application must use the “user session”.
Methods
Section titled “Methods”addGroup
Section titled “addGroup”Description:
| Method | Return values | Description |
|---|---|---|
| addGroup(String token, String nodeId, String grpName) | void | Adds an empty metadata group to a node. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;
public class Test { public static void main(String[] args) { try { OKMPropertyGroup.getInstance().addGroup(null, "/okm:root/logo.png", "okg:consulting"); } catch (Exception e) { e.printStackTrace(); } }}removeGroup
Section titled “removeGroup”Description:
| Method | Return values | Description |
|---|---|---|
| removeGroup(String token, String nodeId, String grpName) | void | Removes a metadata group of a node. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;
public class Test { public static void main(String[] args) { try { OKMPropertyGroup.getInstance().removeGroup(null, "/okm:root/logo.png", "okg:consulting"); } catch (Exception e) { e.printStackTrace(); } }}getGroups
Section titled “getGroups”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.bean.PropertyGroup;
public class Test { public static void main(String[] args) { try { for (PropertyGroup pg : OKMPropertyGroup.getInstance().getGroups(null, "/okm:root/logo.png")) { System.out.println(pg); } } catch (Exception e) { e.printStackTrace(); } }}getAllGroups
Section titled “getAllGroups”Description:
| Method | Return values | Description |
|---|---|---|
| getAllGroups(String token) | List |
Retrieves a list of all metadata groups set into the application. |
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;import com.openkm.bean.PropertyGroup;
public class Test { public static void main(String[] args) { try { for (PropertyGroup pg : OKMPropertyGroup.getInstance().getAllGroups(null)) { System.out.println(pg); } } catch (Exception e) { e.printStackTrace(); } }}getProperties
Section titled “getProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getProperties(String token, String nodeId, String grpName) | List |
Retrieves a list of all metadata group elements and its node values. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;import com.openkm.bean.form.FormElement;
public class Test { public static void main(String[] args) { try { for (FormElement fe : OKMPropertyGroup.getInstance().getProperties(null,"/okm:root/logo.png", "okg:consulting")) { System.out.println(fe); } } catch (Exception e) { e.printStackTrace(); } }}getPropertiesSimple
Section titled “getPropertiesSimple”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertiesSimple(String token, String nodeId, String grpName) | Map<String, String> | Retrieves a list of all metadata group elements and its node values. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import java.util.Map;
import com.openkm.api.OKMPropertyGroup;
public class Test { public static void main(String[] args) { try { Map<String, String> properties = OKMPropertyGroup.getInstance().getPropertiesSimple(null,"/okm:root/logo.png", "okg:consulting"); for (String key : properties.keySet()) { System.out.println(key + ":" + properties.get(key)); } } catch (Exception e) { e.printStackTrace(); } }}setProperties
Section titled “setProperties”Description:
| Method | Return values | Description |
|---|---|---|
| setProperties(String token, String nodeId, String grpName, List |
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.ArrayList;import java.util.List;
import com.openkm.api.OKMPropertyGroup;import com.openkm.bean.form.FormElement;import com.openkm.bean.form.Input;
public class Test { public static void main(String[] args) { try { List<FormElement> fElements = OKMPropertyGroup.getInstance().getProperties(null, "/okm:root/logo.pdf","okg:consulting"); for (FormElement fElement : fElements) { if (fElement.getName().equals("okp:consulting.name")) { Input name = (Input) fElement; name.setValue("new value"); } }
OKMPropertyGroup.getInstance().setProperties(null, "/okm:root/logo.pdf", "okg:consulting", fElements);
// Same modification with only affected FormElement fElements = new ArrayList<>(); Input name = new Input(); name.setName("okp:consulting.name"); name.setValue("new value"); fElements.add(name); OKMPropertyGroup.getInstance().setProperties(null, "/okm:root/logo.pdf","okg:consulting", fElements);
} catch (Exception e) { e.printStackTrace(); } }}setPropertySimple
Section titled “setPropertySimple”Description:
| Method | Return values | Description |
|---|---|---|
| setPropertySimple(String token, String nodeId, String propGroup, String propName, String propValue) | void | Changes the metadata group field value of a node. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;
public class Test { public static void main(String[] args) { try { OKMPropertyGroup.getInstance().setPropertySimple(null, "/okm:root/logo.pdf","okg:consulting", "okp:consulting.name", "new name"); } catch (Exception e) { e.printStackTrace(); } }}setPropertiesSimple
Section titled “setPropertiesSimple”Description:
| Method | Return values | Description |
|---|---|---|
| setPropertiesSimple(String token, String nodeId, String grpName, Map<String, String> properties) | void | Changes the metadata group valuea 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.api.OKMPropertyGroup;import com.openkm.util.ISO8601;
public class Test { public static void main(String[] args) { try { Map<String, String> properties = new HashMap<>(); properties.put("okp:consulting.name", "new name");
// Date fields must be saved with basic ISO 8601 format properties.put("okp:consulting.date", ISO8601.formatBasic(Calendar.getInstance())); OKMPropertyGroup.getInstance().setPropertiesSimple(null, "/okm:root/logo.pdf","okg:consulting", properties); } catch (Exception e) { e.printStackTrace(); } }}getPropertyGroupForm
Section titled “getPropertyGroupForm”Description:
| Method | Return values | Description |
|---|---|---|
| getPropertyGroupForm(String token, String grpName) | List |
Retrieves a list of all metadata group elements definition. |
- The grpName should be a valid Metadata group name.
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;import com.openkm.bean.form.FormElement;
public class Test { public static void main(String[] args) { try { for (FormElement fe : OKMPropertyGroup.getInstance().getPropertyGroupForm(null, "okg:consulting")) { System.out.println(fe); } } catch (Exception e) { e.printStackTrace(); } }}hasGroup
Section titled “hasGroup”Description:
| Method | Return values | Description |
|---|---|---|
| hasGroup(String token, String nodeId, String grpName) | boolean | Returns a boolean that indicate if the node has or not a metadata group. |
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;
public class Test { public static void main(String[] args) { try { boolean found = OKMPropertyGroup.getInstance().hasGroup(null, "/okm:root/logo.pdf", "okg:consulting"); System.out.println(found); } catch (Exception e) { e.printStackTrace(); } }}getSuggestions
Section titled “getSuggestions”Description:
| Method | Return values | Description |
|---|---|---|
| getSuggestions(String token, String nodeId, String grpName, String propName) | List |
Retrieves a list of a suggested metadata field values. |
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;
public class Test { public static void main(String[] args) { try { for (String value : OKMPropertyGroup.getInstance().getSuggestions(null, "/okm:root/logo.pdf","okg:technology", "okp:technology.language")) { System.out.println(value); } } catch (Exception e) { e.printStackTrace(); } }}registerDefinition
Section titled “registerDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| registerDefinition(String token, String pgDef) | void | Set the XML Metada 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;
public class Test { public static void main(String[] args) { InputStream is = null; try { is = new FileInputStream("/home/files/PropertyGroups.xml"); String pgDef = IOUtils.toString(is); OKMPropertyGroup.getInstance().registerDefinition(null, pgDef); } catch (Exception e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(is); } }}getRegisteredDefinition
Section titled “getRegisteredDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| getRegisteredDefinition(String token) | String | Returns the XML Metada groups definition. |
Example:
package com.openkm;
import com.openkm.api.OKMPropertyGroup;
public class Test { public static void main(String[] args) { try { String pgDef = OKMPropertyGroup.getInstance().getRegisteredDefinition(null); System.out.println(pgDef); } catch (Exception e) { e.printStackTrace(); } }}