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, "");