use of org.uberfire.workbench.events.ResourceChangeType in project kie-wb-common by kiegroup.
the class Builder method applyBatchResourceChanges.
public IncrementalBuildResults applyBatchResourceChanges(final Map<org.uberfire.backend.vfs.Path, Collection<ResourceChange>> changes) {
checkNotNull("changes", changes);
checkAFullBuildHasBeenPerformed();
// Add all changes to KieFileSystem before executing the build
final List<String> changedFilesKieBuilderPaths = new ArrayList<String>();
final List<ValidationMessage> nonKieResourceValidatorAddedMessages = new ArrayList<ValidationMessage>();
final List<ValidationMessage> nonKieResourceValidatorRemovedMessages = new ArrayList<ValidationMessage>();
final IncrementalBuildResults results = new IncrementalBuildResults(projectGAV);
synchronized (kieFileSystem) {
for (final Map.Entry<org.uberfire.backend.vfs.Path, Collection<ResourceChange>> pathCollectionEntry : changes.entrySet()) {
for (final ResourceChange change : pathCollectionEntry.getValue()) {
final ResourceChangeType type = change.getType();
final Path resource = Paths.convert(pathCollectionEntry.getKey());
checkNotNull("type", type);
checkNotNull("Builder.resourceĀ§", resource);
final String destinationPath = destinationPath(resource);
changedFilesKieBuilderPaths.add(destinationPath);
switch(type) {
case ADD:
case UPDATE:
// Only files can be processed
if (!Files.isRegularFile(resource)) {
continue;
}
update(nonKieResourceValidatorAddedMessages, nonKieResourceValidatorRemovedMessages, resource);
break;
case DELETE:
delete(nonKieResourceValidatorRemovedMessages, resource);
}
}
}
// Perform the Incremental build and get messages from incremental build
buildIncrementally(results, toArray(changedFilesKieBuilderPaths));
}
// Copy in BuildMessages for non-KIE resources
results.addAllAddedMessages(convertValidationMessages(nonKieResourceValidatorAddedMessages));
results.addAllRemovedMessages(convertValidationMessages(nonKieResourceValidatorRemovedMessages));
return results;
}
Aggregations