RegisteringAndAccidentViewPopulator.java
package org.andromda.samples.carrental.contracts.web.registerAccident;
import java.util.Map;
/**
* Provides the ability to populate any view in the Registering and Accident
*/
public final class RegisteringAndAccidentViewPopulator
{
/**
* Map fields from SelectContractRegisterFormImpl form
* to SelectContractRegisterFormImpl form
*
* @param fromForm origin form
* @param toForm destiny form
*/
public static void populateForm(SelectContractRegisterFormImpl fromForm, SelectContractRegisterFormImpl toForm)
{
if(fromForm.isIdContractSet())
{
toForm.setIdContract(fromForm.getIdContract());
}
}
/**
* Map fields from RegisteringAndAccidentFormImpl form
* to SelectContractRegisterFormImpl form
*
* @param fromForm origin form
* @param toForm destiny form
*/
public static void populateForm(RegisteringAndAccidentFormImpl fromForm, SelectContractRegisterFormImpl toForm)
{
if(fromForm.isIdContractSet())
{
toForm.setIdContract(fromForm.getIdContract());
}
}
/**
* Populate page variables for view Select Contract
*
* @param fromForm origin form
* @param pageVariables the page variables
*/
public static void populateSelectContractPageVariables(Object fromForm, Map<String,Object> pageVariables)
{
if(fromForm instanceof RegisteringAndAccidentFormImpl)
{
final RegisteringAndAccidentFormImpl sourceForm=(RegisteringAndAccidentFormImpl)fromForm;
if(sourceForm.isContractsSet())
{
pageVariables.put("contracts",sourceForm.getContracts());
}
}
}
/**
* Populates the view using the appropriate view populator.
*
* @param fromForm the origin form
* @param toForm the destiny form
*/
public static void populateForm(Object fromForm, SelectContractRegisterFormImpl toForm)
{
if(fromForm instanceof SelectContractRegisterFormImpl)
{
populateForm((SelectContractRegisterFormImpl)fromForm,toForm);
}
else if(fromForm instanceof RegisteringAndAccidentFormImpl)
{
populateForm((RegisteringAndAccidentFormImpl)fromForm,toForm);
}
}
}