use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.
the class BpmnDeployer method localizeFlowElements.
protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) {
boolean localizationValuesChanged = false;
if (flowElements == null)
return localizationValuesChanged;
CommandContext commandContext = Context.getCommandContext();
DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof UserTask || flowElement instanceof SubProcess) {
List<ExtensionElement> localizationElements = flowElement.getExtensionElements().get("localization");
if (localizationElements != null) {
for (ExtensionElement localizationElement : localizationElements) {
if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
String locale = localizationElement.getAttributeValue(null, "locale");
String name = localizationElement.getAttributeValue(null, "name");
String documentation = null;
List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
if (documentationElements != null) {
for (ExtensionElement documentationElement : documentationElements) {
documentation = StringUtils.trimToNull(documentationElement.getElementText());
break;
}
}
String flowElementId = flowElement.getId();
if (isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false) {
dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode);
localizationValuesChanged = true;
}
if (documentation != null && isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode) == false) {
dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode);
localizationValuesChanged = true;
}
break;
}
}
}
if (flowElement instanceof SubProcess) {
SubProcess subprocess = (SubProcess) flowElement;
boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode);
boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode);
if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
localizationValuesChanged = true;
}
}
}
}
return localizationValuesChanged;
}
use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.
the class BpmnDeployer method localizeDataObjectElements.
protected boolean localizeDataObjectElements(List<ValuedDataObject> dataObjects, ObjectNode infoNode) {
boolean localizationValuesChanged = false;
CommandContext commandContext = Context.getCommandContext();
DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
for (ValuedDataObject dataObject : dataObjects) {
List<ExtensionElement> localizationElements = dataObject.getExtensionElements().get("localization");
if (localizationElements != null) {
for (ExtensionElement localizationElement : localizationElements) {
if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
String locale = localizationElement.getAttributeValue(null, "locale");
String name = localizationElement.getAttributeValue(null, "name");
String documentation = null;
List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
if (documentationElements != null) {
for (ExtensionElement documentationElement : documentationElements) {
documentation = StringUtils.trimToNull(documentationElement.getElementText());
break;
}
}
if (name != null && isEqualToCurrentLocalizationValue(locale, dataObject.getName(), DynamicBpmnConstants.LOCALIZATION_NAME, name, infoNode) == false) {
dynamicBpmnService.changeLocalizationName(locale, dataObject.getName(), name, infoNode);
localizationValuesChanged = true;
}
if (documentation != null && isEqualToCurrentLocalizationValue(locale, dataObject.getName(), DynamicBpmnConstants.LOCALIZATION_DESCRIPTION, documentation, infoNode) == false) {
dynamicBpmnService.changeLocalizationDescription(locale, dataObject.getName(), documentation, infoNode);
localizationValuesChanged = true;
}
}
}
}
}
return localizationValuesChanged;
}
use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.
the class BpmnDeployer method removeExistingSignalEventSubScription.
protected void removeExistingSignalEventSubScription(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) {
if (latestProcessDefinition != null) {
CommandContext commandContext = Context.getCommandContext();
List<EventSubscriptionEntity> subscriptionsToDisable = commandContext.getEventSubscriptionEntityManager().findEventSubscriptionsByTypeAndProcessDefinitionId(SignalEventHandler.EVENT_HANDLER_TYPE, latestProcessDefinition.getId(), latestProcessDefinition.getTenantId());
for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDisable) {
eventSubscriptionEntity.delete();
}
}
}
use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.
the class SpringTransactionContext method addTransactionListener.
public void addTransactionListener(final TransactionState transactionState, final TransactionListener transactionListener) {
if (transactionState.equals(TransactionState.COMMITTING)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void beforeCommit(boolean readOnly) {
transactionListener.execute(commandContext);
}
});
} else if (transactionState.equals(TransactionState.COMMITTED)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
CommandExecutor commandExecutor = commandContext.getProcessEngineConfiguration().getCommandExecutor();
CommandConfig commandConfig = new CommandConfig(false, TransactionPropagation.REQUIRES_NEW);
commandExecutor.execute(commandConfig, new Command<Void>() {
public Void execute(CommandContext commandContext) {
transactionListener.execute(commandContext);
return null;
}
});
}
});
} else if (transactionState.equals(TransactionState.ROLLINGBACK)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void beforeCompletion() {
transactionListener.execute(commandContext);
}
});
} else if (transactionState.equals(TransactionState.ROLLED_BACK)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCompletion(int status) {
if (TransactionSynchronization.STATUS_ROLLED_BACK == status) {
CommandExecutor commandExecutor = commandContext.getProcessEngineConfiguration().getCommandExecutor();
CommandConfig commandConfig = new CommandConfig(false, TransactionPropagation.REQUIRES_NEW);
commandExecutor.execute(commandConfig, new Command<Void>() {
public Void execute(CommandContext commandContext) {
transactionListener.execute(commandContext);
return null;
}
});
}
}
});
}
}
use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.
the class EventSubscriptionQueryTest method testQueryByEventType.
public void testQueryByEventType() {
processEngineConfiguration.getCommandExecutor().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity1.setEventName("messageName");
messageEventSubscriptionEntity1.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity2.setEventName("messageName");
messageEventSubscriptionEntity2.insert();
SignalEventSubscriptionEntity signalEventSubscriptionEntity3 = new SignalEventSubscriptionEntity();
signalEventSubscriptionEntity3.setEventName("messageName2");
signalEventSubscriptionEntity3.insert();
return null;
}
});
List<EventSubscriptionEntity> list = newEventSubscriptionQuery().eventType("signal").list();
assertEquals(1, list.size());
list = newEventSubscriptionQuery().eventType("message").list();
assertEquals(2, list.size());
cleanDb();
}
Aggregations