/** * Create a new anchor for the given node, specifying which relations it must or can have. * Relations whose maximum cardinality constraint is already fullfilled are not added to the menu. * * @param r OntologyReader to extract information from ontology * @param c OntClass corresponding to this anchor * @param n SGNode for which this anchor is created * @param query true if this is an anchor for a node in the QueryGraph * @param userID UserID * @throws BadAnchorException if the given SGNode does not need an anchor */ public Anchor(OntologyReader r, OntClass c, SGNode n, boolean query, String userID) throws BadAnchorException { node = n; this.query = query; if (node.getAnchor() != null) id = node.getAnchor().getID(); else id = UUID.randomUUID().toString(); reader = r; if (n instanceof SGDateNode) throw new BadAnchorException("A date does not need an anchor"); node.setAnchor(this); // tell the node it has an anchor setURI(userID); if (addShowOrHideOption() == SGNode.NEW) init(c, query); // only make extensive anchors for newly created nodes }