Package org.joget.apps.app.dao

Examples of org.joget.apps.app.dao.EnvironmentVariableDao


                value = FormUtil.getElementPropertyValue(this, formData);
                if (!(value != null && value.trim().length() > 0)) {
                    String envVariable = getPropertyString("envVariable");
                    AppDefinition appDef = AppUtil.getCurrentAppDefinition();
                    ApplicationContext appContext = AppUtil.getApplicationContext();
                    EnvironmentVariableDao environmentVariableDao = (EnvironmentVariableDao) appContext.getBean("environmentVariableDao");
                    EnvironmentVariable env = environmentVariableDao.loadById(envVariable, appDef);

                    int count = 0;

                    if (env != null && env.getValue() != null && env.getValue().trim().length() > 0) {
                        count = Integer.parseInt(env.getValue());
                    }
                    count += 1;

                    String format = getPropertyString("format");
                    value = format;
                    Matcher m = Pattern.compile("(\\?+)").matcher(format);
                    if (m.find()) {
                        String pattern = m.group(1);
                        String formater = pattern.replaceAll("\\?", "0");
                        pattern = pattern.replaceAll("\\?", "\\\\?");

                        DecimalFormat myFormatter = new DecimalFormat(formater);
                        String runningNumber = myFormatter.format(count);
                        value = value.replaceAll(pattern, runningNumber);
                    }

                    if (env == null) {
                        env = new EnvironmentVariable();
                        env.setAppDefinition(appDef);
                        env.setAppId(appDef.getId());
                        env.setAppVersion(appDef.getVersion());
                        env.setId(envVariable);
                        env.setRemarks("Used for plugin: " + getName());
                        env.setValue(Integer.toString(count));
                        environmentVariableDao.add(env);
                    } else {
                        env.setValue(Integer.toString(count));
                        environmentVariableDao.update(env);
                    }

                }
            } catch (Exception e) {
                LogUtil.error(IdGeneratorField.class.getName(), e, "");
View Full Code Here


    @Override
    public String processHashVariable(String variableKey) {
        AppDefinition appDef = (AppDefinition) getProperty("appDefinition");
        if (appDef != null) {
            ApplicationContext appContext = AppUtil.getApplicationContext();
            EnvironmentVariableDao environmentVariableDao = (EnvironmentVariableDao) appContext.getBean("environmentVariableDao");
            EnvironmentVariable env = environmentVariableDao.loadById(variableKey, appDef);
            if (env != null) {
                return env.getValue();
            }
        }
        return null;
View Full Code Here

TOP

Related Classes of org.joget.apps.app.dao.EnvironmentVariableDao

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.