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()); }
private Branch getPortBranchFromWorkflow( TeamWorkFlowArtifact sourceWorkflow, TeamWorkFlowArtifact destinationWorkflow) throws OseeCoreException { if (!sourceWorkflow.isRelated(AtsRelationTypes.Port_To, destinationWorkflow)) { sourceWorkflow.addRelation(AtsRelationTypes.Port_To, destinationWorkflow); sourceWorkflow.persist("create port relation"); } Collection<Branch> branches = BranchManager.getBranchesByName( String.format("Porting [%s] branch", sourceWorkflow.getAtsId())); if (branches.isEmpty()) { TransactionRecord transRecord = (TransactionRecord) AtsClientService.get().getBranchService().getEarliestTransactionId(sourceWorkflow); if (transRecord == null) { return null; } else { return BranchManager.createWorkingBranchFromTx( transRecord, String.format("Porting [%s] branch", sourceWorkflow.getAtsId()), null); } } else { return branches.iterator().next(); } }
private void doPortWork( TeamWorkFlowArtifact sourceWorkflow, TeamWorkFlowArtifact destinationWorkflow) throws OseeCoreException { if (destinationWorkflow.getWorkingBranchForceCacheUpdate() == null) { AtsBranchUtil.createWorkingBranch_Create(destinationWorkflow, true); } Branch destinationBranch = destinationWorkflow.getWorkingBranchForceCacheUpdate(); Branch portBranch = getPortBranchFromWorkflow(sourceWorkflow, destinationWorkflow); if (portBranch == null) { logf( "Source workflow [%s] not ready for port to Workflow [%s].", sourceWorkflow, destinationWorkflow); return; } try { if (portBranch.getBranchState().isCommitted()) { logf("Skipping completed workflow [%s].", destinationWorkflow); } else { ConflictManagerExternal conflictManager = new ConflictManagerExternal(destinationBranch, portBranch); BranchManager.commitBranch(null, conflictManager, false, false); logf("Commit complete for workflow [%s].", destinationWorkflow); } } catch (OseeCoreException ex) { logf("Resolve conflicts for workflow [%s].", destinationWorkflow); } }
private void makeChanges1(TeamWorkFlowArtifact teamArt) throws OseeCoreException { // Make changes and persist teamArt.setSoleAttributeFromString(AtsAttributeTypes.Description, "description 2"); ChangeTypeUtil.setChangeType(teamArt, ChangeType.Problem); teamArt.setSoleAttributeFromString(AtsAttributeTypes.PriorityType, "2"); teamArt.setSoleAttributeFromString(AtsAttributeTypes.ValidationRequired, "true"); AtsVersionService.get().setTargetedVersionAndStore(teamArt, getVersion256()); teamArt.persist("Remote Event Test"); }
@Override public void removeTargetedVersion(IAtsTeamWorkflow teamWf, boolean store) throws OseeCoreException { if (store) { TeamWorkFlowArtifact teamArt = TeamWorkFlowManager.getTeamWorkflowArt(teamWf); teamArt.deleteRelations(AtsRelationTypes.TeamWorkflowTargetedForVersion_Version); } versionCache.deCache(teamWf); }
private void makeChanges4(TeamWorkFlowArtifact teamArt) throws OseeCoreException { // Make changes and persist teamArt.deleteAttributes(AtsAttributeTypes.ValidationRequired); teamArt.deleteAttributes(AtsAttributeTypes.Resolution); teamArt.setSoleAttributeFromString(AtsAttributeTypes.Description, "description 4"); ChangeTypeUtil.setChangeType(teamArt, ChangeType.Support); teamArt.setSoleAttributeFromString(AtsAttributeTypes.PriorityType, "3"); AtsVersionService.get().setTargetedVersionAndStore(teamArt, getVersion258()); teamArt.persist("Remote Event Test"); }
public static Collection<IAtsUser> getValidateReviewFollowupUsers(TeamWorkFlowArtifact teamArt) throws OseeCoreException { Collection<IAtsUser> users = new HashSet<IAtsUser>(); users.addAll(teamArt.getStateMgr().getAssignees(TeamState.Implement)); if (users.size() > 0) { return users; } // Else if Team Workflow , return it to the leads of this team users.addAll(teamArt.getTeamDefinition().getLeads()); return users; }
@Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof Collection<?>) { return ((Collection<?>) parentElement).toArray(); } if (parentElement instanceof Artifact) { try { Artifact artifact = (Artifact) parentElement; if (artifact.isDeleted()) { return new Object[] {}; } if (artifact.isOfType(AtsArtifactTypes.Action)) { relatedArts.addAll(ActionManager.getTeams(artifact)); return ActionManager.getTeams((artifact)).toArray(); } if (artifact.isOfType(AtsArtifactTypes.Goal)) { List<Artifact> arts = AtsClientService.get().getGoalMembersCache().getMembers((GoalArtifact) artifact); relatedArts.addAll(arts); AtsBulkLoad.bulkLoadArtifacts(relatedArts); return arts.toArray(new Artifact[arts.size()]); } if (artifact.isOfType(AtsArtifactTypes.AgileSprint)) { List<Artifact> arts = AtsClientService.get().getSprintItemsCache().getMembers((SprintArtifact) artifact); relatedArts.addAll(arts); AtsBulkLoad.bulkLoadArtifacts(relatedArts); return arts.toArray(new Artifact[arts.size()]); } if (artifact.isOfType(AtsArtifactTypes.TeamWorkflow)) { TeamWorkFlowArtifact teamArt = TeamWorkFlowManager.cast(artifact); List<Artifact> arts = new ArrayList<Artifact>(); // Convert artifacts to WorldArtifactItems arts.addAll(ReviewManager.getReviews(teamArt)); arts.addAll(teamArt.getTaskArtifactsSorted()); relatedArts.addAll(arts); return arts.toArray(); } } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } } return org.eclipse.osee.framework.jdk.core.util.Collections.EMPTY_ARRAY; }
private void validateActionAtStart(Artifact actionArt) throws OseeCoreException { resultData.log("\nValidating Start..."); // 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", teamArt.getSoleAttributeValue(AtsAttributeTypes.Description, null)); testEquals("Change Type", ChangeType.Improvement, ChangeTypeUtil.getChangeType(teamArt)); testEquals( "Priority", "1", teamArt.getSoleAttributeValue(AtsAttributeTypes.PriorityType, null)); }
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()); } }
/** @return true if one or more reviews were created */ public static boolean createNecessaryBranchEventReviews( StateEventType stateEventType, TeamWorkFlowArtifact teamArt, Date createdDate, IAtsUser createdBy, IAtsChangeSet changes) throws OseeCoreException { boolean created = false; if (stateEventType != StateEventType.CommitBranch && stateEventType != StateEventType.CreateBranch) { throw new OseeStateException("Invalid stateEventType [%s]", stateEventType); } // Create any decision and peerToPeer reviews for createBranch and commitBranch for (IAtsDecisionReviewDefinition decRevDef : teamArt.getStateDefinition().getDecisionReviews()) { if (decRevDef.getStateEventType() != null && decRevDef.getStateEventType().equals(stateEventType)) { DecisionReviewArtifact decArt = DecisionReviewDefinitionManager.createNewDecisionReview( decRevDef, changes, teamArt, createdDate, createdBy); if (decArt != null) { created = true; changes.add(decArt); } } } for (IAtsPeerReviewDefinition peerRevDef : teamArt.getStateDefinition().getPeerReviews()) { if (peerRevDef.getStateEventType() != null && peerRevDef.getStateEventType().equals(stateEventType)) { PeerToPeerReviewArtifact peerArt = PeerReviewDefinitionManager.createNewPeerToPeerReview( peerRevDef, changes, teamArt, createdDate, createdBy); if (peerArt != null) { created = true; changes.add(peerArt); } } } return created; }
/** used recursively when originally passed a directory, thus an array of files is accepted */ private static void retrieveData( IProgressMonitor monitor, Collection<TeamWorkFlowArtifact> teamArts, IAttributeType attributeType, XResultData rd) throws OseeCoreException { monitor.subTask("Retrieving Actions"); int x = 1; rd.addRaw(AHTML.beginMultiColumnTable(95)); rd.addRaw( AHTML.addHeaderRowMultiColumnTable( new String[] {"HRID", "Bulld", "UI", attributeType.getName(), "RPCR", "Change"})); for (TeamWorkFlowArtifact teamArt : teamArts) { String rcprId = teamArt.getSoleAttributeValue(AtsAttributeTypes.LegacyPcrId, ""); String result = String.format( "Processing %s/%s RPCR %s for \"%s\"", x, teamArts.size(), rcprId, teamArt.getTeamDefinition().getName()); monitor.subTask(result); rd.log("\nRPCR " + rcprId); for (ICommitConfigArtifact commitConfigArt : AtsBranchManagerCore.getConfigArtifactsConfiguredToCommitTo(teamArt)) { processTeam( teamArt, BranchManager.getBranchByGuid(commitConfigArt.getBaslineBranchGuid()).getShortName(), attributeType, commitConfigArt, rd); } x++; // System.err.println("Developmental purposes only, don't release with this"); // if (x >= 5) // break; } rd.addRaw(AHTML.endMultiColumnTable()); }
private void makeChanges3(TeamWorkFlowArtifact teamArt) throws OseeCoreException { // Make changes and persist AtsVersionService.get().setTargetedVersionAndStore(teamArt, getVersion257()); teamArt.setSoleAttributeFromString(AtsAttributeTypes.ValidationRequired, "false"); teamArt.persist(getClass().getSimpleName()); }
/** * Create a new decision review configured and transitioned to handle action validation * * @param force will force the creation of the review without checking that a review should be * created */ public static DecisionReviewArtifact createValidateReview( TeamWorkFlowArtifact teamArt, boolean force, Date createdDate, IAtsUser createdBy, SkynetTransaction transaction) throws OseeCoreException { // If not validate page, don't do anything if (!force && !isValidatePage(teamArt.getStateDefinition())) { return null; } // If validate review already created for this state, return if (!force && ReviewManager.getReviewsFromCurrentState(teamArt).size() > 0) { for (AbstractReviewArtifact rev : ReviewManager.getReviewsFromCurrentState(teamArt)) { if (rev.getName().equals(VALIDATE_REVIEW_TITLE)) { return null; } } } // Create validate review try { DecisionReviewArtifact decRev = DecisionReviewManager.createNewDecisionReview( teamArt, isValidateReviewBlocking(teamArt.getStateDefinition()) ? ReviewBlockType.Transition : ReviewBlockType.None, true, createdDate, createdBy); decRev.setName(VALIDATE_REVIEW_TITLE); decRev.setSoleAttributeValue( AtsAttributeTypes.DecisionReviewOptions, "No;Followup;" + getValidateReviewFollowupUsersStr(teamArt) + "\n" + "Yes;Completed;"); TransitionHelper helper = new TransitionHelper( "Transition to Decision", Arrays.asList(decRev), DecisionReviewState.Decision.getName(), Arrays.asList(teamArt.getCreatedBy()), null, TransitionOption.None); TransitionManager transitionMgr = new TransitionManager(helper, transaction); TransitionResults results = transitionMgr.handleAll(); if (!results.isEmpty()) { OseeLog.logf( Activator.class, OseeLevel.SEVERE_POPUP, "Error transitioning Decision review [%s] to Decision %s", decRev.toStringWithId(), results); } return decRev; } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } return null; }
private void runClientTest() throws OseeCoreException { String title = getName() + " - Destination Client Test"; resultData.log("Running " + title); NewActionJob job = null; job = new NewActionJob( "tt", "description", ChangeType.Improvement, "1", null, false, getActionableItemsByToken(Arrays.asList(atsActionableItem)), null, null); job.setUser(true); job.setPriority(Job.LONG); job.schedule(); try { job.join(); } catch (InterruptedException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } Artifact actionArt = job.getActionArt(); resultData.log("Created Action " + actionArt); TeamWorkFlowArtifact teamArt = ActionManager.getFirstTeam(actionArt); // Make current user assignee for convenience to developer teamArt.getStateMgr().addAssignee(AtsClientService.get().getUserAdmin().getCurrentUser()); teamArt.persist(getClass().getSimpleName()); validateActionAtStart(actionArt); // Wait for destination client to start if (!MessageDialog.openConfirm( Displays.getActiveShell(), getName(), "Launch \"Destination Client - Start\" test, enter \"" + actionArt.getName().replaceFirst("tt ", "") + "\" and press Ok")) { return; } int sleepTime = 250; makeChanges1(teamArt); sleep(sleepTime); makeChanges2(teamArt); sleep(sleepTime); makeChanges3(teamArt); sleep(sleepTime); makeChanges4(teamArt); sleep(sleepTime); makeChanges5(teamArt); sleep(sleepTime); makeChanges6(teamArt); sleep(sleepTime); makeChanges7(teamArt); sleep(sleepTime); validateActionAtEnd(actionArt); // Wait for destination client to end if (!MessageDialog.openConfirm( Displays.getActiveShell(), getName(), "Launch \"Destination Client - End\" test, enter \"" + actionArt.getName().replaceFirst("tt ", "") + "\" and press Ok")) { return; } XResultDataUI.report(resultData, title); }
private void makeChanges6(TeamWorkFlowArtifact teamArt) throws OseeCoreException { // Make changes and transition AtsVersionService.get().setTargetedVersionAndStore(teamArt, getVersion257()); teamArt.setSoleAttributeFromString(AtsAttributeTypes.ValidationRequired, "false"); teamArt.persist("Remote Event Test"); }
private void makeChanges5(TeamWorkFlowArtifact teamArt) throws OseeCoreException { // Make changes and persist teamArt.setSoleAttributeFromString(AtsAttributeTypes.ValidationRequired, "true"); teamArt.persist(getClass().getSimpleName()); }
private static void processTeam( TeamWorkFlowArtifact teamArt, String buildId, IAttributeType attributeType, ICommitConfigArtifact commitConfigArt, XResultData rd) throws OseeCoreException { String rpcrNum = teamArt.getSoleAttributeValue(AtsAttributeTypes.LegacyPcrId, ""); ChangeData changeData = AtsBranchManager.getChangeData(teamArt, commitConfigArt); for (Artifact modArt : changeData.getArtifacts( KindType.Artifact, ModificationType.NEW, ModificationType.MODIFIED)) { List<String> attrStrs = modArt.getAttributesToStringList(attributeType); if (attrStrs.isEmpty()) { attrStrs.add(EnumeratedAttribute.UNSPECIFIED_VALUE); } for (String attrStr : attrStrs) { rd.addRaw( AHTML.addRowMultiColumnTable( new String[] { teamArt.getHumanReadableId(), buildId, modArt.getName(), attrStr, rpcrNum, "Content" })); } } for (Artifact artChg : changeData.getArtifacts(KindType.Artifact, ModificationType.DELETED)) { List<String> attrStrs = artChg.getAttributesToStringList(attributeType); if (attrStrs.isEmpty()) { attrStrs.add(EnumeratedAttribute.UNSPECIFIED_VALUE); } for (String attrStr : attrStrs) { rd.addRaw( AHTML.addRowMultiColumnTable( new String[] { teamArt.getHumanReadableId(), buildId, artChg.getName(), attrStr, rpcrNum, "Deleted" })); } } for (Artifact artChg : changeData.getArtifacts( KindType.RelationOnly, ModificationType.NEW, ModificationType.MODIFIED)) { List<String> attrStrs = artChg.getAttributesToStringList(attributeType); if (attrStrs.isEmpty()) { attrStrs.add(EnumeratedAttribute.UNSPECIFIED_VALUE); } for (String attrStr : attrStrs) { rd.addRaw( AHTML.addRowMultiColumnTable( new String[] { teamArt.getHumanReadableId(), buildId, artChg.getName(), attrStr, rpcrNum, "Relation" })); } } }
private void makeChanges2(TeamWorkFlowArtifact teamArt) throws OseeCoreException { // Make changes and persist teamArt.setSoleAttributeFromString(AtsAttributeTypes.Description, "description 3"); teamArt.setSoleAttributeFromString(AtsAttributeTypes.ProposedResolution, "this is resolution"); teamArt.persist(getClass().getSimpleName()); }