Using Model Management

How to built you own Model Manager ?

To extend JIRA Database Model, you willhave to follow blow steps :

  • Extend a Model Manager,
  • Define the OFBiz entities to add (Group and Entities)
  • Register your Model Manager as Component.

Your Model Manager ?

Create a ModelManager extending the AbstractPluginModelManager as follow :
01.                 
02.package com.yourcompany.model;
03. 
04.import com.minyaa.model.AbstractPluginModelManager;
05. 
06.public class YourModelManager implements AbstractPluginModelManager {
07.    private static String entityModelFileName = "edit-webapp/WEB-INF/classes/entitydefs/entitymodel.yourcompany.xml";
08. 
09.    private static String entityGroupModelFileName = "edit-webapp/WEB-INF/classes/entitydefs/entitygroup.yourcompany.xml";
10.     
11.    public YourModelManager(final PluginModelManagerDirectory _pluginModelManagerDirectory) {
12.        super(_pluginModelManagerDirectory);
13.    }
14. 
15.    /**
16.     * @see com.minyaa.model.PluginModelManager.getEntityModelFileName()
17.     */
18.    public String getEntityModelFileName() {
19.        return entityModelFileName;
20.    }
21.     
22.    /**
23.     * @see com.minyaa.model.PluginModelManager.getEntityGroupModelFileName()
24.     */
25.    public String getEntityGroupModelFileName() {
26.        return entityGroupModelFileName;
27.    }
28. 
29.    /**
30.     * @see com.minyaa.model.PluginModelManager.getPluginKey()
31.     */
32.    public String getPluginKey() {
33.        return "com.yourcompany.plugin";
34.    }
35.}


Added OFBiz Entities

Define as resource the OFBiz Group an Entities to add ..
  1. Create the Entity OFBiz configuration file edit-webapp/WEB-INF/classes/entitydefs/entitymodel.yourcompany.xml

    01.                 
    02.<?xml version="1.0" encoding="UTF-8"?>
    03.<!DOCTYPE entitymodel PUBLIC "-//OFBiz//DTD Entity Model//EN" "http://oss.org.cn/ossdocs/applications/ofbiz/ofbiz-2.1.1-docs/website/dtds/entitymodel.dtd">
    04. 
    05.<entitymodel>
    06.    <title>Entity Model for Your Plugin</title>
    07.    <description>Entities added to store Your Data</description>
    08.    <author>You</author>
    09.    <version>X.Y</version>
    10.     
    11.    <entity entity-name="YourEntity" table-name="companyprefix_your_entity" package-name="">
    12.    ...
    13.    </entity>
    14. 
    15.</entitymodel>


  2. Create the Group OFBiz configuration file edit-webapp/WEB-INF/classes/entitydefs/entitygroup.yourcompany.xml

    1.                 
    2.<?xml version="1.0" encoding="UTF-8"?>
    3.<!DOCTYPE entitygroup PUBLIC "-//OFBiz//DTD Entity Group//EN" "http://oss.org.cn/ossdocs/applications/ofbiz/ofbiz-2.1.1-docs/website/dtds/entitygroup.dtd">
    4. 
    5.<entitygroup>
    6.    <entity-group group="default" entity="YourEntity"/>
    7.</entitygroup>


Model Manager registration

Finally, define your ModelManager as component in atlassian-plugin.xml :
01.                 
02.<atlassian-plugin key="jira.plugin.yourcompany.model" name="Your Company Plugin for Database Model Extension">
03.    <plugin-info>
04.        <description>${pom.description}</description>
05.        <version>${pom.version}</version>
06.        <vendor name="${pom.organization.name}" url="${pom.organization.url}"/>
07.    </plugin-info>
08.    ...
09.    <component key="YourModelManager" name="YourModelManager" class="com.yourcompany.model.YourModelManager" />
10.    ...
11.</atlassian-plugin>



Loading...