You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »


his page will help you to build your own Worklog Field.

Prerequisites

You will need to follow below prerequisites :

Module Types provided by Minyaa Time

To allow to develop your own Worklog Field, Minyaa Time provides 2 disctints Module Types :

  • <plugin-model /> : It allows a plugin to defined additional OFBiz Entity Configurations.
  • <worklog-field /> : It allows to define a new Worklog Field


Your Worklog Field Plugin step by step ..

Step 1. Create the plugin skeleton

Here, you will create your plugin skeleton with your preferred solution :

Step 2. Update your Maven POM ...

... related the dependencies

In terms of dependencies, you will need to append Minyaa Time (here for JIRA 7.3.x using Minyaa Time 1.16)

<project ...>
	<dependencies>
		<dependency>
			<groupId>com.atlassian.jira</groupId>
			<artifactId>jira-api</artifactId>
			<version>${jira.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>fr.alkaes.minyaa</groupId>
			<artifactId>jira-plugin-minyaa-time</artifactId>
			<version>${minyaa.time.version}</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>
	...
	<properties>
		<jira.version>7.3.0</jira.version>
		<jira.data.version>${jira.version}</jira.data.version>
		<minyaa.time.version>7300.1.16</minyaa.time.version>
	</properties>
</project>

... related the Maven JIRA Plugin

Since the components implemented in your plugin will have to be loaded by Minyaa Time, you will have to make them exportable.

Here, we assume that your Worklog Fields have com.yourcompany.jira.worklogfields as package.

Step 3. Create your Worklog Fields Classes

Then, you will have to develop your first Worklog Field class ...

Interface WorklogField

Minyaa Time provides the below WorklogField interface

and also an abstract implementation : fr.alkaes.myaatm.worklog.fields.AbstractWorklogField.

When you will implement your own Worklog Field, you WILL HAVE TO use it.

Sample : Chargeable

Here the source of fr.alkaes.myaatm.worklog.fields.impl.Chargeable, a Worklog Field provided by default in Minyaa Time (just a sample for the moment).

Validation capacities

If needed, you will be able to validate your field against :

  • Worklog : The current Worklog is referenced in the Field
  • and other Worklog Fields : Map of other Worklog Field is passed to the validate() method with a key based on "entityName:fieldName"

Create also all needed Worklog Fields.

Step 4. Configure your OFBiz Entity

When you have defined all your Worklog Fields, you will have to prepare the OFBiz configuration and also be able to store their values.

It will require 2 distinct XML files :

  • The entity group file where your additional entities will be listed.
  • The entity model file where each of this entity will be configure for each fields

NB : Your are able to store your Worklog Field in one or many entities as you want,

Here is the sample configuration for 2 Worklog Fields stored in 1 Entity

  • <?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>
    
        <!-- WorklogType data -->
        <entity-group group="default" entity="SampleWorklogField"/>
    
    </entitygroup>
  • <?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 Sample Worklog Fields</title>
    	<description>Entities added to extend Worklog Features</description>
    	<copyright>Copyright (c) 2017-2017 Alkaes Consulting</copyright>
    	<author>Vincent Thoule</author>
    	<version>1.16</version>
    
    	<entity entity-name="SampleWorklogField" table-name="sampleworklogfields" package-name="">
    
    		<!-- Mandatory Field used to identify the Worklog -->
    		<field name="id" type="numeric" />
    
    		<!-- "Chargeable" stored as small string -->
    		<field name="chargeable" type="short-varchar" />
    
    
    		<!-- "Chargeable Hours" stored as Double (Number) -->
    		<field name="chargeablehours" type="floating-point" />
    
    
    		<!-- Define Id as the Primary Key -->
    		<prim-key field="id" />
    
    		<!-- Define a relation 0,1 to 1 with Worklog -->
    		<relation type="one" title="Is" rel-entity-name="Worklog">
    			<key-map field-name="id" rel-field-name="id" />
    		</relation>
    	</entity>
    </entitymodel>


Step 4. Configure your Modules in Atlassian Descriptor

When you have implemented all needed Worklog Fields and defined how they will stored in database, you will have to complete the configuration of the Atlassian Descriptor (atlassian-plugin.xml) of your plugin.

You will have to use the 2 module-types previously mentioned ...

Worklog Fields Entity Model Declaration

The <plugin-model /> module type allows you to declare the OFBiz Configuraiton files. They will be injected in OFBiz as soon as the plugin is enabled.

Attributes / Elements

NameRequiredDescriptionDefault
key(tick)The unique identifier of the plugin module.n/a
name
A simple Human readable name of the plugin modulen/a

(tick)
n/a


Element - Resource

NameRequiredDescription
type(tick)Only type="ofbiz" is expected
name(tick)

Two name are supported :

  • name="entity" for the OFBiz entity model file
  • name="entitygroup" for the OFBiz entity group file
location(tick)The location of the OFBiz configuration file

Sample Declaration


Worklog Fields Classes Declaration

Sample Descriptor

Step 5. Build and Deploy


<project ...>
</project>
<plugin-model />

 

On this page:

  • No labels