@SuppressWarnings("unchecked") @Override public <T extends IAtsWorkItem> Collection<T> getItems() throws OseeCoreException { QueryBuilder query = atsServer.getOrcsApi().getQueryFactory().fromBranch(AtsUtilCore.getAtsBranch()); // WorkItem type if (clazz != null) { List<IArtifactType> artifactTypes = getArtifactTypes(); query.andIsOfType(artifactTypes.toArray(new IArtifactType[artifactTypes.size()])); } // team if (teamDef != null) { query.and( AtsAttributeTypes.TeamDefinition, Collections.singleton(AtsUtilCore.getGuid(teamDef))); } // state if (stateType != null) { List<String> stateTypes = new ArrayList<>(); for (StateType type : stateType) { stateTypes.add(type.name()); } query.and(AtsAttributeTypes.CurrentStateType, stateTypes); } // Artifact Types if (artifactTypes != null && artifactTypes.length > 0) { query.andIsOfType(artifactTypes); } if (uuids != null && uuids.length > 0) { List<Long> artIds = new LinkedList<>(); for (Long uuid : uuids) { artIds.add(uuid); } query.andUuids(artIds); } // attributes if (!andAttr.isEmpty()) { for (AtsAttributeQuery attrQuery : andAttr) { query.and(attrQuery.getAttrType(), attrQuery.getValues(), attrQuery.getQueryOption()); } } if (!andRels.isEmpty()) { for (Entry<IRelationTypeSide, IAtsObject> entry : andRels.entrySet()) { query.andRelatedTo(entry.getKey(), (ArtifactReadable) entry.getValue().getStoreObject()); } } Set<T> workItems = new HashSet<>(); Iterator<ArtifactReadable> iterator = query.getResults().iterator(); while (iterator.hasNext()) { workItems.add((T) atsServer.getWorkItemFactory().getWorkItem(iterator.next())); } return workItems; }
@Override public Collection<IAtsTask> createTasks(NewTaskData newTaskData) { AtsTaskEndpointApi taskEp = AtsClientService.getTaskEp(); Response response = taskEp.create(newTaskData); Artifact teamWf = atsClient.getArtifact(newTaskData.getTeamWfUuid()); JaxAtsTasks jaxTasks = response.readEntity(JaxAtsTasks.class); ArtifactEvent artifactEvent = new ArtifactEvent(AtsUtilCore.getAtsBranch()); List<Long> artUuids = new LinkedList<>(); for (JaxAtsTask task : jaxTasks.getTasks()) { String guid = ArtifactQuery.getGuidFromUuid(task.getUuid(), AtsUtilCore.getAtsBranch()); artifactEvent .getArtifacts() .add( new EventBasicGuidArtifact( EventModType.Added, AtsUtilCore.getAtsBranch().getUuid(), AtsArtifactTypes.Task.getGuid(), guid)); artUuids.add(task.getUuid()); RelationLink relation = getRelation(teamWf, task); Artifact taskArt = atsClient.getArtifact(task.getUuid()); DefaultBasicUuidRelation guidRelation = new DefaultBasicUuidRelation( AtsUtilCore.getAtsBranch().getUuid(), AtsRelationTypes.TeamWfToTask_Task.getGuid(), relation.getId(), relation.getGammaId(), getBasicGuidArtifact(teamWf), getBasicGuidArtifact(taskArt)); artifactEvent .getRelations() .add( new EventBasicGuidRelation( RelationEventType.Added, newTaskData.getTeamWfUuid().intValue(), new Long(task.getUuid()).intValue(), guidRelation)); } OseeEventManager.kickPersistEvent(getClass(), artifactEvent); List<IAtsTask> tasks = new LinkedList<>(); for (Long uuid : artUuids) { tasks.add( AtsClientService.get() .getWorkItemFactory() .getTask(AtsClientService.get().getArtifact(uuid))); } return tasks; }
private Artifact getWorkDefinitionFolder() { Artifact result = null; result = ArtifactQuery.getArtifactFromTypeAndName( CoreArtifactTypes.Folder, "Work Definitions", AtsUtilCore.getAtsBranch()); if (result == null) { result = ArtifactQuery.getArtifactFromTypeAndName( CoreArtifactTypes.Folder, "Action Tracking System", AtsUtilCore.getAtsBranch()); } return result; }
@Override public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException { List<Artifact> activeTeams = new LinkedList<>(); for (Artifact agTeam : ArtifactQuery.getArtifactListFromType( AtsArtifactTypes.AgileTeam, AtsUtilCore.getAtsBranch())) { if (agTeam.getSoleAttributeValue(AtsAttributeTypes.Active, true)) { activeTeams.add(agTeam); } } FilteredTreeArtifactDialog dialog = new FilteredTreeArtifactDialog( getName(), "Select Agile Team", activeTeams, new ArtifactTreeContentProvider(), new ArtifactLabelProvider()); if (dialog.open() == 0) { EntryDialog ed = new EntryDialog(getName(), "Enter new Agile Sprint name(s) (comma delimited)"); if (ed.open() == 0) { if (Strings.isValid(ed.getEntry())) { try { AgileEndpointApi ageilEp = AtsClientService.getAgileEndpoint(); JaxNewAgileSprint newSprint = new JaxNewAgileSprint(); int teamUuid = ((Artifact) dialog.getSelectedFirst()).getArtId(); for (String name : ed.getEntry().split(",")) { newSprint.setName(name); newSprint.setTeamUuid(teamUuid); Response response = ageilEp.createSprint(new Long(teamUuid), newSprint); JaxAgileSprint sprint = response.readEntity(JaxAgileSprint.class); if (sprint != null) { long uuid = sprint.getUuid(); Artifact sprintArt = ArtifactQuery.getArtifactFromId( new Long(uuid).intValue(), AtsUtilCore.getAtsBranch()); sprintArt.getParent().reloadAttributesAndRelations(); AtsUtil.openArtifact(sprintArt.getGuid(), OseeCmEditor.CmPcrEditor); } else { AWorkbench.popup("Error creating Agile Team [%s]", response.toString()); return; } } } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } } } } }
@Override protected Collection<Artifact> searchIt(IAtsUser user) throws OseeCoreException { Set<Artifact> assigned = AtsUtil.getAssigned(user); Set<Artifact> artifacts = new HashSet<Artifact>(50); // Because user can be assigned directly to review or through being assigned to task, add in // all the original artifacts. artifacts.addAll(assigned); if (reviewState == ReviewState.InWork) { artifacts.addAll( RelationManager.getRelatedArtifacts(assigned, 1, AtsRelationTypes.TeamWfToTask_TeamWf)); } else { artifacts.addAll( ArtifactQuery.getArtifactListFromAttribute( AtsAttributeTypes.State, "<" + user.getUserId() + ">", AtsUtilCore.getAtsBranch(), QueryOption.CONTAINS_MATCH_OPTIONS)); } List<Artifact> artifactsToReturn = new ArrayList<Artifact>(artifacts.size()); for (Artifact artifact : artifacts) { if (artifact instanceof AbstractReviewArtifact && (reviewState == ReviewState.All || reviewState == ReviewState.InWork && !((AbstractWorkflowArtifact) artifact).isCompletedOrCancelled())) { artifactsToReturn.add(artifact); } } return artifactsToReturn; }
public static List<String> toGuids(Collection<? extends IAtsObject> atsObjects) { List<String> guids = new ArrayList<>(atsObjects.size()); for (IAtsObject atsObj : atsObjects) { guids.add(AtsUtilCore.getGuid(atsObj)); } return guids; }
private TeamWorkFlowArtifact getWorkflowFromAtsID(String atsID) throws OseeCoreException { IArtifactType LbaSubSystemsTeamWorkflow = TokenFactory.createArtifactType(0x0000BA0000000009L, "Lba SubSystems Team Workflow"); return (TeamWorkFlowArtifact) ArtifactQuery.getArtifactFromTypeAndAttribute( LbaSubSystemsTeamWorkflow, AtsAttributeTypes.AtsId, atsID, AtsUtilCore.getAtsBranch()); }
@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); } }
private TeamWorkFlowArtifact getWorkflowFromRpcr(String workflowId) throws OseeCoreException { IArtifactType LbaReqTeamWorkflow = TokenFactory.createArtifactType(0x0000BA000000000BL, "Lba Req Team Workflow"); return (TeamWorkFlowArtifact) ArtifactQuery.getArtifactFromTypeAndAttribute( LbaReqTeamWorkflow, AtsAttributeTypes.LegacyPcrId, workflowId, AtsUtilCore.getAtsBranch()); }
public static Result moveTasks(TeamWorkFlowArtifact newParent, List<TaskArtifact> taskArts) throws OseeCoreException { for (TaskArtifact taskArt : taskArts) { // task dropped on same awa as current parent; do nothing if (taskArt.getParentAWA().equals(newParent)) { return Result.FalseResult; } // Validate able to move tasks; WorkDefinitions must match boolean taskOverridesItsWorkDefinition = AtsClientService.get() .getWorkDefinitionAdmin() .isTaskOverridingItsWorkDefinition(taskArt); IWorkDefinitionMatch match = AtsClientService.get() .getWorkDefinitionAdmin() .getWorkDefinitionForTaskNotYetCreated(newParent); if (!taskOverridesItsWorkDefinition && !taskArt.getWorkDefinition().equals(match.getWorkDefinition())) { return new Result( "Desitination Task WorkDefinition does not match current Task WorkDefintion; Move Aborted"); } } // Move Tasks SkynetTransaction transaction = TransactionManager.createTransaction(AtsUtilCore.getAtsBranch(), "Drop Add Tasks"); for (Artifact art : taskArts) { if (art.isOfType(AtsArtifactTypes.Task)) { TaskArtifact taskArt = (TaskArtifact) art; taskArt.clearCaches(); if (taskArt.getParentAWA() != null) { taskArt.deleteRelation(AtsRelationTypes.TeamWfToTask_TeamWf, taskArt.getParentAWA()); } taskArt.addRelation(AtsRelationTypes.TeamWfToTask_TeamWf, newParent); taskArt.persist(transaction); taskArt.clearCaches(); } } transaction.execute(); return Result.TrueResult; }
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()); } }
@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; }