You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/02/21 12:23:28 UTC
[6/19] MARMOTTA-104: renamed packages in ldpath (resolved)
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-functions-xml/src/test/java/org/apache/marmotta/ldpath/model/functions/xml/XPathFunctionTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-xml/src/test/java/org/apache/marmotta/ldpath/model/functions/xml/XPathFunctionTest.java b/libraries/ldpath/ldpath-functions-xml/src/test/java/org/apache/marmotta/ldpath/model/functions/xml/XPathFunctionTest.java
new file mode 100644
index 0000000..ecb0877
--- /dev/null
+++ b/libraries/ldpath/ldpath-functions-xml/src/test/java/org/apache/marmotta/ldpath/model/functions/xml/XPathFunctionTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2013 Salzburg Research.
+ *
+ * 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.apache.marmotta.ldpath.model.functions.xml;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.marmotta.ldpath.model.fields.FieldMapping;
+import org.apache.marmotta.ldpath.parser.ParseException;
+import org.apache.marmotta.ldpath.parser.RdfPathParser;
+import org.apache.marmotta.ldpath.test.AbstractTestBase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFParseException;
+
+
+@RunWith(Parameterized.class)
+public class XPathFunctionTest extends AbstractTestBase {
+
+ @Parameters(name = "{1}")
+ public static List<String[]> data() {
+ ArrayList<String[]> data = new ArrayList<String[]>();
+ data.add(new String[] { "1", "The Pacific Ocean" });
+ data.add(new String[] { "2", "Magma" });
+ data.add(new String[] { "3", "Red" });
+ data.add(new String[] { "4", "Oxygen" });
+ data.add(new String[] { "5", "Jupiter" });
+ data.add(new String[] { "6", "Titan" });
+ data.add(new String[] { "7", "Mercury" });
+ data.add(new String[] { "8", "11" });
+ data.add(new String[] { "9", "9" });
+ data.add(new String[] { "10", "The median" });
+ return data;
+ }
+
+ @Parameter
+ public String index;
+ @Parameter(1)
+ public String answer;
+
+ @Before
+ public void loadData() throws RepositoryException, RDFParseException, IOException {
+ super.loadData("data.n3", RDFFormat.N3);
+ }
+
+ @Test
+ public void testXpathFunction() throws ParseException {
+ final URI ctx = repository.getValueFactory().createURI(NSS.get("ex") + "Quiz");
+
+ final RdfPathParser<Value> parser = createParserFromString("fn:xpath(\"/quiz/question[" +
+ index +
+ "]/answers/answer[@correct='true']/text()\", foo:xml) :: xsd:string");
+ final FieldMapping<Object, Value> rule = parser.parseRule(NSS);
+ final Collection<Object> values = rule.getValues(backend, ctx);
+
+ Assert.assertEquals(1, values.size());
+ Assert.assertEquals(answer, values.iterator().next());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-functions-xml/src/test/java/xml/RemoveXmlTagsFunctionTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-xml/src/test/java/xml/RemoveXmlTagsFunctionTest.java b/libraries/ldpath/ldpath-functions-xml/src/test/java/xml/RemoveXmlTagsFunctionTest.java
deleted file mode 100644
index ed1597f..0000000
--- a/libraries/ldpath/ldpath-functions-xml/src/test/java/xml/RemoveXmlTagsFunctionTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2013 Salzburg Research.
- *
- * 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 xml;
-
-import at.newmedialab.ldpath.model.fields.FieldMapping;
-import at.newmedialab.ldpath.parser.ParseException;
-import at.newmedialab.ldpath.parser.RdfPathParser;
-import core.AbstractTestBase;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFParseException;
-
-import java.io.IOException;
-import java.util.Collection;
-
-public class RemoveXmlTagsFunctionTest extends AbstractTestBase {
-
- @Before
- public void loadData() throws RepositoryException, RDFParseException, IOException {
- super.loadData("data.n3", RDFFormat.N3);
- }
-
- @Test
- public void testRemoveTags() throws ParseException {
- String result = "A quiz is a form of game or mind sport in which the players (as individuals or in teams) attempt to answer questions correctly.";
-
- final URI context = repository.getValueFactory().createURI(NSS.get("ex") + "Text");
-
- final RdfPathParser<Value> parser = createParserFromString("fn:removeTags(foo:formatted) :: xsd:string");
- final FieldMapping<Object, Value> rule = parser.parseRule(NSS);
- final Collection<Object> values = rule.getValues(backend, context);
-
- Assert.assertEquals(1, values.size());
- Assert.assertEquals(result, values.iterator().next());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-functions-xml/src/test/java/xml/XPathFunctionTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-xml/src/test/java/xml/XPathFunctionTest.java b/libraries/ldpath/ldpath-functions-xml/src/test/java/xml/XPathFunctionTest.java
deleted file mode 100644
index 94af5c7..0000000
--- a/libraries/ldpath/ldpath-functions-xml/src/test/java/xml/XPathFunctionTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2013 Salzburg Research.
- *
- * 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 xml;
-
-import at.newmedialab.ldpath.model.fields.FieldMapping;
-import at.newmedialab.ldpath.parser.ParseException;
-import at.newmedialab.ldpath.parser.RdfPathParser;
-import core.AbstractTestBase;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFParseException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-@RunWith(Parameterized.class)
-public class XPathFunctionTest extends AbstractTestBase {
-
- @Parameters(name = "{1}")
- public static List<String[]> data() {
- ArrayList<String[]> data = new ArrayList<String[]>();
- data.add(new String[] { "1", "The Pacific Ocean" });
- data.add(new String[] { "2", "Magma" });
- data.add(new String[] { "3", "Red" });
- data.add(new String[] { "4", "Oxygen" });
- data.add(new String[] { "5", "Jupiter" });
- data.add(new String[] { "6", "Titan" });
- data.add(new String[] { "7", "Mercury" });
- data.add(new String[] { "8", "11" });
- data.add(new String[] { "9", "9" });
- data.add(new String[] { "10", "The median" });
- return data;
- }
-
- @Parameter
- public String index;
- @Parameter(1)
- public String answer;
-
- @Before
- public void loadData() throws RepositoryException, RDFParseException, IOException {
- super.loadData("data.n3", RDFFormat.N3);
- }
-
- @Test
- public void testXpathFunction() throws ParseException {
- final URI ctx = repository.getValueFactory().createURI(NSS.get("ex") + "Quiz");
-
- final RdfPathParser<Value> parser = createParserFromString("fn:xpath(\"/quiz/question[" +
- index +
- "]/answers/answer[@correct='true']/text()\", foo:xml) :: xsd:string");
- final FieldMapping<Object, Value> rule = parser.parseRule(NSS);
- final Collection<Object> values = rule.getValues(backend, ctx);
-
- Assert.assertEquals(1, values.size());
- Assert.assertEquals(answer, values.iterator().next());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-functions-xml/src/test/resources/org/apache/marmotta/ldpath/model/functions/xml/data.n3
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-xml/src/test/resources/org/apache/marmotta/ldpath/model/functions/xml/data.n3 b/libraries/ldpath/ldpath-functions-xml/src/test/resources/org/apache/marmotta/ldpath/model/functions/xml/data.n3
new file mode 100644
index 0000000..bd2a52b
--- /dev/null
+++ b/libraries/ldpath/ldpath-functions-xml/src/test/resources/org/apache/marmotta/ldpath/model/functions/xml/data.n3
@@ -0,0 +1,102 @@
+@prefix ex: <http://www.example.com/> .
+@prefix foo: <http://localhost/vcab#> .
+
+ex:Text a ex:Test;
+ foo:formatted """A <em>quiz</em> is a form of <strong>game</strong> or <strong>mind sport</strong> in which the players <font size="tiny">(as individuals or in teams)</font> attempt to answer questions <strong>correctly</strong>.""".
+
+ex:Quiz a ex:Test;
+ foo:xml """<?xml version="1.0" encoding="UTF-8"?>
+<!-- All changes here should be reflected in the actual test-data file data.n3 -->
+<quiz>
+ <!-- Selected questions from http://www.sciencekids.co.nz/quizzes.html -->
+ <question category="earth">
+ <qline>What is the name of the largest ocean on earth?</qline>
+ <answers>
+ <answer correct="true">The Pacific Ocean</answer>
+ <answer>The Atlantic Ocean</answer>
+ <answer>The Indian Ocean</answer>
+ </answers>
+ </question>
+ <question category="earth">
+ <qline>What do you call molten rock before it has erupted?</qline>
+ <answers>
+ <answer correct="true">Magma</answer>
+ <answer>Lava</answer>
+ <answer>Hot-Stone</answer>
+ </answers>
+ </question>
+ <question category="earth">
+ <qline>The gemstone ruby is typically what color?</qline>
+ <answers>
+ <answer correct="true">Red</answer>
+ <answer>Blue</answer>
+ <answer>Green</answer>
+ <answer>White</answer>
+ </answers>
+ </question>
+ <question category="earth">
+ <qline>What is the second most common gas found in the air we breathe?</qline>
+ <answers>
+ <answer>Carbon Dioxide</answer>
+ <answer>Nitrogen</answer>
+ <answer>Argon</answer>
+ <answer correct="true">Oxygen</answer>
+ </answers>
+ </question>
+ <question category="space">
+ <qline>What planet is famous for its big red spot on it?</qline>
+ <answers>
+ <answer correct="true">Jupiter</answer>
+ <answer>Uranus</answer>
+ <answer>Venus</answer>
+ <answer>Neptune</answer>
+ </answers>
+ </question>
+ <question category="space">
+ <qline>What is the name of Saturn’s largest moon?</qline>
+ <answers>
+ <answer correct="true">Titan</answer>
+ <answer>Enceladus</answer>
+ <answer>Rhea</answer>
+ <answer>Europa</answer>
+ <answer>Callisto</answer>
+ <answer>Ganymede</answer>
+ </answers>
+ </question>
+ <question category="space">
+ <qline>What is the closest planet to the Sun?</qline>
+ <answers>
+ <answer correct="true">Mercury</answer>
+ <answer>Venus</answer>
+ <answer>Mars</answer>
+ <answer>Saturn</answer>
+ </answers>
+ </question>
+ <question category="math">
+ <qline>What is the next prime number after 7?</qline>
+ <answers>
+ <answer>9</answer>
+ <answer correct="true">11</answer>
+ <answer>12</answer>
+ <answer>15</answer>
+ </answers>
+ </question>
+ <question category="math">
+ <qline>How many sides does a nonagon have?</qline>
+ <answers>
+ <answer>7</answer>
+ <answer>8</answer>
+ <answer correct="true">9</answer>
+ <answer>10</answer>
+ </answers>
+ </question>
+ <question category="math">
+ <qline>In statistics, the middle value of an ordered set of values is called what?</qline>
+ <answers>
+ <answer correct="true">The median</answer>
+ <answer>The mean</answer>
+ <answer>The average</answer>
+ </answers>
+ </question>
+</quiz>
+""".
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-functions-xml/src/test/resources/org/apache/marmotta/ldpath/model/functions/xml/quiz.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-xml/src/test/resources/org/apache/marmotta/ldpath/model/functions/xml/quiz.xml b/libraries/ldpath/ldpath-functions-xml/src/test/resources/org/apache/marmotta/ldpath/model/functions/xml/quiz.xml
new file mode 100644
index 0000000..ac80657
--- /dev/null
+++ b/libraries/ldpath/ldpath-functions-xml/src/test/resources/org/apache/marmotta/ldpath/model/functions/xml/quiz.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2013 Salzburg Research.
+ ~
+ ~ 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.
+ -->
+
+<!-- All changes here should be reflected in the actual test-data file data.n3 -->
+<quiz>
+ <!-- Selected questions from http://www.sciencekids.co.nz/quizzes.html -->
+ <question category="earth">
+ <qline>What is the name of the largest ocean on earth?</qline>
+ <answers>
+ <answer correct="true">The Pacific Ocean</answer>
+ <answer>The Atlantic Ocean</answer>
+ <answer>The Indian Ocean</answer>
+ </answers>
+ </question>
+ <question category="earth">
+ <qline>What do you call molten rock before it has erupted?</qline>
+ <answers>
+ <answer correct="true">Magma</answer>
+ <answer>Lava</answer>
+ <answer>Hot-Stone</answer>
+ </answers>
+ </question>
+ <question category="earth">
+ <qline>The gemstone ruby is typically what color?</qline>
+ <answers>
+ <answer correct="true">Red</answer>
+ <answer>Blue</answer>
+ <answer>Green</answer>
+ <answer>White</answer>
+ </answers>
+ </question>
+ <question category="earth">
+ <qline>What is the second most common gas found in the air we breathe?</qline>
+ <answers>
+ <answer>Carbon Dioxide</answer>
+ <answer>Nitrogen</answer>
+ <answer>Argon</answer>
+ <answer correct="true">Oxygen</answer>
+ </answers>
+ </question>
+ <question category="space">
+ <qline>What planet is famous for its big red spot on it?</qline>
+ <answers>
+ <answer correct="true">Jupiter</answer>
+ <answer>Uranus</answer>
+ <answer>Venus</answer>
+ <answer>Neptune</answer>
+ </answers>
+ </question>
+ <question category="space">
+ <qline>What is the name of Saturn’s largest moon?</qline>
+ <answers>
+ <answer correct="true">Titan</answer>
+ <answer>Enceladus</answer>
+ <answer>Rhea</answer>
+ <answer>Europa</answer>
+ <answer>Callisto</answer>
+ <answer>Ganymede</answer>
+ </answers>
+ </question>
+ <question category="space">
+ <qline>What is the closest planet to the Sun?</qline>
+ <answers>
+ <answer correct="true">Mercury</answer>
+ <answer>Venus</answer>
+ <answer>Mars</answer>
+ <answer>Saturn</answer>
+ </answers>
+ </question>
+ <question category="math">
+ <qline>What is the next prime number after 7?</qline>
+ <answers>
+ <answer>9</answer>
+ <answer correct="true">11</answer>
+ <answer>12</answer>
+ <answer>15</answer>
+ </answers>
+ </question>
+ <question category="math">
+ <qline>How many sides does a nonagon have?</qline>
+ <answers>
+ <answer>7</answer>
+ <answer>8</answer>
+ <answer correct="true">9</answer>
+ <answer>10</answer>
+ </answers>
+ </question>
+ <question category="math">
+ <qline>In statistics, the middle value of an ordered set of values is called what?</qline>
+ <answers>
+ <answer correct="true">The median</answer>
+ <answer>The mean</answer>
+ <answer>The average</answer>
+ </answers>
+ </question>
+</quiz>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-functions-xml/src/test/resources/xml/data.n3
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-xml/src/test/resources/xml/data.n3 b/libraries/ldpath/ldpath-functions-xml/src/test/resources/xml/data.n3
deleted file mode 100644
index bd2a52b..0000000
--- a/libraries/ldpath/ldpath-functions-xml/src/test/resources/xml/data.n3
+++ /dev/null
@@ -1,102 +0,0 @@
-@prefix ex: <http://www.example.com/> .
-@prefix foo: <http://localhost/vcab#> .
-
-ex:Text a ex:Test;
- foo:formatted """A <em>quiz</em> is a form of <strong>game</strong> or <strong>mind sport</strong> in which the players <font size="tiny">(as individuals or in teams)</font> attempt to answer questions <strong>correctly</strong>.""".
-
-ex:Quiz a ex:Test;
- foo:xml """<?xml version="1.0" encoding="UTF-8"?>
-<!-- All changes here should be reflected in the actual test-data file data.n3 -->
-<quiz>
- <!-- Selected questions from http://www.sciencekids.co.nz/quizzes.html -->
- <question category="earth">
- <qline>What is the name of the largest ocean on earth?</qline>
- <answers>
- <answer correct="true">The Pacific Ocean</answer>
- <answer>The Atlantic Ocean</answer>
- <answer>The Indian Ocean</answer>
- </answers>
- </question>
- <question category="earth">
- <qline>What do you call molten rock before it has erupted?</qline>
- <answers>
- <answer correct="true">Magma</answer>
- <answer>Lava</answer>
- <answer>Hot-Stone</answer>
- </answers>
- </question>
- <question category="earth">
- <qline>The gemstone ruby is typically what color?</qline>
- <answers>
- <answer correct="true">Red</answer>
- <answer>Blue</answer>
- <answer>Green</answer>
- <answer>White</answer>
- </answers>
- </question>
- <question category="earth">
- <qline>What is the second most common gas found in the air we breathe?</qline>
- <answers>
- <answer>Carbon Dioxide</answer>
- <answer>Nitrogen</answer>
- <answer>Argon</answer>
- <answer correct="true">Oxygen</answer>
- </answers>
- </question>
- <question category="space">
- <qline>What planet is famous for its big red spot on it?</qline>
- <answers>
- <answer correct="true">Jupiter</answer>
- <answer>Uranus</answer>
- <answer>Venus</answer>
- <answer>Neptune</answer>
- </answers>
- </question>
- <question category="space">
- <qline>What is the name of Saturn’s largest moon?</qline>
- <answers>
- <answer correct="true">Titan</answer>
- <answer>Enceladus</answer>
- <answer>Rhea</answer>
- <answer>Europa</answer>
- <answer>Callisto</answer>
- <answer>Ganymede</answer>
- </answers>
- </question>
- <question category="space">
- <qline>What is the closest planet to the Sun?</qline>
- <answers>
- <answer correct="true">Mercury</answer>
- <answer>Venus</answer>
- <answer>Mars</answer>
- <answer>Saturn</answer>
- </answers>
- </question>
- <question category="math">
- <qline>What is the next prime number after 7?</qline>
- <answers>
- <answer>9</answer>
- <answer correct="true">11</answer>
- <answer>12</answer>
- <answer>15</answer>
- </answers>
- </question>
- <question category="math">
- <qline>How many sides does a nonagon have?</qline>
- <answers>
- <answer>7</answer>
- <answer>8</answer>
- <answer correct="true">9</answer>
- <answer>10</answer>
- </answers>
- </question>
- <question category="math">
- <qline>In statistics, the middle value of an ordered set of values is called what?</qline>
- <answers>
- <answer correct="true">The median</answer>
- <answer>The mean</answer>
- <answer>The average</answer>
- </answers>
- </question>
-</quiz>
-""".
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-functions-xml/src/test/resources/xml/quiz.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-xml/src/test/resources/xml/quiz.xml b/libraries/ldpath/ldpath-functions-xml/src/test/resources/xml/quiz.xml
deleted file mode 100644
index ac80657..0000000
--- a/libraries/ldpath/ldpath-functions-xml/src/test/resources/xml/quiz.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright (c) 2013 Salzburg Research.
- ~
- ~ 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.
- -->
-
-<!-- All changes here should be reflected in the actual test-data file data.n3 -->
-<quiz>
- <!-- Selected questions from http://www.sciencekids.co.nz/quizzes.html -->
- <question category="earth">
- <qline>What is the name of the largest ocean on earth?</qline>
- <answers>
- <answer correct="true">The Pacific Ocean</answer>
- <answer>The Atlantic Ocean</answer>
- <answer>The Indian Ocean</answer>
- </answers>
- </question>
- <question category="earth">
- <qline>What do you call molten rock before it has erupted?</qline>
- <answers>
- <answer correct="true">Magma</answer>
- <answer>Lava</answer>
- <answer>Hot-Stone</answer>
- </answers>
- </question>
- <question category="earth">
- <qline>The gemstone ruby is typically what color?</qline>
- <answers>
- <answer correct="true">Red</answer>
- <answer>Blue</answer>
- <answer>Green</answer>
- <answer>White</answer>
- </answers>
- </question>
- <question category="earth">
- <qline>What is the second most common gas found in the air we breathe?</qline>
- <answers>
- <answer>Carbon Dioxide</answer>
- <answer>Nitrogen</answer>
- <answer>Argon</answer>
- <answer correct="true">Oxygen</answer>
- </answers>
- </question>
- <question category="space">
- <qline>What planet is famous for its big red spot on it?</qline>
- <answers>
- <answer correct="true">Jupiter</answer>
- <answer>Uranus</answer>
- <answer>Venus</answer>
- <answer>Neptune</answer>
- </answers>
- </question>
- <question category="space">
- <qline>What is the name of Saturn’s largest moon?</qline>
- <answers>
- <answer correct="true">Titan</answer>
- <answer>Enceladus</answer>
- <answer>Rhea</answer>
- <answer>Europa</answer>
- <answer>Callisto</answer>
- <answer>Ganymede</answer>
- </answers>
- </question>
- <question category="space">
- <qline>What is the closest planet to the Sun?</qline>
- <answers>
- <answer correct="true">Mercury</answer>
- <answer>Venus</answer>
- <answer>Mars</answer>
- <answer>Saturn</answer>
- </answers>
- </question>
- <question category="math">
- <qline>What is the next prime number after 7?</qline>
- <answers>
- <answer>9</answer>
- <answer correct="true">11</answer>
- <answer>12</answer>
- <answer>15</answer>
- </answers>
- </question>
- <question category="math">
- <qline>How many sides does a nonagon have?</qline>
- <answers>
- <answer>7</answer>
- <answer>8</answer>
- <answer correct="true">9</answer>
- <answer>10</answer>
- </answers>
- </question>
- <question category="math">
- <qline>In statistics, the middle value of an ordered set of values is called what?</qline>
- <answers>
- <answer correct="true">The median</answer>
- <answer>The mean</answer>
- <answer>The average</answer>
- </answers>
- </question>
-</quiz>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template-linkeddata/src/main/java/at/newmedialab/ldpath/template/LDTemplate.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template-linkeddata/src/main/java/at/newmedialab/ldpath/template/LDTemplate.java b/libraries/ldpath/ldpath-template-linkeddata/src/main/java/at/newmedialab/ldpath/template/LDTemplate.java
deleted file mode 100644
index c12fa6c..0000000
--- a/libraries/ldpath/ldpath-template-linkeddata/src/main/java/at/newmedialab/ldpath/template/LDTemplate.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template;
-
-import at.newmedialab.ldpath.backend.linkeddata.LDMemoryBackend;
-import at.newmedialab.ldpath.backend.linkeddata.LDPersistentBackend;
-import at.newmedialab.ldpath.backend.sesame.SesameRepositoryBackend;
-import at.newmedialab.ldpath.template.engine.TemplateEngine;
-import ch.qos.logback.classic.Level;
-import freemarker.template.TemplateException;
-import org.apache.commons.cli.*;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Value;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.*;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class LDTemplate {
-
-
- private static final Logger log = LoggerFactory.getLogger(LDTemplate.class);
-
- public static void main(String[] args) {
- Options options = buildOptions();
-
- CommandLineParser parser = new PosixParser();
- try {
- CommandLine cmd = parser.parse( options, args);
-
- Level logLevel = Level.WARN;
-
- if(cmd.hasOption("loglevel")) {
- String logLevelName = cmd.getOptionValue("loglevel");
- if("DEBUG".equals(logLevelName.toUpperCase())) {
- logLevel = Level.DEBUG;
- } else if("INFO".equals(logLevelName.toUpperCase())) {
- logLevel = Level.INFO;
- } else if("WARN".equals(logLevelName.toUpperCase())) {
- logLevel = Level.WARN;
- } else if("ERROR".equals(logLevelName.toUpperCase())) {
- logLevel = Level.ERROR;
- } else {
- log.error("unsupported log level: {}",logLevelName);
- }
- }
-
- if(logLevel != null) {
- for(String logname : new String [] {"at","org","net","com"}) {
-
- ch.qos.logback.classic.Logger logger =
- (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logname);
- logger.setLevel(logLevel);
- }
- }
-
- File template = null;
- if(cmd.hasOption("template")) {
- template = new File(cmd.getOptionValue("template"));
- }
-
-
- SesameRepositoryBackend backend;
- if(cmd.hasOption("store")) {
- backend = new LDPersistentBackend(new File(cmd.getOptionValue("store")));
- } else {
- backend = new LDMemoryBackend();
- }
-
- Resource context = null;
- if(cmd.hasOption("context")) {
- context = backend.getRepository().getValueFactory().createURI(cmd.getOptionValue("context"));
- }
-
- BufferedWriter out = null;
- if(cmd.hasOption("out")) {
- File of = new File(cmd.getOptionValue("out"));
- if(of.canWrite()) {
- out = new BufferedWriter(new FileWriter(of));
- } else {
- log.error("cannot write to output file {}",of);
- System.exit(1);
- }
- } else {
- out = new BufferedWriter(new OutputStreamWriter(System.out));
- }
-
- if(backend != null && context != null && template != null) {
- TemplateEngine<Value> engine = new TemplateEngine<Value>(backend);
-
- engine.setDirectoryForTemplateLoading(template.getParentFile());
- engine.processFileTemplate(context,template.getName(),out);
- out.flush();
- }
- out.close();
-
- if(backend instanceof LDPersistentBackend) {
- ((LDPersistentBackend) backend).shutdown();
- }
-
-
- } catch (ParseException e) {
- System.err.println("invalid arguments");
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp( "LDQuery", options, true );
- } catch (FileNotFoundException e) {
- System.err.println("file or program could not be found");
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("LDQuery", options, true);
- } catch (IOException e) {
- System.err.println("could not access file");
- e.printStackTrace(System.err);
- } catch (TemplateException e) {
- System.err.println("error while processing template");
- e.printStackTrace(System.err);
- }
-
-
- }
-
- private static Options buildOptions() {
- Options result = new Options();
-
-
- Option context = OptionBuilder.withArgName("uri").hasArg().withDescription("URI of the context node to start from").create("context");
- context.setRequired(true);
- result.addOption(context);
-
- Option template = OptionBuilder.withArgName("file").hasArg().withDescription("the template file to apply to the context resource").create("template");
- template.setRequired(true);
- result.addOption(template);
-
- Option out = OptionBuilder.withArgName("file").hasArg().withDescription("file where to write the output; if not given, will write to stdout").create("out");
- out.setRequired(false);
- result.addOption(out);
-
- Option loglevel = OptionBuilder.withArgName("level").hasArg().withDescription("set the log level; default is 'warn'").create("loglevel");
- result.addOption(loglevel);
-
- Option store = OptionBuilder.withArgName("dir").hasArg().withDescription("cache the retrieved data in this directory").create("store");
- result.addOption(store);
-
-
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template-linkeddata/src/main/java/org/apache/marmotta/ldpath/template/LDTemplate.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template-linkeddata/src/main/java/org/apache/marmotta/ldpath/template/LDTemplate.java b/libraries/ldpath/ldpath-template-linkeddata/src/main/java/org/apache/marmotta/ldpath/template/LDTemplate.java
new file mode 100644
index 0000000..f197ea5
--- /dev/null
+++ b/libraries/ldpath/ldpath-template-linkeddata/src/main/java/org/apache/marmotta/ldpath/template/LDTemplate.java
@@ -0,0 +1,165 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * 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.apache.marmotta.ldpath.template;
+
+import ch.qos.logback.classic.Level;
+import freemarker.template.TemplateException;
+import org.apache.commons.cli.*;
+import org.apache.marmotta.ldpath.backend.linkeddata.LDMemoryBackend;
+import org.apache.marmotta.ldpath.backend.linkeddata.LDPersistentBackend;
+import org.apache.marmotta.ldpath.backend.sesame.SesameRepositoryBackend;
+import org.apache.marmotta.ldpath.template.engine.TemplateEngine;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Value;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class LDTemplate {
+
+
+ private static final Logger log = LoggerFactory.getLogger(LDTemplate.class);
+
+ public static void main(String[] args) {
+ Options options = buildOptions();
+
+ CommandLineParser parser = new PosixParser();
+ try {
+ CommandLine cmd = parser.parse( options, args);
+
+ Level logLevel = Level.WARN;
+
+ if(cmd.hasOption("loglevel")) {
+ String logLevelName = cmd.getOptionValue("loglevel");
+ if("DEBUG".equals(logLevelName.toUpperCase())) {
+ logLevel = Level.DEBUG;
+ } else if("INFO".equals(logLevelName.toUpperCase())) {
+ logLevel = Level.INFO;
+ } else if("WARN".equals(logLevelName.toUpperCase())) {
+ logLevel = Level.WARN;
+ } else if("ERROR".equals(logLevelName.toUpperCase())) {
+ logLevel = Level.ERROR;
+ } else {
+ log.error("unsupported log level: {}",logLevelName);
+ }
+ }
+
+ if(logLevel != null) {
+ for(String logname : new String [] {"at","org","net","com"}) {
+
+ ch.qos.logback.classic.Logger logger =
+ (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logname);
+ logger.setLevel(logLevel);
+ }
+ }
+
+ File template = null;
+ if(cmd.hasOption("template")) {
+ template = new File(cmd.getOptionValue("template"));
+ }
+
+
+ SesameRepositoryBackend backend;
+ if(cmd.hasOption("store")) {
+ backend = new LDPersistentBackend(new File(cmd.getOptionValue("store")));
+ } else {
+ backend = new LDMemoryBackend();
+ }
+
+ Resource context = null;
+ if(cmd.hasOption("context")) {
+ context = backend.getRepository().getValueFactory().createURI(cmd.getOptionValue("context"));
+ }
+
+ BufferedWriter out = null;
+ if(cmd.hasOption("out")) {
+ File of = new File(cmd.getOptionValue("out"));
+ if(of.canWrite()) {
+ out = new BufferedWriter(new FileWriter(of));
+ } else {
+ log.error("cannot write to output file {}",of);
+ System.exit(1);
+ }
+ } else {
+ out = new BufferedWriter(new OutputStreamWriter(System.out));
+ }
+
+ if(backend != null && context != null && template != null) {
+ TemplateEngine<Value> engine = new TemplateEngine<Value>(backend);
+
+ engine.setDirectoryForTemplateLoading(template.getParentFile());
+ engine.processFileTemplate(context,template.getName(),out);
+ out.flush();
+ }
+ out.close();
+
+ if(backend instanceof LDPersistentBackend) {
+ ((LDPersistentBackend) backend).shutdown();
+ }
+
+
+ } catch (ParseException e) {
+ System.err.println("invalid arguments");
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp( "LDQuery", options, true );
+ } catch (FileNotFoundException e) {
+ System.err.println("file or program could not be found");
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp("LDQuery", options, true);
+ } catch (IOException e) {
+ System.err.println("could not access file");
+ e.printStackTrace(System.err);
+ } catch (TemplateException e) {
+ System.err.println("error while processing template");
+ e.printStackTrace(System.err);
+ }
+
+
+ }
+
+ private static Options buildOptions() {
+ Options result = new Options();
+
+
+ Option context = OptionBuilder.withArgName("uri").hasArg().withDescription("URI of the context node to start from").create("context");
+ context.setRequired(true);
+ result.addOption(context);
+
+ Option template = OptionBuilder.withArgName("file").hasArg().withDescription("the template file to apply to the context resource").create("template");
+ template.setRequired(true);
+ result.addOption(template);
+
+ Option out = OptionBuilder.withArgName("file").hasArg().withDescription("file where to write the output; if not given, will write to stdout").create("out");
+ out.setRequired(false);
+ result.addOption(out);
+
+ Option loglevel = OptionBuilder.withArgName("level").hasArg().withDescription("set the log level; default is 'warn'").create("loglevel");
+ result.addOption(loglevel);
+
+ Option store = OptionBuilder.withArgName("dir").hasArg().withDescription("cache the retrieved data in this directory").create("store");
+ result.addOption(store);
+
+
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/pom.xml b/libraries/ldpath/ldpath-template/pom.xml
index ecf687d..75df065 100644
--- a/libraries/ldpath/ldpath-template/pom.xml
+++ b/libraries/ldpath/ldpath-template/pom.xml
@@ -65,10 +65,10 @@
<!-- Enable this for including your enhancement chain configuration -->
<!-- <Install-Path>config</Install-Path> -->
<Export-Package>
- at.newmedialab.ldpath.template;version=${project.version},
- at.newmedialab.ldpath.template.engine;version=${project.version},
- at.newmedialab.ldpath.template.model;version=${project.version},
- at.newmedialab.ldpath.template.util;version=${project.version}
+ org.apache.marmotta.ldpath.template;version=${project.version},
+ org.apache.marmotta.ldpath.template.engine;version=${project.version},
+ org.apache.marmotta.ldpath.template.model;version=${project.version},
+ org.apache.marmotta.ldpath.template.util;version=${project.version}
</Export-Package>
<!--
<_exportcontents>freemarker.*;version="2.3.19"</_exportcontents>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathDirective.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathDirective.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathDirective.java
deleted file mode 100644
index fea20e6..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathDirective.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.engine;
-
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.exception.LDPathParseException;
-import at.newmedialab.ldpath.model.Constants;
-import at.newmedialab.ldpath.template.model.freemarker.TemplateNodeModel;
-import at.newmedialab.ldpath.template.model.freemarker.TemplateStackModel;
-import at.newmedialab.ldpath.template.model.freemarker.TemplateWrapperModel;
-import at.newmedialab.ldpath.template.model.transformers.*;
-import at.newmedialab.ldpath.template.util.FormatUtil;
-import freemarker.core.Environment;
-import freemarker.template.*;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A directive for inserting values retrieved with LDPath. It can be used in several forms:
- * <p/>
- * <strong>Value Insertion (without body):</strong><br/>
- * Allows inserting the value of a path expression. The path expression should specify an XML schema type for the
- * type conversion. If no type is given, string conversion is assumed. If the expression would return several values,
- * only the first result is taken.
- * <p/>
- * <code>
- * <@ldpath path="... :: xsd:type">
- * </code>
- * <p/>
- * <strong>Value Iteration (with body):</strong>
- * Allows iterating over result nodes of a path expression. Further path expressions can be used to select the
- * values of each result node.
- * <p/>
- * <code>
- * <@ldpath path="..."><br/>
- * ...<br/>
- * <@ldpath path="..."><br/>
- * ...<br/>
- * </@ldpath>
- * </code>
- * <p/>
- * If a loop variable is given, it will be bound to the context node. The context node is also implicitly available
- * as the variable "context".
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class LDPathDirective<Node> implements TemplateDirectiveModel {
-
-
- private LDPath<Node> ldpath;
- private RDFBackend<Node> backend;
-
- public LDPathDirective(RDFBackend<Node> backend) {
- this.ldpath = new LDPath<Node>(backend);
- this.backend = backend;
-
- // register custom freemarker transformers for the parser so we get the results immediately in the freemarker model
- ldpath.registerTransformer(Constants.NS_XSD + "string", new TemplateScalarTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "decimal", new TemplateLongTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "integer", new TemplateIntegerTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "long", new TemplateLongTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "short", new TemplateIntegerTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "double", new TemplateDoubleTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "float", new TemplateFloatTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "dateTime", new TemplateDateTransformer<Node>(TemplateDateModel.DATETIME));
- ldpath.registerTransformer(Constants.NS_XSD + "date", new TemplateDateTransformer<Node>(TemplateDateModel.DATE));
- ldpath.registerTransformer(Constants.NS_XSD + "time", new TemplateDateTransformer<Node>(TemplateDateModel.TIME));
- ldpath.registerTransformer(Constants.NS_XSD + "boolean", new TemplateBooleanTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "anyURI", new TemplateScalarTransformer<Node>());
-
- }
-
- /**
- * Executes this user-defined directive; called by FreeMarker when the user-defined
- * directive is called in the template.
- *
- * @param env the current processing environment. Note that you can access
- * the output {@link java.io.Writer Writer} by {@link freemarker.core.Environment#getOut()}.
- * @param params the parameters (if any) passed to the directive as a
- * map of key/value pairs where the keys are {@link String}-s and the
- * values are {@link freemarker.template.TemplateModel} instances. This is never
- * <code>null</code>. If you need to convert the template models to POJOs,
- * you can use the utility methods in the {@link freemarker.template.utility.DeepUnwrap} class.
- * @param loopVars an array that corresponds to the "loop variables", in
- * the order as they appear in the directive call. ("Loop variables" are out-parameters
- * that are available to the nested body of the directive; see in the Manual.)
- * You set the loop variables by writing this array. The length of the array gives the
- * number of loop-variables that the caller has specified.
- * Never <code>null</code>, but can be a zero-length array.
- * @param body an object that can be used to render the nested content (body) of
- * the directive call. If the directive call has no nested content (i.e., it is like
- * [@myDirective /] or [@myDirective][/@myDirective]), then this will be
- * <code>null</code>.
- * @throws freemarker.template.TemplateException
- *
- * @throws java.io.IOException
- */
- @Override
- public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
- TemplateStackModel contextStack = (TemplateStackModel)env.getVariable("context");
- if(contextStack == null || contextStack.empty()) {
- throw new TemplateModelException("error; no context node available");
- }
- TemplateNodeModel<Node> context = (TemplateNodeModel<Node>)contextStack.peek();
-
- SimpleScalar pathScalar = (SimpleScalar)params.get("path");
- if(pathScalar == null) {
- throw new TemplateException("the directive has been called without a path parameter",env);
- }
- String path = pathScalar.getAsString();
-
- TemplateWrapperModel<Map<String,String>> namespacesWrapped = (TemplateWrapperModel<Map<String,String>>)env.getGlobalVariable("namespaces");
-
- Map<String,String> namespaces;
- if(namespacesWrapped == null) {
- namespaces = new HashMap<String, String>();
- namespacesWrapped = new TemplateWrapperModel<Map<String, String>>(new HashMap<String, String>());
- env.setGlobalVariable("namespaces",namespacesWrapped);
- } else {
- namespaces = namespacesWrapped.getAdaptedObject(Map.class);
- }
-
-
- if(body == null) { // value insertion
- if(!path.contains("::")) {
- path = path + ":: xsd:string";
- }
- try {
- Collection results = ldpath.pathTransform(context.getNode(),path,namespaces);
-
- if(results.size() > 0) {
- Object result = results.iterator().next();
-
- if(result instanceof TemplateNumberModel) {
- env.getOut().write(FormatUtil.formatNumber( ((TemplateNumberModel)result).getAsNumber() ));
- } else if(result instanceof TemplateDateModel) {
- switch (((TemplateDateModel)result).getDateType()) {
- case TemplateDateModel.DATE:
- env.getOut().write(FormatUtil.formatDate(((TemplateDateModel)result).getAsDate()));
- break;
- case TemplateDateModel.TIME:
- env.getOut().write(FormatUtil.formatTime(((TemplateDateModel)result).getAsDate()));
- break;
- case TemplateDateModel.DATETIME:
- env.getOut().write(FormatUtil.formatDateTime(((TemplateDateModel)result).getAsDate()));
- break;
- default:
- env.getOut().write(FormatUtil.formatDateTime(((TemplateDateModel)result).getAsDate()));
- }
- } else if(result instanceof TemplateScalarModel) {
- env.getOut().write( ((TemplateScalarModel)result).getAsString() );
- } else if(result instanceof TemplateBooleanModel) {
- env.getOut().write( Boolean.toString(((TemplateBooleanModel)result).getAsBoolean()) );
- }
-
- } // else write nothing
-
-
- } catch (LDPathParseException e) {
- throw new TemplateException("invalid path for ldpath directive: "+path,e,env);
- }
-
- } else {
- try {
- for(Node node : ldpath.pathQuery(context.getNode(),path,namespaces)) {
- contextStack.push(new TemplateNodeModel<Node>(node, backend));
-
- if(loopVars.length > 0) {
- loopVars[0] = new TemplateNodeModel<Node>(node,backend);
- }
-
- body.render(env.getOut());
-
- contextStack.pop();
- }
- } catch(LDPathParseException ex) {
- throw new TemplateException("invalid path for ldpath directive: "+path,ex,env);
- }
-
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathMethod.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathMethod.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathMethod.java
deleted file mode 100644
index 6fba273..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathMethod.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.engine;
-
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.exception.LDPathParseException;
-import at.newmedialab.ldpath.model.Constants;
-import at.newmedialab.ldpath.template.model.freemarker.TemplateNodeModel;
-import at.newmedialab.ldpath.template.model.freemarker.TemplateStackModel;
-import at.newmedialab.ldpath.template.model.freemarker.TemplateWrapperModel;
-import at.newmedialab.ldpath.template.model.transformers.*;
-import freemarker.core.Environment;
-import freemarker.template.TemplateDateModel;
-import freemarker.template.TemplateMethodModel;
-import freemarker.template.TemplateModelException;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class LDPathMethod<Node> implements TemplateMethodModel {
-
-
- private LDPath<Node> ldpath;
- private RDFBackend<Node> backend;
-
- public LDPathMethod(RDFBackend<Node> backend) {
- this.ldpath = new LDPath<Node>(backend);
- this.backend = backend;
-
- // register custom freemarker transformers for the parser so we get the results immediately in the freemarker model
- ldpath.registerTransformer(Constants.NS_XSD + "string", new TemplateScalarTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "decimal", new TemplateLongTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "integer", new TemplateIntegerTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "long", new TemplateLongTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "short", new TemplateIntegerTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "double", new TemplateDoubleTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "float", new TemplateFloatTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "dateTime", new TemplateDateTransformer<Node>(TemplateDateModel.DATETIME));
- ldpath.registerTransformer(Constants.NS_XSD + "date", new TemplateDateTransformer<Node>(TemplateDateModel.DATE));
- ldpath.registerTransformer(Constants.NS_XSD + "time", new TemplateDateTransformer<Node>(TemplateDateModel.TIME));
- ldpath.registerTransformer(Constants.NS_XSD + "boolean", new TemplateBooleanTransformer<Node>());
- ldpath.registerTransformer(Constants.NS_XSD + "anyURI", new TemplateScalarTransformer<Node>());
-
- }
-
-
- /**
- * Executes a method call. All arguments passed to the method call are
- * coerced to strings before being passed, if the FreeMarker rules allow
- * the coercion. If some of the passed arguments can not be coerced to a
- * string, an exception will be raised in the engine and the method will
- * not be called. If your method would like to act on actual data model
- * objects instead of on their string representations, implement the
- * {@link freemarker.template.TemplateMethodModelEx} instead.
- *
- * @param arguments a <tt>List</tt> of <tt>String</tt> objects
- * containing the values of the arguments passed to the method.
- * @return the return value of the method, or null. If the returned value
- * does not implement {@link freemarker.template.TemplateModel}, it will be automatically
- * wrapped using the {@link freemarker.core.Environment#getObjectWrapper() environment
- * object wrapper}.
- */
- @Override
- public Object exec(List arguments) throws TemplateModelException {
- Environment env = Environment.getCurrentEnvironment();
-
-
- TemplateStackModel contextStack = (TemplateStackModel)env.getVariable("context");
- if(contextStack == null || contextStack.empty()) {
- throw new TemplateModelException("error; no context node available");
- }
- TemplateNodeModel<Node> context = (TemplateNodeModel<Node>)contextStack.peek();
-
- String path;
- if(arguments.size() != 1) {
- throw new TemplateModelException("the directive has been called without a path parameter");
- } else {
- path = (String)arguments.get(0);
- if(!path.contains("::")) {
- path = path + " :: xsd:string";
- }
- }
-
- TemplateWrapperModel<Map<String,String>> namespacesWrapped = (TemplateWrapperModel<Map<String,String>>)env.getGlobalVariable("namespaces");
-
- Map<String,String> namespaces;
- if(namespacesWrapped == null) {
- namespaces = new HashMap<String, String>();
- namespacesWrapped = new TemplateWrapperModel<Map<String, String>>(new HashMap<String, String>());
- env.setGlobalVariable("namespaces",namespacesWrapped);
- } else {
- namespaces = namespacesWrapped.getAdaptedObject(Map.class);
- }
-
- if(arguments.size() != 1) {
- throw new TemplateModelException("wrong number of arguments for method call");
- }
-
- try {
- Collection result = ldpath.pathTransform(context.getNode(),path,namespaces);
- if(result.size() > 0) {
- return result;
- } else {
- return null;
- }
- } catch (LDPathParseException e) {
- throw new TemplateModelException("could not parse path expression '"+path+"'",e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/NamespaceDirective.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/NamespaceDirective.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/NamespaceDirective.java
deleted file mode 100644
index f17b09a..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/NamespaceDirective.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.engine;
-
-import at.newmedialab.ldpath.template.model.freemarker.TemplateWrapperModel;
-import freemarker.core.Environment;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateScalarModel;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class NamespaceDirective implements TemplateDirectiveModel {
-
-
- public NamespaceDirective() {
- }
-
- /**
- * Executes this user-defined directive; called by FreeMarker when the user-defined
- * directive is called in the template.
- *
- * @param env the current processing environment. Note that you can access
- * the output {@link java.io.Writer Writer} by {@link freemarker.core.Environment#getOut()}.
- * @param params the parameters (if any) passed to the directive as a
- * map of key/value pairs where the keys are {@link String}-s and the
- * values are {@link freemarker.template.TemplateModel} instances. This is never
- * <code>null</code>. If you need to convert the template models to POJOs,
- * you can use the utility methods in the {@link freemarker.template.utility.DeepUnwrap} class.
- * @param loopVars an array that corresponds to the "loop variables", in
- * the order as they appear in the directive call. ("Loop variables" are out-parameters
- * that are available to the nested body of the directive; see in the Manual.)
- * You set the loop variables by writing this array. The length of the array gives the
- * number of loop-variables that the caller has specified.
- * Never <code>null</code>, but can be a zero-length array.
- * @param body an object that can be used to render the nested content (body) of
- * the directive call. If the directive call has no nested content (i.e., it is like
- * [@myDirective /] or [@myDirective][/@myDirective]), then this will be
- * <code>null</code>.
- * @throws freemarker.template.TemplateException
- *
- * @throws java.io.IOException
- */
- @Override
- public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
- TemplateWrapperModel<Map<String,String>> namespacesWrapped = (TemplateWrapperModel<Map<String,String>>)env.getGlobalVariable("namespaces");
-
- Map<String,String> namespaces;
- if(namespacesWrapped == null) {
- namespaces = new HashMap<String, String>();
- namespacesWrapped = new TemplateWrapperModel<Map<String, String>>(namespaces);
- env.setGlobalVariable("namespaces",namespacesWrapped);
- } else {
- namespaces = namespacesWrapped.getAdaptedObject(Map.class);
- }
-
-
- Iterator paramIter = params.entrySet().iterator();
- while (paramIter.hasNext()) {
- Map.Entry ent = (Map.Entry) paramIter.next();
-
- String paramName = (String) ent.getKey();
- TemplateModel paramValue = (TemplateModel) ent.getValue();
-
- if(paramValue instanceof TemplateScalarModel) {
- String uri = ((TemplateScalarModel)paramValue).getAsString();
-
- try {
- URI test = new URI(uri);
- namespaces.put(paramName,test.toString());
- } catch (URISyntaxException e) {
- throw new TemplateModelException("invalid namespace URI '"+uri+"'",e);
- }
- }
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/TemplateEngine.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/TemplateEngine.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/TemplateEngine.java
deleted file mode 100644
index 6de4078..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/TemplateEngine.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.engine;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.template.model.freemarker.TemplateNodeModel;
-import at.newmedialab.ldpath.template.model.freemarker.TemplateStackModel;
-import freemarker.cache.TemplateLoader;
-import freemarker.template.Configuration;
-import freemarker.template.DefaultObjectWrapper;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class TemplateEngine<Node> {
-
- private Configuration freemarker;
-
- private RDFBackend<Node> backend;
-
- public TemplateEngine(RDFBackend<Node> backend) {
-
- this.backend = backend;
-
- freemarker = new Configuration();
- freemarker.setObjectWrapper(new DefaultObjectWrapper());
-
-
- }
-
-
- /**
- * Allow setting a different template loader. Custom template loaders can be implemented in addition to
- * those provided by FreeMarker.
- *
- * @param loader
- */
- public void setTemplateLoader(TemplateLoader loader) {
- freemarker.setTemplateLoader(loader);
- }
-
-
- public void setDirectoryForTemplateLoading(File dir) throws IOException {
- freemarker.setDirectoryForTemplateLoading(dir);
- }
-
- public void setServletContextForTemplateLoading(Object sctxt, String path) {
- freemarker.setServletContextForTemplateLoading(sctxt, path);
- }
-
- public void setClassForTemplateLoading(Class clazz, String pathPrefix) {
- freemarker.setClassForTemplateLoading(clazz, pathPrefix);
- }
-
-
- /**
- * Process the template with the given name forn the given context node and write the result to the given
- * output writer. The way the template is retrieved depends on the template loader, which can be set using the
- * setTemplateLoader() method.
- *
- * @param context the initial context node to apply this template to
- * @param templateName the name of the template
- * @param out where to write the results
- * @throws IOException
- * @throws TemplateException
- */
- public void processFileTemplate(Node context, String templateName, Writer out) throws IOException, TemplateException {
- processTemplate(context,freemarker.getTemplate(templateName),null,out);
- }
-
- /**
- * Process the template with the given name forn the given context node and write the result to the given
- * output writer. The initial environment is passed over to the invocation of the template. The way the template
- * is retrieved depends on the template loader, which can be set using the setTemplateLoader() method.
- *
- * @param context the initial context node to apply this template to
- * @param templateName the name of the template
- * @param initialEnv an initial root environment for processing the template
- * @param out where to write the results
- * @throws IOException
- * @throws TemplateException
- */
- public void processFileTemplate(Node context, String templateName, Map initialEnv, Writer out) throws IOException, TemplateException {
- processTemplate(context,freemarker.getTemplate(templateName),initialEnv,out);
- }
-
-
- private void processTemplate(Node context, Template template, Map initialEnv, Writer out) throws IOException, TemplateException {
- Map root = new HashMap();
-
- if(initialEnv != null) {
- for(Map.Entry entry : (Set<Map.Entry>) initialEnv.entrySet()) {
- root.put(entry.getKey(), entry.getValue());
- }
- }
-
- root.put("namespace", new NamespaceDirective());
- root.put("evalLDPath",new LDPathMethod(backend));
- root.put("ldpath",new LDPathDirective(backend));
-
- TemplateStackModel contexts = new TemplateStackModel();
- contexts.push(new TemplateNodeModel(context,backend));
- root.put("context",contexts);
-
- template.process(root,out);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateNodeModel.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateNodeModel.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateNodeModel.java
deleted file mode 100644
index 47ea772..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateNodeModel.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.model.freemarker;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import freemarker.template.*;
-
-/**
- * A custom freemarker model to represent RDF nodes (implementation independent, generic)
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class TemplateNodeModel<Node> implements TemplateModel, TemplateHashModel, AdapterTemplateModel {
-
- private Node node;
- private RDFBackend<Node> backend;
-
- public TemplateNodeModel(Node node, RDFBackend<Node> backend) {
- this.node = node;
- this.backend = backend;
- }
-
- public Node getNode() {
- return node;
- }
-
- /**
- * Gets a <tt>TemplateModel</tt> from the hash.
- *
- * @param key the name by which the <tt>TemplateModel</tt>
- * is identified in the template.
- * @return the <tt>TemplateModel</tt> referred to by the key,
- * or null if not found.
- */
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- if( ("uri".equals(key) && backend.isURI(node)) || ("content".equals(key) && backend.isLiteral(node))) {
- return new TemplateScalarModel() {
- @Override
- public String getAsString() throws TemplateModelException {
- return backend.stringValue(node);
- }
- };
- } else if("language".equals(key) && backend.isLiteral(node)) {
- return new TemplateScalarModel() {
- @Override
- public String getAsString() throws TemplateModelException {
- return backend.getLiteralLanguage(node).getLanguage();
- }
- };
- } else if("type".equals(key) && backend.isLiteral(node)) {
- return new TemplateScalarModel() {
- @Override
- public String getAsString() throws TemplateModelException {
- return backend.getLiteralType(node).toString();
- }
- };
- } else if("id".equals(key) && backend.isBlank(node)) {
- return new TemplateScalarModel() {
- @Override
- public String getAsString() throws TemplateModelException {
- return backend.stringValue(node);
- }
- };
- }
- return null;
- }
-
- @Override
- public boolean isEmpty() throws TemplateModelException {
- return false;
- }
-
- /**
- * Retrieves the underlying object, or some other object semantically
- * equivalent to its value narrowed by the class hint.
- *
- * @param hint the desired class of the returned value. An implementation
- * should make reasonable effort to retrieve an object of the requested
- * class, but if that is impossible, it must at least return the underlying
- * object as-is. As a minimal requirement, an implementation must always
- * return the exact underlying object when
- * <tt>hint.isInstance(underlyingObject) == true</tt> holds. When called
- * with <tt>java.lang.Object.class</tt>, it should return a generic Java
- * object (i.e. if the model is wrapping a scripting lanugage object that is
- * further wrapping a Java object, the deepest underlying Java object should
- * be returned).
- * @return the underlying object, or its value accommodated for the hint
- * class.
- */
- @Override
- public Object getAdaptedObject(Class hint) {
- return node;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateStackModel.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateStackModel.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateStackModel.java
deleted file mode 100644
index 3820a55..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateStackModel.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.model.freemarker;
-
-import freemarker.template.TemplateModel;
-
-import java.util.Stack;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class TemplateStackModel implements TemplateModel {
-
- private Stack<TemplateModel> stack;
-
- public TemplateStackModel() {
- stack = new Stack<TemplateModel>();
- }
-
-
- public TemplateModel push(TemplateModel item) {
- return stack.push(item);
- }
-
- public TemplateModel pop() {
- return stack.pop();
- }
-
- public TemplateModel peek() {
- return stack.peek();
- }
-
- public boolean empty() {
- return stack.empty();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateWrapperModel.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateWrapperModel.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateWrapperModel.java
deleted file mode 100644
index d8006d1..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateWrapperModel.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.model.freemarker;
-
-import freemarker.template.AdapterTemplateModel;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class TemplateWrapperModel<T> implements AdapterTemplateModel {
-
- private T object;
-
- public TemplateWrapperModel(T object) {
- this.object = object;
- }
-
- /**
- * Retrieves the underlying object, or some other object semantically
- * equivalent to its value narrowed by the class hint.
- *
- * @param hint the desired class of the returned value. An implementation
- * should make reasonable effort to retrieve an object of the requested
- * class, but if that is impossible, it must at least return the underlying
- * object as-is. As a minimal requirement, an implementation must always
- * return the exact underlying object when
- * <tt>hint.isInstance(underlyingObject) == true</tt> holds. When called
- * with <tt>java.lang.Object.class</tt>, it should return a generic Java
- * object (i.e. if the model is wrapping a scripting lanugage object that is
- * further wrapping a Java object, the deepest underlying Java object should
- * be returned).
- * @return the underlying object, or its value accommodated for the hint
- * class.
- */
- @Override
- public T getAdaptedObject(Class hint) {
- return object;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateBooleanTransformer.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateBooleanTransformer.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateBooleanTransformer.java
deleted file mode 100644
index 8bd5a88..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateBooleanTransformer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.model.transformers;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.transformers.NodeTransformer;
-import at.newmedialab.ldpath.model.transformers.BooleanTransformer;
-import freemarker.template.TemplateBooleanModel;
-import freemarker.template.TemplateModelException;
-
-/**
- * Transform a node into the freemarker boolean type (TemplateBooleanModel).
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class TemplateBooleanTransformer<Node> implements NodeTransformer<TemplateBooleanModel,Node> {
-
- private BooleanTransformer<Node> delegate;
-
- public TemplateBooleanTransformer() {
- delegate = new BooleanTransformer<Node>();
- }
-
- /**
- * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
- * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
- * carrying out the transformation.
- *
- * @param node
- * @return
- */
- @Override
- public TemplateBooleanModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
- return new TemplateBooleanModel() {
- @Override
- public boolean getAsBoolean() throws TemplateModelException {
- return delegate.transform(nodeRDFBackend,node);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDateTransformer.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDateTransformer.java b/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDateTransformer.java
deleted file mode 100644
index 278f721..0000000
--- a/libraries/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDateTransformer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * 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 at.newmedialab.ldpath.template.model.transformers;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.transformers.NodeTransformer;
-import at.newmedialab.ldpath.model.transformers.DateTimeTransformer;
-import freemarker.template.TemplateDateModel;
-import freemarker.template.TemplateModelException;
-
-import java.util.Date;
-
-/**
- * Transform a node into the freemarker date type ({@link freemarker.template.TemplateDateModel}).
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class TemplateDateTransformer<Node> implements NodeTransformer<TemplateDateModel,Node> {
-
- private DateTimeTransformer<Node> delegate;
-
- private int type = TemplateDateModel.UNKNOWN;
-
- public TemplateDateTransformer() {
- delegate = new DateTimeTransformer<Node>();
- }
-
- public TemplateDateTransformer(int type) {
- this.type = type;
- }
-
- /**
- * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
- * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
- * carrying out the transformation.
- *
- * @param node
- * @return
- */
- @Override
- public TemplateDateModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
- return new TemplateDateModel() {
- @Override
- public Date getAsDate() throws TemplateModelException {
- return delegate.transform(nodeRDFBackend, node);
- }
-
- @Override
- public int getDateType() {
- return type;
- }
- };
- }
-}