diff options
Diffstat (limited to 'plugins/org.eclipse.osee.ats.core')
5 files changed, 250 insertions, 6 deletions
diff --git a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF index 7f0e64bd0a1..c3b4b9659c7 100644 --- a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF @@ -44,6 +44,7 @@ Import-Package: com.google.inject, org.osgi.framework Bundle-Vendor: Eclipse Open System Engineering Environment Export-Package: org.eclipse.osee.ats.core, + org.eclipse.osee.ats.core.ai, org.eclipse.osee.ats.core.column, org.eclipse.osee.ats.core.config, org.eclipse.osee.ats.core.model, diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/ai/ModifyActionableItems.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/ai/ModifyActionableItems.java new file mode 100644 index 00000000000..64e7b6942bd --- /dev/null +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/ai/ModifyActionableItems.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.core.ai; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.eclipse.osee.ats.api.ai.IAtsActionableItem; +import org.eclipse.osee.ats.api.team.CreateTeamData; +import org.eclipse.osee.ats.api.team.CreateTeamOption; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.ats.api.user.IAtsUser; +import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow; +import org.eclipse.osee.ats.core.config.ITeamDefinitionUtility; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.util.Conditions; +import org.eclipse.osee.framework.core.util.XResultData; + +/** + * @author Donald G Dunne + */ +public class ModifyActionableItems { + + private final XResultData results; + private final IAtsTeamWorkflow teamWf; + private final Collection<IAtsActionableItem> currAIsForAllWfs; + private final Collection<IAtsActionableItem> currWorkflowDesiredAIs; + private final Collection<IAtsActionableItem> newAIs; + private final IAtsUser modifiedBy; + private final List<CreateTeamData> teamDatas = new ArrayList<CreateTeamData>(); + private final List<IAtsActionableItem> addAis = new ArrayList<IAtsActionableItem>(); + private final List<IAtsActionableItem> removeAis = new ArrayList<IAtsActionableItem>(); + private final Map<IAtsTeamDefinition, CreateTeamData> teamDefToTeamDataMap = + new HashMap<IAtsTeamDefinition, CreateTeamData>(); + private final ITeamDefinitionUtility teamDefUtil; + + public ModifyActionableItems(XResultData results, IAtsTeamWorkflow teamWf, Collection<IAtsActionableItem> currAIsForAllWfs, Collection<IAtsActionableItem> currWorkflowDesiredAIs, Collection<IAtsActionableItem> newAIs, IAtsUser modifiedBy, ITeamDefinitionUtility teamDefUtil) { + this.results = results; + this.teamWf = teamWf; + this.currAIsForAllWfs = currAIsForAllWfs; + this.currWorkflowDesiredAIs = currWorkflowDesiredAIs; + this.newAIs = newAIs; + this.modifiedBy = modifiedBy; + this.teamDefUtil = teamDefUtil; + } + + public void performModification() throws OseeCoreException { + Conditions.checkNotNull(results, "results"); + Conditions.checkNotNull(teamWf, "teamWf"); + Conditions.checkNotNull(modifiedBy, "modifiedBy"); + // Determine if changes to this workflow's actionable items + processAisAddedRemovedFromSelectedTeamWf(); + // Determine what workflows to add + processAisAddedForNewWorkflows(); + } + + private void processAisAddedForNewWorkflows() throws OseeCoreException { + Set<IAtsActionableItem> allAIsForNewWorkflow = new HashSet<IAtsActionableItem>(); + Set<IAtsActionableItem> duplicatedAIs = new HashSet<IAtsActionableItem>(); + // determine AIs that already have a team workflow associated + for (IAtsActionableItem checkAi : newAIs) { + if (!checkAi.isActionable()) { + results.logErrorWithFormat("Actionable Item [%s] is not actionable; select item lower in hierarchy", + checkAi); + } else { + if (currAIsForAllWfs.contains(checkAi)) { + duplicatedAIs.add(checkAi); + } + allAIsForNewWorkflow.add(checkAi); + } + } + Date createdDate = new Date(); + // process new and duplicated workflows + for (IAtsActionableItem ai : allAIsForNewWorkflow) { + IAtsTeamDefinition teamDef = getImpactedTeamDef(ai); + if (teamDefToTeamDataMap.containsKey(teamDef)) { + CreateTeamData createTeamData = teamDefToTeamDataMap.get(teamDef); + createTeamData.getActionableItems().add(ai); + } else { + CreateTeamData createTeamData = + new CreateTeamData(teamDef, Arrays.asList(ai), new LinkedList<IAtsUser>(teamDef.getLeads()), + createdDate, modifiedBy, CreateTeamOption.Duplicate_If_Exists); + teamDatas.add(createTeamData); + teamDefToTeamDataMap.put(teamDef, createTeamData); + } + } + // add messages to results + for (CreateTeamData data : teamDatas) { + results.log(String.format("Create New Team Workflow for Actionable Item(s) %s", data.getActionableItems())); + for (IAtsActionableItem ai : data.getActionableItems()) { + if (duplicatedAIs.contains(ai)) { + results.logWithFormat(" - Note: Actionable Item [%s] is impacted by an existing Team Workflow\n", ai); + } + } + } + } + + /** + * Return single Team Definition associated with this Actionable Item + */ + private IAtsTeamDefinition getImpactedTeamDef(IAtsActionableItem ai) throws OseeCoreException { + IAtsTeamDefinition teamDef = null; + Collection<IAtsTeamDefinition> impactedTeamDefs = teamDefUtil.getImpactedTeamDefs(Arrays.asList(ai)); + if (impactedTeamDefs.size() > 0) { + teamDef = impactedTeamDefs.iterator().next(); + } + return teamDef; + } + + private void processAisAddedRemovedFromSelectedTeamWf() throws OseeCoreException { + Set<IAtsActionableItem> currAIs = teamWf.getActionableItems(); + if (currWorkflowDesiredAIs.isEmpty()) { + results.logError("All AIs can not be removed from a Team Workflow; Cancel workflow instead"); + } else { + for (IAtsActionableItem checkedAi : currWorkflowDesiredAIs) { + if (!currAIs.contains(checkedAi)) { + results.logWithFormat("Add Actionable Item [%s] to the selected Team Workflow\n", checkedAi); + addAis.add(checkedAi); + } + } + for (IAtsActionableItem currAi : currAIs) { + if (!currWorkflowDesiredAIs.contains(currAi)) { + results.logWithFormat("Remove Actionable Item [%s] to the selected Team Workflow\n", currAi); + removeAis.add(currAi); + } + } + } + } + + public List<CreateTeamData> getTeamDatas() { + return teamDatas; + } + + public List<IAtsActionableItem> getAddAis() { + return addAis; + } + + public List<IAtsActionableItem> getRemoveAis() { + return removeAis; + } + +} diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/ActionableItems.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/ActionableItems.java index 80173b916fa..3ca7e87c67c 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/ActionableItems.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/ActionableItems.java @@ -129,18 +129,18 @@ public class ActionableItems { return Collections.castAll(getActive(getChildren(topAi, false), active)); } - public static List<IAtsActionableItem> getActive(Collection<IAtsActionableItem> teamDefs, Active active) { + public static List<IAtsActionableItem> getActive(Collection<IAtsActionableItem> ais, Active active) { List<IAtsActionableItem> results = new ArrayList<IAtsActionableItem>(); - for (IAtsActionableItem aia : teamDefs) { + for (IAtsActionableItem ai : ais) { if (active == Active.Both) { - results.add(aia); + results.add(ai); } else { // assume active unless otherwise specified - boolean attributeActive = aia.isActive(); + boolean attributeActive = ai.isActive(); if (active == Active.Active && attributeActive) { - results.add(aia); + results.add(ai); } else if (active == Active.InActive && !attributeActive) { - results.add(aia); + results.add(ai); } } } @@ -158,4 +158,37 @@ public class ActionableItems { return children; } + /** + * Return all active actionable items that this team is responsible for + */ + public static List<IAtsActionableItem> getActiveForTeam(IAtsTeamDefinition teamDef, Active active) { + List<IAtsActionableItem> results = new ArrayList<IAtsActionableItem>(); + for (IAtsActionableItem ai : teamDef.getActionableItems()) { + getActiveForTeam(teamDef, active, results, ai); + for (IAtsActionableItem childAi : ai.getChildrenActionableItems()) { + getActiveForTeam(teamDef, active, results, childAi); + } + } + return results; + } + + /** + * Add ai to results if owned by teamDef an matches active status + */ + private static void getActiveForTeam(IAtsTeamDefinition teamDef, Active active, List<IAtsActionableItem> results, IAtsActionableItem ai) { + if (ai.getTeamDefinition() == null || ai.getTeamDefinition().equals(teamDef)) { + if (active == Active.Both) { + results.add(ai); + } else { + // assume active unless otherwise specified + boolean attributeActive = ai.isActive(); + if (active == Active.Active && attributeActive) { + results.add(ai); + } else if (active == Active.InActive && !attributeActive) { + results.add(ai); + } + } + } + } + } diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/ITeamDefinitionUtility.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/ITeamDefinitionUtility.java new file mode 100644 index 00000000000..2d5e349ca39 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/ITeamDefinitionUtility.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.core.config; + +import java.util.Collection; +import org.eclipse.osee.ats.api.ai.IAtsActionableItem; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.framework.core.exception.OseeCoreException; + +/** + * @author Donald G Dunne + */ +public interface ITeamDefinitionUtility { + + public Collection<IAtsTeamDefinition> getImpactedTeamDefs(Collection<IAtsActionableItem> aias) throws OseeCoreException; + +} diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/TeamDefinitionUtility.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/TeamDefinitionUtility.java new file mode 100644 index 00000000000..9b2a5ec3a10 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/TeamDefinitionUtility.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2013 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ats.core.config; + +import java.util.Collection; +import org.eclipse.osee.ats.api.ai.IAtsActionableItem; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.framework.core.exception.OseeCoreException; + +/** + * @author Donald G Dunne + */ +public class TeamDefinitionUtility implements ITeamDefinitionUtility { + + @Override + public Collection<IAtsTeamDefinition> getImpactedTeamDefs(Collection<IAtsActionableItem> aias) throws OseeCoreException { + return TeamDefinitions.getImpactedTeamDefs(aias); + } + +} |