You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(85) |
Apr
|
May
|
Jun
|
Jul
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Lars H. <lh...@us...> - 2005-03-10 13:32:37
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13043/src/org/tmapiutils/query/tolog/test Modified Files: TologParserTest.java TologParserTestBase.java Log Message: More TM4J -> TMAPI translations Index: TologParserTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/TologParserTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TologParserTest.java 8 Mar 2005 12:33:58 -0000 1.3 --- TologParserTest.java 10 Mar 2005 13:32:23 -0000 1.4 *************** *** 256,273 **** public void testObjectAddressing() throws Exception { TopicMap tm = createTopicMap(); ! Topic tm4jorg = tm.createTopic(null); ! String id = tm4jorg.getObjectId(); ! Topic tm4j = tm.createTopic("tm4j"); ! Topic respfor = tm.createTopic("responsiblefor"); ! Topic resp = tm.createTopic("responsible"); ! Topic respy = tm.createTopic("responsibility"); ! Association a = tm.createAssociation(null); a.setType(respfor); ! AssociationRole m = a.createAssociationRole(null); m.setType(resp); ! m.addPlayer(tm4jorg); ! m = a.createAssociationRole(null); m.setType(respy); ! m.addPlayer(tm4j); String queryString = "select $A from @responsiblefor(@" + id + ":@responsible, $A:@responsibility)?"; --- 256,273 ---- public void testObjectAddressing() throws Exception { TopicMap tm = createTopicMap(); ! // Topic tm4jorg = tm.createTopic(null); ! // String id = tm4jorg.getObjectId(); ! // Topic tm4j = tm.createTopic("tm4j"); ! // Topic respfor = tm.createTopic("responsiblefor"); ! // Topic resp = tm.createTopic("responsible"); ! // Topic respy = tm.createTopic("responsibility"); ! Association a = tm.createAssociation(); a.setType(respfor); ! AssociationRole m = a.createAssociationRole(null, null); m.setType(resp); ! m.setPlayer(tm4jorg); ! m = a.createAssociationRole(null, null); m.setType(respy); ! m.setPlayer(tm4j); String queryString = "select $A from @responsiblefor(@" + id + ":@responsible, $A:@responsibility)?"; Index: TologParserTestBase.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/TologParserTestBase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TologParserTestBase.java 8 Mar 2005 12:33:58 -0000 1.3 --- TologParserTestBase.java 10 Mar 2005 13:32:24 -0000 1.4 *************** *** 18,34 **** package org.tmapiutils.query.tolog.test; ! import java.io.StringReader; ! import org.tmapi.core.Locator; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapProvider; ! import org.tmapi.core.TopicMapProviderFactory; ! import org.tmapi.core.memory.TopicMapProviderFactoryImpl; ! import org.tmapi.core.source.SerializedTopicMapSource; ! import org.tmapi.core.utils.IDGenerator; ! import org.tmapi.core.utils.IDGeneratorFactory; ! import org.tmapi.core.utils.LTMBuilder; import junit.framework.TestCase; /** --- 18,41 ---- package org.tmapiutils.query.tolog.test; ! //import java.io.StringReader; ! ! //import org.tmapi.core.TopicMapProvider; ! //import org.tmapi.core.TopicMapProviderFactory; ! //import org.tmapi.core.memory.TopicMapProviderFactoryImpl; ! //import org.tmapi.core.source.SerializedTopicMapSource; ! //import org.tmapi.core.utils.IDGenerator; ! //import org.tmapi.core.utils.IDGeneratorFactory; ! //import org.tmapi.core.utils.LTMBuilder; import junit.framework.TestCase; + // TMAPI + import org.tmapi.core.Locator; + import org.tmapi.core.TopicMapSystemFactory; + import org.tmapi.core.TopicMapSystem; + import org.tmapi.core.TopicMapObject; + import org.tmapi.core.TopicMap; + import org.tmapi.core.Topic; + import org.tmapi.core.Association; /** *************** *** 39,48 **** public class TologParserTestBase extends TestCase { ! private IDGenerator m_idGen; protected TopicMap m_tm; protected TopicMap m_tm2; ! protected TopicMapProvider m_provider; public TologParserTestBase(String arg0) { --- 46,56 ---- public class TologParserTestBase extends TestCase { ! // private IDGenerator m_idGen; protected TopicMap m_tm; protected TopicMap m_tm2; ! // protected TopicMapProvider m_provider; ! protected TopicMapSystem _tmSystem; public TologParserTestBase(String arg0) { *************** *** 55,67 **** public void setUp() throws Exception { super.setUp(); ! TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! m_provider = tmpf.newTopicMapProvider(); ! Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! m_tm = m_provider.addTopicMap(src); ! loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0_2.xtm"); ! src = new SerializedTopicMapSource(new StringReader(TESTMAP2), loc, new LTMBuilder()); ! m_tm2 = m_provider.addTopicMap(src); ! m_idGen = IDGeneratorFactory.newIDGenerator(); } --- 63,80 ---- public void setUp() throws Exception { super.setUp(); ! _tmSystem = TopicMapSystemFactory.newInstance().newTopicMapSystem(); ! m_tm = _tmSystem.createTopicMap("http://www.techquila.com/test/tolog1.0.xtm"); ! m_tm2 = _tmSystem.createTopicMap("http://www.techquila.com/test/tolog1.0_2.xtm"); ! ! ! // TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! // m_provider = tmpf.newTopicMapProvider(); ! // Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! // SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! // m_tm = m_provider.addTopicMap(src); ! // loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0_2.xtm"); ! // src = new SerializedTopicMapSource(new StringReader(TESTMAP2), loc, new LTMBuilder()); ! // m_tm2 = m_provider.addTopicMap(src); ! // m_idGen = IDGeneratorFactory.newIDGenerator(); } |
From: Lars H. <lh...@us...> - 2005-03-10 13:32:36
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13043/src/org/tmapiutils/query/tolog Modified Files: todo-log.txt Log Message: More TM4J -> TMAPI translations Index: todo-log.txt =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/todo-log.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** todo-log.txt 9 Mar 2005 12:40:20 -0000 1.10 --- todo-log.txt 10 Mar 2005 13:32:24 -0000 1.11 *************** *** 48,85 **** Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - - - File: query\tolog\test\TologParserTest.java - line: 258 - createMember - Must become "createAssociationRole" - line: 261 - createMember - Must become "createAssociationRole" - - - File: query\tolog\test\TologParserTestBase.java - line: 16 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 17 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 18 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 21 - IDGeneratorFactory - Has become org.tmapi.core.utils.IDGeneratorFactory - line: 38 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 49 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 50 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 57 - IDGeneratorFactory - Has become org.tmapi.core.utils.IDGeneratorFactory --- 48,49 ---- |
From: Lars H. <lh...@us...> - 2005-03-10 13:32:34
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13043/src/org/tmapiutils/query/tolog/parser Modified Files: tolog.g Log Message: More TM4J -> TMAPI translations Index: tolog.g =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/tolog.g,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tolog.g 8 Mar 2005 12:33:55 -0000 1.2 --- tolog.g 10 Mar 2005 13:32:22 -0000 1.3 *************** *** 1,5 **** ! header { package org.tmapiutils.query.tolog.parser; } ! ! { /* * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer --- 1,3 ---- ! header { /* * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer *************** *** 18,21 **** --- 16,23 ---- * limitations under the License. */ + package org.tmapiutils.query.tolog.parser; + } + + { import java.io.File; *************** *** 33,43 **** import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ! org.tmapiutils.query.tolog.TologParserException; ! org.tmapiutils.query.tolog.predicates.DynamicAssociationPredicate; import org.tmapiutils.utils.IndexUtils; // TMAPI - import org.tmapi.core.TopicMapObject; import org.tmapi.core.Locator; import org.tmapi.core.Topic; import org.tmapi.core.TopicMap; --- 35,45 ---- import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ! import org.tmapiutils.query.tolog.TologParserException; ! import org.tmapiutils.query.tolog.predicates.DynamicAssociationPredicate; import org.tmapiutils.utils.IndexUtils; // TMAPI import org.tmapi.core.Locator; + import org.tmapi.core.TopicMapObject; import org.tmapi.core.Topic; import org.tmapi.core.TopicMap; *************** *** 156,162 **** } return tmo; ! } catch (LocatorResolutionException ex) { ! throw new TologParserException("Invalid topic identifier " + ident + ". The identifier cannot be resolved to a URI fragment identifier."); ! } catch (TMAPIException ex) { throw new TologParserException("Initializing of index failed", ex); } --- 158,167 ---- } return tmo; ! } ! // -- ToDo: better exception handling, more useful hints ! //catch (LocatorResolutionException ex) { ! // throw new TologParserException("Invalid topic identifier " + ident + ". The identifier cannot be resolved to a URI fragment identifier."); ! //} ! catch (TMAPIException ex) { throw new TologParserException("Initializing of index failed", ex); } *************** *** 254,261 **** } if (m_log.isDebugEnabled()) m_log.debug("END importModule " + modSrc + " as " + modPrefix); ! } catch (LocatorFactoryException ex) { ! throw new TologParserException("Unable to resolve module reference " + modSrc + " to a valid URL.", ex); ! } catch (LocatorResolutionException ex) { ! throw new TologParserException("Unable to resolve module reference " + modSrc + " to a valid URL.", ex); } catch (MalformedURLException ex) { throw new TologParserException("Unable to open module reference " + modSrc + ".", ex); --- 259,266 ---- } if (m_log.isDebugEnabled()) m_log.debug("END importModule " + modSrc + " as " + modPrefix); ! //} catch (LocatorFactoryException ex) { ! // throw new TologParserException("Unable to resolve module reference " + modSrc + " to a valid URL.", ex); ! //} catch (LocatorResolutionException ex) { ! // throw new TologParserException("Unable to resolve module reference " + modSrc + " to a valid URL.", ex); } catch (MalformedURLException ex) { throw new TologParserException("Unable to open module reference " + modSrc + ".", ex); |
From: Lars H. <lh...@us...> - 2005-03-10 13:27:42
|
Update of /cvsroot/tmapi-utils/tmapi-utils/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11712/utils Modified Files: terminology.py Log Message: Added "addPlayer" as critical TM4J term Index: terminology.py =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/utils/terminology.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** terminology.py 8 Mar 2005 13:34:20 -0000 1.11 --- terminology.py 10 Mar 2005 13:27:31 -0000 1.12 *************** *** 135,139 **** 'getTopicBySubjectIndicator(':'TopicMap.getTopicBySubjectIndicator -> TopicsIndex.getTopicBySubjectIdentifier', 'getObjectBySourceLocator(':'TopicMap.getObjectBySourceLocator -> TopicMapObjectsIndex.getTopicMapObjectBySourceLocator', ! 'getTopicByID':'Has become "getObjectById". Typecast necessary!', # ScopedObjectsIndex 'getScopedObjects(':'Could be getScopedObjectsByScopingTopic or ..ByScopingTopics', --- 135,139 ---- 'getTopicBySubjectIndicator(':'TopicMap.getTopicBySubjectIndicator -> TopicsIndex.getTopicBySubjectIdentifier', 'getObjectBySourceLocator(':'TopicMap.getObjectBySourceLocator -> TopicMapObjectsIndex.getTopicMapObjectBySourceLocator', ! 'getTopicByID':'Has become "getObjectById". Typecast necessary!', # ScopedObjectsIndex 'getScopedObjects(':'Could be getScopedObjectsByScopingTopic or ..ByScopingTopics', *************** *** 141,144 **** --- 141,145 ---- 'getPlayers()':'AssociationRole can have only one player', 'setPlayers(':'AssociationRole can have only one player', + 'addPlayer(':'AssociationRole can have only one player', # Factory methods 'createName':'Must become "createTopicName"', |
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2232/src/org/tmapiutils/query/tolog/predicates/test Modified Files: AssociationPredicateTest.java AssociationRolePredicateTest.java DirectInstanceOfPredicateTest.java DynamicAssociationPredicateTest.java InstanceOfPredicateTest.java PredicateTestBase.java ReifiesPredicateTest.java ResourcePredicateTest.java TopicMapPredicateTest.java TopicNameTest.java TypePredicateTest.java ValueLikePredicateTest.java ValuePredicateTest.java VariantPredicateTest.java Log Message: - All predicates and predicate tests now compile - TMAPI compatible enhancements in /parser directory - Updated ToDo Index: ResourcePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ResourcePredicateTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ResourcePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.5 --- ResourcePredicateTest.java 9 Mar 2005 12:40:19 -0000 1.6 *************** *** 30,34 **** import org.tmapi.core.Topic; import org.tmapi.core.Occurrence; - import org.tmapi.index.core.TopicsIndex; /** --- 30,33 ---- *************** *** 63,74 **** public void createTestMap(TopicMap tm) { Topic tmapiutils = tm.createTopic(); - tmapiutils.addSubjectIdentifier(createLocator("tmapiutils")); Topic homepage = tm.createTopic(); Topic contact_details = tm.createTopic(); ! tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/", homepage, null); ! tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/contact/", contact_details, null); Topic tmapi = tm.createTopic(); ! tmapiutils.addSubjectIdentifier(createLocator("tmapi")); ! tmapi.createOccurrence(createLocator("http://tmapi.org/", homepage, null); } --- 62,75 ---- public void createTestMap(TopicMap tm) { Topic tmapiutils = tm.createTopic(); Topic homepage = tm.createTopic(); Topic contact_details = tm.createTopic(); ! tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/"), homepage, null); ! tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/contact/"), contact_details, null); Topic tmapi = tm.createTopic(); ! tmapi.createOccurrence(createLocator("http://tmapi.org/"), homepage, null); ! ! registerObject("tmapiutils", tmapiutils); ! registerObject("homepage", homepage); ! registerObject("tmapi", tmapi); } *************** *** 86,94 **** public void testOpenMatch() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); - Topic tmapiutils = topicsIdx.getTopicBySubjectIdentifier(createLocator("tmapiutils")); - Topic tmapi = topicsIdx.getTopicBySubjectIdentifier(createLocator("tmapi")); List params = new ArrayList(); Variable a = new Variable("A"); --- 87,90 ---- *************** *** 101,105 **** assertEquals(2, out.getColumns().size()); assertEquals(3, out.getRows().size()); ! Iterator it = tmapiutils.getOccurrences().iterator(); while (it.hasNext()) { Occurrence o = (Occurrence)it.next(); --- 97,101 ---- assertEquals(2, out.getColumns().size()); assertEquals(3, out.getRows().size()); ! Iterator it = ((Topic) getObjectById("tmapiutils")).getOccurrences().iterator(); while (it.hasNext()) { Occurrence o = (Occurrence)it.next(); *************** *** 109,113 **** assertTrue(l.equals(o.getResource())); } ! it = tmapi.getOccurrences().iterator(); while (it.hasNext()) { Occurrence o = (Occurrence)it.next(); --- 105,109 ---- assertTrue(l.equals(o.getResource())); } ! it = ((Topic) getObjectById("tmapiutils")).getOccurrences().iterator(); while (it.hasNext()) { Occurrence o = (Occurrence)it.next(); *************** *** 120,127 **** public void testOccurrenceByLocator() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); - Topic tmapiutils = topicsIdx.getTopicBySubjectIdentifier(createLocator("tmapiutils")); List params = new ArrayList(); Variable a = new Variable("A"); --- 116,119 ---- *************** *** 134,138 **** assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! Iterator it = tmapiutils.getOccurrences().iterator(); while (it.hasNext()) { Occurrence o = (Occurrence)it.next(); --- 126,130 ---- assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! Iterator it = ((Topic) getObjectById("tmapiutils")).getOccurrences().iterator(); while (it.hasNext()) { Occurrence o = (Occurrence)it.next(); *************** *** 146,158 **** public void testLocatorByOccurrence() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); - Topic tmapiutils = topicsIdx.getTopicBySubjectIdentifier(createLocator("tmapiutils")); List params = new ArrayList(); Variable b = new Variable("B"); Locator loc = m_tm.createLocator("http://tmapiutils.org/"); Occurrence o = null; ! Iterator it = tmapiutils.getOccurrences().iterator(); while (it.hasNext()) { o = (Occurrence)it.next(); --- 138,146 ---- public void testLocatorByOccurrence() throws Exception { List params = new ArrayList(); Variable b = new Variable("B"); Locator loc = m_tm.createLocator("http://tmapiutils.org/"); Occurrence o = null; ! Iterator it = ((Topic) getObjectById("tmapiutils")).getOccurrences().iterator(); while (it.hasNext()) { o = (Occurrence)it.next(); Index: PredicateTestBase.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/PredicateTestBase.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PredicateTestBase.java 8 Mar 2005 12:33:58 -0000 1.7 --- PredicateTestBase.java 9 Mar 2005 12:40:19 -0000 1.8 *************** *** 85,89 **** protected TopicMapObject getObjectById(String name) { ! return (TopicMapObject) _objectMap.get(name); } --- 85,93 ---- protected TopicMapObject getObjectById(String name) { ! TopicMapObject obj = (TopicMapObject) _objectMap.get(name); ! if (obj == null) { ! throw new RuntimeException("Object Id not found :" + name); ! } ! return obj; } Index: TopicMapPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TopicMapPredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TopicMapPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 --- TopicMapPredicateTest.java 9 Mar 2005 12:40:19 -0000 1.5 *************** *** 25,30 **** // TMAPI import org.tmapi.core.TopicMapObject; import org.tmapi.core.Topic; - import org.tmapi.index.core.TopicMapObjectsIndex; /** --- 25,30 ---- // TMAPI import org.tmapi.core.TopicMapObject; + import org.tmapi.core.TopicMap; import org.tmapi.core.Topic; /** *************** *** 51,55 **** public void createTestMap(TopicMap tm) { Topic topic = tm.createTopic(); ! topic.addSourceLocator(createLocator("hello-world")); } --- 51,56 ---- public void createTestMap(TopicMap tm) { Topic topic = tm.createTopic(); ! ! registerObject("hello-world", topic); } *************** *** 72,78 **** public void testClosedMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); params.add(new Variable("A")); --- 73,76 ---- *************** *** 84,89 **** assertEquals(m_tm, out.getRow(0).get(0)); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("hello-world")); ! params.set(0, tmo); out = m_predicate.matches(params, m_context); assertNotNull(out); --- 82,86 ---- assertEquals(m_tm, out.getRow(0).get(0)); ! params.set(0, getObjectById("hello-world")); out = m_predicate.matches(params, m_context); assertNotNull(out); Index: ValuePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ValuePredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ValuePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 --- ValuePredicateTest.java 9 Mar 2005 12:40:20 -0000 1.4 *************** *** 27,31 **** // TMAPI ! import org.tmapi.core.TopicMap import org.tmapi.core.Topic; import org.tmapi.core.Occurrence; --- 27,31 ---- // TMAPI ! import org.tmapi.core.TopicMap; import org.tmapi.core.Topic; import org.tmapi.core.Occurrence; *************** *** 58,68 **** public void createTestMap(TopicMap tm) { Topic bond = tm.createTopic(); Topic fav_drink = tm.createTopic(); ! TopicName tn bond.createTopicName("James Bond", null); ! // ToDo: Create variants! bond.createOccurrence("Vodka martini. Shaken not stirred", fav_drink, null); registerObject("bond", bond); registerObject("favourite-drink", fav_drink); } --- 58,81 ---- public void createTestMap(TopicMap tm) { Topic bond = tm.createTopic(); + Topic hmg = tm.createTopic(); Topic fav_drink = tm.createTopic(); ! ! Topic sort = tm.createTopic(); ! sort.addSubjectIdentifier(tm.createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#sort")); ! ! Topic display = tm.createTopic(); ! display.addSubjectIdentifier(tm.createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#display")); ! ! TopicName tn = bond.createTopicName("James Bond", null); ! tn.createVariant("bond, james", null).addScopingTopic(sort); ! tn.createVariant("James Bond", null).addScopingTopic(display); ! ! bond.createTopicName("007", null).addScopingTopic(hmg); ! bond.createOccurrence("Vodka martini. Shaken not stirred", fav_drink, null); registerObject("bond", bond); registerObject("favourite-drink", fav_drink); + registerObject("hmg", hmg); } *************** *** 83,88 **** assertNotNull(out); assertEquals(1, out.getColumns().size()); ! // TODO: This should be 2 when indexing of Variant names is supported. ! assertEquals(1, out.getRows().size()); Iterator it = out.getColumn(a).iterator(); while (it.hasNext()) { --- 96,100 ---- assertNotNull(out); assertEquals(1, out.getColumns().size()); ! assertEquals(2, out.getRows().size()); Iterator it = out.getColumn(a).iterator(); while (it.hasNext()) { *************** *** 91,95 **** assertEquals("James Bond", ((TopicName)o).getValue()); } else if (o instanceof Occurrence) { ! assertEquals("James Bond", ((Occurrence)o).getValue()); } } --- 103,107 ---- assertEquals("James Bond", ((TopicName)o).getValue()); } else if (o instanceof Occurrence) { ! assertEquals("James Bond", ((Variant)o).getValue()); } } *************** *** 192,196 **** } } - } } --- 204,207 ---- Index: ReifiesPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ReifiesPredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReifiesPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 --- ReifiesPredicateTest.java 9 Mar 2005 12:40:19 -0000 1.5 *************** *** 23,29 **** import org.tmapiutils.query.tolog.predicates.ReifiesPredicate; import org.tmapiutils.query.tolog.utils.VariableSet; - // import org.tmapi.core.utils.TopicMapBuilder; - // import org.tmapi.core.utils.XTMBuilder; - //import org.tmapi.index.core.TopicMapObjectsIndex; // TMAPI import org.tmapi.core.TopicMap; --- 23,26 ---- *************** *** 50,54 **** public String getTestMap() { return "<topicMap xmlns=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" + ! "<topic id=\"fred\"/> <topic id=\"bigco\"/> <topic id=\"worksfor\"/>" "<association id=\"assoc1\">" + "<instanceOf><topicRef xlink:href=\"#worksfor\"/></instanceOf>" + --- 47,51 ---- public String getTestMap() { return "<topicMap xmlns=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" + ! "<topic id=\"fred\"/> <topic id=\"bigco\"/> <topic id=\"worksfor\"/>" + "<association id=\"assoc1\">" + "<instanceOf><topicRef xlink:href=\"#worksfor\"/></instanceOf>" + *************** *** 67,84 **** Topic works_for = tm.createTopic(); Topic fred = tm.createTopic(); - Topic fredemp = tm.createTopic(); Topic barney = tm.createTopic(); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); Association assoc1 = tm.createAssociation(); assoc1.setType(works_for); assoc1.createAssociationRole(fred, employee); assoc1.createAssociationRole(bigco, employer); ! assoc1.createAssociationRole(barney, employee); ! registerObject("assoc1", assoc1); registerObject("fred", fred); registerObject("barney", barney); registerObject("fredemp", fredemp); } --- 64,92 ---- Topic works_for = tm.createTopic(); Topic fred = tm.createTopic(); Topic barney = tm.createTopic(); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); + Topic fredemp = tm.createTopic(); + fredemp.addSubjectIdentifier(tm.createLocator("assoc1")); + + Association assoc1 = tm.createAssociation(); assoc1.setType(works_for); assoc1.createAssociationRole(fred, employee); assoc1.createAssociationRole(bigco, employer); ! assoc1.addSourceLocator(tm.createLocator("assoc1")); ! Association assoc2 = tm.createAssociation(); ! assoc2.setType(works_for); ! assoc2.createAssociationRole(barney, employee); ! assoc2.createAssociationRole(bigco, employer); ! ! registerObject("works-for", works_for); registerObject("fred", fred); registerObject("barney", barney); + registerObject("employee", employee); + registerObject("bigco", bigco); + registerObject("employer", employer); registerObject("fredemp", fredemp); } *************** *** 108,112 **** ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! params.add(fredemp); params.add(a); m_predicate.setParameters(params); --- 116,120 ---- ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! params.add(getObjectById("fredemp")); params.add(a); m_predicate.setParameters(params); *************** *** 140,151 **** params.add(b); m_predicate.setParameters(params); ! params.set(0, getObjectById("fredemp"))); ! params.set(1, getObjectById("assoc1"))); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! params.set(0, getObjectById("fredemp"))); ! params.set(1, getObjectById("m1"))); out = m_predicate.matches(params, m_context); assertNotNull(out); --- 148,159 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, getObjectById("fredemp")); ! params.set(1, getObjectById("assoc1")); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! params.set(0, getObjectById("fredemp")); ! params.set(1, getObjectById("m1")); out = m_predicate.matches(params, m_context); assertNotNull(out); Index: AssociationRolePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/AssociationRolePredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AssociationRolePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 --- AssociationRolePredicateTest.java 9 Mar 2005 12:40:19 -0000 1.5 *************** *** 58,75 **** Topic works_for = tm.createTopic(); Topic fred = tm.createTopic(); - fred.addSubjectIdentifier(tm.createLocator("fred")); Topic barney = tm.createTopic(); - barney.addSubjectIdentifier(tm.createLocator("barney")); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); - Association assoc = tm.createAssociation(); - assoc.setType(works_for); - assoc.createAssociationRole(fred, employee); - assoc.createAssociationRole(bigco, employer); - assoc.createAssociationRole(barney, employee); registerObject("fred", fred); registerObject("barney", barney); } --- 58,82 ---- Topic works_for = tm.createTopic(); Topic fred = tm.createTopic(); Topic barney = tm.createTopic(); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); + Association assoc1 = tm.createAssociation(); + assoc1.setType(works_for); + assoc1.createAssociationRole(fred, employee); + assoc1.createAssociationRole(bigco, employer); + + Association assoc2 = tm.createAssociation(); + assoc2.setType(works_for); + assoc2.createAssociationRole(barney, employee); + assoc2.createAssociationRole(bigco, employer); + + registerObject("works-for", works_for); registerObject("fred", fred); registerObject("barney", barney); + registerObject("employee", employee); + registerObject("bigco", bigco); + registerObject("employer", employer); } Index: DirectInstanceOfPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/DirectInstanceOfPredicateTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DirectInstanceOfPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.6 --- DirectInstanceOfPredicateTest.java 9 Mar 2005 12:40:19 -0000 1.7 *************** *** 18,41 **** package org.tmapiutils.query.tolog.predicates.test; - import java.io.StringReader; import java.util.ArrayList; import java.util.List; - import org.tmapiutils.query.tolog.parser.Predicate; import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.predicates.DirectInstanceOfPredicate; - import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; - //import org.tmapi.core.TopicMapProvider; - //import org.tmapi.core.TopicMapProviderFactory; - //import org.tmapi.core.memory.TopicMapProviderFactoryImpl; - //import org.tmapi.core.source.SerializedTopicMapSource; - //import org.tmapi.core.utils.LTMBuilder; - // TMAPI - import org.tmapi.core.Locator; import org.tmapi.core.TopicMap; - import junit.framework.TestCase; /** --- 18,31 ---- package org.tmapiutils.query.tolog.predicates.test; import java.util.ArrayList; import java.util.List; import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.predicates.DirectInstanceOfPredicate; import org.tmapiutils.query.tolog.utils.VariableSet; // TMAPI import org.tmapi.core.TopicMap; + import org.tmapi.core.Topic; /** *************** *** 44,53 **** * @author Lars Heuer (heuer[at]semagia.com) */ ! public class DirectInstanceOfPredicateTest extends TestCase { - private Predicate m_predicate; - private TopicMap m_tm; - private TopicMapProvider m_provider; - private TologContext m_context; /** --- 34,39 ---- * @author Lars Heuer (heuer[at]semagia.com) */ ! public class DirectInstanceOfPredicateTest extends PredicateTestBase { /** *************** *** 59,66 **** } ! public static void main(String[] args) { ! junit.textui.TestRunner.run(DirectInstanceOfPredicateTest.class); } public void testOpenMatch() throws Exception { --- 45,83 ---- } ! public Class getPredicateClass() { ! return DirectInstanceOfPredicate.class; } + private static final String TESTMAP = + "[digestive:biscuit]\n" + + "[battenburg:cake]\n" + + "[jaffacake:cake]\n" + + "[jaffacake:biscuit]\n" + + "[custardcream:biscuit]\n"; + + + public void createTestMap(TopicMap tm) { + Topic digestive = tm.createTopic(); + Topic biscuit = tm.createTopic(); + Topic battenburg = tm.createTopic(); + Topic cake = tm.createTopic(); + Topic jaffacake = tm.createTopic(); + Topic custardcream = tm.createTopic(); + + digestive.addType(biscuit); + battenburg.addType(cake); + jaffacake.addType(cake); + jaffacake.addType(biscuit); + custardcream.addType(biscuit); + + registerObject("digestive", digestive); + registerObject("biscuit", biscuit); + registerObject("battenburg", battenburg); + registerObject("cake", cake); + registerObject("jaffacake", jaffacake); + registerObject("custardcream", custardcream); + } + + public void testOpenMatch() throws Exception { *************** *** 75,84 **** assertEquals(2, out.getColumns().size()); assertEquals(5, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("digestive"))); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("battenburg"))); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("custardcream"))); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("jaffacake"))); ! assertTrue(out.getColumn(b).contains(m_tm.getObjectById("biscuit"))); ! assertTrue(out.getColumn(b).contains(m_tm.getObjectById("cake"))); } --- 92,101 ---- assertEquals(2, out.getColumns().size()); assertEquals(5, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(getObjectById("digestive"))); ! assertTrue(out.getColumn(a).contains(getObjectById("battenburg"))); ! assertTrue(out.getColumn(a).contains(getObjectById("custardcream"))); ! assertTrue(out.getColumn(a).contains(getObjectById("jaffacake"))); ! assertTrue(out.getColumn(b).contains(getObjectById("biscuit"))); ! assertTrue(out.getColumn(b).contains(getObjectById("cake"))); } *************** *** 94,99 **** assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("battenburg"))); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("jaffacake"))); } --- 111,116 ---- assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(getObjectById("battenburg"))); ! assertTrue(out.getColumn(a).contains(getObjectById("jaffacake"))); } *************** *** 101,105 **** List params = new ArrayList(); Variable a = new Variable("A"); ! params.add(m_tm.getObjectById("jaffacake")); params.add(a); m_predicate.setParameters(params); --- 118,122 ---- List params = new ArrayList(); Variable a = new Variable("A"); ! params.add(getObjectById("jaffacake")); params.add(a); m_predicate.setParameters(params); *************** *** 108,113 **** assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("cake"))); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("biscuit"))); } --- 125,130 ---- assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(getObjectById("cake"))); ! assertTrue(out.getColumn(a).contains(getObjectById("biscuit"))); } *************** *** 116,146 **** Variable a = new Variable("A"); params.add(a); ! params.add(m_tm.getObjectById("cake")); m_predicate.setParameters(params); ! params.set(0, m_tm.getObjectById("jaffacake")); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("jaffacake"))); } ! protected void setUp() throws Exception { ! TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! m_provider = tmpf.newTopicMapProvider(); ! Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! m_tm = m_provider.addTopicMap(src); ! m_predicate = new DirectInstanceOfPredicate(); ! m_predicate.initialise(m_tm); ! m_context = new TologContext(); ! } - private static final String TESTMAP = - "[digestive:biscuit]\n" + - "[battenburg:cake]\n" + - "[jaffacake:cake]\n" + - "[jaffacake:biscuit]\n" + - "[custardcream:biscuit]\n"; } --- 133,157 ---- Variable a = new Variable("A"); params.add(a); ! params.add(getObjectById("cake")); m_predicate.setParameters(params); ! params.set(0, getObjectById("jaffacake")); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(getObjectById("jaffacake"))); } ! // protected void setUp() throws Exception { ! // TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! // m_provider = tmpf.newTopicMapProvider(); ! // Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! // SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! // m_tm = m_provider.addTopicMap(src); ! // m_predicate = new DirectInstanceOfPredicate(); ! // m_predicate.initialise(m_tm); ! // m_context = new TologContext(); ! // } } Index: VariantPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/VariantPredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** VariantPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 --- VariantPredicateTest.java 9 Mar 2005 12:40:20 -0000 1.4 *************** *** 23,26 **** --- 23,29 ---- import org.tmapiutils.query.tolog.predicates.VariantPredicate; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI + import org.tmapi.core.TopicMap; + import org.tmapi.core.Topic; import org.tmapi.core.TopicName; import org.tmapi.core.Variant; *************** *** 44,48 **** */ public String getTestMap() { ! return "[fred = \"Fred Flinstone\";\"Flintstone, F.\"]\n" + "[barney = \"Barney Rubble\";\"Rubble, B.\"]"; } --- 47,71 ---- */ public String getTestMap() { ! return "[fred = \"Fred Flinstone\";\"Flintstone, F.\"]\n" + ! "[barney = \"Barney Rubble\";\"Rubble, B.\"]"; ! } ! ! ! public void createTestMap(TopicMap tm) { ! ! Topic fred = tm.createTopic(); ! Topic barney = tm.createTopic(); ! ! Topic sort = tm.createTopic(); ! sort.addSubjectIdentifier(tm.createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#sort")); ! ! ArrayList sortScope = new ArrayList(); ! sortScope.add(sort); ! ! fred.createTopicName("Fred Flinstone", null).createVariant("Flintstone, F.", sortScope); ! barney.createTopicName("Barney Rubble", null).createVariant("Rubble, B.", sortScope); ! ! registerObject("fred", fred); ! registerObject("barney", barney); } *************** *** 62,66 **** m_predicate.setParameters(params); ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); params.set(0, fredName); VariableSet out = m_predicate.matches(params, m_context); --- 85,89 ---- m_predicate.setParameters(params); ! TopicName fredName = (TopicName) ((Topic) getObjectById("fred")).getTopicNames().iterator().next(); params.set(0, fredName); VariableSet out = m_predicate.matches(params, m_context); *************** *** 78,82 **** m_predicate.setParameters(params); ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(1, fredVar); --- 101,105 ---- m_predicate.setParameters(params); ! TopicName fredName = (TopicName) ((Topic) getObjectById("fred")).getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(1, fredVar); *************** *** 95,99 **** m_predicate.setParameters(params); ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(0, fredName); --- 118,122 ---- m_predicate.setParameters(params); ! TopicName fredName = (TopicName) ((Topic) getObjectById("fred")).getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(0, fredName); Index: DynamicAssociationPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/DynamicAssociationPredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DynamicAssociationPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 --- DynamicAssociationPredicateTest.java 9 Mar 2005 12:40:19 -0000 1.5 *************** *** 18,41 **** package org.tmapiutils.query.tolog.predicates.test; - import java.io.StringReader; import java.util.ArrayList; import java.util.List; - import junit.framework.TestCase; - import org.apache.log4j.BasicConfigurator; ! import org.tmapi.core.Locator; import org.tmapiutils.query.tolog.parser.ClauseList; import org.tmapiutils.query.tolog.parser.PlayerRoleVarPair; import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.predicates.DynamicAssociationPredicate; - import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapProvider; ! import org.tmapi.core.TopicMapProviderFactory; ! import org.tmapi.core.memory.TopicMapProviderFactoryImpl; ! import org.tmapi.core.source.SerializedTopicMapSource; ! import org.tmapi.core.utils.LTMBuilder; /** --- 18,37 ---- package org.tmapiutils.query.tolog.predicates.test; import java.util.ArrayList; import java.util.List; import org.apache.log4j.BasicConfigurator; ! import org.tmapiutils.query.tolog.parser.ClauseList; import org.tmapiutils.query.tolog.parser.PlayerRoleVarPair; import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.predicates.DynamicAssociationPredicate; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI + import org.tmapi.core.Locator; import org.tmapi.core.TopicMap; ! import org.tmapi.core.Topic; ! import org.tmapi.core.Association; ! /** *************** *** 44,52 **** * @author Lars Heuer (heuer[at]semagia.com) */ ! public class DynamicAssociationPredicateTest extends TestCase { ! private TopicMap m_tm; ! private TopicMapProvider m_provider; ! private TologContext m_context; /** --- 40,47 ---- * @author Lars Heuer (heuer[at]semagia.com) */ ! public class DynamicAssociationPredicateTest extends PredicateTestBase { ! ! private static final String TESTMAP ="worksfor(kal:employee, techquila:employer)\n" + "worksfor(fred:employee, bigcorp:employer)\n"; /** *************** *** 56,65 **** public DynamicAssociationPredicateTest(String arg0) { super(arg0); - BasicConfigurator.configure(); } ! public static void main(String[] args) { ! junit.textui.TestRunner.run(DynamicAssociationPredicateTest.class); ! BasicConfigurator.configure(); } --- 51,87 ---- public DynamicAssociationPredicateTest(String arg0) { super(arg0); } ! public Class getPredicateClass() { ! return DynamicAssociationPredicate.class; ! } ! ! public void createTestMap(TopicMap tm) { ! Topic works_for = tm.createTopic(); ! Topic fred = tm.createTopic(); ! Topic kal = tm.createTopic(); ! Topic techquila = tm.createTopic(); ! Topic employee = tm.createTopic(); ! Topic employer = tm.createTopic(); ! Topic bigco = tm.createTopic(); ! ! Association assoc1 = tm.createAssociation(); ! assoc1.setType(works_for); ! assoc1.createAssociationRole(kal, employee); ! assoc1.createAssociationRole(techquila, employer); ! ! ! Association assoc2 = tm.createAssociation(); ! assoc2.setType(works_for); ! assoc2.createAssociationRole(fred, employee); ! assoc2.createAssociationRole(bigco, employer); ! ! registerObject("works-for", works_for); ! registerObject("fred", fred); ! registerObject("kal", kal); ! registerObject("techquila", techquila); ! registerObject("employee", employee); ! registerObject("bigco", bigco); ! registerObject("employer", employer); } *************** *** 69,75 **** DynamicAssociationPredicate p = new DynamicAssociationPredicate(); ArrayList params = new ArrayList(); ! params.add(m_tm.getObjectById("worksfor")); ! params.add(new PlayerRoleVarPair((Topic) m_tm.getObjectById("kal"), (Topic) m_tm.getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("A"), (Topic) m_tm.getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); --- 91,97 ---- DynamicAssociationPredicate p = new DynamicAssociationPredicate(); ArrayList params = new ArrayList(); ! params.add(getObjectById("worksfor")); ! params.add(new PlayerRoleVarPair((Topic) getObjectById("kal"), (Topic) getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("A"), (Topic) getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); *************** *** 81,85 **** assertNotNull(r); assertEquals(r.size(), 1); ! assertEquals(m_tm.getObjectById("techquila"), r.get(0)); } --- 103,107 ---- assertNotNull(r); assertEquals(r.size(), 1); ! assertEquals(getObjectById("techquila"), r.get(0)); } *************** *** 91,97 **** p.initialise(m_tm); ArrayList params = new ArrayList(); ! params.add(m_tm.getObjectById("worksfor")); ! params.add(new PlayerRoleVarPair(new Variable("PERSON"), (Topic) m_tm.getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("COMPANY"), (Topic) m_tm.getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); --- 113,119 ---- p.initialise(m_tm); ArrayList params = new ArrayList(); ! params.add(getObjectById("worksfor")); ! params.add(new PlayerRoleVarPair(new Variable("PERSON"), (Topic) getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("COMPANY"), (Topic) getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); *************** *** 106,114 **** assertEquals(row.size(), 2); assertTrue( ! row.get(0).equals(m_tm.getObjectById("kal")) || ! row.get(0).equals(m_tm.getObjectById("fred"))); assertTrue( ! row.get(1).equals(m_tm.getObjectById("techquila")) || ! row.get(1).equals(m_tm.getObjectById("bigcorp"))); } } --- 128,136 ---- assertEquals(row.size(), 2); assertTrue( ! row.get(0).equals(getObjectById("kal")) || ! row.get(0).equals(getObjectById("fred"))); assertTrue( ! row.get(1).equals(getObjectById("techquila")) || ! row.get(1).equals(getObjectById("bigcorp"))); } } *************** *** 120,125 **** ArrayList params = new ArrayList(); params.add(new Variable("ASSOC")); ! params.add(new PlayerRoleVarPair(new Variable("PERSON"), (Topic) m_tm.getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("COMPANY"), (Topic) m_tm.getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); --- 142,147 ---- ArrayList params = new ArrayList(); params.add(new Variable("ASSOC")); ! params.add(new PlayerRoleVarPair(new Variable("PERSON"), (Topic) getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("COMPANY"), (Topic) getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); *************** *** 134,144 **** assertNotNull(row); assertEquals(row.size(), 3); ! assertEquals(m_tm.getObjectById("worksfor"), row.get(0)); assertTrue( ! row.get(1).equals(m_tm.getObjectById("kal")) || ! row.get(1).equals(m_tm.getObjectById("fred"))); assertTrue( ! row.get(2).equals(m_tm.getObjectById("techquila")) || ! row.get(2).equals(m_tm.getObjectById("bigcorp"))); } } --- 156,166 ---- assertNotNull(row); assertEquals(row.size(), 3); ! assertEquals(getObjectById("worksfor"), row.get(0)); assertTrue( ! row.get(1).equals(getObjectById("kal")) || ! row.get(1).equals(getObjectById("fred"))); assertTrue( ! row.get(2).equals(getObjectById("techquila")) || ! row.get(2).equals(getObjectById("bigcorp"))); } } *************** *** 147,161 **** * @see junit.framework.TestCase#setUp() */ ! protected void setUp() throws Exception { ! TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! m_provider = tmpf.newTopicMapProvider(); ! Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! m_tm = m_provider.addTopicMap(src); ! assertNotNull(m_tm.getObjectById("worksfor")); ! m_context = new TologContext(); ! } - private static final String TESTMAP ="worksfor(kal:employee, techquila:employer)\n" + "worksfor(fred:employee, bigcorp:employer)\n"; } --- 169,182 ---- * @see junit.framework.TestCase#setUp() */ ! // protected void setUp() throws Exception { ! // TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! // m_provider = tmpf.newTopicMapProvider(); ! // Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! // SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! // m_tm = m_provider.addTopicMap(src); ! // assertNotNull(m_tm.getObjectById("worksfor")); ! // m_context = new TologContext(); ! // } } Index: TopicNameTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TopicNameTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TopicNameTest.java 8 Mar 2005 12:33:58 -0000 1.4 --- TopicNameTest.java 9 Mar 2005 12:40:20 -0000 1.5 *************** *** 56,59 **** --- 56,62 ---- public void createTestMap(TopicMap tm) { + Topic sort = tm.createTopic(); + sort.addSubjectIdentifier(tm.createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#sort")); + Topic topic1 = tm.createTopic(); topic1.createTopicName("Topic1", null); *************** *** 61,68 **** topic2.createTopicName("Topic2", null); Topic topic3 = tm.createTopic(); ! topic3.createTopicName("Topic3", null); ! // Should be the display name. ! // Todo: Test if this breaks something ! topic3.createTopicName("topic3", null); topic3.createTopicName("Topic Three", null); Topic topic4 = tm.createTopic(); --- 64,68 ---- topic2.createTopicName("Topic2", null); Topic topic3 = tm.createTopic(); ! topic3.createTopicName("Topic3", null).createVariant("topic3", null).addScopingTopic(sort); topic3.createTopicName("Topic Three", null); Topic topic4 = tm.createTopic(); Index: TypePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TypePredicateTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TypePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.5 --- TypePredicateTest.java 9 Mar 2005 12:40:20 -0000 1.6 *************** *** 25,32 **** import org.tmapiutils.query.tolog.predicates.TypePredicate; import org.tmapiutils.query.tolog.utils.VariableSet; import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; import org.tmapi.core.Occurrence; - import org.tmapi.core.Topic; /** --- 25,34 ---- import org.tmapiutils.query.tolog.predicates.TypePredicate; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI + import org.tmapi.core.TopicMap; + import org.tmapi.core.Topic; import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; import org.tmapi.core.Occurrence; /** Index: AssociationPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/AssociationPredicateTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AssociationPredicateTest.java 8 Mar 2005 12:33:57 -0000 1.6 --- AssociationPredicateTest.java 9 Mar 2005 12:40:19 -0000 1.7 *************** *** 28,32 **** import org.tmapi.core.Topic; import org.tmapi.core.Association; - import org.tmapi.index.core.TopicsIndex; /** --- 28,31 ---- *************** *** 55,69 **** Topic works_for = tm.createTopic(); Topic fred = tm.createTopic(); - fred.addSubjectIdentifier(tm.createLocator("fred")); Topic barney = tm.createTopic(); - barney.addSubjectIdentifier(tm.createLocator("barney")); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); ! Association assoc = tm.createAssociation(); ! assoc.setType(works_for); ! assoc.createAssociationRole(fred, employee); ! assoc.createAssociationRole(bigco, employer); ! assoc.createAssociationRole(barney, employee); } --- 54,78 ---- Topic works_for = tm.createTopic(); Topic fred = tm.createTopic(); Topic barney = tm.createTopic(); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); ! ! Association assoc1 = tm.createAssociation(); ! assoc1.setType(works_for); ! assoc1.createAssociationRole(fred, employee); ! assoc1.createAssociationRole(bigco, employer); ! ! Association assoc2 = tm.createAssociation(); ! assoc2.setType(works_for); ! assoc2.createAssociationRole(barney, employee); ! assoc2.createAssociationRole(bigco, employer); ! ! registerObject("works-for", works_for); ! registerObject("fred", fred); ! registerObject("barney", barney); ! registerObject("employee", employee); ! registerObject("bigco", bigco); ! registerObject("employer", employer); } *************** *** 92,98 **** public void testClosedMatch() throws Exception { - TopicsIndex topicsIdx = (TopicsIndex) m_tm.getHelperObject(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 101,104 ---- *************** *** 104,109 **** assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! Topic fred = topicsIdx.getTopicBySubjectIdentifier(createLocator("fred")); ! params.set(0, fred); out = m_predicate.matches(params, m_context); assertNotNull(out); --- 110,114 ---- assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! params.set(0, getObjectById("fred")); out = m_predicate.matches(params, m_context); assertNotNull(out); *************** *** 113,145 **** } - /* - * $Log$ - * Revision 1.6 2005/03/08 12:33:57 lheuer - * Shift to Apache License 2.0 - * More TMAPI compatible, some classes already compile. ;) - * Deleted CVS log from files - * - * Revision 1.5 2005/03/07 14:00:25 lheuer - * Added missing org.tmapi.core.TopicMap import - * - * Revision 1.4 2005/03/07 13:37:56 lheuer - * Added missing org.tmapi.core.Topic import - * - * Revision 1.3 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.2 2005/03/06 19:37:23 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/11 08:29:29 kal_ahmed - * Added association and association-role predicates. - * - */ \ No newline at end of file --- 118,119 ---- Index: InstanceOfPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/InstanceOfPredicateTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** InstanceOfPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.5 --- InstanceOfPredicateTest.java 9 Mar 2005 12:40:19 -0000 1.6 *************** *** 27,32 **** import org.tmapi.core.TopicMap; import org.tmapi.core.Topic; ! import org.tmapi.index.core.TopicMapObjectsIndex; ! import org.tmapi.index.core.TopicsIndex; /** --- 27,31 ---- import org.tmapi.core.TopicMap; import org.tmapi.core.Topic; ! import org.tmapi.core.Association; /** *************** *** 59,86 **** public void createTestMap(TopicMap tm) { Topic animal = tm.createTopic(); - animal.addSourceLocator(createLocator("animal")); Topic mammal = tm.createTopic(); - mammal.addSourceLocator(createLocator("mammal")); Topic reptile = tm.createTopic(); - reptile.addSourceLocator(createLocator("reptile")); Topic elephant = tm.createTopic(); - elephant.addSourceLocator(createLocator("elephant")); Topic nelly = tm.createTopic(); - nelly.addSourceLocator(createLocator("nelly")); nelly.addType(elephant); Topic supersub = tm.createTopic(); supersub.addSubjectIdentifier(createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#superclass-subclass")); ! sub = tm.createTopic(); sub.addSubjectIdentifier(createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#subclass")); ! supr = tm.createTopic(); supr.addSubjectIdentifier(createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#superclass")); ! Association assoc = tm.createAssociation(); ! assoc.setType(supersub); ! assoc.createAssociationRole(animal, supr); ! assoc.createAssociationRole(mammal, sub); ! assoc.createAssociationRole(reptile, sub); ! assoc.createAssociationRole(mammal, supr); ! assoc.createAssociationRole(elephant, sub); } --- 58,93 ---- public void createTestMap(TopicMap tm) { Topic animal = tm.createTopic(); Topic mammal = tm.createTopic(); Topic reptile = tm.createTopic(); Topic elephant = tm.createTopic(); Topic nelly = tm.createTopic(); nelly.addType(elephant); Topic supersub = tm.createTopic(); supersub.addSubjectIdentifier(createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#superclass-subclass")); ! Topic sub = tm.createTopic(); sub.addSubjectIdentifier(createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#subclass")); ! Topic supr = tm.createTopic(); supr.addSubjectIdentifier(createLocator("http://www.topicmaps.org/xtm/1.0/core.xtm#superclass")); ! Association assoc1 = tm.createAssociation(); ! assoc1.setType(supersub); ! assoc1.createAssociationRole(animal, supr); ! assoc1.createAssociationRole(mammal, sub); ! ! Association assoc2 = tm.createAssociation(); ! assoc2.setType(supersub); ! assoc2.createAssociationRole(animal, supr); ! assoc2.createAssociationRole(reptile, sub); ! ! Association assoc3 = tm.createAssociation(); ! assoc3.setType(supersub); ! assoc3.createAssociationRole(mammal, supr); ! assoc3.createAssociationRole(elephant, sub); ! ! registerObject("animal", animal); ! registerObject("nelly", nelly); ! registerObject("elephant", elephant); ! registerObject("mammal", mammal); ! registerObject("reptile", reptile); } *************** *** 93,106 **** public void testClassMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); - TopicMapObject nelly = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("nelly")); - TopicMapObject elephant = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("elephant")); - TopicMapObject mammal = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("mammal")); - TopicMapObject animal = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("animal")); ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! params.add(nelly); params.add(a); m_predicate.setParameters(params); --- 100,106 ---- public void testClassMatch() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! params.add(getObjectById("nelly")); params.add(a); m_predicate.setParameters(params); *************** *** 109,127 **** assertEquals(1, out.getColumns().size()); assertEquals(3, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(elephant)); ! assertTrue(out.getColumn(a).contains(mammal)); ! assertTrue(out.getColumn(a).contains(animal)); } public void testInstanceMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); - TopicMapObject animal = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("animal")); - TopicMapObject nelly = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("nelly")); ArrayList params = new ArrayList(); Variable a = new Variable("A"); params.add(a); ! params.add(animal); m_predicate.setParameters(params); VariableSet out = m_predicate.matches(params, m_context); --- 109,122 ---- assertEquals(1, out.getColumns().size()); assertEquals(3, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(getObjectById("elephant"))); ! assertTrue(out.getColumn(a).contains(getObjectById("mammal"))); ! assertTrue(out.getColumn(a).contains(getObjectById("animal"))); } public void testInstanceMatch() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); params.add(a); ! params.add(getObjectById("animal")); m_predicate.setParameters(params); VariableSet out = m_predicate.matches(params, m_context); *************** *** 129,143 **** assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(nelly)); } public void testOpenMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); - TopicMapObject animal = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("animal")); - TopicMapObject nelly = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("nelly")); - TopicMapObject elephant = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("elephant")); - TopicMapObject mammal = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("mammal")); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 124,131 ---- assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(getObjectById("nelly"))); } public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 150,167 **** assertEquals(2, out.getColumns().size()); assertEquals(3, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(nelly)); ! assertTrue(out.getColumn(b).contains(elephant)); ! assertTrue(out.getColumn(b).contains(mammal)); ! assertTrue(out.getColumn(b).contains(animal)); } public void testClosedMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); - TopicMapObject animal = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("animal")); - TopicMapObject nelly = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("nelly")); - TopicMapObject reptile = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("reptile")); - TopicMapObject mammal = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("mammal")); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 138,148 ---- assertEquals(2, out.getColumns().size()); assertEquals(3, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(getObjectById("nelly"))); ! assertTrue(out.getColumn(b).contains(getObjectById("elephant"))); ! assertTrue(out.getColumn(b).contains(getObjectById("mammal"))); ! assertTrue(out.getColumn(b).contains(getObjectById("animal"))); } public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 170,181 **** params.add(b); m_predicate.setParameters(params); ! params.set(0, nelly); ! params.set(1, mammal); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(1, out.getRows().size()); ! params.set(0, nelly); ! params.set(1, reptile); out = m_predicate.matches(params, m_context); assertNotNull(out); --- 151,162 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, getObjectById("nelly")); ! params.set(1, getObjectById("mammal")); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(1, out.getRows().size()); ! params.set(0, getObjectById("nelly")); ! params.set(1, getObjectById("reptile")); out = m_predicate.matches(params, m_context); assertNotNull(out); Index: ValueLikePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ValueLikePredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ValueLikePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 --- ValueLikePredicateTest.java 9 Mar 2005 12:40:20 -0000 1.5 *************** *** 18,41 **** package org.tmapiutils.query.tolog.predicates.test; - //import java.io.StringReader; import java.util.ArrayList; import java.util.Iterator; - import org.tmapiutils.query.tolog.parser.Predicate; import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.predicates.ValueLikePredicate; import org.tmapiutils.query.tolog.utils.VariableSet; - //import org.tmapi.core.TopicMapProviderFactory; - //import org.tmapi.core.memory.TopicMapProviderFactoryImpl; - //import org.tmapi.core.memory.index.LuceneFullTextIndexProvider; - //import org.tmapi.core.source.SerializedTopicMapSource; - // TMAPI import org.tmapi.core.Locator; import org.tmapi.core.Topic; - import org.tmapi.core.TopicName; import org.tmapi.core.Occurrence; ! import org.tmapi.core.TopicMapObject; /** --- 18,35 ---- package org.tmapiutils.query.tolog.predicates.test; import java.util.ArrayList; import java.util.Iterator; import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.predicates.ValueLikePredicate; import org.tmapiutils.query.tolog.utils.VariableSet; // TMAPI import org.tmapi.core.Locator; + import org.tmapi.core.TopicMapObject; + import org.tmapi.core.TopicMap; import org.tmapi.core.Topic; import org.tmapi.core.Occurrence; ! import org.tmapi.core.TopicName; /** *************** *** 60,63 **** --- 54,72 ---- } + + public void createTestMap(TopicMap tm) { + + Topic test = tm.createTopic(); + Topic description = tm.createTopic(); + + test.createTopicNam... [truncated message content] |
From: Lars H. <lh...@us...> - 2005-03-09 12:40:33
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2232/src/org/tmapiutils/query/tolog/test Modified Files: AssociationPredicateTest.java Increment.java ProjectionTest.java SortingTest.java Log Message: - All predicates and predicate tests now compile - TMAPI compatible enhancements in /parser directory - Updated ToDo Index: ProjectionTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/ProjectionTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProjectionTest.java 8 Mar 2005 12:33:58 -0000 1.3 --- ProjectionTest.java 9 Mar 2005 12:40:20 -0000 1.4 *************** *** 22,29 **** import java.util.Iterator; import java.util.List; import junit.framework.TestCase; - import org.tmapi.core.Locator; import org.tmapiutils.query.tolog.parser.ClauseList; import org.tmapiutils.query.tolog.parser.PlayerRoleVarPair; --- 22,29 ---- import java.util.Iterator; import java.util.List; + import java.util.HashMap; import junit.framework.TestCase; import org.tmapiutils.query.tolog.parser.ClauseList; import org.tmapiutils.query.tolog.parser.PlayerRoleVarPair; *************** *** 34,54 **** import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; ! import org.tmapi.core.Topic; import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapProvider; ! import org.tmapi.core.TopicMapProviderFactory; ! import org.tmapi.core.memory.TopicMapProviderFactoryImpl; ! import org.tmapi.core.source.SerializedTopicMapSource; ! import org.tmapi.core.utils.LTMBuilder; /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class ProjectionTest extends TestCase { private TopicMap m_tm; ! ! private TopicMapProvider m_provider; /** --- 34,56 ---- import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; ! // TMAPI ! import org.tmapi.core.Locator; ! import org.tmapi.core.TopicMapSystemFactory; ! import org.tmapi.core.TopicMapSystem; ! import org.tmapi.core.TopicMapObject; import org.tmapi.core.TopicMap; ! import org.tmapi.core.Topic; ! import org.tmapi.core.Association; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ProjectionTest extends TestCase { private TopicMap m_tm; ! private TopicMapSystem _tmSystem; ! private HashMap _objectMap; /** *************** *** 68,74 **** DynamicAssociationPredicate p = new DynamicAssociationPredicate(); ArrayList params = new ArrayList(); ! params.add(m_tm.getObjectById("contains")); ! params.add(new PlayerRoleVarPair(new Variable("CONTAINER"), m_tm.getObjectById("container"))); ! params.add(new PlayerRoleVarPair(new Variable("CONTAINEE"), m_tm.getObjectById("containee"))); p.setParameters(params); p.initialise(m_tm); --- 70,76 ---- DynamicAssociationPredicate p = new DynamicAssociationPredicate(); ArrayList params = new ArrayList(); ! params.add(getObjectById("contains")); ! params.add(new PlayerRoleVarPair(new Variable("CONTAINER"), (Topic) getObjectById("container"))); ! params.add(new PlayerRoleVarPair(new Variable("CONTAINEE"), (Topic) getObjectById("containee"))); p.setParameters(params); p.initialise(m_tm); *************** *** 95,106 **** assertTrue(row.get(0) instanceof Topic); assertTrue(row.get(1) instanceof Integer); ! if (row.get(0).equals(m_tm.getObjectById("europe"))) { assertEquals(new Integer(3), row.get(1)); ! } else if (row.get(0).equals(m_tm.getObjectById("asia"))) { assertEquals(new Integer(2), row.get(1)); } } } ! /* * @see TestCase#setUp() --- 97,108 ---- assertTrue(row.get(0) instanceof Topic); assertTrue(row.get(1) instanceof Integer); ! if (row.get(0).equals(getObjectById("europe"))) { assertEquals(new Integer(3), row.get(1)); ! } else if (row.get(0).equals(getObjectById("asia"))) { assertEquals(new Integer(2), row.get(1)); } } } ! /* * @see TestCase#setUp() *************** *** 108,116 **** protected void setUp() throws Exception { super.setUp(); ! TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! m_provider = tmpf.newTopicMapProvider(); ! Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! m_tm = m_provider.addTopicMap(src); } --- 110,192 ---- protected void setUp() throws Exception { super.setUp(); ! _objectMap = new HashMap(); ! _tmSystem = TopicMapSystemFactory.newInstance().newTopicMapSystem(); ! m_tm = _tmSystem.createTopicMap("http://tmapiutils.org/test/tolog1.0/"); ! createTestMap(m_tm); ! // TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! // m_provider = tmpf.newTopicMapProvider(); ! // Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! // SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! // m_tm = m_provider.addTopicMap(src); ! } ! ! protected void tearDown() throws Exception{ ! super.tearDown(); ! _objectMap.clear(); ! // remove created TopicMaps from TopicMapSystem ! m_tm.remove(); ! // Close TopicMapSystem instance ! _tmSystem.close(); ! } ! ! public void createTestMap(TopicMap tm) { ! Topic contains = tm.createTopic(); ! Topic europe = tm.createTopic(); ! Topic container = tm.createTopic(); ! Topic uk = tm.createTopic(); ! Topic containee = tm.createTopic(); ! Topic germany = tm.createTopic(); ! Topic france = tm.createTopic(); ! Topic asia = tm.createTopic(); ! Topic japan = tm.createTopic(); ! Topic india = tm.createTopic(); ! ! Association assoc1 = tm.createAssociation(); ! assoc1.setType(contains); ! assoc1.createAssociationRole(europe, container); ! assoc1.createAssociationRole(germany, containee); ! ! Association assoc2 = tm.createAssociation(); ! assoc2.setType(contains); ! assoc2.createAssociationRole(europe, container); ! assoc2.createAssociationRole(uk, containee); ! ! Association assoc3 = tm.createAssociation(); ! assoc3.setType(contains); ! assoc3.createAssociationRole(europe, container); ! assoc3.createAssociationRole(france, containee); ! ! Association assoc4 = tm.createAssociation(); ! assoc4.setType(contains); ! assoc4.createAssociationRole(asia, container); ! assoc4.createAssociationRole(japan, containee); ! ! Association assoc5 = tm.createAssociation(); ! assoc5.setType(contains); ! assoc5.createAssociationRole(asia, container); ! assoc5.createAssociationRole(india, containee); ! ! registerObject("contains", contains); ! registerObject("container", container); ! registerObject("containee", containee); ! registerObject("europe", europe); ! registerObject("uk", uk); ! registerObject("germany", germany); ! registerObject("france", france); ! registerObject("asia", asia); ! registerObject("japan", japan); ! registerObject("india", india); ! } ! ! protected void registerObject(String name, TopicMapObject obj) { ! _objectMap.put(name, obj); ! } ! ! protected TopicMapObject getObjectById(String name) { ! TopicMapObject obj = (TopicMapObject) _objectMap.get(name); ! if (obj == null) { ! throw new RuntimeException("Object Id not found :" + name); ! } ! return obj; } *************** *** 118,122 **** "contains(europe:container, uk:containee)\n" + "contains(europe:container, germany:containee)\n" + ! "contains(europe:container, france:containee)\n" + "contains(asia:container, japan:containee)\n" + "contains(asia:container, india:containee)\n"; --- 194,198 ---- "contains(europe:container, uk:containee)\n" + "contains(europe:container, germany:containee)\n" + ! "contains(europe:container, france:containee)\n" + "contains(asia:container, japan:containee)\n" + "contains(asia:container, india:containee)\n"; Index: AssociationPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/AssociationPredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AssociationPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 --- AssociationPredicateTest.java 9 Mar 2005 12:40:20 -0000 1.4 *************** *** 21,29 **** import java.util.ArrayList; import java.util.List; import junit.framework.TestCase; import org.apache.log4j.BasicConfigurator; - import org.tmapi.core.Locator; import org.tmapiutils.query.tolog.parser.ClauseList; import org.tmapiutils.query.tolog.parser.PlayerRoleVarPair; --- 21,29 ---- import java.util.ArrayList; import java.util.List; + import java.util.HashMap; import junit.framework.TestCase; import org.apache.log4j.BasicConfigurator; import org.tmapiutils.query.tolog.parser.ClauseList; import org.tmapiutils.query.tolog.parser.PlayerRoleVarPair; *************** *** 32,41 **** import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapProvider; ! import org.tmapi.core.TopicMapProviderFactory; ! import org.tmapi.core.memory.TopicMapProviderFactoryImpl; ! import org.tmapi.core.source.SerializedTopicMapSource; ! import org.tmapi.core.utils.LTMBuilder; /** --- 32,44 ---- import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI + import org.tmapi.core.Locator; + import org.tmapi.core.TopicMapSystemFactory; + import org.tmapi.core.TopicMapSystem; + import org.tmapi.core.TopicMapObject; import org.tmapi.core.TopicMap; ! import org.tmapi.core.Topic; ! import org.tmapi.core.Association; ! /** *************** *** 47,52 **** private TopicMap m_tm; ! ! private TopicMapProvider m_provider; /** --- 50,55 ---- private TopicMap m_tm; ! private TopicMapSystem _tmSystem; ! private HashMap _objectMap; /** *************** *** 69,74 **** ArrayList params = new ArrayList(); params.add(m_tm.getObjectById("worksfor")); ! params.add(new PlayerRoleVarPair(m_tm.getObjectById("kal"), m_tm.getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("A"), m_tm.getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); --- 72,77 ---- ArrayList params = new ArrayList(); params.add(m_tm.getObjectById("worksfor")); ! params.add(new PlayerRoleVarPair((Topic) getObjectById("kal"), (Topic) getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("A"), (Topic) getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); *************** *** 81,85 **** assertNotNull(row); assertEquals(row.size(), 1); ! assertEquals(m_tm.getObjectById("techquila"), row.get(0)); } --- 84,88 ---- assertNotNull(row); assertEquals(row.size(), 1); ! assertEquals(getObjectById("techquila"), row.get(0)); } *************** *** 92,97 **** ArrayList params = new ArrayList(); params.add(m_tm.getObjectById("worksfor")); ! params.add(new PlayerRoleVarPair(new Variable("PERSON"), m_tm.getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("COMPANY"), m_tm.getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); --- 95,100 ---- ArrayList params = new ArrayList(); params.add(m_tm.getObjectById("worksfor")); ! params.add(new PlayerRoleVarPair(new Variable("PERSON"), (Topic) getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("COMPANY"), (Topic) getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); *************** *** 107,115 **** assertEquals(row.size(), 2); assertTrue( ! row.get(0).equals(m_tm.getObjectById("kal")) || ! row.get(0).equals(m_tm.getObjectById("fred"))); assertTrue( ! row.get(1).equals(m_tm.getObjectById("techquila")) || ! row.get(1).equals(m_tm.getObjectById("bigcorp"))); } } --- 110,118 ---- assertEquals(row.size(), 2); assertTrue( ! row.get(0).equals(getObjectById("kal")) || ! row.get(0).equals(getObjectById("fred"))); assertTrue( ! row.get(1).equals(getObjectById("techquila")) || ! row.get(1).equals(getObjectById("bigcorp"))); } } *************** *** 121,126 **** ArrayList params = new ArrayList(); params.add(new Variable("ASSOC")); ! params.add(new PlayerRoleVarPair(new Variable("PERSON"), m_tm.getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("COMPANY"), m_tm.getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); --- 124,129 ---- ArrayList params = new ArrayList(); params.add(new Variable("ASSOC")); ! params.add(new PlayerRoleVarPair(new Variable("PERSON"), (Topic) getObjectById("employee"))); ! params.add(new PlayerRoleVarPair(new Variable("COMPANY"), (Topic) getObjectById("employer"))); p.setParameters(params); c.addPredicate(p); *************** *** 136,159 **** assertNotNull(row); assertEquals(row.size(), 3); ! assertEquals(row.get(0), m_tm.getObjectById("worksfor")); assertTrue( ! row.get(1).equals(m_tm.getObjectById("kal")) || ! row.get(1).equals(m_tm.getObjectById("fred"))); assertTrue( ! row.get(2).equals(m_tm.getObjectById("techquila")) || ! row.get(2).equals(m_tm.getObjectById("bigcorp"))); } } - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ protected void setUp() throws Exception { ! TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! m_provider = tmpf.newTopicMapProvider(); ! Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! m_tm = m_provider.addTopicMap(src); ! assertNotNull(m_tm.getObjectById("worksfor")); } --- 139,213 ---- assertNotNull(row); assertEquals(row.size(), 3); ! assertEquals(row.get(0), getObjectById("worksfor")); assertTrue( ! row.get(1).equals(getObjectById("kal")) || ! row.get(1).equals(getObjectById("fred"))); assertTrue( ! row.get(2).equals(getObjectById("techquila")) || ! row.get(2).equals(getObjectById("bigcorp"))); } } protected void setUp() throws Exception { ! super.setUp(); ! _objectMap = new HashMap(); ! _tmSystem = TopicMapSystemFactory.newInstance().newTopicMapSystem(); ! m_tm = _tmSystem.createTopicMap("http://tmapiutils.org/test/tolog1.0/"); ! createTestMap(m_tm); ! // TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); ! // m_provider = tmpf.newTopicMapProvider(); ! // Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.techquila.com/test/tolog1.0.xtm"); ! // SerializedTopicMapSource src = new SerializedTopicMapSource(new StringReader(TESTMAP), loc, new LTMBuilder()); ! // m_tm = m_provider.addTopicMap(src); ! } ! ! protected void tearDown() throws Exception{ ! super.tearDown(); ! _objectMap.clear(); ! // remove created TopicMaps from TopicMapSystem ! m_tm.remove(); ! // Close TopicMapSystem instance ! _tmSystem.close(); ! } ! ! public void createTestMap(TopicMap tm) { ! Topic works_for = tm.createTopic(); ! Topic fred = tm.createTopic(); ! Topic kal = tm.createTopic(); ! Topic techquila = tm.createTopic(); ! Topic employee = tm.createTopic(); ! Topic employer = tm.createTopic(); ! Topic bigco = tm.createTopic(); ! ! Association assoc1 = tm.createAssociation(); ! assoc1.setType(works_for); ! assoc1.createAssociationRole(kal, employee); ! assoc1.createAssociationRole(techquila, employer); ! ! ! Association assoc2 = tm.createAssociation(); ! assoc2.setType(works_for); ! assoc2.createAssociationRole(fred, employee); ! assoc2.createAssociationRole(bigco, employer); ! ! registerObject("works-for", works_for); ! registerObject("fred", fred); ! registerObject("kal", kal); ! registerObject("techquila", techquila); ! registerObject("employee", employee); ! registerObject("bigco", bigco); ! registerObject("employer", employer); ! } ! ! protected void registerObject(String name, TopicMapObject obj) { ! _objectMap.put(name, obj); ! } ! ! protected TopicMapObject getObjectById(String name) { ! TopicMapObject obj = (TopicMapObject) _objectMap.get(name); ! if (obj == null) { ! throw new RuntimeException("Object Id not found :" + name); ! } ! return obj; } Index: Increment.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/Increment.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Increment.java 8 Mar 2005 12:33:58 -0000 1.2 --- Increment.java 9 Mar 2005 12:40:20 -0000 1.3 *************** *** 26,29 **** --- 26,30 ---- import org.tmapiutils.query.tolog.predicates.PredicateBase; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI import org.tmapi.core.TopicMap; Index: SortingTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/SortingTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SortingTest.java 8 Mar 2005 12:33:58 -0000 1.3 --- SortingTest.java 9 Mar 2005 12:40:20 -0000 1.4 *************** *** 19,35 **** import java.util.ArrayList; import junit.framework.TestCase; - import org.tmapi.core.Locator; import org.tmapiutils.query.tolog.parser.Sorting; import org.tmapiutils.query.tolog.parser.Variable; ! import org.tmapi.core.TopicName; ! import org.tmapi.core.Topic; import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapProvider; ! import org.tmapi.core.TopicMapProviderFactory; ! import org.tmapi.core.utils.IDGenerator; ! import org.tmapi.core.utils.IDGeneratorFactory; /** --- 19,37 ---- import java.util.ArrayList; + import java.util.HashMap; + import java.util.Arrays; import junit.framework.TestCase; import org.tmapiutils.query.tolog.parser.Sorting; import org.tmapiutils.query.tolog.parser.Variable; ! ! // TMAPI ! import org.tmapi.core.TopicMapSystemFactory; ! import org.tmapi.core.TopicMapSystem; import org.tmapi.core.TopicMap; ! import org.tmapi.core.Topic; ! import org.tmapi.core.TopicName; ! /** *************** *** 40,45 **** public class SortingTest extends TestCase { ! private TopicMapProvider m_provider; ! private IDGenerator m_idgen; /** --- 42,46 ---- public class SortingTest extends TestCase { ! private TopicMapSystem _tmSystem; /** *************** *** 49,55 **** public SortingTest(String arg0) throws Exception { super(arg0); ! TopicMapProviderFactory tmpf = TopicMapProviderFactory.newInstance(); ! m_provider = tmpf.newTopicMapProvider(); ! m_idgen = IDGeneratorFactory.newIDGenerator(); } --- 50,54 ---- public SortingTest(String arg0) throws Exception { super(arg0); ! _tmSystem = TopicMapSystemFactory.newInstance().newTopicMapSystem(); } *************** *** 91,98 **** public void testSortTopics() throws Exception { ! TopicMap tm = newTopicMap(); ! Topic t1 = tm.createTopic("t1"); ! Topic t2 = tm.createTopic("t2"); ! Topic t3 = tm.createTopic("t3"); ArrayList cols = new ArrayList(); --- 90,113 ---- public void testSortTopics() throws Exception { ! // TopicMap tm = newTopicMap(); ! // Topic t1 = tm.createTopic("t1"); ! // Topic t2 = tm.createTopic("t2"); ! // Topic t3 = tm.createTopic("t3"); ! ! TopicMap tm = _tmSystem.createTopicMap("http://tmapiutils.org/test/tolog1.0/test/SortTopics"); ! Topic t1 = tm.createTopic(); ! Topic t2 = tm.createTopic(); ! Topic t3 = tm.createTopic(); ! ! String[] objectIds = new String[3]; ! objectIds[0] = t1.getObjectId(); ! objectIds[1] = t2.getObjectId(); ! objectIds[2] = t3.getObjectId(); ! Arrays.sort(objectIds); ! ! HashMap topics = new HashMap(); ! topics.put(t1.getObjectId(), t1); ! topics.put(t2.getObjectId(), t2); ! topics.put(t3.getObjectId(), t3); ArrayList cols = new ArrayList(); *************** *** 101,113 **** ArrayList row1 = new ArrayList(); ! row1.add(t3); rows.add(row1); ArrayList row2 = new ArrayList(); ! row2.add(t1); rows.add(row2); ArrayList row3 = new ArrayList(); ! row3.add(t2); rows.add(row3); --- 116,131 ---- ArrayList row1 = new ArrayList(); ! //row1.add(t3); ! row1.add(topics.get(objectIds[2])); rows.add(row1); ArrayList row2 = new ArrayList(); ! // row2.add(t1); ! row2.add(topics.get(objectIds[0])); rows.add(row2); ArrayList row3 = new ArrayList(); ! // row3.add(t2); ! row3.add(topics.get(objectIds[1])); rows.add(row3); *************** *** 130,140 **** public void testSortNames() throws Exception { ! TopicMap tm = newTopicMap(); ! Topic t1 = tm.createTopic("t1"); ! TopicName bn1 = t1.createName("bn1","Topic C"); ! Topic t2 = tm.createTopic("t2"); ! TopicName bn2 = t2.createName("bn2", "Topic B"); ! Topic t3 = tm.createTopic("t3"); ! TopicName bn3 = t3.createName("bn3", "Topic A"); ArrayList cols = new ArrayList(); --- 148,165 ---- public void testSortNames() throws Exception { ! // TopicMap tm = newTopicMap(); ! // Topic t1 = tm.createTopic("t1"); ! // TopicName bn1 = t1.createName("bn1","Topic C"); ! // Topic t2 = tm.createTopic("t2"); ! // TopicName bn2 = t2.createName("bn2", "Topic B"); ! // Topic t3 = tm.createTopic("t3"); ! // TopicName bn3 = t3.createName("bn3", "Topic A"); ! TopicMap tm = _tmSystem.createTopicMap("http://tmapiutils.org/test/tolog1.0/test/SortNames"); ! Topic t1 = tm.createTopic(); ! TopicName bn1 = t1.createTopicName("Topic C", null); ! Topic t2 = tm.createTopic(); ! TopicName bn2 = t2.createTopicName("Topic B", null); ! Topic t3 = tm.createTopic(); ! TopicName bn3 = t3.createTopicName("Topic A", null); ArrayList cols = new ArrayList(); *************** *** 165,172 **** } ! private TopicMap newTopicMap() throws Exception { ! Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.tm4j.org/tests/" + m_idgen.getObjectId()); ! return m_provider.createTopicMap(loc); ! } } --- 190,197 ---- } ! // private TopicMap newTopicMap() throws Exception { ! // Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.tm4j.org/tests/" + m_idgen.getObjectId()); ! // return m_provider.createTopicMap(loc); ! // } } |
From: Lars H. <lh...@us...> - 2005-03-09 12:40:33
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2232/src/org/tmapiutils/query/tolog Modified Files: todo-log.txt Log Message: - All predicates and predicate tests now compile - TMAPI compatible enhancements in /parser directory - Updated ToDo Index: todo-log.txt =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/todo-log.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** todo-log.txt 8 Mar 2005 12:33:39 -0000 1.9 --- todo-log.txt 9 Mar 2005 12:40:20 -0000 1.10 *************** *** 22,109 **** - File: query\tolog\predicates\InstanceOfPredicate.java - line: 23 - TopicMapUtils - Usage of org.tm4j.topicmap.TopicMapUtils (has become org.tmapi.core.TopicMapUtils!) - line: 35 - TopicMapUtils - Usage of org.tm4j.topicmap.TopicMapUtils (has become org.tmapi.core.TopicMapUtils!) - line: 167 - getIndexManager() - Should become getHelperObject(IndexInterface.class) - - - File: query\tolog\predicates\test\DirectInstanceOfPredicateTest.java - line: 18 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 19 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 20 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 35 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 114 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 115 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - - - File: query\tolog\predicates\test\DynamicAssociationPredicateTest.java - line: 28 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 29 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 30 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 41 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 142 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 143 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - - - File: query\tolog\predicates\test\ValueLikePredicateTest.java - line: 25 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 26 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 107 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 108 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 113 - getIndexManager() - Should become getHelperObject(IndexInterface.class) - - - File: query\tolog\predicates\test\ValuePredicateTest.java - line: 21 - DataObject - DataObject has no equivalent in TMAPI (either an Occurrence or a Variant) - line: 165 - DataObject - DataObject has no equivalent in TMAPI (either an Occurrence or a Variant) - line: 166 - DataObject - DataObject has no equivalent in TMAPI (either an Occurrence or a Variant) - - File: query\tolog\test\MemoryQueryEvaluatorImplTest.java line: 28 --- 22,25 ---- *************** *** 133,189 **** - File: query\tolog\test\ProjectionTest.java - line: 31 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 32 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 33 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 45 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 103 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 104 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - - - File: query\tolog\test\SortingTest.java - line: 23 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 24 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 26 - IDGeneratorFactory - Has become org.tmapi.core.utils.IDGeneratorFactory - line: 34 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 43 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 44 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 45 - IDGeneratorFactory - Has become org.tmapi.core.utils.IDGeneratorFactory - line: 126 - createName - Must become "createTopicName" - line: 128 - createName - Must become "createTopicName" - line: 130 - createName - Must become "createTopicName" - File: query\tolog\test\TologParserTest.java --- 49,52 ---- |
From: Lars H. <lh...@us...> - 2005-03-09 12:40:29
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2232/src/org/tmapiutils/query/tolog/parser Modified Files: ClauseList.java PlayerRolePair.java Predicate.java TologRuleInstanceImpl.java Log Message: - All predicates and predicate tests now compile - TMAPI compatible enhancements in /parser directory - Updated ToDo Index: PlayerRolePair.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/PlayerRolePair.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PlayerRolePair.java 8 Mar 2005 12:33:40 -0000 1.2 --- PlayerRolePair.java 9 Mar 2005 12:40:18 -0000 1.3 *************** *** 19,22 **** --- 19,23 ---- import org.tmapiutils.query.tolog.utils.ReferenceUtils; + // TMAPI import org.tmapi.core.Topic; Index: Predicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Predicate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Predicate.java 8 Mar 2005 12:33:40 -0000 1.2 --- Predicate.java 9 Mar 2005 12:40:18 -0000 1.3 *************** *** 24,27 **** --- 24,28 ---- import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI import org.tmapi.core.TopicMap; Index: TologRuleInstanceImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/TologRuleInstanceImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TologRuleInstanceImpl.java 8 Mar 2005 12:33:40 -0000 1.3 --- TologRuleInstanceImpl.java 9 Mar 2005 12:40:18 -0000 1.4 *************** *** 32,38 **** import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; ! import org.tmapi.core.Topic; ! import org.tmapi.core.TopicMap; import org.tmapi.core.TopicMapObject; /** --- 32,40 ---- import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; ! // TMAPI import org.tmapi.core.TopicMapObject; + import org.tmapi.core.TopicMap; + import org.tmapi.core.Topic; + /** Index: ClauseList.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/ClauseList.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ClauseList.java 8 Mar 2005 12:33:40 -0000 1.2 --- ClauseList.java 9 Mar 2005 12:40:18 -0000 1.3 *************** *** 27,30 **** --- 27,31 ---- import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI import org.tmapi.core.Topic; |
From: Lars H. <lh...@us...> - 2005-03-09 12:40:29
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2232/src/org/tmapiutils/query/tolog/predicates Modified Files: AssociationPredicate.java InstanceOfPredicate.java PredicateBase.java ReifiesPredicate.java ScopePredicate.java TopicMapPredicate.java TypePredicate.java ValuePredicate.java Log Message: - All predicates and predicate tests now compile - TMAPI compatible enhancements in /parser directory - Updated ToDo Index: PredicateBase.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/PredicateBase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PredicateBase.java 8 Mar 2005 12:33:57 -0000 1.2 --- PredicateBase.java 9 Mar 2005 12:40:19 -0000 1.3 *************** *** 31,34 **** --- 31,35 ---- import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI import org.tmapi.core.Topic; import org.tmapi.core.TopicMap; Index: AssociationPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/AssociationPredicate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AssociationPredicate.java 8 Mar 2005 12:33:56 -0000 1.2 --- AssociationPredicate.java 9 Mar 2005 12:40:19 -0000 1.3 *************** *** 24,27 **** --- 24,28 ---- import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI import org.tmapi.core.Association; Index: TopicMapPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/TopicMapPredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TopicMapPredicate.java 8 Mar 2005 12:33:57 -0000 1.3 --- TopicMapPredicate.java 9 Mar 2005 12:40:19 -0000 1.4 *************** *** 23,26 **** --- 23,27 ---- import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI import org.tmapi.core.TopicMap; Index: TypePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/TypePredicate.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TypePredicate.java 8 Mar 2005 12:33:57 -0000 1.4 --- TypePredicate.java 9 Mar 2005 12:40:19 -0000 1.5 *************** *** 26,30 **** import org.tmapiutils.query.tolog.utils.VariableSet; - import org.tmapiutils.utils.IndexUtils; // TMAPI import org.tmapi.core.TopicMapObject; --- 26,29 ---- Index: ValuePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/ValuePredicate.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ValuePredicate.java 8 Mar 2005 12:33:57 -0000 1.4 --- ValuePredicate.java 9 Mar 2005 12:40:19 -0000 1.5 *************** *** 26,30 **** import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.utils.VariableSet; - // TMAPI import org.tmapi.core.TopicMapObject; --- 26,29 ---- Index: ScopePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/ScopePredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ScopePredicate.java 8 Mar 2005 12:33:57 -0000 1.3 --- ScopePredicate.java 9 Mar 2005 12:40:19 -0000 1.4 *************** *** 27,31 **** import org.tmapiutils.utils.IndexUtils; - // TMAPI import org.tmapi.core.TopicMap; --- 27,30 ---- Index: ReifiesPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/ReifiesPredicate.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ReifiesPredicate.java 8 Mar 2005 12:33:57 -0000 1.6 --- ReifiesPredicate.java 9 Mar 2005 12:40:19 -0000 1.7 *************** *** 94,108 **** addResultsRow(ret, new Object[] {topic, object}); } - // Locator l = topic.getSubjectLocators(); - // if (l == null) { - // return; - // } - // Iterator it = object.getSourceLocators().iterator(); - // while (it.hasNext()) { - // if (it.next().equals(l)) { - // addResultsRow(ret, new Object[] {topic, object}); - // return; - // } - // } } --- 94,97 ---- *************** *** 118,136 **** } } - // // TODO Add an accessor method to TopicMap to allow access to all topics with a subject locator - // Iterator it = getTopicMap().getTopics().iterator(); - // while (it.hasNext()) { - // Topic t = (Topic)it.next(); - // Iterator si = t.getSubjectIdentifiers().iterator(); - // while (si.hasNext()) { - // Locator l = (Locator)si.next(); - // if (l != null) { - // TopicMapObject reified = getTopicMap().getObjectBySourceLocator(l); - // if (reified != null) { - // addResultsRow(ret, new Object[] {t, reified}); - // } - // } - // } - // } } --- 107,110 ---- *************** *** 163,173 **** addResultsRow(ret, new Object[] {reifier, object}); } - // Iterator it = object.getSourceLocators().iterator(); - // while (it.hasNext()) { - // Topic t = getTopicMap().getTopicBySubjectIndicator((Locator)it.next()); - // if (t != null) { - // addResultsRow(ret, new Object[] {t, object}); - // } - // } } --- 137,140 ---- *************** *** 176,186 **** addResultsRow(ret, new Object[] { reifier, iter.next()}); } - // Iterator it = reifier.getSubjectIdentifiers().iterator(); - // while (it.hasNext()) { - // TopicMapObject tmo = getTopicMap().getObjectBySourceLocator((Locator)it.next()); - // if (tmo != null) { - // addResultsRow(ret, new Object[] { reifier, tmo }); - // } - // } } --- 143,146 ---- Index: InstanceOfPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/InstanceOfPredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InstanceOfPredicate.java 8 Mar 2005 14:49:16 -0000 1.3 --- InstanceOfPredicate.java 9 Mar 2005 12:40:19 -0000 1.4 *************** *** 135,141 **** IndexUtils.updateIndex(_topicIdx); for (Iterator iter = _topicIdx.getTopicsByType(cls).iterator(); iter.hasNext();) { ! addResultsRow(ret, new Object[] {it.next(), cls}); } ! for (Iterator iter = m_utils.getSubClasses(cls).iterator(); iter.hasNext()) { Topic sub = (Topic) iter.next(); for (Iterator insts = _topicIdx.getTopicsByType(sub).iterator(); insts.hasNext();) { --- 135,141 ---- IndexUtils.updateIndex(_topicIdx); for (Iterator iter = _topicIdx.getTopicsByType(cls).iterator(); iter.hasNext();) { ! addResultsRow(ret, new Object[] {iter.next(), cls}); } ! for (Iterator iter = m_utils.getSubClasses(cls).iterator(); iter.hasNext();) { Topic sub = (Topic) iter.next(); for (Iterator insts = _topicIdx.getTopicsByType(sub).iterator(); insts.hasNext();) { *************** *** 172,176 **** m_utils = new SuperSubClassUtils(); try { ! _topicIdx = (TopicsIndex) tm.getHelperObject(TopicsIndex); } catch (TMAPIException ex) { throw new TologParserException("Error initialising topic types index for instance-of predicate."); --- 172,176 ---- m_utils = new SuperSubClassUtils(); try { ! _topicIdx = (TopicsIndex) tm.getHelperObject(TopicsIndex.class); } catch (TMAPIException ex) { throw new TologParserException("Error initialising topic types index for instance-of predicate."); |
From: Lars H. <lh...@us...> - 2005-03-08 14:49:27
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22372/src/org/tmapiutils/query/tolog/predicates Modified Files: InstanceOfPredicate.java Log Message: Removed typos Index: InstanceOfPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/InstanceOfPredicate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** InstanceOfPredicate.java 8 Mar 2005 12:33:57 -0000 1.2 --- InstanceOfPredicate.java 8 Mar 2005 14:49:16 -0000 1.3 *************** *** 29,33 **** import org.tmapiutils.utils.IndexUtils; ! import org.tmapiutils.utils.SuperSubClassUtils.java; // TMAPI import org.tmapi.core.Topic; --- 29,33 ---- import org.tmapiutils.utils.IndexUtils; ! import org.tmapiutils.utils.SuperSubClassUtils; // TMAPI import org.tmapi.core.Topic; *************** *** 111,119 **** */ private void openMatch(Variable instVar, Variable cls, VariableSet ret) throws TologProcessingException { ! Iterator it = m_tti.getTopicTypes().iterator(); while (it.hasNext()) { Topic type = (Topic)it.next(); Collection supers = m_utils.getSuperClasses(type); ! Iterator instances = m_tti.getTopicsByType(type).iterator(); while (instances.hasNext()) { Topic inst = (Topic)instances.next(); --- 111,120 ---- */ private void openMatch(Variable instVar, Variable cls, VariableSet ret) throws TologProcessingException { ! IndexUtils.updateIndex(_topicIdx); ! Iterator it = _topicIdx.getTopicTypes().iterator(); while (it.hasNext()) { Topic type = (Topic)it.next(); Collection supers = m_utils.getSuperClasses(type); ! Iterator instances = _topicIdx.getTopicsByType(type).iterator(); while (instances.hasNext()) { Topic inst = (Topic)instances.next(); |
From: Lars H. <lh...@us...> - 2005-03-08 13:58:44
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8497/src/org/tmapiutils/query/tolog/predicates Modified Files: DynamicAssociationPredicate.java Log Message: Added private class TypeTester Index: DynamicAssociationPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/DynamicAssociationPredicate.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DynamicAssociationPredicate.java 8 Mar 2005 12:33:56 -0000 1.4 --- DynamicAssociationPredicate.java 8 Mar 2005 13:58:33 -0000 1.5 *************** *** 34,37 **** --- 34,38 ---- import org.tmapiutils.query.tolog.utils.VariableSet; + import uk.co.jezuk.mango.Predicate; import uk.co.jezuk.mango.UnaryFunction; import uk.co.jezuk.mango.iterators.PredicatedIterator; *************** *** 43,48 **** import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; - import org.tmapi.core.Topic; import org.tmapi.core.TopicMap; import org.tmapi.core.TMAPIException; import org.tmapi.index.core.AssociationsIndex; --- 44,51 ---- import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; import org.tmapi.core.TopicMap; + import org.tmapi.core.Topic; + import org.tmapi.core.Occurrence; + import org.tmapi.core.TopicName; import org.tmapi.core.TMAPIException; import org.tmapi.index.core.AssociationsIndex; *************** *** 447,451 **** ! // ToDo: TypeTester --- 450,493 ---- ! /** ! * A simplified version of the ! * org.tm4j.topicmap.utils.testers.TypeTester ! * ! * Returns <code>true</code> if the topic bounded to this ! * predicate is used as type of the specified TopicMapObject. ! */ ! private class TypeTester implements Predicate { ! ! private Topic _type; ! ! public TypeTester(Topic type) { ! _type = type; ! } ! ! /** ! * Performs the test. ! * @param o The object to be tested. ! * @return True if the object is a Topic, Association, ! * AssociationRole, Occurrence or TopicName ! * and if there is one or more type-specifying ! * topic for that object which is the allowed type. ! */ ! public boolean test(Object o) { ! Topic type = null; ! if (o instanceof Topic) { ! // Handle the special case ! return ((Topic) o).getTypes().contains(_type); ! } else if (o instanceof Association) { ! type = ((Association) o).getType(); ! } else if (o instanceof AssociationRole) { ! type = ((AssociationRole) o).getType(); ! } else if (o instanceof Occurrence) { ! type = ((Occurrence) o).getType(); ! } else if (o instanceof TopicName) { ! type = ((TopicName) o).getType(); ! } ! return (type != null && _type.equals(type)); ! } ! } |
From: Lars H. <lh...@us...> - 2005-03-08 13:34:35
|
Update of /cvsroot/tmapi-utils/tmapi-utils/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2424/utils Modified Files: terminology.py tm4j2tmapi.py Log Message: Added License text Added more TM4J keywords Index: tm4j2tmapi.py =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/utils/tm4j2tmapi.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tm4j2tmapi.py 6 Mar 2005 17:10:31 -0000 1.1 --- tm4j2tmapi.py 8 Mar 2005 13:34:20 -0000 1.2 *************** *** 1,3 **** --- 1,20 ---- #!/usr/bin/env python + + # + # Copyright 2005 TMAPI Utils / Lars Heuer + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # + """ The converter. Index: terminology.py =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/utils/terminology.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** terminology.py 7 Mar 2005 00:55:58 -0000 1.10 --- terminology.py 8 Mar 2005 13:34:20 -0000 1.11 *************** *** 1,2 **** --- 1,17 ---- + # + # Copyright 2005 TMAPI Utils / Lars Heuer + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # """ Translation table TM4J term -> TMAPI term. *************** *** 109,112 **** --- 124,130 ---- 'SerializedTopicMap':'No equivalent', 'AssociationExtractor':'No equivalent', + 'IndexException':'No equivalent. May be translatable to TMAPIIndexException', + 'IndexManagerException':'No equivalent. May be translatable to TMAPIIndexException / TMAPIException', + 'TypeTester':'No equivalent', # Topic 'getSubject()':'Replaced just getSubject() -> getSubjectLocators(). ToDo: .iterator().next() or something', |
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/parser Modified Files: Clause.java ClauseList.java NEClause.java NotClause.java OrClause.java Placeholder.java PlayerRolePair.java PlayerRoleVarPair.java Predicate.java Projection.java ProjectionImpl.java Sorting.java TologQuery.java TologResultsSetImpl.java TologRule.java TologRuleImpl.java TologRuleInstance.java TologRuleInstanceImpl.java Variable.java tolog.g Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: PlayerRolePair.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/PlayerRolePair.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PlayerRolePair.java 6 Mar 2005 17:29:06 -0000 1.1 --- PlayerRolePair.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 15,25 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class PlayerRolePair { protected Topic m_pTopic; protected Topic m_rTopic; ! protected PlayerRolePair() { } --- 22,33 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class PlayerRolePair { protected Topic m_pTopic; protected Topic m_rTopic; ! protected PlayerRolePair() { } *************** *** 28,35 **** m_rTopic = roleTopic; } ! public Topic getPlayerTopic() { return m_pTopic; } public Topic getRoleTopic() { return m_rTopic; } ! public String toString() { return ReferenceUtils.getTologReference(m_pTopic) + ":" + ReferenceUtils.getTologReference(m_rTopic); --- 36,43 ---- m_rTopic = roleTopic; } ! public Topic getPlayerTopic() { return m_pTopic; } public Topic getRoleTopic() { return m_rTopic; } ! public String toString() { return ReferenceUtils.getTologReference(m_pTopic) + ":" + ReferenceUtils.getTologReference(m_rTopic); *************** *** 37,57 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.3 2004/06/07 20:31:15 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 45,46 ---- Index: tolog.g =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/tolog.g,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tolog.g 6 Mar 2005 17:29:07 -0000 1.1 --- tolog.g 8 Mar 2005 12:33:55 -0000 1.2 *************** *** 1,21 **** ! header { package org.tm4j.tologx.parser; } { /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ - import org.tm4j.net.Locator; - import org.tm4j.net.LocatorFactoryException; - import org.tm4j.net.LocatorResolutionException; - import org.tm4j.topicmap.Topic; - import org.tm4j.topicmap.TopicMap; - import org.tm4j.topicmap.TopicMapObject; import java.io.File; import java.io.FileInputStream; --- 1,22 ---- ! header { package org.tmapiutils.query.tolog.parser; } { /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ import java.io.File; import java.io.FileInputStream; *************** *** 32,43 **** import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ! import org.tm4j.tologx.TologParserException; ! import org.tm4j.tologx.predicates.DynamicAssociationPredicate; } /** * INTERNAL: Parser for the tolog syntax. */ - class TologParser extends Parser; --- 33,56 ---- import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ! org.tmapiutils.query.tolog.TologParserException; ! org.tmapiutils.query.tolog.predicates.DynamicAssociationPredicate; ! ! import org.tmapiutils.utils.IndexUtils; ! // TMAPI ! import org.tmapi.core.TopicMapObject; ! import org.tmapi.core.Locator; ! import org.tmapi.core.Topic; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.TMAPIException; ! import org.tmapi.index.core.TopicMapObjectsIndex; ! import org.tmapi.index.core.TopicsIndex; } /** * INTERNAL: Parser for the tolog syntax. + * + * @author Kal Ahmed (kal[at]techquila.com) + * @author Lars Heuer (heuer[at]semagia.com) */ class TologParser extends Parser; *************** *** 48,51 **** --- 61,66 ---- { + private TopicMapObjectsIndex _tmoIdx; + private TopicsIndex _topicIdx; private static final Log m_log = LogFactory.getLog(TologParser.class); private Stack m_clauseStack = new Stack(); *************** *** 75,83 **** private String m_identifier = null; private Class m_dynAssocPredicate = DynamicAssociationPredicate.class; ! public void setTopicMap(TopicMap topicmap) { m_tm = topicmap; } ! private Object getObjectByIdent(String ident) throws TologParserException { try { --- 90,98 ---- private String m_identifier = null; private Class m_dynAssocPredicate = DynamicAssociationPredicate.class; ! public void setTopicMap(TopicMap topicmap) { m_tm = topicmap; } ! private Object getObjectByIdent(String ident) throws TologParserException { try { *************** *** 85,90 **** if (ident.startsWith("i\"")) { String si = ident.substring(2, ident.length() - 1); ! Locator l = m_tm.getBaseLocator().resolveRelative(si); ! tmo = m_tm.getTopicBySubjectIndicator(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with subject indicator: " + si); --- 100,110 ---- if (ident.startsWith("i\"")) { String si = ident.substring(2, ident.length() - 1); ! Locator loc = m_tm.getBaseLocator().resolveRelative(si); ! _topicIdx.open(); ! if (!_topicIdx.getFlags().isAutoUpdated()) { ! _topicIdx.reindex(); ! } ! tmo = _topicIdx.getTopicBySubjectIdentifier(loc); ! // tmo = m_tm.getTopicBySubjectIndicator(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with subject indicator: " + si); *************** *** 92,110 **** } else if (ident.startsWith("a\"")) { String sa = ident.substring(2, ident.length() - 1); ! Locator l = m_tm.getBaseLocator().resolveRelative(sa); ! tmo = m_tm.getTopicBySubject(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with subject address: " + sa); ! } } else if (ident.startsWith("s\"")) { String src = ident.substring(2, ident.length() - 1); ! Locator l = m_tm.getBaseLocator().resolveRelative(src); ! tmo = m_tm.getObjectBySourceLocator(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with source locator address: " + src); ! } } else if (ident.startsWith("@")) { String id = ident.substring(1); ! tmo = m_tm.getObjectByID(id); if (tmo == null) { throw new TologParserException("No object found in topic map with id: " + id); --- 112,140 ---- } else if (ident.startsWith("a\"")) { String sa = ident.substring(2, ident.length() - 1); ! Locator loc = m_tm.getBaseLocator().resolveRelative(sa); ! _topicIdx.open(); ! if (!_topicIdx.getFlags().isAutoUpdated()) { ! _topicIdx.reindex(); ! } ! tmo = _topicIdx.getTopicBySubjectLocator(loc); ! // tmo = m_tm.getTopicBySubject(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with subject address: " + sa); ! } } else if (ident.startsWith("s\"")) { String src = ident.substring(2, ident.length() - 1); ! Locator loc = m_tm.getBaseLocator().resolveRelative(src); ! _tmoIdx.open(); ! if (!_tmoIdx.getFlags().isAutoUpdated()) { ! _tmoIdx.reindex(); ! } ! tmo = _tmoIdx.getTopicMapObjectBySourceLocator(loc); ! // tmo = m_tm.getObjectBySourceLocator(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with source locator address: " + src); ! } } else if (ident.startsWith("@")) { String id = ident.substring(1); ! tmo = m_tm.getObjectById(id); if (tmo == null) { throw new TologParserException("No object found in topic map with id: " + id); *************** *** 114,121 **** tmo = new Placeholder(ref); } else { ! Locator l = m_tm.getBaseLocator().resolveRelative("#" + ident); ! tmo = m_tm.getObjectBySourceLocator(l); if (tmo == null) { ! throw new TologParserException("No object in topic map with source locator " + l.getAddress()); } } --- 144,156 ---- tmo = new Placeholder(ref); } else { ! Locator loc = m_tm.getBaseLocator().resolveRelative("#" + ident); ! _tmoIdx.open(); ! if (!_tmoIdx.getFlags().isAutoUpdated()) { ! _tmoIdx.reindex(); ! } ! tmo = _tmoIdx.getTopicMapObjectBySourceLocator(loc); ! //tmo = m_tm.getObjectBySourceLocator(l); if (tmo == null) { ! throw new TologParserException("No object in topic map with source locator " + loc.getReference()); } } *************** *** 123,146 **** } catch (LocatorResolutionException ex) { throw new TologParserException("Invalid topic identifier " + ident + ". The identifier cannot be resolved to a URI fragment identifier."); } } ! public void setBaseLocator(Locator baseLoc) { m_baseLoc = baseLoc; } ! public void setPrefix(String prefix) { m_prefix = prefix; } ! public Map getRules() { return m_rulesByName; } ! public void setRules(Map m) { m_rulesByName.clear(); m_rulesByName.putAll(m); } ! public void setPrefixRules(Map m) { Iterator keys = m.keySet().iterator(); --- 158,183 ---- } catch (LocatorResolutionException ex) { throw new TologParserException("Invalid topic identifier " + ident + ". The identifier cannot be resolved to a URI fragment identifier."); + } catch (TMAPIException ex) { + throw new TologParserException("Initializing of index failed", ex); } } ! public void setBaseLocator(Locator baseLoc) { m_baseLoc = baseLoc; } ! public void setPrefix(String prefix) { m_prefix = prefix; } ! public Map getRules() { return m_rulesByName; } ! public void setRules(Map m) { m_rulesByName.clear(); m_rulesByName.putAll(m); } ! public void setPrefixRules(Map m) { Iterator keys = m.keySet().iterator(); *************** *** 156,169 **** } } ! public void setPredicates(Map m) { m_predicatesByID.clear(); m_predicatesByID.putAll(m); } ! public void setDynamicAssociationPredicateClass(Class c) { ! m_dynAssocPredicate = c; } ! private void importModule(String modSrc, String modPrefix) throws TologParserException { // Hack to remove enclosing quotes from URL production. --- 193,206 ---- } } ! public void setPredicates(Map m) { m_predicatesByID.clear(); m_predicatesByID.putAll(m); } ! public void setDynamicAssociationPredicateClass(Class c) { ! m_dynAssocPredicate = c; } ! private void importModule(String modSrc, String modPrefix) throws TologParserException { // Hack to remove enclosing quotes from URL production. *************** *** 177,203 **** if (m_baseLoc == null) { if (m_tm.getBaseLocator() != null) { ! m_log.debug("Resolving name against topic map base locator: " + m_tm.getBaseLocator().getAddress()); moduleLoc = m_tm.getBaseLocator().resolveRelative(modSrc); } else { ! moduleLoc = m_tm.getLocatorFactory().createLocator("URI", modSrc); } } else { ! m_log.debug("Resolving name against module base locator: " + m_baseLoc.getAddress()); moduleLoc = m_baseLoc.resolveRelative(modSrc); } ! m_log.debug("Resolved module locator: "+ moduleLoc.getAddress()); InputStream is = null; try { m_log.debug("Trying address as URL..."); ! URL u = new URL(moduleLoc.getAddress()); is = u.openStream(); } catch (MalformedURLException ex) { m_log.debug("Trying address as file name..."); ! File f = new File(moduleLoc.getAddress()); m_log.debug("Got new file: "+ f.getAbsolutePath()); if (f.exists()) { is = new FileInputStream(f); } else { ! throw new TologParserException("Unable to process module reference " + moduleLoc.getAddress() + " as either a URL or a file name."); } } --- 214,240 ---- if (m_baseLoc == null) { if (m_tm.getBaseLocator() != null) { ! m_log.debug("Resolving name against topic map base locator: " + m_tm.getBaseLocator().getReference()); moduleLoc = m_tm.getBaseLocator().resolveRelative(modSrc); } else { ! moduleLoc = m_tm.createLocator(modSrc); } } else { ! m_log.debug("Resolving name against module base locator: " + m_baseLoc.getReference()); moduleLoc = m_baseLoc.resolveRelative(modSrc); } ! m_log.debug("Resolved module locator: "+ moduleLoc.getReference()); InputStream is = null; try { m_log.debug("Trying address as URL..."); ! URL u = new URL(moduleLoc.getReference()); is = u.openStream(); } catch (MalformedURLException ex) { m_log.debug("Trying address as file name..."); ! File f = new File(moduleLoc.getReference()); m_log.debug("Got new file: "+ f.getAbsolutePath()); if (f.exists()) { is = new FileInputStream(f); } else { ! throw new TologParserException("Unable to process module reference " + moduleLoc.getReference() + " as either a URL or a file name."); } } *************** *** 208,212 **** p.module(); Map moduleRules = p.getRules(); ! if (m_log.isDebugEnabled()) m_log.debug("Parse of module " + moduleLoc.getAddress() + " completed. Parser reports " + moduleRules.size() + " rules."); Iterator it = moduleRules.keySet().iterator(); while (it.hasNext()) { --- 245,249 ---- p.module(); Map moduleRules = p.getRules(); ! if (m_log.isDebugEnabled()) m_log.debug("Parse of module " + moduleLoc.getReference() + " completed. Parser reports " + moduleRules.size() + " rules."); Iterator it = moduleRules.keySet().iterator(); while (it.hasNext()) { *************** *** 229,233 **** } } ! private void addRule(String name, TologRule rule) { m_predicatesByID.put(name, TologRule.class); --- 266,270 ---- } } ! private void addRule(String name, TologRule rule) { m_predicatesByID.put(name, TologRule.class); *************** *** 240,250 **** (r:rule)* ; ! directive throws TologParserException : import_module ! | prefixmap ; ! import_module throws TologParserException : "import" mod_src:URL "as" mod_prefix:NAME --- 277,287 ---- (r:rule)* ; ! directive throws TologParserException : import_module ! | prefixmap ; ! import_module throws TologParserException : "import" mod_src:URL "as" mod_prefix:NAME *************** *** 253,272 **** prefixmap throws TologParserException : ! "using" prefix:NAME "for" ! (INDURL { m_prefixMap.put(prefix, LT(0).getText()); }| ADDURL { m_prefixMap.put(prefix, LT(0).getText()); }| SRCURL { m_prefixMap.put(prefix, LT(0).getText()); }| OBJID { m_prefixMap.put(prefix, LT(0).getText()); }) ; ! rule returns [TologRule r] throws TologParserException {r = null;}: {m_rule = new TologRuleImpl(); } ! (rulehead) ! IMPLIES clauselist {m_rule.setRuleBody(m_currClauseList); } FULLSTOP ! { ! if (m_rules == null) m_rules = new ArrayList(); ! m_rules.add(m_rule); r = m_rule; } --- 290,309 ---- prefixmap throws TologParserException : ! "using" prefix:NAME "for" ! (INDURL { m_prefixMap.put(prefix, LT(0).getText()); }| ADDURL { m_prefixMap.put(prefix, LT(0).getText()); }| SRCURL { m_prefixMap.put(prefix, LT(0).getText()); }| OBJID { m_prefixMap.put(prefix, LT(0).getText()); }) ; ! rule returns [TologRule r] throws TologParserException {r = null;}: {m_rule = new TologRuleImpl(); } ! (rulehead) ! IMPLIES clauselist {m_rule.setRuleBody(m_currClauseList); } FULLSTOP ! { ! if (m_rules == null) m_rules = new ArrayList(); ! m_rules.add(m_rule); r = m_rule; } *************** *** 275,284 **** rulehead : name:NAME { ! m_rule.setName(name.getText()); addRule(name.getText(), m_rule); } ! LPAREN variable { m_rule.addHeadParameter(new Variable(m_varName)); } ! (COMMA variable { m_rule.addHeadParameter(new Variable(m_varName)); })* RPAREN ; --- 312,321 ---- rulehead : name:NAME { ! m_rule.setName(name.getText()); addRule(name.getText(), m_rule); } ! LPAREN variable { m_rule.addHeadParameter(new Variable(m_varName)); } ! (COMMA variable { m_rule.addHeadParameter(new Variable(m_varName)); })* RPAREN ; *************** *** 295,299 **** QM { ! q = new TologQuery(m_currClauseList); if (m_proj != null) q.setProjection(m_proj); if (m_sorting != null) q.setSorting(m_sorting); --- 332,336 ---- QM { ! q = new TologQuery(m_currClauseList); if (m_proj != null) q.setProjection(m_proj); if (m_sorting != null) q.setSorting(m_sorting); *************** *** 302,306 **** } ; ! selectpart : "select" --- 339,343 ---- } ; ! selectpart : "select" *************** *** 316,321 **** orderpart { m_sorting = new Sorting(); }: ! "order" "by" ! (variable { m_sorting.addSort(new Variable(m_varName));})+ ( ("asc" { m_sorting.setSortAscending(true);} ) | --- 353,358 ---- orderpart { m_sorting = new Sorting(); }: ! "order" "by" ! (variable { m_sorting.addSort(new Variable(m_varName));})+ ( ("asc" { m_sorting.setSortAscending(true);} ) | *************** *** 329,333 **** ; ! count : "count" LPAREN variable RPAREN ; --- 366,370 ---- ; ! count : "count" LPAREN variable RPAREN ; *************** *** 357,361 **** throw new TologParserException("Unable to create a new dynamic association predicate from class " + m_dynAssocPredicate.getName() + ".", ex); } ! } | prefixedident { --- 394,398 ---- throw new TologParserException("Unable to create a new dynamic association predicate from class " + m_dynAssocPredicate.getName() + ".", ex); } ! } | prefixedident { *************** *** 388,403 **** } ) ! LPAREN (pair { m_predicateParams.add(m_param); } | URL { m_predicateParams.add(LT(0).getText()); }) (COMMA (pair { m_predicateParams.add(m_param); }) | URL { m_predicateParams.add(LT(0).getText());})* RPAREN ! { ! m_predicate.setParameters(m_predicateParams); ! m_currClauseList.addPredicate(m_predicate); } ; pair throws TologParserException: ! { if (m_dynAssocPredicate.isInstance(m_predicate)) { m_param = m_prp = new PlayerRoleVarPair(); --- 425,440 ---- } ) ! LPAREN (pair { m_predicateParams.add(m_param); } | URL { m_predicateParams.add(LT(0).getText()); }) (COMMA (pair { m_predicateParams.add(m_param); }) | URL { m_predicateParams.add(LT(0).getText());})* RPAREN ! { ! m_predicate.setParameters(m_predicateParams); ! m_currClauseList.addPredicate(m_predicate); } ; pair throws TologParserException: ! { if (m_dynAssocPredicate.isInstance(m_predicate)) { m_param = m_prp = new PlayerRoleVarPair(); *************** *** 407,412 **** m_log.debug("START: pair"); } ! ! expr { if (m_refObject != null) { --- 444,449 ---- m_log.debug("START: pair"); } ! ! expr { if (m_refObject != null) { *************** *** 430,439 **** } } ! (COLON expr ! { if (m_prp != null) { if (m_refObject != null) { if (m_refObject instanceof Topic) { ! m_prp.setRoleTopic((Topic)m_refObject); } else if (m_refObject instanceof Placeholder) { m_prp.setRolePlaceholder((Placeholder)m_refObject); --- 467,476 ---- } } ! (COLON expr ! { if (m_prp != null) { if (m_refObject != null) { if (m_refObject instanceof Topic) { ! m_prp.setRoleTopic((Topic)m_refObject); } else if (m_refObject instanceof Placeholder) { m_prp.setRolePlaceholder((Placeholder)m_refObject); *************** *** 451,455 **** {m_log.debug("END: pair");} ; ! orclause throws TologParserException: { m_clauseStack.push(m_currClauseList); m_oc = new OrClause(); } --- 488,492 ---- {m_log.debug("END: pair");} ; ! orclause throws TologParserException: { m_clauseStack.push(m_currClauseList); m_oc = new OrClause(); } *************** *** 459,486 **** RCURLY { ! m_currClauseList = (ClauseList) m_clauseStack.pop(); m_currClauseList.addClause(m_oc); } ; ! notclause throws TologParserException: ! "not" LPAREN { m_clauseStack.push(m_currClauseList); m_nc = new NotClause(); } clauselist RPAREN { ! m_nc.setTest(m_currClauseList); ! m_currClauseList = (ClauseList)m_clauseStack.pop(); m_currClauseList.addClause(m_nc); } ; ! opclause throws TologParserException : { m_nec = new NEClause(); } (expr { m_nec.setLeft(m_refObject); m_nec.setLeftVar(m_varName); } ! "/=" expr { m_nec.setRight(m_refObject); m_nec.setRightVar(m_varName); }) { m_currClauseList.addClause(m_nec); } ; ! expr throws TologParserException : { m_varName = null; m_refObject = null; } --- 496,523 ---- RCURLY { ! m_currClauseList = (ClauseList) m_clauseStack.pop(); m_currClauseList.addClause(m_oc); } ; ! notclause throws TologParserException: ! "not" LPAREN { m_clauseStack.push(m_currClauseList); m_nc = new NotClause(); } clauselist RPAREN { ! m_nc.setTest(m_currClauseList); ! m_currClauseList = (ClauseList)m_clauseStack.pop(); m_currClauseList.addClause(m_nc); } ; ! opclause throws TologParserException : { m_nec = new NEClause(); } (expr { m_nec.setLeft(m_refObject); m_nec.setLeftVar(m_varName); } ! "/=" expr { m_nec.setRight(m_refObject); m_nec.setRightVar(m_varName); }) { m_currClauseList.addClause(m_nec); } ; ! expr throws TologParserException : { m_varName = null; m_refObject = null; } *************** *** 488,505 **** { m_log.debug("After expr: " + String.valueOf(m_varName) + "/" + String.valueOf(m_refObject)); } ; ! ! variable : {m_varName = null; } (DOLLAR NAME { m_varName = LT(0).getText(); }) ; ! ref throws TologParserException: { m_refObject = null; } prefixedident { m_refObject = getObjectByIdent(m_identifier); } ; ! prefixedident : ! (NAME DBLCOLON) => prefix:NAME DBLCOLON ref:NAME ! { m_log.debug("Got identifier '" + ref.getText() + "' with prefix '" + prefix.getText() + "'."); String exp = (String) m_prefixMap.get(prefix.getText()); --- 525,542 ---- { m_log.debug("After expr: " + String.valueOf(m_varName) + "/" + String.valueOf(m_refObject)); } ; ! ! variable : {m_varName = null; } (DOLLAR NAME { m_varName = LT(0).getText(); }) ; ! ref throws TologParserException: { m_refObject = null; } prefixedident { m_refObject = getObjectByIdent(m_identifier); } ; ! prefixedident : ! (NAME DBLCOLON) => prefix:NAME DBLCOLON ref:NAME ! { m_log.debug("Got identifier '" + ref.getText() + "' with prefix '" + prefix.getText() + "'."); String exp = (String) m_prefixMap.get(prefix.getText()); *************** *** 542,547 **** name:NAME { m_identifier = name.getText(); } ; ! ! /* predname throws TologParserException : ident { --- 579,584 ---- name:NAME { m_identifier = name.getText(); } ; ! ! /* predname throws TologParserException : ident { *************** *** 571,583 **** INDURL ; ! address: ADDURL ; ! srcloc: SRCURL ; ! /** * INTERNAL: Lexer for tolog syntax. --- 608,620 ---- INDURL ; ! address: ADDURL ; ! srcloc: SRCURL ; ! /** * INTERNAL: Lexer for tolog syntax. *************** *** 586,591 **** class TologLexer extends Lexer; ! options { ! charVocabulary = '\1'..'\uFFFF'; k = 2; } --- 623,628 ---- class TologLexer extends Lexer; ! options { ! charVocabulary = '\1'..'\uFFFF'; k = 2; } *************** *** 596,601 **** ; ! NAME : ! ('A'..'Z' | 'a'..'z' | '_') ('A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '.' | '-')* ; --- 633,638 ---- ; ! NAME : ! ('A'..'Z' | 'a'..'z' | '_') ('A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '.' | '-')* ; *************** *** 604,616 **** '"' (~('"' | '\n') | '\n' { newline(); } )* '"' ; ! INDURL : 'i' URL ; ! ADDURL : 'a' URL ; ! SRCURL : 's' URL --- 641,653 ---- '"' (~('"' | '\n') | '\n' { newline(); } )* '"' ; ! INDURL : 'i' URL ; ! ADDURL : 'a' URL ; ! SRCURL : 's' URL *************** *** 624,628 **** '%' INT ; ! NE : "/="; --- 661,665 ---- '%' INT ; ! NE : "/="; Index: TologQuery.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/TologQuery.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologQuery.java 6 Mar 2005 17:29:06 -0000 1.1 --- TologQuery.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 21,29 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class TologQuery { ! private ClauseList m_rootClauseList; private Projection m_projection; --- 28,37 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TologQuery { ! private ClauseList m_rootClauseList; private Projection m_projection; *************** *** 32,44 **** private int m_pageLength; private static final Log m_log = LogFactory.getLog(TologQuery.class); ! public TologQuery(ClauseList rootClauseList) { m_rootClauseList = rootClauseList; } ! public ClauseList getRootClauseList() { return m_rootClauseList; } ! /** * @return --- 40,52 ---- private int m_pageLength; private static final Log m_log = LogFactory.getLog(TologQuery.class); ! public TologQuery(ClauseList rootClauseList) { m_rootClauseList = rootClauseList; } ! public ClauseList getRootClauseList() { return m_rootClauseList; } ! /** * @return *************** *** 116,120 **** return new TologResultsSetImpl(m_projection.getColumns(), sortedRows.subList(m_pageStart, pageLength)); } ! public String toString() { StringBuffer sb = new StringBuffer(); --- 124,128 ---- return new TologResultsSetImpl(m_projection.getColumns(), sortedRows.subList(m_pageStart, pageLength)); } ! public String toString() { StringBuffer sb = new StringBuffer(); *************** *** 167,205 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.9 2004/07/19 15:59:51 kal_ahmed - * Query processing now initialises the input variable set correctly. - * - * Revision 1.8 2004/07/19 14:52:40 kal_ahmed - * More fixes to processing of recursive rules. ClauseList now aborts when the input parameter list becomes empty. - * - * Revision 1.7 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.6 2004/06/16 21:21:43 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.5 2004/06/13 19:44:30 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - * Revision 1.4 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.3 2004/06/07 20:31:33 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 175,176 ---- Index: Variable.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Variable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Variable.java 6 Mar 2005 17:29:07 -0000 1.1 --- Variable.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,17 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class Variable { --- 1,25 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class Variable { *************** *** 22,30 **** } public String getName() { return m_name; } ! public String toString() { return "$" + m_name; } ! public boolean equals(Object o) { if (o instanceof Variable) { --- 30,38 ---- } public String getName() { return m_name; } ! public String toString() { return "$" + m_name; } ! public boolean equals(Object o) { if (o instanceof Variable) { *************** *** 33,37 **** return false; } ! public int hashCode() { return m_name.hashCode(); --- 41,45 ---- return false; } ! public int hashCode() { return m_name.hashCode(); *************** *** 39,56 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:07 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 47,48 ---- Index: Projection.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Projection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Projection.java 6 Mar 2005 17:29:06 -0000 1.1 --- Projection.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.parser; *************** *** 15,21 **** /** ! * @author Kal ! * ! * Describe Projection here. */ public interface Projection { --- 23,29 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public interface Projection { *************** *** 25,29 **** /** * Returns the columns in the projection as a list of either Variable or Count ! * instances. * @return a list of column descriptors */ --- 33,37 ---- /** * Returns the columns in the projection as a list of either Variable or Count ! * instances. * @return a list of column descriptors */ *************** *** 36,46 **** } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.6 2004/06/09 21:12:19 kal_ahmed - * Added standard source file header and footer. - * - */ \ No newline at end of file --- 44,45 ---- Index: Sorting.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Sorting.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Sorting.java 6 Mar 2005 17:29:06 -0000 1.1 --- Sorting.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 26,30 **** * of the sort columns and the sort direction and provides a method for * sorting a projection. ! * @author Kal Ahmed (ka...@te...) */ public class Sorting { --- 33,39 ---- * of the sort columns and the sort direction and provides a method for * sorting a projection. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class Sorting { *************** *** 34,49 **** private RowComparator m_rowComparator = null; private Comparator m_invRowComparator; ! public void addSort(Variable sortVar) { m_sortCols.add(sortVar); } ! public void setSortAscending(boolean sortAscending) { m_sortAscending = sortAscending; } ! /** * Sorts a list of results rows by this class's sorting criteria. The sort ! * is executed as an in-place sort of <code>rows</code>, so the * List returned by this method is in fact the same List object passed * in in the <code>rows</code> parameter. --- 43,58 ---- private RowComparator m_rowComparator = null; private Comparator m_invRowComparator; ! public void addSort(Variable sortVar) { m_sortCols.add(sortVar); } ! public void setSortAscending(boolean sortAscending) { m_sortAscending = sortAscending; } ! /** * Sorts a list of results rows by this class's sorting criteria. The sort ! * is executed as an in-place sort of <code>rows</code>, so the * List returned by this method is in fact the same List object passed * in in the <code>rows</code> parameter. *************** *** 73,77 **** return rows; } ! public String toString() { if (m_sortCols.isEmpty()) { --- 82,86 ---- return rows; } ! public String toString() { if (m_sortCols.isEmpty()) { *************** *** 84,88 **** sb.append(it.next().toString()); if (it.hasNext()) { ! sb.append(","); } sb.append(" "); --- 93,97 ---- sb.append(it.next().toString()); if (it.hasNext()) { ! sb.append(","); } sb.append(" "); *************** *** 97,120 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.4 2004/06/07 20:31:33 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 106,107 ---- Index: TologRuleImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/TologRuleImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologRuleImpl.java 6 Mar 2005 17:29:07 -0000 1.1 --- TologRuleImpl.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.parser; *************** *** 15,21 **** /** ! * @author Kal ! * ! * Describe DefaultRuleImpl here. */ public class TologRuleImpl implements TologRule { --- 23,29 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TologRuleImpl implements TologRule { *************** *** 26,34 **** private String m_name; ! public TologRuleImpl() { m_headParams = new ArrayList(); } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Rule#getName() --- 34,42 ---- private String m_name; ! public TologRuleImpl() { m_headParams = new ArrayList(); } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Rule#getName() *************** *** 55,63 **** m_body = body; } ! public ClauseList getRuleBody() { return m_body; } ! public List getHeadParameters() { return m_headParams; --- 63,71 ---- m_body = body; } ! public ClauseList getRuleBody() { return m_body; } ! public List getHeadParameters() { return m_headParams; *************** *** 70,74 **** return new TologRuleInstanceImpl(this); } ! public String toString() { StringBuffer ret = new StringBuffer(); --- 78,82 ---- return new TologRuleInstanceImpl(this); } ! public String toString() { StringBuffer ret = new StringBuffer(); *************** *** 88,98 **** } } ! /* ! * $Log$ ! * Revision 1.1 2005/03/06 17:29:07 lheuer ! * Initial tolog import ! * ! * Revision 1.3 2004/06/09 21:12:19 kal_ahmed ! * Added standard source file header and footer. ! * ! */ \ No newline at end of file --- 96,98 ---- } } ! Index: TologRuleInstance.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/TologRuleInstance.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologRuleInstance.java 6 Mar 2005 17:29:07 -0000 1.1 --- TologRuleInstance.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,18 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.parser; /** ! * @author Kal ! * ! * Describe RuleInstance here. */ public interface TologRuleInstance extends Predicate { --- 1,26 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.parser; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public interface TologRuleInstance extends Predicate { *************** *** 20,30 **** } ! /* ! * $Log$ ! * Revision 1.1 2005/03/06 17:29:07 lheuer ! * Initial tolog import ! * ! * Revision 1.3 2004/06/09 21:12:19 kal_ahmed ! * Added standard source file header and footer. ! * ! */ \ No newline at end of file --- 28,30 ---- } ! Index: ProjectionImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/ProjectionImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProjectionImpl.java 6 Mar 2005 21:11:32 -0000 1.2 --- ProjectionImpl.java 8 Mar 2005 12:33:40 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 21,26 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class ProjectionImpl implements Projection { --- 28,34 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ProjectionImpl implements Projection { *************** *** 29,46 **** private static final Log m_log = LogFactory.getLog(ProjectionImpl.class); ! public ProjectionImpl () { m_columns = new ArrayList(); m_rows = new ArrayList(); } ! public void addVariable(Variable var) { m_columns.add(var); } ! public void addCount(Variable var) { m_columns.add(new Count(var)); } ! public void addVariableSet(VariableSet varSet) { if (m_columns.isEmpty()) { --- 37,54 ---- private static final Log m_log = LogFactory.getLog(ProjectionImpl.class); ! public ProjectionImpl () { m_columns = new ArrayList(); m_rows = new ArrayList(); } ! public void addVariable(Variable var) { m_columns.add(var); } ! public void addCount(Variable var) { m_columns.add(new Count(var)); } ! public void addVariableSet(VariableSet varSet) { if (m_columns.isEmpty()) { *************** *** 75,79 **** } } ! if (m_log.isDebugEnabled()) debugRow("Adding new row: ", newRow); boolean hasMatch = false; --- 83,87 ---- } } ! if (m_log.isDebugEnabled()) debugRow("Adding new row: ", newRow); boolean hasMatch = false; *************** *** 93,105 **** } } ! } } if (!hasMatch) { m_log.debug("Adding new row to projection."); m_rows.add(newRow); ! } } } ! private boolean compareRows(List r1, List r2) { for (int col = 0; col < r1.size(); col++) { --- 101,113 ---- } } ! } } if (!hasMatch) { m_log.debug("Adding new row to projection."); m_rows.add(newRow); ! } } } ! private boolean compareRows(List r1, List r2) { for (int col = 0; col < r1.size(); col++) { *************** *** 117,124 **** return true; } ! /** * Returns the columns in the projection as a list of either Variable or Count ! * instances. * @return a list of column descriptors */ --- 125,132 ---- return true; } ! /** * Returns the columns in the projection as a list of either Variable or Count ! * instances. * @return a list of column descriptors */ *************** *** 126,130 **** return m_columns; } ! /** * Returns the data rows in the projection. --- 134,138 ---- return m_columns; } ! /** * Returns the data rows in the projection. *************** *** 134,138 **** return m_rows; } ! public class Count { private Variable m_var; --- 142,146 ---- return m_rows; } ! public class Count { private Variable m_var; *************** *** 144,148 **** } } ! private void debugRow(String msg, List row) { StringBuffer m = new StringBuffer(); --- 152,156 ---- } } ! private void debugRow(String msg, List row) { StringBuffer m = new StringBuffer(); *************** *** 162,166 **** m_log.debug(m.toString()); } ! public String toString() { if (m_columns.isEmpty()) { --- 170,174 ---- m_log.debug(m.toString()); } ! public String toString() { if (m_columns.isEmpty()) { *************** *** 180,212 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:32 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.3 2004/06/09 21:05:01 kal_ahmed - * Added support for 'select * from' projection. - * - * Revision 1.2 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.1 2004/06/07 20:31:33 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 188,189 ---- Index: Clause.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Clause.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Clause.java 6 Mar 2005 17:29:06 -0000 1.1 --- Clause.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 18,26 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public interface Clause { ! public void doReplacement(Object[] params) throws TologProcessingException; --- 25,34 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public interface Clause { ! public void doReplacement(Object[] params) throws TologProcessingException; *************** *** 30,59 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.6 2004/06/16 21:21:43 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.5 2004/06/13 19:44:30 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - * Revision 1.4 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 38,39 ---- Index: OrClause.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/OrClause.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OrClause.java 6 Mar 2005 17:29:06 -0000 1.1 --- OrClause.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 22,27 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class OrClause implements Clause { --- 29,35 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class OrClause implements Clause { *************** *** 30,34 **** private List m_vars; private static final Log m_log = LogFactory.getLog(OrClause.class); ! public OrClause() { m_children = new ArrayList(); --- 38,42 ---- private List m_vars; private static final Log m_log = LogFactory.getLog(OrClause.class); ! public OrClause() { m_children = new ArrayList(); *************** *** 46,50 **** } } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Clause#execute(org.tmapiutils.query.to... [truncated message content] |
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/predicates Modified Files: AssociationPredicate.java AssociationRolePredicate.java BaseLocatorPredicate.java DirectInstanceOfPredicate.java DynamicAssociationPredicate.java InstanceOfPredicate.java OccurrencePredicate.java PredicateBase.java ReifiesPredicate.java ResourcePredicate.java RolePlayerPredicate.java ScopePredicate.java SourceLocatorsPredicate.java SubjectIdentifierPredicate.java SubjectLocatorPredicate.java TopicMapPredicate.java TopicNamePredicate.java TopicPredicate.java TypePredicate.java ValueLikePredicate.java ValuePredicate.java VariantPredicate.java Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: TopicPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/TopicPredicate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TopicPredicate.java 6 Mar 2005 17:30:00 -0000 1.1 --- TopicPredicate.java 8 Mar 2005 12:33:57 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 21,26 **** /** ! * @author Kal ! * */ public class TopicPredicate extends PredicateBase { --- 27,33 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TopicPredicate extends PredicateBase { *************** *** 30,34 **** new ParameterInfo(true, Object.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() --- 37,41 ---- new ParameterInfo(true, Object.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() *************** *** 64,78 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:30:00 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/12 14:58:50 kal_ahmed - * Initial version - * - * Revision 1.5 2004/06/11 08:29:28 kal_ahmed - * Added association and association-role predicates. - * - */ \ No newline at end of file --- 71,72 ---- Index: AssociationPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/AssociationPredicate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AssociationPredicate.java 6 Mar 2005 17:29:58 -0000 1.1 --- AssociationPredicate.java 8 Mar 2005 12:33:56 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 21,27 **** /** ! * @author Kal ! * ! * Describe AssociationPredicate here. */ public class AssociationPredicate extends PredicateBase { --- 27,33 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class AssociationPredicate extends PredicateBase { *************** *** 31,35 **** new ParameterInfo(true, Object.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() --- 37,41 ---- new ParameterInfo(true, Object.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() *************** *** 66,76 **** } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:58 lheuer - * Initial tolog import - * - * Revision 1.5 2004/06/11 08:29:28 kal_ahmed - * Added association and association-role predicates. - * - */ \ No newline at end of file --- 72,73 ---- Index: TopicMapPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/TopicMapPredicate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TopicMapPredicate.java 7 Mar 2005 12:32:00 -0000 1.2 --- TopicMapPredicate.java 8 Mar 2005 12:33:57 -0000 1.3 *************** *** 1,10 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 20,24 **** /** * ! * @author Kal Ahmed (ka...@te...) */ public class TopicMapPredicate extends PredicateBase { --- 27,32 ---- /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TopicMapPredicate extends PredicateBase { *************** *** 53,57 **** } else if (params.get(0) instanceof TopicMap) { TopicMap topicmap = (TopicMap)params.get(0); ! if (tst.equals(getTopicMap())) { addResultsRow(ret, new Object[] { topicmap }); } --- 61,65 ---- } else if (params.get(0) instanceof TopicMap) { TopicMap topicmap = (TopicMap)params.get(0); ! if (getTopicMap().equals(topicmap)) { addResultsRow(ret, new Object[] { topicmap }); } *************** *** 62,78 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.1 2005/03/06 17:30:00 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/13 10:32:28 kal_ahmed - * Initial implementation of topicmap() predicate. - * - */ \ No newline at end of file --- 70,71 ---- Index: ValuePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/ValuePredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ValuePredicate.java 7 Mar 2005 16:17:20 -0000 1.3 --- ValuePredicate.java 8 Mar 2005 12:33:57 -0000 1.4 *************** *** 1,10 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 34,38 **** /** * ! * @author Kal Ahmed (ka...@te...) */ public class ValuePredicate extends PredicateBase { --- 41,46 ---- /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ValuePredicate extends PredicateBase { *************** *** 130,134 **** } catch (TMAPIException ex) { ! throw new TologParserException("Error initialising indexes for " + PREDICATE_NAME, ex); } for (Iterator it = _occIdx.getOccurrencesByValue(data).iterator(); it.hasNext();) { --- 138,142 ---- } catch (TMAPIException ex) { ! throw new TologProcessingException("Error initialising indexes for " + PREDICATE_NAME, ex); } for (Iterator it = _occIdx.getOccurrencesByValue(data).iterator(); it.hasNext();) { Index: ScopePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/ScopePredicate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScopePredicate.java 6 Mar 2005 23:38:00 -0000 1.2 --- ScopePredicate.java 8 Mar 2005 12:33:57 -0000 1.3 *************** *** 1,6 **** /* ! * Created on 11-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates; *************** *** 23,29 **** /** ! * @author Kal ! * ! * Describe ScopePredicate here. */ public class ScopePredicate extends PredicateBase { --- 36,42 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ScopePredicate extends PredicateBase { *************** *** 35,39 **** new ParameterInfo(true) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() --- 48,52 ---- new ParameterInfo(true) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() *************** *** 78,82 **** Topic topic = (Topic) themes.next(); for (Iterator scoped = _scopeIdx.getScopedObjectsByScopingTopic(topic).iterator(); scoped.hasNext();) { ! addResultsRow(ret, new Object[] {scoped.next(), theme}); } } --- 91,95 ---- Topic topic = (Topic) themes.next(); for (Iterator scoped = _scopeIdx.getScopedObjectsByScopingTopic(topic).iterator(); scoped.hasNext();) { ! addResultsRow(ret, new Object[] {scoped.next(), topic}); } } Index: AssociationRolePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/AssociationRolePredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AssociationRolePredicate.java 7 Mar 2005 12:32:00 -0000 1.3 --- AssociationRolePredicate.java 8 Mar 2005 12:33:56 -0000 1.4 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 23,29 **** /** - * @author Kal * ! * Describe AssociationRolePredicate here. */ public class AssociationRolePredicate extends PredicateBase { --- 29,35 ---- /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class AssociationRolePredicate extends PredicateBase { *************** *** 108,126 **** } - /* - * $Log$ - * Revision 1.3 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.2 2005/03/06 19:37:22 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:29:58 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/11 08:29:29 kal_ahmed - * Added association and association-role predicates. - * - */ \ No newline at end of file --- 114,115 ---- Index: SubjectLocatorPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/SubjectLocatorPredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SubjectLocatorPredicate.java 6 Mar 2005 23:38:00 -0000 1.3 --- SubjectLocatorPredicate.java 8 Mar 2005 12:33:57 -0000 1.4 *************** *** 1,6 **** /* ! * Created on 11-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates; *************** *** 8,11 **** --- 21,25 ---- import java.util.List; + import org.tmapiutils.query.tolog.TologParserException; import org.tmapiutils.query.tolog.TologProcessingException; import org.tmapiutils.query.tolog.parser.Variable; *************** *** 15,18 **** --- 29,33 ---- // TMAPI import org.tmapi.core.Locator; + import org.tmapi.core.TopicMap; import org.tmapi.core.Topic; import org.tmapi.core.TMAPIException; *************** *** 20,26 **** /** ! * @author Kal ! * ! * Describe SubjectIdentifierPredicate here. */ public class SubjectLocatorPredicate extends PredicateBase { --- 35,41 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class SubjectLocatorPredicate extends PredicateBase { *************** *** 32,36 **** new ParameterInfo(true) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() --- 47,51 ---- new ParameterInfo(true) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() *************** *** 55,59 **** VariableSet ret = new VariableSet(); initialiseResultsSet(ret); ! if ((topic instanceof Topic) && (loc instanceof Variable)) { matchSubjectLocator((Topic)topic, ret); --- 70,74 ---- VariableSet ret = new VariableSet(); initialiseResultsSet(ret); ! if ((topic instanceof Topic) && (loc instanceof Variable)) { matchSubjectLocator((Topic)topic, ret); Index: ValueLikePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/ValueLikePredicate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ValueLikePredicate.java 6 Mar 2005 17:30:00 -0000 1.1 --- ValueLikePredicate.java 8 Mar 2005 12:33:57 -0000 1.2 *************** *** 1,14 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates; import java.util.List; --- 1,22 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates; + import java.util.Iterator; import java.util.List; *************** *** 17,34 **** import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.utils.VariableSet; ! import org.tmapi.core.TopicMap; import org.tmapi.core.TopicMapObject; ! import org.tmapi.core.index.IndexManager; ! import org.tmapi.core.index.text.FullTextIndex; ! import org.tmapi.core.index.text.QueryHit; ! import org.tmapi.core.index.text.QueryResult; /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class ValueLikePredicate extends PredicateBase { - private FullTextIndex m_txtIx; public static final String PREDICATE_NAME="value-like"; private static final ParameterInfo[] PARAM_INFO = new ParameterInfo[] { --- 25,44 ---- import org.tmapiutils.query.tolog.parser.Variable; import org.tmapiutils.query.tolog.utils.VariableSet; ! // TMAPI import org.tmapi.core.TopicMapObject; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.Topic; ! import org.tmapi.core.Occurrence; ! import org.tmapi.core.TopicName; ! import org.tmapi.core.Variant; ! /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ValueLikePredicate extends PredicateBase { public static final String PREDICATE_NAME="value-like"; private static final ParameterInfo[] PARAM_INFO = new ParameterInfo[] { *************** *** 36,40 **** new ParameterInfo(true, String.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() --- 46,50 ---- new ParameterInfo(true, String.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() *************** *** 56,67 **** public VariableSet matches(List params) throws TologProcessingException { VariableSet ret = new VariableSet(); ! Object o = params.get(0); ! String srchString = (String)params.get(1); initialiseResultsSet(ret); ! if (o instanceof Variable) { ! getAllMatches(srchString, ret); ! } else if (o instanceof TopicMapObject) { ! getObjectMatches((TopicMapObject)o, srchString, ret); } return ret; --- 66,77 ---- public VariableSet matches(List params) throws TologProcessingException { VariableSet ret = new VariableSet(); ! Object obj = params.get(0); ! String searchString = (String)params.get(1); initialiseResultsSet(ret); ! if (obj instanceof Variable) { ! getAllMatches(searchString, ret); ! } else if (obj instanceof TopicMapObject) { ! getObjectMatches((TopicMapObject) obj, searchString, ret); } return ret; *************** *** 72,86 **** * @param ret */ ! private void getAllMatches(String srchString, VariableSet ret) throws TologProcessingException { ! try { ! QueryResult qr = m_txtIx.findByText(srchString, true); ! for (int i = 0; i < qr.size(); i++) { ! QueryHit qh = qr.getHit(i); ! addResultsRow(ret, new Object[] { qh.getObject(), srchString }); } ! } catch (TologProcessingException ex) { ! throw ex; ! } catch (Exception ex) { ! throw new TologProcessingException("Error processing full-text query in " + PREDICATE_NAME + " predicate.", ex); } } --- 82,101 ---- * @param ret */ ! private void getAllMatches(String searchString, VariableSet ret) throws TologProcessingException { ! for (Iterator topicIter = getTopicMap().getTopics().iterator(); topicIter.hasNext();) { ! Topic topic = (Topic) topicIter.next(); ! for (Iterator tnIter = topic.getTopicNames().iterator(); tnIter.hasNext();) { ! TopicName tn = (TopicName) tnIter.next(); ! addMatch(tn, tn.getValue(), searchString, ret); ! for (Iterator varIter = tn.getVariants().iterator(); varIter.hasNext();) { ! Variant variant = (Variant) varIter.next(); ! addMatch(variant, variant.getValue(), searchString, ret); ! } } ! for (Iterator occIter = topic.getOccurrences().iterator(); occIter.hasNext();) { ! Occurrence occ = (Occurrence) occIter.next(); ! addMatch(occ, occ.getValue(), searchString, ret); ! } ! } } *************** *** 91,107 **** * @param ret */ ! private void getObjectMatches(TopicMapObject object, String srchString, VariableSet ret) throws TologProcessingException { ! try { ! QueryResult qr = m_txtIx.findByText(srchString, true); ! for (int i = 0; i < qr.size(); i++) { ! QueryHit qh = qr.getHit(i); ! if (qh.getObject().equals(object)) { ! addResultsRow(ret, new Object[] { object, srchString }); ! } ! } ! } catch (TologProcessingException ex) { ! throw ex; ! } catch (Exception ex) { ! throw new TologProcessingException("Error processing full-text query in " + PREDICATE_NAME + " predicate.", ex); } } --- 106,127 ---- * @param ret */ ! private void getObjectMatches(TopicMapObject object, String searchString, VariableSet ret) throws TologProcessingException { ! String value = null; ! if (object instanceof Occurrence) { ! value = ((Occurrence) object).getValue(); ! } ! else if (object instanceof TopicName) { ! value = ((TopicName) object).getValue(); ! } ! else if(object instanceof Variant) { ! value = ((Variant) object).getValue(); ! } ! addMatch(object, value, searchString, ret); ! } ! ! ! private void addMatch(TopicMapObject obj, String value, String searchString, VariableSet ret) throws TologProcessingException { ! if (value != null && value.indexOf(searchString) != -1) { ! addResultsRow(ret, new Object[] { obj, searchString }); } } *************** *** 112,142 **** public void initialise(TopicMap tm) throws TologParserException { super.initialise(tm); ! IndexManager ixMgr = tm.getIndexManager(); ! try { ! m_txtIx = (FullTextIndex) ixMgr.getIndex(FullTextIndex.class); ! if (m_txtIx == null) { ! throw new TologParserException("No full-text index is registered for this topic map. '" + PREDICATE_NAME + "' predicates cannot be used."); ! } ! if (!m_txtIx.isOpen()) { ! m_txtIx.open(); ! } ! m_txtIx.reindex(); ! } catch (TologParserException ex) { ! throw ex; ! } catch (Exception ex) { ! throw new TologParserException("Error initialising text index for predicate " + PREDICATE_NAME, ex); ! } } } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:30:00 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/13 11:30:26 kal_ahmed - * Initial implementation of value-like predicate. - * - */ \ No newline at end of file --- 132,152 ---- public void initialise(TopicMap tm) throws TologParserException { super.initialise(tm); ! // IndexManager ixMgr = tm.getIndexManager(); ! // try { ! // m_txtIx = (FullTextIndex) ixMgr.getIndex(FullTextIndex.class); ! // if (m_txtIx == null) { ! // throw new TologParserException("No full-text index is registered for this topic map. '" + PREDICATE_NAME + "' predicates cannot be used."); ! // } ! // if (!m_txtIx.isOpen()) { ! // m_txtIx.open(); ! // } ! // m_txtIx.reindex(); ! // } catch (TologParserException ex) { ! // throw ex; ! // } catch (Exception ex) { ! // throw new TologParserException("Error initialising text index for predicate " + PREDICATE_NAME, ex); ! // } } } Index: SourceLocatorsPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/SourceLocatorsPredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SourceLocatorsPredicate.java 6 Mar 2005 23:38:00 -0000 1.3 --- SourceLocatorsPredicate.java 8 Mar 2005 12:33:57 -0000 1.4 *************** *** 1,6 **** /* ! * Created on 11-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates; *************** *** 8,11 **** --- 21,25 ---- import java.util.List; + import org.tmapiutils.query.tolog.TologParserException; import org.tmapiutils.query.tolog.TologProcessingException; import org.tmapiutils.query.tolog.parser.Variable; *************** *** 24,30 **** /** ! * @author Kal ! * ! * Describe SourceLocatorsPredicate here. */ public class SourceLocatorsPredicate extends PredicateBase { --- 38,44 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class SourceLocatorsPredicate extends PredicateBase { *************** *** 35,41 **** private static final ParameterInfo [] PARAM_INFO = new ParameterInfo [] { new ParameterInfo(true), ! new ParameterInfo(true) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() --- 49,55 ---- private static final ParameterInfo [] PARAM_INFO = new ParameterInfo [] { new ParameterInfo(true), ! new ParameterInfo(true) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() *************** *** 86,91 **** ! private void addSourceLocators(TopicMapObject tmObj) { ! for (Iterator iter = tmObj.getSourceLocators().iter(); iter.hasNext();) { addResultsRow(ret, new Object[] {tmObj, iter.next()}); } --- 100,105 ---- ! private void addSourceLocators(VariableSet ret, TopicMapObject tmObj) throws TologProcessingException { ! for (Iterator iter = tmObj.getSourceLocators().iterator(); iter.hasNext();) { addResultsRow(ret, new Object[] {tmObj, iter.next()}); } *************** *** 96,111 **** */ private void openMatch(VariableSet ret) throws TologProcessingException { ! addSourceLocators(getTopicMap()); for (Iterator topicIter = getTopicMap().getTopics().iterator(); topicIter.hasNext();) { Topic topic = (Topic) topicIter.next(); ! addSourceLocators(topic); for (Iterator occIter = topic.getOccurrences().iterator(); occIter.hasNext();) { ! addSourceLocators((TopicMapObject) occIter.next()); } for (Iterator tnIter = topic.getTopicNames().iterator(); tnIter.hasNext();) { TopicName tn = (TopicName) tnIter.next(); ! addSourceLocators(tn); for (Iterator varIter = tn.getVariants().iterator(); varIter.hasNext();) { ! addSourceLocator((TopicMapObject) varIter.next()); } } --- 110,125 ---- */ private void openMatch(VariableSet ret) throws TologProcessingException { ! addSourceLocators(ret, getTopicMap()); for (Iterator topicIter = getTopicMap().getTopics().iterator(); topicIter.hasNext();) { Topic topic = (Topic) topicIter.next(); ! addSourceLocators(ret, topic); for (Iterator occIter = topic.getOccurrences().iterator(); occIter.hasNext();) { ! addSourceLocators(ret, (TopicMapObject) occIter.next()); } for (Iterator tnIter = topic.getTopicNames().iterator(); tnIter.hasNext();) { TopicName tn = (TopicName) tnIter.next(); ! addSourceLocators(ret, tn); for (Iterator varIter = tn.getVariants().iterator(); varIter.hasNext();) { ! addSourceLocators(ret, (TopicMapObject) varIter.next()); } } *************** *** 113,119 **** for (Iterator iter = getTopicMap().getAssociations().iterator(); iter.hasNext();) { Association assoc = (Association) iter.next(); ! addSourceLocators(assoc); for (Iterator roleIter = assoc.getAssociationRoles().iterator(); iter.hasNext();) { ! addSourceLocators((TopicMapObject) iter.next()); } } --- 127,133 ---- for (Iterator iter = getTopicMap().getAssociations().iterator(); iter.hasNext();) { Association assoc = (Association) iter.next(); ! addSourceLocators(ret, assoc); for (Iterator roleIter = assoc.getAssociationRoles().iterator(); iter.hasNext();) { ! addSourceLocators(ret, (TopicMapObject) iter.next()); } } *************** *** 126,134 **** */ private void closedMatch(TopicMapObject tmo, Locator locator, VariableSet ret) throws TologProcessingException { ! for (Iterator iter = tmo.getSourceLocators().iterator(); iter.hasNext();) { ! if (iter.next().equals(locator)) { ! addResultsRow(ret, new Object[] {tmo, locator}); ! return; ! } } } --- 140,145 ---- */ private void closedMatch(TopicMapObject tmo, Locator locator, VariableSet ret) throws TologProcessingException { ! if (tmo.getSourceLocators().contains(locator)) { ! addResultsRow(ret, new Object[] {tmo, locator}); } } *************** *** 140,148 **** private void matchObject(Locator locator, VariableSet ret) throws TologProcessingException { IndexUtils.updateIndex(_tmoIdx); ! TopicMapObject tmo = _tmoIdx.getTopicMapObjectBySourceLocator(locator); ! if (tmo != null) { ! addResultsRow(ret, new Object[] {tmo, locator}); ! } ! } /** --- 151,159 ---- private void matchObject(Locator locator, VariableSet ret) throws TologProcessingException { IndexUtils.updateIndex(_tmoIdx); ! TopicMapObject tmo = _tmoIdx.getTopicMapObjectBySourceLocator(locator); ! if (tmo != null) { ! addResultsRow(ret, new Object[] {tmo, locator}); ! } ! } /** Index: OccurrencePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/OccurrencePredicate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OccurrencePredicate.java 6 Mar 2005 21:39:42 -0000 1.2 --- OccurrencePredicate.java 8 Mar 2005 12:33:57 -0000 1.3 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.predicates; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates; *************** *** 22,28 **** /** ! * @author Kal ! * ! * Describe OccurrencePredicate here. */ public class OccurrencePredicate extends PredicateBase --- 30,36 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class OccurrencePredicate extends PredicateBase *************** *** 33,37 **** new ParameterInfo(true, Object.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() --- 41,45 ---- new ParameterInfo(true, Object.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() *************** *** 98,111 **** } - /* - * $Log$ - * Revision 1.2 2005/03/06 21:39:42 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:30:00 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/10 08:19:40 kal_ahmed - * Added standard file header and footer. - * - */ \ No newline at end of file --- 106,107 ---- Index: TopicNamePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/TopicNamePredicate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TopicNamePredicate.java 6 Mar 2005 22:44:55 -0000 1.2 --- TopicNamePredicate.java 8 Mar 2005 12:33:57 -0000 1.3 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 28,39 **** /** - * - * @author Henke * */ public class TopicNamePredicate extends PredicateBase { // private TopicNamesIndex idx=null; public static final String PREDICATE_NAME = "topic-name"; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() --- 34,46 ---- /** * + * @author Henke + * @author Kal Ahmed (kal[at]techquila.com) + * @author Lars Heuer (heuer[at]semagia.com) */ public class TopicNamePredicate extends PredicateBase { // private TopicNamesIndex idx=null; public static final String PREDICATE_NAME = "topic-name"; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.PredicateBase#getParamInfo() *************** *** 60,67 **** VariableSet ret = new VariableSet(); initialiseResultsSet(ret); ! Object paramTopic = params.get(0); Object paramName = params.get(1); ! if((paramName instanceof Variable) && (paramTopic instanceof Variable)) { Iterator itTopics = getTopicMap().getTopics().iterator(); --- 67,74 ---- VariableSet ret = new VariableSet(); initialiseResultsSet(ret); ! Object paramTopic = params.get(0); Object paramName = params.get(1); ! if((paramName instanceof Variable) && (paramTopic instanceof Variable)) { Iterator itTopics = getTopicMap().getTopics().iterator(); *************** *** 111,115 **** public void initialise(TopicMap tm) throws TologParserException { super.initialise(tm); ! /* try { --- 118,122 ---- public void initialise(TopicMap tm) throws TologParserException { super.initialise(tm); ! /* try { *************** *** 122,138 **** } - /* - * $Log$ - * Revision 1.2 2005/03/06 22:44:55 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:30:00 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 21:31:17 kal_ahmed - * Added TopicNamePredicate to builtins. - * - * Revision 1.1 2004/06/14 20:08:05 kal_ahmed - * Initial version. Contributed by Stefan Henke. - * - */ \ No newline at end of file --- 129,130 ---- Index: TypePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/TypePredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TypePredicate.java 7 Mar 2005 12:32:00 -0000 1.3 --- TypePredicate.java 8 Mar 2005 12:33:57 -0000 1.4 *************** *** 1,10 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 36,40 **** /** * ! * @author Kal Ahmed (ka...@te...) */ public class TypePredicate extends PredicateBase { --- 43,48 ---- /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TypePredicate extends PredicateBase { *************** *** 105,108 **** --- 113,141 ---- } + + private void initializeIndexes() throws TologProcessingException { + try { + _assocIdx.open(); + if (!_assocIdx.getFlags().isAutoUpdated()) { + _assocIdx.reindex(); + } + _roleIdx.open(); + if (!_roleIdx.getFlags().isAutoUpdated()) { + _roleIdx.reindex(); + } + _occIdx.open(); + if (!_occIdx.getFlags().isAutoUpdated()) { + _occIdx.reindex(); + } + _tnIdx.open(); + if (!_tnIdx.getFlags().isAutoUpdated()) { + _tnIdx.reindex(); + } + } + catch (TMAPIException ex) { + throw new TologProcessingException("Error initialising indexes for " + PREDICATE_NAME, ex); + } + } + /** * @param topic *************** *** 110,124 **** */ private void getTyped(Topic type, VariableSet ret) throws TologProcessingException { ! IndexUtils.updateIndex(_assocIdx); Iterator it = _assocIdx.getAssociationsByType(type).iterator(); addInstances(type, it, ret); - IndexUtils.updateIndex(_roleIdx); it = _roleIdx.getAssociationRolesByType(type).iterator(); addInstances(type, it, ret); - IndexUtils.updateIndex(_occIdx); it = _occIdx.getOccurrencesByType(type).iterator(); addInstances(type, it, ret); ! IndexUtils.updateIndex(_tnIdx); ! it = _tnIdx.getOccurrencesByType(type).iterator(); addInstances(type, it, ret); } --- 143,154 ---- */ private void getTyped(Topic type, VariableSet ret) throws TologProcessingException { ! initializeIndexes(); Iterator it = _assocIdx.getAssociationsByType(type).iterator(); addInstances(type, it, ret); it = _roleIdx.getAssociationRolesByType(type).iterator(); addInstances(type, it, ret); it = _occIdx.getOccurrencesByType(type).iterator(); addInstances(type, it, ret); ! it = _tnIdx.getTopicNamesByType(type).iterator(); addInstances(type, it, ret); } *************** *** 160,164 **** */ private void openMatch(VariableSet ret) throws TologProcessingException { ! IndexUtils.updateIndex(_assocIdx); for (Iterator types = _assocIdx.getAssociationTypes().iterator(); types.hasNext();) { Topic type = (Topic)types.next(); --- 190,194 ---- */ private void openMatch(VariableSet ret) throws TologProcessingException { ! initializeIndexes(); for (Iterator types = _assocIdx.getAssociationTypes().iterator(); types.hasNext();) { Topic type = (Topic)types.next(); *************** *** 167,171 **** } } - IndexUtils.updateIndex(_roleIdx); for (Iterator types = _roleIdx.getAssociationRoleTypes().iterator(); types.hasNext();) { Topic type = (Topic)types.next(); --- 197,200 ---- *************** *** 174,178 **** } } - IndexUtils.updateIndex(_occIdx); for (Iterator types = _occIdx.getOccurrenceTypes().iterator(); types.hasNext();) { Topic type = (Topic)types.next(); --- 203,206 ---- *************** *** 181,185 **** } } - IndexUtils.updateIndex(_tnIdx); for (Iterator types = _tnIdx.getTopicNameTypes().iterator(); types.hasNext();) { Topic type = (Topic)types.next(); --- 209,212 ---- *************** *** 207,226 **** } - - /* - * $Log$ - * Revision 1.3 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.2 2005/03/06 21:11:33 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:30:00 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/13 10:16:47 kal_ahmed - * Initial implementation of type() predicate. - * - */ \ No newline at end of file --- 234,235 ---- Index: PredicateBase.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/PredicateBase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PredicateBase.java 6 Mar 2005 17:30:00 -0000 1.1 --- PredicateBase.java 8 Mar 2005 12:33:57 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates; *************** *** 28,33 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public abstract class PredicateBase implements Predicate { --- 35,41 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public abstract class PredicateBase implements Predicate { *************** *** 35,48 **** private List m_params; private TopicMap m_tm; ! ! public void initialise(TopicMap tm) throws TologParserException { m_tm = tm; } ! public TopicMap getTopicMap() { return m_tm; } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Predicate#setParameters(java.util.List) --- 43,56 ---- private List m_params; private TopicMap m_tm; ! ! public void initialise(TopicMap tm) throws TologParserException { m_tm = tm; } ! public TopicMap getTopicMap() { return m_tm; } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Predicate#setParameters(java.util.List) *************** *** 57,63 **** return matches(params); } ! public abstract VariableSet matches(List params) throws TologProcessingException ; ! public Object getParameterValue(int paramIx, Map paramMap) { Object param = m_params.get(paramIx); --- 65,71 ---- return matches(params); } ! public abstract VariableSet matches(List params) throws TologProcessingException ; ! public Object getParameterValue(int paramIx, Map paramMap) { Object param = m_params.get(paramIx); *************** *** 102,106 **** return m_params; } ! public void validateParameters() throws TologParserException { if (m_params.size() < getMinParamCount()) { --- 110,114 ---- return m_params; } ! public void validateParameters() throws TologParserException { if (m_params.size() < getMinParamCount()) { *************** *** 121,128 **** } } ! } } ! /** * Returns the minimum number of parameters accepted by this predicate. --- 129,136 ---- } } ! } } ! /** * Returns the minimum number of parameters accepted by this predicate. *************** *** 132,136 **** return getParamCount(); } ! /** * Returns the maximum number of parameters accepted by this predicate. --- 140,144 ---- return getParamCount(); } ! /** * Returns the maximum number of parameters accepted by this predicate. *************** *** 150,154 **** */ public abstract ParameterInfo [] getParamInfo(); ! /** * Returns the number of parameters accepted by this predicate. --- 158,162 ---- */ public abstract ParameterInfo [] getParamInfo(); ! /** * Returns the number of parameters accepted by this predicate. *************** *** 160,164 **** return pi == null ? 0 : pi.length; } ! /** * Indicates if a variable is allowed to be specified for a predicate parameter. --- 168,172 ---- return pi == null ? 0 : pi.length; } ! /** * Indicates if a variable is allowed to be specified for a predicate parameter. *************** *** 173,186 **** ParameterInfo pi = getParamInfo()[ix]; if (pi != null) { ! return pi.isVariableAllowed(); } else { return true; } } ! /** * Validates that a parameter is of the expected type. * @param ix the index of the predicate parameter being tested ! * @param paramType the type of the predicate parameter * @return true if <code>paramType</code> is an allowed type * for the parameter at <code>ix</code>, false otherwise. --- 181,194 ---- ParameterInfo pi = getParamInfo()[ix]; if (pi != null) { ! return pi.isVariableAllowed(); } else { return true; } } ! /** * Validates that a parameter is of the expected type. * @param ix the index of the predicate parameter being tested ! * @param paramType the type of the predicate parameter * @return true if <code>paramType</code> is an allowed type * for the parameter at <code>ix</code>, false otherwise. *************** *** 189,193 **** ParameterInfo pi = getParamInfo()[ix]; if (pi != null) { ! return pi.validateParamType(paramType); } else { return true; --- 197,201 ---- ParameterInfo pi = getParamInfo()[ix]; if (pi != null) { ! return pi.validateParamType(paramType); } else { return true; *************** *** 204,208 **** } } ! public void addResultsRow(VariableSet resultsSet, Object[] results) throws TologProcessingException { int max = getParameters().size(); --- 212,216 ---- } } ! public void addResultsRow(VariableSet resultsSet, Object[] results) throws TologProcessingException { int max = getParameters().size(); *************** *** 215,219 **** resultsSet.addRow(row); } ! /** * Returns the name of this predicate. This name is used in exception --- 223,227 ---- resultsSet.addRow(row); } ! /** * Returns the name of this predicate. This name is used in exception *************** *** 238,242 **** } /** ! * Parameter description information for predicates derived from the PredicateBase * abstract class. This class keeps track of two pieces of information for a parameter. * The first, <code>variableAllowed</code>, is a boolean flag which is true if it is allowable --- 246,250 ---- } /** ! * Parameter description information for predicates derived from the PredicateBase * abstract class. This class keeps track of two pieces of information for a parameter. * The first, <code>variableAllowed</code>, is a boolean flag which is true if it is allowable *************** *** 244,248 **** * is an array of Class instances which define the allowed Class (or interface) that * the parameter value should implement. The parameter is required to be assignable ! * to one of the classes specified in <code>allowedTypes</code>. * @author Kal Ahmed (ka...@te...) */ --- 252,256 ---- * is an array of Class instances which define the allowed Class (or interface) that * the parameter value should implement. The parameter is required to be assignable ! * to one of the classes specified in <code>allowedTypes</code>. * @author Kal Ahmed (ka...@te...) */ *************** *** 250,254 **** private boolean m_varAllowed; private Class[] m_allowedTypes; ! /** * Creates information for a parameter where the type of the parameter --- 258,262 ---- private boolean m_varAllowed; private Class[] m_allowedTypes; ! /** * Creates information for a parameter where the type of the parameter *************** *** 260,266 **** m_allowedTypes = null; } ! /** ! * Creates information for a parameter where the parameter type is * constrainted to a single class * @param variableAllowed indicates whether or not a variable is allowed for this parameter. --- 268,274 ---- m_allowedTypes = null; } ! /** ! * Creates information for a parameter where the parameter type is * constrainted to a single class * @param variableAllowed indicates whether or not a variable is allowed for this parameter. *************** *** 271,275 **** m_allowedTypes = new Class[] {allowedType}; } ! /** * Creates information for a parameter where the parameter type can be one --- 279,283 ---- m_allowedTypes = new Class[] {allowedType}; } ! /** * Creates information for a parameter where the parameter type can be one *************** *** 282,290 **** m_allowedTypes = allowedTypes; } ! public boolean isVariableAllowed() { return m_varAllowed; } ! public boolean validateParamType(Class paramType) { if (m_allowedTypes == null) return true; --- 290,298 ---- m_allowedTypes = allowedTypes; } ! public boolean isVariableAllowed() { return m_varAllowed; } ! public boolean validateParamType(Class paramType) { if (m_allowedTypes == null) return true; *************** *** 297,335 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:30:00 lheuer - * Initial tolog import - * - * Revision 1.8 2004/07/20 07:12:07 kal_ahmed - * getParameters() now returns a direct reference to the parameters which can be modified. - * - * Revision 1.7 2004/07/16 13:51:36 kal_ahmed - * Fixes for tolog engine handling of rules and rule-recursion. - * - * Revision 1.6 2004/06/16 21:21:43 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.5 2004/06/13 19:44:30 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - * Revision 1.4 2004/06/13 17:17:59 kal_ahmed - * Added registration of builtin predicates. Fixed rule expansion code to handle player/role pairs correctly. - * - * Revision 1.3 2004/06/09 22:15:08 kal_ahmed - * Fixed parser to disallow player:role pairs in predicates other than dynamic association predicates. Fixed initialisation of extension predicates. Added DirectInstanceOfPredicate extension to in-memory query evaluator. - * - * Revision 1.2 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.1 2004/06/07 20:31:59 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.2 2004/06/02 19:22:13 kal_ahmed - * Added support for parsing rules and including them in queries. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 305,306 ---- Index: SubjectIdentifierPredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/SubjectIdentifierPredicate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SubjectIdentifierPredicate.java 6 Mar 2005 23:38:00 -0000 1.3 --- SubjectIdentifierPredicate.java 8 Mar 2005 12:33:57 -0000 1.4 *************** *** 1,6 **** /* ! * Created on 11-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES ... [truncated message content] |
From: Lars H. <lh...@us...> - 2005-03-08 12:34:27
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/memory In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/memory Modified Files: PreparedQueryImpl.java QueryEvaluatorImpl.java Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: PreparedQueryImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/memory/PreparedQueryImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PreparedQueryImpl.java 6 Mar 2005 17:28:46 -0000 1.1 --- PreparedQueryImpl.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.memory; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.memory; *************** *** 16,32 **** /** ! * @author Kal ! * ! * Describe PreparedQueryImpl here. */ public class PreparedQueryImpl implements PreparedQuery { private TologQuery m_query; ! public PreparedQueryImpl(TologQuery q) { m_query = q; rewrite(); } ! /** * Rewrite the query for optimisation purposes --- 24,40 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class PreparedQueryImpl implements PreparedQuery { private TologQuery m_query; ! public PreparedQueryImpl(TologQuery q) { m_query = q; rewrite(); } ! /** * Rewrite the query for optimisation purposes *************** *** 58,74 **** } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:28:46 lheuer - * Initial tolog import - * - * Revision 1.4 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.3 2004/06/16 21:21:43 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.2 2004/06/09 21:12:18 kal_ahmed - * Added standard source file header and footer. - * - */ \ No newline at end of file --- 66,67 ---- Index: QueryEvaluatorImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/memory/QueryEvaluatorImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryEvaluatorImpl.java 6 Mar 2005 17:28:46 -0000 1.1 --- QueryEvaluatorImpl.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.memory; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.memory; *************** *** 51,57 **** /** ! * @author Kal ! * ! * Describe QueryEvaluatorImpl here. */ public class QueryEvaluatorImpl implements QueryEvaluator { --- 59,65 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class QueryEvaluatorImpl implements QueryEvaluator { *************** *** 62,66 **** private Map m_rulesByPrefix = null; private Map m_predicatesByName = null; ! public QueryEvaluatorImpl(TopicMap tm) { m_rulesByName = new HashMap(); --- 70,74 ---- private Map m_rulesByPrefix = null; private Map m_predicatesByName = null; ! public QueryEvaluatorImpl(TopicMap tm) { m_rulesByName = new HashMap(); *************** *** 70,74 **** setTopicMap(tm); } ! /** * Loads the default built-in predicates --- 78,82 ---- setTopicMap(tm); } ! /** * Loads the default built-in predicates *************** *** 100,109 **** m_tm = tm; } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.QueryEvaluator#addRulesModule(java.io.InputStream, java.lang.String) */ public void addRulesModule(InputStream src, String prefix) ! throws IOException, TologParserException { try { --- 108,117 ---- m_tm = tm; } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.QueryEvaluator#addRulesModule(java.io.InputStream, java.lang.String) */ public void addRulesModule(InputStream src, String prefix) ! throws IOException, TologParserException { try { *************** *** 142,146 **** */ public PreparedQuery prepareQuery(String queryString) ! throws TologParserException, TologProcessingException { try { --- 150,154 ---- */ public PreparedQuery prepareQuery(String queryString) ! throws TologParserException, TologProcessingException { try { *************** *** 162,166 **** */ public TologResultsSet execute(String queryString) ! throws TologParserException, TologProcessingException { PreparedQuery pq = prepareQuery(queryString); --- 170,174 ---- */ public TologResultsSet execute(String queryString) ! throws TologParserException, TologProcessingException { PreparedQuery pq = prepareQuery(queryString); *************** *** 183,192 **** String predicateName, Class predicateClass) ! throws IllegalArgumentException { if (!Predicate.class.isAssignableFrom(predicateClass)) { throw new IllegalArgumentException("Class does not implement the " + Predicate.class.getName() + " interface."); } ! m_predicatesByName.put(predicateName, predicateClass); } --- 191,200 ---- String predicateName, Class predicateClass) ! throws IllegalArgumentException { if (!Predicate.class.isAssignableFrom(predicateClass)) { throw new IllegalArgumentException("Class does not implement the " + Predicate.class.getName() + " interface."); } ! m_predicatesByName.put(predicateName, predicateClass); } *************** *** 200,240 **** } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:28:46 lheuer - * Initial tolog import - * - * Revision 1.12 2004/11/02 16:03:38 kal_ahmed - * Fixed reported bug with processing external tolog modules. - * - * Revision 1.11 2004/08/17 14:55:28 kal_ahmed - * Fixed naming of subject-locator and subject-identifier predicate implementations (Bug#1010670). - * - * Revision 1.10 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.9 2004/06/16 21:21:43 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.8 2004/06/14 21:31:16 kal_ahmed - * Added TopicNamePredicate to builtins. - * - * Revision 1.7 2004/06/13 19:44:30 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - * Revision 1.6 2004/06/13 17:17:59 kal_ahmed - * Added registration of builtin predicates. Fixed rule expansion code to handle player/role pairs correctly. - * - * Revision 1.5 2004/06/10 17:09:34 kal_ahmed - * Added reifies and instance-of predicates. - * - * Revision 1.4 2004/06/10 08:18:35 kal_ahmed - * Added OccurrencePredicate to default extensions. - * - * Revision 1.3 2004/06/09 22:15:08 kal_ahmed - * Fixed parser to disallow player:role pairs in predicates other than dynamic association predicates. Fixed initialisation of extension predicates. Added DirectInstanceOfPredicate extension to in-memory query evaluator. - * - * Revision 1.2 2004/06/09 21:12:18 kal_ahmed - * Added standard source file header and footer. - * - */ \ No newline at end of file --- 208,209 ---- |
From: Lars H. <lh...@us...> - 2005-03-08 12:34:27
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog Modified Files: PreparedQuery.java QueryEvaluator.java QueryEvaluatorFactory.java TologFragmentBuilder.java TologFragmentBuilderException.java TologFragmentBuilderImpl.java TologParserException.java TologProcessingException.java TologResultsSet.java todo-log.txt Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: QueryEvaluator.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/QueryEvaluator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryEvaluator.java 6 Mar 2005 17:27:33 -0000 1.1 --- QueryEvaluator.java 8 Mar 2005 12:33:39 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ */ package org.tmapiutils.query.tolog; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog; *************** *** 23,26 **** --- 31,37 ---- * This class also supports the registration of extension * predicates. + * + * @author Kal Ahmed (kal[at]techquila.com) + * @author Lars Heuer (heuer[at]semagia.com) */ public interface QueryEvaluator *************** *** 34,40 **** * read but contained syntax errors. */ ! public void addRulesModule(InputStream src, String prefix) throws IOException, TologParserException; ! /** * Adds a new rule to the QueryEvaluator. --- 45,51 ---- * read but contained syntax errors. */ ! public void addRulesModule(InputStream src, String prefix) throws IOException, TologParserException; ! /** * Adds a new rule to the QueryEvaluator. *************** *** 43,51 **** */ public void addRule(String rule) throws TologParserException; ! /** * Parses (and possibly optimizes) the specified tolog query string. * The return value is the parsed query which can then be executed ! * simply by calling {PreparedQuery#execute()}. * @param queryString the tolog query string to be parsed. * @return the PreparedQuery that represents the parsed, optimized tolog query. --- 54,62 ---- */ public void addRule(String rule) throws TologParserException; ! /** * Parses (and possibly optimizes) the specified tolog query string. * The return value is the parsed query which can then be executed ! * simply by calling {PreparedQuery#execute()}. * @param queryString the tolog query string to be parsed. * @return the PreparedQuery that represents the parsed, optimized tolog query. *************** *** 54,58 **** */ public PreparedQuery prepareQuery(String queryString) throws TologParserException, TologProcessingException; ! /** * A convenience method that parses and optimizes the specified --- 65,69 ---- */ public PreparedQuery prepareQuery(String queryString) throws TologParserException, TologProcessingException; ! /** * A convenience method that parses and optimizes the specified *************** *** 73,79 **** * @throws TologParserException if a syntax error or parse-time error is found in <code>queryString</code> * @throws TologProcessingException if an error occurrs during the optimisation or evaluation of the query. ! */ public TologResultsSet execute(String queryString, Object[] queryParams) throws TologParserException, TologProcessingException; ! /** * Registers an extension predicate with the QueryEvaluator. --- 84,90 ---- * @throws TologParserException if a syntax error or parse-time error is found in <code>queryString</code> * @throws TologProcessingException if an error occurrs during the optimisation or evaluation of the query. ! */ public TologResultsSet execute(String queryString, Object[] queryParams) throws TologParserException, TologProcessingException; ! /** * Registers an extension predicate with the QueryEvaluator. *************** *** 87,128 **** public void registerPredicateClass(String predicateName, Class predicateClass) throws IllegalArgumentException; ! /** ! * Returns a Map of the predicates currently registered with the * QueryEvaluator. The Map key is the name of the predicate and * the value is the implementation Class of the predicate. */ public Map getRegisteredPredicates(); ! } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:27:33 lheuer - * Initial tolog import - * - * Revision 1.8 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.7 2004/06/16 21:21:42 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.6 2004/06/13 19:44:21 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - * Revision 1.5 2004/06/13 17:17:58 kal_ahmed - * Added registration of builtin predicates. Fixed rule expansion code to handle player/role pairs correctly. - * - * Revision 1.4 2004/06/09 22:15:07 kal_ahmed - * Fixed parser to disallow player:role pairs in predicates other than dynamic association predicates. Fixed initialisation of extension predicates. Added DirectInstanceOfPredicate extension to in-memory query evaluator. - * - * Revision 1.3 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.2 2004/06/03 19:36:21 kal_ahmed - * Added support for 'using' and 'import' directives to parser. - * - * Revision 1.1 2004/06/02 19:54:45 kal_ahmed - * Initial proposal for high-level query interface. - * - */ \ No newline at end of file --- 98,109 ---- public void registerPredicateClass(String predicateName, Class predicateClass) throws IllegalArgumentException; ! /** ! * Returns a Map of the predicates currently registered with the * QueryEvaluator. The Map key is the name of the predicate and * the value is the implementation Class of the predicate. */ public Map getRegisteredPredicates(); ! } Index: QueryEvaluatorFactory.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/QueryEvaluatorFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryEvaluatorFactory.java 6 Mar 2005 17:27:33 -0000 1.1 --- QueryEvaluatorFactory.java 8 Mar 2005 12:33:39 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog; *************** *** 14,22 **** /** ! * @author Kal ! * ! * Describe QueryEvaluatorFactory here. */ ! public class QueryEvaluatorFactory { --- 22,30 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ ! public class QueryEvaluatorFactory { *************** *** 27,37 **** } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:27:33 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/09 21:12:18 kal_ahmed - * Added standard source file header and footer. - * - */ \ No newline at end of file --- 35,36 ---- Index: TologParserException.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologParserException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologParserException.java 6 Mar 2005 17:27:33 -0000 1.1 --- TologParserException.java 8 Mar 2005 12:33:39 -0000 1.2 *************** *** 1,17 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog; /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class TologParserException extends Exception { --- 1,25 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TologParserException extends Exception { *************** *** 20,37 **** super(msg); } ! public TologParserException(String msg, Throwable cause) { super(msg, cause); ! } } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:27:33 lheuer - * Initial tolog import - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 28,35 ---- super(msg); } ! public TologParserException(String msg, Throwable cause) { super(msg, cause); ! } } Index: TologProcessingException.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologProcessingException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologProcessingException.java 6 Mar 2005 17:27:33 -0000 1.1 --- TologProcessingException.java 8 Mar 2005 12:33:39 -0000 1.2 *************** *** 1,17 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog; /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class TologProcessingException extends Exception { --- 1,25 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TologProcessingException extends Exception { *************** *** 20,24 **** super(msg); } ! public TologProcessingException(String msg, Throwable cause) { super(msg, cause); --- 28,32 ---- super(msg); } ! public TologProcessingException(String msg, Throwable cause) { super(msg, cause); *************** *** 26,37 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:27:33 lheuer - * Initial tolog import - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 34,35 ---- Index: TologFragmentBuilderException.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologFragmentBuilderException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologFragmentBuilderException.java 6 Mar 2005 17:27:33 -0000 1.1 --- TologFragmentBuilderException.java 8 Mar 2005 12:33:39 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ */ package org.tmapiutils.query.tolog; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog; *************** *** 15,18 **** --- 22,28 ---- * Exception raised by the TologFragmentBuilder interface when exporting * a TologResultsSet object into a topic map fragment. + * + * @author Kal Ahmed (kal[at]techquila.com) + * @author Lars Heuer (heuer[at]semagia.com) */ public class TologFragmentBuilderException extends Exception { *************** *** 50,70 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:27:33 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.3 2004/02/26 21:33:42 kal_ahmed - * Updated license text and reformatted source with Jalopy. - * - * Revision 1.2 2003/08/31 15:08:39 kal_ahmed - * Reformatted source code to Sun code style. - * - * Revision 1.1 2002/12/02 16:51:12 kal_ahmed - * Initial version - * - */ --- 60,61 ---- Index: TologResultsSet.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologResultsSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologResultsSet.java 6 Mar 2005 17:27:33 -0000 1.1 --- TologResultsSet.java 8 Mar 2005 12:33:39 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ */ package org.tmapiutils.query.tolog; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog; *************** *** 19,22 **** --- 26,32 ---- * be thought of as a table consisting of a number of named columns with * one row for each distinct match to the Tolog query. + * + * @author Kal Ahmed (kal[at]techquila.com) + * @author Lars Heuer (heuer[at]semagia.com) */ public interface TologResultsSet { *************** *** 48,68 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:27:33 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.4 2004/02/26 21:33:42 kal_ahmed - * Updated license text and reformatted source with Jalopy. - * - * Revision 1.3 2003/08/31 15:08:39 kal_ahmed - * Reformatted source code to Sun code style. - * - * Revision 1.2 2002/05/06 11:53:43 kal_ahmed - * Added header and log - * - */ --- 58,59 ---- Index: todo-log.txt =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/todo-log.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** todo-log.txt 7 Mar 2005 13:05:42 -0000 1.8 --- todo-log.txt 8 Mar 2005 12:33:39 -0000 1.9 *************** *** 3,6 **** --- 3,7 ---- There are more ToDos, but this a beginning. :)) + File: query\tolog\TologFragmentBuilderImpl.java line: 25 *************** *** 33,44 **** - - File: query\tolog\predicates\ValueLikePredicate.java - line: 114 - getIndexManager() - Should become getHelperObject(IndexInterface.class) - - - File: query\tolog\predicates\test\DirectInstanceOfPredicateTest.java line: 18 --- 34,37 ---- *************** *** 61,64 **** --- 54,58 ---- Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem + File: query\tolog\predicates\test\DynamicAssociationPredicateTest.java line: 28 *************** *** 82,87 **** - - File: query\tolog\predicates\test\ValueLikePredicateTest.java line: 25 --- 76,79 ---- *************** *** 101,104 **** --- 93,97 ---- Should become getHelperObject(IndexInterface.class) + File: query\tolog\predicates\test\ValuePredicateTest.java line: 21 *************** *** 113,137 **** - File: query\tolog\test\AssociationPredicateTest.java - line: 28 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 29 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 30 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 42 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 144 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - line: 145 - TopicMapProvider - Usage of TopicMapProvider cannot be translated 1:1 to TopicMapSystem - - File: query\tolog\test\MemoryQueryEvaluatorImplTest.java line: 28 --- 106,109 ---- *************** *** 214,217 **** --- 186,190 ---- Must become "createTopicName" + File: query\tolog\test\TologParserTest.java line: 258 *************** *** 222,225 **** --- 195,199 ---- Must become "createAssociationRole" + File: query\tolog\test\TologParserTestBase.java line: 16 *************** *** 247,249 **** IDGeneratorFactory Has become org.tmapi.core.utils.IDGeneratorFactory - --- 221,222 ---- Index: PreparedQuery.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/PreparedQuery.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PreparedQuery.java 6 Mar 2005 17:27:33 -0000 1.1 --- PreparedQuery.java 8 Mar 2005 12:33:39 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog; *************** *** 15,20 **** * Represents a parsed, optimized tolog query which can * be executed as often as required. */ ! public interface PreparedQuery { /** --- 23,31 ---- * Represents a parsed, optimized tolog query which can * be executed as often as required. + * + * @author Kal Ahmed (kal[at]techquila.com) + * @author Lars Heuer (heuer[at]semagia.com) */ ! public interface PreparedQuery { /** *************** *** 26,30 **** */ public String getQueryString(); ! /** * Executes the prepared query. --- 37,41 ---- */ public String getQueryString(); ! /** * Executes the prepared query. *************** *** 33,39 **** */ public TologResultsSet execute() throws TologProcessingException; ! /** ! * Executes a prepared query substituting <i>%n</i> references with the <i>n</i>th value from * the parameter array. * @param params the parameter array for this query evaluation --- 44,50 ---- */ public TologResultsSet execute() throws TologProcessingException; ! /** ! * Executes a prepared query substituting <i>%n</i> references with the <i>n</i>th value from * the parameter array. * @param params the parameter array for this query evaluation *************** *** 43,60 **** public TologResultsSet execute(Object[] params) throws TologProcessingException; } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:27:33 lheuer - * Initial tolog import - * - * Revision 1.4 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.3 2004/06/16 21:21:42 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.2 2004/06/09 21:12:18 kal_ahmed - * Added standard source file header and footer. - * - */ \ No newline at end of file --- 54,55 ---- Index: TologFragmentBuilder.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologFragmentBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologFragmentBuilder.java 6 Mar 2005 17:27:33 -0000 1.1 --- TologFragmentBuilder.java 8 Mar 2005 12:33:39 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ */ package org.tmapiutils.query.tolog; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog; *************** *** 17,20 **** --- 24,30 ---- * The interface for implementations which export a TologResultsSet into * a TopicMapFragment. + * + * @author Kal Ahmed (kal[at]techquila.com) + * @author Lars Heuer (heuer[at]semagia.com) */ public interface TologFragmentBuilder { Index: TologFragmentBuilderImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologFragmentBuilderImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TologFragmentBuilderImpl.java 6 Mar 2005 21:11:31 -0000 1.2 --- TologFragmentBuilderImpl.java 8 Mar 2005 12:33:39 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ */ package org.tmapiutils.query.tolog; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog; *************** *** 14,18 **** import org.tmapi.core.LocatorFactory; import org.tmapi.core.LocatorFactoryException; ! import org.tmapi.core.Association; import org.tmapi.core.TopicName; --- 21,25 ---- import org.tmapi.core.LocatorFactory; import org.tmapi.core.LocatorFactoryException; ! // TMAPI import org.tmapi.core.Association; import org.tmapi.core.TopicName; *************** *** 224,257 **** } } - - - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:31 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:27:33 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.6 2004/02/26 21:33:42 kal_ahmed - * Updated license text and reformatted source with Jalopy. - * - * Revision 1.5 2003/08/31 15:08:39 kal_ahmed - * Reformatted source code to Sun code style. - * - * Revision 1.4 2003/06/19 21:09:57 kal_ahmed - * Updated factory methods to eliminate deprecation warnings. - * - * Revision 1.3 2003/05/01 15:51:56 kal_ahmed - * Reorganised import statements. - * - * Revision 1.2 2002/12/13 21:30:09 kal_ahmed - * Fixed Javadoc bugs - * - * Revision 1.1 2002/12/02 16:51:12 kal_ahmed - * Initial version - * - */ --- 231,232 ---- |
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/utils Modified Files: DefaultRowComparator.java InvertedComparator.java ReferenceUtils.java RowComparator.java TologContext.java VariableSet.java Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: InvertedComparator.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/utils/InvertedComparator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InvertedComparator.java 6 Mar 2005 17:35:06 -0000 1.1 --- InvertedComparator.java 8 Mar 2005 12:34:00 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.utils; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.utils; *************** *** 14,24 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class InvertedComparator implements Comparator { Comparator m_comp; ! public InvertedComparator(Comparator comp) { m_comp = comp; --- 21,32 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class InvertedComparator implements Comparator { Comparator m_comp; ! public InvertedComparator(Comparator comp) { m_comp = comp; *************** *** 34,48 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:35:06 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/07 20:32:16 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 42,43 ---- Index: ReferenceUtils.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/utils/ReferenceUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReferenceUtils.java 6 Mar 2005 21:11:34 -0000 1.2 --- ReferenceUtils.java 8 Mar 2005 12:34:00 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.utils; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.utils; *************** *** 17,25 **** /** ! * @author Kal ! * ! * Describe ReferenceUtils here. */ ! public class ReferenceUtils { --- 24,32 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ ! public class ReferenceUtils { *************** *** 32,41 **** Locator l = (Locator)it.next(); if (l.getReference().startsWith(baseAddress) && ! l.getReference().substring(baseAddress.length()).startsWith("#")) { ret = l.getReference().substring(baseAddress.length()); } } ! if (ret == null) { return "@" + tmo.getObjectId(); --- 39,48 ---- Locator l = (Locator)it.next(); if (l.getReference().startsWith(baseAddress) && ! l.getReference().substring(baseAddress.length()).startsWith("#")) { ret = l.getReference().substring(baseAddress.length()); } } ! if (ret == null) { return "@" + tmo.getObjectId(); *************** *** 46,59 **** } - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:34 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:35:06 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/09 21:12:19 kal_ahmed - * Added standard source file header and footer. - * - */ \ No newline at end of file --- 53,54 ---- Index: RowComparator.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/utils/RowComparator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RowComparator.java 6 Mar 2005 17:35:06 -0000 1.1 --- RowComparator.java 8 Mar 2005 12:34:00 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.utils; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.utils; *************** *** 15,30 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public abstract class RowComparator implements Comparator { public abstract void addSortColumn(int ix); ! /* (non-Javadoc) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { ! return compare((List)o1, (List)o2); } --- 22,38 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public abstract class RowComparator implements Comparator { public abstract void addSortColumn(int ix); ! /* (non-Javadoc) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { ! return compare((List)o1, (List)o2); } *************** *** 32,46 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:35:06 lheuer - * Initial tolog import - * - * Revision 1.1 2004/06/07 20:32:17 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 40,41 ---- Index: TologContext.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/utils/TologContext.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologContext.java 6 Mar 2005 17:35:06 -0000 1.1 --- TologContext.java 8 Mar 2005 12:34:00 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.utils; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.utils; *************** *** 19,29 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class TologContext { ! Stack m_ruleStack = new Stack(); ! public void pushRule(TologRule rule, List params) { if (rule.getName() == null) { --- 26,37 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TologContext { ! Stack m_ruleStack = new Stack(); ! public void pushRule(TologRule rule, List params) { if (rule.getName() == null) { *************** *** 32,36 **** m_ruleStack.push(new TologContextElement(rule.getName(), params)); } ! public boolean inRule(TologRule rule) { Iterator it = m_ruleStack.iterator(); --- 40,44 ---- m_ruleStack.push(new TologContextElement(rule.getName(), params)); } ! public boolean inRule(TologRule rule) { Iterator it = m_ruleStack.iterator(); *************** *** 43,47 **** return false; } ! public void popRule(TologRule rule) { if (((TologContextElement)m_ruleStack.peek()).ruleName.equals(rule.getName())) { --- 51,55 ---- return false; } ! public void popRule(TologRule rule) { if (((TologContextElement)m_ruleStack.peek()).ruleName.equals(rule.getName())) { *************** *** 51,55 **** } } ! public List getParams(TologRule rule) { for (int i = m_ruleStack.size() - 1; i >= 0; i--) { --- 59,63 ---- } } ! public List getParams(TologRule rule) { for (int i = m_ruleStack.size() - 1; i >= 0; i--) { *************** *** 61,69 **** return null; } ! public int getDepth() { return m_ruleStack.size(); } ! class TologContextElement { String ruleName; --- 69,77 ---- return null; } ! public int getDepth() { return m_ruleStack.size(); } ! class TologContextElement { String ruleName; *************** *** 76,93 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:35:06 lheuer - * Initial tolog import - * - * Revision 1.3 2004/07/16 13:51:53 kal_ahmed - * Fixes for tolog engine handling of rules and rule-recursion. - * - * Revision 1.2 2004/06/16 21:21:44 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.1 2004/06/13 19:44:31 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - */ \ No newline at end of file --- 84,85 ---- Index: DefaultRowComparator.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/utils/DefaultRowComparator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DefaultRowComparator.java 6 Mar 2005 21:11:34 -0000 1.2 --- DefaultRowComparator.java 8 Mar 2005 12:33:59 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.utils; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.utils; *************** *** 27,36 **** * <li>If the values implement TopicMapObject, then compare on the ID property.</li> * </ol> ! * @author Kal Ahmed (ka...@te...) */ public class DefaultRowComparator extends RowComparator { private List m_sortColumns = new ArrayList(); ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.RowComparator#addSortColumn(int) --- 34,45 ---- * <li>If the values implement TopicMapObject, then compare on the ID property.</li> * </ol> ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class DefaultRowComparator extends RowComparator { private List m_sortColumns = new ArrayList(); ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.RowComparator#addSortColumn(int) *************** *** 66,86 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:34 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:35:06 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/27 17:47:40 kal_ahmed - * Fixed imports. - * - * Revision 1.1 2004/06/07 20:32:15 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 75,76 ---- Index: VariableSet.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/utils/VariableSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VariableSet.java 6 Mar 2005 21:11:34 -0000 1.2 --- VariableSet.java 8 Mar 2005 12:34:00 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.utils; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.utils; *************** *** 23,28 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class VariableSet { --- 30,36 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class VariableSet { *************** *** 30,34 **** private List m_rows; private List m_cols; ! public VariableSet() { m_rows = new ArrayList(); --- 38,42 ---- private List m_rows; private List m_cols; ! public VariableSet() { m_rows = new ArrayList(); *************** *** 37,44 **** public int indexOf(Variable var) { ! return m_cols.indexOf(var); } ! ! public int addColumn(Object colHead) { int ix = m_cols.indexOf(colHead); --- 45,52 ---- public int indexOf(Variable var) { ! return m_cols.indexOf(var); } ! ! public int addColumn(Object colHead) { int ix = m_cols.indexOf(colHead); *************** *** 53,57 **** return m_cols.size() - 1; } ! public void addRow(List values) throws TologProcessingException { if (values.size() != m_cols.size()) { --- 61,65 ---- return m_cols.size() - 1; } ! public void addRow(List values) throws TologProcessingException { if (values.size() != m_cols.size()) { *************** *** 60,64 **** m_rows.add(values); } ! public void addRowFromMap(Map values) throws TologProcessingException { Iterator it = m_cols.iterator(); --- 68,72 ---- m_rows.add(values); } ! public void addRowFromMap(Map values) throws TologProcessingException { Iterator it = m_cols.iterator(); *************** *** 86,90 **** } ! /* public Map getMapping(int rowNum) { HashMap m = new HashMap(); --- 94,98 ---- } ! /* public Map getMapping(int rowNum) { HashMap m = new HashMap(); *************** *** 98,112 **** */ public List removeRow(int rowNum) { ! return (List)m_rows.remove(rowNum); } ! public boolean isEmpty() { return m_rows.isEmpty(); } ! public List getColumns() { return m_cols; } ! public void addColumns(List vars) { m_cols.addAll(vars); --- 106,120 ---- */ public List removeRow(int rowNum) { ! return (List)m_rows.remove(rowNum); } ! public boolean isEmpty() { return m_rows.isEmpty(); } ! public List getColumns() { return m_cols; } ! public void addColumns(List vars) { m_cols.addAll(vars); *************** *** 120,124 **** } } ! public Object clone() { VariableSet ret = new VariableSet(); --- 128,132 ---- } } ! public Object clone() { VariableSet ret = new VariableSet(); *************** *** 132,141 **** return ret; } ! public int size() { return m_rows.size(); } ! ! public void dump(Log log) { if (log.isDebugEnabled()) { --- 140,149 ---- return ret; } ! public int size() { return m_rows.size(); } ! ! public void dump(Log log) { if (log.isDebugEnabled()) { *************** *** 148,152 **** } } ! public void dump() { System.out.println("Variable Set:" + toString()); --- 156,160 ---- } } ! public void dump() { System.out.println("Variable Set:" + toString()); *************** *** 157,161 **** } } ! private String dumpVars(List l) { StringBuffer ret = new StringBuffer(); --- 165,169 ---- } } ! private String dumpVars(List l) { StringBuffer ret = new StringBuffer(); *************** *** 166,170 **** return ret.toString(); } ! private String dumpRow(List r) { StringBuffer ret = new StringBuffer(); --- 174,178 ---- return ret.toString(); } ! private String dumpRow(List r) { StringBuffer ret = new StringBuffer(); *************** *** 194,198 **** projectRow.add(srcRow.get(selectIxs[i])); } ! boolean add = true; Iterator retItems = ret.iterator(); --- 202,206 ---- projectRow.add(srcRow.get(selectIxs[i])); } ! boolean add = true; Iterator retItems = ret.iterator(); *************** *** 218,222 **** return ret; } ! /** * Adds one variable set to another, merging the columns --- 226,230 ---- return ret; } ! /** * Adds one variable set to another, merging the columns *************** *** 256,268 **** addRow(row); } ! public List getRows() { return m_rows; } ! public List getRow(int ix) { return (List)m_rows.get(ix); } ! public void addMatchResults(List inputRow, VariableSet results) { Iterator rows = results.getRows().iterator(); --- 264,276 ---- addRow(row); } ! public List getRows() { return m_rows; } ! public List getRow(int ix) { return (List)m_rows.get(ix); } ! public void addMatchResults(List inputRow, VariableSet results) { Iterator rows = results.getRows().iterator(); *************** *** 274,278 **** int max = cols.size(); for (int c = 0; c < max; c++) { ! if (cols.get(c) instanceof Variable) { int ix = indexOf((Variable)cols.get(c)); rowToAdd.set(ix, resultRow.get(c)); --- 282,286 ---- int max = cols.size(); for (int c = 0; c < max; c++) { ! if (cols.get(c) instanceof Variable) { int ix = indexOf((Variable)cols.get(c)); rowToAdd.set(ix, resultRow.get(c)); *************** *** 284,307 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:34 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:35:06 lheuer - * Initial tolog import - * - * Revision 1.3 2004/07/16 13:51:53 kal_ahmed - * Fixes for tolog engine handling of rules and rule-recursion. - * - * Revision 1.2 2004/06/09 20:20:31 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.1 2004/06/07 20:32:17 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 292,293 ---- |
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/predicates/test Modified Files: AssociationPredicateTest.java AssociationRolePredicateTest.java BaseLocatorPredicateTest.java DirectInstanceOfPredicateTest.java DynamicAssociationPredicateTest.java InstanceOfPredicateTest.java OccurrencePredicateTest.java PredicateTestBase.java ReifiesPredicateTest.java ResourcePredicateTest.java TopicMapPredicateTest.java TopicNameTest.java TypePredicateTest.java ValueLikePredicateTest.java ValuePredicateTest.java VariantPredicateTest.java Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: ResourcePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ResourcePredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ResourcePredicateTest.java 7 Mar 2005 12:32:00 -0000 1.4 --- ResourcePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.5 *************** *** 1,10 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 27,31 **** /** * ! * @author Kal Ahmed (ka...@te...) */ public class ResourcePredicateTest extends PredicateTestBase { --- 34,39 ---- /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ResourcePredicateTest extends PredicateTestBase { *************** *** 57,61 **** --- 65,71 ---- tmapiutils.addSubjectIdentifier(createLocator("tmapiutils")); Topic homepage = tm.createTopic(); + Topic contact_details = tm.createTopic(); tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/", homepage, null); + tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/contact/", contact_details, null); Topic tmapi = tm.createTopic(); tmapiutils.addSubjectIdentifier(createLocator("tmapi")); *************** *** 166,188 **** } - - /* - * $Log$ - * Revision 1.4 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.3 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.2 2005/03/06 18:15:43 lheuer - * org.tmapi.core.Locator -> org.tmapi.core.Locator - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.1 2004/07/27 10:15:57 kal_ahmed - * Initial version - * - */ \ No newline at end of file --- 176,177 ---- Index: PredicateTestBase.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/PredicateTestBase.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PredicateTestBase.java 7 Mar 2005 13:12:38 -0000 1.6 --- PredicateTestBase.java 8 Mar 2005 12:33:58 -0000 1.7 *************** *** 1,17 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.predicates.test; import java.util.HashMap; - //import java.io.StringReader; - import junit.framework.TestCase; --- 1,24 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; + import java.util.Iterator; import java.util.HashMap; import junit.framework.TestCase; *************** *** 24,32 **** import org.tmapi.core.TopicMapObject; import org.tmapi.core.TopicMap; /** - * @author Kal * ! * Describe PredicateTestBase here. */ public abstract class PredicateTestBase extends TestCase { --- 31,40 ---- import org.tmapi.core.TopicMapObject; import org.tmapi.core.TopicMap; + import org.tmapi.core.TMAPIException; /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public abstract class PredicateTestBase extends TestCase { *************** *** 34,38 **** protected Predicate m_predicate; ! protected TopicMap _topicMap; private HashMap _maps; private HashMap _objectMap; --- 42,46 ---- protected Predicate m_predicate; ! protected TopicMap m_tm; private HashMap _maps; private HashMap _objectMap; *************** *** 53,62 **** public void setUp() throws Exception { ! super().setUp(); ! _tmSystem = TopicMapSystemFactory().newInstance().newTopicMapSystem(); removeAllMaps(); ! m_tm = createTopicMap('http://tmapiutils.org/test/tolog1.0/'); m_predicate = (Predicate) getPredicateClass().newInstance(); - m_predicate.createTestMap(m_tm); m_predicate.initialise(m_tm); m_context = new TologContext(); --- 61,70 ---- public void setUp() throws Exception { ! super.setUp(); ! _tmSystem = TopicMapSystemFactory.newInstance().newTopicMapSystem(); removeAllMaps(); ! m_tm = createTopicMap("http://tmapiutils.org/test/tolog1.0/"); ! createTestMap(m_tm); m_predicate = (Predicate) getPredicateClass().newInstance(); m_predicate.initialise(m_tm); m_context = new TologContext(); *************** *** 67,71 **** _objectMap.clear(); // remove created TopicMaps from TopicMapSystem ! removeAllMaps(); // Close TopicMapSystem instance _tmSystem.close(); --- 75,79 ---- _objectMap.clear(); // remove created TopicMaps from TopicMapSystem ! removeAllMaps(); // Close TopicMapSystem instance _tmSystem.close(); *************** *** 85,135 **** protected void removeAllMaps() throws TMAPIException { ! for (Iterator iter = _tmSystem.getBaseLocators().iterator(); iter.hasNext();) removeTopicMap(_tmSystem.getTopicMap((Locator)iter.next())); } } ! protected TopicMap createTopicMap(String reference)throws TopicMapExistsException{ TopicMap tm = _tmSystem.createTopicMap(reference); ! _maps.put(reference,tm); return tm; } ! protected void removeTopicMap(TopicMap tm)throws TMAPIException{ _maps.remove(tm.getBaseLocator().getReference()); tm.remove(); } - - } - /* - * $Log$ - * Revision 1.6 2005/03/07 13:12:38 lheuer - * Clear the _objectMap in tearDown() - * - * Revision 1.5 2005/03/07 13:00:41 lheuer - * Typo _system vs. _tmSystem - * - * Revision 1.4 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.3 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.2 2005/03/06 18:15:43 lheuer - * org.tmapi.core.Locator -> org.tmapi.core.Locator - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.4 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.3 2004/06/13 11:30:26 kal_ahmed - * Initial implementation of value-like predicate. - * - * Revision 1.2 2004/06/10 17:09:35 kal_ahmed - * Added reifies and instance-of predicates. - * - */ \ No newline at end of file --- 93,110 ---- protected void removeAllMaps() throws TMAPIException { ! for (Iterator iter = _tmSystem.getBaseLocators().iterator(); iter.hasNext();) { removeTopicMap(_tmSystem.getTopicMap((Locator)iter.next())); } } ! protected TopicMap createTopicMap(String reference) throws TMAPIException { TopicMap tm = _tmSystem.createTopicMap(reference); ! _maps.put(reference, tm); return tm; } ! ! protected void removeTopicMap(TopicMap tm) throws TMAPIException { _maps.remove(tm.getBaseLocator().getReference()); tm.remove(); } } Index: TopicMapPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TopicMapPredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TopicMapPredicateTest.java 7 Mar 2005 12:32:00 -0000 1.3 --- TopicMapPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates.test; *************** *** 22,27 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class TopicMapPredicateTest extends PredicateTestBase { --- 29,35 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TopicMapPredicateTest extends PredicateTestBase { *************** *** 62,66 **** assertEquals(m_tm, out.getRow(0).get(0)); } ! public void testClosedMatch() throws Exception { tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); --- 70,74 ---- assertEquals(m_tm, out.getRow(0).get(0)); } ! public void testClosedMatch() throws Exception { tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); *************** *** 75,79 **** assertEquals(1, out.getRows().size()); assertEquals(m_tm, out.getRow(0).get(0)); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("hello-world")); params.set(0, tmo); --- 83,87 ---- assertEquals(1, out.getRows().size()); assertEquals(m_tm, out.getRow(0).get(0)); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("hello-world")); params.set(0, tmo); *************** *** 84,106 **** } - - /* - * $Log$ - * Revision 1.3 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.2 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/13 10:32:29 kal_ahmed - * Initial implementation of topicmap() predicate. - * - */ \ No newline at end of file --- 92,93 ---- Index: ReifiesPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ReifiesPredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReifiesPredicateTest.java 7 Mar 2005 12:32:00 -0000 1.3 --- ReifiesPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; *************** *** 17,26 **** // import org.tmapi.core.utils.TopicMapBuilder; // import org.tmapi.core.utils.XTMBuilder; ! import org.tmapi.index.core.TopicMapObjectsIndex; /** ! * @author Kal ! * ! * Describe ReifiesPredicateTest here. */ public class ReifiesPredicateTest extends PredicateTestBase { --- 25,38 ---- // import org.tmapi.core.utils.TopicMapBuilder; // import org.tmapi.core.utils.XTMBuilder; ! //import org.tmapi.index.core.TopicMapObjectsIndex; ! // TMAPI ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.Topic; ! import org.tmapi.core.Association; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ReifiesPredicateTest extends PredicateTestBase { *************** *** 37,41 **** */ public String getTestMap() { ! return "<topicMap xmlns=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" + "<topic id=\"fred\"/> <topic id=\"bigco\"/> <topic id=\"worksfor\"/>" + "<association id=\"assoc1\">" + "<instanceOf><topicRef xlink:href=\"#worksfor\"/></instanceOf>" + "<member id=\"m1\"><topicRef xlink:href=\"#fred\"/></member>" + "<member id=\"m2\"><topicRef xlink:href=\"#bigco\"/></member>" + "</association>" + "<topic id=\"fredemp\"> <subjectIdentity><resourceRef xlink:href=\"#assoc1\"/> </subjectIdentity> </topic>" + "</topicMap>"; } --- 49,60 ---- */ public String getTestMap() { ! return "<topicMap xmlns=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" + ! "<topic id=\"fred\"/> <topic id=\"bigco\"/> <topic id=\"worksfor\"/>" ! "<association id=\"assoc1\">" + ! "<instanceOf><topicRef xlink:href=\"#worksfor\"/></instanceOf>" + ! "<member id=\"m1\"><topicRef xlink:href=\"#fred\"/></member>" + ! "<member id=\"m2\"><topicRef xlink:href=\"#bigco\"/></member>" + ! "</association>" + ! "<topic id=\"fredemp\"> <subjectIdentity><resourceRef xlink:href=\"#assoc1\"/> </subjectIdentity> </topic>" + "</topicMap>"; } *************** *** 49,66 **** Topic fred = tm.createTopic(); Topic fredemp = tm.createTopic(); - fred.addSubjectIdentifier(tm.createLocator("fred")); Topic barney = tm.createTopic(); - barney.addSubjectIdentifier(tm.createLocator("barney")); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); ! Association assoc = tm.createAssociation(); ! assoc.setType(works_for); ! assoc.createAssociationRole(fred, employee); ! assoc.createAssociationRole(bigco, employer); ! assoc.createAssociationRole(barney, employee); } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.test.PredicateTestBase#getPredicateClass() --- 68,88 ---- Topic fred = tm.createTopic(); Topic fredemp = tm.createTopic(); Topic barney = tm.createTopic(); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); ! Association assoc1 = tm.createAssociation(); ! assoc1.setType(works_for); ! assoc1.createAssociationRole(fred, employee); ! assoc1.createAssociationRole(bigco, employer); ! assoc1.createAssociationRole(barney, employee); ! ! registerObject("assoc1", assoc1); ! registerObject("fred", fred); ! registerObject("barney", barney); ! registerObject("fredemp", fredemp); } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.test.PredicateTestBase#getPredicateClass() *************** *** 71,81 **** public void testMatchReifier() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); params.add(a); ! params.add(m_tm.getObjectById("assoc1")); m_predicate.setParameters(params); VariableSet out = m_predicate.matches(params, m_context); --- 93,100 ---- public void testMatchReifier() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); params.add(a); ! params.add(getObjectById("assoc1")); m_predicate.setParameters(params); VariableSet out = m_predicate.matches(params, m_context); *************** *** 83,97 **** assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("fredemp")); ! assertTrue(out.getRow(0).contains(tmo)); } ! public void testMatchReified() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! params.add(m_tm.getObjectById("fredemp")); params.add(a); m_predicate.setParameters(params); --- 102,112 ---- assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getRow(0).contains(getObjectById("fredemp"))); } ! public void testMatchReified() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! params.add(fredemp); params.add(a); m_predicate.setParameters(params); *************** *** 100,111 **** assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("assoc1")); ! assertTrue(out.getRow(0).contains(tmo)); } ! public void testOpenMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 115,122 ---- assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getRow(0).contains(getObjectById("fredemp"))); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 118,131 **** assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! TopicMapObject fredemp = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("fredemp")); ! TopicMapObject assoc1 = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("assoc1")); ! assertTrue(out.getRow(0).get(0).equals(fredemp)); ! assertTrue(out.getRow(0).get(1).equals(assoc1)); } ! public void testClosedMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 129,137 ---- assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getRow(0).get(0).equals(getObjectById("fredemp"))); ! assertTrue(out.getRow(0).get(1).equals(getObjectById("assoc1"))); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 134,173 **** params.add(b); m_predicate.setParameters(params); ! TopicMapObject fredemp = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("fredemp")); ! TopicMapObject assoc1 = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("assoc1")); ! params.set(0, fredemp)); ! params.set(1, assoc1)); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! TopicMapObject m1 = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("m1")); ! params.set(0, fredemp)); ! params.set(1, m1)); out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! } } - /* - * $Log$ - * Revision 1.3 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.2 2005/03/06 21:11:33 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/10 17:09:35 kal_ahmed - * Added reifies and instance-of predicates. - * - */ \ No newline at end of file --- 140,156 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, getObjectById("fredemp"))); ! params.set(1, getObjectById("assoc1"))); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! params.set(0, getObjectById("fredemp"))); ! params.set(1, getObjectById("m1"))); out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! } } Index: AssociationRolePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/AssociationRolePredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AssociationRolePredicateTest.java 7 Mar 2005 12:32:00 -0000 1.3 --- AssociationRolePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 24,33 **** import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; - import org.tmapi.index.core.TopicsIndex; /** - * @author Kal * ! * Describe AssociationRolePredicateTest here. */ public class AssociationRolePredicateTest extends PredicateTestBase { --- 30,38 ---- import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class AssociationRolePredicateTest extends PredicateTestBase { *************** *** 64,67 **** --- 69,75 ---- assoc.createAssociationRole(bigco, employer); assoc.createAssociationRole(barney, employee); + + registerObject("fred", fred); + registerObject("barney", barney); } *************** *** 74,83 **** public void testMatchAssociation() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! Topic fred = topicsIdx.getTopicBySubjectIdentifier(createLocator("fred")); AssociationRole role = (AssociationRole) fred.getRolesPlayed().iterator().next(); params.add(a); --- 82,88 ---- public void testMatchAssociation() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! Topic fred = (Topic) getObjectById("fred"); AssociationRole role = (AssociationRole) fred.getRolesPlayed().iterator().next(); params.add(a); *************** *** 92,100 **** public void testMatchRoles() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); ArrayList params = new ArrayList(); ! Topic barney = topicsIdx.getTopicBySubjectIdentifier(createLocator("fred")); Association assoc = ((AssociationRole) barney.getRolesPlayed().iterator().next()).getAssociation(); Variable a = new Variable("A"); --- 97,102 ---- public void testMatchRoles() throws Exception { ArrayList params = new ArrayList(); ! Topic barney =(Topic) getObjectById("barney"); Association assoc = ((AssociationRole) barney.getRolesPlayed().iterator().next()).getAssociation(); Variable a = new Variable("A"); *************** *** 106,111 **** assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! assertEquals(assoc, ((AssociationRole)out.getRow(0).get(0)).getParent()); ! assertEquals(assoc, ((AssociationRole)out.getRow(1).get(0)).getParent()); } --- 108,113 ---- assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! assertEquals(assoc, ((AssociationRole)out.getRow(0).get(0)).getAssociation()); ! assertEquals(assoc, ((AssociationRole)out.getRow(1).get(0)).getAssociation()); } *************** *** 129,135 **** public void testClosedMatch() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 131,134 ---- *************** *** 138,142 **** params.add(b); m_predicate.setParameters(params); ! Topic fred = topicsIdx.getTopicBySubjectIdentifier(createLocator("fred")); AssociationRole role = (AssociationRole) fred.getRolesPlayed().iterator().next(); Association assoc = role.getAssociation(); --- 137,141 ---- params.add(b); m_predicate.setParameters(params); ! Topic fred = (Topic) getObjectById("fred"); AssociationRole role = (AssociationRole) fred.getRolesPlayed().iterator().next(); Association assoc = role.getAssociation(); *************** *** 148,152 **** assertEquals(1, out.getRows().size()); ! Topic barney = topicsIdx.getTopicBySubjectIdentifier(createLocator("barney")); AssociationRole role2 = (AssociationRole)barney.getRolesPlayed().iterator().next(); params.set(1, role2); --- 147,151 ---- assertEquals(1, out.getRows().size()); ! Topic barney =(Topic) getObjectById("barney"); AssociationRole role2 = (AssociationRole)barney.getRolesPlayed().iterator().next(); params.set(1, role2); *************** *** 157,178 **** } } ! /* ! * $Log$ ! * Revision 1.3 2005/03/07 12:32:00 lheuer ! * More TM4J -> TMAPI translations ! * Updated ToDo ! * ResourcePredicate can handle Variants, too ! * ! * Revision 1.2 2005/03/06 19:37:23 lheuer ! * Changed getTopicByID to getObjectById ! * ! * Revision 1.1 2005/03/06 17:33:23 lheuer ! * Initial tolog import ! * ! * Revision 1.2 2004/06/14 20:09:46 kal_ahmed ! * Updated test code to work with new Predicate interface. ! * ! * Revision 1.1 2004/06/11 08:29:29 kal_ahmed ! * Added association and association-role predicates. ! * ! */ \ No newline at end of file --- 156,158 ---- } } ! Index: DirectInstanceOfPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/DirectInstanceOfPredicateTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DirectInstanceOfPredicateTest.java 7 Mar 2005 12:32:00 -0000 1.5 --- DirectInstanceOfPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.6 *************** *** 1,6 **** /* ! * Created on 10-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; *************** *** 27,33 **** /** - * @author Kal * ! * Describe DirectInstanceOfPredicateTest here. */ public class DirectInstanceOfPredicateTest extends TestCase { --- 40,46 ---- /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class DirectInstanceOfPredicateTest extends TestCase { Index: BaseLocatorPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/BaseLocatorPredicateTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BaseLocatorPredicateTest.java 7 Mar 2005 12:32:00 -0000 1.2 --- BaseLocatorPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,6 **** /* ! * Created on 11-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; *************** *** 10,18 **** import org.tmapiutils.query.tolog.predicates.BaseLocatorPredicate; import org.tmapiutils.query.tolog.utils.VariableSet; /** ! * @author Kal ! * ! * Describe BaseLocatorPredicateTest here. */ public class BaseLocatorPredicateTest extends PredicateTestBase { --- 23,33 ---- import org.tmapiutils.query.tolog.predicates.BaseLocatorPredicate; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI + import org.tmapi.core.TopicMap; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class BaseLocatorPredicateTest extends PredicateTestBase { *************** *** 31,35 **** return "[test]"; } ! public void createTestMap(TopicMap tm) { // noop. --- 46,50 ---- return "[test]"; } ! public void createTestMap(TopicMap tm) { // noop. *************** *** 42,46 **** return BaseLocatorPredicate.class; } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); --- 57,61 ---- return BaseLocatorPredicate.class; } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 52,58 **** assertEquals(1, out.getRows().size()); assertEquals(m_tm.getBaseLocator(), out.getRow(0).get(0)); ! } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); --- 67,73 ---- assertEquals(1, out.getRows().size()); assertEquals(m_tm.getBaseLocator(), out.getRow(0).get(0)); ! } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 72,76 **** assertEquals(1, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! } --- 87,91 ---- assertEquals(1, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! } Index: DynamicAssociationPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/DynamicAssociationPredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DynamicAssociationPredicateTest.java 6 Mar 2005 19:37:23 -0000 1.3 --- DynamicAssociationPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates.test; *************** *** 33,38 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class DynamicAssociationPredicateTest extends TestCase { --- 40,46 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class DynamicAssociationPredicateTest extends TestCase { *************** *** 76,80 **** } ! public void testMultipleMatch() throws Exception { --- 84,88 ---- } ! public void testMultipleMatch() throws Exception { *************** *** 105,109 **** } } ! public void testRoleMatch() throws Exception { ClauseList c = new ClauseList(); --- 113,117 ---- } } ! public void testRoleMatch() throws Exception { ClauseList c = new ClauseList(); *************** *** 135,139 **** } } ! /* (non-Javadoc) * @see junit.framework.TestCase#setUp() --- 143,147 ---- } } ! /* (non-Javadoc) * @see junit.framework.TestCase#setUp() *************** *** 152,184 **** } - - /* - * $Log$ - * Revision 1.3 2005/03/06 19:37:23 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.2 2005/03/06 18:15:43 lheuer - * org.tmapi.core.Locator -> org.tmapi.core.Locator - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.3 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.2 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.1 2004/06/07 20:42:24 kal_ahmed - * Added infrastructure for backend-specific implementations and start of a default in-memory implementation. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:17 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 160,161 ---- Index: VariantPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/VariantPredicateTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VariantPredicateTest.java 6 Mar 2005 19:37:40 -0000 1.2 --- VariantPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates.test; *************** *** 20,25 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class VariantPredicateTest extends PredicateTestBase { --- 27,33 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class VariantPredicateTest extends PredicateTestBase { *************** *** 53,58 **** params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); params.set(0, fredName); VariableSet out = m_predicate.matches(params, m_context); --- 61,66 ---- params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); params.set(0, fredName); VariableSet out = m_predicate.matches(params, m_context); *************** *** 61,65 **** assertEquals(fredName.getVariants().iterator().next(), out.getRow(0).get(1)); } ! public void testGetTopicName() throws Exception { ArrayList params = new ArrayList(); --- 69,73 ---- assertEquals(fredName.getVariants().iterator().next(), out.getRow(0).get(1)); } ! public void testGetTopicName() throws Exception { ArrayList params = new ArrayList(); *************** *** 69,74 **** params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(1, fredVar); --- 77,82 ---- params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(1, fredVar); *************** *** 78,82 **** assertEquals(fredName, out.getRow(0).get(0)); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); --- 86,90 ---- assertEquals(fredName, out.getRow(0).get(0)); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 86,91 **** params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(0, fredName); --- 94,99 ---- params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(0, fredName); *************** *** 97,101 **** assertEquals(fredVar, out.getRow(0).get(1)); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); --- 105,109 ---- assertEquals(fredVar, out.getRow(0).get(1)); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 105,109 **** params.add(b); m_predicate.setParameters(params); ! VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); --- 113,117 ---- params.add(b); m_predicate.setParameters(params); ! VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); *************** *** 112,129 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:33:24 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/13 10:56:32 kal_ahmed - * Initial implementation of variant() predicate. - * - */ \ No newline at end of file --- 120,121 ---- Index: ValuePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ValuePredicateTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ValuePredicateTest.java 6 Mar 2005 19:37:40 -0000 1.2 --- ValuePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates.test; *************** *** 19,33 **** import org.tmapiutils.query.tolog.utils.VariableSet; - // TODO: - import org.tmapi.core.DataObject; - // TMAPI import org.tmapi.core.Topic; - import org.tmapi.core.TopicName; import org.tmapi.core.Occurrence; /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class ValuePredicateTest extends PredicateTestBase { --- 26,40 ---- import org.tmapiutils.query.tolog.utils.VariableSet; // TMAPI + import org.tmapi.core.TopicMap import org.tmapi.core.Topic; import org.tmapi.core.Occurrence; + import org.tmapi.core.TopicName; + import org.tmapi.core.Variant; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ValuePredicateTest extends PredicateTestBase { *************** *** 44,48 **** */ public String getTestMap() { ! return "[bond = \"James Bond\";\"bond, james\";\"James Bond\"\n" + " = \"007\" / hmg]" + "{bond, favourite-drink, [[\"Vodka martini. Shaken not stirred\"]]}"; } --- 51,68 ---- */ public String getTestMap() { ! return "[bond = \"James Bond\";\"bond, james\";\"James Bond\"\n" + ! " = \"007\" / hmg]" + ! "{bond, favourite-drink, [[\"Vodka martini. Shaken not stirred\"]]}"; ! } ! ! public void createTestMap(TopicMap tm) { ! Topic bond = tm.createTopic(); ! Topic fav_drink = tm.createTopic(); ! TopicName tn bond.createTopicName("James Bond", null); ! // ToDo: Create variants! ! bond.createOccurrence("Vodka martini. Shaken not stirred", fav_drink, null); ! ! registerObject("bond", bond); ! registerObject("favourite-drink", fav_drink); } *************** *** 75,79 **** } } ! public void testMatchOnObject() throws Exception { ArrayList params = new ArrayList(); --- 95,99 ---- } } ! public void testMatchOnObject() throws Exception { ArrayList params = new ArrayList(); *************** *** 83,87 **** params.add(b); m_predicate.setParameters(params); ! TopicName bn = (TopicName) ((Topic) m_tm.getObjectById("bond")).getTopicNames().iterator().next(); params.set(0, bn); VariableSet out = m_predicate.matches(params, m_context); --- 103,107 ---- params.add(b); m_predicate.setParameters(params); ! TopicName bn = (TopicName) ((Topic) getObjectById("bond")).getTopicNames().iterator().next(); params.set(0, bn); VariableSet out = m_predicate.matches(params, m_context); *************** *** 95,100 **** assertEquals(bn.getValue(), o); } ! ! Occurrence o = (Occurrence) ((Topic) m_tm.getObjectById("bond")).getOccurrences().iterator().next(); assertNotNull(o.getValue()); params.set(0, o); --- 115,120 ---- assertEquals(bn.getValue(), o); } ! ! Occurrence o = (Occurrence) ((Topic) getObjectById("bond")).getOccurrences().iterator().next(); assertNotNull(o.getValue()); params.set(0, o); *************** *** 105,109 **** assertEquals(o.getValue(), out.getRow(0).get(1)); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); --- 125,129 ---- assertEquals(o.getValue(), out.getRow(0).get(1)); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 113,117 **** params.add(b); m_predicate.setParameters(params); ! TopicName bn = (TopicName) ((Topic) m_tm.getObjectById("bond")).getTopicNames().iterator().next(); params.set(0, bn); params.set(1, bn.getValue()); --- 133,137 ---- params.add(b); m_predicate.setParameters(params); ! TopicName bn = (TopicName) ((Topic) getObjectById("bond")).getTopicNames().iterator().next(); params.set(0, bn); params.set(1, bn.getValue()); *************** *** 132,137 **** assertEquals(2, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! ! Occurrence o = (Occurrence) ((Topic) m_tm.getObjectById("bond")).getOccurrences().iterator().next(); assertNotNull(o.getValue()); params.set(0, o); --- 152,157 ---- assertEquals(2, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! ! Occurrence o = (Occurrence) ((Topic) getObjectById("bond")).getOccurrences().iterator().next(); assertNotNull(o.getValue()); params.set(0, o); *************** *** 147,153 **** assertNotNull(out); assertEquals(2, out.getColumns().size()); ! assertEquals(0, out.getRows().size()); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); --- 167,173 ---- assertNotNull(out); assertEquals(2, out.getColumns().size()); ! assertEquals(0, out.getRows().size()); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 168,193 **** if (o instanceof TopicName) { assertEquals(v, ((TopicName)o).getValue()); ! } else if (o instanceof DataObject) { ! assertEquals(v, ((DataObject)o).getValue()); } } ! } } - - /* - * $Log$ - * Revision 1.2 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/13 09:06:43 kal_ahmed - * Initial version of value() predicate. - * - */ \ No newline at end of file --- 188,197 ---- if (o instanceof TopicName) { assertEquals(v, ((TopicName)o).getValue()); ! } else if (o instanceof Variant) { ! assertEquals(v, ((Variant)o).getValue()); } } ! } } Index: TopicNameTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TopicNameTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TopicNameTest.java 7 Mar 2005 16:34:51 -0000 1.3 --- TopicNameTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,6 **** /* ! * Created on 14-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; *************** *** 17,23 **** /** ! * @author Kal ! * ! * Describe TopicNameTest here. */ public class TopicNameTest extends PredicateTestBase { --- 30,36 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TopicNameTest extends PredicateTestBase { *************** *** 49,53 **** Topic topic3 = tm.createTopic(); topic3.createTopicName("Topic3", null); ! // Should be the display name. // Todo: Test if this breaks something topic3.createTopicName("topic3", null); --- 62,66 ---- Topic topic3 = tm.createTopic(); topic3.createTopicName("Topic3", null); ! // Should be the display name. // Todo: Test if this breaks something topic3.createTopicName("topic3", null); *************** *** 71,75 **** Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn = (TopicName) topic1.getTopicNames().iterator().next(); ! ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 84,88 ---- Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn = (TopicName) topic1.getTopicNames().iterator().next(); ! ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 78,82 **** params.add(b); m_predicate.setParameters(params); ! params.set(1, bn); VariableSet out = m_predicate.matches(params, new TologContext()); --- 91,95 ---- params.add(b); m_predicate.setParameters(params); ! params.set(1, bn); VariableSet out = m_predicate.matches(params, new TologContext()); *************** *** 85,89 **** assertEquals(topic1, out.getRow(0).get(0)); } ! public void testMatchOnTopic() throws Exception { Topic topic3 = (Topic) getObjectById("topic3"); --- 98,102 ---- assertEquals(topic1, out.getRow(0).get(0)); } ! public void testMatchOnTopic() throws Exception { Topic topic3 = (Topic) getObjectById("topic3"); *************** *** 94,98 **** params.add(b); m_predicate.setParameters(params); ! params.set(0, topic3); VariableSet out = m_predicate.matches(params, new TologContext()); --- 107,111 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, topic3); VariableSet out = m_predicate.matches(params, new TologContext()); *************** *** 105,109 **** assertTrue(data.equals("Topic3") || data.equals("Topic Three")); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); --- 118,122 ---- assertTrue(data.equals("Topic3") || data.equals("Topic Three")); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 113,117 **** params.add(b); m_predicate.setParameters(params); ! VariableSet out = m_predicate.matches(params, new TologContext()); assertNotNull(out); --- 126,130 ---- params.add(b); m_predicate.setParameters(params); ! VariableSet out = m_predicate.matches(params, new TologContext()); assertNotNull(out); *************** *** 119,128 **** assertFalse(out.getColumn(a).contains(getObjectById("topic4"))); } ! public void testClosedMatch() throws Exception { Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn1 = (TopicName) topic1.getTopicNames().iterator().next(); Topic topic2 = (Topic) getObjectById("topic2"); ! ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 132,141 ---- assertFalse(out.getColumn(a).contains(getObjectById("topic4"))); } ! public void testClosedMatch() throws Exception { Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn1 = (TopicName) topic1.getTopicNames().iterator().next(); Topic topic2 = (Topic) getObjectById("topic2"); ! ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 131,135 **** params.add(b); m_predicate.setParameters(params); ! params.set(0, topic1); params.set(1, bn1); --- 144,148 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, topic1); params.set(1, bn1); *************** *** 137,141 **** assertNotNull(out); assertEquals(1, out.getRows().size()); ! params.set(0, topic2); out = m_predicate.matches(params, new TologContext()); --- 150,154 ---- assertNotNull(out); assertEquals(1, out.getRows().size()); ! params.set(0, topic2); out = m_predicate.matches(params, new TologContext()); *************** *** 144,145 **** --- 157,159 ---- } } + Index: TypePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TypePredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TypePredicateTest.java 7 Mar 2005 13:05:41 -0000 1.4 --- TypePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.5 *************** *** 1,10 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the L... [truncated message content] |
From: Lars H. <lh...@us...> - 2005-03-08 12:34:14
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/backends In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/test/backends Modified Files: BasicTests.java QueryTestBase.java Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: QueryTestBase.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/backends/QueryTestBase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QueryTestBase.java 6 Mar 2005 21:11:34 -0000 1.2 --- QueryTestBase.java 8 Mar 2005 12:33:59 -0000 1.3 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.test.backends; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.test.backends; *************** *** 26,43 **** /** ! * @author Kal ! * ! * Describe QueryTestBase here. */ ! public class QueryTestBase extends ConfigurableBackendTest { private HashMap m_maps; ! public QueryTestBase(String name) { super(name); m_maps = new HashMap(); } ! ! public TopicMap getTopicMap(String tmKey) throws Exception { TopicMap ret = (TopicMap) m_maps.get(tmKey); --- 34,51 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ ! public class QueryTestBase extends ConfigurableBackendTest { private HashMap m_maps; ! public QueryTestBase(String name) { super(name); m_maps = new HashMap(); } ! ! public TopicMap getTopicMap(String tmKey) throws Exception { TopicMap ret = (TopicMap) m_maps.get(tmKey); *************** *** 48,52 **** return ret; } ! protected void doQueryWithModule(TopicMap tm, File moduleFile, String modulePrefix, String queryString, String[][] expectedResults) throws Exception { QueryEvaluator qe = QueryEvaluatorFactory.newQueryEvaluator(tm); --- 56,60 ---- return ret; } ! protected void doQueryWithModule(TopicMap tm, File moduleFile, String modulePrefix, String queryString, String[][] expectedResults) throws Exception { QueryEvaluator qe = QueryEvaluatorFactory.newQueryEvaluator(tm); *************** *** 55,59 **** validateResultsSet(rs, expectedResults); } ! protected void doQuery(TopicMap tm, String queryString, String[][] expectedResults) throws Exception { QueryEvaluator qe = QueryEvaluatorFactory.newQueryEvaluator(tm); --- 63,67 ---- validateResultsSet(rs, expectedResults); } ! protected void doQuery(TopicMap tm, String queryString, String[][] expectedResults) throws Exception { QueryEvaluator qe = QueryEvaluatorFactory.newQueryEvaluator(tm); *************** *** 61,65 **** validateResultsSet(rs, expectedResults); } ! protected void doQuery(TopicMap tm, String [] rules, String queryString, String [][] expectedResults) throws Exception { QueryEvaluator qe = QueryEvaluatorFactory.newQueryEvaluator(tm); --- 69,73 ---- validateResultsSet(rs, expectedResults); } ! protected void doQuery(TopicMap tm, String [] rules, String queryString, String [][] expectedResults) throws Exception { QueryEvaluator qe = QueryEvaluatorFactory.newQueryEvaluator(tm); *************** *** 70,74 **** validateResultsSet(rs, expectedResults); } ! protected void validateResultsSet(TologResultsSet rs, String[][] expectedResults) throws Exception { assertEquals("Results set size is wrong.", expectedResults.length, rs.getNumRows()); --- 78,82 ---- validateResultsSet(rs, expectedResults); } ! protected void validateResultsSet(TologResultsSet rs, String[][] expectedResults) throws Exception { assertEquals("Results set size is wrong.", expectedResults.length, rs.getNumRows()); *************** *** 79,83 **** } } ! public String dumpResultsSet(TologResultsSet rs) { StringBuffer ret = new StringBuffer(); --- 87,91 ---- } } ! public String dumpResultsSet(TologResultsSet rs) { StringBuffer ret = new StringBuffer(); *************** *** 88,92 **** return ret.toString(); } ! /** * @param list --- 96,100 ---- return ret.toString(); } ! /** * @param list *************** *** 116,120 **** return false; } ! protected boolean validateRow(List row, String [] expected) throws Exception { if (row.size() != expected.length) return false; --- 124,128 ---- return false; } ! protected boolean validateRow(List row, String [] expected) throws Exception { if (row.size() != expected.length) return false; *************** *** 164,195 **** } - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:34 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:34:39 lheuer - * Initial tolog import - * - * Revision 1.8 2004/07/21 08:45:35 kal_ahmed - * Fixed bugs in reifies predicate. - * - * Revision 1.7 2004/07/19 14:52:41 kal_ahmed - * More fixes to processing of recursive rules. ClauseList now aborts when the input parameter list becomes empty. - * - * Revision 1.6 2004/07/16 13:51:52 kal_ahmed - * Fixes for tolog engine handling of rules and rule-recursion. - * - * Revision 1.5 2004/06/21 18:42:28 kal_ahmed - * Improved exception propagation. - * - * Revision 1.4 2004/06/20 14:12:31 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.3 2004/06/15 20:00:35 kal_ahmed - * Added a few more tests over the block-world topic map. - * - * Revision 1.2 2004/06/15 19:44:48 kal_ahmed - * Resynced expected results with actual topic map. - * - */ \ No newline at end of file --- 172,173 ---- Index: BasicTests.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/backends/BasicTests.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicTests.java 6 Mar 2005 17:34:39 -0000 1.1 --- BasicTests.java 8 Mar 2005 12:33:59 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.test.backends; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.test.backends; *************** *** 16,24 **** /** ! * @author Kal ! * ! * Describe BasicTests here. */ ! public class BasicTests extends QueryTestBase { --- 24,32 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ ! public class BasicTests extends QueryTestBase { *************** *** 30,34 **** } ! public void testOneDynamicAssociation() throws Exception { TopicMap tm = getTopicMap("tolog.blocks"); --- 38,42 ---- } ! public void testOneDynamicAssociation() throws Exception { TopicMap tm = getTopicMap("tolog.blocks"); *************** *** 39,43 **** }); } ! public void testOpenDynamicAssociation() throws Exception { --- 47,51 ---- }); } ! public void testOpenDynamicAssociation() throws Exception { *************** *** 50,54 **** new String [] { "yellowblock", "redblock"}}); } ! public void testTwoDynamicAssociationsAND() throws Exception { --- 58,62 ---- new String [] { "yellowblock", "redblock"}}); } ! public void testTwoDynamicAssociationsAND() throws Exception { *************** *** 60,64 **** }); } ! public void testTwoDynamicAssociationsOR() throws Exception { --- 68,72 ---- }); } ! public void testTwoDynamicAssociationsOR() throws Exception { *************** *** 71,75 **** }); } ! public void testInstanceOf() throws Exception { --- 79,83 ---- }); } ! public void testInstanceOf() throws Exception { *************** *** 89,93 **** new String [] {"blueblock"}}); } ! public void testNamesToValues() throws Exception { doQuery( --- 97,101 ---- new String [] {"blueblock"}}); } ! public void testNamesToValues() throws Exception { doQuery( *************** *** 100,104 **** new String [] {"yellowblock", "Yellow Block"}}); } ! public void testNamesAndOcurrencesToValues() throws Exception { doQuery( --- 108,112 ---- new String [] {"yellowblock", "Yellow Block"}}); } ! public void testNamesAndOcurrencesToValues() throws Exception { doQuery( *************** *** 110,116 **** new String [] {"redblock", "Red Block", "10"}, new String [] {"yellowblock", "Yellow Block", "15"}}); ! } ! public void testDynamicAssociationWithVariableType() throws Exception { doQuery( --- 118,124 ---- new String [] {"redblock", "Red Block", "10"}, new String [] {"yellowblock", "Yellow Block", "15"}}); ! } ! public void testDynamicAssociationWithVariableType() throws Exception { doQuery( *************** *** 124,128 **** }); } ! private static final String [] auto_rules = new String [] { "matches-facet($FACET, $FV, $INST) :- " + --- 132,136 ---- }); } ! private static final String [] auto_rules = new String [] { "matches-facet($FACET, $FV, $INST) :- " + *************** *** 135,139 **** " matches-facet($FACET, $X, $INST)" + "}.", ! "subfacet-of($SUBFV, $SUPERFV, $FACET) :- " + " facet-has-hierarchy-type($FACET : facet, $ASSOC : facet-hierarchy-type)," + --- 143,147 ---- " matches-facet($FACET, $X, $INST)" + "}.", ! "subfacet-of($SUBFV, $SUPERFV, $FACET) :- " + " facet-has-hierarchy-type($FACET : facet, $ASSOC : facet-hierarchy-type)," + *************** *** 145,154 **** " subfacet-of($X, $SUPERFV, $FACET)" + " }.", ! "direct-subfacet-of($SUBFV, $SUPERFV, $FACET) :- " + " facet-has-hierarchy-type($FACET:facet, $ASSOC:facet-hierarchy-type)," + " direct-instance-of($SUPER, superordinate-role)," + " direct-instance-of($SUB, subordinate-role)," + ! " $ASSOC($SUBFV:$SUB, $SUPERFV:$SUPER).", }; --- 153,162 ---- " subfacet-of($X, $SUPERFV, $FACET)" + " }.", ! "direct-subfacet-of($SUBFV, $SUPERFV, $FACET) :- " + " facet-has-hierarchy-type($FACET:facet, $ASSOC:facet-hierarchy-type)," + " direct-instance-of($SUPER, superordinate-role)," + " direct-instance-of($SUB, subordinate-role)," + ! " $ASSOC($SUBFV:$SUB, $SUPERFV:$SUPER).", }; *************** *** 198,202 **** rs = qe.execute("select $AUTO from matches-facet(body-type, all-body-types, $AUTO), matches-facet(engine-type, all-engine-types, $AUTO), matches-facet(engine-size, all-engine-sizes, $AUTO) ?"); assertEquals(7, rs.getNumRows()); ! this.validateResultsSet(rs, new String[][] { new String [] {"clio1_2"}, --- 206,210 ---- rs = qe.execute("select $AUTO from matches-facet(body-type, all-body-types, $AUTO), matches-facet(engine-type, all-engine-types, $AUTO), matches-facet(engine-size, all-engine-sizes, $AUTO) ?"); assertEquals(7, rs.getNumRows()); ! this.validateResultsSet(rs, new String[][] { new String [] {"clio1_2"}, *************** *** 215,219 **** "direct-subfacet-of($SUBFV, $SUPERFV, $FACET) :- " + "facet-has-hierarchy-type($FACET:facet, $ASSOC:facet-hierarchy-type)," + ! "$ASSOC($SUBFV:$SUB, $SUPERFV:$SUPER)," + "direct-instance-of($SUPER, superordinate-role)," + "direct-instance-of($SUB, subordinate-role)."); --- 223,227 ---- "direct-subfacet-of($SUBFV, $SUPERFV, $FACET) :- " + "facet-has-hierarchy-type($FACET:facet, $ASSOC:facet-hierarchy-type)," + ! "$ASSOC($SUBFV:$SUB, $SUPERFV:$SUPER)," + "direct-instance-of($SUPER, superordinate-role)," + "direct-instance-of($SUB, subordinate-role)."); *************** *** 231,235 **** assertEquals(0, rs.getNumRows()); } ! public void testReifiesPredicate() throws Exception { TopicMap tm = getTopicMap("tolog.reification"); --- 239,243 ---- assertEquals(0, rs.getNumRows()); } ! public void testReifiesPredicate() throws Exception { TopicMap tm = getTopicMap("tolog.reification"); *************** *** 256,281 **** } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:34:39 lheuer - * Initial tolog import - * - * Revision 1.8 2004/07/21 08:45:35 kal_ahmed - * Fixed bugs in reifies predicate. - * - * Revision 1.7 2004/07/19 16:02:43 kal_ahmed - * Fixed tests to properly initialize input variable set. - * - * Revision 1.6 2004/07/19 14:52:40 kal_ahmed - * More fixes to processing of recursive rules. ClauseList now aborts when the input parameter list becomes empty. - * - * Revision 1.5 2004/07/16 13:51:37 kal_ahmed - * Fixes for tolog engine handling of rules and rule-recursion. - * - * Revision 1.4 2004/07/14 21:42:25 kal_ahmed - * Parser now supports a variable for the association type in a dynamic association predicate. - * - * Revision 1.3 2004/06/15 20:00:35 kal_ahmed - * Added a few more tests over the block-world topic map. - * - */ \ No newline at end of file --- 264,265 ---- |
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/test Modified Files: AndClauseTest.java AssociationPredicateTest.java BackendTests.java ImportTest.java Increment.java MemoryQueryEvaluatorImplTest.java NotClauseTest.java OrClauseTest.java ProjectionTest.java RuleTest.java SortingTest.java TologParserTest.java TologParserTestBase.java VariableSetTest.java Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: AssociationPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/AssociationPredicateTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AssociationPredicateTest.java 6 Mar 2005 21:11:33 -0000 1.2 --- AssociationPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.test; *************** *** 33,38 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class AssociationPredicateTest extends TestCase { --- 40,46 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class AssociationPredicateTest extends TestCase { *************** *** 76,80 **** } ! public void testMultipleMatch() throws Exception { --- 84,88 ---- } ! public void testMultipleMatch() throws Exception { *************** *** 106,110 **** } } ! public void testRoleMatch() throws Exception { ClauseList c = new ClauseList(); --- 114,118 ---- } } ! public void testRoleMatch() throws Exception { ClauseList c = new ClauseList(); *************** *** 137,141 **** } } ! /* (non-Javadoc) * @see junit.framework.TestCase#setUp() --- 145,149 ---- } } ! /* (non-Javadoc) * @see junit.framework.TestCase#setUp() *************** *** 153,182 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:33 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:34:06 lheuer - * Initial tolog import - * - * Revision 1.6 2004/07/19 16:02:42 kal_ahmed - * Fixed tests to properly initialize input variable set. - * - * Revision 1.5 2004/06/14 20:10:33 kal_ahmed - * Updated test code to work with new Predicate and Clause interfaces. - * - * Revision 1.4 2004/06/09 20:20:31 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:17 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 161,162 ---- Index: ImportTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/ImportTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportTest.java 6 Mar 2005 17:34:06 -0000 1.1 --- ImportTest.java 8 Mar 2005 12:33:58 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.test; *************** *** 19,30 **** /** ! * @author Kal ! * ! * Describe ImportTest here. */ ! public class ImportTest extends TologParserTestBase { File m_modulesDir; ! /** * @param arg0 --- 27,38 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ ! public class ImportTest extends TologParserTestBase { File m_modulesDir; ! /** * @param arg0 *************** *** 40,44 **** assertTrue("Cannot locate module to be referenced at " + refModule.getAbsolutePath(), refModule.exists()); ! String rootModule = "import \"" + refModule.toURL().toString() + "\" as test"; TologParser p = new TologParser(new TologLexer(new StringReader(rootModule))); --- 48,52 ---- assertTrue("Cannot locate module to be referenced at " + refModule.getAbsolutePath(), refModule.exists()); ! String rootModule = "import \"" + refModule.toURL().toString() + "\" as test"; TologParser p = new TologParser(new TologLexer(new StringReader(rootModule))); *************** *** 51,60 **** assertNotNull(r); } ! public void testNestedImport() throws Exception { File refModule = new File(m_modulesDir, "nested-module-parent.tl"); assertTrue("Cannot locate module to be referenced at " + refModule.getAbsolutePath(), refModule.exists()); ! String rootModule = "import \"" + refModule.toURL().toString() + "\" as test"; TologParser p = new TologParser(new TologLexer(new StringReader(rootModule))); --- 59,68 ---- assertNotNull(r); } ! public void testNestedImport() throws Exception { File refModule = new File(m_modulesDir, "nested-module-parent.tl"); assertTrue("Cannot locate module to be referenced at " + refModule.getAbsolutePath(), refModule.exists()); ! String rootModule = "import \"" + refModule.toURL().toString() + "\" as test"; TologParser p = new TologParser(new TologLexer(new StringReader(rootModule))); *************** *** 65,82 **** assertEquals(1, rules.size()); TologRule r = (TologRule)rules.get("test:crosscontinent"); ! assertNotNull(r); } ! } ! /* ! * $Log$ ! * Revision 1.1 2005/03/06 17:34:06 lheuer ! * Initial tolog import ! * ! * Revision 1.4 2004/06/13 17:18:00 kal_ahmed ! * Added registration of builtin predicates. Fixed rule expansion code to handle player/role pairs correctly. ! * ! * Revision 1.3 2004/06/09 21:12:19 kal_ahmed ! * Added standard source file header and footer. ! * ! */ \ No newline at end of file --- 73,79 ---- assertEquals(1, rules.size()); TologRule r = (TologRule)rules.get("test:crosscontinent"); ! assertNotNull(r); } ! } ! Index: RuleTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/RuleTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleTest.java 6 Mar 2005 17:34:06 -0000 1.1 --- RuleTest.java 8 Mar 2005 12:33:58 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.test; *************** *** 25,31 **** /** ! * @author Kal ! * ! * Describe RuleTest here. */ public class RuleTest extends TestCase { --- 33,39 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class RuleTest extends TestCase { *************** *** 43,48 **** junit.textui.TestRunner.run(RuleTest.class); } ! ! public void testRule() throws Exception { TologRule r = new TologRuleImpl(); --- 51,56 ---- junit.textui.TestRunner.run(RuleTest.class); } ! ! public void testRule() throws Exception { TologRule r = new TologRuleImpl(); *************** *** 63,72 **** i2Params.add(new Variable("B")); i2.setParameters(i2Params); ! ruleBody.addPredicate(i1); ruleBody.addPredicate(i2); ! r.setRuleBody(ruleBody); ! ClauseList cl = new ClauseList(); Predicate p = r.newInstance(); --- 71,80 ---- i2Params.add(new Variable("B")); i2.setParameters(i2Params); ! ruleBody.addPredicate(i1); ruleBody.addPredicate(i2); ! r.setRuleBody(ruleBody); ! ClauseList cl = new ClauseList(); Predicate p = r.newInstance(); *************** *** 76,80 **** p.setParameters(pParams); cl.addPredicate(p); ! VariableSet vsIn = new VariableSet(); vsIn.addColumn(new Variable("X")); --- 84,88 ---- p.setParameters(pParams); cl.addPredicate(p); ! VariableSet vsIn = new VariableSet(); vsIn.addColumn(new Variable("X")); *************** *** 90,109 **** } ! /* ! * $Log$ ! * Revision 1.1 2005/03/06 17:34:06 lheuer ! * Initial tolog import ! * ! * Revision 1.8 2004/07/19 16:02:42 kal_ahmed ! * Fixed tests to properly initialize input variable set. ! * ! * Revision 1.7 2004/06/16 21:21:44 kal_ahmed ! * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. ! * ! * Revision 1.6 2004/06/14 20:10:33 kal_ahmed ! * Updated test code to work with new Predicate and Clause interfaces. ! * ! * Revision 1.5 2004/06/09 21:12:19 kal_ahmed ! * Added standard source file header and footer. ! * ! */ \ No newline at end of file --- 98,100 ---- } ! Index: SortingTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/SortingTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SortingTest.java 6 Mar 2005 21:11:34 -0000 1.2 --- SortingTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.test; *************** *** 27,32 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class SortingTest extends TestCase { --- 34,40 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class SortingTest extends TestCase { *************** *** 34,38 **** private TopicMapProvider m_provider; private IDGenerator m_idgen; ! /** * Constructor for SortingTest. --- 42,46 ---- private TopicMapProvider m_provider; private IDGenerator m_idgen; ! /** * Constructor for SortingTest. *************** *** 54,58 **** cols.add(new Variable("A")); cols.add(new Variable("B")); ! ArrayList rows = new ArrayList(); --- 62,66 ---- cols.add(new Variable("A")); cols.add(new Variable("B")); ! ArrayList rows = new ArrayList(); *************** *** 71,85 **** row3.add(new Integer(1)); rows.add(row3); ! Sorting sorting = new Sorting(); sorting.addSort(new Variable("A")); sorting.addSort(new Variable("B")); sorting.sort(cols, rows); ! assertEquals(row3, rows.get(0)); assertEquals(row2, rows.get(1)); assertEquals(row1, rows.get(2)); } ! public void testSortTopics() throws Exception { TopicMap tm = newTopicMap(); --- 79,93 ---- row3.add(new Integer(1)); rows.add(row3); ! Sorting sorting = new Sorting(); sorting.addSort(new Variable("A")); sorting.addSort(new Variable("B")); sorting.sort(cols, rows); ! assertEquals(row3, rows.get(0)); assertEquals(row2, rows.get(1)); assertEquals(row1, rows.get(2)); } ! public void testSortTopics() throws Exception { TopicMap tm = newTopicMap(); *************** *** 87,116 **** Topic t2 = tm.createTopic("t2"); Topic t3 = tm.createTopic("t3"); ! ArrayList cols = new ArrayList(); cols.add(new Variable("A")); ArrayList rows = new ArrayList(); ! ArrayList row1 = new ArrayList(); row1.add(t3); rows.add(row1); ! ArrayList row2 = new ArrayList(); row2.add(t1); rows.add(row2); ! ! ArrayList row3 = new ArrayList(); row3.add(t2); rows.add(row3); ! Sorting sorting = new Sorting(); sorting.addSort(new Variable("A")); sorting.sort(cols, rows); sorting.setSortAscending(true); ! assertEquals(row2, rows.get(0)); assertEquals(row3, rows.get(1)); assertEquals(row1, rows.get(2)); ! sorting.setSortAscending(false); sorting.sort(cols, rows); --- 95,124 ---- Topic t2 = tm.createTopic("t2"); Topic t3 = tm.createTopic("t3"); ! ArrayList cols = new ArrayList(); cols.add(new Variable("A")); ArrayList rows = new ArrayList(); ! ArrayList row1 = new ArrayList(); row1.add(t3); rows.add(row1); ! ArrayList row2 = new ArrayList(); row2.add(t1); rows.add(row2); ! ! ArrayList row3 = new ArrayList(); row3.add(t2); rows.add(row3); ! Sorting sorting = new Sorting(); sorting.addSort(new Variable("A")); sorting.sort(cols, rows); sorting.setSortAscending(true); ! assertEquals(row2, rows.get(0)); assertEquals(row3, rows.get(1)); assertEquals(row1, rows.get(2)); ! sorting.setSortAscending(false); sorting.sort(cols, rows); *************** *** 120,124 **** } ! public void testSortNames() throws Exception { TopicMap tm = newTopicMap(); --- 128,132 ---- } ! public void testSortNames() throws Exception { TopicMap tm = newTopicMap(); *************** *** 129,160 **** Topic t3 = tm.createTopic("t3"); TopicName bn3 = t3.createName("bn3", "Topic A"); ! ArrayList cols = new ArrayList(); cols.add(new Variable("A")); ArrayList rows = new ArrayList(); ! ArrayList row1 = new ArrayList(); row1.add(bn3); rows.add(row1); ! ArrayList row2 = new ArrayList(); row2.add(bn1); rows.add(row2); ! ! ArrayList row3 = new ArrayList(); row3.add(bn2); rows.add(row3); ! Sorting sorting = new Sorting(); sorting.addSort(new Variable("A")); sorting.sort(cols, rows); ! assertEquals(row1, rows.get(0)); assertEquals(row3, rows.get(1)); assertEquals(row2, rows.get(2)); ! ! } ! private TopicMap newTopicMap() throws Exception { Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.tm4j.org/tests/" + m_idgen.getObjectId()); --- 137,168 ---- Topic t3 = tm.createTopic("t3"); TopicName bn3 = t3.createName("bn3", "Topic A"); ! ArrayList cols = new ArrayList(); cols.add(new Variable("A")); ArrayList rows = new ArrayList(); ! ArrayList row1 = new ArrayList(); row1.add(bn3); rows.add(row1); ! ArrayList row2 = new ArrayList(); row2.add(bn1); rows.add(row2); ! ! ArrayList row3 = new ArrayList(); row3.add(bn2); rows.add(row3); ! Sorting sorting = new Sorting(); sorting.addSort(new Variable("A")); sorting.sort(cols, rows); ! assertEquals(row1, rows.get(0)); assertEquals(row3, rows.get(1)); assertEquals(row2, rows.get(2)); ! ! } ! private TopicMap newTopicMap() throws Exception { Locator loc = m_provider.getLocatorFactory().createLocator("URI", "http://www.tm4j.org/tests/" + m_idgen.getObjectId()); *************** *** 163,180 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:34 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:34:06 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 171,172 ---- Index: ProjectionTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/ProjectionTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProjectionTest.java 6 Mar 2005 21:11:34 -0000 1.2 --- ProjectionTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.test; *************** *** 116,148 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:34 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:34:06 lheuer - * Initial tolog import - * - * Revision 1.7 2004/07/19 16:02:42 kal_ahmed - * Fixed tests to properly initialize input variable set. - * - * Revision 1.6 2004/06/14 20:10:33 kal_ahmed - * Updated test code to work with new Predicate and Clause interfaces. - * - * Revision 1.5 2004/06/09 20:20:31 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.4 2004/06/07 20:32:11 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:17 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 123,124 ---- Index: OrClauseTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/OrClauseTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OrClauseTest.java 6 Mar 2005 17:34:06 -0000 1.1 --- OrClauseTest.java 8 Mar 2005 12:33:58 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.test; *************** *** 24,29 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class OrClauseTest extends TestCase { --- 31,37 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class OrClauseTest extends TestCase { *************** *** 49,53 **** p1.setParameters(params1); ac1.addPredicate(p1); ! ClauseList ac2 = new ClauseList(); Predicate p2 = new Increment(); --- 57,61 ---- p1.setParameters(params1); ac1.addPredicate(p1); ! ClauseList ac2 = new ClauseList(); Predicate p2 = new Increment(); *************** *** 57,70 **** p2.setParameters(params2); ac2.addPredicate(p2); ! OrClause oc = new OrClause(); oc.add(ac1); oc.add(ac2); ! VariableSet in = new VariableSet(); in.addColumn(new Variable("A")); in.addRow(in.getColumns()); VariableSet ret = oc.execute(in, new TologContext()); ! assertEquals(2, ret.size()); List row = ret.getRow(0); --- 65,78 ---- p2.setParameters(params2); ac2.addPredicate(p2); ! OrClause oc = new OrClause(); oc.add(ac1); oc.add(ac2); ! VariableSet in = new VariableSet(); in.addColumn(new Variable("A")); in.addRow(in.getColumns()); VariableSet ret = oc.execute(in, new TologContext()); ! assertEquals(2, ret.size()); List row = ret.getRow(0); *************** *** 72,76 **** assertEquals(1, row.size()); assertEquals(new Integer(2), (Integer)row.get(0)); ! row = ret.getRow(1); assertNotNull(row); --- 80,84 ---- assertEquals(1, row.size()); assertEquals(new Integer(2), (Integer)row.get(0)); ! row = ret.getRow(1); assertNotNull(row); *************** *** 80,106 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:34:06 lheuer - * Initial tolog import - * - * Revision 1.6 2004/07/19 16:02:42 kal_ahmed - * Fixed tests to properly initialize input variable set. - * - * Revision 1.5 2004/06/14 20:10:33 kal_ahmed - * Updated test code to work with new Predicate and Clause interfaces. - * - * Revision 1.4 2004/06/09 20:20:31 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:17 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 88,89 ---- Index: NotClauseTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/NotClauseTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NotClauseTest.java 6 Mar 2005 17:34:06 -0000 1.1 --- NotClauseTest.java 8 Mar 2005 12:33:58 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.test; *************** *** 24,29 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class NotClauseTest extends TestCase { --- 31,37 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class NotClauseTest extends TestCase { *************** *** 50,57 **** p1.setParameters(params1); ac1.addPredicate(p1); ! NotClause nc = new NotClause(); nc.setTest(ac1); ! VariableSet in = new VariableSet(); in.addColumn(new Variable("A")); --- 58,65 ---- p1.setParameters(params1); ac1.addPredicate(p1); ! NotClause nc = new NotClause(); nc.setTest(ac1); ! VariableSet in = new VariableSet(); in.addColumn(new Variable("A")); *************** *** 59,63 **** in.addRow(new Object[] { new Integer(1), new Integer(2)}); in.addRow(new Object[] { new Integer(1), new Integer(3)}); ! VariableSet ret = nc.execute(in, new TologContext()); --- 67,71 ---- in.addRow(new Object[] { new Integer(1), new Integer(2)}); in.addRow(new Object[] { new Integer(1), new Integer(3)}); ! VariableSet ret = nc.execute(in, new TologContext()); *************** *** 69,92 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:34:06 lheuer - * Initial tolog import - * - * Revision 1.5 2004/06/14 20:10:33 kal_ahmed - * Updated test code to work with new Predicate and Clause interfaces. - * - * Revision 1.4 2004/06/09 20:20:31 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:17 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 77,78 ---- Index: Increment.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/Increment.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Increment.java 6 Mar 2005 17:34:06 -0000 1.1 --- Increment.java 8 Mar 2005 12:33:58 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.test; *************** *** 22,27 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class Increment extends PredicateBase { --- 29,35 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class Increment extends PredicateBase { *************** *** 31,35 **** new ParameterInfo(true, Integer.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Predicate#matches(java.util.Map) --- 39,43 ---- new ParameterInfo(true, Integer.class) }; ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Predicate#matches(java.util.Map) *************** *** 59,63 **** return ret; } ! private VariableSet createVariableSet() { VariableSet ret = new VariableSet(); --- 67,71 ---- return ret; } ! private VariableSet createVariableSet() { VariableSet ret = new VariableSet(); *************** *** 92,121 **** // No-op for this predicate } - - } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:34:06 lheuer - * Initial tolog import - * - * Revision 1.6 2004/06/09 22:15:09 kal_ahmed - * Fixed parser to disallow player:role pairs in predicates other than dynamic association predicates. Fixed initialisation of extension predicates. Added DirectInstanceOfPredicate extension to in-memory query evaluator. - * - * Revision 1.5 2004/06/09 20:20:31 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.4 2004/06/07 20:31:59 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:17 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 100,104 ---- // No-op for this predicate } + } Index: VariableSetTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/VariableSetTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VariableSetTest.java 6 Mar 2005 17:34:06 -0000 1.1 --- VariableSetTest.java 8 Mar 2005 12:33:58 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.test; *************** *** 19,24 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class VariableSetTest extends TestCase { --- 26,32 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class VariableSetTest extends TestCase { *************** *** 41,45 **** base.addColumn(new Variable("B")); base.addColumn(new Variable("C")); ! VariableSet results = new VariableSet(); results.addColumn(new Variable("A")); --- 49,53 ---- base.addColumn(new Variable("B")); base.addColumn(new Variable("C")); ! VariableSet results = new VariableSet(); results.addColumn(new Variable("A")); *************** *** 47,53 **** results.addRow(new Object[] { "A1", "B1" }); results.addRow(new Object[] { "A2", "B2" }); ! base.addMatchResults(base.getColumns(), results); ! assertEquals(2, base.getRows().size()); List row1 = base.getRow(0); --- 55,61 ---- results.addRow(new Object[] { "A1", "B1" }); results.addRow(new Object[] { "A2", "B2" }); ! base.addMatchResults(base.getColumns(), results); ! assertEquals(2, base.getRows().size()); List row1 = base.getRow(0); *************** *** 65,71 **** vs.addColumn(b); vs.addColumn(c); ! vs.addRow(new Object[] {"A1", "B1", "C1"}); ! List l = vs.project(new Variable[] {a, b}, null); assertEquals(1, l.size()); --- 73,79 ---- vs.addColumn(b); vs.addColumn(c); ! vs.addRow(new Object[] {"A1", "B1", "C1"}); ! List l = vs.project(new Variable[] {a, b}, null); assertEquals(1, l.size()); *************** *** 74,78 **** assertEquals("A1", row.get(0)); assertEquals("B1", row.get(1)); ! l = vs.project(new Variable[] {a}, c); assertEquals(1, l.size()); --- 82,86 ---- assertEquals("A1", row.get(0)); assertEquals("B1", row.get(1)); ! l = vs.project(new Variable[] {a}, c); assertEquals(1, l.size()); *************** *** 81,85 **** assertEquals("A1", row.get(0)); assertEquals(new Integer(1), row.get(1)); ! vs.addRow(new Object[] { "A1", "B2", "C1" }); --- 89,93 ---- assertEquals("A1", row.get(0)); assertEquals(new Integer(1), row.get(1)); ! vs.addRow(new Object[] { "A1", "B2", "C1" }); *************** *** 90,94 **** assertEquals("A1", row.get(0)); assertEquals(new Integer(2), row.get(1)); ! } --- 98,102 ---- assertEquals("A1", row.get(0)); assertEquals(new Integer(2), row.get(1)); ! } *************** *** 98,107 **** vs1.addColumn(new Variable("B")); vs1.addRow(new Object[] {"A1", "B1"}); ! VariableSet vs2 = new VariableSet(); vs2.addColumn(new Variable("B")); vs2.addColumn(new Variable("C")); vs2.addRow(new Object[] {"B2", "C2"}); ! vs1.add(vs2); assertEquals(3, vs1.getColumns().size()); --- 106,115 ---- vs1.addColumn(new Variable("B")); vs1.addRow(new Object[] {"A1", "B1"}); ! VariableSet vs2 = new VariableSet(); vs2.addColumn(new Variable("B")); vs2.addColumn(new Variable("C")); vs2.addRow(new Object[] {"B2", "C2"}); ! vs1.add(vs2); assertEquals(3, vs1.getColumns().size()); *************** *** 120,137 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:34:06 lheuer - * Initial tolog import - * - * Revision 1.3 2004/06/09 20:20:31 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.2 2004/06/03 19:55:17 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/05/30 22:08:26 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 128,129 ---- Index: MemoryQueryEvaluatorImplTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/MemoryQueryEvaluatorImplTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MemoryQueryEvaluatorImplTest.java 6 Mar 2005 21:11:34 -0000 1.2 --- MemoryQueryEvaluatorImplTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.test; *************** *** 32,38 **** /** ! * @author Kal ! * ! * Describe MemoryQueryEvaluatorImplTest here. */ public class MemoryQueryEvaluatorImplTest extends TestCase { --- 40,46 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class MemoryQueryEvaluatorImplTest extends TestCase { *************** *** 41,49 **** private TopicMapProvider m_provider; private TestQuery[] TEST_QUERIES = new TestQuery[] { ! new TestQuery("blocks1", "blocks.ltm", "select * from restson($A:upper, $B:lower)?", 2, 3, new Object[][] { ! new Object[] {new TopicRef("redblock"), new TopicRef("blueblock") } }), new TestQuery("blocks2", "blocks.ltm", --- 49,57 ---- private TopicMapProvider m_provider; private TestQuery[] TEST_QUERIES = new TestQuery[] { ! new TestQuery("blocks1", "blocks.ltm", "select * from restson($A:upper, $B:lower)?", 2, 3, new Object[][] { ! new Object[] {new TopicRef("redblock"), new TopicRef("blueblock") } }), new TestQuery("blocks2", "blocks.ltm", *************** *** 58,62 **** new TestQuery("blocks3", "blocks.ltm", "select $BLOCK, $OTHER, $SHAPE from restson($OTHER:lower, $BLOCK:upper), has-shape($OTHER:block, $SHAPE:shape)?", ! 3, 3, new Object [][] { new Object[] { new TopicRef("redblock"), new TopicRef("blueblock"), new TopicRef("cylinder") }, --- 66,70 ---- new TestQuery("blocks3", "blocks.ltm", "select $BLOCK, $OTHER, $SHAPE from restson($OTHER:lower, $BLOCK:upper), has-shape($OTHER:block, $SHAPE:shape)?", ! 3, 3, new Object [][] { new Object[] { new TopicRef("redblock"), new TopicRef("blueblock"), new TopicRef("cylinder") }, *************** *** 65,69 **** }), }; ! /** * Constructor for MemoryQueryEvaluatorImplTest. --- 73,77 ---- }), }; ! /** * Constructor for MemoryQueryEvaluatorImplTest. *************** *** 79,83 **** } } ! /** * Locates the directory containing tologx package test --- 87,91 ---- } } ! /** * Locates the directory containing tologx package test *************** *** 86,90 **** * by the System property 'testdir' * @return the File that represents the tologx test resource directory. ! * @throws RuntimeException if the System property 'testdir' is not specified, * or if the test directory or the tologx subdirectory could not be found. */ --- 94,98 ---- * by the System property 'testdir' * @return the File that represents the tologx test resource directory. ! * @throws RuntimeException if the System property 'testdir' is not specified, * or if the test directory or the tologx subdirectory could not be found. */ *************** *** 92,96 **** String testdirName = System.getProperty("testdir"); if (testdirName == null) { ! throw new RuntimeException("No value for system property 'testdir'"); } File f = new File(testdirName); --- 100,104 ---- String testdirName = System.getProperty("testdir"); if (testdirName == null) { ! throw new RuntimeException("No value for system property 'testdir'"); } File f = new File(testdirName); *************** *** 109,118 **** return tmpf.newTopicMapProvider(System.getProperties()); } ! public static void main(String[] args) { junit.textui.TestRunner.run(MemoryQueryEvaluatorImplTest.class); } ! public TopicMap getTopicMap(File tmFile, boolean forceReload) throws Exception { Locator tmLoc = m_provider.getLocatorFactory().createLocator("URI", tmFile.toURL().toString()); --- 117,126 ---- return tmpf.newTopicMapProvider(System.getProperties()); } ! public static void main(String[] args) { junit.textui.TestRunner.run(MemoryQueryEvaluatorImplTest.class); } ! public TopicMap getTopicMap(File tmFile, boolean forceReload) throws Exception { Locator tmLoc = m_provider.getLocatorFactory().createLocator("URI", tmFile.toURL().toString()); *************** *** 128,132 **** return m_provider.addTopicMap(src); } ! /* * @see TestCase#setUp() --- 136,140 ---- return m_provider.addTopicMap(src); } ! /* * @see TestCase#setUp() *************** *** 152,156 **** checkResultsSet("simpleQuery", results, 2, 3, expectedResults); } ! public void testQueries() throws Exception { for (int i = 0; i < TEST_QUERIES.length; i++) { --- 160,164 ---- checkResultsSet("simpleQuery", results, 2, 3, expectedResults); } ! public void testQueries() throws Exception { for (int i = 0; i < TEST_QUERIES.length; i++) { *************** *** 177,181 **** checkResultsSet(TEST_QUERIES[i].name, rs, TEST_QUERIES[i].resultsCols, TEST_QUERIES[i].resultsRows, ! TEST_QUERIES[i].expectedRows); } catch (TologProcessingException ex) { if (TEST_QUERIES[i].processingErrorExpected) return; --- 185,189 ---- checkResultsSet(TEST_QUERIES[i].name, rs, TEST_QUERIES[i].resultsCols, TEST_QUERIES[i].resultsRows, ! TEST_QUERIES[i].expectedRows); } catch (TologProcessingException ex) { if (TEST_QUERIES[i].processingErrorExpected) return; *************** *** 183,187 **** } } ! public void testInlineModule() throws Exception { TopicMap tm = getTopicMap(new File(m_tologTestDir, "blocks.ltm"), false); --- 191,195 ---- } } ! public void testInlineModule() throws Exception { TopicMap tm = getTopicMap(new File(m_tologTestDir, "blocks.ltm"), false); *************** *** 200,204 **** (row.get(0).equals(greenblock) && row.get(1).equals(blueblock))); } ! public void testExternalModule() throws Exception { TopicMap tm = getTopicMap(new File(m_tologTestDir, "blocks.ltm"), false); --- 208,212 ---- (row.get(0).equals(greenblock) && row.get(1).equals(blueblock))); } ! public void testExternalModule() throws Exception { TopicMap tm = getTopicMap(new File(m_tologTestDir, "blocks.ltm"), false); *************** *** 216,220 **** (row.get(0).equals(greenblock) && row.get(1).equals(blueblock))); } ! public void testRecursiveRules() throws Exception { TopicMap tm = getTopicMap(new File(m_tologTestDir, "family.ltm"), false); --- 224,228 ---- (row.get(0).equals(greenblock) && row.get(1).equals(blueblock))); } ! public void testRecursiveRules() throws Exception { TopicMap tm = getTopicMap(new File(m_tologTestDir, "family.ltm"), false); *************** *** 242,246 **** } } ! public void testReplacement() throws Exception { TopicMap tm = getTopicMap(new File(m_tologTestDir, "blocks.ltm"), false); --- 250,254 ---- } } ! public void testReplacement() throws Exception { TopicMap tm = getTopicMap(new File(m_tologTestDir, "blocks.ltm"), false); *************** *** 250,254 **** assertEquals(tm.getObjectById("yellowblock"), rst.getRow(0).get(0)); } ! private void checkResultsSet(String testName, TologResultsSet results, int expectedColSize, int expectedRowSize, Object[][]expectedRows) { assertEquals(testName + ": Unexpected results set width.", expectedColSize, results.getNumCols()); --- 258,262 ---- assertEquals(tm.getObjectById("yellowblock"), rst.getRow(0).get(0)); } ! private void checkResultsSet(String testName, TologResultsSet results, int expectedColSize, int expectedRowSize, Object[][]expectedRows) { assertEquals(testName + ": Unexpected results set width.", expectedColSize, results.getNumCols()); *************** *** 263,267 **** } } ! private String dumpRow(List row) { StringBuffer ret = new StringBuffer(); --- 271,275 ---- } } ! private String dumpRow(List row) { StringBuffer ret = new StringBuffer(); *************** *** 280,284 **** return ret.toString(); } ! class TestQuery { String name; --- 288,292 ---- return ret.toString(); } ! class TestQuery { String name; *************** *** 290,294 **** int resultsRows; Object [][] expectedRows; ! public TestQuery(String name, String tm, String queryString, boolean parseErrorExpected, boolean processingErrorExpected) { this.name = name; --- 298,302 ---- int resultsRows; Object [][] expectedRows; ! public TestQuery(String name, String tm, String queryString, boolean parseErrorExpected, boolean processingErrorExpected) { this.name = name; *************** *** 298,302 **** this.processingErrorExpected = processingErrorExpected; } ! public TestQuery(String name, String tm, String queryString, int resultsCols, int resultsRows, Object[][]expectedRows) { this.name = name; --- 306,310 ---- this.processingErrorExpected = processingErrorExpected; } ! public TestQuery(String name, String tm, String queryString, int resultsCols, int resultsRows, Object[][]expectedRows) { this.name = name; *************** *** 308,312 **** } } ! class TopicRef { String id; --- 316,320 ---- } } ! class TopicRef { String id; *************** *** 317,354 **** } - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:34 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:34:06 lheuer - * Initial tolog import - * - * Revision 1.11 2004/11/02 16:03:39 kal_ahmed - * Fixed reported bug with processing external tolog modules. - * - * Revision 1.10 2004/06/20 14:12:31 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.9 2004/06/16 21:21:44 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.8 2004/06/14 21:33:07 kal_ahmed - * Fixed query evaluation when multiple predicates introduce new variables. - * - * Revision 1.7 2004/06/13 19:58:12 kal_ahmed - * Fixed testRecursiveRules() query. Reinstated disabled tests. - * - * Revision 1.6 2004/06/13 19:44:31 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - * Revision 1.5 2004/06/13 17:18:00 kal_ahmed - * Added registration of builtin predicates. Fixed rule expansion code to handle player/role pairs correctly. - * - * Revision 1.4 2004/06/09 22:15:09 kal_ahmed - * Fixed parser to disallow player:role pairs in predicates other than dynamic association predicates. Fixed initialisation of extension predicates. Added DirectInstanceOfPredicate extension to in-memory query evaluator. - * - * Revision 1.3 2004/06/09 21:12:19 kal_ahmed - * Added standard source file header and footer. - * - */ \ No newline at end of file --- 325,326 ---- Index: TologParserTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/test/TologParserTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TologParserTest.java 6 Mar 2005 21:11:34 -0000 1.2 --- TologParserTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.test; *************** *** 47,52 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class TologParserTest extends TologParserTestBase { --- 54,60 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TologParserTest extends TologParserTestBase { *************** *** 57,61 **** {"not(contains(europe : container, $B : containee))?", "select * from not(contains(europe:container, $B:containee))?"}, { ! "{ contains(europe:container, $B:containee) | contains(asia:container, $B:containee) }?", "select * from { contains(europe:container, $B:containee) | contains(asia:container, $B:containee) }?"}, { --- 65,69 ---- {"not(contains(europe : container, $B : containee))?", "select * from not(contains(europe:container, $B:containee))?"}, { ! "{ contains(europe:container, $B:containee) | contains(asia:container, $B:containee) }?", "select * from { contains(europe:container, $B:containee) | contains(asia:container, $B:containee) }?"}, { *************** *** 92,104 **** } }; ! private final String [][] m_rulesTest = { ! { "nestedin($A, $B) :- { contains($B, $A) | contains($C, $A), nestedin($C, $B) }.", "nestedin($A, $B) :- { contains($B, $A) | contains($C, $A), nestedin($C, $B) }." }, { ! "nestedin($A, $B) :- contains($C, $A), contains($B, $C).", ! "nestedin($A, $B) :- contains($C, $A), contains($B, $C)." } /* --- 100,112 ---- } }; ! private final String [][] m_rulesTest = { ! { "nestedin($A, $B) :- { contains($B, $A) | contains($C, $A), nestedin($C, $B) }.", "nestedin($A, $B) :- { contains($B, $A) | contains($C, $A), nestedin($C, $B) }." }, { ! "nestedin($A, $B) :- contains($C, $A), contains($B, $C).", ! "nestedin($A, $B) :- contains($C, $A), contains($B, $C)." } /* *************** *** 109,144 **** */ }; ! private final String [][] m_parserTest2 = { { ! "select $ASSOC, $ROLE1, $ROLE2 from " + " association-role($ASSOC, $ROLE1)," + ! " role-player($ROLE1, AT1)," + ! " association-role($ASSOC, $ROLE2)," + " role-player($ROLE2, AT2)," + " type($ASSOC, activity_responsibility)?", ! "select $ASSOC, $ROLE1, $ROLE2 from " + " association-role($ASSOC, $ROLE1)," + ! " role-player($ROLE1, AT1)," + ! " association-role($ASSOC, $ROLE2)," + " role-player($ROLE2, AT2)," + " type($ASSOC, activity_responsibility)?", }, { ! "select $ASSOC, $ROLE1, $ROLE2 from " + " association-role($ASSOC, $ROLE1)," + ! " role-player($ROLE1, AT1)," + ! " association-role($ASSOC, $ROLE2)," + " role-player($ROLE2, AT2)?", ! "select $ASSOC, $ROLE1, $ROLE2 from " + " association-role($ASSOC, $ROLE1)," + ! " role-player($ROLE1, AT1)," + ! " association-role($ASSOC, $ROLE2)," + " role-player($ROLE2, AT2)?" } }; ! private Map m_predicatesByName; ! /** * Constructor for TologParserTest. --- 117,152 ---- */ }; ! private final String [][] m_parserTest2 = { { ! "select $ASSOC, $ROLE1, $ROLE2 from " + " association-role($ASSOC, $ROLE1)," + ! " role-player($ROLE1, AT1)," + ! " association-role($ASSOC, $ROLE2)," + " role-player($ROLE2, AT2)," + " type($ASSOC, activity_responsibility)?", ! "select $ASSOC, $ROLE1, $ROLE2 from " + " association-role($ASSOC, $ROLE1)," + ! " role-player($ROLE1, AT1)," + ! " association-role($ASSOC, $ROLE2)," + " role-player($ROLE2, AT2)," + " type($ASSOC, activity_responsibility)?", }, { ! "select $ASSOC, $ROLE1, $ROLE2 from " + " association-role($ASSOC, $ROLE1)," + ! " role-player($ROLE1, AT1)," + ! " association-role($ASSOC, $ROLE2)," + " role-player($ROLE2, AT2)?", ! "select $ASSOC, $ROLE1, $ROLE2 from " + " association-role($ASSOC, $ROLE1)," + ! " role-player($ROLE1, AT1)," + ! " association-role($ASSOC, $ROLE2)," + " role-player($ROLE2, AT2)?" } }; ! private Map m_predicatesByName; ! /** * Constructor for TologParserTest. *************** *** 161,165 **** ClauseList rootClauseList = q.getRootClauseList(); assertEquals(1, rootClauseList.size()); ! assertEquals("select * from contains($A:container, $B:containee)?", q.toString()); } --- 169,173 ---- ClauseList rootClauseList = q.getRootClauseList(); assertEquals(1, rootClauseList.size()); ! assertEquals("select * from contains($A:container, $B:containee)?", q.toString()); } *************** *** 188,192 **** System.out.println(q.toString()); //assertEquals("Comparison failure for input " + m_parserTest2[i][0], ! // m_parserTest2[i][1], q.toString()); } } --- 196,200 ---- System.out.println(q.toString()); //assertEquals("Comparison failure for input " + m_parserTest2[i][0], ! // m_parserTest2[i][1], q.toString()); } } *************** *** 200,204 **** } } ! public void testSubjectIndicatorAddressing() throws Exception { TopicMap tm = getTopicMapFromLTMString( --- 208,212 ---- } } ! public void testSubjectIndicatorAddressing() throws Exception { TopicMap tm = getTopicMapFromLTMString( *************** *** 214,218 **** q.toString()); } ! public void testSubjectAddressAddressing() throws Exception { TopicMap tm = getTopicMapFromLTMString( --- 222,... [truncated message content] |
From: Lars H. <lh...@us...> - 2005-03-07 17:48:18
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29281/src/org/tmapiutils/utils Modified Files: PSI.java Log Message: Licence change to Apache 2.0 Index: PSI.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/utils/PSI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PSI.java 7 Mar 2005 14:32:24 -0000 1.1 --- PSI.java 7 Mar 2005 17:48:08 -0000 1.2 *************** *** 1,9 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ package org.tmapiutils.utils; --- 1,18 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. ! */ package org.tmapiutils.utils; |
From: Lars H. <lh...@us...> - 2005-03-07 16:35:06
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9785/src/org/tmapiutils/query/tolog/predicates/test Modified Files: TopicNameTest.java Log Message: TopicNamePredicate test should be TMAPI compatible Index: TopicNameTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TopicNameTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TopicNameTest.java 6 Mar 2005 19:37:40 -0000 1.2 --- TopicNameTest.java 7 Mar 2005 16:34:51 -0000 1.3 *************** *** 11,16 **** import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; ! import org.tmapi.core.TopicName; import org.tmapi.core.Topic; /** --- 11,18 ---- import org.tmapiutils.query.tolog.utils.TologContext; import org.tmapiutils.query.tolog.utils.VariableSet; ! // TMAPI ! import org.tmapi.core.TopicMap; import org.tmapi.core.Topic; + import org.tmapi.core.TopicName; /** *************** *** 32,38 **** */ public String getTestMap() { ! return "[topic1 = \"Topic1\"]\n" + "[topic2 = \"Topic2\"]\n" + "[topic3 = \"Topic3\";\"topic3\"" + " = \"Topic Three\"]\n" + "[topic4]"; } /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.test.PredicateTestBase#getPredicateClass() --- 34,64 ---- */ public String getTestMap() { ! return "[topic1 = \"Topic1\"]\n" + ! "[topic2 = \"Topic2\"]\n" + ! "[topic3 = \"Topic3\";\"topic3\"" + ! " = \"Topic Three\"]\n" + ! "[topic4]"; } + + public void createTestMap(TopicMap tm) { + Topic topic1 = tm.createTopic(); + topic1.createTopicName("Topic1", null); + Topic topic2 = tm.createTopic(); + topic2.createTopicName("Topic2", null); + Topic topic3 = tm.createTopic(); + topic3.createTopicName("Topic3", null); + // Should be the display name. + // Todo: Test if this breaks something + topic3.createTopicName("topic3", null); + topic3.createTopicName("Topic Three", null); + Topic topic4 = tm.createTopic(); + + registerObject("topic1", topic1); + registerObject("topic2", topic2); + registerObject("topic3", topic3); + registerObject("topic4", topic4); + } + /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.test.PredicateTestBase#getPredicateClass() *************** *** 43,47 **** public void testMatchOnName() throws Exception { ! Topic topic1 = (Topic) m_tm.getObjectById("topic1"); TopicName bn = (TopicName) topic1.getTopicNames().iterator().next(); --- 69,73 ---- public void testMatchOnName() throws Exception { ! Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn = (TopicName) topic1.getTopicNames().iterator().next(); *************** *** 61,65 **** public void testMatchOnTopic() throws Exception { ! Topic topic3 = (Topic) m_tm.getObjectById("topic3"); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 87,91 ---- public void testMatchOnTopic() throws Exception { ! Topic topic3 = (Topic) getObjectById("topic3"); ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 91,101 **** assertNotNull(out); assertEquals(4, out.getRows().size()); ! assertFalse(out.getColumn(a).contains(m_tm.getObjectById("topic4"))); } public void testClosedMatch() throws Exception { ! Topic topic1 = (Topic) m_tm.getObjectById("topic1"); TopicName bn1 = (TopicName) topic1.getTopicNames().iterator().next(); ! Topic topic2 = (Topic) m_tm.getObjectById("topic2"); ArrayList params = new ArrayList(); --- 117,127 ---- assertNotNull(out); assertEquals(4, out.getRows().size()); ! assertFalse(out.getColumn(a).contains(getObjectById("topic4"))); } public void testClosedMatch() throws Exception { ! Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn1 = (TopicName) topic1.getTopicNames().iterator().next(); ! Topic topic2 = (Topic) getObjectById("topic2"); ArrayList params = new ArrayList(); |
From: Lars H. <lh...@us...> - 2005-03-07 16:17:31
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5391/src/org/tmapiutils/query/tolog/predicates Modified Files: ValuePredicate.java Log Message: Replaced VariantContainer with TopicName Index: ValuePredicate.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/ValuePredicate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ValuePredicate.java 7 Mar 2005 12:32:00 -0000 1.2 --- ValuePredicate.java 7 Mar 2005 16:17:20 -0000 1.3 *************** *** 20,24 **** import org.tmapiutils.query.tolog.utils.VariableSet; - import org.tmapiutils.IndexUtils; // TMAPI import org.tmapi.core.TopicMapObject; --- 20,23 ---- *************** *** 96,100 **** } return value; - } --- 95,98 ---- *************** *** 106,118 **** String value = getValue(object); - - // String value = null; - // if (object instanceof DataObject) { - // DataObject d = (DataObject)object; - // value = d.getValue(); - // if (value == null) value = d.getResource().getReference(); - // } else if (object instanceof TopicName) { - // value = ((TopicName)object).getValue(); - // } if (value != null) { addResultsRow(ret, new Object[] {object, value}); --- 104,107 ---- *************** *** 126,138 **** private void matchObject(String data, VariableSet ret) throws TologProcessingException { ! IndexUtils.updateIndex(_occIdx); for (Iterator it = _occIdx.getOccurrencesByValue(data).iterator(); it.hasNext();) { addResultsRow(ret, new Object[] {it.next(), data}); } - IndexUtils.updateIndex(_tnIdx); for (Iterator it = _tnIdx.getTopicNamesByValue(data).iterator(); it.hasNext();) { addResultsRow(ret, new Object[] { it.next(), data }); } - IndexUtils.updateIndex(_varIdx); for (Iterator it = _varIdx.getVariantsByValue(data).iterator(); it.hasNext();) { addResultsRow(ret, new Object[] { it.next(), data }); --- 115,141 ---- private void matchObject(String data, VariableSet ret) throws TologProcessingException { ! try { ! _occIdx.open(); ! if (!_occIdx.getFlags().isAutoUpdated()) { ! _occIdx.reindex(); ! } ! _tnIdx.open(); ! if (!_tnIdx.getFlags().isAutoUpdated()) { ! _tnIdx.reindex(); ! } ! _varIdx.open(); ! if (!_varIdx.getFlags().isAutoUpdated()) { ! _varIdx.reindex(); ! } ! } ! catch (TMAPIException ex) { ! throw new TologParserException("Error initialising indexes for " + PREDICATE_NAME, ex); ! } for (Iterator it = _occIdx.getOccurrencesByValue(data).iterator(); it.hasNext();) { addResultsRow(ret, new Object[] {it.next(), data}); } for (Iterator it = _tnIdx.getTopicNamesByValue(data).iterator(); it.hasNext();) { addResultsRow(ret, new Object[] { it.next(), data }); } for (Iterator it = _varIdx.getVariantsByValue(data).iterator(); it.hasNext();) { addResultsRow(ret, new Object[] { it.next(), data }); *************** *** 151,164 **** addResultsRow(ret, new Object[] { object, data }); } - - // if (object instanceof DataObject) { - // if (data.equals(((DataObject)object).getValue())) { - // addResultsRow(ret, new Object[] { object, data}); - // } - // } else if (object instanceof TopicName) { - // if (data.equals(((TopicName)object).getValue())) { - // addResultsRow(ret, new Object[] { object, data }); - // } - // } } --- 154,157 ---- *************** *** 213,223 **** } ! private void addVariants(VariantContainer vc) throws TologProcessingException { ! for (Iterator it = vc.getVariants().iterator(); it.hasNext();) { ! Variant vn = (Variant) it.next(); ! if (vn.getValue() != null) { ! addResultsRow(m_vs, new Object[] { vn, vn.getValue() }); } - addVariants(v); } } --- 206,216 ---- } ! private void addVariants(TopicName topicname) throws TologProcessingException { ! for (Iterator it = topicname.getVariants().iterator(); it.hasNext();) { ! Variant variant = (Variant) it.next(); ! String value = variant.getValue(); ! if (value != null) { ! addResultsRow(m_vs, new Object[] { variant, value }); } } } *************** *** 225,244 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.1 2005/03/06 17:30:00 lheuer - * Initial tolog import - * - * Revision 1.2 2004/09/27 14:34:00 kal_ahmed - * Predicate now checks the string value of variant names as well as occurrences and base names. - * - * Revision 1.1 2004/06/13 09:06:43 kal_ahmed - * Initial version of value() predicate. - * - */ \ No newline at end of file --- 218,219 ---- |
From: Lars H. <lh...@us...> - 2005-03-07 14:32:37
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15172/src/org/tmapiutils/utils Added Files: PSI.java Log Message: PSI class to simplify access to often used XTM 1.0 PSIs --- NEW FILE: PSI.java --- /* Copyright (c) 2000-2004 The TM4J Project. All rights reserved. This software is licensed under a modified version of the Apache Software License. The full license text can be found at http://tm4j.org/LICENSE.txt */ package org.tmapiutils.utils; /** * This class defines constants for the XTM 1.0 Published Subject Indicators. * Each constant defines the PSI as a full URL. */ public class PSI { /** * The base URL for XTM 1.0 (not actually an XTM PSI). */ public static final String XTM1_BASE = "http://www.topicmaps.org/xtm/1.0/"; /** * The base URL for all XTM 1.0 PSIs. */ public static final String PSI_DOC = XTM1_BASE + "core.xtm#"; /** * Suitability for Sorting: Suitability of a topic name for use as a sort key; * for use in the scopes of variant names. */ public static final String SORT = PSI_DOC + "sort"; /** * Suitability for Display: Suitability of a topic name for display; * for use in the scopes of variant names. */ public static final String DISPLAY = PSI_DOC + "display"; /** * Class-Instance Association Template: The template for associations * that establish a class-instance relationship between topics. */ public static final String CLASS_INSTANCE = PSI_DOC + "class-instance"; /** * Class Role: The "Class" role in a Class-Instance association. */ public static final String CLASS = PSI_DOC + "class"; /** * Instance Role: The "Instance" role in a Class-Instance association. */ public static final String INSTANCE = PSI_DOC + "instance"; /** * Superclass-Subclass Association Template: The template for associations * that establish a Superclass-Subclass relationship between topics. */ public static final String SUPERCLASS_SUBCLASS = PSI_DOC + "superclass-subclass"; /** * Superclass Role: The "Superclass" role in a Superclass-Subclass association. */ public static final String SUPERCLASS = PSI_DOC + "superclass"; /** * Subclass Role: The "Subclass" role in a Superclass-Subclass association. */ public static final String SUBCLASS = PSI_DOC + "subclass"; // Default classes /** * The PSI for a Topic Map <b>Topic</b>. */ public static final String TOPIC = PSI_DOC + "topic"; /** * The PSI for a Topic Map <b>Association</b>. */ public static final String ASSOCIATION = PSI_DOC + "association"; /** * The PSI for a Topic Map <b>Occurrence</b>. */ public static final String OCCURRENCE = PSI_DOC + "occurrence"; } |
From: Lars H. <lh...@us...> - 2005-03-07 14:10:35
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9364/src/org/tmapiutils/query/tolog/predicates/test Modified Files: OccurrencePredicateTest.java Log Message: Occurrence test TMAPI compatible Index: OccurrencePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/OccurrencePredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OccurrencePredicateTest.java 6 Mar 2005 21:11:33 -0000 1.3 --- OccurrencePredicateTest.java 7 Mar 2005 14:10:25 -0000 1.4 *************** *** 18,21 **** --- 18,22 ---- import org.tmapiutils.query.tolog.utils.VariableSet; // TMAPI + import org.tmapi.core.TopicMap; import org.tmapi.core.Topic; *************** *** 34,37 **** --- 35,52 ---- "{tm4j, homepage, \"http://www.tm4j.org/\"}"; + public void createTestMap(TopicMap tm) { + Topic tmapiutils = tm.createTopic(); + Topic homepage = tm.createTopic(); + Topic contact_details = tm.createTopic(); + tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/", homepage, null); + tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/contact/", contact_details, null); + Topic tmapi = tm.createTopic(); + tmapi.createOccurrence(createLocator("http://tmapi.org/", homepage, null); + + registerObject("tmapi", tmapi); + registerObject("tmapiutils", tmapiutils); + registerObject("homepage"), homepage); + registerObject("contact-details", contact_details); + } /** *************** *** 53,56 **** --- 68,73 ---- return TESTMAP; } + + /* (non-Javadoc) *************** *** 72,82 **** assertEquals(2, out.getColumns().size()); assertEquals(3, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("techquila"))); ! assertTrue(out.getColumn(a).contains(m_tm.getObjectById("tm4j"))); ! Iterator it = ((Topic) m_tm.getObjectById("techquila")).getOccurrences().iterator(); while (it.hasNext()) { assertTrue(out.getColumn(b).contains(it.next())); } ! it = ((Topic) m_tm.getObjectById("tm4j")).getOccurrences().iterator(); while (it.hasNext()) { assertTrue(out.getColumn(b).contains(it.next())); --- 89,99 ---- assertEquals(2, out.getColumns().size()); assertEquals(3, out.getRows().size()); ! assertTrue(out.getColumn(a).contains(getObjectById("tmapiutils"))); ! assertTrue(out.getColumn(a).contains(getObjectById("tmapi"))); ! Iterator it = ((Topic) getObjectById("tmapiutils")).getOccurrences().iterator(); while (it.hasNext()) { assertTrue(out.getColumn(b).contains(it.next())); } ! it = ((Topic) getObjectById("tmapi")).getOccurrences().iterator(); while (it.hasNext()) { assertTrue(out.getColumn(b).contains(it.next())); *************** *** 88,92 **** Variable a = new Variable("A"); params.add(a); ! params.add(m_tm.getObjectById("techquila").getOccurrences().iterator().next()); m_predicate.setParameters(params); VariableSet out = m_predicate.matches(params, m_context); --- 105,109 ---- Variable a = new Variable("A"); params.add(a); ! params.add(getObjectById("tmapiutils").getOccurrences().iterator().next()); m_predicate.setParameters(params); VariableSet out = m_predicate.matches(params, m_context); *************** *** 94,98 **** assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getRow(0).contains(m_tm.getObjectById("techquila"))); } --- 111,115 ---- assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getRow(0).contains(getObjectById("tmapiutils"))); } *************** *** 100,104 **** List params = new ArrayList(); Variable a = new Variable("A"); ! params.add(m_tm.getObjectById("techquila")); params.add(a); m_predicate.setParameters(params); --- 117,121 ---- List params = new ArrayList(); Variable a = new Variable("A"); ! params.add(getObjectById("tmapiutils")); params.add(a); m_predicate.setParameters(params); *************** *** 107,111 **** assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! Iterator it = ((Topic) m_tm.getObjectById("techquila")).getOccurrences().iterator(); while (it.hasNext()) { assertTrue(out.getColumn(a).contains(it.next())); --- 124,128 ---- assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! Iterator it = ((Topic) getObjectById("tmapiutils")).getOccurrences().iterator(); while (it.hasNext()) { assertTrue(out.getColumn(a).contains(it.next())); *************** *** 120,129 **** params.add(b); m_predicate.setParameters(params); ! params.set(0, m_tm.getObjectById("tm4j")); ! params.set(1, m_tm.getObjectById("tm4j").getOccurrences().iterator().next()); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(1, out.getRows().size()); ! params.set(0, m_tm.getObjectById("techquila")); out = m_predicate.matches(params, m_context); assertNotNull(out); --- 137,146 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, getObjectById("tmapi")); ! params.set(1, getObjectById("tmapi").getOccurrences().iterator().next()); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(1, out.getRows().size()); ! params.set(0, getObjectById("tmapiutils")); out = m_predicate.matches(params, m_context); assertNotNull(out); *************** *** 131,151 **** } } - - /* - * $Log$ - * Revision 1.3 2005/03/06 21:11:33 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.2 2005/03/06 19:37:23 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.3 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.2 2004/06/10 08:19:41 kal_ahmed - * Added standard file header and footer. - * - */ \ No newline at end of file --- 148,149 ---- |