use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class BuildServiceImplTest method testApplyBatchResourceChanges.
@Test
public void testApplyBatchResourceChanges() {
when(buildServiceHelper.localBuild(module, resourceChanges)).thenReturn(incrementalBuildResults);
IncrementalBuildResults result = buildService.applyBatchResourceChanges(module, resourceChanges);
assertEquals(incrementalBuildResults, result);
verify(buildServiceHelper, times(1)).localBuild(module, resourceChanges);
}
use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class BuildHelper method deletePackageResource.
public IncrementalBuildResults deletePackageResource(final Path resource) {
try {
IncrementalBuildResults results = new IncrementalBuildResults();
final KieModule module = moduleService.resolveModule(resource);
if (module == null) {
return results;
}
final Builder builder = cache.assertBuilder(module);
if (!builder.isBuilt()) {
throw new IllegalStateException("Incremental Build requires a full build be completed first.");
} else {
results = builder.deleteResource(Paths.convert(resource));
}
return results;
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults 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;
}
use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class Builder method deleteResource.
public IncrementalBuildResults deleteResource(final Path resource) {
checkNotNull("resource", resource);
checkAFullBuildHasBeenPerformed();
// Resource Type might have been validated "externally" (i.e. it's not covered by Kie). Clear any errors.
final IncrementalBuildResults results = new IncrementalBuildResults(projectGAV);
final BuildValidationHelper validator = getBuildValidationHelper(resource);
if (validator != null) {
nonKieResourceValidationHelpers.remove(resource);
results.addAllRemovedMessages(convertValidationMessages(nonKieResourceValidationHelperMessages.remove(resource)));
}
synchronized (kieFileSystem) {
removeResource(resource);
buildIncrementally(results, destinationPath(resource));
}
return results;
}
use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class Builder method addResource.
private IncrementalBuildResults addResource(final Path resource, final InputStream inputStream) {
checkNotNull("resource", resource);
// Only files can be processed
if (!Files.isRegularFile(resource)) {
return new IncrementalBuildResults(projectGAV);
}
checkAFullBuildHasBeenPerformed();
// Resource Type might require "external" validation (i.e. it's not covered by Kie)
final IncrementalBuildResults results = new IncrementalBuildResults(projectGAV);
final BuildValidationHelper validator = getBuildValidationHelper(resource);
if (validator != null) {
final List<ValidationMessage> addedValidationMessages = validator.validate(Paths.convert(resource));
results.addAllAddedMessages(convertValidationMessages(addedValidationMessages));
results.addAllRemovedMessages(convertValidationMessages(nonKieResourceValidationHelperMessages.remove(resource)));
nonKieResourceValidationHelpers.put(resource, validator);
nonKieResourceValidationHelperMessages.put(resource, addedValidationMessages);
}
synchronized (kieFileSystem) {
addNewResource(resource, inputStream);
buildIncrementally(results, destinationPath(resource));
}
return results;
}
Aggregations