Package org.joget.apps.app.model

Examples of org.joget.apps.app.model.PackageParticipant


            procDefId = WorkflowUtil.getProcessDefIdWithoutVersion(procDefId);
            Long packageVersion = Long.parseLong(version);
            PackageDefinition packageDef = packageDefinitionDao.loadPackageDefinition(packageId, packageVersion);
           
            if (packageDef != null) {
                PackageParticipant participant = packageDef.getPackageParticipant(procDefId, participantId);

                //Set app definition   
                AppDefinition appDef = packageDef.getAppDefinition();
                AppUtil.setCurrentAppDefinition(appDef);

                //if process start white list and app is not publish
                if (WorkflowUtil.PROCESS_START_WHITE_LIST.equals(participantId) && !appDef.isPublished()) {
                    resultList = getParticipantsByAdminUser();
                } else if (WorkflowUtil.PROCESS_START_WHITE_LIST.equals(participantId) && appDef.isPublished() && participant == null) {
                    resultList = getParticipantsByCurrentUser();
                } else if (participant != null) {
                    if (PackageParticipant.TYPE_USER.equals(participant.getType())) {
                        resultList = getParticipantsByUsers(participant);
                    } else if (PackageParticipant.TYPE_GROUP.equals(participant.getType())) {
                        resultList = getParticipantsByGroups(participant);
                    } else if (PackageParticipant.TYPE_REQUESTER.equals(participant.getType())) {
                        resultList = getParticipantsByRequester(participant, procDefId, procId, requesterUsername);
                    } else if (PackageParticipant.TYPE_REQUESTER_HOD.equals(participant.getType())) {
                        resultList = getParticipantsByRequesterHod(participant, procDefId, procId, requesterUsername);
                    } else if (PackageParticipant.TYPE_REQUESTER_HOD_IGNORE_REPORT_TO.equals(participant.getType())) {
                        resultList = getParticipantsByRequesterHodIgnoreReportTo(participant, procDefId, procId, requesterUsername);
                    } else if (PackageParticipant.TYPE_REQUESTER_SUBORDINATES.equals(participant.getType())) {
                        resultList = getParticipantsByRequesterSubordinates(participant, procDefId, procId, requesterUsername);
                    } else if (PackageParticipant.TYPE_REQUESTER_DEPARTMENT.equals(participant.getType())) {
                        resultList = getParticipantsByRequesterDepartment(participant, procDefId, procId, requesterUsername);
                    } else if (PackageParticipant.TYPE_DEPARTMENT.equals(participant.getType())) {
                        resultList = getParticipantsByDepartment(participant);
                    } else if (PackageParticipant.TYPE_HOD.equals(participant.getType())) {
                        resultList = getParticipantsByHod(participant);
                    } else if (PackageParticipant.TYPE_WORKFLOW_VARIABLE.equals(participant.getType())) {
                        resultList = getParticipantsByWorkflowVariable(participant, actId);
                    } else if (PackageParticipant.TYPE_PLUGIN.equals(participant.getType())) {
                        resultList = getParticipantsByPlugin(participant, procDefId, procId, version, actId);
                    } else if (PackageParticipant.TYPE_ROLE.equals(participant.getType()) && PackageParticipant.VALUE_ROLE_LOGGED_IN_USER.equals(participant.getValue())) {
                        resultList = getParticipantsByLoggedInUser();
                    } else if (PackageParticipant.TYPE_ROLE.equals(participant.getType()) && PackageParticipant.VALUE_ROLE_ADMIN.equals(participant.getValue())) {
                        resultList = getParticipantsByAdminUser();
                    }
                }
            }
        } catch (Exception ex) {
View Full Code Here


                //if app version is the only version for the app and no package is found, set process start white list to admin user
                if (appDefinitionDao.countVersions(appId) == 1) {
                    Collection<WorkflowProcess> processList = workflowManager.getProcessList(appDef.getAppId(), packageVersion.toString());
                    for (WorkflowProcess wp : processList) {
                        String processIdWithoutVersion = WorkflowUtil.getProcessDefIdWithoutVersion(wp.getId());
                        PackageParticipant participant = new PackageParticipant();
                        participant.setProcessDefId(processIdWithoutVersion);
                        participant.setParticipantId(WorkflowUtil.PROCESS_START_WHITE_LIST);
                        participant.setType(PackageParticipant.TYPE_ROLE);
                        participant.setValue(PackageParticipant.VALUE_ROLE_ADMIN);
                        packageDefinitionDao.addAppParticipant(appDef.getAppId(), appDef.getVersion(), participant);
                    }
                }
            } else {
                originalVersion = packageDef.getVersion();
View Full Code Here

                            }
                        }

                        if (oldPackageDef.getPackageParticipantMap() != null) {
                            for (Entry e : oldPackageDef.getPackageParticipantMap().entrySet()) {
                                PackageParticipant participant = (PackageParticipant) e.getValue();
                                participant.setPackageDefinition(packageDef);
                                packageDefinitionDao.addAppParticipant(newAppDef.getAppId(), appVersion, participant);
                            }
                        }
                    }
