Examples of IDiagramProfile


Examples of org.jbpm.designer.web.profile.IDiagramProfile

        String profileName = request.getParameter("profile");
        if(profileName == null || profileName.length() < 1) {
            // default to jbpm
            profileName = "jbpm";
        }
        IDiagramProfile profile = _profileService.findProfile(
                request, profileName);
        if (profile == null) {
            _logger.error("No profile with the name " + profileName
                    + " 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

Examples of org.jbpm.designer.web.profile.IDiagramProfile

        String uuid = Utils.getUUID(req);
        String preProcessingParam = req.getParameter("pp");
        if (uuid == null) {
            throw new ServletException("uuid parameter required");
        }
        IDiagramProfile profile = _profileService.findProfile(req, req.getParameter("profile"));
    try {
      String response =  new String(_repository.load(req, uuid, profile, getServletContext()), Charset.forName("UTF-8"));
      resp.getWriter().write(response);
    } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of org.jbpm.designer.web.profile.IDiagramProfile

        String preProcessingParam = req.getParameter("pp");
        if(preProcessingParam == null) {
            preProcessingParam = "ReadOnlyService";
        }
        if(actionParam != null && actionParam.equals("toXML")) {
            IDiagramProfile profile = _profileService.findProfile(req, req.getParameter("profile"));
            String json = req.getParameter("data");
            String xml = "";
            try {
                xml = _repository.toXML(json, profile, preProcessingParam);
            } catch(Exception e) {
                _logger.error("Error transforming to XML : " + e.getMessage());
            }
            StringWriter output = new StringWriter();
            output.write(xml);
            resp.setContentType("application/xml");
            resp.setCharacterEncoding("UTF-8");
            resp.setStatus(200);
            resp.getWriter().print(output.toString());
        } else if(actionParam != null && actionParam.equals("checkErrors")) {
          String retValue = "false";
          IDiagramProfile profile = _profileService.findProfile(req, req.getParameter("profile"));
            String json = req.getParameter("data");
            try {
        String xmlOut = profile.createMarshaller().parseModel(json, preProcessingParam);
        String jsonIn = profile.createUnmarshaller().parseModel(xmlOut, profile, preProcessingParam);
        if(jsonIn == null || jsonIn.length() < 1) {
          retValue = "true";
        }
      } catch (Throwable t) {
        retValue = "true";
        _logger.error("Exception parsing process: " + t.getMessage());
      }
            resp.setContentType("text/plain");
            resp.setCharacterEncoding("UTF-8");
            resp.setStatus(200);
            resp.getWriter().print(retValue);
        } else {
            BufferedReader reader = req.getReader();
            StringWriter reqWriter = new StringWriter();
            char[] buffer = new char[4096];
            int read;
            while ((read = reader.read(buffer)) != -1) {
                reqWriter.write(buffer, 0, read);
            }
       
            String data = reqWriter.toString();
            try {
                JSONObject jsonObject = new JSONObject(data);
           
                String json = (String) jsonObject.get("data");
                String svg = (String) jsonObject.get("svg");
                String uuid = (String) jsonObject.get("uuid");
                String profileName = (String) jsonObject.get("profile");
                boolean autosave = jsonObject.getBoolean("savetype");
           
                IDiagramProfile profile = _profileService.findProfile(req, req.getParameter("profile"));
           
                _repository.save(req, uuid, json, svg, profile, autosave);

            } catch (JSONException e1) {
                throw new ServletException(e1);
View Full Code Here

Examples of org.jbpm.designer.web.profile.IDiagramProfile

            throws ServletException, IOException {
    String json = req.getParameter("data");
        String profileName = req.getParameter("profile");
        String preprocessingData = req.getParameter("pp");
        String uuid = Utils.getUUID(req);
        IDiagramProfile profile = _profileService.findProfile(req, profileName);

        BPMN2SyntaxChecker checker = new BPMN2SyntaxChecker(json, preprocessingData, profile, uuid);
    checker.checkSyntax();
    resp.setCharacterEncoding("UTF-8");
        resp.setContentType("application/json");
View Full Code Here

Examples of org.jbpm.designer.web.profile.IDiagramProfile

            throws ServletException, IOException {
    String profileName = req.getParameter("profile");
    String action = req.getParameter("action");
        String uuid = Utils.getUUID(req);

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

    if(action != null && action.equals(ACTION_GETTHEMENAMES)) {
      String themeStr = getThemeNames(profile, getServletContext(), uuid);
      PrintWriter pw = resp.getWriter();
      resp.setContentType("text/plain");
View Full Code Here

Examples of org.jbpm.designer.web.profile.IDiagramProfile

        //rawSvg = URLDecoder.decode(rawSvg, "UTF-8");

        if(sourceEnc != null && sourceEnc.equals("true")) {
            bpmn2in = new String(Base64.decodeBase64(bpmn2in), "UTF-8");
        }
        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();
                    PDFTranscoder t = new PDFTranscoder();
                    TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
                    TranscoderOutput output = new TranscoderOutput(bout);
                    t.transcode(input, output);
                    resp.setCharacterEncoding("UTF-8");
                    resp.setContentType("text/plain");

                    resp.getWriter().write("<object data=\"data:application/pdf;base64," + Base64.encodeBase64(bout.toByteArray()) "\" type=\"application/pdf\"></object>");
                } else {
                    storeInRepository(uuid, rawSvg, transformto, processid, repository);

                    resp.setContentType("application/pdf");
                    if (processid != null) {
                        resp.setHeader("Content-Disposition",
                                "attachment; filename=\"" + processid + ".pdf\"");
                    } else {
                        resp.setHeader("Content-Disposition",
                                "attachment; filename=\"" + uuid + ".pdf\"");
                    }

                    PDFTranscoder t = new PDFTranscoder();
                    TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
                    TranscoderOutput output = new TranscoderOutput(resp.getOutputStream());
                    t.transcode(input, output);
                }
            } catch (TranscoderException e) {
                resp.sendError(500, e.getMessage());
            }
        } else if (transformto != null && transformto.equals(TO_PNG)) {
            try {
                if(respaction != null && respaction.equals(RESPACTION_SHOWURL)) {
                    ByteArrayOutputStream bout = new ByteArrayOutputStream();
                    PNGTranscoder t = new PNGTranscoder();
                    t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen");
                    TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
                    TranscoderOutput output = new TranscoderOutput(bout);
                    t.transcode(input, output);
                    resp.setCharacterEncoding("UTF-8");
                    resp.setContentType("text/plain");
                    resp.getWriter().write("<img src=\"data:image/png;base64," + Base64.encodeBase64(bout.toByteArray()) + "\">");
                } else {
                    storeInRepository(uuid, rawSvg, transformto, processid, repository);
                    resp.setContentType("image/png");
                    if (processid != null) {
                        resp.setHeader("Content-Disposition", "attachment; filename=\"" + processid + ".png\"");
                    } else {
                        resp.setHeader("Content-Disposition", "attachment; filename=\"" + uuid + ".png\"");
                    }

                    PNGTranscoder t = new PNGTranscoder();
                    t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen");
                    TranscoderInput input = new TranscoderInput(new StringReader(
                            formattedSvg));
                    TranscoderOutput output = new TranscoderOutput(
                            resp.getOutputStream());
                    t.transcode(input, output);
                }
            } catch (TranscoderException e) {
                resp.sendError(500, e.getMessage());
            }
        } else if (transformto != null && transformto.equals(TO_SVG)) {
            storeInRepository(uuid, rawSvg, transformto, processid, repository);
        } else if (transformto != null && transformto.equals(JPDL_TO_BPMN2)) {
            try {
                String bpmn2 = JbpmMigration.transform(jpdl);
                Definitions def = ((JbpmProfileImpl) profile).getDefinitions(bpmn2);
                // add bpmndi info to Definitions with help of gpd
                addBpmnDiInfo(def, gpd);
                // hack for now
                revisitSequenceFlows(def, bpmn2);
                // another hack if id == name
                revisitNodeNames(def);

                // get the xml from Definitions
                ResourceSet rSet = new ResourceSetImpl();
                rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl());
                JBPMBpmn2ResourceImpl bpmn2resource = (JBPMBpmn2ResourceImpl) rSet.createResource(URI.createURI("virtual.bpmn2"));
                rSet.getResources().add(bpmn2resource);
                bpmn2resource.getContents().add(def);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                bpmn2resource.save(outputStream, new HashMap<Object, Object>());
                String fullXmlModel =  outputStream.toString();
                // convert to json and write response
                String json = profile.createUnmarshaller().parseModel(fullXmlModel, profile, pp);
                resp.setContentType("application/json");
                resp.getWriter().print(json);
            } catch(Exception e) {
                _logger.error(e.getMessage());
                resp.setContentType("application/json");
                resp.getWriter().print("{}");
            }
        }  else if (transformto != null && transformto.equals(BPMN2_TO_JSON)) {
            try {
                if(convertServiceTasks != null && convertServiceTasks.equals("true")) {
                    bpmn2in = bpmn2in.replaceAll("drools:taskName=\".*?\"", "drools:taskName=\"ReadOnlyService\"");
                    bpmn2in = bpmn2in.replaceAll("tns:taskName=\".*?\"", "tns:taskName=\"ReadOnlyService\"");
                }

                Definitions def = ((JbpmProfileImpl) profile).getDefinitions(bpmn2in);
                def.setTargetNamespace("http://www.omg.org/bpmn20");

                if(convertServiceTasks != null && convertServiceTasks.equals("true")) {
                    // fix the data input associations for converted tasks
                    List<RootElement> rootElements =  def.getRootElements();
                    for(RootElement root : rootElements) {
                        if(root instanceof Process) {
                            updateTaskDataInputs((Process) root, def);
                        }
                    }
                }


                // get the xml from Definitions
                ResourceSet rSet = new ResourceSetImpl();
                rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl());
                JBPMBpmn2ResourceImpl bpmn2resource = (JBPMBpmn2ResourceImpl) rSet.createResource(URI.createURI("virtual.bpmn2"));
                bpmn2resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
                bpmn2resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_DEFER_IDREF_RESOLUTION, true);
                bpmn2resource.getDefaultLoadOptions().put( JBPMBpmn2ResourceImpl.OPTION_DISABLE_NOTIFY, true );
                bpmn2resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF, JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF_RECORD);
                bpmn2resource.setEncoding("UTF-8");
                rSet.getResources().add(bpmn2resource);
                bpmn2resource.getContents().add(def);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                bpmn2resource.save(outputStream, new HashMap<Object, Object>());
                String revisedXmlModel =  outputStream.toString();
                String json = profile.createUnmarshaller().parseModel(revisedXmlModel, profile, pp);
                resp.setContentType("application/json");
                resp.getWriter().print(json);
            } catch(Exception e) {
                e.printStackTrace();
                _logger.error(e.getMessage());
View Full Code Here

Examples of org.jbpm.designer.web.profile.IDiagramProfile

     * @param request
     * @param response
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response) {
        parseRequest(request, response);
        IDiagramProfile profile = _profileService.findProfile(request, "jbpm");
        Repository repository = profile.getRepository();
        if(!initialized) {
            try {
                initializeDefaultRepo(profile, repository, request);
                initialized = true;
            } catch (Exception e) {
                logger.error("Unable to initialize repository: " + e.getMessage());
            }
        }
        JSONObject returnJson = new JSONObject();
        try {
            Iterator<String> keys = requestParams.keySet().iterator();
            while(keys.hasNext()) {
                String key = keys.next();
            }

            String cmd = (String) requestParams.get("cmd");
            if(cmd != null && cmd.equals("open")) {
                OpenCommand command = new OpenCommand();
                command.init(request, response, profile, repository, requestParams);
                output(response, false, command.execute());
            } else if(cmd != null && cmd.equals("mkdir")) {
                MakeDirCommand command = new MakeDirCommand();
                command.init(request, response, profile, repository, requestParams);
                output(response, false, command.execute());
            } else if(cmd != null && cmd.equals("mkfile")) {
                MakeFileCommand command = new MakeFileCommand();
                command.init(request, response, profile, repository, requestParams);
                output(response, false, command.execute());
            } else if(cmd != null && cmd.equals("rm")) {
                RemoveAssetCommand command = new RemoveAssetCommand();
                command.init(request, response, profile, repository, requestParams);
                output(response, false, command.execute());
            } else if(cmd != null && cmd.equals("rename")) {
                RenameCommand command = new RenameCommand();
                command.init(request, response, profile, repository, requestParams);
                output(response, false, command.execute());
            } else if(cmd != null && cmd.equals("paste")) {
                PasteCommand command = new PasteCommand();
                command.init(request, response, profile, repository, requestParams);
                output(response, false, command.execute());
            } else if(cmd != null && cmd.equals("upload")) {
                UploadCommand command = new UploadCommand();
                command.init(request, response, profile, repository, requestParams, listFiles, listFileStreams);
                output(response, false, command.execute());
            } else if(cmd != null && cmd.equals("getsvg")) {
                try {
                    Asset asset = profile.getRepository().loadAssetFromPath((String) requestParams.get("current"));
                    if(asset != null && asset.getAssetContent() != null) {
                        outputPlain(response, false, (String) asset.getAssetContent(), "image/svg+xml");
                    } else {
                        outputPlain(response, true, "<p><b>Process image not available.</p><p>You can generate the process image in the process editor.</b></p>", null);
                    }
View Full Code Here

Examples of org.jbpm.designer.web.profile.IDiagramProfile

        String uuid = Utils.getUUID(req);
    String profileName = req.getParameter("profile");
    String action = req.getParameter("action");
    String versionNum = req.getParameter("version");

    IDiagramProfile profile = _profileService.findProfile(req, profileName);
    String[] packageAssetInfo = ServletUtil.findPackageAndAssetInfo(uuid, profile);
        String packageName = packageAssetInfo[0];
        String assetName = packageAssetInfo[1];
        if(action != null && action.equals("getversion") && versionNum != null) {
          resp.setCharacterEncoding("UTF-8");
View Full Code Here

Examples of org.jbpm.designer.web.profile.IDiagramProfile

    String selectionId = req.getParameter("sel");
    String numInstances = req.getParameter("numinstances");
    String interval = req.getParameter("interval");
    String intervalUnit = req.getParameter("intervalunit");

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

        if(action != null && action.equals(ACTION_GETPATHINFO)) {
          DroolsFactoryImpl.init();
            BpsimFactoryImpl.init();

          Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
            Definitions def = ((Definitions) unmarshaller.unmarshall(json, preprocessingData).getContents().get(0));
            PathFinder pfinder = null;
            if(selectionId != null && selectionId.length() > 0) {
              // find the embedded subprocess
              SubProcess selectedContainer = null;
              List<RootElement> rootElements =  def.getRootElements();
                for(RootElement root : rootElements) {
                  if(root instanceof Process) {
                    Process process = (Process) root;
                    selectedContainer = findSelectedContainer(selectionId, process);
                    if(selectedContainer != null) {
                          pfinder = PathFinderFactory.getInstance(selectedContainer);
                        }
                    else {
                          _logger.error("Could not find selected contaner with id: " + selectionId);
                        }
                  }
                }
            }
            if(pfinder == null) {
              pfinder = PathFinderFactory.getInstance(def);
            }
            JSONObject pathjson =  pfinder.findPaths(new JSONPathFormatConverter());
            PrintWriter pw = resp.getWriter();
      resp.setContentType("text/plain");
      resp.setCharacterEncoding("UTF-8");
      pw.write(pathjson.toString());
        } else if(action != null && action.equals(ACTION_RUNSIMULATION)) {
          try {
        DroolsFactoryImpl.init();
                BpsimFactoryImpl.init();

        Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
        Definitions def = ((Definitions) unmarshaller.unmarshall(json, preprocessingData).getContents().get(0));
        String processXML = profile.createMarshaller().parseModel(json, preprocessingData);
        // find the process id
        List<RootElement> rootElements =  def.getRootElements();
        String processId = "";
        for(RootElement root : rootElements) {
          if(root instanceof Process) {
View Full Code Here

Examples of org.jbpm.designer.web.profile.IDiagramProfile

        String uuid = Utils.getUUID(req);
        String processPackage = req.getParameter("ppackage");
        String processId = req.getParameter("pid");
        String action = req.getParameter("action");
       
        IDiagramProfile profile = _profileService.findProfile(req, profileName);
        if(action != null && action.equals("openprocessintab")) {
          String retValue = "";
          List<String> allPackageNames = ServletUtil.getPackageNamesFromRepository(profile);
          if(allPackageNames != null && allPackageNames.size() > 0) {
            for(String packageName : allPackageNames) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.