コード例 #1
0
  @Requires(IRepositoryConfig.CAPABILITY_AUDITING)
  public void testReloadingRevisions() throws Exception {
    final String RESOURCE_NAME = "resource";

    Set<CDOID> ids = new HashSet<CDOID>();
    long timeStampOfHoleCommit;

    CDOSession initialSession = openSession();
    {
      // create model history
      CDOTransaction openTransaction = initialSession.openTransaction();
      CDOResource resource = openTransaction.getOrCreateResource(getResourcePath(RESOURCE_NAME));

      // creating initial commit
      Company createdCompany = getModel1Factory().createCompany();
      createdCompany.setName("CompanyTesting");
      createdCompany.setCity("City");
      createdCompany.setStreet("Street");

      resource.getContents().add(createdCompany);

      openTransaction.commit();

      // collect id's
      for (TreeIterator<EObject> allContents = resource.getAllContents(); allContents.hasNext(); ) {
        CDOObject next = CDOUtil.getCDOObject(allContents.next());
        ids.add(next.cdoID());
      }

      // making holes - detaching
      List<EObject> contents = new ArrayList<EObject>(resource.getContents());
      for (int i = 0; i < contents.size(); i++) {
        EcoreUtil.delete(contents.get(i), true);
      }

      timeStampOfHoleCommit = openTransaction.commit().getTimeStamp();
    }

    // check when locally cached elements are availabe
    checkRevisionsOnGivenSession(ids, timeStampOfHoleCommit, 2, initialSession);

    // turn of revision download by timestamp
    checkRevisionsOnGivenSession(ids, -1, 2, initialSession);
    initialSession.close();

    checkRevisions(ids, timeStampOfHoleCommit, 2);

    // turn of revision download by timestamp
    checkRevisions(ids, -1, 2);

    // clear caches
    clearCache(getRepository().getRevisionManager());
    checkRevisions(ids, timeStampOfHoleCommit, 2);

    // turn of revision download by timestamp
    clearCache(getRepository().getRevisionManager());
    checkRevisions(ids, -1, 2);
  }
コード例 #2
0
  /**
   * Deletes an EObject, while exceptions are handled with the values specified.
   *
   * @param eObject the EObject to delete
   * @param exceptionLog the current log of exceptions
   * @param ignoreAndLog should exceptions be ignored and added to <code>exceptionLog</code>?
   * @see EcoreUtil#delete(EObject)
   */
  public static void delete(
      EObject eObject, Set<RuntimeException> exceptionLog, boolean ignoreAndLog) {
    try {
      EcoreUtil.delete(eObject, true);

    } catch (RuntimeException e) {
      handle(e, exceptionLog, ignoreAndLog);
    }
  }
コード例 #3
0
 protected boolean removeFeatureEAnnotation(String featureID) {
   EModelElement element = getElement();
   EAnnotation eAnnotation = element.getEAnnotation(featureID);
   if (eAnnotation != null) {
     EcoreUtil.delete(eAnnotation);
     cleanCachedValueForFeature(featureID);
     return true;
   }
   return false;
 }
コード例 #4
0
  @Override
  public void removeRepository(IPapyrusRepository repository) {
    if (repository.isConnected()) {
      throw new IllegalArgumentException("repository is still connected"); // $NON-NLS-1$
    }

    repositories.remove(repository.getURL());
    EcoreUtil.delete(((PapyrusRepository) repository).getModel());

    fireElementRemovedEvent(repository);
  }
コード例 #5
0
 @Override
 protected boolean internalDoUndo() {
   boolean close = DiagramPartitioningUtil.closeSubdiagramEditors((State) subdiagram.getElement());
   if (!close) return false;
   // Since the canonical edit policy creates edges for the semantic
   // transitions and it is not done within the TransactionalCommand we
   // have to delete the created edges manually when undo is executed.
   while (subdiagram.getEdges().size() > 0) {
     EcoreUtil.delete((EObject) subdiagram.getEdges().get(0));
   }
   return true;
 }
コード例 #6
0
  @Lock(LockType.WRITE)
  public Object remove(String id) {
    if (store.get(id) == null) {
      EObject obj = getEObjectByID(id);
      store.put(id, obj);
    }
    EObject obj = store.get(id);
    if (validation.getFlag()) {
      Diagnostic d = Diagnostician.INSTANCE.validate(obj);
      if (d.getSeverity() == Diagnostic.ERROR)
        throw new WebApplicationException(Status.BAD_REQUEST);
    }

    EcoreUtil.delete(obj);
    store.remove(id);
    try {
      resourceLoader.getResource().save(Collections.EMPTY_MAP);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return null;
  }
コード例 #7
0
  @Override
  public void postComparison(final Comparison comparison, Monitor monitor) {
    // Create DBDiffs
    new DatabaseDiffExtension().visit(comparison);

    // Delete all empty DBDiffs
    final DiffContentService service = new DiffContentService();
    Collection<Diff> toDelete =
        Collections2.filter(
            comparison.getDifferences(),
            new Predicate<Diff>() {

              public boolean apply(Diff input) {
                return input instanceof DBDiff
                    && service.getSubDiffs(input, comparison).isEmpty()
                    && input.getRefinedBy().isEmpty();
              }
            });
    for (Diff diff : toDelete) {
      // It could be optimized doing diff.eContainer().eContents().delete(diff) since no object
      // references it.
      EcoreUtil.delete(diff);
    }
  }
コード例 #8
0
  public void execute(ICustomContext context) {
    File file = getFileDomainObject(context);

    EcoreUtil.delete(file);
  }
コード例 #9
0
ファイル: EcoreExtension.java プロジェクト: sculptor/base
 /** Recursively removes the model element from the model. */
 public static void delete(final EObject o) {
   EcoreUtil.delete(o, true);
 }