PropertyGroup samples
Basics
From older OpenKM version we named "Metadata Groups" as "Property Groups".
Although we understand this name not helps a lot to identifying these methods with metadata ones, for historical reason, we continue maintaining the nomenclature.
For more information about Metadata.
On almost methods you'll see parameter named "nodeId". The value of this parameter can be a valid document, folder, mail or record UUID or path.
Example of nodeId:
- Using UUID -> "f123a950-0329-4d62-8328-0ff500fd42db";
- Using path -> "/okm:root/SDK4PHP/logo.png"
Methods
addGroup
Description:
Method | Return values | Description |
---|---|---|
addGroup($nodeId, $grpName) |
void |
Adds an empty metadata group to a node. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testAddGroup() {
try {
$this->ws->addGroup('/okm:root/SDK4PHP/logo.png', 'okg:consulting');
echo 'addGroup';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testAddGroup();
?>
removeGroup
Description:
Method | Return values | Description |
---|---|---|
removeGroup($nodeId, $grpName) |
void |
Removes a metadata group of a node. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testRemoveGroup() {
try {
$this->ws->removeGroup('/okm:root/SDK4PHP/logo.png', 'okg:consulting');
echo 'Remove Group';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testRemoveGroup()
?>
getGroups
Description:
Method | Return values | Description |
---|---|---|
getGroups($nodeId) |
array |
Retrieves a list of metadata groups assigned to a node. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetGroups() {
try {
$propertyGroups = $this->ws->getGroups('/okm:root/SDK4PHP/logo.png');
foreach ($propertyGroups as $propertyGroup) {
var_dump($propertyGroup);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testGetGroups();
?>
getAllGroups
Description:
Method | Return values | Description |
---|---|---|
getAllGroups() |
array |
Retrieves a list of all metadata groups set into the application. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetAllGroups() {
try {
$propertyGroups = $this->ws->getAllGroups();
foreach ($propertyGroups as $propertyGroup) {
var_dump($propertyGroup);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testGetAllGroups();
?>
getPropertyGroupProperties
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroupProperties(String nodeId, String grpName) |
List<FormElement> |
Retrieves a list of all metadata group elements and its values of a node. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. The method is usually used to display form elements with its values to be shown or changed by user. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetPropertyGroupProperties() {
try {
$formElements = $this->ws->getPropertyGroupProperties('/okm:root/SDK4PHP/logo.png', 'okg:consulting');
foreach ($formElements as $formElement) {
var_dump($formElement);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testGetPropertyGroupProperties();
?>
getPropertyGroupPropertiesSimple
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroupPropertiesSimple($nodeId, $grpName) |
array |
Retrieves a list of all metadata group elements and its values of a node. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetPropertyGroupPropertiesSimple() {
try {
$properties = $this->ws->getPropertyGroupPropertiesSimple('/okm:root/SDK4PHP/logo.png', 'okg:consulting');
foreach ($properties as $property) {
var_dump($property);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testGetPropertyGroupPropertiesSimple();
?>
getPropertyGroupForm
Description:
Method | Return values | Description |
---|---|---|
getPropertyGroupForm($grpName) |
array |
Retrieves a list of all metadata group elements definition. |
Parameters: $grpName string type is the grpName should be a valid Metadata group name. The method is usually used to display empty form elements for creating new metadata values. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetPropertyGroupForm() {
try {
$formElements = $this->ws->getPropertyGroupForm('okg:consulting');
foreach ($formElements as $formElement) {
var_dump($formElement);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testGetPropertyGroupPropertiesSimple();
?>
setPropertyGroupProperties
Description:
Method | Return values | Description |
---|---|---|
setPropertyGroupProperties($nodeId, $grpName, $formElements) |
void |
Changes the metadata group values of a node. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. $formElements array type is an array of the FormElement Before changing metadata, you should have the group added in the node ( see addGroup method ) otherwise will be raised and error. Is not mandatory set into parameter ofeList all FormElement, is enough with the formElements you wish to change its values. The sample below is based on this Metadata group definition:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testSetPropertyGroupProperties() {
try {
// Same modification with only affected FormElement
$formElements = array();
$name = new \openkm\bean\form\Input();
$name->setName("okp:consulting.name");
$name->setValue("new value");
$formElements[] = $name;
$this->ws->setPropertyGroupProperties('/okm:root/SDK4PHP/logo.png', 'okg:consulting', $formElements);
echo 'updated';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testSetPropertyGroupProperties();
?>
setPropertyGroupPropertiesSimple
Description:
Method | Return values | Description |
---|---|---|
setPropertyGroupPropertiesSimple($nodeId, $grpName, $properties) |
void |
Changes the metadata group values of a node. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. $properties array type is an array Before changing metadata, you should have the group added in the node ( see addGroup method ) otherwise will be raised and error. Is not mandatory set into properties parameter all fields values, is enough with the fields you wish to change its values. The sample below is based on this Metadata group definition:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
ini_set('display_errors', true);
error_reporting(E_ALL);
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testSetPropertyGroupPropertiesSimple() {
try {
$properties = [];
$properties["okp:consulting.name"] = "new value";
$properties["okp:consulting.important"] = "true";
$this->ws->setPropertyGroupPropertiesSimple('/okm:root/SDK4PHP/logo.png', 'okg:consulting', $properties);
echo 'updated';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testSetPropertyGroupPropertiesSimple();
?>
hasGroup
Description:
Method | Return values | Description |
---|---|---|
hasGroup($nodeId, $grpName) |
bool |
Returns a boolean that indicate if the node has or not a metadata group. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testSetPropertyGroupPropertiesSimple() {
try {
echo 'Have metadata group: ' . $this->ws->hasGroup('/okm:root/SDK4PHP/logo.png', 'okg:consulting');
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testSetPropertyGroupPropertiesSimple();
?>
getRegisteredDefinition
Description:
Method | Return values | Description |
---|---|---|
getRegisteredDefinition() |
string |
Return the XML Metada groups definition. |
The method only can be executed by super user grants ( ROLE_ADMIN member user). |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetRegisteredDefinition() {
try {
var_dump($this->ws->getRegisteredDefinition());
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testGetRegisteredDefinition();
?>
getSuggestions
Description:
Method | Return values | Description |
---|---|---|
getSuggestions($nodeId, $grpName, $propName) |
List<String> |
Retrieves a list of a suggested metadata field values. |
Parameters: $nodeId string type is the uuid or path of the document, folder, mail or record. $grpName string type is the grpName should be a valid Metadata group name. $propName string type is the propName parameter should be a Metadata Select field type. The propName parameter should be a Metadata Select field type. More information at Creating your own Suggestion Analyzer and Metadata Select field. The sample below is based on this Metadata group definition:
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetSuggestions() {
try {
$suggestions = $this->ws->getSuggestions('/okm:root/SDK4PHP/logo.png', 'okg:consulting', 'okp:technology.language');
foreach ($suggestions as $suggestion) {
var_dump($suggestion);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testGetSuggestions();
?>
registerDefinition
Description:
Method | Return values | Description |
---|---|---|
registerDefinition($content) |
void |
Sets the XML Metada groups definition into the repository. |
Parameters: $content string type is recommend using file_get_contents — Reads entire file into a string The method only can be executed by super user grants ( ROLE_ADMIN member user). |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExamplePropertyGroup {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testRegisterDefinition() {
try {
$fileName = dirname(__FILE__) . '/propertygroup/propertyGroups.xml';
$this->ws->registerDefinition(file_get_contents($fileName));
var_dump('Register Definition correct');
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$examplePropertyGroup = new ExamplePropertyGroup();
$examplePropertyGroup->testRegisterDefinition();
?>