Skip to content
This repository was archived by the owner on Nov 15, 2019. It is now read-only.

Manual Measure Implementation

Antonin Abherve edited this page Nov 10, 2017 · 15 revisions

Even if we recommend to use Modelio and his extension dedicated to SMM modeling, you still have the possibility to implement and package manually your measures.

An SMM Measure is composed of several artefactes: The java implementation of the measure as a jar file, a lib folder containing the Java libraries used by the measure implementation and a MeasureMetaData.xml file containing meta-data related to the measure.In order to implement the measure you will have to provide these three artefactes.

This files as to be packaged as a zip file.

Java implementation packaged as jar file

Java Measure Project Template

  • Create manually a new Java project You can create manually a new Standard Java 8 project to implement your measure. To implement a valid measure you will have to integrate the 0.2.08 version of SMMMeasureApi library in your project (https://github.com/ITEA3-Measure/SMMMeasureApi)

The library is also available as a Maven dependency:

<repositories>
  <repository>
    <id>Modelio</id>
    <url>http://repository.modelio.org/</url>
  </repository>
</repositories>
<dependencies>
  <dependency>
    <groupId>org.measure.smmmeasure.api</groupId>
    <artifactId>SMMMeasureApi</artifactId>
    <version>0.6.00</version>
  </dependency>	
</dependencies>

Implement the measure

To implement the measure, you will have the complete the DirectMeasureImpl / DerivedMeasureImpl Java class generated from the Modelio project.

Build the measure

the implementation of a measure is integrated as a jar file.

Meta Data File

MeasureMetaData.xml

The MetaData.xml file contains meta-datas related to the SMM Measure:

  • Name, description, catgory and provider of the Measure
  • Type of the Measure
  • Unite (data model) of the measure
  • List of properties of the measure
  • List of references for Derived Measure (inputs form others measures)
Element Cardianlity Attribute Description
Measure 1 The Measure
name Name / Id of the Measure
type SMM Type of the measure : [DIRECT,COLLECTIVE,RACKING,GRADE,BINARY,COUNTING,ESCALED,RATIO]
category Classification of the measure by category
provider People / Entity which developed the measure
description 1 (Measure) Description of the Measure
unite 1 (Measure) DataModel of measurements returned by the measure
fields * (unite) A Field of the measure unite
fieldName Name of the field
fieldType Type of the field : [u_text,u_integer,u_long,u_date,u_boolean,u_float,u_geo_point,...]
scopeProperties * (Measure) A property user to configure the execution of the measure
name Name of the property
defaultValue Default value of the property
type Type of the property :[STRING,INTEGER,FLOAT,DATE,ENUM,PASSWORD,DESABLE]
description 1(scopeProperties ) Description of the scope property
enumType 1(scopeProperties) Emum definition for scopeProperties of type ENUM
enumvalue *(enumType) Emum values
label label of the enum entry
value value of the enum entry
references * (Measure) References to inputs required by Derived Measures
measureRef Name of the required measure
number Default Number of instance of this input required
expirationDelay Filter old measurement
references-role 1 Role of the imput in current Measurement. This role allow to identifyseveral instance of the same Measure in a DerivedMeasure.

Example of a MeasureMetaData.xml file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Measure name="RandomMeasure" type="DIRECT">
    <description>Return a random measure and his variation</description>
    <scopeProperties defaultValue="100" name="MaxRange" type="INTEGER">
        <description>MaxRange</description>
    </scopeProperties>
    <scopeProperties defaultValue="0" name="MinRange" type="FLOAT">
        <description>MinRange</description>
    </scopeProperties>
    <scopeProperties defaultValue="0" name="PreviousValue" type="DESABLE">
        <description>PreviousValue</description>
    </scopeProperties>
    <scopeProperties defaultValue="Borned" name="Kind" type="ENUM">
        <description>Kind</description>
        <enumType>
            <enumvalue label="Is Borrned" value="Borned"/>
            <enumvalue label="Not Borrned" value="UnBorned"/>
        </enumType>
    </scopeProperties>
    <scopeProperties name="TestDate" type="DATE">
        <description>TestDate</description>
    </scopeProperties>
    <scopeProperties name="TestPassword" type="PASSWORD">
        <description>TestPassword</description>
    </scopeProperties>
    <scopeProperties name="TestString" type="STRING">
        <description>TestString</description>
    </scopeProperties>
    <unit name="RandomMeasurement">
        <fields fieldName="FinalValue4" fieldType="u_double"/>
        <fields fieldName="Variation4" fieldType="u_integer"/>
        <fields fieldName="myDate" fieldType="u_date"/>
    </unit>
</Measure>

Product the MetaData.xml file

The MeasureMetaData.xml file can be generated using JAXB :


	public static void main(String[] args) {
	SMMMeasure measure = new SMMMeasure();
		measure.setName("RandomGenerator");
		measure.setDescription("A Test Measure delivering a random number at each execution");
		measure.setType(MeasureType.DIRECT);
		measure.setCategory("Test");
		measure.setProvider("Softeam");
		
		MeasureUnit unit = new MeasureUnit();
		MeasureUnitField f1 = new MeasureUnitField();
		f1.setFieldName("postDate");
		f1.setFieldType(FieldType.u_date);
		unit.getFields().add(f1);
		
		MeasureUnitField f2 = new MeasureUnitField();
		f2.setFieldName("myValue");
		f2.setFieldType(FieldType.u_double);
		unit.getFields().add(f2);
		
		measure.setUnit(unit);

		ScopeProperty minRange = new ScopeProperty();
		minRange.setName("MinRange");
		minRange.setDescription("Min range of RandomGenerator");
		minRange.setDefaultValue("0");
		minRange.setType(ScopePropertyType.INTEGER);

		ScopeProperty maxRange = new ScopeProperty();
		maxRange.setName("MaxRange");
		maxRange.setDescription("Max range of RandomGenerator");
		maxRange.setDefaultValue("100");
		maxRange.setType(ScopePropertyType.INTEGER);
		
		ScopeProperty delta = new ScopeProperty();
		delta.setName("Delta");
		delta.setDescription("Delta max between 2 value ");
		delta.setDefaultValue("5");
		delta.setType(ScopePropertyType.INTEGER);
		
		ScopeProperty previous = new ScopeProperty();
		previous.setName("PreviousValue");	
		previous.setDefaultValue("0");
		previous.setType(ScopePropertyType.DESABLE);

		measure.getScopeProperties().add(minRange);
		measure.getScopeProperties().add(maxRange);
		measure.getScopeProperties().add(delta);
		measure.getScopeProperties().add(previous);
		
		File xmlTmpFile = File.createTempFile("SMMMeasure", "xml");

		JAXBContext context = JAXBContext.newInstance(SMMMeasure.class);
		Marshaller m = context.createMarshaller();
		m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		m.marshal(measure, xmlTmpFile);
	}

Manual Packaging

The Packaged Measure is a simple ZIP organised as :

  • Measure (Folder)
    • MeasureImplementation.jar (Jar file containing the measure implementation)
    • MeasureMetaData.xml (XML file whit measure meta-datas)
    • lib (Folder)
      • javalibrary1.jar (java library used by the implementation)
      • javalibrary2.jar

Clone this wiki locally