OKMRelation
Esta página aún no está disponible en tu idioma.
Basics
Section titled “Basics”On most methods you’ll see 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”getRelationTypes
Section titled “getRelationTypes”Description:
| Method | Return values | Description |
|---|---|---|
| getRelationTypes(String token, String type) | List |
Retrieves a list of all relations defined of a type. |
- Available types values:
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.RelationType;import com.openkm.dao.bean.NodeRelationType;
public class Test { public static void main(String[] args) { try { for (RelationType rt : OKMRelation.getInstance().getRelationTypes(null, NodeRelationType.BIDIRECTIONAL)) { System.out.println(rt); } } catch (Exception e) { e.printStackTrace(); } }}Description:
| Method | Return values | Description |
|---|---|---|
| add(String token, String nodeAId, String nodeBId, long relationType) | void | Sets a relation between two nodes. |
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.RelationType;import com.openkm.dao.bean.NodeRelationType;
public class Test { public static void main(String[] args) { try { for (RelationType rt : OKMRelation.getInstance().getRelationTypes(null, NodeRelationType.BIDIRECTIONAL)) { // looking for a relation named invoice if (rt.getTitleAToB().equals("invoice")) { OKMRelation.getInstance().add(null, "/okm:root/invoice.pdf", "/okm:root/budget.pdf", rt.getId()); } } } catch (Exception e) { e.printStackTrace(); } }}delete
Section titled “delete”Description:
| Method | Return values | Description |
|---|---|---|
| delete(String token, long relationId) | void | Deletes a relation. |
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.RelationType;import com.openkm.dao.bean.NodeRelationType;
public class Test { public static void main(String[] args) { try { for (RelationType rt : OKMRelation.getInstance().getRelationTypes(null, NodeRelationType.BIDIRECTIONAL)) { // looking for a relation named invoice if (rt.getTitleAToB().equals("invoice")) { OKMRelation.getInstance().delete(null, rt.getId()); } } } catch (Exception e) { e.printStackTrace(); } }}getRelations
Section titled “getRelations”Description:
| Method | Return values | Description |
|---|---|---|
| getRelations(String token, String nodeId) | List |
Retrieves a list of all relations of a node. |
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.Relation;
public class Test { public static void main(String[] args) { try { for (Relation relation : OKMRelation.getInstance().getRelations(null, "/okm:root/invoice.pdf")) { System.out.println(relation); } } catch (Exception e) { e.printStackTrace(); } }}getRelationGroups
Section titled “getRelationGroups”Description:
| Method | Return values | Description |
|---|---|---|
| getRelationGroups(String token, String nodeId) | List |
Retrieves a list of all relation groups of a node. |
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.RelationGroup;
public class Test { public static void main(String[] args) { try { for (RelationGroup rg : OKMRelation.getInstance().getRelationGroups(null, "/okm:root/invoice.pdf")) { System.out.println(rg); } } catch (Exception e) { e.printStackTrace(); } }}addGroup
Section titled “addGroup”Description:
| Method | Return values | Description |
|---|---|---|
| addGroup(String token, String nodeId, String groupName, long type) | void | Adds a relation group at a node. |
- On a relation group only has sense to apply a relation type of NodeRelationType.MANY_TO_MANY.
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.RelationType;import com.openkm.dao.bean.NodeRelationType;
public class Test { public static void main(String[] args) { try { for (RelationType rt : OKMRelation.getInstance().getRelationTypes(null, NodeRelationType.MANY_TO_MANY)) { if (rt.getTitle().equals("staple")) { OKMRelation.getInstance().addGroup(null, "/okm:root/invoice.pdf", "staple group", rt.getId()); } } } catch (Exception e) { e.printStackTrace(); } }}addNodeToGroup
Section titled “addNodeToGroup”Description:
| Method | Return values | Description |
|---|---|---|
| addNodeToGroup(String token, String nodeId, long groupId) | void | Adds a node to an existing relation group. |
- On a relation group only has sense to apply a relation type of NodeRelationType.MANY_TO_MANY.
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.RelationType;import com.openkm.dao.bean.NodeRelationType;
public class Test { public static void main(String[] args) { try { for (RelationType rt : OKMRelation.getInstance().getRelationTypes(null, NodeRelationType.MANY_TO_MANY)) { if (rt.getTitle().equals("staple")) { OKMRelation.getInstance().addNodeToGroup(null, "/okm:root/invoice.pdf", rt.getId()); } } } catch (Exception e) { e.printStackTrace(); } }}deleteGroup
Section titled “deleteGroup”Description:
| Method | Return values | Description |
|---|---|---|
| deleteGroup(String token, String nodeId, long groupId) | void | Remove a node from a relation group. |
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.RelationType;import com.openkm.dao.bean.NodeRelationType;
public class Test { public static void main(String[] args) { try { for (RelationType rt : OKMRelation.getInstance().getRelationTypes(null, NodeRelationType.MANY_TO_MANY)) { if (rt.getTitle().equals("staple")) { OKMRelation.getInstance().deleteGroup(null, "/okm:root/invoice.pdf", rt.getId()); } } } catch (Exception e) { e.printStackTrace(); } }}findGroup
Section titled “findGroup”Description:
| Method | Return values | Description |
|---|---|---|
| findGroup(String token, long groupId) | RelationGroup | Finds a relation group by id. |
Example:
package com.openkm;
import com.openkm.api.OKMRelation;import com.openkm.bean.RelationGroup;
public class Test { public static void main(String[] args) { try { long groupId = 11; RelationGroup rg = OKMRelation.getInstance().findGroup(null, groupId); System.out.println(rg); } catch (Exception e) { e.printStackTrace(); } }}setGroupName
Section titled “setGroupName”Description:
| Method | Return values | Description |
|---|---|---|
| setGroupName(String token, long groupId, String groupName) | void | Changes the relation group name. |
Example:
package com.openkm;
import com.openkm.api.OKMRelation;
public class Test { public static void main(String[] args) { try { long groupId = 11; OKMRelation.getInstance().setGroupName(null, groupId, "new name"); } catch (Exception e) { e.printStackTrace(); } }}