Esempio n. 1
0
 public void setPrimarySubcomponent(Component sub) {
   if (null != sub && null != sub.getPath() && null != sub.getDelegate()) {
     this.primarySubcomponent = sub;
   }
   // System.err.println(this.getPath()+"("+this.getDelegate().getId()+")'s *primary* subcomponent:
   // "+sub.getPath()+"("+sub.getDelegate().getId()+")");
 }
Esempio n. 2
0
 public void setSecondarySubcomponent(Collection<Component> subs) {
   for (Component sub : subs) {
     if (null != sub && null != sub.getPath() && null != sub.getDelegate()) {
       this.secondarySubcomponents.add(sub);
     }
     // System.err.println(this.getPath()+"("+this.getDelegate().getId()+")'s secondary
     // subcomponent: "+sub.getPath()+"("+sub.getDelegate().getId()+")");
   }
 }
Esempio n. 3
0
  /**
   * @param out
   * @param indent
   */
  private void describe(PrintStream out, String indent) {

    out.print(
        "\n"
            + indent
            + "When "
            + getPath()
            + "'s delegate <"
            + getDelegate().getId()
            + "> was removed,\n"
            + indent
            + "   it  flung  "
            + getLeafs().size()
            + " individual nodes\n"
            + indent
            + "   and caused "
            + getSubcomponents().size()
            + " isolated connected components:\n");

    // Primary
    if (null != getPrimarySubcomponent()) {
      out.print(indent + "       " + getPrimarySubcomponent().getPath());
      getPrimarySubcomponent().describe(out, indent + "       ");
    } else {
      // out.println(indent+"      (no primary subcomponent) "+getPrimarySubcomponent());
    }

    // Secondary
    if (getSecondarySubcomponents().size() > 0) {
      for (Component sub : getSecondarySubcomponents()) {
        out.print(indent + "       " + sub.getPath());
        sub.describe(out, indent + "       ");
      }
    } else {
      // out.println(indent+"      (no secondary subcomponents) "+getSubcomponents());
    }
  }
Esempio n. 4
0
  /**
   * @param base - grows with each call down.
   * @param indent -
   * @param conn -
   * @param reportR - named graph to write into.
   * @param out -
   * @param root - stays the same, so each node can point to its root.
   */
  private void describe(
      String base,
      String indent,
      RepositoryConnection conn,
      Resource reportR,
      PrintStream out,
      Resource root) {

    out.print(
        "\n"
            + indent
            + "When "
            + getPath()
            + "'s delegate <"
            + getDelegate().getId()
            + "> was removed,\n"
            + indent
            + "   it  flung  "
            + getLeafs().size()
            + " individual nodes\n"
            + indent
            + "   and caused "
            + getSubcomponents().size()
            + " isolated connected components:\n");

    Resource component = vf.createURI(base + "/" + getPath());
    try {
      conn.add(component, RDF.a, PROVO.Collection, reportR);
      if (this.removalDepth == 0) {
        conn.add(component, RDF.a, VSR.Root, reportR);
        root = component;
      }
      conn.add(component, Centrifuge.hasRoot, root, reportR);
      conn.add(component, DCTerms.identifier, vf.createLiteral(getPath()), reportR);
      conn.add(
          component,
          PROVO.specializationOf,
          vf.createURI(this.delegate.getId().toString()),
          reportR);
      conn.add(component, VSR.depth, vf.createLiteral(this.removalDepth), reportR);

      for (Vertex leaf : this.getLeafs()) {
        Resource leafR = vf.createURI(leaf.getId().toString());
        conn.add(component, DCTerms.hasPart, leafR, reportR);
      }
    } catch (RepositoryException e) {
      e.printStackTrace();
    }

    // Primary
    if (null != getPrimarySubcomponent()) {
      out.print(indent + "       " + getPrimarySubcomponent().getPath());
      try {
        Resource subR = vf.createURI(base + "/" + getPrimarySubcomponent().getPath());
        conn.add(component, DCTerms.hasPart, subR, reportR);
        conn.add(subR, RDF.a, Centrifuge.Primary, reportR);
        conn.add(subR, RDF.a, PROVO.Collection, reportR);
        conn.add(
            subR,
            DCTerms.identifier,
            vf.createLiteral(getPrimarySubcomponent().getPath()),
            reportR);
      } catch (RepositoryException e) {
        e.printStackTrace();
      }
      getPrimarySubcomponent().describe(base, indent + "       ", conn, reportR, out, root);
    } else {
      // out.println(indent+"      (no primary subcomponent) "+getPrimarySubcomponent());
    }

    // Secondary
    if (getSecondarySubcomponents().size() > 0) {
      for (Component sub : getSecondarySubcomponents()) {
        Resource subR = vf.createURI(base + "/" + sub.getPath());
        try {
          conn.add(component, DCTerms.hasPart, subR, reportR);
        } catch (RepositoryException e) {
          e.printStackTrace();
        }
      }
      for (Component sub : getSecondarySubcomponents()) {
        Resource subR = vf.createURI(base + "/" + sub.getPath());
        try {
          conn.add(subR, RDF.a, Centrifuge.Secondary, reportR);
          conn.add(subR, RDF.a, PROVO.Collection, reportR);
          conn.add(
              subR,
              DCTerms.identifier,
              vf.createLiteral(getPrimarySubcomponent().getPath()),
              reportR);
          conn.commit();
        } catch (RepositoryException e) {
          e.printStackTrace();
        }
      }

      for (Component sub : getSecondarySubcomponents()) {
        out.print(indent + "       " + sub.getPath());
        sub.describe(base, indent + "       ", conn, reportR, out, root);
      }
    } else {
      // out.println(indent+"      (no secondary subcomponents) "+getSubcomponents());
    }
  }