Esempio n. 1
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>());
      }
    }
  }
 @Before
 public void setup() throws Exception {
   artifact =
       ArtifactTypeManager.addArtifact(
           CoreArtifactTypes.GeneralDocument,
           DemoBranches.SAW_Bld_1,
           method.getQualifiedTestName());
   artifact.setAttributeValues(CoreAttributeTypes.StaticId, START_VALUE);
 }
Esempio n. 3
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;
 }
Esempio n. 4
0
  private synchronized void updateExtractedElements() {
    selectionLatch.setCurrentValues(getDestinationArtifact(), getSourceFile(), getArtifactParser());
    if (selectionLatch.areSelectionsValid()) {
      selectionLatch.latch();

      collector.reset();

      final Artifact destinationArtifact = selectionLatch.currentSelected.destinationArtifact;
      final File sourceFile = selectionLatch.currentSelected.sourceFile;
      final IArtifactExtractor extractor = selectionLatch.currentSelected.extractor;

      operationReportMessages.setLength(0);

      IOperation op =
          ArtifactImportOperationFactory.createArtifactsCompOperation(
              "Extracting data from source",
              sourceFile,
              destinationArtifact,
              new OperationLogger() {
                @Override
                public void log(String... row) {
                  for (String warningMessage : row) {
                    operationReportMessages.append(warningMessage);
                  }
                };
              },
              extractor,
              collector,
              selectedArtifactTypes,
              true);

      selectedArtifactTypes.clear();

      if (executeOperation(op)) {
        artifactTypeSelectPanel.setAllowedArtifactTypes(selectedArtifactTypes);
        try {
          if (getArtifactType() != null) {
            ArtifactType specificArtifactType = ArtifactTypeManager.getType(getArtifactType());
            attributeTypeSelectPanel.setAllowedAttributeTypes(
                specificArtifactType.getAttributeTypes(getDestinationArtifact().getFullBranch()));
          }
        } catch (Exception ex) {
          OseeLog.log(Activator.class, Level.SEVERE, ex);
        }
      }
    }
  }
  /** 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();
  }
 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;
 }
  private void loadIsValues(
      Branch sourceBranch,
      Set<Integer> artIds,
      ArrayList<ChangeBuilder> changeBuilders,
      Set<Integer> newAndDeletedArtifactIds,
      IProgressMonitor monitor,
      Map<Integer, ChangeBuilder> attributesWasValueCache,
      Map<Integer, ModificationType> artModTypes,
      Set<Integer> modifiedArtifacts,
      IOseeStatement chStmt,
      boolean hasBranch,
      long time,
      TransactionRecord fromTransactionId,
      TransactionRecord toTransactionId,
      boolean hasSpecificArtifact)
      throws OseeCoreException {
    ModificationType artModType;
    AttributeChangeBuilder attributeChangeBuilder;

    try {
      TransactionDelta txDelta = new TransactionDelta(fromTransactionId, toTransactionId);

      while (chStmt.next()) {
        int attrId = chStmt.getInt("attr_id");
        int artId = chStmt.getInt("art_id");
        int sourceGamma = chStmt.getInt("gamma_id");
        int attrTypeId = chStmt.getInt("attr_type_id");
        int artTypeId = chStmt.getInt("art_type_id");
        String isValue = chStmt.getString("is_value");
        ModificationType modificationType = ModificationType.getMod(chStmt.getInt("mod_type"));

        if (artModTypes.containsKey(artId)) {
          artModType = artModTypes.get(artId);
        } else {
          artModType = ModificationType.MODIFIED;
        }

        // This will be false iff the artifact was new and then deleted
        if (!newAndDeletedArtifactIds.contains(artId)) {
          // Want to add an artifact changed item once if any attribute was modified && artifact was
          // not
          // NEW or DELETED and these changes are not for a specific artifact
          if (artModType == ModificationType.MODIFIED && !modifiedArtifacts.contains(artId)) {

            ArtifactChangeBuilder artifactChangeBuilder =
                new ArtifactChangeBuilder(
                    sourceBranch,
                    ArtifactTypeManager.getType(artTypeId),
                    -1,
                    artId,
                    txDelta,
                    ModificationType.MODIFIED,
                    !hasBranch);

            changeBuilders.add(artifactChangeBuilder);
            modifiedArtifacts.add(artId);
          }

          // ModTypes will be temporarily set to new and then revised for based on the existence of
          // a was value
          if (modificationType == ModificationType.MODIFIED
              && artModType != ModificationType.INTRODUCED) {
            modificationType = ModificationType.NEW;
          }
          IArtifactType artifactType = ArtifactTypeManager.getType(artTypeId);
          AttributeType attributeType = AttributeTypeManager.getType(attrTypeId);
          attributeChangeBuilder =
              new AttributeChangeBuilder(
                  sourceBranch,
                  artifactType,
                  sourceGamma,
                  artId,
                  txDelta,
                  modificationType,
                  !hasBranch,
                  isValue,
                  "",
                  attrId,
                  attributeType,
                  artModType);

          changeBuilders.add(attributeChangeBuilder);
          attributesWasValueCache.put(attrId, attributeChangeBuilder);
          artIds.add(artId);
        }
      }

      if (getMonitor() != null) {
        monitor.worked(13);
        monitor.subTask("Gathering Was values");
      }
    } finally {
      chStmt.close();
    }
  }