Package org.enhydra.jawe.base.xpdlhandler

Examples of org.enhydra.jawe.base.xpdlhandler.XPDLHandler


                if (split.length == 3) {
                    processDefId = split[2];
                }

                // load package definition
                XPDLHandler xpdlHandler = jaweManager.getXPDLHandler();
                xpdlHandler.setValidation(false);
                jaweController.openPackageFromStream(xpdl.getBytes("UTF-8"));
                org.enhydra.shark.xpdl.elements.Package pkg = xpdlHandler.getPackageById(packageId);
                org.enhydra.shark.xpdl.elements.WorkflowProcess wp = pkg.getWorkflowProcess(processDefId);
                GraphController gc = (GraphController) jaweManager.getComponentManager().getComponent("GraphComponent");
                gc.selectGraphForElement(wp);
                Graph graph = gc.getGraph(wp);
View Full Code Here


    }

    public Package createPackage(String type) {
        Package pkg = new Package();
        adjustType(pkg, type);
        XPDLHandler xpdlhandler = JaWEManager.getInstance().getXPDLHandler();
        JaWETypes jts = JaWEManager.getInstance().getJaWEController().getJaWETypes();
        boolean hasTemplate = jts.hasTemplateId(type);
        if (hasTemplate) {
            jts.fillFromTemplate(pkg, type);
        }
        String id = pkg.getId();
        if (!hasTemplate || id.equals("") || xpdlhandler.getPackageById(id) != null) {
            int i = 0;
            while (id.equals("") || xpdlhandler.getPackageById(id) != null) {
                id = "package" + String.valueOf(++i);
            }
            pkg.setId(id);
        }
        if (!hasTemplate || pkg.getName().equals("")) {
View Full Code Here

                    } else if (action == XMLElementChangeInfo.REMOVED) {
                        removePackage(pkg);
                    }
                }
                if (adjustOtherPkgs) {
                    XPDLHandler xpdlh = JaWEManager.getInstance().getXPDLHandler();
                    List allPkgs = new ArrayList(xpdlh.getAllPackages());
                    allPkgs.removeAll(changedElements);
                    Map allExtPkgPars = getAllPackageParticipants(changedElements);
                    List allGraphElements = getAllWorkflowProcessesAndActivitySetsForAdjustment(allPkgs);

                    Iterator it = allGraphElements.iterator();
View Full Code Here

        if (JaWE.getJaWEVersion() != JaWE.COMMUNITY_VERSION || JaWE.addOnsAvailable()) {
            xpdlhSettings = properties.getProperty("XPDLHandler.Settings",
                    "org.enhydra.jawe.base.xpdlhandler.XPDLHandlerSettings");
        }

        XPDLHandler xpdlh = null;
        try {
            XPDLHandlerSettings hs = (XPDLHandlerSettings) cl.loadClass(xpdlhSettings).newInstance();
            hs.setPropertyMgr(propertyMgr);

            Constructor c = Class.forName(xpdlhClass).getConstructor(new Class[]{
                        XPDLHandlerSettings.class
                    });
            xpdlh = (XPDLHandler) c.newInstance(new Object[]{
                        hs
                    });
        } catch (Throwable ex) {
            String msg = "JaweManager -> Problems while instantiating XPDL Handler class '" + xpdlhClass + "' - using default!";
            xpdlh = new XPDLHandler();
            xpdlh.setXPDLRepositoryHandler(xpdlRHandler);
            loggingManager.error(msg, ex);
        }
        xpdlh.setXPDLRepositoryHandler(xpdlRHandler);
        xpdlh.setLocale(ResourceManager.getChoosenLocale());
        return xpdlh;
    }
