Metadata Select field
Attribute | Description | Required |
---|---|---|
label |
The text is shown as a label in the user interface. |
true |
name |
Unique field identifier. Two metadata fields can't have the same name. The name must be unique. The name must start with "okp:". Using the metadata group name as a basis for the metadata field name is a good practice. For example, if "okg:consulting" has been used for the group name, the field name would be "okp:consulting.select", changing "okg" to "okp." That helps to find the metadata group based on the metadata field name. Please use only letters, numbers, and underscores: "0-9a-zA-Z_". |
true |
type |
Type value. Allowed types:
|
true |
table |
Metadata table name. The application can store values in a metadata table that can be used in this query. |
* |
width |
The width of the HTML element. In the KCenter UI, width values must be based on percentages; for example:
|
|
height | The height of the HTML element. | |
optionsQuery | A metadata query is used to get the selected options. | * |
className |
A class is used to get the selected options. | * |
suggestion |
The application can automatically suggest values based on document content analysis when adding metadata to documents. By default, the application includes some implementations that can be easily extended.
For more information, read Creating your own Suggestion Analyzer. |
false |
parentElement | Parent field name value. In this case, the value is hierarchical with other field values (the parent). | false |
description | General description. | false |
read-only | The set field cannot be modified in the user interface. By default, the value is "false". | false |
dbColumnSize |
Set the size of the database field where the value is stored. By default, fields are stored in a database column of 128 characters. Because your data length might be longer than 128 characters, the administrator should update the default column size. Take a look at the Metadata XML definition documentation section for a detailed explanation of metadata stored in the OpenKM database. |
|
defaultAccess |
Default security access policy. By default, it is set to "grant", so all users will see the property. |
|
Child elements:
|
||
* There are three options to get option values:
One of these options must be defined; otherwise, you will get an error. They cannot be combined; only one may be chosen. |
Basic select example
- Type is equal to simple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
"http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
<property-group label="Consulting" name="okg:consulting">
<select label="select label" name="okp:consulting.select" type="simple">
<option label="one" value="001" />
<option label="two" value="002" />
<option label="three" value="003" />
</select>
</property-group>
</property-groups>
Allow multiple choices
- Type is equal to multiple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
"http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
<property-group label="Consulting" name="okg:consulting">
<select label="select label" name="okp:consulting.select" type="multiple">
<option label="one" value="001" />
<option label="two" value="002" />
<option label="three" value="003" />
</select>
</property-group>
</property-groups>
Based on SQL query
We can also get these option values using an SQL query. This SQL statement should be put in the optionsQuery attribute, but the table attribute should be empty (otherwise, this query is treated as a metadata query). Note that the first element returned in every row is the option value, and the second is the option label.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
"http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
<property-group label="Location" name="okg:location">
<select label="Country" name="okp:location.country" type="simple"
optionsQuery="select CT_ID, CT_NAME from COUNTRY order by CT_NAME" />
</property-group>
</property-groups>
The table used in this sample is defined as follows:
create table COUNTRY ( CT_ID varchar(2), CT_NAME varchar(32), primary key(CT_ID) );
insert into COUNTRY (CT_ID, CT_NAME) values ('es', 'Spain');
insert into COUNTRY (CT_ID, CT_NAME) values ('pt', 'Portugal');
insert into COUNTRY (CT_ID, CT_NAME) values ('it', 'Italy');
Based on className
To help get a list from external applications or other purposes, your class can be built to retrieve the option values from those systems.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
"http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
<property-group label="Consulting" name="okg:consulting">
<select label="select label" name="okp:consulting.select" type="simple"
className="com.openkm.plugin.form.values.OptionSelectUserList" />
</property-group>
</property-groups>
For more information, read Creating your own Option Select Values plugin.
Suggested options
Based on the content analyzer, the application can suggest some option values. In the user interface, the recommended options will be shown in green.
The application includes some implementations that can be easily extended.
- com.openkm.form.suggestion.DocumentContentContainsSuggestion: Gets recommendations based on document content (use String.contains)
- com.openkm.form.suggestion.DocumentContentTokenizerSuggestion: Gets suggestions based on document content (use StringTokenizer).
- com.openkm.form.suggestion.DocumentTermsSuggestion: Gets recommendations based on document term vectors.
For more information, read Creating your own Suggestion Analyzer.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
"http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
<property-group label="Consulting" name="okg:consulting">
<select label="select label" name="okp:consulting.select" type="multiple"
suggestion="com.openkm.form.suggestion.DocumentContentContainsSuggestion">
<option label="one" value="001" />
<option label="two" value="002" />
<option label="three" value="003" />
</select>
</property-group>
</property-groups>
Hierarchical relationship
- The option values of the field "okp:consulting.children" have a parent relation with "okp:consulting.parent". It is defined by parentElement="okp:consulting.parent".
- The option value "benefits" of the field "okp:consulting.children" has a parent value "directives" in the field "okp:consulting.parent".
Tree relationships:
- directives
- benefits
- eligibility
- services
- handbook
- basic
- normal
- advanced
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN"
"http://www.openkm.com/dtd/property-groups-3.10.dtd">
<property-groups>
<property-group label="Consulting" name="okg:consulting">
<select label="Parent" name="okp:consulting.parent" type="simple">
<option value="directives" label="Directives" />
<option value="handbook" label="Handbook Paragraphs" />
</select>
<select label="Children" name="okp:consulting.children" type="simple" parentElement="okp:consulting.parent">
<option value="benefits" label="Benefits" parentValue="directives" />
<option value="elegibility" label="Eligibility" parentValue="directives" />
<option value="services" label="Services" parentValue="directives" />
<option value="basic" label="Basic" parentValue="handbook" />
<option value="normal" label="Advanced" parentValue="handbook" />
<option value="advanced" label="Normal" parentValue="handbook" />
</select>
</property-group>
</property-groups>
Hierarchical relationship with SQL
We use a couple of tables to obtain the information in this case.
create table LOCALIDAD (
LOC_ID varchar(8),
LOC_NAME varchar(32),
primary key (LOC_ID)
);
create table UBICACION (
UBI_ID varchar(8),
UBI_LOC varchar(8),
UBI_NAME varchar(32),
primary key (UBI_ID)
);
insert into LOCALIDAD (LOC_ID, LOC_NAME) values ('l0', 'Localidad 0');
insert into LOCALIDAD (LOC_ID, LOC_NAME) values ('l1', 'Localidad 1');
insert into LOCALIDAD (LOC_ID, LOC_NAME) values ('l2', 'Localidad 2');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u0', 'l0', 'Ubicación 0');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u1', 'l0', 'Ubicación 1');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u2', 'l0', 'Ubicación 2');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u3', 'l1', 'Ubicación 4');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u4', 'l1', 'Ubicación 5');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u5', 'l1', 'Ubicación 6');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u6', 'l2', 'Ubicación 7');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u7', 'l2', 'Ubicación 8');
insert into UBICACION (UBI_ID, UBI_LOC, UBI_NAME) values ('u8', 'l2', 'Ubicación 9');
This is the form definition:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.7//EN"
"http://www.openkm.com/dtd/property-groups-3.7.dtd">
<property-groups>
<property-group label="Sample" name="okg:sample">
<!-- Parent child -->
<select label="Localidad" name="okp:sample.localidad"
optionsQuery="select LOC_ID, LOC_NAME from LOCALIDAD" />
<select label="Ubicacion" name="okp:sample.ubicacion" parentElement="okp:sample.localidad"
optionsQuery="select UBI_ID, UBI_NAME, UBI_LOC from UBICACION" />
</property-group>
</property-groups>