コード例 #1
0
  protected AbstractWorkflowModuleDescriptor getWorkflowModuleDescriptor(
      String className, final String pluginType) throws PluginParseException {
    final Collection moduleDescriptors =
        pluginAccessor.getEnabledModuleDescriptorsByType(pluginType);

    for (Iterator iterator = moduleDescriptors.iterator(); iterator.hasNext(); ) {
      AbstractWorkflowModuleDescriptor abstractWorkflowModuleDescriptor =
          (AbstractWorkflowModuleDescriptor) iterator.next();
      if (abstractWorkflowModuleDescriptor.getImplementationClass().getName().equals(className)) {
        return abstractWorkflowModuleDescriptor;
      }
    }

    return null;
  }
コード例 #2
0
  public WorkflowDescriptorInfo formatDescriptor(AbstractDescriptor descriptor) {
    final String type;
    final Map args;
    if (descriptor instanceof FunctionDescriptor) {
      type = ((FunctionDescriptor) descriptor).getType();
      args = ((FunctionDescriptor) descriptor).getArgs();
    } else if (descriptor instanceof ConditionDescriptor) {
      type = ((ConditionDescriptor) descriptor).getType();
      args = ((ConditionDescriptor) descriptor).getArgs();
    } else if (descriptor instanceof ValidatorDescriptor) {
      type = ((ValidatorDescriptor) descriptor).getType();
      args = ((ValidatorDescriptor) descriptor).getArgs();
    } else {
      throw new IllegalArgumentException("Invalid descriptor type");
    }

    if ("class".equalsIgnoreCase(type) && args.containsKey("class.name")) {
      String className = (String) args.get("class.name");
      try {
        final AbstractWorkflowModuleDescriptor abstractWorkflowModuleDescriptor =
            getWorkflowModuleDescriptor(className, pluginType);

        if (abstractWorkflowModuleDescriptor != null) {
          // We have a plugin module that can generate description HTML for us - so use it
          String description =
              abstractWorkflowModuleDescriptor.getHtml(
                  JiraWorkflowPluginConstants.RESOURCE_NAME_VIEW, descriptor);
          return new WorkflowDescriptorInfo(
              description,
              orderable && abstractWorkflowModuleDescriptor.isOrderable(),
              delete && abstractWorkflowModuleDescriptor.isDeletable(),
              edit && abstractWorkflowModuleDescriptor.isEditable());
        } else {
          // If we do not have a descriptor for the module we cannot edit it
          return new WorkflowDescriptorInfo(null, orderable, delete, false);
        }

      } catch (PluginParseException e) {
        final String message = "Cannot find module descriptors.";
        log.error(message, e);
        throw new NestableRuntimeException(message, e);
      }
    }

    // If we do not have a descriptor for the module we cannot edit it
    return new WorkflowDescriptorInfo(
        "Type: " + type + " with arguments " + args, orderable, delete, false);
  }