示例#1
0
  @Override
  protected void saveWidgetValues() {
    super.saveWidgetValues();
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {

      settings.put("isDirectory", isDirectory());

      File file = getSourceFile();
      if (file != null) {
        settings.put("source.file", getSourceFile().getAbsolutePath());
      }

      IArtifactExtractor parser = getArtifactParser();
      if (parser != null) {
        settings.put("selected.parser", parser.getClass().getSimpleName());
      }

      Artifact artifact = getDestinationArtifact();
      if (artifact != null) {
        settings.put("destination.artifact.guid", artifact.getGuid());
        settings.put("destination.branch.uuid", artifact.getBranch().getUuid());
      }
      settings.put("is.update.existing.selected", isUpdateExistingSelected());
    }
  }
示例#2
0
  @Override
  public InputStream getRenderInputStream(
      PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException {
    InputStream stream = null;
    try {
      if (artifacts.isEmpty()) {
        stream =
            Streams.convertStringToInputStream(
                WordWholeDocumentAttribute.getEmptyDocumentContent(), "UTF-8");
      } else {
        Artifact artifact = artifacts.iterator().next();
        String content =
            artifact.getOrInitializeSoleAttributeValue(CoreAttributeTypes.WholeWordContent);
        if (presentationType == PresentationType.DIFF
            && WordUtil.containsWordAnnotations(content)) {
          throw new OseeStateException(
              "Trying to diff the [%s] artifact on the [%s] branch, which has tracked changes turned on.  All tracked changes must be removed before the artifacts can be compared.",
              artifact.getName(), artifact.getBranch().getName());
        }

        LinkType linkType = LinkType.OSEE_SERVER_LINK;
        content = WordMlLinkHandler.link(linkType, artifact, content);

        String classification = WordRendererUtil.getDataRightsClassification(artifact);
        if (Strings.isValid(classification)) {
          content = addDataRights(content, classification, artifact);
        }

        stream = Streams.convertStringToInputStream(content, "UTF-8");
      }
    } catch (IOException ex) {
      OseeExceptions.wrapAndThrow(ex);
    }
    return stream;
  }
示例#3
0
  @Override
  public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
    try {
      if (treeItem.getData() instanceof Artifact) {
        Artifact useArt = (Artifact) treeItem.getData();
        if (useArt.isOfType(AtsArtifactTypes.Action)) {
          if (ActionManager.getTeams(useArt).size() == 1) {
            useArt = ActionManager.getFirstTeam(useArt);
          } else {
            return false;
          }
        }
        if (!(useArt instanceof AbstractWorkflowArtifact)) {
          return false;
        }
        AbstractWorkflowArtifact awa = (AbstractWorkflowArtifact) useArt;
        boolean modified = promptChangeAssignees(Arrays.asList(awa), isPersistViewer());
        XViewer xViewer = ((XViewerColumn) treeColumn.getData()).getTreeViewer();
        if (modified && isPersistViewer(xViewer)) {
          AtsChangeSet.execute("persist assignees via alt-left-click", awa);
        }
        if (modified) {
          xViewer.update(awa, null);
          return true;
        }
      }
    } catch (OseeCoreException ex) {
      OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
    }

    return false;
  }
示例#4
0
  @Override
  public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
    try {
      if (treeItem.getData() instanceof Artifact) {
        Artifact useArt = (Artifact) treeItem.getData();
        if (!(useArt.isOfType(AtsArtifactTypes.AbstractWorkflowArtifact))) {
          return false;
        }

        boolean modified = promptChangeSprint(useArt, isPersistViewer());

        XViewer xViewer = ((XViewerColumn) treeColumn.getData()).getTreeViewer();
        if (modified && isPersistViewer(xViewer)) {
          useArt.persist("persist sprints via alt-left-click");
        }
        if (modified) {
          xViewer.update(useArt, null);
          return true;
        }
      }
    } catch (OseeCoreException ex) {
      OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
    }

    return false;
  }
示例#5
0
  private String addDataRights(String content, String classification, Artifact artifact) {
    String toReturn = content;
    PageOrientation orientation = WordRendererUtil.getPageOrientation(artifact);
    DataRightInput request = new DataRightInput();
    request.addData(artifact.getGuid(), classification, orientation, 0);

    DataRightProvider provider = new DataRightProviderImpl();
    DataRightResult dataRights = provider.getDataRights(request);
    String footer = dataRights.getContent(artifact.getGuid(), orientation);

    Matcher startFtr = START_PATTERN.matcher(footer);
    Matcher endFtr = END_PATTERN.matcher(footer);
    if (startFtr.find() && endFtr.find()) {
      ChangeSet ftrCs = new ChangeSet(footer);
      ftrCs.delete(0, startFtr.end());
      ftrCs.delete(endFtr.start(), footer.length());
      footer = ftrCs.applyChangesToSelf().toString();
    }

    startFtr.reset(content);
    endFtr.reset(content);
    ChangeSet cs = new ChangeSet(content);
    while (startFtr.find()) {
      if (endFtr.find()) {
        cs.replace(startFtr.end(), endFtr.start(), footer);
      }
    }
    toReturn = cs.applyChangesToSelf().toString();
    return toReturn;
  }
  @Override
  public void performDragOver(DropTargetEvent event) {
    if (!ArtifactTransfer.getInstance().isSupportedType(event.currentDataType)) {
      event.detail = DND.DROP_NONE;
      return;
    }
    final ArtifactData artData = ArtifactTransfer.getInstance().nativeToJava(event.currentDataType);
    if (artData == null) {
      event.detail = DND.DROP_NONE;
      return;
    }
    for (Artifact art : artData.getArtifacts()) {
      if (art.isOfType(CoreArtifactTypes.UniversalGroup)) {
        event.detail = DND.DROP_NONE;
        return;
      }
    }
    Tree tree = treeViewer.getTree();
    TreeItem dragOverTreeItem = tree.getItem(treeViewer.getTree().toControl(event.x, event.y));

    event.feedback = DND.FEEDBACK_EXPAND;
    event.detail = DND.DROP_NONE;

    // Set as COPY if drag item over group (copy versus move will be determined on drop
    if (dragOverTreeItem != null
        && ((GroupExplorerItem) dragOverTreeItem.getData()).isUniversalGroup()) {
      event.detail = DND.DROP_COPY;
      tree.setInsertMark(null, false);
    }
    // Handle re-ordering within same group
    else if (dragOverTreeItem != null
        && !((GroupExplorerItem) dragOverTreeItem.getData()).isUniversalGroup()) {
      GroupExplorerItem dragOverGroupItem = (GroupExplorerItem) dragOverTreeItem.getData();
      IStructuredSelection selectedItem = (IStructuredSelection) treeViewer.getSelection();
      Object obj = selectedItem.getFirstElement();
      if (obj instanceof GroupExplorerItem) {
        GroupExplorerItem droppingGroupItem = (GroupExplorerItem) obj;

        // the group to move must belong to the same group as the member to insert before/after
        if (dragOverGroupItem.getParentItem().equals(droppingGroupItem.getParentItem())) {
          if (isFeedbackAfter) {
            event.feedback = DND.FEEDBACK_INSERT_AFTER;
          } else {
            event.feedback = DND.FEEDBACK_INSERT_BEFORE;
          }
          event.detail = DND.DROP_MOVE;
        }
      } else {
        if (isFeedbackAfter) {
          event.feedback = DND.FEEDBACK_INSERT_AFTER;
        } else {
          event.feedback = DND.FEEDBACK_INSERT_BEFORE;
        }
        event.detail = DND.DROP_COPY;
      }
    } else {
      tree.setInsertMark(null, false);
    }
  }
  @Test
  public void testSetAttributeValuesWithDuplicates() throws Exception {
    artifact.setAttributeValues(CoreAttributeTypes.StaticId, ADD_DUPLICATES);

    List<String> actual = artifact.getAttributesToStringList(CoreAttributeTypes.StaticId);

    assertTrue(Collections.isEqual(ADD_DUPLICATES_EXPECTED, actual));
  }
  @Test
  public void testSetAttributeValuesAddOneRemoveOne() throws Exception {
    artifact.setAttributeValues(CoreAttributeTypes.StaticId, ADD_ONE_REMOVE_ONE);

    List<String> actual = artifact.getAttributesToStringList(CoreAttributeTypes.StaticId);

    assertTrue(Collections.isEqual(ADD_ONE_REMOVE_ONE, actual));
  }
示例#9
0
 /** Creates a simple artifact and adds it to the root artifact default hierarchical relation */
 public static Artifact createSimpleArtifact(
     IArtifactType artifactType, String name, IOseeBranch branch) throws OseeCoreException {
   Artifact softArt = ArtifactTypeManager.addArtifact(artifactType, branch);
   softArt.setName(name);
   softArt.addAttribute(CoreAttributeTypes.Subsystem, "Electrical");
   Artifact rootArtifact = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch);
   rootArtifact.addRelation(CoreRelationTypes.Default_Hierarchical__Child, softArt);
   return softArt;
 }
  @Test
  public void testSetAttributeValuesRemoveAll() throws Exception {
    artifact.setAttributeValues(
        CoreAttributeTypes.StaticId, java.util.Collections.<String>emptyList());

    List<String> actual = artifact.getAttributesToStringList(CoreAttributeTypes.StaticId);

    assertTrue(actual.isEmpty());
  }
 public void addValid(Artifact artifact) {
   if (artifact == null) {
     needWindow = true;
   } else {
     this.branch = artifact.getBranch();
     this.validArtifacts.add(artifact);
     this.names.add(artifact.getName());
   }
 }
