private void addOccurrences(TopicIF t, DataPool dp, int count) { for (int i=0; i < count; i++) { OccurrenceIF occ = b.makeOccurrence(t, (TopicIF)CollectionUtils.getRandom(dp.occurrenceTypes), "occurrence-" + (i+1)); } }
protected static OccurrenceIF addOccurrence(TopicMap topicMap, LocatorIF base_on, TopicIF topic, String otype, String datatype, String value) { TopicMapIF topicmap = topicMap.getTopicMapIF(); TopicMapBuilderIF builder = topicmap.getBuilder(); LocatorIF dt; if (datatype.equals("datatype-string")) dt = DataTypes.TYPE_STRING; else if (datatype.equals("datatype-number")) dt = DataTypes.TYPE_DECIMAL; else throw new RuntimeException("Unsupported datatype: " + datatype); return builder.makeOccurrence(topic, getTopic(topicmap, base_on, otype), value, dt); }
public static OccurrenceIF makeOccurrence(TopicIF otype, TopicIF topicIF, String value, LocatorIF datatype, Collection<TopicIF> scope) { TopicMapBuilderIF builder = topicIF.getTopicMap().getBuilder(); OccurrenceIF occ = builder.makeOccurrence(topicIF, otype, value, datatype); Iterator<TopicIF> iter = scope.iterator(); while (iter.hasNext()) { TopicIF scopingTopic = iter.next(); occ.addTheme(scopingTopic); } return occ; }
@Override public void startOccurrence(ValueGeneratorIF type, ValueGeneratorIF value) { OccurrenceIF occurrence = builder.makeOccurrence(topic, type.getTopic(), value.getLiteral(), value.getDatatype()); scoped = occurrence; reifiable = occurrence; }
@Override public void createTypedIFs(TopicMapBuilderIF builder, TopicIF type) { builder.makeOccurrence(builder.makeTopic(), type, "foo1"); builder.makeOccurrence(builder.makeTopic(), type, "foo2"); builder.makeOccurrence(builder.makeTopic(), type, "foo3"); }
private TopicIF createRecentFile(File aFile) { TopicIF file = builder.makeTopic(recentLoaded); file.addSubjectLocator(VizUtils.makeLocator(aFile)); builder.makeOccurrence(file, timestamp, ""); return file; }
@Override public void statement(AResource sub, AResource pred, ALiteral lit) { TopicIF topic = getSubject(sub); TopicIF ourtype = type; if (ourtype == null) ourtype = getPredicate(pred); OccurrenceIF occ = builder.makeOccurrence(topic, ourtype, lit.toString()); addScope(occ); } }
@Override public void createTypedIFs(TopicMapBuilderIF builder, TopicIF type) { type.addSubjectIdentifier(URILocator.create("foo:bar")); builder.makeOccurrence(builder.makeTopic(), type, "foo1"); builder.makeOccurrence(builder.makeTopic(), type, "foo2"); builder.makeOccurrence(builder.makeTopic(), type, "foo3"); }
@Override protected TMObjectIF makeObject() { TopicIF topic = builder.makeTopic(); TopicIF otype = builder.makeTopic(); return builder.makeOccurrence(topic, otype, ""); }
public void testOccurrenceRemoval() { TopicIF type = builder.makeTopic(); TopicIF topic = builder.makeTopic(); OccurrenceIF occ = builder.makeOccurrence(topic, type, "duplicate"); occ = builder.makeOccurrence(topic, type, "duplicate"); DuplicateSuppressionUtils.removeDuplicates(topic); assertTrue("duplicate occurrence were not removed", topic.getOccurrences().size() == 1); }
@Override public void run() { OccurrenceIF o = builder.makeOccurrence(getTopic(), getTopic(), ""); this.data.put("OccurrenceIF", o); this.objectId = o.getObjectId(); } });
public void testBug510_O() { assertEquals("Index finds spurious occurrences", 0, clsix.getOccurrences(null).size()); builder.makeOccurrence(type, type, ""); assertEquals("Index finds spurious occurrences", 0, clsix.getOccurrences(null).size()); }
public void testOccurrencesByType() { TopicIF type = builder.makeTopic(); assertTrue("occurrences by non-existent type initially not empty", topic.getOccurrencesByType(type).size() == 0); OccurrenceIF occ = builder.makeOccurrence(topic, type, "foo"); assertTrue("occurrences of correct type not found", topic.getOccurrencesByType(type).size() == 1); OccurrenceIF occ2 = builder.makeOccurrence(topic, builder.makeTopic(), "bar"); assertTrue("occurrence with with incorrect type found", topic.getOccurrencesByType(type).size() == 1); }
@Override public void setUp() throws Exception { super.setUp(); TopicIF topic = builder.makeTopic(); parent = topic; TopicIF otype = builder.makeTopic(); occurrence = builder.makeOccurrence(topic, otype, ""); object = occurrence; scoped = occurrence; typed = occurrence; }
@Override public Occurrence createOccurrence(Topic type, String value, Topic... scope) { Check.typeNotNull(this, type); Check.valueNotNull(this, value); Check.scopeNotNull(this, scope); Check.scopeInTopicMap(getTopicMap(), scope); Check.typeInTopicMap(getTopicMap(), type); OccurrenceIF occ = topicMap.getWrapped().getBuilder().makeOccurrence( wrapped, topicMap.unwrapTopic(type), value); applyScope(occ, scope); return topicMap.wrapOccurrence(occ); }
public void testOccurrenceGenerate() { TopicIF topic = builder.makeTopic(); TopicIF otype = builder.makeTopic(); OccurrenceIF occ = builder.makeOccurrence(topic, otype, "value"); DocumentIF doc = generator.generate(occ); Collection fields = doc.getFields(); assertTrue("Occurrence DocumentIF has " + fields.size() + " fields", fields.size() == 3); verifyObjectId(occ, doc.getField("object_id")); verifyClass(doc.getField("class"), "O"); verifyContent(doc.getField("content"), "value"); }
public void testOccurrenceGenerate2() { TopicIF topic = builder.makeTopic(); TopicIF otype = builder.makeTopic(); OccurrenceIF occ = builder.makeOccurrence(topic, otype, makeLocator("http://www.ontopia.net")); DocumentIF doc = generator.generate(occ); Collection fields = doc.getFields(); assertTrue("Occurrence DocumentIF has " + fields.size() + " fields", fields.size() == 4); verifyObjectId(occ, doc.getField("object_id")); verifyClass(doc.getField("class"), "O"); verifyLocator(doc, "http://www.ontopia.net/"); }
@Override public Occurrence createOccurrence(Topic type, Locator value, Topic... scope) { Check.typeNotNull(this, type); Check.valueNotNull(this, value); Check.scopeNotNull(this, scope); Check.scopeInTopicMap(getTopicMap(), scope); Check.typeInTopicMap(getTopicMap(), type); OccurrenceIF occ = topicMap.getWrapped().getBuilder().makeOccurrence( wrapped, topicMap.unwrapTopic(type), topicMap.unwrapLocator(value)); applyScope(occ, scope); return topicMap.wrapOccurrence(occ); }
public void testGetOccurrenceCount() { assertEquals(0, stats.getOccurrenceCount()); builder.makeOccurrence(builder.makeTopic(), builder.makeTopic(), "foo"); assertEquals(1, stats.getOccurrenceCount()); }
public void testGetOccurrenceTypeCount() { assertEquals(0, stats.getOccurrenceTypeCount()); builder.makeOccurrence(builder.makeTopic(), builder.makeTopic(), "foo"); assertEquals(1, stats.getOccurrenceTypeCount()); }