Creating your own Autocomplete Form plugin
You can create your own autocomplete form.
Conditions:
- The new Default Form Values class must implement the “AutocompleteFormValues” interface.
- The new Default Form Values class must be declared in the package “com.openkm.plugin.form.values”.
- The new Default Form Values class must be annotated with “@PluginImplementation”.
- The new Default Form Values class must extend “BasePlugin”.
Default Autocomplete Form interface:
package com.openkm.plugin.form.values;
import com.openkm.bean.form.FormElement;import net.xeoh.plugins.base.Plugin;
import java.util.List;
public interface AutocompleteFormValues extends Plugin { String getName();
void autocompleteFormValues(String uuid, String grpName, List<FormElement> formElementList);}The new class must be loaded into the package com.openkm.plugin.form.values because the application’s plugin system will try to load it from there. See the sample below:
Method description
Section titled “Method description”| Method | Type | Description |
|---|---|---|
| autocompleteFormValues(String uuid, String grpName, List |
void | The method autocompletes the group’s form elements. |
Example of the default form values implementation
Section titled “Example of the default form values implementation”package com.openkm.plugin.form.values;
import com.openkm.bean.form.FormElement;import com.openkm.bean.form.HorizontalPanel;import com.openkm.bean.form.Input;import com.openkm.bean.form.VerticalPanel;import com.openkm.plugin.BasePlugin;import net.xeoh.plugins.base.annotations.PluginImplementation;import org.apache.commons.lang3.StringUtils;import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import java.util.List;
@PluginImplementationpublic class SampleAutocompleteFormValues extends BasePlugin implements AutocompleteFormValues { private static final Logger log = LoggerFactory.getLogger(SampleAutocompleteFormValues.class);
@Override public String getName() { return "Sample autocomplete form values implementation"; }
@Override public void autocompleteFormValues(String uuid, String grpName, List<FormElement> formElementList) { log.info("autocompleteFormValues({}, {}, {})", uuid, grpName, formElementList); autocomplete(formElementList); }
private void autocomplete(List<FormElement> formElementList) { for (FormElement formElement : formElementList) { if (formElement instanceof Input) { Input input = (Input) formElement; if (StringUtils.isEmpty(input.getValue())) { input.setValue("Autocomplete with name: " + formElement.getName()); } } else if (formElement instanceof HorizontalPanel) { HorizontalPanel hPanel = (HorizontalPanel) formElement; autocomplete(hPanel.getElements()); } else if (formElement instanceof VerticalPanel) { VerticalPanel vPanel = (VerticalPanel) formElement; autocomplete(vPanel.getElements()); } } }}Metadata definition
Section titled “Metadata definition”<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.11//EN" "http://www.openkm.com/dtd/property-groups-3.11.dtd"><property-groups> <property-group label="Autocomple sample" name="okg:autocomplete" autocompleteValueClassName="com.openkm.plugin.form.values.SampleAutocompleteFormValues"> <input label="Input label first" name="okp:autocomplete.first" type="text"/> <hpanel name="okp:autocomplete.horizontal1"> <input label="Input label 1" name="okp:autocomplete.input_h1" /> <input label="Input label 2" name="okp:autocomplete.input_h2" /> </hpanel> </property-group></property-groups>Metadata Extraction using AI
Section titled “Metadata Extraction using AI”If a document contains extracted text and the artificial intelligence parameters are properly configured in the OpenKM application settings, metadata can be automatically extracted using the following autocomplete plugin:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.11//EN" "http://www.openkm.com/dtd/property-groups-3.11.dtd"><property-groups> <property-group label="Consulting" name="okg:consulting" autocompleteValueClassName="com.openkm.plugin.form.values.AIAutocompleteFormValues"> <input label="Input label" name="okp:consulting.input1" /> <separator label="Separator label" name="okp:consulting.separator" /> <input label="Input label" name="okp:consulting.input2" /> </property-group></property-groups>