| 22 | |
| 23 | Let's start with a very simple plugin. This plugin will just create a new topic type called `Tag`. Once the plugin is installed the topic type will appear in the DeepaMehta webclient's //Create// menu, so you can create instances. And you will be able to fulltext search for tags. |
| 24 | |
| 25 | Developing such a simple plugin involves no Java coding at all. All is declarative, mainly in JSON format. |
| 26 | |
| 27 | Of course the topic type could be created interactively as well, by using DeepaMehta's type editor. However, being packaged as a plugin you can publish it. When other DeepaMehta users install your plugin they can use your type definitions. |
| 28 | |
| 29 | You create the plugin just by creating directories and text files. A DeepaMehta plugin project adheres to a certain directory structure and file name conventions. |
| 30 | |
| 31 | Setup a directory structure as follows: |
| 32 | {{{ |
| 33 | dm4-tagging/ |
| 34 | pom.xml |
| 35 | src/ |
| 36 | main/ |
| 37 | resources/ |
| 38 | migrations/ |
| 39 | migration1.json |
| 40 | plugin.properties |
| 41 | }}} |
| 42 | |
| 43 | Create the file **`pom.xml`** with this content: |
| 44 | {{{ |
| 45 | <project> |
| 46 | <modelVersion>4.0.0</modelVersion> |
| 47 | |
| 48 | <name>DM4 Tagging</name> |
| 49 | <groupId>org.mydomain.dm4-plugins</groupId> |
| 50 | <artifactId>tagging</artifactId> |
| 51 | <version>0.1-SNAPSHOT</version> |
| 52 | <packaging>bundle</packaging> |
| 53 | |
| 54 | <parent> |
| 55 | <groupId>de.deepamehta</groupId> |
| 56 | <artifactId>deepamehta-plugin-parent</artifactId> |
| 57 | <version>4.1.1-SNAPSHOT</version> |
| 58 | </parent> |
| 59 | </project> |
| 60 | }}} |
| 61 | |
| 62 | Create the file **`migration1.json`**: |
| 63 | {{{ |
| 64 | { |
| 65 | topic_types: [ |
| 66 | { |
| 67 | value: "Tag", |
| 68 | uri: "domain.tagging.tag", |
| 69 | data_type_uri: "dm4.core.text", |
| 70 | index_mode_uris: ["dm4.core.fulltext"], |
| 71 | view_config_topics: [ |
| 72 | { |
| 73 | type_uri: "dm4.webclient.view_config", |
| 74 | composite: { |
| 75 | dm4.webclient.show_in_create_menu: true |
| 76 | } |
| 77 | } |
| 78 | ] |
| 79 | } |
| 80 | ] |
| 81 | } |
| 82 | }}} |
| 83 | |
| 84 | Create the file **`plugin.properties`**: |
| 85 | {{{ |
| 86 | requiredPluginMigrationNr = 1 |
| 87 | importModels = de.deepamehta.webclient |
| 88 | }}} |