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; }
/** * 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>"); }
public InternalNode addInternalNode(Label label) { String id = nodeIdFactory.getNodeId(label.getUri()); InternalNode node = new InternalNode(id, label); if (this.graphBuilder.addNodeAndUpdate(node)) return node; return null; }
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))
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>"); }
String nodeId; nodeId = nodeIdFactory.getNodeId(domainUri); source = new InternalNode(nodeId, new Label(domainUri)); if (!this.graphBuilder.addNodeAndUpdate(source, addedNodes)) return null;
String nodeId; nodeId = nodeIdFactory.getNodeId(domainUri); source = new InternalNode(nodeId, new Label(domainUri)); if (!this.graphBuilder.addNodeAndUpdate(source, addedNodes)) return 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());
String id = this.nodeIdFactory.getNodeId(source.getLabel().getUri()); InternalNode node = new InternalNode(id, new Label(source.getLabel())); if (this.graphBuilder.addNode(node)) { String id = nodeIdFactory.getNodeId(target.getLabel().getUri()); InternalNode node = new InternalNode(id, new Label(target.getLabel())); if (this.graphBuilder.addNode(node)) { 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)) {
String id = this.nodeIdFactory.getNodeId(node.getUri()); InternalNode newNode = new InternalNode(id, node.getLabel());