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 :
				
package com.yourcompany.model;

import com.minyaa.model.AbstractPluginModelManager;

public class YourModelManager implements AbstractPluginModelManager {
	private static String entityModelFileName = "edit-webapp/WEB-INF/classes/entitydefs/entitymodel.yourcompany.xml";

	private static String entityGroupModelFileName = "edit-webapp/WEB-INF/classes/entitydefs/entitygroup.yourcompany.xml";
	
	public YourModelManager(final PluginModelManagerDirectory _pluginModelManagerDirectory) {
		super(_pluginModelManagerDirectory);
	}

	/**
	 * @see com.minyaa.model.PluginModelManager.getEntityModelFileName() 
	 */
	public String getEntityModelFileName() {
		return entityModelFileName;
	}
	
	/**
	 * @see com.minyaa.model.PluginModelManager.getEntityGroupModelFileName()
	 */
	public String getEntityGroupModelFileName() {
		return entityGroupModelFileName;
	}

	/**
	 * @see com.minyaa.model.PluginModelManager.getPluginKey()
	 */
	public String getPluginKey() {
		return "com.yourcompany.plugin";
	}
}


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

    				
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE entitymodel PUBLIC "-//OFBiz//DTD Entity Model//EN" "http://oss.org.cn/ossdocs/applications/ofbiz/ofbiz-2.1.1-docs/website/dtds/entitymodel.dtd">
    
    <entitymodel>
    	<title>Entity Model for Your Plugin</title>
    	<description>Entities added to store Your Data</description>
    	<author>You</author>
    	<version>X.Y</version>
    	
    	<entity entity-name="YourEntity" table-name="companyprefix_your_entity" package-name="">
    	...
    	</entity>
    
    </entitymodel>
    


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

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


Model Manager registration

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