private void addLinks(Set<LabeledLink> links) { if (links == null) return; for (LabeledLink link : links) { if (!this.tree.containsEdge(link) && this.tree.containsVertex(link.getSource()) && this.tree.containsVertex(link.getTarget())) { this.tree.addEdge(link.getSource(), link.getTarget(), link); } } }
public void changeLinkStatus(LabeledLink link, LinkStatus status) { super.changeLinkStatus(link, status); if (status == LinkStatus.PreferredByUI) return; SteinerNode n1 = new SteinerNode(link.getSource().getId()); SteinerNode n2 = new SteinerNode(link.getTarget().getId()); SteinerEdge e = new SteinerEdge(n1, link.getId(), n2, (float)link.getWeight()); if (getTopKGraph().get(n2).remove(e)) { if (link instanceof LabeledLink) { e.setModelIds(((LabeledLink)link).getModelIds()); e.setForced(status == LinkStatus.ForcedByUser); } getTopKGraph().get(n2).add(e); } }
private Set<String> getTriples(DirectedWeightedMultigraph<Node, LabeledLink> g, HashMap<Node,String> nodeIds, boolean ignoreSemanticTypes, boolean ignoreColumnNodes) { String separator = "|"; Set<String> triples = new HashSet<>(); if (g == null) return triples; String s, p, o, triple; for (LabeledLink l : g.edgeSet()) { if (ignoreSemanticTypes && !(l.getTarget() instanceof InternalNode)) continue; s = nodeIds.get(l.getSource()); o = nodeIds.get(l.getTarget()); p = l.getLabel().getUri(); if (ignoreColumnNodes) triple = s + separator + p; else triple = s + separator + p + separator + o; // System.out.println(triple); triples.add(triple); } return triples; }
private LabeledLink getMainProvenanceLink(Alignment alignment, LabeledLink link) { String edgeUri = link.getUri(); for(LabeledLink otherLink : alignment.getCurrentIncomingLinksToNode(link.getTarget().getId())) { if(otherLink.getUri().equals(edgeUri) && otherLink.isMainProvenanceLink()) return otherLink; } return null; }
public void updateCoherence(LabeledLink link) { if (link == null) return; if (interactiveMode) { if (link.getStatus() == LinkStatus.ForcedByUser) return; if (link.getTarget() instanceof ColumnNode) { ColumnNode cn = (ColumnNode)link.getTarget(); if (cn.getSemanticTypeStatus() == ColumnSemanticTypeStatus.UserAssigned) return; } } else { if (!(link.getTarget() instanceof InternalNode)) return; } this.itemsCount ++; if (link.getModelIds() == null || link.getModelIds().isEmpty()) return; updateCoherence(link.getModelIds()); }
for (LabeledLink link : links) { Node source = link.getSource(); Integer sourceIndex = verticesIndex.get(source); Node target = link.getTarget(); Integer targetIndex = verticesIndex.get(target); Set<LabeledLink> outEdges = alignmentGraph linkObj.put(JsonKeys.label.name(), link.getLabel().getLocalName()); linkObj.put(JsonKeys.rdfsLabel.name(), link.getLabel().getRdfsLabel()); linkObj.put(JsonKeys.rdfsComment.name(), link.getLabel().getRdfsComment()); linkObj.put(JsonKeys.isProvenance.name(), link.isProvenance()); linkObj.put(JsonKeys.id.name(), link.getId() + ""); linkObj.put(JsonKeys.linkStatus.name(), link.getStatus() .name()); linkObj.put(JsonKeys.linkUri.name(), link.getLabel() .getUri()); linkObj.put(JsonKeys.linkType.name(), link.getType()); if (link.getType() == LinkType.ObjectPropertySpecializationLink) { ObjectPropertySpecializationLink spLink = (ObjectPropertySpecializationLink) link; String linkId = spLink.getSpecializedLinkId(); linkObj.put(JsonKeys.source.name(), linkId); edgeLinksArr.put(linkObj); } else if (link.getType() == LinkType.DataPropertyOfColumnLink) { DataPropertyOfColumnLink spLink = (DataPropertyOfColumnLink) link; String linkId = spLink.getSpecializedLinkId();
source = e.getSource(); target = e.getTarget(); String id = LinkIdFactory.getLinkId(e.getUri(), n1.getId(), n2.getId()); LabeledLink l = this.graphBuilder.getIdToLinkMap().get(id); if (l != null) { int numOfPatterns = l.getModelIds().size(); double currentW = l.getWeight(); double newW = model.getGraph().getEdgeWeight(e); if (newW < currentW) this.graphBuilder.changeLinkWeight(l, ModelingParams.PATTERN_LINK_WEIGHT); l.getModelIds().add(indexedModelId); n1.getModelIds().add(indexedModelId); n2.getModelIds().add(indexedModelId); LabeledLink link = e.copy(id); logger.error("cannot instanciate a link from the type: " + e.getType().toString()); continue; link.setStatus(LinkStatus.Normal); // all the links in learning graph are normal if (link.getModelIds() != null) link.getModelIds().clear(); link.getModelIds().add(indexedModelId);
if (inputModelEdges.indexOf(e.getId()) != -1) continue; if (vertexIdToArgument.get(e.getSource().getId()) == null || vertexIdToArgument.get(e.getTarget().getId()) == null) continue; Label propertyPredicate = new Label(e.getLabel().getUri(), e.getLabel().getNs(), e.getLabel().getPrefix(), e.getLabel().getRdfsLabel(), e.getLabel().getRdfsComment()); IndividualPropertyAtom propertyAtom; vertexIdToArgument.get(e.getSource().getId()), vertexIdToArgument.get(e.getTarget().getId()));
if (alignment.getSteinerTree() != null) { for (LabeledLink link : alignment.getSteinerTree().edgeSet()) { if ((link.getStatus() == LinkStatus.Normal || link.getStatus() == LinkStatus.PreferredByUI) && (link.getType() == LinkType.ObjectPropertyLink)) { links.add(link); ChangeInternalNodeLinksCommandFactory cinlcf = new ChangeInternalNodeLinksCommandFactory(); for (LabeledLink link : links) { if(link.getStatus() != LinkStatus.ForcedByUser) { JSONObject newEdge = new JSONObject(); newEdge.put(ChangeInternalNodeLinksCommand.LinkJsonKeys.edgeSourceId.name(), link.getSource().getId()); newEdge.put(ChangeInternalNodeLinksCommand.LinkJsonKeys.edgeTargetId.name(), link.getTarget().getId()); newEdge.put(ChangeInternalNodeLinksCommand.LinkJsonKeys.edgeId.name(), link.getUri()); newEdge.put(ChangeInternalNodeLinksCommand.LinkJsonKeys.isProvenance.name(), link.isProvenance()); newEdges.put(newEdge); Set<String> provLinkIds = new HashSet<>(); for(LabeledLink link : outLinks) { if(link.isProvenance()) { hasProvLink = true; provLinkIds.add(link.getId()); continue; if(link.getType() == LinkType.DataPropertyLink) hasDataProperty = true;
Collections.sort(idSortedLinks); for (LabeledLink l : idSortedLinks) { key = l.getSource().getUri() + l.getUri() + l.getTarget().getUri(); if (this.graphBuilder.getPatternLinks().get(key) != null) { sortedLinks.add(l); source = e.getSource(); target = e.getTarget(); linkUri = e.getUri(); Collections.sort(matchedLinks); for (LabeledLink l : matchedLinks) { if (!mappedLinks.contains(l.getId())) { mappedLinks.add(l.getId()); n1 = l.getSource(); n2 = l.getTarget(); mapping.put(source,n1); mapping.put(target, n2); if (matchedLinks != null && !matchedLinks.isEmpty()) { for (LabeledLink l : matchedLinks) { if (!mappedLinks.contains(l.getId()) && !mappedNodes.contains(l.getSource().getId()) && l.getTarget().getId().equalsIgnoreCase(n2.getId())) { mappedLinks.add(l.getId()); n1 = l.getSource(); mapping.put(source,n1); mappedNodes.add(n1.getId());
source = e.getSource(); target = e.getTarget(); String id = LinkIdFactory.getLinkId(e.getLabel().getUri(), n1.getId(), n2.getId()); if (e instanceof DataPropertyLink) link = new DataPropertyLink(id, e.getLabel()); else if (e instanceof ObjectPropertyLink) link = new ObjectPropertyLink(id, e.getLabel(), ((ObjectPropertyLink)e).getObjectPropertyType()); else if (e instanceof SubClassLink) link = new SubClassLink(id); else if (e instanceof ClassInstanceLink) link = new ClassInstanceLink(id, e.getKeyType()); else if (e instanceof ColumnSubClassLink) link = new ColumnSubClassLink(id); link = new ObjectPropertySpecializationLink(id, ((ObjectPropertySpecializationLink)e).getSpecializedLinkId()); else { logger.error("cannot instanciate a link from the type: " + e.getType().toString()); continue; link.getModelIds().add(modelId);
for (LabeledLink l : model.getGraph().edgeSet()) { if (!(l.getSource() instanceof InternalNode)) { logger.error("column node cannot have an outgoing link!"); return; source = modelToAlignmentNode.get(l.getSource()); target = modelToAlignmentNode.get(l.getTarget()); String id = LinkIdFactory.getLinkId(l.getUri(), source.getId(), target.getId()); LabeledLink newLink = l.copy(id); tree.setEdgeWeight(newLink, l.getWeight()); newLink.getLabel(), source.getLabel(), source.getId(), false, SemanticType.Origin.User, 1.0);
public LabeledLink copy(String newId) { Label label = this.getLabel(); if (this instanceof DataPropertyLink) newLink = new DataPropertyLink(newId, label, this.isProvenance); newLink = new SubClassLink(newId); else if (this instanceof ClassInstanceLink) newLink = new ClassInstanceLink(newId, this.getKeyType()); else if (this instanceof ColumnSubClassLink) newLink = new ColumnSubClassLink(newId); newLink = new ObjectPropertySpecializationLink(newId, ((ObjectPropertySpecializationLink)this).getSpecializedLinkId()); else logger.error("cannot instanciate a link from the type: " + this.getType().toString()); newLink.setStatus(this.getStatus()); newLink.setModelIds(new HashSet<>(this.getModelIds())); newLink.setKeyType(this.getKeyType()); newLink.setProvenance(this.isProvenance, this.isMainProvenanceLink); return newLink;
for (LabeledLink inLink : incomingLinksArr) { source = inLink.getSource(); target = inLink.getTarget(); if (e != null && inLink.equals(e)) continue; LabeledLink reverseLink = inLink.clone(); //new Link(inLink.getId(), label); tree.removeEdge(inLink); tree.addEdge(target, source, reverseLink); tree.setEdgeWeight(reverseLink, inLink.getWeight()); reversedLinks.add(inLink.getId()); target = outLink.getTarget(); if (visitedNodes.contains(target)) { tree.removeEdge(outLink); removedLinks.add(outLink.getId()); } else { treeToRootedTree(tree, target, outLink, visitedNodes, reversedLinks, removedLinks);
return false; ((LabeledLink)link).getLabel().setNs(label.getNs()); ((LabeledLink)link).getLabel().setPrefix(label.getPrefix()); this.idToLinkMap.put(labeledLink.getId(), labeledLink); Set<LabeledLink> linksWithSameUri = uriToLinksMap.get(labeledLink.getUri()); if (linksWithSameUri == null) { linksWithSameUri = new HashSet<>(); uriToLinksMap.put(labeledLink.getUri(), linksWithSameUri); Set<LabeledLink> linksWithSameType = typeToLinksMap.get(labeledLink.getType()); if (linksWithSameType == null) { linksWithSameType = new HashSet<>(); typeToLinksMap.put(labeledLink.getType(), linksWithSameType); if (labeledLink.getStatus() != LinkStatus.Normal) { Set<LabeledLink> linksWithSameStatus = statusToLinksMap.get(labeledLink.getStatus()); if (linksWithSameStatus == null) { linksWithSameStatus = new HashSet<>(); statusToLinksMap.put(labeledLink.getStatus(), linksWithSameStatus); if (labeledLink.getModelIds() != null) { this.modelIds.addAll(labeledLink.getModelIds()); this.numberOfModelLinks++;
if(property.getTarget().getType() == NodeType.ColumnNode) continue; link.put(Arguments.uri.name(), property.getUri()); link.put(Arguments.label.name(), property.getLabel().getDisplayName()); 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());
Node target = link.getTarget(); if(target instanceof ColumnNode) { //ALready covered in semantic types continue; Node source = link.getSource(); String property = "`" + getPropertyName(link.getLabel()) + "`"; String to = getClassName(target); String from = getClassName(source); if(link.isProvenance()) { property = property + "<BR> - _specified provenance_"; String provProperty = property + "-" + to;
if (l.getStatus() == LinkStatus.ForcedByUser) { Node source = l.getSource(); Node target = l.getTarget(); if (!this.graphBuilder.addLink(source, target, l)) { LabeledLink existingLink = this.graphBuilder.getIdToLinkMap().get(l.getId()); if (existingLink != null) { // the link already exist, but it may not be forced by user this.graphBuilder.changeLinkStatus(existingLink, LinkStatus.ForcedByUser);