Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no longer set category job for every element on xml if category was set in config enableCategory #3734

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.flowable.common.engine.api.variable.VariableContainer;
import org.flowable.job.service.JobService;
import org.flowable.job.service.impl.persistence.entity.JobEntity;
import org.springframework.util.CollectionUtils;

/**
* @author Filip Hrisafov
Expand Down Expand Up @@ -62,19 +63,23 @@ protected static JobEntity createJob(VariableContainer variableContainer, BaseEl
job.setElementName(((CaseElement) baseElement).getName());
}

List<ExtensionElement> jobCategoryElements = baseElement.getExtensionElements().get("jobCategory");
if (jobCategoryElements != null && jobCategoryElements.size() > 0) {
ExtensionElement jobCategoryElement = jobCategoryElements.get(0);
if (StringUtils.isNotEmpty(jobCategoryElement.getElementText())) {
Expression categoryExpression = cmmnEngineConfiguration.getExpressionManager().createExpression(jobCategoryElement.getElementText());
Object categoryValue = categoryExpression.getValue(variableContainer);
if (categoryValue != null) {
job.setCategory(categoryValue.toString());
if(CollectionUtils.isEmpty(cmmnEngineConfiguration.getEnabledJobCategories())){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(CollectionUtils.isEmpty(cmmnEngineConfiguration.getEnabledJobCategories())){
if (CollectionUtils.isEmpty(cmmnEngineConfiguration.getEnabledJobCategories())) {

The project standards are to use spaces

List<ExtensionElement> jobCategoryElements = baseElement.getExtensionElements().get("jobCategory");
if (jobCategoryElements != null && jobCategoryElements.size() > 0) {
ExtensionElement jobCategoryElement = jobCategoryElements.get(0);
if (StringUtils.isNotEmpty(jobCategoryElement.getElementText())) {
Expression categoryExpression = cmmnEngineConfiguration.getExpressionManager().createExpression(jobCategoryElement.getElementText());
Object categoryValue = categoryExpression.getValue(variableContainer);
if (categoryValue != null) {
job.setCategory(categoryValue.toString());
}
}
}
}else{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}else{
} else {

String category = cmmnEngineConfiguration.getEnabledJobCategories().get(0);
job.setCategory(category);
}


job.setTenantId(variableContainer.getTenantId());

return job;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.job.service.JobService;
import org.flowable.job.service.impl.persistence.entity.JobEntity;
import org.springframework.util.CollectionUtils;

/**
* @author Filip Hrisafov
Expand All @@ -45,18 +46,25 @@ public static JobEntity createJob(ExecutionEntity execution, BaseElement baseEle
}
job.setJobHandlerType(jobHandlerType);

List<ExtensionElement> jobCategoryElements = baseElement.getExtensionElements().get("jobCategory");
if (jobCategoryElements != null && jobCategoryElements.size() > 0) {
ExtensionElement jobCategoryElement = jobCategoryElements.get(0);
if (StringUtils.isNotEmpty(jobCategoryElement.getElementText())) {
Expression categoryExpression = processEngineConfiguration.getExpressionManager().createExpression(jobCategoryElement.getElementText());
Object categoryValue = categoryExpression.getValue(execution);
if (categoryValue != null) {
job.setCategory(categoryValue.toString());

if(CollectionUtils.isEmpty(processEngineConfiguration.getEnabledJobCategories())){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(CollectionUtils.isEmpty(processEngineConfiguration.getEnabledJobCategories())){
if (CollectionUtils.isEmpty(processEngineConfiguration.getEnabledJobCategories())) {

List<ExtensionElement> jobCategoryElements = baseElement.getExtensionElements().get("jobCategory");
if (jobCategoryElements != null && jobCategoryElements.size() > 0) {
ExtensionElement jobCategoryElement = jobCategoryElements.get(0);
if (StringUtils.isNotEmpty(jobCategoryElement.getElementText())) {
Expression categoryExpression = processEngineConfiguration.getExpressionManager().createExpression(jobCategoryElement.getElementText());
Object categoryValue = categoryExpression.getValue(execution);
if (categoryValue != null) {
job.setCategory(categoryValue.toString());
}
}
}
}else{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}else{
} else {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I forgot format, hihi

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbmalkovsky done, pls re-check

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tijsrademakers pls review this

String category = processEngineConfiguration.getEnabledJobCategories().get(0);
job.setCategory(category);
}


// Inherit tenant id (if applicable)
if (execution.getTenantId() != null) {
job.setTenantId(execution.getTenantId());
Expand Down