Package org.joget.apps.app.model

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


    public Collection<String> createAppDefinition(AppDefinition appDefinition) {
        Collection<String> errors = new ArrayList<String>();

        // check for duplicate
        String appId = appDefinition.getId();
        AppDefinition appDef = appDefinitionDao.loadById(appId);
        if (appDef != null) {
            errors.add("console.app.error.label.idExists");
        } else {
            // create app
            appDefinitionDao.saveOrUpdate(appDefinition);
View Full Code Here


    public AppDefinition createNewAppDefinitionVersion(String appId) {
        TimeZone current = TimeZone.getDefault();
        TimeZone.setDefault(TimeZone.getTimeZone("GMT 0"));
       
        Long version = appDefinitionDao.getLatestVersion(appId);
        AppDefinition appDef = appDefinitionDao.loadVersion(appId, version);

        Serializer serializer = new Persister();
        AppDefinition newAppDef = null;

        try {
            newAppDef = serializer.read(AppDefinition.class, new ByteArrayInputStream(getAppDefinitionXml(appId, version)), "UTF-8");
        } catch (Exception e) {
            LogUtil.error(AppServiceImpl.class.getName(), e, appId);
        } finally {
            TimeZone.setDefault(current);
        }

        PackageDefinition packageDef = appDef.getPackageDefinition();
        byte[] xpdl = null;
       
        if (packageDef != null) {
            xpdl = workflowManager.getPackageContent(packageDef.getId(), packageDef.getVersion().toString());
        }
       
        Long newAppVersion = newAppDef.getVersion() + 1;
        return importAppDefinition(newAppDef, newAppVersion, xpdl);
    }
View Full Code Here

        return importAppDefinition(newAppDef, newAppVersion, xpdl);
    }

    @Override
    public void deleteAppDefinitionVersion(String appId, Long version) {
        AppDefinition appDef = appDefinitionDao.loadVersion(appId, version);

        appDefinitionDao.delete(appDef);
    }
View Full Code Here

    //----- Console workflow management use cases ------
    @Override
    public PackageDefinition deployWorkflowPackage(String appId, String version, byte[] packageXpdl, boolean createNewApp) throws Exception {

        PackageDefinition packageDef = null;
        AppDefinition appDef = null;
        String packageId = workflowManager.getPackageIdFromDefinition(packageXpdl);
       
        // get app version
        if (appId != null && !appId.isEmpty()) {
            appDef = loadAppDefinition(appId, version);

            // verify packageId
            if (appDef != null && !packageId.equalsIgnoreCase(appDef.getAppId())) {
                throw new UnsupportedOperationException("Package ID does not match App ID");
            }
        } else {
            appDef = loadAppDefinition(packageId, null);
        }

        if (appDef != null || createNewApp) {
            Long originalVersion = null;
           
            //to fix package id letter case issue
            if (appDef != null && !packageId.equals(appDef.getAppId())) {
                packageXpdl = StringUtil.searchAndReplaceByteContent(packageXpdl, packageId, appDef.getAppId());
                packageId = appDef.getAppId();
            }

            // deploy package
            String versionStr = workflowManager.getCurrentPackageVersion(packageId);
            String packageIdToUpload = (versionStr != null && !versionStr.isEmpty()) ? packageId : null;
            workflowManager.processUpload(packageIdToUpload, packageXpdl);

            // load package
            versionStr = workflowManager.getCurrentPackageVersion(packageId);
            WorkflowPackage workflowPackage = workflowManager.getPackage(packageId, versionStr);

            // create app from package if not specified
            if (appDef == null) {
                appDef = new AppDefinition();
                appDef.setAppId(packageId);
                appDef.setName(workflowPackage.getPackageName());
                appDef.setVersion(new Long(1));
                createAppDefinition(appDef);
            }

            // get package definition
            packageDef = appDef.getPackageDefinition();
            Long packageVersion = Long.parseLong(versionStr);
            if (packageDef == null) {
                packageDef = packageDefinitionDao.createPackageDefinition(appDef, packageVersion);
               
                //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();
                packageDefinitionDao.updatePackageDefinitionVersion(packageDef, packageVersion);
View Full Code Here

     * @return
     */
    protected Form loadFormByFormDefId(String appId, String version, String formDefId, FormData formData, WorkflowAssignment wfAssignment) {
        Form form = null;
        try {
            AppDefinition appDef = getAppDefinition(appId, version);
            FormDefinition formDef = formDefinitionDao.loadById(formDefId, appDef);
           
            if (formDef != null && formDef.getJson() != null) {
                String formJson = formDef.getJson();
                formJson = AppUtil.processHashVariable(formJson, wfAssignment, StringUtil.TYPE_JSON, null);
View Full Code Here

        TimeZone.setDefault(TimeZone.getTimeZone("GMT 0"));
       
        try {
            baos = new ByteArrayOutputStream();

            AppDefinition appDef = getAppDefinition(appId, Long.toString(version));

            Serializer serializer = new Persister();
            serializer.write(appDef, baos, "UTF-8");

            appDefinitionXml = baos.toByteArray();
View Full Code Here

        auditTrail.setClazz(clazz);
        auditTrail.setMethod(method);
        auditTrail.setMessage(message);
        auditTrail.setTimestamp(new Date());

        AppDefinition appDef = AppUtil.getCurrentAppDefinition();
        if (appDef != null) {
            auditTrail.setAppId(appDef.getId());
            auditTrail.setAppVersion(appDef.getVersion().toString());
        }

        auditTrailDao.addAuditTrail(auditTrail);
        executePlugin(auditTrail);
    }
View Full Code Here

    protected void executePlugin(AuditTrail auditTrail) {
        Collection<Plugin> pluginList = pluginManager.list(AuditTrailPlugin.class);
        for (Plugin plugin : pluginList) {
            AuditTrailPlugin p = (AuditTrailPlugin) plugin;
            try {
                AppDefinition appDef = AppUtil.getCurrentAppDefinition();
                if (appDef != null) {
                    PluginDefaultPropertiesDao pluginDefaultPropertiesDao = (PluginDefaultPropertiesDao) AppUtil.getApplicationContext().getBean("pluginDefaultPropertiesDao");
                    PluginDefaultProperties pluginDefaultProperties = pluginDefaultPropertiesDao.loadById(plugin.getClass().getName(), appDef);

                    if (pluginDefaultProperties != null) {
View Full Code Here

            }

            String appId = "";
            String appVersion = "";

            AppDefinition appDef = AppUtil.getCurrentAppDefinition();

            if (appDef != null) {
                appId = appDef.getId();
                appVersion = appDef.getVersion().toString();
            }

            String filePath = "/web/client/app/" + appId + "/" + appVersion + "/form/download/" + formDefId + "/" + primaryKeyValue + "/" + encodedFileName + ".";
            if (Boolean.valueOf(getPropertyString("attachment")).booleanValue()) {
                filePath += "?attachment=true";
View Full Code Here

    @Override
    public String renderTemplate(FormData formData, Map dataModel) {
        String template = "form.ftl";

        // get current app
        AppDefinition appDef = AppUtil.getCurrentAppDefinition();
        if (appDef != null) {
            dataModel.put("appId", appDef.getAppId());
            dataModel.put("appVersion", appDef.getVersion());
        }
       
        // check whether in form builder
        boolean formBuilderActive = FormUtil.isFormBuilderActive();
      
View Full Code Here

TOP

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

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.