コード例 #1
0
  private void addSavedUserCreatedNodes(
      ArtifactFragment parent,
      Resource instanceRes,
      Resource modelRes,
      Map<Resource, ArtifactFragment> instanceRes2AFMap,
      ReloRdfRepository repo) {
    ArtifactFragment childToAdd =
        SeqUtil.createAFForSavedResources(
            repo, modelRes, instanceRes, parent, (DiagramModel) getModel());
    if (childToAdd == null)
      logger.error("Could not create model for " + instanceRes + "in parent " + parent);

    // Add AF to parent and call same method with child
    int indexWhenSaved = findSavedIndex(repo, instanceRes);
    List<ArtifactFragment> childrenAddedToParent = parent.getShownChildren();
    if (parent instanceof DiagramModel)
      childrenAddedToParent = ((DiagramModel) parent).getChildren();
    else if (parent instanceof UserCreatedInstanceModel)
      childrenAddedToParent = ((NodeModel) parent).getChildren();

    int indexToAddAt = getCurrentIndex(indexWhenSaved, repo, childrenAddedToParent);
    parent.appendShownChild(childToAdd, indexToAddAt);
    instanceRes2AFMap.put(instanceRes, childToAdd);

    for (DiagramPolicy pol : childToAdd.getDiagramPolicies()) pol.readRDF(repo);

    addSavedContainee(childToAdd, instanceRes, instanceRes2AFMap, repo);
  }
コード例 #2
0
  private void addSavedCodeRes(
      ArtifactFragment parent,
      Resource codeRes,
      Map<Resource, ArtifactFragment> instanceRes2AFMap,
      ReloRdfRepository repo)
      throws Exception {
    ArtifactFragment childToAdd = SeqUtil.createChronoModelForResource(codeRes, parent, repo, this);
    if (childToAdd == null)
      throw new Exception("Could not create model for resource: " + codeRes.toString());

    if (parent instanceof DiagramModel) instanceResToAF.put(codeRes, childToAdd);

    //		Statement indexWhenSavedStmt = repo.getStatement(codeRes, RJCore.index, null);
    //		int indexWhenSaved = (indexWhenSavedStmt == null || indexWhenSavedStmt.getObject() == null)
    // ? -1 : Integer.parseInt(indexWhenSavedStmt.getObject().toString());
    int indexWhenSaved = findSavedIndex(repo, codeRes);
    //		int indexToAddAt = -1;

    List<ArtifactFragment> childrenAddedToParent = parent.getShownChildren();
    if (parent instanceof DiagramModel)
      childrenAddedToParent = ((DiagramModel) parent).getChildren();
    else if (parent instanceof NodeModel)
      childrenAddedToParent = ((NodeModel) parent).getChildren();
    //		for(ArtifactFragment addedChild : childrenAddedToParent) {
    //
    //			Resource addedChildSaveRes = addedChild.getInstanceRes();
    //			Statement addedChildIndexWhenSavedStmt = repo.getStatement(addedChildSaveRes, RJCore.index,
    // null);
    //			int addedChildIndexWhenSaved = -1;
    //			if(addedChildIndexWhenSavedStmt.getObject()!=null)
    //				addedChildIndexWhenSaved =
    // Integer.parseInt(addedChildIndexWhenSavedStmt.getObject().toString());
    //
    //			if(indexWhenSaved>-1 && indexWhenSaved<addedChildIndexWhenSaved)
    //				indexToAddAt = childrenAddedToParent.indexOf(addedChild);
    //		}
    int indexToAddAt = getCurrentIndex(indexWhenSaved, repo, childrenAddedToParent);
    parent.appendShownChild(childToAdd, indexToAddAt);
    instanceRes2AFMap.put(codeRes, childToAdd);

    for (DiagramPolicy pol : childToAdd.getDiagramPolicies()) {
      pol.readRDF(repo);
    }

    addSavedContainee(childToAdd, codeRes, instanceRes2AFMap, repo);
  }