Esempio n. 1
0
 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;
 }
Esempio n. 2
0
  @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
  public Object executeWithException(ExecutionEvent event, IStructuredSelection selection)
      throws OseeCoreException {
    Branch selectedBranch =
        Handlers.getBranchesFromStructuredSelection(selection).iterator().next();

    EntryDialog ed =
        new EntryDialog(
            "Set Associated Artifact",
            "Set Associated Artifact for Branch\n\n\""
                + selectedBranch.getName()
                + "\""
                + (selectedBranch.getAssociatedArtifactId() != null
                    ? "\n\nCurrently: " + selectedBranch.getAssociatedArtifactId()
                    : "")
                + "\n\nEnter new Artifact Id to associate:");
    ed.setEntry(String.valueOf(selectedBranch.getAssociatedArtifactId()));
    if (ed.open() == 0) {
      String artId = ed.getEntry();
      Artifact associatedArtifact =
          ArtifactQuery.getArtifactFromId(Integer.parseInt(artId), BranchManager.getCommonBranch());
      if (MessageDialog.openConfirm(
          Displays.getActiveShell(),
          "Set Associated Artifact",
          "Set Associated Artifact for Branch\n\n\""
              + selectedBranch.getName()
              + "\"\nto\nArtifact: "
              + associatedArtifact)) {
        selectedBranch.setAssociatedArtifactId(Integer.parseInt(artId));
        BranchManager.persist(selectedBranch);
      }
    }

    return null;
  }
Esempio n. 4
0
  @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;
  }
Esempio n. 5
0
  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());
  }
Esempio n. 6
0
  @Override
  protected void restoreWidgetValues() {
    super.restoreWidgetValues();
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
      if (getDefaultSourceFile() == null) {
        directoryFileSelector.setDirectorySelected(settings.getBoolean("isDirectory"));
        String file = settings.get("source.file");
        if (Strings.isValid(file)) {
          directoryFileSelector.setText(file);
        }
      }

      String parser = settings.get("selected.parser");
      if (Strings.isValid(parser)) {
        for (IArtifactExtractor item : importContributionManager.getExtractors()) {
          if (parser.equals(item.getClass().getSimpleName())) {
            parserSelectPanel.setArtifactExtractor(item);
          }
        }
      }
      if (getDefaultDestinationArtifact() == null) {
        String guid = settings.get("destination.artifact.guid");
        String branchUuidStr = settings.get("destination.branch.uuid");

        if (GUID.isValid(guid) && Strings.isNumeric(branchUuidStr)) {
          try {
            Long bramchUuid = Long.valueOf(branchUuidStr);
            Artifact artifact =
                ArtifactQuery.getArtifactFromId(guid, BranchManager.getBranchByUuid(bramchUuid));
            artifactSelectPanel.setDefaultItem(artifact);
          } catch (OseeCoreException ex) {
            OseeLog.logf(
                Activator.class,
                Level.SEVERE,
                "Unable to restore destination artifact- guid:[%s] branch uuid:[%d]",
                guid,
                branchUuidStr);
          }
        }
      }

      boolean toUpdate = settings.getBoolean("is.update.existing.selected");
      updateExistingArtifacts.setSelection(toUpdate);
      deleteUnmatchedArtifacts.setEnabled(toUpdate);
      if (toUpdate) {
        try {
          ArtifactType artType = ArtifactTypeManager.getType(getArtifactType());
          attributeTypeSelectPanel.setAllowedAttributeTypes(
              artType.getAttributeTypes(getDestinationArtifact().getFullBranch()));
        } catch (OseeCoreException ex) {
          OseeLog.log(Activator.class, Level.SEVERE, ex);
        }
      } else {
        attributeTypeSelectPanel.setAllowedAttributeTypes(new ArrayList<IAttributeType>());
      }
    }
  }
Esempio n. 7
0
 @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);
   }
 }
Esempio n. 8
0
  @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;
  }
