Commit 034d43a8 authored by Pietro Braghieri's avatar Pietro Braghieri
Browse files

Update OSLC_README.md

parent fa3470f1
......@@ -55,7 +55,7 @@ For example, to get the list the available Automation Plans, calls the end point
#### Extend an existing Automation Plan
Suppose you want to extend an analysis tool function by adding a new parameter.
For example, we need to add the parameter `wholeArchitecture` of type `boolean` to the function `Check Contract Validation Property`.
We have to work only on the OSLC client side, following these steps:
We have to work on both the client side and the server side following these steps:
##### Client Side
Suppose that the `wholeArchitecture` attribute is already present in the class `eu.fbk.tools.adapter.ocra.CheckValidationProperty.java`.
......@@ -98,47 +98,188 @@ case ToolParameterConstants.PARAM_BEHAVIOUR_MODEL:
}
break;
```
##### Server Side
In this case, we have to modify the plugin [eu.fbk.tools.oslc.provider](/bundles/eu.fbk.tools.oslc.provider) as follow:
* add the following method in the class `eu.fbk.tools.oslc.automation.resources.PlanCatalog.java`
```
private static Property getWholeArchitectureProperty()
{
final Property property = new Property();
property.setName(ToolParameterConstants.PARAM_WHOLE_ARCHITECTURE);
property.setTitle("Whole Architecture");
property.setValueType(ValueType.String);
property.setDescription("If set, compute whole architecture");
property.setOccurs(Occurs.ZeroOrOne);
return property;
}
```
and add the invocation of such method in the `getContractPropertyValidationPlan()` method:
```
public static AutomationPlan getContractPropertyValidationPlan()
{
final AutomationPlan plan = new AutomationPlan();
plan.setIdentifier(CheckValidationProperty.FUNCTION_NAME);
plan.setTitle(CheckValidationProperty.FUNCTION_NAME);
plan.setDescription(CheckValidationProperty.DESCRIPTION);
plan.addParameterDefinition(getTimeoutProperty());
plan.addParameterDefinition(getAsynchronousExecutionProperty());
plan.addParameterDefinition(getContractModelProperty());
plan.addParameterDefinition(getComponentNameProperty());
plan.addParameterDefinition(getTimeModelProperty());
plan.addParameterDefinition(getPropertyValidationType());
plan.addParameterDefinition(getOcraAlgorithmTypeProperty());
plan.addParameterDefinition(getPropertyNameProperty());
plan.addParameterDefinition(getPropertiesProperty());
plan.addParameterDefinition(getPossibilityProperty());
plan.addParameterDefinition(getWholeArchitectureProperty());
try
{
new AutomationPlanResource().createResourceInternal(plan);
}
catch (URISyntaxException e)
{
logger.error(e.getMessage());
}
return plan;
}
```
#### Add a new Automation Plan
Suppose we have already defined a new function (e.g. `GenerateMiterArchitecture`) and we want to implement the remote version.
Suppose we have already defined a new function (e.g. `CheckValidationProperty`) and we want to implement the remote version.
We have to work on both the client side and the server side following these steps:
##### Client Side
As described in the previous case, we need to implement the `getParameters()` and `setParameters()` methods, according to the function parameters.
As described in the previous case, we need to implement the `getParameters()` and `setParameters()` methods, according to the function parameters.
```
@Override
public List<ToolFunctionParameter> getParameters()
{
final List<ToolFunctionParameter> parameters = super.getParameters();
if( componentsMapping != null)
if( componentName != null)
{
parameters.add(new ToolFunctionParameter(ToolParameterConstants.PARAM_COMPONENT_NAME, componentName));
}
if( wholeArchitecture != null)
{
parameters.addAll(getMapParameter(ToolParameterConstants.PARAM_COMPONENTS_MAPPING, componentsMapping));
parameters.add(new ToolFunctionParameter(ToolParameterConstants.PARAM_WHOLE_ARCHITECTURE, wholeArchitecture.toString()));
}
if( propertyValidationType != null)
{
parameters.add(new ToolFunctionParameter(ToolParameterConstants.PARAM_PROPERTY_VALIDATION_TYPE, propertyValidationType.toString()));
}
if( propertyName != null)
{
parameters.add(new ToolFunctionParameter(ToolParameterConstants.PARAM_PROPERTY_NAME, propertyName));
}
if( properties != null)
{
parameters.add(new ToolFunctionParameter(ToolParameterConstants.PARAM_PROPERTIES, properties));
}
if( possibility != null)
{
parameters.add(new ToolFunctionParameter(ToolParameterConstants.PARAM_POSSIBILITY, possibility));
}
return parameters;
}
@Override
public void setParameters(List<ToolFunctionParameter> parameters)
protected void setParameter(ToolFunctionParameter parameter)
{
for( ToolFunctionParameter parameter : parameters )
switch( parameter.name )
{
switch( parameter.name )
{
case ToolParameterConstants.PARAM_COMPONENTS_MAPPING:
componentsMapping = setMapParameter(ToolParameterConstants.PARAM_COMPONENTS_MAPPING, parameters);
break;
default:
setParameter(parameter);
break;
}
case ToolParameterConstants.PARAM_COMPONENT_NAME:
componentName = parameter.value;
break;
case ToolParameterConstants.PARAM_WHOLE_ARCHITECTURE:
wholeArchitecture = Boolean.valueOf(parameter.value);
break;
case ToolParameterConstants.PARAM_PROPERTY_VALIDATION_TYPE:
try
{
propertyValidationType = PropertyValidationType.valueOf(parameter.value);
}
catch (Exception e)
{
logger.error("Invalid " + parameter.name +": " + parameter.value == null ? "null value" : parameter.value);
}
break;
case ToolParameterConstants.PARAM_PROPERTY_NAME:
propertyName = parameter.value;
break;
case ToolParameterConstants.PARAM_PROPERTIES:
properties = parameter.value;
break;
case ToolParameterConstants.PARAM_POSSIBILITY:
possibility = parameter.value;
break;
default:
super.setParameter(parameter);
break;
}
}
```
##### Server Side
In this case, we have to modify the plugin [eu.fbk.tools.oslc.provider](/bundles/eu.fbk.tools.oslc.provider)
###### New AutomationPlan definition
* add the following methods in the class `eu.fbk.tools.oslc.automation.resources.PlanCatalog.java`
```
public static AutomationPlan getContractPropertyValidationPlan()
{
final AutomationPlan plan = new AutomationPlan();
plan.setIdentifier(CheckValidationProperty.FUNCTION_NAME);
plan.setTitle(CheckValidationProperty.FUNCTION_NAME);
plan.setDescription(CheckValidationProperty.DESCRIPTION);
plan.addParameterDefinition(getTimeoutProperty());
plan.addParameterDefinition(getAsynchronousExecutionProperty());
plan.addParameterDefinition(getContractModelProperty());
plan.addParameterDefinition(getComponentNameProperty());
plan.addParameterDefinition(getTimeModelProperty());
plan.addParameterDefinition(getPropertyValidationType());
plan.addParameterDefinition(getOcraAlgorithmTypeProperty());
plan.addParameterDefinition(getPropertyNameProperty());
plan.addParameterDefinition(getWholeArchitectureProperty());
plan.addParameterDefinition(getPropertiesProperty());
plan.addParameterDefinition(getPossibilityProperty());
try
{
new AutomationPlanResource().createResourceInternal(plan);
}
catch (URISyntaxException e)
{
logger.error(e.getMessage());
}
return plan;
}
```
#### Web Server Installation
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment