diff options
author | donald.g.dunne | 2016-08-03 21:03:14 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2016-08-31 16:18:11 +0000 |
commit | 44c7e9d6ec5adfa5bf56db55aee76503085de2eb (patch) | |
tree | 2e130be971223d38c36a0b18897a3ac46c22675a | |
parent | 73ddfa25082eb7c2bcea3496cd5526cfebbcc11d (diff) | |
download | org.eclipse.osee-44c7e9d6ec5adfa5bf56db55aee76503085de2eb.tar.gz org.eclipse.osee-44c7e9d6ec5adfa5bf56db55aee76503085de2eb.tar.xz org.eclipse.osee-44c7e9d6ec5adfa5bf56db55aee76503085de2eb.zip |
feature[ats_ATS305921]: Update Tasks and Action import spreadsheets
Change-Id: I64212a4204a30cad99b9f5c8dea3c09bc0638f31
13 files changed, 308 insertions, 86 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsTest_Util_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsTest_Util_Suite.java index 949b756eb93..a63af62b93a 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsTest_Util_Suite.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsTest_Util_Suite.java @@ -26,7 +26,8 @@ import org.junit.runners.Suite; AtsImageTest.class, AtsXWidgetsExampleBlamTest.class, CreateActionUsingAllActionableItemsTest.class, - ImportActionsViaSpreadsheetTest.class}) + ImportActionsViaSpreadsheetTest.class, + ImportTasksFromSpreadsheetTest.class}) /** * @author Donald G. Dunne */ diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/ImportTasksFromSpreadsheetTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/ImportTasksFromSpreadsheetTest.java new file mode 100644 index 00000000000..7907797ebc0 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/ImportTasksFromSpreadsheetTest.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2016 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.client.integration.tests.ats.util; + +import java.io.File; +import java.util.Collection; +import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +import org.eclipse.osee.ats.api.user.IAtsUser; +import org.eclipse.osee.ats.api.workdef.IAttributeResolver; +import org.eclipse.osee.ats.api.workflow.IAtsTask; +import org.eclipse.osee.ats.client.integration.tests.AtsClientService; +import org.eclipse.osee.ats.client.integration.tests.ats.core.client.AtsTestUtil; +import org.eclipse.osee.ats.core.users.AtsCoreUsers; +import org.eclipse.osee.ats.demo.api.DemoUsers; +import org.eclipse.osee.ats.util.Import.ImportTasksFromSpreadsheet; +import org.eclipse.osee.framework.plugin.core.PluginUtil; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test Case for {@link ImportTasksFromSpreadsheet} + * + * @author Donald G. Dunne + */ +public class ImportTasksFromSpreadsheetTest { + + @After + public void cleanup() { + AtsTestUtil.cleanup(); + } + + @Test + public void testPerformImport() throws Exception { + AtsTestUtil.cleanupAndReset(getClass().getSimpleName()); + ImportTasksFromSpreadsheet importTasks = new ImportTasksFromSpreadsheet(); + + PluginUtil util = new PluginUtil("org.eclipse.osee.ats"); + File file = util.copyPluginFileToOseeData("support/Task Import.xml", "Task Import.xml"); + importTasks.performImport(false, AtsTestUtil.getTeamWf(), file); + + Collection<IAtsTask> tasks = AtsClientService.get().getTaskService().getTasks(AtsTestUtil.getTeamWf()); + Assert.assertEquals(3, tasks.size()); + IAttributeResolver attrs = AtsClientService.get().getAttributeResolver(); + for (IAtsTask task : tasks) { + if (task.getName().equals("2nd Task")) { + Assert.assertEquals("Category", attrs.getSoleAttributeValue(task, AtsAttributeTypes.Category1, "")); + Assert.assertEquals("Waiting", attrs.getSoleAttributeValue(task, AtsAttributeTypes.Resolution, "")); + Assert.assertEquals("Implement", attrs.getSoleAttributeValue(task, AtsAttributeTypes.RelatedToState, "")); + Assert.assertEquals(3.0, attrs.getSoleAttributeValue(task, AtsAttributeTypes.EstimatedHours, 0.0), 0.01); + Assert.assertEquals(DemoUsers.Joe_Smith.getUserId(), task.getCreatedBy().getUserId()); + Assert.assertEquals(1, task.getAssignees().size()); + Assert.assertEquals(AtsCoreUsers.UNASSIGNED_USER.getUserId(), + task.getAssignees().iterator().next().getUserId()); + } else if (task.getName().equals("3rd Task")) { + Assert.assertEquals(DemoUsers.Kay_Jones.getUserId(), task.getCreatedBy().getUserId()); + Assert.assertEquals(2, task.getAssignees().size()); + for (IAtsUser assignee : task.getAssignees()) { + Assert.assertTrue(assignee.getUserId().equals( + DemoUsers.Joe_Smith.getUserId()) || assignee.getUserId().equals(DemoUsers.Kay_Jones.getUserId())); + } + Assert.assertEquals("", attrs.getSoleAttributeValue(task, AtsAttributeTypes.Category1, "")); + } + } + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/CreateTasksOperation.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/CreateTasksOperation.java index 408eb4f2da4..47158ff8fde 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/CreateTasksOperation.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/CreateTasksOperation.java @@ -282,7 +282,8 @@ public class CreateTasksOperation { if (Strings.isValid(jaxTask.getDescription())) { changes.setSoleAttributeValue(task, AtsAttributeTypes.Description, jaxTask.getDescription()); } - atsServer.getActionFactory().initializeNewStateMachine(task, assignees, createdByDate, asUser, + IAtsUser createdBy = atsServer.getUserService().getUserById(jaxTask.getCreatedByUserId()); + atsServer.getActionFactory().initializeNewStateMachine(task, assignees, createdByDate, createdBy, workDefinition, changes); // Set parent state task is related to if set diff --git a/plugins/org.eclipse.osee.ats/plugin.xml b/plugins/org.eclipse.osee.ats/plugin.xml index 7c465548ad4..c096ed59ea4 100644 --- a/plugins/org.eclipse.osee.ats/plugin.xml +++ b/plugins/org.eclipse.osee.ats/plugin.xml @@ -198,7 +198,7 @@ name="ImportTasksFromSpreadsheet" point="org.eclipse.osee.framework.ui.skynet.BlamOperation"> <Operation - className="org.eclipse.osee.ats.operation.ImportTasksFromSpreadsheet"> + className="org.eclipse.osee.ats.util.Import.ImportTasksFromSpreadsheet"> </Operation> </extension> <extension @@ -206,7 +206,7 @@ name="ImportTasksFromSimpleList" point="org.eclipse.osee.framework.ui.skynet.BlamOperation"> <Operation - className="org.eclipse.osee.ats.operation.ImportTasksFromSimpleList"> + className="org.eclipse.osee.ats.util.Import.ImportTasksFromSimpleList"> </Operation> </extension> <extension diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/ImportTasksViaSimpleList.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/ImportTasksViaSimpleList.java index 7689318d2f8..fa08da25bb5 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/ImportTasksViaSimpleList.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/ImportTasksViaSimpleList.java @@ -11,7 +11,7 @@ package org.eclipse.osee.ats.actions; import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact; -import org.eclipse.osee.ats.operation.ImportTasksFromSimpleList; +import org.eclipse.osee.ats.util.Import.ImportTasksFromSimpleList; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.blam.BlamEditor; import org.eclipse.osee.framework.ui.swt.ImageManager; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/ImportTasksViaSpreadsheet.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/ImportTasksViaSpreadsheet.java index e10b814aa5e..0b2522f550e 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/ImportTasksViaSpreadsheet.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/ImportTasksViaSpreadsheet.java @@ -11,7 +11,7 @@ package org.eclipse.osee.ats.actions; import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact; -import org.eclipse.osee.ats.operation.ImportTasksFromSpreadsheet; +import org.eclipse.osee.ats.util.Import.ImportTasksFromSpreadsheet; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.blam.BlamEditor; import org.eclipse.osee.framework.ui.swt.ImageManager; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ExcelAtsActionArtifactExtractor.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ExcelAtsActionArtifactExtractor.java index 56261405b12..8b3904b062b 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ExcelAtsActionArtifactExtractor.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ExcelAtsActionArtifactExtractor.java @@ -31,6 +31,7 @@ import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; import org.eclipse.osee.ats.api.notify.AtsNotificationEventFactory; import org.eclipse.osee.ats.api.notify.AtsNotifyType; +import org.eclipse.osee.ats.api.task.JaxAttribute; import org.eclipse.osee.ats.api.team.ChangeType; import org.eclipse.osee.ats.api.team.CreateTeamOption; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; @@ -47,7 +48,9 @@ import org.eclipse.osee.ats.core.config.TeamDefinitions; import org.eclipse.osee.ats.core.util.AtsUtilCore; import org.eclipse.osee.ats.internal.Activator; import org.eclipse.osee.ats.internal.AtsClientService; +import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.exception.UserNotInDatabase; +import org.eclipse.osee.framework.core.model.type.AttributeType; import org.eclipse.osee.framework.core.util.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -57,7 +60,9 @@ import org.eclipse.osee.framework.jdk.core.util.io.xml.RowProcessor; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; +import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI; import org.xml.sax.InputSource; @@ -102,8 +107,7 @@ public class ExcelAtsActionArtifactExtractor { Collection<IAtsActionableItem> aias = new ArrayList<>(); for (Artifact aiaArt : ArtifactQuery.getArtifactListFromTypeAndName(AtsArtifactTypes.ActionableItem, actionableItemName, AtsUtilCore.getAtsBranch())) { - IAtsActionableItem ai = - AtsClientService.get().getCache().getByUuid(aiaArt.getUuid(), IAtsActionableItem.class); + IAtsActionableItem ai = AtsClientService.get().getConfigItemFactory().getActionableItem(aiaArt); if (ai != null) { aias.add(ai); } @@ -187,8 +191,16 @@ public class ExcelAtsActionArtifactExtractor { actionNameToAction.put(aData.title, actionArt); actionArts.add(actionArt); } else { - Set<IAtsActionableItem> aias = - ActionableItems.getActionableItems(aData.actionableItems, AtsClientService.get()); + Set<IAtsActionableItem> aias = new HashSet<>(); + for (String actionableItemName : aData.actionableItems) { + for (Artifact aiaArt : ArtifactQuery.getArtifactListFromTypeAndName(AtsArtifactTypes.ActionableItem, + actionableItemName, AtsUtilCore.getAtsBranch())) { + IAtsActionableItem ai = AtsClientService.get().getConfigItemFactory().getActionableItem(aiaArt); + if (ai != null) { + aias.add(ai); + } + } + } Map<IAtsTeamDefinition, Collection<IAtsActionableItem>> teamDefToAias = getTeamDefToAias(aias); for (Entry<IAtsTeamDefinition, Collection<IAtsActionableItem>> entry : teamDefToAias.entrySet()) { @@ -200,6 +212,11 @@ public class ExcelAtsActionArtifactExtractor { teamWorkflow.setSoleAttributeValue(AtsAttributeTypes.PriorityType, aData.priorityStr); } teamWorkflow.setSoleAttributeValue(AtsAttributeTypes.ChangeType, aData.changeType); + + for (JaxAttribute attr : aData.attributes) { + IAttributeType attrType = AttributeTypeManager.getType(attr.getAttrTypeName()); + teamWorkflow.setAttributeValues(attrType, attr.getValues()); + } newTeamArts.add(teamWorkflow); addToGoal(Collections.singleton(teamWorkflow), changes); } @@ -302,9 +319,6 @@ public class ExcelAtsActionArtifactExtractor { return "Extract each row as an Action"; } - /** - * @return the actionArts - */ public Set<Artifact> getActionArts() { return actionArts; } @@ -323,6 +337,7 @@ public class ExcelAtsActionArtifactExtractor { protected Set<String> actionableItems = new HashSet<>(); protected String version = ""; protected Double estimatedHours = null; + protected List<JaxAttribute> attributes = new LinkedList<>(); } private final static class InternalRowProcessor implements RowProcessor { @@ -397,30 +412,52 @@ public class ExcelAtsActionArtifactExtractor { ActionData aData = new ActionData(); for (int i = 0; i < cols.length; i++) { - if (headerRow[i] != null) { - if (headerRow[i].equalsIgnoreCase(Columns.Title.name())) { + String header = headerRow[i]; + if (header != null) { + if (header.equalsIgnoreCase(Columns.Title.name())) { if (cols[i].equals("")) { return; } aData.title = cols[i]; - } else if (headerRow[i].equalsIgnoreCase(Columns.Priority.name())) { + } else if (header.equalsIgnoreCase(Columns.Priority.name())) { aData.priorityStr = cols[i]; - } else if (headerRow[i].equalsIgnoreCase(Columns.Version.name())) { + } else if (header.equalsIgnoreCase(Columns.Version.name())) { aData.version = cols[i] == null ? "" : cols[i]; - } else if (headerRow[i].equalsIgnoreCase(Columns.ChangeType.name())) { + } else if (header.equalsIgnoreCase(Columns.ChangeType.name())) { aData.changeType = cols[i]; - } else if (headerRow[i].equalsIgnoreCase(Columns.Description.name())) { + } else if (header.equalsIgnoreCase(Columns.Description.name())) { aData.desc = cols[i] == null ? "" : cols[i]; - } else if (headerRow[i].equalsIgnoreCase(Columns.EstimatedHours.name())) { + } else if (header.equalsIgnoreCase(Columns.EstimatedHours.name())) { if (Strings.isValid(cols[i])) { aData.estimatedHours = new Double(cols[i]); } - } else if (headerRow[i].equalsIgnoreCase(Columns.ActionableItems.name())) { + } else if (header.equalsIgnoreCase(Columns.ActionableItems.name())) { processActionableItems(cols, aData, i); - } else if (headerRow[i].equalsIgnoreCase(Columns.Assignees.name())) { + } else if (header.equalsIgnoreCase(Columns.Assignees.name())) { processAssignees(cols, aData, i); } else { - resultData.error("Unhandled column => " + headerRow[i]); + String attrTypeName = header; + if (Strings.isValid(attrTypeName)) { + AttributeType attributeType = AttributeTypeManager.getType(attrTypeName); + if (attributeType == null) { + OseeLog.log(Activator.class, Level.SEVERE, "Invalid Attribute Type Name => " + header); + } else { + if (!ArtifactTypeManager.getArtifactTypesFromAttributeType(attributeType, + AtsUtilCore.getAtsBranch()).contains(AtsArtifactTypes.Task)) { + OseeLog.log(Activator.class, Level.SEVERE, "Invalid Attribute Type for Task => " + header); + } else { + String value = cols[i]; + if (Strings.isValid(value)) { + JaxAttribute attr = new JaxAttribute(); + attr.setAttrTypeName(attrTypeName); + attr.getValues().add(value); + aData.attributes.add(attr); + } + } + } + } else { + OseeLog.log(Activator.class, Level.SEVERE, "Unhandled column => " + header); + } } } } diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ExcelAtsTaskArtifactExtractor.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ExcelAtsTaskArtifactExtractor.java index 7c7d3cf600b..a92423b04e7 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ExcelAtsTaskArtifactExtractor.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ExcelAtsTaskArtifactExtractor.java @@ -17,6 +17,7 @@ import java.util.Date; import java.util.logging.Level; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; import org.eclipse.osee.ats.api.task.JaxAtsTask; import org.eclipse.osee.ats.api.task.JaxAtsTaskFactory; @@ -24,14 +25,19 @@ import org.eclipse.osee.ats.api.task.NewTaskData; import org.eclipse.osee.ats.api.user.IAtsUser; import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact; import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact; +import org.eclipse.osee.ats.core.util.AtsUtilCore; import org.eclipse.osee.ats.internal.Activator; import org.eclipse.osee.ats.internal.AtsClientService; +import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist; +import org.eclipse.osee.framework.core.model.type.AttributeType; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelSaxHandler; import org.eclipse.osee.framework.jdk.core.util.io.xml.RowProcessor; import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; +import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; @@ -139,28 +145,49 @@ public class ExcelAtsTaskArtifactExtractor { return; } for (int i = 0; i < row.length; i++) { - if (headerRow[i] == null) { + String header = headerRow[i]; + if (header == null) { OseeLog.log(Activator.class, Level.SEVERE, "Null header column => " + i); - } else if (headerRow[i].equalsIgnoreCase("Assignees")) { + } else if (header.equalsIgnoreCase("Assignees")) { processAssignees(row, task, i); - } else if (headerRow[i].equalsIgnoreCase("Resolution")) { + } else if (header.equalsIgnoreCase("Resolution")) { processResolution(row, task, i); - } else if (headerRow[i].equalsIgnoreCase("Description")) { + } else if (header.equalsIgnoreCase("Created By")) { + processCreatedBy(row, task, i); + } else if (header.equalsIgnoreCase("Description")) { processDescription(row, task, i); - } else if (headerRow[i].equalsIgnoreCase("Related to State")) { + } else if (header.equalsIgnoreCase("Related to State")) { processRelatedToState(row, task, i); - } else if (headerRow[i].equalsIgnoreCase("Notes")) { + } else if (header.equalsIgnoreCase("Notes")) { processNotes(row, task, i); - } else if (headerRow[i].equalsIgnoreCase("Title")) { + } else if (header.equalsIgnoreCase("Title")) { processTitle(row, task, i); - } else if (headerRow[i].equalsIgnoreCase("Percent Complete")) { + } else if (header.equalsIgnoreCase("Percent Complete")) { processPercentComplete(row, i); - } else if (headerRow[i].equalsIgnoreCase("Hours Spent")) { + } else if (header.equalsIgnoreCase("Hours Spent")) { processHoursSpent(row, i); - } else if (headerRow[i].equalsIgnoreCase("Estimated Hours")) { + } else if (header.equalsIgnoreCase("Estimated Hours")) { processEstimatedHours(row, task, i); } else { - OseeLog.log(Activator.class, Level.SEVERE, "Unhandled column => " + headerRow[i]); + String attrTypeName = header; + if (Strings.isValid(attrTypeName)) { + AttributeType attributeType = AttributeTypeManager.getType(attrTypeName); + if (attributeType == null) { + OseeLog.log(Activator.class, Level.SEVERE, "Invalid Attribute Type Name => " + header); + } else { + if (!ArtifactTypeManager.getArtifactTypesFromAttributeType(attributeType, + AtsUtilCore.getAtsBranch()).contains(AtsArtifactTypes.Task)) { + OseeLog.log(Activator.class, Level.SEVERE, "Invalid Attribute Type for Task => " + header); + } else { + String value = row[i]; + if (Strings.isValid(value)) { + task.addAttribute(attributeType, value); + } + } + } + } else { + OseeLog.log(Activator.class, Level.SEVERE, "Unhandled column => " + header); + } } } } @@ -215,6 +242,31 @@ public class ExcelAtsTaskArtifactExtractor { } } + private void processCreatedBy(String[] row, JaxAtsTask taskArt, int i) throws OseeCoreException { + String str = row[i]; + if (Strings.isValid(str)) { + IAtsUser user = null; + try { + user = AtsClientService.get().getUserService().getUserById(str); + } catch (ArtifactDoesNotExist ex) { + // do nothing + } + if (user == null) { + try { + user = AtsClientService.get().getUserService().getUserByName(str); + } catch (ArtifactDoesNotExist ex) { + // do nothing + } + } + if (user != null) { + taskArt.setCreatedByUserId(user.getUserId()); + } else { + throw new OseeArgumentException("Invalid Created By \"%s\" for row %d. Use OSEE user name or id.", str, + rowNum); + } + } + } + private void processEstimatedHours(String[] row, JaxAtsTask taskArt, int i) throws OseeArgumentException, OseeCoreException { String str = row[i]; double hours = 0; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ImportActionsViaSpreadsheetBlam.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ImportActionsViaSpreadsheetBlam.java index d5bbcb7ea68..d04777d16d9 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ImportActionsViaSpreadsheetBlam.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ImportActionsViaSpreadsheetBlam.java @@ -139,7 +139,11 @@ public class ImportActionsViaSpreadsheetBlam extends AbstractBlam { @Override public String getDescriptionUsage() { - return "Import Actions via Excel Spreadsheet.\n Open example spreadsheet, save to desktop and edit as desired. Once completed, select file from this BLAM and Run."; + return "Import Actions via Excel Spreadsheet.\n Open example spreadsheet, " // + + "save to desktop and edit as desired. Once completed, select file from " // + + "this BLAM and Run. Titles that are the same are placed under the same action." // + + " After \"Estimated Hours\", remaining columns will attempt to match " // + + "column name with valid attribute type name add that to Task."; } @Override diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ImportTasksFromSimpleList.java index 783cabe3158..1b810806623 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ImportTasksFromSimpleList.java @@ -8,7 +8,7 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.ats.operation; +package org.eclipse.osee.ats.util.Import; import java.util.ArrayList; import java.util.Arrays; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSpreadsheet.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ImportTasksFromSpreadsheet.java index febbca394ce..5753384a54a 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSpreadsheet.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/Import/ImportTasksFromSpreadsheet.java @@ -8,7 +8,7 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.ats.operation; +package org.eclipse.osee.ats.util.Import; import java.io.File; import java.util.Arrays; @@ -20,24 +20,27 @@ import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.task.NewTaskData; import org.eclipse.osee.ats.api.task.NewTaskDataFactory; import org.eclipse.osee.ats.api.task.NewTaskDatas; +import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow; import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact; import org.eclipse.osee.ats.core.client.util.AtsUtilClient; import org.eclipse.osee.ats.editor.WorkflowEditor; +import org.eclipse.osee.ats.internal.Activator; import org.eclipse.osee.ats.internal.AtsClientService; -import org.eclipse.osee.ats.util.Import.ExcelAtsTaskArtifactExtractor; -import org.eclipse.osee.ats.util.Import.TaskImportJob; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.plugin.core.PluginUtil; import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; +import org.eclipse.osee.framework.ui.skynet.widgets.XButtonPush; import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewer; import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener; import org.eclipse.osee.framework.ui.skynet.widgets.XWidget; import org.eclipse.osee.framework.ui.skynet.widgets.util.SwtXWidgetRenderer; import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.swt.program.Program; import org.eclipse.ui.forms.widgets.FormToolkit; /** @@ -45,6 +48,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit; */ public class ImportTasksFromSpreadsheet extends AbstractBlam { + private static final String OPEN_EXCEL_IMPORT_EXAMPLE_SPREADSHEET = "Open Excel Import Example Spreadsheet"; public final static String TASK_IMPORT_SPREADSHEET = "Task Import Spreadsheet"; public final static String TEAM_WORKFLOW = "Taskable Workflow (drop here)"; public final static String EMAIL_POCS = "Email POCs"; @@ -62,11 +66,33 @@ public class ImportTasksFromSpreadsheet extends AbstractBlam { XListDropViewer viewer = (XListDropViewer) xWidget; viewer.setInput(Arrays.asList(taskableStateMachineArtifact)); } + if (xWidget.getLabel().equals(OPEN_EXCEL_IMPORT_EXAMPLE_SPREADSHEET)) { + XButtonPush button = (XButtonPush) xWidget; + button.addXModifiedListener(new XModifiedListener() { + + @Override + public void widgetModified(XWidget widget) { + try { + File file = getSampleSpreadsheetFile(); + Program.launch(file.getCanonicalPath()); + } catch (Exception ex) { + log(ex); + } + } + }); + } + } + + public File getSampleSpreadsheetFile() throws Exception { + PluginUtil util = new PluginUtil(Activator.PLUGIN_ID); + return util.getPluginFile("support/Task Import.xml"); } @Override public String getXWidgetsXml() { StringBuffer buffer = new StringBuffer("<xWidgets>"); + buffer.append( + "<XWidget xwidgetType=\"XButtonPush\" displayName=\"Open Excel Import Example Spreadsheet\" displayLabel=\"false\"/>"); buffer.append("<XWidget xwidgetType=\"XListDropViewer\" displayName=\"" + TEAM_WORKFLOW + "\" />"); buffer.append("<XWidget xwidgetType=\"XFileSelectionDialog\" displayName=\"" + TASK_IMPORT_SPREADSHEET + "\" />"); buffer.append( @@ -77,7 +103,9 @@ public class ImportTasksFromSpreadsheet extends AbstractBlam { @Override public String getDescriptionUsage() { - return "Import tasks from spreadsheet into given Team Workflow"; + return "Import tasks from spreadsheet into given Team Workflow. " // + + "After \"Notes\" column, remaining columns will attempt to match " // + + "column name with valid attribute type name add that to workflow."; } public void setTaskableStateMachineArtifact(TeamWorkFlowArtifact taskableStateMachineArtifact) { @@ -112,32 +140,37 @@ public class ImportTasksFromSpreadsheet extends AbstractBlam { return; } File file = new File(filename); - try { - - AtsUtilClient.setEmailEnabled(emailPocs); - NewTaskData newTaskData = NewTaskDataFactory.get("Import Tasks from Spreadsheet", - AtsClientService.get().getUserService().getCurrentUser(), (TeamWorkFlowArtifact) artifact); - - Job job = Jobs.startJob(new TaskImportJob(file, - new ExcelAtsTaskArtifactExtractor((TeamWorkFlowArtifact) artifact, newTaskData))); - job.join(); - - AtsClientService.get().getTaskService().createTasks(new NewTaskDatas(newTaskData)); - } catch (Exception ex) { - log(ex); - return; - } finally { - AtsUtilClient.setEmailEnabled(true); - } + performImport(emailPocs, (TeamWorkFlowArtifact) artifact, file); WorkflowEditor.editArtifact(artifact); } catch (Exception ex) { log(ex); } - }; + } + }); } + public void performImport(boolean emailPocs, IAtsTeamWorkflow teamWf, File file) { + try { + + AtsUtilClient.setEmailEnabled(emailPocs); + NewTaskData newTaskData = NewTaskDataFactory.get("Import Tasks from Spreadsheet", + AtsClientService.get().getUserService().getCurrentUser(), teamWf); + + Job job = Jobs.startJob(new TaskImportJob(file, + new ExcelAtsTaskArtifactExtractor((TeamWorkFlowArtifact) teamWf.getStoreObject(), newTaskData))); + job.join(); + + AtsClientService.get().getTaskService().createTasks(new NewTaskDatas(newTaskData)); + } catch (Exception ex) { + log(ex); + return; + } finally { + AtsUtilClient.setEmailEnabled(true); + } + } + @Override public Collection<String> getCategories() { return Arrays.asList("ATS"); diff --git a/plugins/org.eclipse.osee.ats/support/Action Import.xml b/plugins/org.eclipse.osee.ats/support/Action Import.xml index 324953d53f5..7960f58113a 100644 --- a/plugins/org.eclipse.osee.ats/support/Action Import.xml +++ b/plugins/org.eclipse.osee.ats/support/Action Import.xml @@ -6,14 +6,16 @@ xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> - <Version>11.9999</Version> + <Version>15.00</Version> </DocumentProperties> + <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> + <AllowPNG/> + </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> - <WindowHeight>9300</WindowHeight> - <WindowWidth>15135</WindowWidth> - <WindowTopX>120</WindowTopX> - <WindowTopY>120</WindowTopY> - <AcceptLabelsInFormulas/> + <WindowHeight>11655</WindowHeight> + <WindowWidth>15360</WindowWidth> + <WindowTopX>0</WindowTopX> + <WindowTopY>0</WindowTopY> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> @@ -21,18 +23,19 @@ <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Bottom"/> <Borders/> - <Font/> + <Font ss:FontName="Arial"/> <Interior/> <NumberFormat/> <Protection/> </Style> </Styles> <Worksheet ss:Name="Sheet1"> - <Table ss:ExpandedColumnCount="8" ss:ExpandedRowCount="6" x:FullColumns="1" + <Table ss:ExpandedColumnCount="9" ss:ExpandedRowCount="6" x:FullColumns="1" x:FullRows="1"> <Column ss:AutoFitWidth="0" ss:Width="117"/> - <Column ss:AutoFitWidth="0" ss:Width="171.75" ss:Span="1"/> - <Column ss:Index="4" ss:AutoFitWidth="0" ss:Width="113.25"/> + <Column ss:AutoFitWidth="0" ss:Width="171.75"/> + <Column ss:Width="75.75"/> + <Column ss:AutoFitWidth="0" ss:Width="124.5"/> <Column ss:Width="60"/> <Column ss:Index="7" ss:AutoFitWidth="0" ss:Width="78.75"/> <Row> @@ -44,6 +47,7 @@ <Cell><Data ss:Type="String">Priority</Data></Cell> <Cell><Data ss:Type="String">Version</Data></Cell> <Cell><Data ss:Type="String">EstimatedHours</Data></Cell> + <Cell><Data ss:Type="String">ats.Category</Data></Cell> </Row> <Row> <Cell><Data ss:Type="String">Fix the SAW Editor</Data></Cell> @@ -74,6 +78,7 @@ <Cell><Data ss:Type="Number">5</Data></Cell> <Cell><Data ss:Type="String">SAW_Bld_3</Data></Cell> <Cell><Data ss:Type="Number">4</Data></Cell> + <Cell><Data ss:Type="String">Category</Data></Cell> </Row> <Row> <Cell><Data ss:Type="String">Add the new feature</Data></Cell> @@ -87,7 +92,7 @@ <Cell><Data ss:Type="String">Help the users</Data></Cell> <Cell><Data ss:Type="String">Support what they need</Data></Cell> <Cell><Data ss:Type="String">Timesheet</Data></Cell> - <Cell><Data ss:Type="String">Joe Smith</Data></Cell> + <Cell><Data ss:Type="String">Joe Smith; Kay Jones</Data></Cell> <Cell><Data ss:Type="String">Support</Data></Cell> <Cell><Data ss:Type="Number">1</Data></Cell> <Cell ss:Index="8"><Data ss:Type="Number">2</Data></Cell> @@ -95,11 +100,12 @@ </Table> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <Selected/> + <LeftColumnVisible>1</LeftColumnVisible> <Panes> <Pane> <Number>3</Number> - <ActiveRow>1</ActiveRow> - <ActiveCol>5</ActiveCol> + <ActiveRow>5</ActiveRow> + <ActiveCol>3</ActiveCol> </Pane> </Panes> <ProtectObjects>False</ProtectObjects> @@ -107,12 +113,18 @@ </WorksheetOptions> </Worksheet> <Worksheet ss:Name="Sheet2"> + <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" + x:FullRows="1"> + </Table> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <ProtectObjects>False</ProtectObjects> <ProtectScenarios>False</ProtectScenarios> </WorksheetOptions> </Worksheet> <Worksheet ss:Name="Sheet3"> + <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" + x:FullRows="1"> + </Table> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <ProtectObjects>False</ProtectObjects> <ProtectScenarios>False</ProtectScenarios> diff --git a/plugins/org.eclipse.osee.ats/support/Task Import.xml b/plugins/org.eclipse.osee.ats/support/Task Import.xml index e67278495f8..02d074120e4 100644 --- a/plugins/org.eclipse.osee.ats/support/Task Import.xml +++ b/plugins/org.eclipse.osee.ats/support/Task Import.xml @@ -9,17 +9,16 @@ <LastAuthor>Donald G. Dunne</LastAuthor> <Created>1996-10-14T23:33:28Z</Created> <LastSaved>2008-05-27T21:06:21Z</LastSaved> - <Version>11.9999</Version> + <Version>15.00</Version> </DocumentProperties> <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> <DoNotRelyOnCSS/> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> - <WindowHeight>9300</WindowHeight> - <WindowWidth>15135</WindowWidth> - <WindowTopX>120</WindowTopX> - <WindowTopY>120</WindowTopY> - <AcceptLabelsInFormulas/> + <WindowHeight>11655</WindowHeight> + <WindowWidth>21225</WindowWidth> + <WindowTopX>0</WindowTopX> + <WindowTopY>0</WindowTopY> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> @@ -27,14 +26,14 @@ <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Bottom"/> <Borders/> - <Font/> + <Font ss:FontName="Arial"/> <Interior/> <NumberFormat/> <Protection/> </Style> </Styles> <Worksheet ss:Name="Sheet1"> - <Table ss:ExpandedColumnCount="9" ss:ExpandedRowCount="4" x:FullColumns="1" + <Table ss:ExpandedColumnCount="10" ss:ExpandedRowCount="4" x:FullColumns="1" x:FullRows="1"> <Column ss:Width="78"/> <Column ss:Width="102"/> @@ -42,7 +41,7 @@ <Column ss:AutoFitWidth="0" ss:Width="83.25" ss:Span="1"/> <Row> <Cell><Data ss:Type="String">Title</Data></Cell> - <Cell><Data ss:Type="String">Originator</Data></Cell> + <Cell><Data ss:Type="String">Created By</Data></Cell> <Cell><Data ss:Type="String">Assignees</Data></Cell> <Cell><Data ss:Type="String">Resolution</Data></Cell> <Cell><Data ss:Type="String">Related to State</Data></Cell> @@ -50,11 +49,12 @@ <Cell><Data ss:Type="String">Estimated Hours</Data></Cell> <Cell><Data ss:Type="String">Percent Complete</Data></Cell> <Cell><Data ss:Type="String">Notes</Data></Cell> + <Cell><Data ss:Type="String">ats.Category</Data></Cell> </Row> <Row> <Cell><Data ss:Type="String">1st Task</Data></Cell> - <Cell><Data ss:Type="String">Brooks, Ryan D</Data></Cell> - <Cell><Data ss:Type="String">Dunne, Donald G</Data></Cell> + <Cell><Data ss:Type="String">Joe Smith</Data></Cell> + <Cell><Data ss:Type="String">Joe Smith</Data></Cell> <Cell><Data ss:Type="String">Working</Data></Cell> <Cell><Data ss:Type="String">Implement</Data></Cell> <Cell><Data ss:Type="Number">3</Data></Cell> @@ -64,7 +64,7 @@ </Row> <Row> <Cell><Data ss:Type="String">2nd Task</Data></Cell> - <Cell><Data ss:Type="String">Dunne, Donald G</Data></Cell> + <Cell><Data ss:Type="String">Joe Smith</Data></Cell> <Cell><Data ss:Type="String">UnAssigned</Data></Cell> <Cell><Data ss:Type="String">Waiting</Data></Cell> <Cell><Data ss:Type="String">Implement</Data></Cell> @@ -72,11 +72,12 @@ <Cell><Data ss:Type="Number">3</Data></Cell> <Cell><Data ss:Type="Number">45</Data></Cell> <Cell><Data ss:Type="String">Note 2</Data></Cell> + <Cell><Data ss:Type="String">Category</Data></Cell> </Row> <Row> <Cell><Data ss:Type="String">3rd Task</Data></Cell> - <Cell><Data ss:Type="String">Dunne, Donald G</Data></Cell> - <Cell><Data ss:Type="String">Dunne, Donald G; Brooks, Ryan D</Data></Cell> + <Cell><Data ss:Type="String">Kay Jones</Data></Cell> + <Cell><Data ss:Type="String">Joe Smith; Kay Jones</Data></Cell> <Cell><Data ss:Type="String">Waiting</Data></Cell> <Cell><Data ss:Type="String">Implement</Data></Cell> <Cell><Data ss:Type="Number">1</Data></Cell> @@ -90,7 +91,7 @@ <Pane> <Number>3</Number> <ActiveRow>3</ActiveRow> - <ActiveCol>8</ActiveCol> + <ActiveCol>2</ActiveCol> </Pane> </Panes> <ProtectObjects>False</ProtectObjects> @@ -98,12 +99,18 @@ </WorksheetOptions> </Worksheet> <Worksheet ss:Name="Sheet2"> + <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" + x:FullRows="1"> + </Table> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <ProtectObjects>False</ProtectObjects> <ProtectScenarios>False</ProtectScenarios> </WorksheetOptions> </Worksheet> <Worksheet ss:Name="Sheet3"> + <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" + x:FullRows="1"> + </Table> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <ProtectObjects>False</ProtectObjects> <ProtectScenarios>False</ProtectScenarios> |