public LiteralNode addLiteralNode(String nodeId, String value, String type, String language, boolean isUri) { type = type.replace(Prefixes.XSD + ":", Namespaces.XSD); Label literalType = new Label(type, Namespaces.XSD, Prefixes.XSD); String id = nodeId; if(isUri && value.startsWith("\"") && value.endsWith("\"")) value = value.substring(1, value.length()-1); LiteralNode node = new LiteralNode(id, value, literalType, language, isUri); if(this.graphBuilder.addNode(node)) return node; return null; }
if (!this.graphBuilder.addNode(target)) return null; addedNodes.add(target);
public LiteralNode addLiteralNode(String value, String type, String language, boolean isUri) { type = type.replace(Prefixes.XSD + ":", Namespaces.XSD); Label literalType = new Label(type, Namespaces.XSD, Prefixes.XSD); String id = nodeIdFactory.getNodeId(value); if(isUri && value.startsWith("\"") && value.endsWith("\"")) value = value.substring(1, value.length()-1); LiteralNode node = new LiteralNode(id, value, literalType, language, isUri); if(this.graphBuilder.addNode(node)) return node; return null; }
if (!this.graphBuilder.addNode(target)) return null; addedNodes.add(target);
public boolean addNode(Node node) { if (super.addNode(node)) { SteinerNode n = new SteinerNode(node.getId()); getTopKGraphNodes().put(n.getNodeId(), n); getTopKGraph().put(n, new TreeSet<SteinerEdge>()); return true; } else return false; }
/** * 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>"); }
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); } } }
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);
public boolean addNodeAndUpdate(Node node, Set<Node> addedNodes) { ModelingConfiguration modelingConfiguration = ModelingConfigurationRegistry.getInstance().getModelingConfiguration(ContextParametersRegistry.getInstance().getContextParameters(ontologyManager.getContextId()).getKarmaHome()); boolean result = addNode(node); if (!result) return result; if (!modelingConfiguration.getOntologyAlignment()) return result; if (addedNodes == null) addedNodes = new HashSet<>(); addedNodes.add(node); if (node instanceof InternalNode) addClosureAndUpdateLinks((InternalNode)node, addedNodes); return result; }
c.getHNodeId(), c.getColumnName(), c.getRdfLiteralType(), c.getLanguage()); if (this.graphBuilder.addNode(newNode)) { columnNodeMapping.put(n, newNode);
private void initialGraph() { logger.debug("<enter"); ModelingConfiguration modelingConfiguration = ModelingConfigurationRegistry.getInstance().getModelingConfiguration(ContextParametersRegistry.getInstance().getContextParameters(ontologyManager.getContextId()).getKarmaHome()); // Add Thing to the Graph if (modelingConfiguration.getThingNode()) { String id = nodeIdFactory.getNodeId(Uris.THING_URI); Label label = new Label(Uris.THING_URI, Namespaces.OWL, Prefixes.OWL); Node thing = new InternalNode(id, label); addNode(thing); } logger.debug("exit>"); }
if (!this.graphBuilder.addNode(target)) continue;; addedNodes.add(target);
if (!this.graphBuilder.addNode(target)) continue;; addedNodes.add(target);
return null; if (this.graphBuilder.addNode(newNode)) { String linkId = LinkIdFactory.getLinkId(incomingLink.getUri(), m.getId(), newNode.getId()); DataPropertyLink link = new DataPropertyLink(linkId, new Label(incomingLink.getLabel()));
this.addNode(node);
String id = this.nodeIdFactory.getNodeId(source.getLabel().getUri()); InternalNode node = new InternalNode(id, new Label(source.getLabel())); if (this.graphBuilder.addNode(node)) { n1 = node; } else continue; String id = new RandomGUID().toString(); ColumnNode node = new ColumnNode(id, id, ((ColumnNode)target).getColumnName(), null, null); if (this.graphBuilder.addNode(node)) { n1 = node; } else continue; String id = nodeIdFactory.getNodeId(target.getLabel().getUri()); InternalNode node = new InternalNode(id, new Label(target.getLabel())); if (this.graphBuilder.addNode(node)) { n2 = node; } else continue; String id = nodeIdFactory.getNodeId(lTarget.getValue()); LiteralNode node = new LiteralNode(id, lTarget.getValue(), new Label(target.getLabel()), lTarget.getLanguage(), lTarget.isUri()); if (this.graphBuilder.addNode(node)) { n2 = node; } else continue; String id = new RandomGUID().toString(); ColumnNode node = new ColumnNode(id, id, ((ColumnNode)target).getColumnName(), null, null); if (this.graphBuilder.addNode(node)) { n2 = node; } else continue;
InternalNode newNode = new InternalNode(id, node.getLabel()); if (!this.addNode(newNode)) { logger.error("could not add the new node " + newNode.getId()); return null;