PropertyGroup samples
Basics
From older OpenKM version we named "Metadata Groups" as "Property Groups".
Although we understand this name does not help 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 |
Add 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 used. |
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();
?>
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 Is not mandatory set into parameter ofeList all FormElement, is enought 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 of the SimplePropertyGroup 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';
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 = array();
$name = new \openkm\bean\SimplePropertyGroup();
$name->setName("okp:consulting.name");
$name->setValue("new value");
$properties[] = $name;
$important = new \openkm\bean\SimplePropertyGroup();
$important->setName("okp:consulting.important");
$important->setValue("true");
$properties[] = $important;
$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();
?>