Esempio n. 9
0
  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 Set<Artifact> getEmailGroupsAndUserGroups(User user) throws OseeCoreException {
   Set<Artifact> artifacts = new HashSet<Artifact>();
   for (Artifact art :
       ArtifactQuery.getArtifactListFromType(
           CoreArtifactTypes.UserGroup, BranchManager.getCommonBranch())) {
     // Only add group if have read permissions
     if (!art.getName().equals("Root Artifact")
         && AccessControlManager.hasPermission(art, PermissionEnum.READ)) {
       artifacts.add(art);
     }
   }
   return artifacts;
 }
  private static Set<IAtsActionableItem> getActionableItemsByToken(
      Collection<IArtifactToken> aiArtifactTokens) throws OseeCoreException {
    Set<IAtsActionableItem> aias = new HashSet<IAtsActionableItem>();
    for (IArtifactToken token : aiArtifactTokens) {
      Artifact aiArt =
          ArtifactQuery.getArtifactFromId(token.getGuid(), AtsUtilCore.getAtsBranchToken());

      if (aiArt != null) {
        IAtsActionableItem item = AtsClientService.get().getConfigObject(aiArt);
        aias.add(item);
      }
    }
    return aias;
  }
  @Override
  public AtsArtifactConfigCache call() throws Exception {
    AtsArtifactConfigCache cache = new AtsArtifactConfigCache();

    List<IArtifactType> typesToLoad = getTypesToLoad();
    List<Artifact> artifactListFromType =
        ArtifactQuery.getArtifactListFromType(
            typesToLoad, AtsUtilCore.getAtsBranchToken(), DeletionFlag.EXCLUDE_DELETED);

    for (Artifact artifact : artifactListFromType) {
      loadAtsConfigCacheArtifacts(artifactStore, cache, artifact);
    }
    return cache;
  }
  private void runDestinationTestEnd(String ttNum) throws OseeCoreException {
    String title = getName() + " - Destination Client Test - End";
    String actionTitle = "tt " + ttNum;
    resultData.log("Running " + title);

    Artifact actionArt =
        ArtifactQuery.getArtifactFromTypeAndName(
            AtsArtifactTypes.Action, actionTitle, AtsUtil.getAtsBranch());

    if (actionArt == null) {
      resultData.logError(String.format("Couldn't load Action named [%s]", actionTitle));
    } else {
      resultData.log("Loaded Action " + actionArt);
      AtsUtil.openATSAction(actionArt, AtsOpenOption.OpenOneOrPopupSelect);
    }
    validateActionAtEnd(actionArt);
    XResultDataUI.report(resultData, title);
  }
Esempio n. 14
0
 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());
   }
 }
Esempio n. 15
0
  /**
   * Test method for {@link
   * org.eclipse.osee.framework.skynet.core.artifact.BranchManager#getMergeBranch(Branch, Branch)} .
   */
  @org.junit.Test
  public void test03GetMergeBranchCreated() throws Exception {
    SevereLoggingMonitor monitorLog = new SevereLoggingMonitor();
    OseeLog.registerLoggerListener(monitorLog);
    try {
      Branch mergeBranch =
          BranchManager.getMergeBranch(
              ConflictTestManager.getSourceBranch(), ConflictTestManager.getDestBranch());
      assertFalse(mergeBranch == null);
      Collection<Artifact> artifacts =
          ArtifactQuery.getArtifactListFromBranch(mergeBranch, INCLUDE_DELETED);

      int expectedNumber = ConflictTestManager.numberOfArtifactsOnMergeBranch();
      int actualNumber = artifacts.size();
      assertTrue(
          "(Intermittent failures - needs re-write) - The merge Branch does not contain the expected number of artifacts: ",
          (expectedNumber <= actualNumber) && (actualNumber <= (expectedNumber + 1)));
    } catch (Exception ex) {
      fail(ex.getMessage());
    }
    assertTrue(
        String.format("%d SevereLogs during test.", monitorLog.getAllLogs().size()),
        monitorLog.getAllLogs().isEmpty());
  }
 /** Reads a resource from the given stream. */
 private Artifact readArtifact(DataInputStream dataIn) throws OseeCoreException, IOException {
   int artID = dataIn.readInt();
   int branchId = dataIn.readInt();
   return ArtifactQuery.getArtifactFromId(artID, BranchManager.getBranch(branchId));
 }
  @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;
  }