예제 #1
0
  @SuppressWarnings("static-access")
  public void testDownloadDefaultTemplate() {
    LookAndFeelPropertySection tester = new LookAndFeelPropertySection();
    ResourceType t = ApplicationResourceFileStore.ResourceType.PROCESS_TEMPLATE;
    final String fileName = "process.html";
    assertNotNull(
        "ResourceType PORCESS_TEMPLATE not exist anymore, but this test is based on it", t);

    tester.downloadDefaultTemplate(
        t,
        ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath()
            + File.separatorChar
            + fileName);
    final File createdFile =
        new File(
            ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath()
                + File.separatorChar
                + fileName);
    assertNotNull("File " + fileName + " is asked to be downloaded but is not", createdFile);

    try {
      @SuppressWarnings("unused")
      FileInputStream fromIn = new FileInputStream(createdFile);
    } catch (FileNotFoundException e) {
      BonitaStudioLog.log(e.getMessage());
      fail("File " + fileName + " were not present in the destination folder");
    }
    createdFile.delete();
  }
예제 #2
0
  protected void addProcessImage(
      final BusinessArchiveBuilder builder, final AbstractProcess process) throws CoreException {
    if (PlatformUI.isWorkbenchRunning()) {
      final String processName = process.getName() + "_" + process.getVersion();
      final String path = processName + ".png"; // $NON-NLS-1$

      try {
        Diagram diagram = ModelHelper.getDiagramFor(ModelHelper.getMainProcess(process));
        if (diagram == null) {
          return; // DON'T ADD IMAGE, DON'T THROW EXCEPTION FOR TESTS PURPUSES
        }
        final ResourceSet resourceSet = new ResourceSetImpl();
        final TransactionalEditingDomain editingDomain =
            CustomDiagramEditingDomainFactory.getInstance().createEditingDomain(resourceSet);
        final Resource resource = resourceSet.createResource(diagram.eResource().getURI());
        try {
          resource.load(resourceSet.getLoadOptions());
        } catch (final IOException e1) {
          BonitaStudioLog.error(e1);
        }
        diagram = (Diagram) resource.getEObject(diagram.eResource().getURIFragment(diagram));
        final CopyToImageUtilEx copyToImageUtil = new CopyToImageUtilEx();
        byte[] imageBytes = null;
        try {
          imageBytes =
              copyToImageUtil.copyToImageByteArray(
                  diagram,
                  process,
                  ImageFileFormat.PNG,
                  Repository.NULL_PROGRESS_MONITOR,
                  new PreferencesHint("exportToImage"),
                  true);
        } catch (final Exception e) {
          BonitaStudioLog.error(e);
          return;
        } finally {
          editingDomain.dispose();
        }
        if (imageBytes != null) {
          try {
            builder.addExternalResource(new BarResource(path, imageBytes));
          } catch (final Exception e) {
            BonitaStudioLog.log("Process image file generation has failed"); // $NON-NLS-1$
          }
        }
      } catch (final Exception e) {
        BonitaStudioLog.error(e);
      }
    }
  }