public List<Node> getNodeClosure(Node node) { List<Node> nodeClosure = new ArrayList<>(); if (node instanceof ColumnNode) return nodeClosure; String uri = node.getUri(); Set<String> closure = this.uriClosure.get(uri); if (closure == null) { // the closure has already been computed. closure = computeUriClosure(uri); } for (String s : closure) { Set<Node> nodes = uriToNodesMap.get(s); if (nodes != null) nodeClosure.addAll(nodes); } return nodeClosure; }
for (Node n : sortedNodes) { if (n instanceof InternalNode) { uri = n.getUri(); List<Node> sortedMatchedNodes = uriMatchedNodes.get(uri); if (sortedMatchedNodes == null) { List<Node> sortedMatchedNodes = uriMatchedNodes.get(n.getUri()); internalNodeMapping.put(n, sortedMatchedNodes.get(0)); sortedMatchedNodes.remove(0);
private void addInternalNodes(SemanticModel model, Set<InternalNode> addedNodes) { if (model == null || model.getGraph() == null) return; if (addedNodes == null) addedNodes = new HashSet<>(); HashMap<String, Integer> uriCount = new HashMap<>(); for (Node n : model.getGraph().vertexSet()) { if (n instanceof InternalNode) { Integer count = uriCount.get(n.getUri()); if (count == null) uriCount.put(n.getUri(), 1); else uriCount.put(n.getUri(), count.intValue() + 1); } } for (Map.Entry<String, Integer> stringIntegerEntry : uriCount.entrySet()) { int modelNodeCount = stringIntegerEntry.getValue(); Set<Node> matchedNodes = this.graphBuilder.getUriToNodesMap().get(stringIntegerEntry.getKey()); int graphNodeCount = matchedNodes == null ? 0 : matchedNodes.size(); for (int i = 0; i < modelNodeCount - graphNodeCount; i++) { String id = this.nodeIdFactory.getNodeId(stringIntegerEntry.getKey()); Node n = new InternalNode(id, new Label(stringIntegerEntry.getKey())); if (this.graphBuilder.addNode(n)) addedNodes.add((InternalNode)n); } } }
for (Node n : model.getGraph().vertexSet()) { if (n instanceof InternalNode) { Integer count = uriCount.get(n.getUri()); if (count == null) uriCount.put(n.getUri(), 1); else uriCount.put(n.getUri(), count.intValue() + 1); Set<Node> matchedNodes = this.graphBuilder.getUriToNodesMap().get(n.getUri()); internalNodeMatches.put(n, matchedNodes);
/** * returns all the new nodes that should be added to the graph due to adding the input node * @param node * @param closure: contains all the nodes that are connected to the input node * by ObjectProperty or SubClass links * @return */ private void addNodeClosure(Node node, Set<Node> newAddedNodes) { logger.debug("<enter"); if (newAddedNodes == null) newAddedNodes = new HashSet<>(); String uri = node.getUri(); if (this.uriClosure.get(uri) != null) // the closure is already computed and added to the graph. return; Set<String> uriClosure = computeUriClosure(uri); for (String c : uriClosure) { Set<Node> nodesOfSameUri = this.uriToNodesMap.get(c); if (nodesOfSameUri == null || nodesOfSameUri.isEmpty()) { // the internal node is not added to the graph before Node nn = new InternalNode(nodeIdFactory.getNodeId(c), ontologyManager.getUriLabel(c)); if (addNode(nn)) newAddedNodes.add(nn); } } logger.debug("exit>"); }
Set<Node> nodesWithSameUri = uriToNodesMap.get(node.getUri()); if (nodesWithSameUri != null) nodesWithSameUri.remove(node);
public static HashMap<SemanticType, LabeledLink> getDomainLinks(DirectedGraph<Node, DefaultLink> g, ColumnNode n, List<SemanticType> semanticTypes) { HashMap<SemanticType, LabeledLink> domainLinks = new HashMap<>(); if (g == null || n == null || semanticTypes == null || !g.vertexSet().contains(n)) return domainLinks; Set<DefaultLink> incomingLinks = g.incomingEdgesOf(n); if (incomingLinks != null) { for (SemanticType st : semanticTypes) { for (DefaultLink l : incomingLinks) { if (st.getDomain().getUri().equalsIgnoreCase(l.getSource().getUri()) && st.getType().getUri().equalsIgnoreCase(l.getUri())) { if (l instanceof LabeledLink) domainLinks.put(st, (LabeledLink)l); } } } } return domainLinks; }
sourceObject.put(Arguments.uri.name(), property.getSource().getUri()); sourceObject.put(Arguments.id.name(), property.getSource().getId()); sourceObject.put(Arguments.label.name(), property.getSource().getLabel().getDisplayName()); targetObject.put(Arguments.uri.name(), property.getTarget().getUri()); targetObject.put(Arguments.id.name(), property.getTarget().getId()); targetObject.put(Arguments.label.name(), property.getTarget().getLabel().getDisplayName());
String uri = node.getUri(); Label label = this.ontologyManager.getUriLabel(uri); if (label == null) { Set<Node> nodesWithSameUri = uriToNodesMap.get(node.getUri()); if (nodesWithSameUri == null) { nodesWithSameUri = new HashSet<>(); uriToNodesMap.put(node.getUri(), nodesWithSameUri); this.modelIds.addAll(node.getModelIds()); this.uriClosure.put(node.getUri(), null);
if(link != null) { initialEdge.put(LinkJsonKeys.edgeSourceId.name(), link.getSource().getId()); initialEdge.put(LinkJsonKeys.edgeSourceUri.name(), link.getSource().getUri()); newEdge.put(LinkJsonKeys.edgeSourceId.name(), link.getSource().getId()); newEdge.put(LinkJsonKeys.edgeSourceUri.name(), link.getSource().getUri());
key = source.getUri() + link.getUri(); Set<SemanticTypeMapping> SemanticTypeMappings = this.semanticTypeMatches.get(key); if (SemanticTypeMappings == null) {
nodeIdFactory.getNodeId(node.getUri());
for (Node n : baseModel.getGraph().vertexSet()) { if (n instanceof InternalNode) baseNodeIds.put(n, nodeIdFactory.getNodeId(n.getUri())); else // n is a column node baseNodeIds.put(n, n.getId());
e instanceof LabeledLink) { LabeledLink l = (LabeledLink)e; Set<Node> nodesWithSourceUri = this.graphBuilder.getUriToNodesMap().get(source.getUri()); Set<Node> nodesWithTargetUri = this.graphBuilder.getUriToNodesMap().get(target.getUri()); if (nodesWithSourceUri == null || nodesWithTargetUri == null) continue; for (Node nn1 : nodesWithSourceUri) {