public void realizeParent(CompoundCommand tgtCmd) { // logger.info("realizeParent: " + this); // logger.info(this.getClass().getName() + " .realizeParent() - parent: " + parent // + " / findEditPart(parent): " + findEditPart(parent)); if (getModel() instanceof DerivedArtifact) return; final Artifact parentArt = getArtifact().getArt().queryParentArtifact(getBrowseModel().getRepo()); if (parentArt == null) return; final ReloController rc = getRootController(); ArtifactEditPart parentEP = (ArtifactEditPart) findEditPart(parentArt); if (parentEP != null) { parentEP.assertParenthood(tgtCmd); return; } if (!rc.artCreatable(parentArt)) return; // check if browse model will allow // parentEP = null and it is creatable tgtCmd.add(new CreateParentCommand(this, "create parent and assert parenthood", parentArt, rc)); return; }
/** * Ensures that all elements on a valid path (given by rel) are shown Note: src.rel.tgt && * src!=tgt has to be true * * @param rel - join defining valid paths */ public void showPathElements(JoinedRelType rel) { Artifact curArt = getArtifact().getArt(); if (!isActive()) { log("not active"); return; } logBeg("showPathElements"); ReloController rc = getRootController(); for (ArtifactEditPart visEP : rc.getVisibleNonDerivedArtifactEditParts()) { Artifact visArt = visEP.getArtifact().getArt(); if (curArt.equals(visArt)) continue; // ObjectPair examiningPair = new ObjectPair(this, visEP); for (List<Artifact> resultSetVar : rel.getPaths(getRepo(), curArt, visArt)) { for (Artifact resultArt : resultSetVar) { rc.createOrFindArtifactEditPart(resultArt); } } // flip order of pair (everything else is identical for (List<Artifact> resultSetVar : rel.getPaths(getRepo(), visArt, curArt)) { for (Artifact resultArt : resultSetVar) { rc.createOrFindArtifactEditPart(resultArt); } } } logEnd(); }
// TODO: review public void realizeChildrenArtifacts(List<Artifact> lst) { ReloController rc = (ReloController) getRoot().getContents(); for (Artifact child : lst) { rc.getRootArtifact().addVisibleArt(child); } }
public void showAllDirectRelation( CompoundCommand tgtCmd, final DirectedRel rel, Predicate filter) { try { ReloController rc = getRootController(); Map<Artifact, ArtifactFragment> addedArtToAF = new HashMap<Artifact, ArtifactFragment>(); for (final Artifact relCU : getArtifact().getArt().queryArtList(getRepo(), rel, filter)) { if (rc.canAddRel(getArtifact(), rel, relCU)) { AddNodeAndRelCmd addCmd = new AddNodeAndRelCmd( rc, ArtifactEditPart.this.getArtFrag(), rel, relCU, addedArtToAF); tgtCmd.add(addCmd); ((ReloDoc) rc.getRootArtifact()) .showIncludedRelationships(tgtCmd, addCmd.getNewArtFrag()); } } } catch (Throwable t) { logger.error("Unexpected exception", t); } }
/** 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); } }