Map<String, WorkDefinition> workDefinitions = new HashMap<String, WorkDefinition>();
Thread.currentThread().setContextClassLoader(newLoader);
List<Map<String, Object>> workDefinitionsMaps = new RuleBaseConfiguration().getWorkDefinitions();
for ( Map<String, Object> workDefinitionMap : workDefinitionsMaps ) {
if ( workDefinitionMap != null ) {
WorkDefinitionExtensionImpl workDefinition = new WorkDefinitionExtensionImpl();
workDefinition.setName( (String) workDefinitionMap.get( "name" ) );
workDefinition.setDisplayName( (String) workDefinitionMap.get( "displayName" ) );
workDefinition.setIcon( (String) workDefinitionMap.get( "icon" ) );
String customEditor = (String) workDefinitionMap.get( "eclipse:customEditor" );
if (customEditor == null) {
customEditor = (String) workDefinitionMap.get( "customEditor" );
}
if (customEditor == null) {
customEditor = "org.drools.eclipse.flow.common.editor.editpart.work.SampleCustomEditor";
}
workDefinition.setCustomEditor( customEditor );
Set<ParameterDefinition> parameters = new HashSet<ParameterDefinition>();
Map<String, DataType> parameterMap = (Map<String, DataType>) workDefinitionMap.get( "parameters" );
if ( parameterMap != null ) {
for ( Map.Entry<String, DataType> entry : parameterMap.entrySet() ) {
parameters.add( new ParameterDefinitionImpl( entry.getKey(),
entry.getValue() ) );
}
}
workDefinition.setParameters( parameters );
Set<ParameterDefinition> results = new HashSet<ParameterDefinition>();
Map<String, DataType> resultMap = (Map<String, DataType>) workDefinitionMap.get( "results" );
if ( resultMap != null ) {
for ( Map.Entry<String, DataType> entry : resultMap.entrySet() ) {
results.add( new ParameterDefinitionImpl( entry.getKey(),
entry.getValue() ) );
}
}
workDefinition.setResults( results );
workDefinitions.put( workDefinition.getName(),
workDefinition );
}
}
return workDefinitions;