Package org.jbpm.designer.repository

Examples of org.jbpm.designer.repository.Repository


    @Ignore
    @Test
    public void testTaskFormServletWithUserTask() throws Exception {

        Repository repository = new VFSRepository(producer.getIoService());
        ((VFSRepository)repository).setDescriptor(descriptor);
        profile.setRepository(repository);
        AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text);
        builder.content("bpmn2 content")
                .type("bpmn2")
                .name("userTask")
                .location("/defaultPackage");
        String uniqueId = repository.createAsset(builder.getAsset());
        // setup parameters
        Map<String, String> params = new HashMap<String, String>();
        params.put("uuid", uniqueId);
        params.put("json", readFile("src/test/resources/BPMN2-UserTask.json"));
        params.put("profile", "jbpm");
        params.put("ppdata", null);

        TaskFormsServlet taskFormsServlet = new TaskFormsServlet();
        taskFormsServlet.setProfile(profile);

        taskFormsServlet.init(new TestServletConfig(new TestServletContext(repository)));

        taskFormsServlet.doPost(new TestHttpServletRequest(params), new TestHttpServletResponse());

        Collection<Asset> forms = repository.listAssets("/defaultPackage", new FilterByExtension("ftl"));
        assertNotNull(forms);
        assertEquals(2, forms.size());
        Iterator<Asset> assets = forms.iterator();
        Asset asset1 = assets.next();
        assertEquals("evaluate-taskform", asset1.getName());
        assertEquals("/defaultPackage", asset1.getAssetLocation());

        Asset asset2 = assets.next();
        assertEquals("testprocess-taskform", asset2.getName());
        assertEquals("/defaultPackage", asset2.getAssetLocation());

        Asset<String> form1 = repository.loadAsset(asset1.getUniqueId());
        assertNotNull(form1.getAssetContent());
        Asset<String> form2 = repository.loadAsset(asset2.getUniqueId());
        assertNotNull(form2.getAssetContent());
    }
View Full Code Here


        repo.delete();
        counter++;
    }
    @Test
    public void testProprocess() {
        Repository repository = new VFSRepository(producer.getIoService());
        ((VFSRepository)repository).setDescriptor(descriptor);
        profile.setRepository(repository);
        //prepare folders that will be used
        repository.createDirectory("/myprocesses");
        repository.createDirectory("/global");

        // prepare process asset that will be used to preprocess
        AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text);
        builder.content("bpmn2 content")
                .type("bpmn2")
                .name("process")
                .location("/myprocesses");
        String uniqueId = repository.createAsset(builder.getAsset());

        // create instance of preprocessing unit
        JbpmPreprocessingUnit preprocessingUnitVFS = new JbpmPreprocessingUnit(new TestServletContext(), "/", null);

        // setup parameters
        Map<String, String> params = new HashMap<String, String>();
        params.put("uuid", uniqueId);

        // run preprocess
        preprocessingUnitVFS.preprocess(new TestHttpServletRequest(params), null, new TestIDiagramProfile(repository), null, false, null, null);

        // validate results
        Collection<Asset> globalAssets = repository.listAssets("/global");
        assertNotNull(globalAssets);
        assertEquals(30, globalAssets.size());
        repository.assetExists("/global/backboneformsinclude.fw");
        repository.assetExists("/global/backbonejsinclude.fw");
        repository.assetExists("/global/cancelbutton.fw");
        repository.assetExists("/global/checkbox.fw");
        repository.assetExists("/global/customeditors.json");
        repository.assetExists("/global/div.fw");
        repository.assetExists("/global/dropdownmenu.fw");
        repository.assetExists("/global/fieldset.fw");
        repository.assetExists("/global/form.fw");
        repository.assetExists("/global/handlebarsinclude.fw");
        repository.assetExists("/global/htmlbasepage.fw");
        repository.assetExists("/global/image.fw");
        repository.assetExists("/global/jqueryinclude.fw");
        repository.assetExists("/global/jquerymobileinclude.fw");
        repository.assetExists("/global/link.fw");
        repository.assetExists("/global/mobilebasepage.fw");
        repository.assetExists("/global/orderedlist.fw");
        repository.assetExists("/global/passwordfield.fw");
        repository.assetExists("/global/radiobutton.fw");
        repository.assetExists("/global/script.fw");
        repository.assetExists("/global/submitbutton.fw");
        repository.assetExists("/global/table.fw");
        repository.assetExists("/global/textarea.fw");
        repository.assetExists("/global/textfield.fw");
        repository.assetExists("/global/themes.json");
        repository.assetExists("/global/unorderedlist.fw");
        repository.assetExists("/global/defaultemailicon.gif");
        repository.assetExists("/global/defaultlogicon.gif");
        repository.assetExists("/global/defaultservicenodeicon.png");
        repository.assetExists("/global/.gitignore");

        Collection<Asset> defaultStuff = repository.listAssets("/myprocesses");
        assertNotNull(defaultStuff);
        assertEquals(3, defaultStuff.size());
        repository.assetExists("/myprocesses/WorkDefinitions.wid");
        // this is the process asset that was created for the test but let's check it anyway
        repository.assetExists("/myprocesses/process.bpmn2");
        repository.assetExists("/myprocesses/.gitignore");

    }
