use of eu.esdihumboldt.hale.ui.function.generic.pages.GenericParameterPage in project hale by halestudio.
the class AbstractGenericFunctionWizard method createParameterPages.
/**
* Create parameter pages.
*
* @param initialValues the initial parameter values, may be
* <code>null</code>
* @return the list of parameter pages
*/
protected List<ParameterPage> createParameterPages(@Nullable ListMultimap<String, ParameterValue> initialValues) {
LinkedList<ParameterPage> parameterPages = new LinkedList<ParameterPage>();
// create copy of function parameter set
Set<FunctionParameterDefinition> functionParameters = new LinkedHashSet<>();
for (FunctionParameterDefinition param : getFunction().getDefinedParameters()) functionParameters.add(param);
if (initialValues != null)
initialValues = Multimaps.unmodifiableListMultimap(initialValues);
// get available parameter pages
List<ParameterPageFactory> paramPageFactories = ParameterPageExtension.getInstance().getFactories(new FactoryFilter<ParameterPage, ParameterPageFactory>() {
@Override
public boolean acceptFactory(ParameterPageFactory factory) {
return factory.getFunctionId().equals(getFunctionId());
}
@Override
public boolean acceptCollection(ExtensionObjectFactoryCollection<ParameterPage, ParameterPageFactory> collection) {
return true;
}
});
// use available parameter pages (first come first serve)
for (ParameterPageFactory paramPageFactory : paramPageFactories) {
Set<FunctionParameterDefinition> pageFunctionParameters = new HashSet<>();
for (FunctionParameterDefinition fp : paramPageFactory.getAssociatedParameters()) if (functionParameters.contains(fp))
pageFunctionParameters.add(fp);
if (!pageFunctionParameters.isEmpty()) {
ParameterPage paramPage;
try {
paramPage = paramPageFactory.createExtensionObject();
} catch (Exception e) {
log.error("Could not creating parameter page " + paramPageFactory.getIdentifier(), e);
continue;
}
functionParameters.removeAll(pageFunctionParameters);
parameterPages.add(paramPage);
paramPage.setParameter(pageFunctionParameters, initialValues);
}
}
// use generic parameter page for remaining parameters
if (!functionParameters.isEmpty()) {
ParameterPage generic = new GenericParameterPage();
generic.setParameter(functionParameters, initialValues);
parameterPages.add(generic);
}
return parameterPages;
}
Aggregations