Configuring document expiration

Document expiration is a notification system alert which can be used to advice users nearly document expiration and expired documents.

This option is only available if you have enabled the Document expiration feature.

Document expiration is based on:

  • Metadata group feature.
  • Crontab feature.
  • Report feature.

More information at Document expiration extension.

Configuration

Download the expiration files document_expiration_6.4.zip.

Register parameters

Execute SQL from Administration > Tools > Database query.

-- NOTIFICATION PARAMETERS
DELETE FROM OKM_CONFIG WHERE CFG_KEY LIKE '%expiration.%';
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('expiration.date.pattern','string','dd-MM-yyyy HH:mm:ss');
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('expiration.expiration.alert.days','string','15');
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('expiration.notification.subject','string','New uploaded document with expiration');
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('expiration.notification.template','text','New document uploaded<br/>${docUrl}<br/>Expiration date:${date}<br/>');
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('expiration.alert.subject','string','Alert documents will expire');
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('expiration.alert.template','text','Document ${docUrl} will expire at ${date}<br/>');
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('expiration.expired.subject','string','Documents expired');
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('expiration.expired.template','text','Document ${docUrl} expired at ${date}<br/>');

-- MYSQL DATABASE METADATA GROUP
DELETE FROM OKM_DB_METADATA_TYPE WHERE DMT_TABLE='group';
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('group', 'col00', 'text', 'gru_name');
INSERT INTO OKM_DB_METADATA_TYPE (DMT_TABLE, DMT_REAL_COLUMN, DMT_TYPE, DMT_VIRTUAL_COLUMN) VALUES ('group', 'col01', 'text', 'gru_user');

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, 'group', 'col00', 'text', 'gru_name');

More information at Creating your own database tables.

More information at Database query.

Configure parameters

Field / PropertyTypeDescription

expiration.date.pattern

String

Set the date pattern.

dd-MM-yyyy HH:mm:ss

expiration.notification.subject

String

Mail subject.

New uploaded document with expiration

expiration.notification.template

String

Mail body.

New document uploaded<br/>${docUrl}<br/>Expiration date:${date}<br/>

expiration.expiration.alert.days

Integer

Set the number of days before expiration when it will be send the expiration alert message.

15

Default document expiration set an unique value for all document. This is the default logic but can be implemented your own.

expiration.alert.subject

String

Mail subject.

Alert documents will expire

expiration.alert.template

String

Mail body.

Document ${docUrl} will expire at ${date}<br/>

These parameters are set at Administration > Configuration parameters view.

Register metadata group

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.1//EN"
    "http://www.openkm.com/dtd/property-groups-2.1.dtd">
<property-groups>
  <property-group label="Expiration" name="okg:expiration">
    <input label="Expiration date" name="okp:expiration.date" type="date">
      <validator type="req"/>
    </input>
    <select label="State" name="okp:expiration.state" type="simple">
      <option label="Notify" value="notify" selected="true"/>
      <option label="Valid" value="valid"/>
      <option label="Expired" value="expired"/>
      <validator type="req"/>
    </select>
    <select label="Notify" name="okp:expiration.group.notify" type="multiple" table="group"
            optionsQuery="select $gru_name, $gru_name from DatabaseMetadataValue dmv where dmv.table='group' group by $gru_name">
      <validator type="req"/>
    </select>
    <select label="Notify expiration alert" name="okp:expiration.group.alert" type="multiple" table="group"
            optionsQuery="select $gru_name, $gru_name from DatabaseMetadataValue dmv where dmv.table='group' group by $gru_name">
      <validator type="req"/>
    </select>
    <select label="Notify expirated" name="okp:expiration.group.expired" type="multiple" table="group"
            optionsQuery="select $gru_name, $gru_name from DatabaseMetadataValue dmv where dmv.table='group' group by $gru_name">
      <validator type="req"/>
    </select>
  </property-group>
</property-groups>

Register crontab task

TaskExpressionDescription

InitialNotificationation.jar

*/1 * * * *

After is added metadata group to the node is sent the "initial notification" mail.

The crontab task is executed each minute looking for new nodes with metadata group.

AlertExpirationNotificationation.jar

30 0 * * *

Sent daily mail alert for documents expire soon.

ExpirationNotificationation.jar

0 0 * * *

Sent daily mail alert for documents expired today.

This crontab task should be executed before AlertExpirationNotificationation task.

More information at Crontab.

Register reports

ReportDescription

ValidDocuments.jrxml

List all valid documents.

ExpiredDocuments.jrxml

List all expired documents.

NextExpirationDocuments.jrxml

List documents what will expire soon.

More information at Reports.

See also Profiles for configuring reports in user interface menu view.