TopicIF createNamedTopic(String name, TopicIF type) { TopicMapBuilderIF builder = getTopicMapIF().getBuilder(); TopicIF topic = builder.makeTopic(type); if (name != null && !name.equals("")) builder.makeTopicName(topic, name); return topic; }
private TopicIF getLastModifiedTopic(TopicMapIF topicmap) { TopicIF lastmod = topicmap.getTopicBySubjectIdentifier(psi); if (lastmod == null) { lastmod = topicmap.getBuilder().makeTopic(); lastmod.addSubjectIdentifier(psi); } return lastmod; }
public void testTopicName() { checkDuplicateReificationException( builder.makeTopicName(builder.makeTopic(), "name") ); }
private static TopicIF makeTopic(TopicMapIF tm, String id) throws MalformedURLException { TopicMapBuilderIF builder = tm.getBuilder(); TopicIF topic = builder.makeTopic(); topic.addSubjectIdentifier(new URILocator(RAPServlet.RAP_NAMESPACE + id)); return topic; }
private TopicIF getPasswordTopic(TopicMapIF topicmap) { TopicIF passwd = topicmap.getTopicBySubjectIdentifier(psi); if (passwd == null) { passwd = topicmap.getBuilder().makeTopic(); passwd.addSubjectIdentifier(psi); } return passwd; }
public void testGetNoNameTopicCount() { assertEquals(0, stats.getNoNameTopicCount()); builder.makeTopicName(builder.makeTopic(), "foo"); assertEquals(1, stats.getNoNameTopicCount()); }
@Override public TopicImpl createTopicBySubjectLocator(Locator slo) { Check.itemIdentifierNotNull(this, slo); TopicImpl topic = getTopicBySubjectLocator(slo); if (topic == null) { topic = wrapTopic(wrapped.getBuilder().makeTopic()); topic.addSubjectLocator(slo); } return topic; }
public void testGetVariantCount() { assertEquals(0, stats.getVariantCount()); List<TopicIF> emptyList = Collections.emptyList(); builder.makeVariantName(builder.makeTopicName(builder.makeTopic(), "foo"), "bar", emptyList); assertEquals(1, stats.getVariantCount()); }
public QueryField createQueryField() { TopicMap tm = getTopicMap(); TopicMapBuilderIF builder = tm.getTopicMapIF().getBuilder(); // create name field TopicIF queryFieldType = OntopolyModelUtils.getTopicIF(tm, PSI.ON, "query-field"); TopicIF queryFieldTopic = builder.makeTopic(queryFieldType); // add field QueryField queryField = new QueryField(queryFieldTopic, tm); addField(queryField); return queryField; }
public void testVariantGenerate() { TopicIF topic = builder.makeTopic(); TopicNameIF bn = builder.makeTopicName(topic, "foo"); VariantNameIF vn = builder.makeVariantName(bn, "value"); DocumentIF doc = generator.generate(vn); Collection fields = doc.getFields(); assertTrue("Variant DocumentIF has " + fields.size() + " fields", fields.size() == 3); verifyObjectId(vn, doc.getField("object_id")); verifyClass(doc.getField("class"), "N"); verifyContent(doc.getField("content"), "value"); }
@Override public void run() { TopicNameIF bn = getTopicName(); TopicIF type = builder.makeTopic(); // create type this.data.put("type", type); bn.setType(type); this.objectId = bn.getObjectId(); this.value = type.getObjectId(); } });
@Override public void run() { AssociationIF a = getAssociation(); TopicIF theme = builder.makeTopic(); this.data.put("scope", theme); a.addTheme(theme); this.objectId = a.getObjectId(); this.value = theme.getObjectId(); } });
public void testTopicTypeDeletion() { TopicMapIF topicmap = makeTopicMap(); TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF morituri = builder.makeTopic(); TopicIF instance = builder.makeTopic(morituri); morituri.remove(); assertTrue("Topic still connected to topic map", morituri.getTopicMap() == null); assertTrue("Topic map not empty", topicmap.getTopics().size() == 0); }
public void testTopicGenerate() { TopicIF topic = builder.makeTopic(); DocumentIF doc = generator.generate(topic); Collection fields = doc.getFields(); assertTrue("Topic DocumentIF has " + fields.size() + " fields", fields.size() == 2); verifyObjectId(topic, doc.getField("object_id")); verifyClass(doc.getField("class"), "T"); }
public void testGetTopicCount() { assertEquals(0, stats.getTopicCount()); builder.makeTopic(); assertEquals(1, stats.getTopicCount()); }
public void testGetSubjectIdentifierCount() { assertEquals(0, stats.getSubjectIdentifierCount()); builder.makeTopic().addSubjectIdentifier(URILocator.create("foo:bar")); assertEquals(1, stats.getSubjectIdentifierCount()); }
public void testGetSubjectLocatorCount() { assertEquals(0, stats.getSubjectLocatorCount()); builder.makeTopic().addSubjectLocator(URILocator.create("foo:bar")); assertEquals(1, stats.getSubjectLocatorCount()); }
protected static TopicIF defineIdentityField(TopicMapIF topicmap, LocatorIF base_on, TopicIF itype, TopicIF cardinality) { TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF iField = builder.makeTopic(getTopic(topicmap, base_on, "identity-field")); AssociationIF hasOccurrenceType = builder.makeAssociation(getTopic(topicmap, base_on, "has-identity-type")); builder.makeAssociationRole(hasOccurrenceType, getTopic(topicmap, base_on, "identity-type"), itype); builder.makeAssociationRole(hasOccurrenceType, getTopic(topicmap, base_on, "identity-field"), iField); AssociationIF hasCardinality = builder.makeAssociation(getTopic(topicmap, base_on, "has-cardinality")); builder.makeAssociationRole(hasCardinality, getTopic(topicmap, base_on, "field-definition"), iField); builder.makeAssociationRole(hasCardinality, getTopic(topicmap, base_on, "cardinality"), cardinality); return iField; }
@Test public void testAssociationRole() throws Exception { AssociationIF assoc = tm1.getBuilder().makeAssociation(tm1.getBuilder().makeTopic()); AssociationRoleIF role = tm1.getBuilder().makeAssociationRole(assoc, foo1, foo1); role.setReifier(foo1); concurrentCommit(); // verify no inconsistenties were created check(tm1, role.getType(), "Association role", "type"); check(tm1, role.getPlayer(), "Association role", "player"); check(tm1, role.getReifier(), "Association role", "reifier"); }