if ( imports == null || imports.isEmpty() ) {
return;
}
//Load existing PackageImports
ProjectImports projectImports = new ProjectImports();
final org.uberfire.java.nio.file.Path nioExternalImportsPath = Paths.convert( context ).resolve( "project.imports" );
final Path externalImportsPath = Paths.convert( nioExternalImportsPath );
if ( Files.exists( nioExternalImportsPath ) ) {
projectImports = projectService.load( externalImportsPath );
}
//Make collections of existing Imports so we don't duplicate them when adding the new
List<String> existingImports = new ArrayList<String>();
for ( org.drools.workbench.models.datamodel.imports.Import item : projectImports.getImports().getImports() ) {
existingImports.add( item.getType() );
}
//Add imports
boolean isModified = false;
for ( Import item : imports ) {
if ( !existingImports.contains( item.getClassName() ) ) {
isModified = true;
result.addMessage( "Created Import for '" + item.getClassName() + "'.",
ConversionMessageType.INFO );
projectImports.getImports().addImport( new org.drools.workbench.models.datamodel.imports.Import( item.getClassName() ) );
}
}
//Save update
if ( isModified ) {