@Override
 public void execute() throws SBonitaException {
   final SDependency sDependency =
       BuilderFactory.get(SPlatformDependencyBuilderFactory.class)
           .createNewInstance(name, name + ".jar", jar)
           .done();
   this.dependencyService.createDependency(sDependency);
   final SDependencyMapping sDependencyMapping =
       BuilderFactory.get(SPlatformDependencyMappingBuilderFactory.class)
           .createNewInstance(sDependency.getId(), artifactId, artifactType)
           .done();
   this.dependencyService.createDependencyMapping(sDependencyMapping);
 }
Exemple #2
0
  @Test
  public void checkDependenciesAreDeletedWhenProcessIsDeleted() throws Exception {
    final TenantServiceAccessor tenantAccessor = getTenantAccessor();
    final DependencyService dependencyService = tenantAccessor.getDependencyService();
    final UserTransactionService transactionService = tenantAccessor.getUserTransactionService();
    final ProcessDefinitionBuilder processDef =
        new ProcessDefinitionBuilder().createNewInstance("processToTestTransitions", "1.0");
    processDef.addStartEvent("start");
    processDef.addUserTask("step1", ACTOR_NAME);
    processDef.addEndEvent("end");
    processDef.addTransition("start", "step1");
    processDef.addTransition("step1", "end");
    processDef.addActor(ACTOR_NAME);
    final byte[] content = new byte[] {1, 2, 3, 4, 5, 6, 7};
    final BusinessArchive businessArchive =
        new BusinessArchiveBuilder()
            .createNewBusinessArchive()
            .setProcessDefinition(processDef.done())
            .addClasspathResource(new BarResource("myDep", content))
            .done();
    final ProcessDefinition definition =
        deployAndEnableProcessWithActor(businessArchive, ACTOR_NAME, john);
    final ProcessInstance processInstance = getProcessAPI().startProcess(definition.getId());
    final Long step1Id = waitForUserTask(processInstance, "step1");
    List<Long> dependencyIds =
        transactionService.executeInTransaction(
            new GetDependenciesIds(getSession(), definition.getId(), dependencyService, 0, 100));
    assertEquals(1, dependencyIds.size());
    final SDependency dependency =
        transactionService.executeInTransaction(
            new GetSDependency(dependencyIds.get(0), dependencyService));
    assertTrue(dependency.getName().endsWith("myDep"));
    assertTrue(Arrays.equals(content, dependency.getValue()));

    assignAndExecuteStep(step1Id, john);
    waitForProcessToFinish(processInstance);
    disableAndDeleteProcess(definition);

    dependencyIds =
        transactionService.executeInTransaction(
            new GetDependenciesIds(getSession(), definition.getId(), dependencyService, 0, 100));
    assertEquals(0, dependencyIds.size());
  }