/** * Gets the Regex pattern to match the namespace and job name from a process definition key. * * @return the Regex pattern */ public Pattern getNamespaceAndJobNameRegexPattern() { // Get the job definition template (e.g. ~namespace~.~jobName~) and Regex escape all periods (e.g. ~namespace~\\.~jobName~). String jobDefinitionTemplate = getActivitiJobDefinitionTemplate().replaceAll("\\.", "\\\\."); // Change the tokens to named capture groups (e.g. (?<namespace>.*)\\.(?<jobName>.*)). jobDefinitionTemplate = jobDefinitionTemplate.replaceAll(getNamespaceToken(), "(?<namespace>.*)"); jobDefinitionTemplate = jobDefinitionTemplate.replaceAll(getJobNameToken(), "(?<jobName>.*)"); // Compile the Regex pattern. return Pattern.compile(jobDefinitionTemplate); }
/** * Gets the Regex pattern to match the namespace and job name from a process definition key. * * @return the Regex pattern */ public Pattern getNamespaceAndJobNameRegexPattern() { // Get the job definition template (e.g. ~namespace~.~jobName~) and Regex escape all periods (e.g. ~namespace~\\.~jobName~). String jobDefinitionTemplate = getActivitiJobDefinitionTemplate().replaceAll("\\.", "\\\\."); // Change the tokens to named capture groups (e.g. (?<namespace>.*)\\.(?<jobName>.*)). jobDefinitionTemplate = jobDefinitionTemplate.replaceAll(getNamespaceToken(), "(?<namespace>.*)"); jobDefinitionTemplate = jobDefinitionTemplate.replaceAll(getJobNameToken(), "(?<jobName>.*)"); // Compile the Regex pattern. return Pattern.compile(jobDefinitionTemplate); }
/** * Returns Activiti Id constructed according to the template defined. * * @param namespaceCd the namespace code value * @param jobName the job name value * * @return the Activiti Id */ public String buildActivitiIdString(String namespaceCd, String jobName) { // Populate a map with the tokens mapped to actual database values. Map<String, String> pathToTokenValueMap = new HashMap<>(); pathToTokenValueMap.put(getNamespaceToken(), namespaceCd); pathToTokenValueMap.put(getJobNameToken(), jobName); // The Activiti Id will start as the template. String activitiId = getActivitiJobDefinitionTemplate(); // Substitute the tokens with the actual database values. for (Map.Entry<String, String> mapEntry : pathToTokenValueMap.entrySet()) { activitiId = activitiId.replaceAll(mapEntry.getKey(), mapEntry.getValue()); } // Return the final Activiti Id. return activitiId; }
/** * Returns Activiti Id constructed according to the template defined. * * @param namespaceCd the namespace code value * @param jobName the job name value * * @return the Activiti Id */ public String buildActivitiIdString(String namespaceCd, String jobName) { // Populate a map with the tokens mapped to actual database values. Map<String, String> pathToTokenValueMap = new HashMap<>(); pathToTokenValueMap.put(getNamespaceToken(), namespaceCd); pathToTokenValueMap.put(getJobNameToken(), jobName); // The Activiti Id will start as the template. String activitiId = getActivitiJobDefinitionTemplate(); // Substitute the tokens with the actual database values. for (Map.Entry<String, String> mapEntry : pathToTokenValueMap.entrySet()) { activitiId = activitiId.replaceAll(mapEntry.getKey(), mapEntry.getValue()); } // Return the final Activiti Id. return activitiId; }
/** * Gets the Activiti job definition template. * * @return the Activiti job definition template. */ public String getActivitiJobDefinitionTemplate() { // Set the default Activiti Id tokenized template. // ~namespace~.~jobName~ String defaultActivitiIdTemplate = getNamespaceToken() + "." + getJobNameToken(); // Get the Activiti Id template from the environment, but use the default if one isn't configured. // This gives us the ability to customize/change the format post deployment. String template = configurationHelper.getProperty(ConfigurationValue.ACTIVITI_JOB_DEFINITION_ID_TEMPLATE); if (template == null) { template = defaultActivitiIdTemplate; } return template; }
/** * Gets the Activiti job definition template. * * @return the Activiti job definition template. */ public String getActivitiJobDefinitionTemplate() { // Set the default Activiti Id tokenized template. // ~namespace~.~jobName~ String defaultActivitiIdTemplate = getNamespaceToken() + "." + getJobNameToken(); // Get the Activiti Id template from the environment, but use the default if one isn't configured. // This gives us the ability to customize/change the format post deployment. String template = configurationHelper.getProperty(ConfigurationValue.ACTIVITI_JOB_DEFINITION_ID_TEMPLATE); if (template == null) { template = defaultActivitiIdTemplate; } return template; }