View Full Code Here

    public Package getMainPackage() {
        return JaWEManager.getInstance().getXPDLHandler().getPackageById(getMainPackageId());
    }

    public String getMainPackageId() {
        XPDLHandler xpdlhandler = JaWEManager.getInstance().getXPDLHandler();
        String xpdlId = xpdlhandler.getMainPackageId();
        if (xpdlId == null && xpdlhandler.getAllPackageIds().size() > 0) {
            Iterator it = xpdlhandler.getAllPackages().iterator();
            while (it.hasNext()) {
                Package p = (Package) it.next();
                if (!p.isTransient() && !p.isReadOnly()) {
                    xpdlId = p.getId();
                    break;
View Full Code Here

        return xpdlId;
    }

    // ///////////////////////////// XPDL File Handling /////////////////////////
    public String getPackageFilename(String xpdlId) {
        XPDLHandler xpdlhandler = JaWEManager.getInstance().getXPDLHandler();
        if (xpdlId == null) {
            xpdlId = getMainPackageId();
        }
        Package pkg = xpdlhandler.getPackageById(xpdlId);
        return xpdlhandler.getAbsoluteFilePath(pkg);
    }
View Full Code Here

        Package pkg = xpdlhandler.getPackageById(xpdlId);
        return xpdlhandler.getAbsoluteFilePath(pkg);
    }

    public void changePackageFileName(Package pkg, String newFileName) {
        XPDLHandler xpdlhandler = JaWEManager.getInstance().getXPDLHandler();
        xpdlhandler.registerPackageFilename(newFileName, pkg);
    }
View Full Code Here

    }

    public void newPackage(String type) {
        clearAll();

        XPDLHandler xpdlhandler = JaWEManager.getInstance().getXPDLHandler();
        JaWEManager.getInstance().getLoggingManager().info("JaWEController -> creating new XPDL, type=" + type);

        Package pkg = JaWEManager.getInstance().getXPDLObjectFactory().createPackage(type);
        xpdlhandler.registerPackage(pkg);
        adjustXPDL(pkg);
        createNewXPDLListenerObservable(pkg, true, true);
        setChanged();
        notifyObservers(createInfo(pkg, XMLElementChangeInfo.INSERTED));
        selectionMng.setSelection(pkg, true);
View Full Code Here

        try {
            ws = new WaitScreen(frame);
        } catch (HeadlessException e) {
            // ignore
        }
        XPDLHandler xpdlh = null;
        try {
            Package pkg = null;
            clearAll();
            XPDLHandler xpdlhandler = JaWEManager.getInstance().getXPDLHandler();
            if (jaweFrameShown && filename != null && xpdlStream == null) {
                if (ws != null) {
                    ws.show(null, "", settings.getLanguageDependentString("OpeningFile"));
                }
            }
            xpdlh = JaWEManager.getInstance().createXPDLHandler(xpdlhandler.getXPDLRepositoryHandler());

            try {
                if (filename != null) {
                    pkg = xpdlh.openPackage(filename, true);
                } else {
                    pkg = xpdlh.openPackageFromStream(xpdlStream, true);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                clearAll();
                xpdlh.closeAllPackages();
                if (ws != null) {
                    ws.setVisible(false);
                }
                getJaWEFrame().message(settings.getLanguageDependentString("ErrorCannotOpenXPDL" + "\n" + ex.getMessage()),
                        JOptionPane.INFORMATION_MESSAGE);
            }

            if (pkg != null) {
                // do not allow insertion if package has the same Id as the one already
                // inserted
                Set allpkgids = new HashSet(xpdlhandler.getAllPackageIds());
                boolean canInsert = true;
                if (allpkgids.contains(pkg.getId())) {
                    canInsert = false;
                }
                if (canInsert) {
                    xpdlhandler.synchronizePackages(xpdlh);

                    boolean mainChanged = false;
                    Iterator it = xpdlhandler.getAllPackages().iterator();
                    while (it.hasNext()) {
                        Package p = (Package) it.next();
                        boolean changed = false;
                        try {
                            changed = adjustXPDL(p);
                        } catch (Exception e) {
                            // ignore
                        }

                        XPDLListenerAndObservable xpdl;
                        if (p == pkg) {
                            xpdl = createNewXPDLListenerObservable(pkg, true, false);
                            if (changed) {
                                mainChanged = true;
                            }
                        } else {
                            xpdl = createNewXPDLListenerObservable(p, false, false);
                            p.setReadOnly(true);
                        }
                        xpdl.setModified(changed);
                    }

                    List inserted = new ArrayList();
                    inserted.add(pkg);

                    it = xpdlhandler.getAllPackages().iterator();
                    while (it.hasNext()) {
                        Package pkgext = (Package) it.next();
                        if (pkgext == pkg) {
                            continue;
                        }
                        inserted.add(pkgext);
                    }

                    setChanged();
                    notifyObservers(createInfo(pkg, inserted, XMLElementChangeInfo.INSERTED));

                    if (pkg.getWorkflowProcesses().size() > 0) {
                        selectionMng.setSelection(pkg.getWorkflowProcesses().get(0), true);
                    } else {
                        selectionMng.setSelection(pkg, true);
                    }

                    JaWEManager.getInstance().getLoggingManager().info("JaWEController -> opened package " + pkg.getId());
                    if (settings.isInitialXPDLValidationEnabled()) {
                        try {
                            checkValidity(pkg, true, true, true);
                        } catch (Exception e) {
                            // ignore
                        }

                    }

                    if ((mainChanged) && jaweFrameShown) {
                        if (mainChanged) {
                            if (ws != null) {
                                ws.setVisible(false);
                            }
                            // CUSTOM: hide warning message
//                            frame.message(settings.getLanguageDependentString("InformationTogWEHasAutomaticallyAdjustedSomeXPDLParts"),
//                                    JOptionPane.INFORMATION_MESSAGE);
                            // END CUSTOM
                        }
                    }

                } else {
                    if (getJaWEFrame() != null) {
                        getJaWEFrame().message(settings.getLanguageDependentString("InformationPackageCannotBeOpened"),
                                JOptionPane.INFORMATION_MESSAGE);

                    }
                }
            } else {
                clearAll();
                Map pems = xpdlhandler.getParsingErrorMessages();
                String msg = null;
                if (pems != null && pems.size() > 0) {
                    Set s = (Set) pems.values().toArray()[0];
                    if (s != null && s.size() > 0) {
                        msg = (String) s.toArray()[0];
                    }
                }
                Iterator it = xpdlhandler.getAllPackages().iterator();
                while (it.hasNext()) {
                    Package p = (Package) it.next();
                    if (!p.isTransient()) {
                        xpdlhandler.closePackageVersion(p.getId(), p.getInternalVersion());
                    }
                }
                if (ws != null) {
                    ws.setVisible(false);
                }
View Full Code Here

        //END CUSTOM
    }

    public void addExternalPackage(String filename) {
        Package mainPkg = getMainPackage();
        XPDLHandler xpdlhmain = JaWEManager.getInstance().getXPDLHandler();
        XPDLHandler xpdlh = null;
        if (filename != null && filename.length() > 0) {
            try {
                xpdlh = new XPDLHandler(new DefaultXPDLHandlerSettings());
                Package pkg = xpdlh.openPackage(filename, true);
                // do not allow insertion if package has the same Id as the main one,
                // or as some of its external packages
                Set mainPkgExtPkgIds = new HashSet(mainPkg.getExternalPackageIds());
                boolean canInsert = true;
                if (mainPkgExtPkgIds.contains(pkg.getId())) {
                    canInsert = false;
                }
                if (canInsert) {
                    canInsert = checkInsertion(xpdlhmain, xpdlh, mainPkg.getId());
                }
                if (canInsert) {
                    List l = XMLUtil.getAllExternalPackageIds(xpdlhmain,
                            mainPkg,
                            new HashSet());
                    if (!l.contains(pkg.getId()) && xpdlhmain.getPackageById(pkg.getId()) != null) {
                        canInsert = false;
                    }
                }
                if (canInsert) {
                    Set pkgIdsToInsert = new HashSet(xpdlh.getAllPackageIds());
                    Set otherEPIds = new HashSet(mainPkg.getExternalPackageIds());
                    Set allOtherEPIds = new HashSet(otherEPIds);
                    List l = XMLUtil.getAllExternalPackageIds(xpdlhmain,
                            mainPkg,
                            new HashSet());
                    List ids = new ArrayList(xpdlhmain.getAllPackageIds());
                    ids.removeAll(l);
                    allOtherEPIds.addAll(ids);
                    Iterator it = otherEPIds.iterator();
                    while (it.hasNext()) {
                        String pkgId = (String) it.next();
                        Package p = xpdlhmain.getPackageById(pkgId);
                        allOtherEPIds.addAll(XMLUtil.getAllExternalPackageIds(xpdlhmain,
                                p,
                                new HashSet()));
                    }
                    pkgIdsToInsert.removeAll(allOtherEPIds);

                    Set pkgsToInsert = new HashSet();
                    it = pkgIdsToInsert.iterator();
                    while (it.hasNext()) {
                        String pkgId = (String) it.next();
                        Package tAdd = xpdlh.getPackageById(pkgId);
                        pkgsToInsert.add(tAdd);
                    }

                    xpdlhmain.synchronizePackages(xpdlh);

                    Package realPkg = xpdlhmain.getPackageById(pkg.getId());
                    ExternalPackage ep = null;
                    // insert ExternalPackage
                    ExternalPackages eps = mainPkg.getExternalPackages();
                    File f = new File(xpdlhmain.getAbsoluteFilePath(mainPkg));
                    String parentF = f.getParent();
                    Path newPath = new Path(parentF);
                    String eppath = xpdlhmain.getAbsoluteFilePath(realPkg);
                    String relativePath = Path.getRelativePath(new Path(eppath), newPath);
                    ep = JaWEManager.getInstance().getXPDLObjectFactory().createXPDLObject(eps, "", false);
                    ep.setHref(relativePath);
                    JaWEEAHandler.setExternalPackageEA(ep, realPkg.getId());
                    mainPkg.addExternalPackageMapping(relativePath, realPkg.getId());
                    eps.add(ep);

                    it = pkgsToInsert.iterator();
                    while (it.hasNext()) {
                        Package p = (Package) it.next();
                        boolean changed = adjustXPDL(p);
                        XPDLListenerAndObservable xpdl;
                        xpdl = createNewXPDLListenerObservable(p, false, false);
                        p.setReadOnly(true);
                        xpdl.setModified(changed);
                    }

                    setChanged();
                    notifyObservers(createInfo(mainPkg,
                            new ArrayList(pkgsToInsert),
                            XMLElementChangeInfo.INSERTED));

                    if (ep != null) {
                        getSelectionManager().setSelection(ep, true);
                    }

                } else {
                    getJaWEFrame().message(settings.getLanguageDependentString("InformationExternalPackageCannotBeInserted"),
                            JOptionPane.INFORMATION_MESSAGE);
                    xpdlh.closeAllPackages();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                getJaWEFrame().message(settings.getLanguageDependentString("InformationExternalPackageCannotBeInserted"),
                        JOptionPane.INFORMATION_MESSAGE);
                if (xpdlh != null) {
                    xpdlh.closeAllPackages();
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.enhydra.jawe.base.xpdlhandler.XPDLHandler

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.