Metadata Select field

AttributeDescriptionRequired
label

The text shown as label in the user interface.

true

name

Unique field identifier.

Two metadatas can't have the same name. Name must be unique.

The name must start with "okp:".

It's a good practice to use metadata group name as basis for metadata field name. For example use "okg:consulting" has been used for field name "okp:consulting.select", changin "okg" to "okp". That helps to find out the metada group based on metadata field name.

Please, use only letters, numbers and underscore: "0-9a-zA-Z_".

true

type

Type value. Allowed types:

  • simple ( single choice allowed ).
  • multiple ( multiple choices allowed ).
true
table

Metadata table name.

The application can store values into a metadata table, that can be used in this query.

*
width The width of the HTML element.  
height The height of the HTML element.  
optionsQuery A metadata query used to get the selected options. *

className

A class used to get the selected options. *
suggestion

When adding metadata to documents, the application can suggest automatically some values based on document content analysis. By default the application has some implementations that can easilly be extended.

  • com.openkm.form.suggestion.DocumentContentContainsSuggestion: Gets suggestions based on document's content (use String.contains)
  • com.openkm.form.suggestion.DocumentContentTokenizerSuggestion: Gets suggestions based on document's content (Use StringTokenizer).
  • com.openkm.form.suggestion.DocumentTermsSuggestion: Gets suggestions based on document's term vectors.

For more information read Creating your own Suggestion Analyzer.

false
readonly Set field will not be able to be modified in the user interface. By default the value is "false". false

Child elements:

  • Option. Couples of XML <option label="label text" value="unique identifier value"/>.
  • Validator. For more information see Metadata Validator element.

* There're two options to get option values:

  • Directly defined in XML.
  • Metadata table ( table + optionsQuery ).

One of these options must be defined, otherwise you will get an error. It can not done as a combination of several of them, only one can be choosen.

Basic select example

  • Type is equal to simple.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.3//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.3.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 2.5//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.5.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>

Options based on a metadata table

  • The application uses two tables named OKM_DB_METADATA_TYPE AND OKM_DB_METADATA_VALUE that helps storing the options values used in select. That's very useful when you have a large number of values.
  • In the table OKM_DB_METADATA_TYPE are stored metadata table definition ( table name, column name and column type ).
  • In the table OKM_DB_METADATA_VALUE are stored record values.

Create metadata table definition.

The table will be called country, with two columns, country_id and country_name.

The country_id column is an integer type and country_name is text type.

The country_id is set as column 0 with col00 value.

The country_name is set as column 1 with col01 value.

  • Go to Administration > Database query.
  • At bottom right select JDBC from list.
  • Paste the SQL in the box
DELETE FROM OKM_DB_METADATA_TYPE WHERE DMT_TABLE='country';
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('country', 'col00', 'integer', 'country_id');
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('country', 'col01', 'text', 'country_name');
  • Click Execute button at the bottom right the .

Insert metadata table values:

  • Go to Administration > Database query.
  • At the bottom right select JDBC from list.
  • Paste the SQL in the box
DELETE FROM OKM_DB_METADATA_VALUE WHERE DMV_TABLE='country';
INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) VALUES ('country', '001', 'Australia');
INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) VALUES ('country', '002', 'Canada');
  • Click the Execute button at the bottom right .

The insert queries depending on your database can not be a match, for example in Oracle:

INSERT INTO OKM_DB_METADATA_TYPE (DMT_ID, DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES (HIBERNATE_SEQUENCE.NEXTVAL, 'country', 'col00', 'integer', 'country_id');

More information at Creating your own database tables.

Finally the XML definition:

  • In optionsQuery the values that begin with the character $ are identified as column names. See $country_id and $country_name below.
  • Can use normal SQL clausules like "order by", etc.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.5//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.5.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
     <select label="country" name="okp:consulting.country" type="simple" table="country" 
             optionsQuery="select $country_id, $country_name from DatabaseMetadataValue dmv where dmv.table='country' order by $country_name"/>
  </property-group>
</property-groups>

Suggested options

Based on the content analyzer the application can suggest some options values. At the user interface the suggested options will be shown in green.

The application has some implementations that can easily be extended.

  • com.openkm.form.suggestion.DocumentContentContainsSuggestion: Get suggestions based on document content (use String.contains)
  • com.openkm.form.suggestion.DocumentContentTokenizerSuggestion: Get suggestions based on document content (Use StringTokenizer).
  • com.openkm.form.suggestion.DocumentTermsSuggestion: Get suggestions 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 2.3//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.3.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>