private TopicIF getRecentFile(File aFile) { return topicmap.getTopicBySubjectLocator(VizUtils.makeLocator(aFile)); }
protected TopicIF registerSubjectLocator(TopicIF topic, LocatorIF locator) { // merge with existing, if any TopicIF existing = topicmap.getTopicBySubjectLocator(locator); if (existing != null && !Objects.equals(existing, topic)) { existing.merge(topic); topic = existing; } // add subject locator topic.addSubjectLocator(locator); return topic; }
@Override public TopicIF makeTopicBySubjectLocator(LocatorIF subjloc) { TopicIF topic = topicmap.getTopicBySubjectLocator(subjloc); if (topic == null) { topic = builder.makeTopic(); topic.addSubjectLocator(subjloc); } return topic; }
protected TopicIF resolveResourceRef(LocatorIF locator) { // Look up in the topic map to see if a topic with the identity already exist TopicIF topic = topicmap.getTopicBySubjectLocator(locator); if (topic != null) return topic; // If there is no such topic create a new one with the given subject indicator. topic = builder.makeTopic(); // log.debug("New topic (resourceRef): " + locator); // Set addressable subject topic.addSubjectLocator(locator); return topic; }
protected void registerSubjectLocator(TopicIF topic, LocatorIF loc) { TopicIF other = topicmap.getTopicBySubjectLocator(loc); if (other == null) { topic.addSubjectLocator(loc); return; } if (other != topic) MergeUtils.mergeInto(topic, other); }
private TMObjectIF resolveAsLocator(TopicMapIF topicmap, LocatorIF locator) { TMObjectIF o = topicmap.getTopicBySubjectIdentifier(locator); if (o == null) { o = topicmap.getTopicBySubjectLocator(locator); } if (o == null) { o = topicmap.getObjectByItemIdentifier(locator); } return o; } }
/** * Returns a topic by its subject locator. If no topic with the provided subject locator * exists in the topic map, a new topic with the provided subject locator will * be created. * * @param slo The subject locator * @return A topic with the provided subject locator. */ private TopicIF getTopicBySlo(final LocatorIF slo) { TopicIF topic = topicmap.getTopicBySubjectLocator(slo); if (topic == null) { topic = builder.makeTopic(); topic.addSubjectLocator(slo); } return topic; }
private static TopicIF getTopic(TopicMapIF tm, TopicIF find) { // ISSUE: what if find maps to multiple topics in target? // ISSUE: what if find has no identity? TopicIF found = null; Iterator<LocatorIF> it = find.getSubjectLocators().iterator(); while (it.hasNext() && found == null) { LocatorIF psi = it.next(); found = tm.getTopicBySubjectLocator(psi); } it = find.getSubjectIdentifiers().iterator(); while (it.hasNext() && found == null) { LocatorIF psi = it.next(); found = tm.getTopicBySubjectIdentifier(psi); } it = find.getItemIdentifiers().iterator(); while (it.hasNext() && found == null) { LocatorIF srcloc = it.next(); TMObjectIF obj = tm.getObjectByItemIdentifier(srcloc); // ISSUE: what if this is not a topic? if (obj instanceof TopicIF) found = (TopicIF) obj; } return found; }
while (it.hasNext()) { LocatorIF subject = it.next(); topic = topicmap.getTopicBySubjectLocator(subject); if (topic != null) topics.add(topic);
@Override public TopicImpl getTopicBySubjectLocator(Locator slo) { Check.subjectLocatorNotNull(slo); return wrapTopic(wrapped.getTopicBySubjectLocator(unwrapLocator(slo))); }
@Override public TopicIF getTopicBySubjectLocator(String uri) throws AntlrWrapException { TopicIF topic = topicmap.getTopicBySubjectLocator(absolutify(uri)); if (topic == null) throw new AntlrWrapException(new BadObjectReferenceException("No topic with subject locator '" + uri + "' found")); return topic; }
protected Object getObject(Object value, int valtype) { try { switch (valtype) { case SearcherIF.STRING_VALUE: return value.toString(); case SearcherIF.OBJECT_VALUE: return value; case SearcherIF.OBJECT_ID: return topicmap.getObjectById((String)value); case SearcherIF.SUBJECT_LOCATOR: return topicmap.getTopicBySubjectLocator(new URILocator((String)value)); case SearcherIF.SUBJECT_IDENTIFIER: return topicmap.getTopicBySubjectIdentifier(new URILocator((String)value)); case SearcherIF.ITEM_IDENTIFIER: return topicmap.getObjectByItemIdentifier(new URILocator((String)value)); default: throw new OntopiaRuntimeException("Unknown searche value type: " + valtype); } } catch (MalformedURLException m) { throw new OntopiaRuntimeException(m); } }
@Override public void run(MasterTest mt) { TopicIF t = (TopicIF)topicmap.getObjectById(mt.objectId); assertTrue("Subject locator is not set", t.getSubjectLocators().contains(URILocator.create("x:subject"))); assertTrue("Topic not found by subject locator", topicmap.getTopicBySubjectLocator(URILocator.create("x:subject")).equals(t)); } });
@Override protected void onValidate(IValidatable<String> validatable) { String value = validatable.getValue(); if (value == null) return; LocatorIF locator; try { locator = new URILocator(value); } catch (Exception e) { reportError("validators.IdentityValidator.invalidURI", value); return; } Topic topic = fieldInstanceModel.getFieldInstance().getInstance(); TopicMap topicMap = topic.getTopicMap(); TopicMapIF topicMapIf = topicMap.getTopicMapIF(); TopicIF topicIf = topic.getTopicIF(); TopicIF otopic = topicMapIf.getTopicBySubjectIdentifier(locator); if (otopic != null && !Objects.equals(topicIf, otopic)) reportError("validators.IdentityValidator.subjectIdentifierClash", value); otopic = topicMapIf.getTopicBySubjectLocator(locator); if (otopic != null && !Objects.equals(topicIf, otopic)) reportError("validators.IdentityValidator.subjectLocatorClash", value); }
@Override public void run(MasterTest mt) { TopicIF t = (TopicIF)topicmap.getObjectById(mt.objectId); assertTrue("Subject locator is not null", t.getSubjectLocators().isEmpty()); assertTrue("Topic found by subject locator", topicmap.getTopicBySubjectLocator(URILocator.create("x:subject")) == null); } });
TopicIF t = tm.getTopicBySubjectLocator(sl); if (t != null) { return t;
LocatorIF loc = Utils.getLocator(relation, entity, field, tuple, ctx); if (loc == null) return null; return ctx.getTopicMap().getTopicBySubjectLocator(loc);
@Override public void statement(AResource sub, AResource pred, AResource obj) { if (obj.isAnonymous()) { logger.warn("Blank nodes cannot be subject locators; " + "subject: " + sub.getURI() + "; " + "predicate: " + pred.getURI()); throw new RDFMappingException("Blank nodes cannot be subject locators", sub.getURI(), pred.getURI()); } TopicIF topic = getSubject(sub); LocatorIF loc = null; try { loc = new URILocator(obj.getURI()); } catch (MalformedURLException e) { throw new OntopiaRuntimeException("INTERNAL ERROR", e); } TopicIF other = topicmap.getTopicBySubjectLocator(loc); if (other != null && other != topic) MergeUtils.mergeInto(other, topic); else topic.addSubjectLocator(loc); } }
public void testTopicsCopied() { try { TopicIF t1 = builder1.makeTopic(); TopicIF t2 = builder2.makeTopic(); t2.addSubjectLocator(makeLocator("http://www.ontopia.net")); MergeUtils.mergeInto(topicmap1, topicmap2); assertTrue("topic not copied to target topic map", topicmap1.getTopics().size() == 2); t2 = topicmap1.getTopicBySubjectLocator(makeLocator("http://www.ontopia.net")); assertTrue("topic copied but not registered in subject map", t2 != null); assertTrue("topic not copied correctly", t2.getTopicNames().size() == 0 && t2.getOccurrences().size() == 0 && t2.getSubjectIdentifiers().size() == 0 && t2.getRoles().size() == 0 && t2.getTypes().size() == 0); } catch (ConstraintViolationException e) { fail("spurious ConstraintViolationException" + e.getMessage()); } }
@Override protected void onValidate(IValidatable<String> validatable) { String value = validatable.getValue(); if (value == null) return; LocatorIF locator; try { locator = new URILocator(value); } catch (Exception e) { reportError("validators.IdentityValidator.invalidURI", value); return; } Topic topic = fieldInstanceModel.getFieldInstance().getInstance(); TopicMap topicMap = topic.getTopicMap(); TopicMapIF topicMapIf = topicMap.getTopicMapIF(); TopicIF topicIf = topic.getTopicIF(); TopicIF otopic = topicMapIf.getTopicBySubjectIdentifier(locator); if (otopic != null && ObjectUtils.different(topicIf, otopic)) reportError("validators.IdentityValidator.subjectIdentifierClash", value); otopic = topicMapIf.getTopicBySubjectLocator(locator); if (otopic != null && ObjectUtils.different(topicIf, otopic)) reportError("validators.IdentityValidator.subjectLocatorClash", value); }