View Full Code Here

            @RequestParam("param_participantId") String participantId,
            @RequestParam("param_type") String type,
            @RequestParam(value = "param_value", required = false) String value,
            @RequestParam(value = "pluginProperties", required = false) String pluginProperties) throws UnsupportedEncodingException {

        PackageParticipant participant = new PackageParticipant();
        participant.setProcessDefId(processDefId);
        participant.setParticipantId(participantId);

        AppDefinition appDef = appService.getAppDefinition(appId, version);
        PackageDefinition packageDef = appDef.getPackageDefinition();

        if (PackageParticipant.TYPE_PLUGIN.equals(type)) {
            if (pluginProperties == null) {
                //request params
                Map<String, String> propertyMap = new HashMap();
                Enumeration<String> e = request.getParameterNames();
                while (e.hasMoreElements()) {
                    String paramName = e.nextElement();

                    if (!paramName.startsWith("param_")) {
                        String[] paramValue = (String[]) request.getParameterValues(paramName);
                        propertyMap.put(paramName, CsvUtil.getDeliminatedString(paramValue));
                    }
                }

                // form csv properties
                StringWriter sw = new StringWriter();
                try {
                    CSVWriter writer = new CSVWriter(sw);
                    Iterator it = propertyMap.entrySet().iterator();
                    while (it.hasNext()) {
                        Map.Entry<String, String> pairs = (Map.Entry) it.next();
                        writer.writeNext(new String[]{pairs.getKey(), pairs.getValue()});
                    }
                    writer.close();
                } catch (Exception ex) {
                    LogUtil.error(getClass().getName(), ex, "");
                }
                String pluginProps = sw.toString();
                participant.setPluginProperties(pluginProps);
            } else {
                PackageParticipant participantExisting = packageDef.getPackageParticipant(processDefId, participantId);
                String oldJson = "";
                if (participantExisting != null && PackageParticipant.TYPE_PLUGIN.equals(participantExisting.getType())) {
                    oldJson = participantExisting.getPluginProperties();
                }
               
                participant.setPluginProperties(PropertyUtil.propertiesJsonStoreProcessing(oldJson, pluginProperties));
            }
        } else if ((PackageParticipant.TYPE_GROUP.equals(type) || PackageParticipant.TYPE_USER.equals(type)) && packageDef != null) {
            //Using Set to prevent duplicate value
            Set values = new HashSet();
            StringTokenizer valueToken = new StringTokenizer(value, ",");
            while (valueToken.hasMoreTokens()) {
                values.add((String) valueToken.nextElement());
            }
           
            PackageParticipant participantExisting = packageDef.getPackageParticipant(processDefId, participantId);
            if (participantExisting != null && participantExisting.getValue() != null) {
               
                StringTokenizer existingValueToken = (type.equals(participantExisting.getType())) ? new StringTokenizer(participantExisting.getValue().replaceAll(";", ","), ",") : null;
                while (existingValueToken != null && existingValueToken.hasMoreTokens()) {
                    values.add((String) existingValueToken.nextElement());
                }
            }
View Full Code Here

        if (value != null && value.trim().length() > 0) {
            plugin = pluginManager.getPlugin(value);
        } else {
            if (packageDef != null) {
                PackageParticipant participant = packageDef.getPackageParticipant(processDefId, participantId);
                plugin = pluginManager.getPlugin(participant.getValue());

                if (participant.getPluginProperties() != null && participant.getPluginProperties().trim().length() > 0) {
                    if (!(plugin instanceof PropertyEditable)) {
                        Map propertyMap = new HashMap();
                        propertyMap = CsvUtil.getPluginPropertyMap(participant.getPluginProperties());
                        map.addAttribute("propertyMap", propertyMap);
                    } else {
                        map.addAttribute("properties", PropertyUtil.propertiesJsonLoadProcessing(participant.getPluginProperties()));
                    }
                }
            }
        }
View Full Code Here

        AppDefinition appDef = appService.getAppDefinition(appId, version);
        PackageDefinition packageDef = appDef.getPackageDefinition();
        processDefId = WorkflowUtil.getProcessDefIdWithoutVersion(processDefId);

        if ((PackageParticipant.TYPE_USER.equals(type) || PackageParticipant.TYPE_GROUP.equals(type)) && value != null) {
            PackageParticipant participantExisting = packageDef.getPackageParticipant(processDefId, participantId);
            if (participantExisting != null && participantExisting.getValue() != null) {
                //Using Set to prevent duplicate value
                Set values = new HashSet();
                StringTokenizer existingValueToken = new StringTokenizer(participantExisting.getValue().replaceAll(";", ","), ",");
                while (existingValueToken.hasMoreTokens()) {
                    String temp = (String) existingValueToken.nextElement();
                    if (!temp.equals(value)) {
                        values.add(temp);
                    }
                }

                //Convert Set to String
                String result = "";
                Iterator i = values.iterator();
                while (i.hasNext()) {
                    result += i.next().toString() + ',';
                }
                if (value.length() > 0) {
                    result = result.substring(0, result.length() - 1);
                }
                participantExisting.setValue(result);
                packageDefinitionDao.addAppParticipant(appId, appDef.getVersion(), participantExisting);
            }
        } else {
            packageDefinitionDao.removeAppParticipant(appId, appDef.getVersion(), processDefId, participantId);
        }
View Full Code Here

TOP

Related Classes of org.joget.apps.app.model.PackageParticipant

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.