private void validateActionAtEnd(Artifact actionArt) throws OseeCoreException { resultData.log("\nValidating End..."); // Ensure event service is connected if (!OseeEventManager.isEventManagerConnected()) { resultData.logError("Remote Event Service is not connected"); return; } resultData.log("Remote Event Service connected"); // Validate values TeamWorkFlowArtifact teamArt = ActionManager.getFirstTeam(actionArt); testEquals( "Description", "description 4", teamArt.getSoleAttributeValue(AtsAttributeTypes.Description, null)); testEquals("Change Type", ChangeType.Support, ChangeTypeUtil.getChangeType(teamArt)); testEquals( "Priority", "3", teamArt.getSoleAttributeValue(AtsAttributeTypes.PriorityType, null)); testEquals( "Validation Required", "false", String.valueOf(teamArt.getSoleAttributeValue(AtsAttributeTypes.ValidationRequired, null))); IAtsVersion verArt = AtsVersionService.get().getTargetedVersion(teamArt); String expectedTargetedVersion; if (verArt != null) { expectedTargetedVersion = verArt.toString(); } else { expectedTargetedVersion = "not set"; } testEquals("Targeted Version", expectedTargetedVersion, "2.5.7"); testEquals("State", TeamState.Analyze.getName(), teamArt.getStateMgr().getCurrentStateName()); }
@Override public IAtsVersion store(IAtsVersion version, IAtsTeamDefinition teamDef) { Conditions.checkNotNull(version, "version"); Conditions.checkNotNull(teamDef, "teamDef"); Conditions.checkNotNull(teamDef.getStoreObject(), "teamDef storeObject"); IAtsVersion result = version; if (version.getStoreObject() == null) { Artifact verArt = cacheProvider.get().getArtifact(version); if (verArt == null) { AtsChangeSet changes = new AtsChangeSet("Create " + version); VersionArtifactWriter writer = new VersionArtifactWriter(); verArt = writer.store(version, cacheProvider.get(), changes); changes.relate(teamDef, AtsRelationTypes.TeamDefinitionToVersion_Version, verArt); version.setStoreObject(verArt); changes.execute(); } } return result; }
private IAtsTeamWorkflow setTargetedVersionLink(IAtsTeamWorkflow teamWf, IAtsVersion version) throws OseeCoreException { Artifact versionArt = ArtifactQuery.checkArtifactFromId(version.getGuid(), AtsUtilCore.getAtsBranch()); if (versionArt != null) { TeamWorkFlowArtifact teamArt = TeamWorkFlowManager.getTeamWorkflowArt(teamWf); if (teamArt != null) { teamArt.setRelations( AtsRelationTypes.TeamWorkflowTargetedForVersion_Version, Collections.singleton(versionArt)); return teamArt; } else { throw new OseeStateException( "Team Workflow artifact does not exist [%s]", teamWf.toStringWithId()); } } else { throw new OseeStateException( "Version artifact does not exist [%s]", version.toStringWithId()); } }
private IAtsVersion getSelectedVersionArtifact() throws OseeCoreException { if (versionCombo == null) { return null; } String versionStr = versionCombo.get(); if (!Strings.isValid(versionStr)) { return null; } Collection<IAtsTeamDefinition> teamDefs = getSelectedTeamDefinitions(); if (teamDefs.size() > 0) { IAtsTeamDefinition teamDefHoldingVersions = teamDefs.iterator().next().getTeamDefinitionHoldingVersions(); if (teamDefHoldingVersions == null) { return null; } for (IAtsVersion versionArtifact : teamDefHoldingVersions.getVersions(VersionReleaseType.Both, VersionLockedType.Both)) { if (versionArtifact.getName().equals(versionStr)) { return versionArtifact; } } } return null; }
@Override public void setTeamDefinition(IAtsVersion version, IAtsTeamDefinition teamDef) throws OseeCoreException { Artifact verArt = ArtifactQuery.getArtifactFromId(version.getGuid(), AtsUtilCore.getAtsBranch()); if (verArt == null) { throw new OseeStateException("Version [%s] does not exist.", version); } Artifact teamDefArt = ArtifactQuery.getArtifactFromId(teamDef.getGuid(), AtsUtilCore.getAtsBranch()); if (teamDefArt == null) { throw new OseeStateException("Team Definition [%s] does not exist.", teamDef); } if (!verArt .getRelatedArtifacts(AtsRelationTypes.TeamDefinitionToVersion_TeamDefinition) .contains(teamDefArt)) { verArt.addRelation(AtsRelationTypes.TeamDefinitionToVersion_TeamDefinition, teamDefArt); } }
@Override public Collection<? extends Artifact> getTaskEditorTaskArtifacts() throws OseeCoreException { List<Artifact> workflows = new ArrayList<Artifact>(); Collection<IAtsTeamDefinition> teamDefs = getSelectedTeamDefinitions(); IAtsVersion verArt = getSelectedVersionArtifact(); Collection<Artifact> groups = getSelectedGroups(); IAtsUser user = getSelectedUser(); boolean includeCompleted = isIncludeCompletedCheckbox(); boolean includeCancelled = isIncludeCancelledCheckbox(); // If user selected, handle that case separately cause it's faster to start with assigned if (user != null) { Set<TaskArtifact> userTaskArts = getUserAssignedTaskArtifacts(); if (includeCompleted || includeCancelled) { // If include cancelled or completed, need to perform extra search // Note: Don't need to do this for Originator, Subscribed or Favorites, cause it does // completed canceled in it's own searches userTaskArts.addAll( Collections.castMatching( TaskArtifact.class, ArtifactQuery.getArtifactListFromTypeAndAttribute( AtsArtifactTypes.Task, AtsAttributeTypes.State, "<" + user.getUserId() + ">", AtsUtilCore.getAtsBranch(), QueryOption.CONTAINS_MATCH_OPTIONS))); } Set<TaskArtifact> removeTaskArts = new HashSet<TaskArtifact>(); for (TaskArtifact taskArt : userTaskArts) { if (verArt != null && !verArt.equals( AtsClientService.get() .getVersionService() .getTargetedVersion(taskArt.getParentTeamWorkflow()))) { removeTaskArts.add(taskArt); } if (!teamDefs.isEmpty() && !teamDefs.contains(taskArt.getParentTeamWorkflow().getTeamDefinition())) { removeTaskArts.add(taskArt); } } userTaskArts.removeAll(removeTaskArts); return filterByCompletedAndStateAndSelectedUser(userTaskArts); } // If version specified, get workflows from targeted relation if (verArt != null) { Collection<IAtsTeamWorkflow> targetedForTeamWorkflows = AtsClientService.get().getVersionService().getTargetedForTeamWorkflows(verArt); Collection<Artifact> workflowArts = Collections.castAll(targetedForTeamWorkflows); for (Artifact art : workflowArts) { if (teamDefs.isEmpty()) { workflows.add(art); } // Filter by team def if specified else if (teamDefs.contains(((TeamWorkFlowArtifact) art).getTeamDefinition())) { workflows.add(art); } } } // Else, get workflows from teamdefs else if (teamDefs.size() > 0) { // ElapsedTime time = new ElapsedTime("Task Search - Load Team Workflows by Team // Defs"); TeamWorldSearchItem teamWorldSearchItem = new TeamWorldSearchItem( "", teamDefs, includeCompleted, includeCancelled, false, false, null, null, ReleasedOption.Both, null); workflows.addAll(teamWorldSearchItem.performSearchGetResults(false, SearchType.Search)); // time.end(); } else if (groups.size() > 0) { Set<TaskArtifact> taskArts = new HashSet<TaskArtifact>(); for (Artifact groupArt : groups) { for (Artifact art : groupArt.getRelatedArtifacts(CoreRelationTypes.Universal_Grouping__Members)) { if (art.isOfType(AtsArtifactTypes.Task)) { taskArts.add((TaskArtifact) art); } else if (art instanceof AbstractTaskableArtifact) { taskArts.addAll(((AbstractTaskableArtifact) art).getTaskArtifacts()); } } } return filterByCompletedAndStateAndSelectedUser(taskArts); } // ElapsedTime time = new ElapsedTime("Task Search - Bulk Load related tasks"); // Bulk load tasks related to workflows Collection<Artifact> artifacts = RelationManager.getRelatedArtifacts(workflows, 1, AtsRelationTypes.TeamWfToTask_Task); // time.end(); // Apply the remaining criteria // time = new ElapsedTime("Task Search - Filter by remaining criteria"); Collection<TaskArtifact> tasks = filterByCompletedAndStateAndSelectedUser(artifacts); // time.end(); return tasks; }