Package org.mifosplatform.infrastructure.hooks.domain

Examples of org.mifosplatform.infrastructure.hooks.domain.Hook


      final Set<HookConfiguration> config = assembleConfig(
          command.mapValueOfParameterNamed(configJson), template);
      final JsonArray events = command
          .arrayOfParameterNamed(eventsParamName);
      final Set<HookResource> allEvents = assembleSetOfEvents(events);
      final Hook hook = Hook.fromJson(command, template, config,
          allEvents);

      validateHookRules(template, config, allEvents);

      this.hookRepository.save(hook);

      return new CommandProcessingResultBuilder()
          .withCommandId(command.commandId())
          .withEntityId(hook.getId()).build();
    } catch (final DataIntegrityViolationException dve) {
      handleHookDataIntegrityIssues(command, dve);
      return CommandProcessingResult.empty();
    }
  }
View Full Code Here


    try {
      this.context.authenticatedUser();

      this.fromApiJsonDeserializer.validateForUpdate(command.json());

      final Hook hook = retrieveHookBy(hookId);
      final HookTemplate template = hook.getHookTemplate();
      final Map<String, Object> changes = hook.update(command);

      if (!changes.isEmpty()) {

        if (changes.containsKey(eventsParamName)) {
          final Set<HookResource> events = assembleSetOfEvents(command
              .arrayOfParameterNamed(eventsParamName));
          final boolean updated = hook.updateEvents(events);
          if (!updated) {
            changes.remove(eventsParamName);
          }
        }

        if (changes.containsKey(configParamName)) {
          final String configJson = command
              .jsonFragment(configParamName);
          final Set<HookConfiguration> config = assembleConfig(
              command.mapValueOfParameterNamed(configJson),
              template);
          final boolean updated = hook.updateConfig(config);
          if (!updated) {
            changes.remove(configParamName);
          }
        }
View Full Code Here

  @CacheEvict(value = "hooks", allEntries = true)
  public CommandProcessingResult deleteHook(final Long hookId) {

    this.context.authenticatedUser();

    final Hook hook = retrieveHookBy(hookId);

    try {
      this.hookRepository.delete(hook);
      this.hookRepository.flush();
    } catch (final DataIntegrityViolationException e) {
View Full Code Here

    return new CommandProcessingResultBuilder().withEntityId(hookId)
        .build();
  }

  private Hook retrieveHookBy(final Long hookId) {
    final Hook hook = this.hookRepository.findOne(hookId);
    if (hook == null) {
      throw new HookNotFoundException(hookId.toString());
    }
    return hook;
  }
View Full Code Here

TOP

Related Classes of org.mifosplatform.infrastructure.hooks.domain.Hook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.