示例#12
0
 private void recurseAndOpenCoveragePackage(Artifact artifact) throws OseeCoreException {
   if (artifact.isOfType(CoverageArtifactTypes.CoveragePackage)) {
     CoverageEditor.open(new CoverageEditorInput(artifact.getName(), artifact, null, false));
   } else {
     if (artifact.getParent() != null) {
       recurseAndOpenCoveragePackage(artifact.getParent());
     }
   }
 }
示例#13
0
 @Override
 public int getApplicabilityRating(PresentationType presentationType, IArtifact artifact)
     throws OseeCoreException {
   Artifact aArtifact = artifact.getFullArtifact();
   if (!presentationType.matches(GENERALIZED_EDIT, GENERAL_REQUESTED, PRODUCE_ATTRIBUTE)
       && aArtifact.isAttributeTypeValid(WholeWordContent)) {
     return PRESENTATION_SUBTYPE_MATCH;
   }
   return NO_MATCH;
 }
示例#14
0
 public static Collection<TeamWorkFlowArtifact> getTeamsTeamWorkflowArtifacts(
     Collection<IAtsTeamDefinition> teamDefs) throws OseeCoreException {
   LegacyPCRActionsWorldSearchItem search = new LegacyPCRActionsWorldSearchItem(teamDefs, false);
   Set<TeamWorkFlowArtifact> teamArts = new HashSet<>();
   for (Artifact art : search.performSearchGetResults()) {
     if (art.isOfType(AtsArtifactTypes.TeamWorkflow)) {
       teamArts.add((TeamWorkFlowArtifact) art);
     }
   }
   return teamArts;
 }
 @Override
 public boolean equals(Object obj) {
   boolean result = false;
   if (obj instanceof ArtifactDelta) {
     ArtifactDelta other = (ArtifactDelta) obj;
     boolean left = startArt == null ? other.startArt == null : startArt.equals(other.startArt);
     boolean right = endArt == null ? other.endArt == null : endArt.equals(other.endArt);
     result = left && right;
   }
   return result;
 }
示例#16
0
 public static Collection<ActionArtifact> getTeamsActionArtifacts(
     Collection<IAtsTeamDefinition> teamDefs) throws OseeCoreException {
   LegacyPCRActionsWorldSearchItem search = new LegacyPCRActionsWorldSearchItem(teamDefs, true);
   Set<ActionArtifact> actArts = new HashSet<>();
   for (Artifact art : search.performSearchGetResults()) {
     if (art.isOfType(AtsArtifactTypes.Action)) {
       actArts.add((ActionArtifact) art);
     }
   }
   return actArts;
 }
示例#17
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);
          }
        }
      }
    }
  }
示例#18
0
  @Override
  public int getApplicabilityRating(PresentationType presentationType, IArtifact artifact)
      throws OseeCoreException {
    Artifact aArtifact = artifact.getFullArtifact();
    if (!presentationType.matches(GENERALIZED_EDIT, PRODUCE_ATTRIBUTE)
        && !aArtifact.isHistorical()) {
      if (aArtifact.isOfType(CoveragePackage, CoverageFolder, CoverageUnit)) {
        return PRESENTATION_SUBTYPE_MATCH;
      }
    }

    return NO_MATCH;
  }
 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;
 }
 @Override
 public int hashCode() {
   final int prime = 37;
   int result = 17;
   if (startArt != null) {
     result = prime * result + startArt.hashCode();
   } else {
     result = prime * result;
   }
   if (endArt != null) {
     result = prime * result + endArt.hashCode();
   } else {
     result = prime * result;
   }
   return result;
 }
示例#21
0
 private RelationLink getRelation(Artifact teamWf, JaxAtsTask task) {
   for (RelationLink relation : teamWf.getRelationsAll(DeletionFlag.EXCLUDE_DELETED)) {
     if (relation.getBArtifactId() == task.getUuid()) {
       return relation;
     }
   }
   return null;
 }
  /** Create the TableViewer */
  private void okSelected() {
    ArrayList<ArtifactModel> artifactList =
        relationTableViewer.getArtifactList().getArtifactModel();

    for (int i = 0; i < artifactList.size(); i++) {
      ArtifactModel model = artifactList.get(i);

      if (model.isAdd()) {
        Artifact artifact = model.getArtifact();
        descriptor = model.getDescriptor();
        if (artifact == null) {
          if (descriptor != null) {
            try {
              artifact = ArtifactTypeManager.addArtifact(descriptor, branch);
              artifact.setName(model.getName());
              artifact.setSoleAttributeValue(
                  CoreAttributeTypes.ContentUrl, urls.get(names.indexOf(model.getName())));
              artifact.persist(getClass().getSimpleName());
            } catch (Exception ex) {
              OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
            }
          }
        } else {
          artifact = model.getArtifact();
        }

        if (artifact != null) {
          try {
            relationGroup.getArtifact().addRelation(relationGroup, artifact);
          } catch (OseeCoreException ex) {
            OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
          }
        }
      }
    }
    if (persistOnOk) {
      try {
        relationGroup.getArtifact().persist(getClass().getSimpleName());
      } catch (OseeCoreException ex) {
        OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
      }
    }
    shell.dispose();
    viewer.refresh();
  }
示例#23
0
 @Override
 public Object getParent(Object element) {
   if (element instanceof Artifact) {
     try {
       Artifact artifact = (Artifact) element;
       if (artifact.isDeleted()) {
         return null;
       }
       if (artifact.isOfType(AtsArtifactTypes.TeamWorkflow)) {
         return TeamWorkFlowManager.cast(artifact).getParentActionArtifact();
       }
       if (artifact.isOfType(AtsArtifactTypes.Task)) {
         return TaskManager.cast(artifact).getParentAWA();
       }
       if (artifact.isOfType(AtsArtifactTypes.ReviewArtifact)) {
         return ReviewManager.cast(artifact).getParentAWA();
       }
       if (artifact.isOfType(AtsArtifactTypes.Goal)) {
         return ((GoalArtifact) artifact).getParentAWA();
       }
       if (artifact.isOfType(AtsArtifactTypes.AgileSprint)) {
         return ((SprintArtifact) artifact).getParentAWA();
       }
     } catch (Exception ex) {
       // do nothing
     }
   }
   return null;
 }
 @Before
 public void setup() throws Exception {
   artifact =
       ArtifactTypeManager.addArtifact(
           CoreArtifactTypes.GeneralDocument,
           DemoBranches.SAW_Bld_1,
           method.getQualifiedTestName());
   artifact.setAttributeValues(CoreAttributeTypes.StaticId, START_VALUE);
 }
 public Result isValid() {
   if (!Strings.isValid(getSubject())) {
     return new Result("Must enter subject");
   }
   if (!Strings.isValid(getBody())) {
     return new Result("Must enter body");
   }
   if (workflows.isEmpty()) {
     return new Result("No workflows dropped");
   }
   for (Artifact workflow : workflows) {
     if (!(workflow instanceof AbstractWorkflowArtifact)) {
       return new Result(
           "Only valid for Workflow Artifacts, not [%s]", workflow.getArtifactTypeName());
     }
   }
   return Result.TrueResult;
 }
 protected Artifact getArtifactOrCreate(
     AtsArtifactConfigCache cache,
     IArtifactType artifactType,
     IAtsConfigObject atsObject,
     SkynetTransaction transaction)
     throws OseeCoreException {
   Artifact artifact = cache.getArtifact(atsObject);
   if (artifact == null) {
     artifact =
         ArtifactTypeManager.addArtifact(
             artifactType,
             AtsUtilCore.getAtsBranchToken(),
             atsObject.getName(),
             atsObject.getGuid(),
             atsObject.getHumanReadableId());
     artifact.persist(transaction);
   }
   return artifact;
 }
示例#27
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);
   }
 }
示例#28
0
  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;
  }
示例#29
0
 public static Image getAssigneeImage(Artifact artifact) throws OseeCoreException {
   if (artifact.isDeleted()) {
     return null;
   }
   if (artifact instanceof AbstractWorkflowArtifact) {
     return FrameworkArtifactImageProvider.getUserImage(
         AtsClientService.get()
             .getUserServiceClient()
             .getOseeUsers(((AbstractWorkflowArtifact) artifact).getStateMgr().getAssignees()));
   }
   if (artifact.isOfType(AtsArtifactTypes.Action)) {
     for (TeamWorkFlowArtifact team : ActionManager.getTeams(artifact)) {
       Image image = AssigneeColumnUI.getAssigneeImage(team);
       if (image != null) {
         return image;
       }
     }
   }
   return null;
 }
示例#30
0
 private static Set<IAgileSprint> getActiveSprints(Artifact agileTeamArt) {
   Set<IAgileSprint> activeSprints = new HashSet<>();
   for (Artifact sprintArt :
       agileTeamArt.getRelatedArtifacts(AtsRelationTypes.AgileTeamToSprint_Sprint)) {
     IAgileSprint agileSprint =
         AtsClientService.get().getWorkItemFactory().getAgileSprint(sprintArt);
     if (agileSprint.isActive()) {
       activeSprints.add(agileSprint);
     }
   }
   return activeSprints;
 }