/**
  * @see org.dwfa.bpa.process.I_DefineTask#complete(org.dwfa.bpa.process.I_EncodeBusinessProcess,
  *     org.dwfa.bpa.process.I_Work)
  */
 public void complete(I_EncodeBusinessProcess process, I_Work worker) throws TaskFailedException {
   try {
     ServiceID serviceID = null;
     Class<?>[] serviceTypes = new Class[] {I_QueueProcesses.class};
     Entry[] attrSetTemplates = new Entry[] {this.queueType, this.queueType2};
     ServiceTemplate template = new ServiceTemplate(serviceID, serviceTypes, attrSetTemplates);
     ServiceItemFilter filter = null;
     ServiceItem service = worker.lookup(template, filter);
     I_QueueProcesses q = (I_QueueProcesses) service.service;
     q.write(process, worker.getActiveTransaction());
   } catch (Exception e) {
     throw new TaskFailedException(e);
   }
 }
  @SuppressWarnings("unchecked")
  public Condition evaluate(I_EncodeBusinessProcess process, I_Work worker)
      throws TaskFailedException {
    try {
      List<Collection<UUID>> tempListList =
          (List<Collection<UUID>>) process.getProperty(uuidListListPropName);

      if (worker.getLogger().isLoggable(Level.FINE)) {
        worker.getLogger().fine(("Removing first batch in attachment list."));
      }

      int sizeOfList = tempListList.size();
      List<Collection<UUID>> uuidListList = null;
      if (sizeOfList > listListSize) {
        uuidListList = new ArrayList<Collection<UUID>>(tempListList.subList(0, listListSize));
      } else {
        uuidListList = new ArrayList<Collection<UUID>>(tempListList.subList(0, sizeOfList));
      }

      process.setProperty(this.uuidList2PropName, uuidListList);

      if (tempListList.removeAll(uuidListList)) {
        // do nothing
      } else {
        worker.getLogger().info("error encountered in removing uuid collection from list");
      }

      return Condition.CONTINUE;
    } catch (IllegalArgumentException e) {
      throw new TaskFailedException(e);
    } catch (InvocationTargetException e) {
      throw new TaskFailedException(e);
    } catch (IntrospectionException e) {
      throw new TaskFailedException(e);
    } catch (IllegalAccessException e) {
      throw new TaskFailedException(e);
    }
  }
  public Condition evaluate(I_EncodeBusinessProcess process, I_Work worker)
      throws TaskFailedException {
    try {
      I_ConfigAceFrame config =
          (I_ConfigAceFrame) worker.readAttachement(WorkerAttachmentKeys.ACE_FRAME_CONFIG.name());

      I_TermFactory tf = Terms.get();

      I_ConfigAceFrame workingProfile = (I_ConfigAceFrame) process.getProperty(profilePropName);
      if (workingProfile == null) {
        workingProfile =
            (I_ConfigAceFrame) worker.readAttachement(WorkerAttachmentKeys.ACE_FRAME_CONFIG.name());
      }

      Object conceptObj = process.getProperty(activeConceptPropName);
      I_GetConceptData concept = AceTaskUtil.getConceptFromObject(conceptObj);

      List<? extends I_ConceptAttributeTuple> attrTupels =
          concept.getConceptAttributeTuples(
              workingProfile.getAllowedStatus(), workingProfile.getViewPositionSetReadOnly(),
              workingProfile.getPrecedence(), workingProfile.getConflictResolutionStrategy());

      I_IntSet pathSet = Terms.get().newIntSet();

      ArrayList<UniversalAcePosition> positionList = new ArrayList<UniversalAcePosition>();
      for (I_ConceptAttributeTuple t : attrTupels) {
        positionList.add(
            new UniversalAcePosition(
                tf.getUids(t.getPathId()), tf.convertToThickVersion(t.getVersion())));
        pathSet.add(t.getPathId());
      }
      ArrayList<String> addressList = new ArrayList<String>();

      I_IntList inboxDescTypeList = Terms.get().newIntList();
      inboxDescTypeList.add(ArchitectonicAuxiliary.Concept.USER_INBOX.localize().getNid());
      for (int pathId : pathSet.getSetValues()) {
        I_GetConceptData pathConcept = Terms.get().getConcept(pathId);
        I_DescriptionTuple inboxDesc = pathConcept.getDescTuple(inboxDescTypeList, config);
        if (inboxDesc == null) {
          worker.getLogger().info("Cannot find inbox for: " + pathConcept.getInitialText());
          worker.getLogger().info(" inboxDescTypeList: " + inboxDescTypeList.getListArray());
          for (I_DescriptionVersioned desc : pathConcept.getDescriptions()) {
            for (I_DescriptionTuple tuple : desc.getTuples()) {
              worker.getLogger().info(" desc tuple: " + tuple);
            }
          }
        } else {
          addressList.add(inboxDesc.getText());
        }
      }
      process.setProperty(addressListPropName, addressList);
      process.setProperty(positionListPropName, positionList);
      worker.getLogger().info("Selected status values have these positions: " + positionList);
      worker.getLogger().info("Got addresses from status values: " + addressList);

      return Condition.CONTINUE;
    } catch (IllegalArgumentException e) {
      throw new TaskFailedException(e);
    } catch (IllegalAccessException e) {
      throw new TaskFailedException(e);
    } catch (InvocationTargetException e) {
      throw new TaskFailedException(e);
    } catch (IntrospectionException e) {
      throw new TaskFailedException(e);
    } catch (IOException e) {
      throw new TaskFailedException(e);
    } catch (TerminologyException e) {
      throw new TaskFailedException(e);
    }
  }
  /**
   * @see org.dwfa.bpa.process.I_DefineTask#complete(org.dwfa.bpa.process.I_EncodeBusinessProcess,
   *     org.dwfa.bpa.process.I_Work)
   */
  public Condition evaluate(I_EncodeBusinessProcess process, final I_Work worker)
      throws TaskFailedException {
    try {

      I_HelpMemberRefsetsCalculateConflicts mrc =
          Terms.get().getMemberRefsetConflictCalculator(Terms.get().getActiveAceFrameConfig());
      mrc.setOutputDirectory(new File("."));
      mrc.setValidateOnly(true);
      mrc.run();

      I_ConfigAceFrame config =
          (I_ConfigAceFrame) worker.readAttachement(WorkerAttachmentKeys.ACE_FRAME_CONFIG.name());
      final JPanel signpostPanel = config.getSignpostPanel();
      final JPanel p = new JPanel();
      final JScrollPane jsp = new JScrollPane(p);
      final List<String> details = mrc.getConclictDetails();

      SwingUtilities.invokeAndWait(
          new Runnable() {

            public void run() {
              Component[] components = signpostPanel.getComponents();
              for (int i = 0; i < components.length; i++) {
                signpostPanel.remove(components[i]);
              }

              signpostPanel.setLayout(new GridBagLayout());

              p.setLayout(new GridBagLayout());
              p.setBackground(Color.WHITE);

              GridBagConstraints c = new GridBagConstraints();
              c.fill = GridBagConstraints.BOTH;
              c.gridx = 0;
              c.gridy = 0;
              c.gridheight = 5;
              c.weightx = 1.0;
              c.weighty = 1.0;
              c.anchor = GridBagConstraints.NORTHWEST;

              StringBuffer sb = new StringBuffer();
              sb.append("<html><body><tr><td>");
              int counter = 0;
              for (String conflict : details) {
                // Add to signpost
                if (counter == 0) {
                  sb.append("<h1>" + conflict + "</h1><ul>");
                } else {
                  sb.append("<li>" + conflict + "</li>");
                }

                counter++;
              }

              if (details.size() > 0) {
                sb.append("</ul>");
              }

              sb.append("</td></tr></body></html>");

              p.add(new JLabel(sb.toString()), c);
              signpostPanel.add(jsp, c);
              signpostPanel.validate();
              Container cont = signpostPanel;

              while (cont != null) {
                cont.validate();
                cont = cont.getParent();
              }
            }
          });

      if (mrc.hasConflicts()) {
        return Condition.TRUE;
      }
      return Condition.FALSE;
    } catch (InterruptedException e) {
      throw new TaskFailedException(e);
    } catch (InvocationTargetException e) {
      throw new TaskFailedException(e);
    } catch (Exception e) {
      throw new TaskFailedException(e);
    }
  } // End method evaluate