Source:
<code>public void runOperation(final VariableMap variableMap, IProgressMonitor monitor) { Displays.ensureInDisplayThread(new Runnable() { @Override public void run() { try { List<Artifact> artifacts = variableMap.getArtifacts(TEAM_WORKFLOW); boolean duplicateTasks = variableMap.getBoolean(DUPLICATE_TASKS); boolean createNewWorkflow = variableMap.getString(DUPLICATE_METHOD).equals(CREATE_NEW_WORFLOW_IN_START_STATE); boolean duplicateWorkflow = variableMap.getString(DUPLICATE_METHOD).equals(DUPLICATE_WORKFLOW); String title = variableMap.getString(TITLE); if (artifacts.isEmpty()) { AWorkbench.popup("ERROR", "Must drag in Team Workflow to duplicate."); return; } if (!createNewWorkflow && !duplicateWorkflow) { AWorkbench.popup("ERROR", "Please select \"Duplicate Method\"."); return; } if (duplicateTasks && createNewWorkflow) { AWorkbench.popup("ERROR", "Can not create workflow as new and duplicate tasks."); return; } Artifact artifact = artifacts.iterator().next(); if (!artifact.isOfType(AtsArtifactTypes.TeamWorkflow)) { AWorkbench.popup("ERROR", "Artifact MUST be Team Workflow"); return; } <START> try { <END> Collection<TeamWorkFlowArtifact> teamArts = Collections.castAll(artifacts); if (!teamArts.isEmpty()) { if (defaultTeamWorkflows == null) { setDefaultTeamWorkflows(teamArts); } } if (createNewWorkflow) { handleCreateNewWorkflow(teamArts, title); } else { handleCreateDuplicate(teamArts, duplicateTasks, title); } } catch (Exception ex) { log(ex); } finally { AtsUtilClient.setEmailEnabled(true); } } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } }; }); }</code><technical_language>want castAll. This operation is valid for Team Workflows. Loop isOfType</technical_language>

Target:
public void runOperation(final VariableMap variableMap, IProgressMonitor monitor) { Displays.ensureInDisplayThread(new Runnable() { @Override public void run() { try { List<Artifact> artifacts = variableMap.getArtifacts(TEAM_WORKFLOW); boolean duplicateTasks = variableMap.getBoolean(DUPLICATE_TASKS); boolean createNewWorkflow = variableMap.getString(DUPLICATE_METHOD).equals(CREATE_NEW_WORFLOW_IN_START_STATE); boolean duplicateWorkflow = variableMap.getString(DUPLICATE_METHOD).equals(DUPLICATE_WORKFLOW); String title = variableMap.getString(TITLE); if (artifacts.isEmpty()) { AWorkbench.popup("ERROR", "Must drag in Team Workflow to duplicate."); return; } if (!createNewWorkflow && !duplicateWorkflow) { AWorkbench.popup("ERROR", "Please select \"Duplicate Method\"."); return; } if (duplicateTasks && createNewWorkflow) { AWorkbench.popup("ERROR", "Can not create workflow as new and duplicate tasks."); return; } Artifact artifact = artifacts.iterator().next(); if (!artifact.isOfType(AtsArtifactTypes.TeamWorkflow)) { AWorkbench.popup("ERROR", "Artifact MUST be Team Workflow"); return; } try { Collection<TeamWorkFlowArtifact> teamArts = new ArrayList<TeamWorkFlowArtifact>(); for (Artifact art : artifacts) { if (art instanceof TeamWorkFlowArtifact) { teamArts.add((TeamWorkFlowArtifact) art); } } if (!teamArts.isEmpty()) { if (defaultTeamWorkflows == null) { setDefaultTeamWorkflows(teamArts); } } if (createNewWorkflow) { handleCreateNewWorkflow(teamArts, title); } else { handleCreateDuplicate(teamArts, duplicateTasks, title); } } catch (Exception ex) { log(ex); } finally { AtsUtilClient.setEmailEnabled(true); } } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } }; }); }