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();
    }
  }
  @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;
  }
  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);
    }
  }
Exemple #4
0
  @Ignore
  public void test05CommitWithoutResolutionErrors() {
    SevereLoggingMonitor monitorLog = new SevereLoggingMonitor();
    OseeLog.registerLoggerListener(monitorLog);
    try {
      ConflictManagerExternal conflictManager =
          new ConflictManagerExternal(
              ConflictTestManager.getDestBranch(), ConflictTestManager.getSourceBranch());
      BranchManager.commitBranch(null, conflictManager, false, false);
      assertTrue("Commit did not complete as expected", ConflictTestManager.validateCommit());

      assertEquals(
          "Source Branch state incorrect",
          BranchState.COMMITTED,
          ConflictTestManager.getSourceBranch().getBranchState());

    } catch (Exception ex) {
      fail(
          "No Exceptions should have been thrown. Not even the "
              + ex.getLocalizedMessage()
              + "Exception");
    }

    assertTrue(
        String.format("%d SevereLogs during test.", monitorLog.getSevereLogs().size()),
        monitorLog.getSevereLogs().isEmpty());
  }
Exemple #5
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>());
      }
    }
  }
 @Override
 public Branch getBranch(IAtsVersion version) {
   Branch branch = null;
   long branchUuid = getBranchId(version);
   if (branchUuid > 0) {
     branch = BranchManager.getBranch(branchUuid);
   }
   return branch;
 }
 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;
 }
  public static boolean handleCommitInProgressPostPrompt(
      final ConflictManagerExternal conflictManager, int userOption, boolean skipPrompts)
      throws OseeCoreException {
    boolean toReturn = false;
    Branch sourceBranch = conflictManager.getSourceBranch();
    Branch destinationBranch = conflictManager.getDestinationBranch();

    if (userOption == COMMIT) { // Commit
      BranchManager.commitBranch(null, conflictManager, archiveBranch, false);
      toReturn = true;
    } else if (userOption == LAUNCH_MERGE_VIEW) { // Launch Merge
      MergeView.openView(sourceBranch, destinationBranch, sourceBranch.getBaseTransaction());
    } else if (userOption == DELETE_MERGE) { // Delete Merge
      deleteSingleMergeBranches(sourceBranch, destinationBranch, skipPrompts);
    } else if (userOption == FORCE_COMMIT) { // Force Commit, admin only
      BranchManager.commitBranch(null, conflictManager, archiveBranch, true);
      toReturn = true;
    } else if (userOption == CANCEL) {
      // do nothing
    }
    return toReturn;
  }
Exemple #9
0
 public static Result deleteWorkingBranch(TeamWorkFlowArtifact teamArt, boolean pend)
     throws OseeCoreException {
   IOseeBranch branch = AtsClientService.get().getBranchService().getWorkingBranch(teamArt);
   if (branch != null) {
     IStatus status = null;
     if (pend) {
       status = BranchManager.deleteBranchAndPend(branch);
     } else {
       Job job = BranchManager.deleteBranch(branch);
       job.schedule();
       try {
         job.join();
       } catch (InterruptedException ex) {
         throw new OseeWrappedException(ex);
       }
       status = job.getResult();
     }
     if (status.isOK()) {
       return Result.TrueResult;
     }
     return new Result(status.getMessage());
   }
   return Result.TrueResult;
 }
  @Override
  public void run() throws OseeCoreException {
    Conditions.checkNotNull(configuration, "DbInitConfiguration Info");

    OseeClientProperties.setInDbInit(true);

    createOseeDatastore();

    Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.skynet.core");
    int state = bundle.getState();
    if (state != Bundle.ACTIVE) {
      try {
        bundle.start();
      } catch (BundleException ex) {
        throw new OseeCoreException(ex);
      }
    }
    IOseeCachingService service = DatabaseInitActivator.getInstance().getCachingService();
    service.clearAll();

    IOseeDatabaseService databaseService = DatabaseInitActivator.getInstance().getDatabaseService();
    databaseService.getSequence().clear();
    IdentityService identityService = DatabaseInitActivator.getInstance().getIdentityService();
    identityService.clear();

    Branch systemRoot = BranchManager.getSystemRootBranch();
    Conditions.checkNotNull(systemRoot, "System root was not created - ");

    ClientSessionManager.releaseSession();
    ClientSessionManager.authenticate(
        new BaseCredentialProvider() {

          @Override
          public OseeCredential getCredential() {
            OseeCredential credential = super.getCredential();
            credential.setUserName(SystemUser.BootStrap.getName());
            return credential;
          }
        });

    List<String> oseeTypes = configuration.getOseeTypeExtensionIds();
    Conditions.checkExpressionFailOnTrue(oseeTypes.isEmpty(), "osee types cannot be empty");

    OseeTypesSetup oseeTypesSetup = new OseeTypesSetup();
    oseeTypesSetup.execute(oseeTypes);

    service.clearAll();
  }
