private TenantCommand fetchTenantCommand(final SCommandFetcher commandFetcher, final boolean transactionManagedManually) throws SCommandNotFoundException, SCommandParameterizationException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); try { final SCommand sCommand; if (transactionManagedManually) { sCommand = commandFetcher.fetchInTransaction(tenantAccessor.getUserTransactionService(), tenantAccessor.getCommandService()); } else { sCommand = commandFetcher.fetch(tenantAccessor.getCommandService()); } final String tenantCommandClassName = sCommand.getImplementation(); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); return (TenantCommand) contextClassLoader.loadClass(tenantCommandClassName).newInstance(); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new SCommandParameterizationException(e); } }
private void update(final SCommandFetcher commandFetcher, final CommandUpdater updateDescriptor) throws UpdateException { if (updateDescriptor == null || updateDescriptor.getFields().isEmpty()) { throw new UpdateException("The update descriptor does not contain field updates"); } final SCommandUpdateBuilderFactory fact = BuilderFactory.get(SCommandUpdateBuilderFactory.class); final SCommandUpdateBuilder commandUpdateBuilder = fact.createNewInstance(); final CommandService commandService = getTenantAccessor().getCommandService(); try { final EntityUpdateDescriptor changeDescriptor = getCommandUpdateDescriptor(updateDescriptor, commandUpdateBuilder); final SCommand sCommand = commandFetcher.fetch(commandService); commandService.update(sCommand, changeDescriptor); } catch (final SCommandNotFoundException | SCommandUpdateException e) { throw new UpdateException(e); } }
private TenantCommand fetchTenantCommand(final SCommandFetcher commandFetcher, final boolean transactionManagedManually) throws SCommandNotFoundException, SCommandParameterizationException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); try { final SCommand sCommand; if (transactionManagedManually) { sCommand = commandFetcher.fetchInTransaction(tenantAccessor.getUserTransactionService(), tenantAccessor.getCommandService()); } else { sCommand = commandFetcher.fetch(tenantAccessor.getCommandService()); } final String tenantCommandClassName = sCommand.getImplementation(); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); return (TenantCommand) contextClassLoader.loadClass(tenantCommandClassName).newInstance(); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new SCommandParameterizationException(e); } }
private void update(final SCommandFetcher commandFetcher, final CommandUpdater updateDescriptor) throws UpdateException { if (updateDescriptor == null || updateDescriptor.getFields().isEmpty()) { throw new UpdateException("The update descriptor does not contain field updates"); } final SCommandUpdateBuilderFactory fact = BuilderFactory.get(SCommandUpdateBuilderFactory.class); final SCommandUpdateBuilder commandUpdateBuilder = fact.createNewInstance(); final CommandService commandService = getTenantAccessor().getCommandService(); try { final EntityUpdateDescriptor changeDescriptor = getCommandUpdateDescriptor(updateDescriptor, commandUpdateBuilder); final SCommand sCommand = commandFetcher.fetch(commandService); commandService.update(sCommand, changeDescriptor); } catch (final SCommandNotFoundException | SCommandUpdateException e) { throw new UpdateException(e); } }
private CommandDescriptor getCommand(final SCommandFetcher commandFetcher) throws CommandNotFoundException { final CommandService commandService = getTenantAccessor().getCommandService(); try { final SCommand sCommand = commandFetcher.fetch(commandService); return ModelConvertor.toCommandDescriptor(sCommand); } catch (final SBonitaException e) { throw new CommandNotFoundException(e); } }
private CommandDescriptor getCommand(final SCommandFetcher commandFetcher) throws CommandNotFoundException { final CommandService commandService = getTenantAccessor().getCommandService(); try { final SCommand sCommand = commandFetcher.fetch(commandService); return ModelConvertor.toCommandDescriptor(sCommand); } catch (final SBonitaException e) { throw new CommandNotFoundException(e); } }
@Override public SCommand call() throws Exception { return fetch(commandService); } });
@Override public SCommand call() throws Exception { return fetch(commandService); } });