View Full Code Here

                    + " was registered");
            throw new IllegalArgumentException(
                    "No profile with the name " + profileName +
                            " was registered");
        }
        Repository repo = profile.getRepository();
        XMLOutputter outputter = new XMLOutputter();
        Format format = Format.getPrettyFormat();
        format.setExpandEmptyElements(true);
        outputter.setFormat(format);
        String html = outputter.outputString(doc);
View Full Code Here

         String formType = req.getParameter("formtype");

         if (profile == null) {
          profile = _profileService.findProfile(req, profileName);
         }
         Repository repository = profile.getRepository();

         Asset<String> processAsset = null;
         try {
             processAsset = repository.loadAsset(uuid);


             if(action != null && action.equals(ACTION_LOAD)) {
                 resp.setContentType("text/html");
                 resp.setCharacterEncoding("UTF-8");
View Full Code Here

      pw.write(themeJSON);
    }
  }
 
  private String getThemeJson(IDiagramProfile profile, ServletContext servletContext, String uuid) {
        Repository repository = profile.getRepository();

    String retStr = "";

      try {
            Asset<String> themeAsset = repository.loadAssetFromPath(profile.getRepositoryGlobalDir( uuid ) + "/" + THEME_NAME+THEME_EXT);

            retStr = themeAsset.getAssetContent();

        } catch (Exception e) {
      _logger.error("Error retriving color theme info: " + e.getMessage());
View Full Code Here

    }
        return retStr;
  }
 
  private String getThemeNames(IDiagramProfile profile, ServletContext servletContext, String uuid) {
        Repository repository = profile.getRepository();

    String themesStr = "";
     
        try {

            Asset<String> themeAsset = repository.loadAssetFromPath(profile.getRepositoryGlobalDir( uuid ) + "/" + THEME_NAME+THEME_EXT);

            JSONObject themesObject =  new JSONObject(themeAsset.getAssetContent());
            JSONObject themes = (JSONObject) themesObject.get("themes");
            for (int i = 0; i < themes.names().length(); i++) {
                themesStr += themes.names().getString(i) + ",";
View Full Code Here


        if (profile == null) {
            profile = _profileService.findProfile(req, profileName);
        }
        Repository repository = profile.getRepository();

    Map<String, WorkDefinitionImpl> workitemsFromRepo = WorkItemRepository.getWorkDefinitions(repoURL);
    if(action != null && action.equalsIgnoreCase(displayRepoContent)) {
      if(workitemsFromRepo != null && workitemsFromRepo.size() > 0) {
        Map<String, List<String>> retMap = new HashMap<String, List<String>>();
        for(String key : workitemsFromRepo.keySet()) {
          WorkDefinitionImpl wd = workitemsFromRepo.get(key);
          List<String> keyList = new ArrayList<String>();
          keyList.add(wd.getName() == null ? "" : wd.getName());
          keyList.add(wd.getDisplayName() == null ? "" : wd.getDisplayName());
          keyList.add(repoURL + "/" + wd.getName() + "/" + wd.getIcon());
          keyList.add(wd.getCategory() == null ? "" : wd.getCategory());
          keyList.add(wd.getExplanationText() == null ? "" : wd.getExplanationText());
          keyList.add(repoURL + "/" + wd.getName() + "/" + wd.getDocumentation());
          StringBuffer bn = new StringBuffer();
          if(wd.getParameterNames() != null) {
            String delim = "";
              for (String name : wd.getParameterNames()) {
                  bn.append(delim).append(name);
                  delim = ",";
              }
          }
          keyList.add(bn.toString());
          StringBuffer br = new StringBuffer();
          if(wd.getResultNames() != null) {
            String delim = "";
              for (String resName : wd.getResultNames()) {
                  br.append(delim).append(resName);
                  delim = ",";
              }
          }
          keyList.add(br.toString());
          retMap.put(key, keyList);
        }
        JSONObject jsonObject = new JSONObject();
        for (Entry<String,List<String>> retMapKey : retMap.entrySet()) {
          try {
            jsonObject.put(retMapKey.getKey(), retMapKey.getValue());
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("application/json");
        resp.getWriter().write(jsonObject.toString());
      } else {
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("application/json");
        resp.getWriter().write("false");
        return;
      }
    } else if(action != null && action.equalsIgnoreCase(installRepoContent)) {
      resp.setCharacterEncoding("UTF-8");
      resp.setContentType("application/json");
      if(workitemsFromRepo != null && workitemsFromRepo.size() > 0) {
        boolean gotPackage = false;
        String pkg = "";
        for(String key : workitemsFromRepo.keySet()) {
          if(key.equals(assetsToInstall) && categoryToInstall.equals(workitemsFromRepo.get(key).getCategory())) {
                        String workitemDefinitionURL = workitemsFromRepo.get(key).getPath() + "/" + workitemsFromRepo.get(key).getName() + ".wid";
                        String iconFileURL = workitemsFromRepo.get(key).getPath() + "/" + workitemsFromRepo.get(key).getIcon();
            String workItemDefinitionContent = ConfFileUtils.URLContentsToString(new URL(workitemDefinitionURL));
            String iconName = workitemsFromRepo.get(key).getIcon();
            String widName = workitemsFromRepo.get(key).getName();
            byte[] iconContent = null;
            try {
              iconContent = getImageBytes(new URL(iconFileURL)
              .openStream());
            } catch (Exception e1) {
              _logger.error("Could not read icon image: " + e1.getMessage());
            }
            // install wid and icon
                        repository.deleteAsset(profile.getRepositoryGlobalDir( uuid ) + "/" +  widName + ".wid");

                        AssetBuilder widAssetBuilder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text);
                        widAssetBuilder.name(widName)
                                       .location(profile.getRepositoryGlobalDir( uuid ))
                                       .type("wid")
                                       .content(workItemDefinitionContent);

                        repository.createAsset(widAssetBuilder.getAsset());

                        AssetBuilder iconAssetBuilder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Byte);
                        String iconExtension = iconName.substring(iconName.lastIndexOf(".") + 1);
                        String iconFileName = iconName.substring(0, iconName.lastIndexOf("."));


                        repository.deleteAsset(profile.getRepositoryGlobalDir( uuid ) + "/" + iconFileName + "." + iconExtension);

                        iconAssetBuilder.name(iconFileName)
                                .location(profile.getRepositoryGlobalDir( uuid ))
                                .type(iconExtension)
                                .content(iconContent);

                        repository.createAsset(iconAssetBuilder.getAsset());
          }
        }
      } else {
        _logger.error("Invalid or empty service repository.");
        resp.setCharacterEncoding("UTF-8");
View Full Code Here

        IDiagramProfile profile = _profileService.findProfile(req, profileName);

        DroolsFactoryImpl.init();
        BpsimFactoryImpl.init();

        Repository repository = profile.getRepository();

        if (transformto != null && transformto.equals(TO_PDF)) {
            try {
                if(respaction != null && respaction.equals(RESPACTION_SHOWURL)) {
                    ByteArrayOutputStream bout = new ByteArrayOutputStream();
View Full Code Here

  }

    private String getCustomEditorsJSON(IDiagramProfile profile, ServletContext servletContext, String uuid) {

        String retStr = "";
        Repository repository = profile.getRepository();
        try {
            Asset<String> customEditorAsset = repository.loadAssetFromPath(profile.getRepositoryGlobalDir( uuid ) + "/" + CUSTOMEDITORS_NAME + ".json");

            retStr = customEditorAsset.getAssetContent();

    } catch (Exception e) {
      _logger.error("Error retriving custom editors info: " + e.getMessage());
View Full Code Here

        String dvalue = req.getParameter("dvalue");

        if (profile == null) {
            profile = _profileService.findProfile(req, profileName);
        }
        Repository repository = profile.getRepository();

        if(action != null && action.equals(ACTION_SAVE)) {
          storeInRepository(uuid, profile, dvalue, repository);
          PrintWriter pw = resp.getWriter();
        resp.setContentType("text/plain");
View Full Code Here

TOP

Related Classes of org.jbpm.designer.repository.Repository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.