Exemple #11
0
  /**
   * Test method for {@link
   * org.eclipse.osee.framework.skynet.core.artifact.BranchManager#getMergeBranch(Branch, Branch)} .
   */
  @org.junit.Test
  public void test01GetMergeBranchNotCreated() throws Exception {
    SevereLoggingMonitor monitorLog = new SevereLoggingMonitor();
    OseeLog.registerLoggerListener(monitorLog);
    try {
      Branch mergeBranch =
          BranchManager.getMergeBranch(
              ConflictTestManager.getSourceBranch(), ConflictTestManager.getDestBranch());

      assertTrue(
          "The merge branch should be null as it hasn't been created yet", mergeBranch == null);
    } catch (Exception ex) {
      fail(ex.getMessage());
    }
    assertTrue(
        String.format("%d SevereLogs during test.", monitorLog.getSevereLogs().size()),
        monitorLog.getSevereLogs().isEmpty());
  }
  @Override
  protected void doWork(IProgressMonitor monitor) throws Exception {
    Branch startBranch = uiData.getTxDelta().getStartTx().getBranch();
    Branch otherBranch = branchProvider.getBranch(monitor);
    checkForCancelledStatus(monitor);

    Conditions.checkNotNull(otherBranch, "other branch to compare to");

    TransactionRecord startTx = TransactionManager.getHeadTransaction(startBranch);
    TransactionRecord endTx = TransactionManager.getHeadTransaction(otherBranch);
    TransactionDelta txDelta = new TransactionDelta(startTx, endTx);
    uiData.setTxDelta(txDelta);

    Branch mergeBranch = BranchManager.getMergeBranch(startBranch, otherBranch, true);
    uiData.setMergeBranch(mergeBranch);

    if (otherBranch.equals(startBranch.getParentBranch())) {
      uiData.setCompareType(CompareType.COMPARE_CURRENTS_AGAINST_PARENT);
    } else {
      uiData.setCompareType(CompareType.COMPARE_CURRENTS_AGAINST_OTHER_BRANCH);
    }
  }
  /** 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 static String constructConfirmMessage(Branch sourceBranch, List<Branch> branches)
      throws OseeCoreException {
    StringBuilder sb = new StringBuilder();
    String ending = "";
    String beginning = "";

    sb.append("Are you sure you want to delete the merge ");
    if (branches.size() > 1) {
      beginning = "branches:\n";
      ending = "\n\nAll merged conflicts for these branches will be lost.";
    } else {
      beginning = "branch:\n";
      ending = "\n\nAll merged conflicts for this branch will be lost.";
    }
    sb.append(beginning);
    for (Branch branch : branches) {
      MergeBranch mergeBranch = BranchManager.getMergeBranch(sourceBranch, branch);
      sb.append(mergeBranch);
      sb.append("\n");
    }
    sb.append(ending);

    return sb.toString();
  }
Exemple #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());
  }
 private static void doDelete(Branch sourceBranch, Branch destBranch) throws OseeCoreException {
   if (BranchManager.hasMergeBranches(sourceBranch)) {
     MergeBranch mergeBranch = BranchManager.getMergeBranch(sourceBranch, destBranch);
     BranchManager.purgeBranch(mergeBranch);
   }
 }
 @Override
 public IOseeBranch adapt(Attribute<?> attribute, Identity<String> identity)
     throws OseeCoreException {
   String uuid = identity.getGuid();
   return Strings.isNumeric(uuid) ? BranchManager.getBranchByUuid(Long.valueOf(uuid)) : null;
 }
 /** 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));
 }