Exemplo n.º 1
0
  /** Asserts parenthood for this AEP */
  public void assertParenthood(CompoundCommand tgtCmd) {
    final ArtifactEditPart thisAEP = this;
    Artifact thisArt = thisAEP.getArtifact().getArt();
    ReloController rc = getRootController();

    // logger.info("assertParenthood: " + thisAEP);

    for (Artifact child : thisArt.queryChildrenArtifacts(thisAEP.getRepo())) {
      final ArtifactEditPart childEP = rc.findArtifactEditPart(child);
      if (childEP == null) continue;

      final ArtifactEditPart oldParentEP = (ArtifactEditPart) childEP.getParent();

      Command reparentCmd = new ReparentCommand(childEP, thisAEP, oldParentEP);

      if (oldParentEP instanceof ReloController) {
        // was at the top level before
        tgtCmd.add(reparentCmd);
        continue;
      }

      ArtifactEditPart oldParentAEP = (ArtifactEditPart) oldParentEP;

      // want to do: if (oldParentAEP == thisAEP) continue;
      //      need to do this otherwise we will have infinite loops
      // we also need to take into account derived code units as well

      // @tag post-rearch-verify
      if (oldParentAEP
          .getArtifact()
          .getNonDerivedBaseArtifact()
          .equals(thisAEP.getArtifact().getNonDerivedBaseArtifact())) {
        continue;
      }

      tgtCmd.add(reparentCmd);
    }
  }