+
+
+ A Java based compilercompiler is used to generate the parser (javacc-4.x).
+
+
+ Using the parser is quite simple :
+
+
+
+ ...
+
+ DependencyParser dp = new DependencyParser();
+ dp.setTooldescription(...); // from a file or from a resource stream or DOM element
+ ParameterWrapper pw = new ParameterWrapper();
+
+ pw.setParameter(...) // from a file, a Properties object or DOM element
+ dp.setParameterWrapper(pw);
+
+ dp.setFunctionId(...); // id of function within tooldescription to be evaluted
+
+
+ // parse Dependency string and generate tree
+ Node node = dp.generate();
+
+ // evaluate parameter set against dependency tree
+ if (!node.evaluate()) {
+ // get list of missing parameter id's
+ List missingParamIdList = node.getMissingConstraints()
+ }
+
+
+ ...
+
+
+
+
+
+*/
+public class DependencyParser {
+
+
+ private Element tooldescription = null;
+ private ParameterWrapper parameterwrapper = null;
+ private String fct_id = null;
+
+ private final String ToolDescriptionNS = "bibiserv:de.unibi.techfak.bibiserv.cms";
+
+
+
+
+ /* ---------------------- public methods ------------------------------ */
+
+
+ public DependencyParser(){
+ this(new StringReader(""));
+ }
+
+ /**
+ * Set a reference to a tooldescripton DOM element to current parser instance.
+ *
+ * @param Element tooldescription
+ */
+ public void setTooldescription(Element tooldescription){
+ this.tooldescription = tooldescription;
+ }
+
+
+ /**
+ * Read tooldescription from a file.
+ *
+ * @param file
+ * @throws DependencyException
+ * @throws FileNotFoundException
+ */
+ public void setTooldescription(File file) throws DependencyException, FileNotFoundException {
+ setTooldescription(new FileInputStream(file));
+ }
+
+ /**
+ * Read Tooldescription from an Inputstream.
+ *
+ * @param is
+ * @throws DependencyException
+ */
+ public void setTooldescription(InputStream is) throws DependencyException{
+ try {
+ /* read param from (xml-file)*/
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ /* read description from file */
+ tooldescription = db.parse(is).getDocumentElement();
+
+ } catch(Exception e){
+ throw new DependencyException(e,DependencyExceptionEnum.setTooldescriptionException,"");
+ }
+ }
+
+ public void setFunctionId(String id) {
+ this.fct_id = id;
+ }
+
+ /** Set a ParameterWrapper object */
+ public void setParameterWrapper(ParameterWrapper parameterwrapper){
+ this.parameterwrapper = parameterwrapper;
+ }
+
+ /**
+ * Extract dependency strings from tooldescription and set function id.
+ *
+ * @return List of Dependency Strings
+ */
+ public List getDependencyStrings() throws DependencyException {
+
+
+ if (fct_id == null) {
+ throw new DependencyException("No fct_id set!", DependencyExceptionEnum.noFunctionId, "");
+ }
+ if (tooldescription == null) {
+ throw new DependencyException("No ToolDescription (runnableitem) element set!", DependencyExceptionEnum.noRunnableItem, "");
+ }
+
+ /* extract dependency defintion*/
+ try {
+ XPathFactory xpf = XPathFactory.newInstance();
+ XPath xpath = xpf.newXPath();
+ xpath.setNamespaceContext(new MyNSContext());
+ NodeList nl = (NodeList) xpath.evaluate("//bibi:dependency[@id=//bibi:function[@id='" + fct_id + "']/bibi:depref/@ref]/bibi:dependencyDefinition", tooldescription, XPathConstants.NODESET);
+
+ List l = new ArrayList();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Element e = (Element) nl.item(i);
+ if (e != null) {
+ String dep = e.getTextContent();
+ if (dep != null && !dep.isEmpty()) {
+ l.add(dep);
+ }
+ }
+ }
+ return l;
+ } catch (Exception e) {
+ throw new DependencyException("Exception occured while extraxting dependency defintion from function [@id='" + fct_id + "']!", e, DependencyExceptionEnum.dependencyExtractionError, fct_id);
+ }
+
+
+
+ }
+
+
+ /**
+ * Initiate a parser run and return true if expression is valid, false
+ * otherwise
+ *
+ * @return Returns true in the case the expression is evaluate to true,
+ * false otherwise
+ * @throws ParseException if the expression is false
+ */
+ public Node generate() throws ParseException, DependencyException {
+
+ if (parameterwrapper == null) {
+ throw new DependencyException("No parameter wrapper set!", DependencyExceptionEnum.noParameterWrapper, "");
+ }
+
+
+ List depdeflist = getDependencyStrings();
+
+ /* if list is empty return Empty Node */
+ if (depdeflist.isEmpty()) {
+ return new EmptyNode();
+ }
+
+
+ /* (re) initalize Parser */
+ ReInit(new StringReader(depdeflist.get(0)));
+ /* parse input and generate Treerepresentation */
+ Node n = fct();
+
+
+
+ for (int i = 1; i < depdeflist.size(); i++) {
+ /* (re) initalize Parser */
+ ReInit(new StringReader(depdeflist.get(1)));
+ n = new LogOpNode(OpNode.Operations.AND, n, fct());
+ }
+ return n;
+ }
+
+ /* ---------------------- private methods ----------------------------- */
+ private Element getElementById(Element elem, String id){
+ try {
+ XPathFactory xpf = XPathFactory.newInstance();
+ XPath xpath = xpf.newXPath();
+ return (Element)xpath.evaluate("//*[@id='"+id+"']", elem ,XPathConstants.NODE);
+ } catch (Exception e){
+ System.err.println(e.getMessage());
+ return null;
+ }
+
+ }
+
+
+ /* ------------------------ inner class ------------------------------- */
+
+ /** Very simple Implementation for a NamespaceContext. MyNSContext knows only
+ one Prefix "bibi..." URI "bibiserv:de.unibi.techfak.bibiserv.cms" combination. */
+
+ class MyNSContext implements NamespaceContext{
+
+ public String getNamespaceURI(String prefix) {
+ if (prefix.startsWith("bibi") ){
+ return ToolDescriptionNS ;
+ }
+ throw new UnsupportedOperationException("Unsupported Prefix '"+prefix+"'.");
+ }
+
+ public String getPrefix(String namespaceURI) {
+ if (namespaceURI.equals(ToolDescriptionNS)) {
+ return "bibi";
+ }
+ throw new UnsupportedOperationException("Unsupported URI : '"+namespaceURI+"'.");
+ }
+
+ public Iterator getPrefixes(String namespaceURI) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+}
+PARSER_END(DependencyParser)
+
+
+/* The defintion of Token, Terminal and Non-Terminal Symbols follows the
+ BNF Notation. I used the javacc feature to integrate Java code to
+ parse and interpret on the fly ... */
+
+
+SKIP :
+{
+ " "
+ | "\t"
+ | "\n"
+ | "\r"
+}
+
+
+TOKEN :
+{
+
+|
+|
+}
+
+
+
+
+Node fct() :
+{
+ Node a;
+}
+{
+ (a=xor()|a=not()|a=or()|a=and()|a=impl()|a=logeq()|a=eq()|a=ne()|a=le()|a=ge()|a=lt()|a=gt()|"def" "(" a=id() ")")
+ {
+ return a;
+ }
+}
+
+Node and() :
+{
+ LogOpNode n = new LogOpNode(OpNode.Operations.AND);
+ Node a,b;
+}
+{
+ "and" "(" a=fct() "," b=fct() ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+Node or() :
+{
+ LogOpNode n = new LogOpNode(OpNode.Operations.OR);
+ Node a,b;
+}
+{
+ "or" "(" a=fct() "," b=fct() ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+Node not() :
+{
+ LogOpNode n = new LogOpNode(OpNode.Operations.NOT);
+ Node a;
+}
+{
+ "not" "(" a=fct() ")"
+ {
+ n.add_A(a);
+ return n;
+ }
+
+}
+
+Node xor() :
+{
+ LogOpNode n = new LogOpNode(OpNode.Operations.XOR);
+ Node a,b;
+}
+{
+ "xor" "(" a=fct() "," b=fct() ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+Node impl() :
+{
+ // impl can be represented as or(not(A),B)
+ LogOpNode n = new LogOpNode(OpNode.Operations.OR);
+ LogOpNode n1 = new LogOpNode(OpNode.Operations.NOT);
+ Node a,b;
+}
+{
+ "impl" "(" a=fct() "," b=fct() ")"
+ {
+ n1.add_A(a);
+ n.add_A(n1);
+ n.add_B(b);
+ return n;
+ }
+ }
+
+Node logeq() :
+{
+ // logeq can be represented as and(or(not(A),B),or(not(B),A))
+ LogOpNode n = new LogOpNode(OpNode.Operations.AND);
+ LogOpNode n1 = new LogOpNode(OpNode.Operations.OR);
+ LogOpNode n11 = new LogOpNode(OpNode.Operations.NOT);
+ LogOpNode n2 = new LogOpNode(OpNode.Operations.OR);
+ LogOpNode n21 = new LogOpNode(OpNode.Operations.NOT);
+
+ Node a,b;
+}
+{
+ "logeq" "(" a=fct() "," b=fct() ")"
+ {
+ n11.add_A(a);
+ n1.add_A(n11);
+ n1.add_B(b);
+
+ n21.add_A(b);
+ n2.add_A(n21);
+ n2.add_B(a);
+
+ n.add_A(n1);
+ n.add_B(n2);
+
+ return n;
+ }
+ }
+
+Node eq() :
+{
+ CmpOpNode n = new CmpOpNode(OpNode.Operations.EQ);
+ Node a,b;
+}
+{
+ "eq" "(" a=id() "," ( b=id() | b=value() ) ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+Node ne() :
+{
+ CmpOpNode n = new CmpOpNode(OpNode.Operations.NE);
+ Node a,b;
+}
+{
+ "ne" "(" a=id() "," ( b=id() | b=value() ) ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+
+Node lt() :
+{
+ CmpOpNode n = new CmpOpNode(OpNode.Operations.LT);
+ Node a,b;
+}
+{
+ "lt" "(" a=id() "," ( b=id() | b=value() ) ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+
+Node gt() :
+{
+ CmpOpNode n = new CmpOpNode(OpNode.Operations.GT);
+ Node a,b;
+}
+{
+ "gt" "(" a=id() "," ( b=id() | b=value() ) ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+
+Node le() :
+{
+ CmpOpNode n = new CmpOpNode(OpNode.Operations.LE);
+ Node a,b;
+}
+{
+ "le" "(" a=id() "," ( b=id() | b=value() ) ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+
+Node ge() :
+{
+ CmpOpNode n = new CmpOpNode(OpNode.Operations.GE);
+ Node a,b;
+}
+{
+ "ge" "(" a=id() "," ( b=id() | b=value() ) ")"
+ {
+ n.add_A(a);
+ n.add_B(b);
+ return n;
+ }
+}
+
+
+Node id() :
+{ Node n;
+}
+{
+
+ {
+ /* real id is token without the first char '@'*/
+ String id = token.image.substring(1);
+ /* if tool_description != null, evaluate the expression .. */
+ if ( tooldescription != null) {
+
+ /* get typ of element */
+ Element tool_elem = getElementById(tooldescription,id);
+ if (tool_elem == null) {
+ throw new ParseException(ParseExceptionMessageEnum.noParameterWidthId.getMessage()+id);
+
+ }
+ Element tmp = (Element)tool_elem.getElementsByTagNameNS(ToolDescriptionNS,"type").item(0);
+ if (tmp == null) {
+ throw new ParseException(ParseExceptionMessageEnum.noTypeChildParameter.getMessage()+id);
+ }
+ String type = tmp.getTextContent();
+ /* create new Id.Node with type of parameter */
+ if (type.equalsIgnoreCase("String")) {
+ n = new Id(id,LeafNode.TYPE.STRING,parameterwrapper);
+ return n;
+ } else if (type.equalsIgnoreCase("int")) {
+ n = new Id(id,LeafNode.TYPE.INT,parameterwrapper);
+ return n;
+ } else if (type.equalsIgnoreCase("float")) {
+ n = new Id(id,LeafNode.TYPE.FLOAT,parameterwrapper);
+ return n;
+ } else if (type.equalsIgnoreCase("boolean")) {
+ n = new Id(id,LeafNode.TYPE.BOOLEAN,parameterwrapper);
+ return n;
+ } else {
+ /* remark Jan : type date_time is not supported at moment */
+ throw new ParseException(ParseExceptionMessageEnum.notSupportedOrImplemented.getMessage()+type);
+ }
+ }
+ return null;
+ }
+}
+
+Node value() :
+{ Node n;}
+{
+ ( | )
+ {
+ String value = token.image;
+
+
+
+ /* String */
+ if (value.startsWith("'")) {
+ n = new Const(value.substring(1,value.length()-1));
+ } else if (value.equalsIgnoreCase("true") | value.equalsIgnoreCase("false")) {
+ n = new Const(Boolean.parseBoolean(value.toLowerCase()));
+ } else if (value.matches("[+|-]?\\d+")) {
+ n = new Const(Integer.parseInt(value));
+ } else if (value.matches("[+|-]?\\d+\\.\\d+[f]?")) {
+ n = new Const(Float.parseFloat(value));
+ } else {
+ throw new ParseException(ParseExceptionMessageEnum.unknownConstantValue.getMessage()+value);
+ }
+
+ return n;
+ }
+}
+
+
diff --git a/libs/dependencyparser/src/test/java/de/unibi/techfak/bibiserv/util/dependencyparser/DependencyParserTest.java b/libs/dependencyparser/src/test/java/de/unibi/techfak/bibiserv/util/dependencyparser/DependencyParserTest.java
new file mode 100644
index 0000000..9e319f4
--- /dev/null
+++ b/libs/dependencyparser/src/test/java/de/unibi/techfak/bibiserv/util/dependencyparser/DependencyParserTest.java
@@ -0,0 +1,802 @@
+/*
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+Copyright 2010 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+All rights reserved.
+
+The contents of this file are subject to the terms of the Common
+Development and Distribution License("CDDL") (the "License"). You
+may not use this file except in compliance with the License. You can
+obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+
+See the License for the specific language governing permissions and
+limitations under the License. When distributing the software, include
+this License Header Notice in each file. If applicable, add the following
+below the License Header, with the fields enclosed by brackets [] replaced
+by your own identifying information:
+
+"Portions Copyrighted 2011 BiBiServ"
+
+Contributor(s):
+ */
+package de.unibi.techfak.bibiserv.util.dependencyparser;
+
+import de.unibi.techfak.bibiserv.util.dependencyparser.LeafNode.TYPE;
+import java.util.Set;
+import de.unibi.techfak.bibiserv.util.Pair;
+import de.unibi.techfak.bibiserv.util.dependencyparser.javacc.ParseException;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Collection;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * JUnit Test class. Test generated Parser and build Tree using the sample tool
+ * description containing
+ *
+ * @author jkrueger
+ */
+public class DependencyParserTest {
+
+ private DependencyParser dp;
+ private ParameterWrapper pw;
+ private List> pl;
+
+ public DependencyParserTest() throws DependencyException, FileNotFoundException {
+ dp = new DependencyParser();
+ dp.setTooldescription(new FileInputStream("src/test/xml/sample.xml"));
+ pw = new ParameterWrapper();
+ dp.setParameterWrapper(pw);
+
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Test
+ public void test_ConstraintHashMap() {
+
+ ConstraintHashMap chm = new ConstraintHashMap();
+
+ chm.put(new Id("A", TYPE.INT), (Constraints) null);
+
+ chm.put(new Id("B", TYPE.FLOAT), Arrays.asList(new Constraints[]{new Constraints(OpNode.Operations.GT, new Const(20f))}));
+
+ ConstraintHashMap chm2 = new ConstraintHashMap();
+
+ chm2.put(new Id("C", TYPE.INT), new Constraints(OpNode.Operations.EQ, new Const(1)));
+
+ ConstraintHashMap chm3 = new ConstraintHashMap();
+ chm3.putAll(chm);
+ chm3.putAll(chm2);
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void test_NodeUtility() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_1");
+ String expectedString = dp.getDependencyStrings().get(0);
+ Node node = dp.generate();
+ String string = NodeUtility.Node2String(node);
+ System.err.println("DPStr : " + string);
+ assertEquals(expectedString, string);
+
+ dp.setFunctionId("fct_10");
+ expectedString = dp.getDependencyStrings().get(0);
+ node = dp.generate();
+ string = NodeUtility.Node2String(node);
+ System.err.println("DPStr : " + string);
+ assertEquals(expectedString, string);
+
+ dp.setFunctionId("fct_17");
+
+ List l = dp.getDependencyStrings();
+ expectedString = "and(" + l.get(0) + "," + l.get(1) + ")";
+ node = dp.generate();
+ string = NodeUtility.Node2String(node);
+ System.err.println("DPStr : " + string);
+ assertEquals(expectedString, string);
+
+ }
+
+ // fct1 has three parameters (A,B,C) and dependency (A & B & C)
+ @Test
+ public void test_fct_1() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_1");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertFalse(node.evaluate());
+
+ assertHashEquals("Expected [A,B,C] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null,
+ new Id("B", LeafNode.TYPE.FLOAT), null,
+ new Id("C", LeafNode.TYPE.INT), null
+ }));
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("C", "5"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+
+ assertHashEquals("Expected [B] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("B", LeafNode.TYPE.FLOAT), null
+ }));
+
+ pl.add(new Pair("B", "20"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+ }
+
+ // fct2 has three parameters (A,B,C) and dependency (A | B | C)
+ @Test
+ public void test_fct_2() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_2");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertFalse(node.evaluate());
+ assertHashEquals("Expected [A,B,C] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null,
+ new Id("B", LeafNode.TYPE.FLOAT), null,
+ new Id("C", LeafNode.TYPE.INT), null
+ }));
+
+ pl.add(new Pair("B", "20"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+
+ }
+
+ // fct3 has three parameters (A,B,C) and dependency ((A & B) | C)
+ @Test
+ public void test_fct_3() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_3");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertFalse(node.evaluate());
+ assertHashEquals("Expected [A,B,C] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null,
+ new Id("B", LeafNode.TYPE.FLOAT), null,
+ new Id("C", LeafNode.TYPE.INT), null
+ }));
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "20"));
+ pw.setParameter(pl);
+ assertTrue(node.evaluate());
+
+ pl.clear();
+ pl.add(new Pair("C", "5"));
+ pw.setParameter(pl);
+ assertTrue(node.evaluate());
+ }
+
+ // fct4 has five parameters (A,B,C,D,E) and dependency ((A & B) | (C & D) | E)
+ @Test
+ public void test_fct_4() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_4");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertFalse(node.evaluate());
+
+ assertHashEquals("Expected [A,B,C,D,E] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null,
+ new Id("B", LeafNode.TYPE.FLOAT), null,
+ new Id("C", LeafNode.TYPE.INT), null,
+ new Id("D", LeafNode.TYPE.FLOAT), null,
+ new Id("E", LeafNode.TYPE.INT), null
+ }));
+
+ pl.add(new Pair("E", "5"));
+ pw.setParameter(pl);
+ assertTrue(node.evaluate());
+ }
+
+ // fct5 has two parameters (A,B) and dependency (A & NOT(B))
+ @Test
+ public void test_fct_5() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_5");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertFalse(node.evaluate());
+ assertHashEquals("Expected [A] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null
+ }));
+ pl.add(new Pair("A", "10"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+
+ pl.add(new Pair("B", "20"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals("Expected [B] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("B", LeafNode.TYPE.FLOAT), null
+ }));
+ }
+
+ // fct6 has two parameters (A,B) and dependency (A -> B)
+ @Test
+ public void test_fct_6() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_6");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertTrue(node.evaluate());
+
+ pl.add(new Pair("A", "10"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals("Expected [A,B] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null,
+ new Id("B", LeafNode.TYPE.FLOAT), null
+ }));
+ pl.add(new Pair("B", "20"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+ }
+
+ // fct7 has two parameters (A,B) and dependency ((A == 10) -> B)
+ @Test
+ public void test_fct_7() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_7");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertTrue(node.evaluate());
+
+ pl.add(new Pair("A", "10"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals(
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null,
+ new Id("B", LeafNode.TYPE.FLOAT), null
+ }));
+
+ pl.add(new Pair("B", "20"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+
+ // it is not forbidden to assign more than value to a parameter
+ pl.add(new Pair("A", "11")); // should be ok also
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+
+ }
+
+ // fct8 has two parameters (A,B) and dependency (A <-> B)
+ @Test
+ public void test_fct_8() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_8");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertTrue(node.evaluate());
+
+ pl.add(new Pair("A", "10"));
+ pw.setParameter(pl);
+ assertFalse(node.evaluate());
+
+ assertHashEquals("Expected [A,B] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null,
+ new Id("B", LeafNode.TYPE.FLOAT), null
+ }));
+ pl.clear();
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+ assertFalse(node.evaluate());
+ assertHashEquals("Expected [A,B] but got " + node.getMissingConstraints().keySet().toString() + "!",
+ node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), null,
+ new Id("B", LeafNode.TYPE.FLOAT), null
+ }));
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "20"));
+ pw.setParameter(pl);
+ assertTrue(node.evaluate());
+ }
+
+ // fct9 has two parameters (A,B) and dependency ((A > 10) And (B > 10.0))
+ @Test
+ public void test_fct_9() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_9");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), OpNode.Operations.GT, new Const(new Integer(10)),
+ new Id("B", LeafNode.TYPE.FLOAT), OpNode.Operations.GT, new Const(new Float(10))
+ }));
+ pl.clear();
+ pl.add(new Pair("A", "11"));
+ pl.add(new Pair("B", "11"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+ }
+
+ // fct10 has two parameters (A,B) and dependency ((A = 10) And (B = 10.0))
+ @Test
+ public void test_fct_10() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_10");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ pl.add(new Pair("A", "11"));
+ pl.add(new Pair("B", "11"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), OpNode.Operations.EQ, new Const(new Integer(10)),
+ new Id("B", LeafNode.TYPE.FLOAT), OpNode.Operations.EQ, new Const(new Float(10))
+ }));
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+ }
+
+ // fct11 has two parameters (A,B) and dependency ((A < 10) And (B < 10.0))
+ @Test
+ public void test_fct_11() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_11");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ pw.setParameter(pl);
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals("Expected values [A<10, B<10], but got [" + node.getMissingConstraints().toString() + "]", node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), OpNode.Operations.LT, new Const(new Integer(10)),
+ new Id("B", LeafNode.TYPE.FLOAT), OpNode.Operations.LT, new Const(new Float(10))
+ }));
+
+ pl.clear();
+ pl.add(new Pair("A", "9"));
+ pl.add(new Pair("B", "9"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+ }
+
+ // fct9 has two parameters (A,B) and dependency ((A >= 10) And (B >= 10.0))
+ @Test
+ public void test_fct_12() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_12");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ pl.clear();
+ pl.add(new Pair("A", "9"));
+ pl.add(new Pair("B", "9"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), OpNode.Operations.GE, new Const(new Integer(10)),
+ new Id("B", LeafNode.TYPE.FLOAT), OpNode.Operations.GE, new Const(new Float(10))
+ }));
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+ }
+
+ // fct10 has two parameters (A,B) and dependency ((A != 10) And (B != 10.0))
+ @Test
+ public void test_fct_13() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_13");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), OpNode.Operations.NE, new Const(new Integer(10)),
+ new Id("B", LeafNode.TYPE.FLOAT), OpNode.Operations.NE, new Const(new Float(10))
+ }));
+
+ pl.clear();
+ pl.add(new Pair("A", "11"));
+ pl.add(new Pair("B", "11"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+ }
+
+ // fct11 has two parameters (A,B) and dependency ((A <= 10) And (B <= 10.0))
+ @Test
+ public void test_fct_14() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_14");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ pl.clear();
+ pl.add(new Pair("A", "11"));
+ pl.add(new Pair("B", "11"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{
+ new Id("A", LeafNode.TYPE.INT), OpNode.Operations.LE, new Const(new Integer(10)),
+ new Id("B", LeafNode.TYPE.FLOAT), OpNode.Operations.LE, new Const(new Float(10))
+ }));
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+ assertTrue(node.evaluate());
+ }
+
+ // fct11 has two parameters (A,B) and dependency ((A > B))
+ @Test
+ public void test_fct_15() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_15");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{new Id("A", LeafNode.TYPE.INT), null, new Id("B", LeafNode.TYPE.FLOAT), null}));
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{new Id("A", LeafNode.TYPE.INT), OpNode.Operations.GT, new Id("B", LeafNode.TYPE.FLOAT)}));
+
+ pl.clear();
+ pl.add(new Pair("A", "11"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+ }
+
+ // fct16 has two parameters (A,B) and dependency (A and (not (B > 10))
+ @Test
+ public void test_fct_16() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_16");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{new Id("A", LeafNode.TYPE.INT), null}));
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "11"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ assertHashEquals(node.getMissingConstraints(), createHashfromArray(new Object[]{new Id("B", LeafNode.TYPE.INT), OpNode.Operations.LE, new Const(new Integer(10))}));
+ }
+
+ @Test
+ public void test_fct_17() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_17");
+
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pl.add(new Pair("C", "TRUE"));
+ pl.add(new Pair("D", "Hello World"));
+ pw.setParameter(pl);
+
+ assertTrue(node.evaluate());
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "10"));
+ pl.add(new Pair("C", "FALSE"));
+ pw.setParameter(pl);
+
+ assertFalse(node.evaluate());
+ }
+
+ @Test
+ public void test_fct_18() throws ParseException, DependencyException {
+ /*
+ * Test Funktion entspricht der Abhaengigkeitbeschreibung von dem Tool
+ * RNAhybrid.
+ */
+ dp.setFunctionId("fct_18");
+
+ pl = new ArrayList();
+
+ pw.setParameter(pl);
+
+ Node node = dp.generate();
+
+ System.err.println("cum. dep : " + NodeUtility.Node2String(node));
+
+ // no parameter set should return true
+ assertTrue(node.evaluate());
+
+ pl.clear();
+ pl.add(new Pair("A", "10"));
+ pl.add(new Pair("B", "11"));
+ pw.setParameter(pl);
+
+ // Parameter A,B : A < B should return true
+ assertTrue(node.evaluate());
+
+ }
+
+ @Test
+ public void test_fct_19() throws ParseException, DependencyException {
+ /*
+ * Test Funktion entspricht der Abhaengigkeitbeschreibung von dem Tool
+ * RNAhybrid.
+ */
+ dp.setFunctionId("fct_19");
+
+ pl = new ArrayList();
+ pl.add(new Pair("C", "false"));
+ pw.setParameter(pl);
+
+ Node node = dp.generate();
+
+ // no parameter set should return true
+ boolean result = node.evaluate();
+ String missedConstraints = "none";
+ if (!result) {
+ missedConstraints = ConstraintHashMaptoString(node.getMissingConstraints());
+ }
+ assertTrue("Missed constraints:" + missedConstraints, result);
+
+ pl.clear();
+ pl.add(new Pair("C", "true"));
+ pw.setParameter(pl);
+
+ result = node.evaluate();
+ missedConstraints = "none";
+ if (!result) {
+ missedConstraints = ConstraintHashMaptoString(node.getMissingConstraints());
+ }
+ assertFalse("Missed constraints:" + missedConstraints, result);
+
+ pl.clear();
+ pl.add(new Pair("C", "true"));
+ pl.add(new Pair("A", "10"));
+
+ pw.setParameter(pl);
+
+ // should return true
+ assertTrue(node.evaluate());
+
+ }
+
+ public static void assertListEquals(Collection result, Collection expected) {
+ assertListEquals("", result, expected);
+
+ }
+
+ public static void assertListEquals(String message, Collection result, Collection expected) {
+
+ if (result == null && expected == null) {
+ return;
+ }
+
+ if (result == null) {
+ fail("Result Set is null ! Expected " + expected.toString());
+ }
+
+ // if expected value is null it doesn't matter what the result contains ...
+ if (expected == null) {
+ return;
+ }
+
+ if (result.size() != expected.size()) {
+ fail("Size of expected Set (" + expected.size() + ") differs from result Set (" + result.size() + ").");
+ }
+ List a = new ArrayList(result);
+ Collections.sort(a);
+
+ List b = new ArrayList(expected);
+ Collections.sort(b);
+
+ for (int c = 0; c < a.size(); ++c) {
+ assertEquals("[" + a.get(c) + "] differs from [" + b.get(c) + "] " + message, a.get(c), b.get(c));
+
+ }
+ }
+
+ public static void assertHashEquals(String message, ConstraintHashMap result, Collection expected) {
+ assertListEquals(message, result.keySet(), expected);
+ }
+
+ public static void assertHashEquals(ConstraintHashMap result, ConstraintHashMap expected) {
+ assertHashEquals("", result, expected);
+ }
+
+ public static void assertHashEquals(String message, ConstraintHashMap result, ConstraintHashMap expected) {
+ Set s_a = result.keySet();
+
+ Set s_b = expected.keySet();
+
+ if (s_a.size() != s_b.size()) {
+ fail("Number of expected keys (" + s_a.size() + ") differs from keys in result map (" + s_b.size() + ").");
+ }
+
+ for (Id id_a : s_a) {
+ if (!s_b.contains(id_a)) {
+ fail("Expected id (" + id_a + ") not found in result map!");
+ } else {
+ assertListEquals(result.get(id_a), expected.get(id_a));
+ }
+ }
+
+ }
+
+ public static ConstraintHashMap createHashfromArray(Object[] ts) {
+ ConstraintHashMap r = new ConstraintHashMap();
+
+ int s = 0;
+ Id id = null;
+ OpNode.Operations op = OpNode.Operations.NULL;
+ LeafNode ln = null;
+ for (Object t : ts) {
+ switch (s) {
+ case 0: {
+ id = (Id) t;
+ s = 1;
+ break;
+ }
+ case 1: {
+ if (t == null || t.equals(OpNode.Operations.NULL)) {
+ r.put(id, (List) null);
+ s = 0;
+ } else {
+ op = (OpNode.Operations) t;
+ s = 2;
+ }
+ break;
+ }
+ case 2: {
+ ln = (LeafNode) t;
+ r.put(id, new Constraints(op, ln));
+ s = 0;
+ }
+ }
+ }
+
+ return r;
+ }
+
+ public static String ConstraintHashMaptoString(ConstraintHashMap map) {
+ StringBuilder sb = new StringBuilder();
+ for (Id id : map.keySet()) {
+ System.err.println(".");
+ sb.append(id.getId()).append("[").append(id.getType()).append("]:");
+ // cronstraints could be null if not defined
+ if (map.get(id) == null) {
+ sb.append("defined");
+ } else {
+ for (Constraints c : map.get(id)) {
+ sb.append(c.toString());
+ sb.append(",");
+ }
+ sb.setLength(sb.length() - 1);
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/libs/dependencyparser/src/test/java/de/unibi/techfak/bibiserv/util/dependencyparser/DependencyParserTest2.java b/libs/dependencyparser/src/test/java/de/unibi/techfak/bibiserv/util/dependencyparser/DependencyParserTest2.java
new file mode 100644
index 0000000..9ea35c8
--- /dev/null
+++ b/libs/dependencyparser/src/test/java/de/unibi/techfak/bibiserv/util/dependencyparser/DependencyParserTest2.java
@@ -0,0 +1,70 @@
+/*
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+Copyright 2010 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+All rights reserved.
+
+The contents of this file are subject to the terms of the Common
+Development and Distribution License("CDDL") (the "License"). You
+may not use this file except in compliance with the License. You can
+obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+
+See the License for the specific language governing permissions and
+limitations under the License. When distributing the software, include
+this License Header Notice in each file. If applicable, add the following
+below the License Header, with the fields enclosed by brackets [] replaced
+by your own identifying information:
+
+"Portions Copyrighted 2011 BiBiServ"
+
+Contributor(s):
+ */
+package de.unibi.techfak.bibiserv.util.dependencyparser;
+
+import de.unibi.techfak.bibiserv.util.Pair;
+import de.unibi.techfak.bibiserv.util.dependencyparser.javacc.ParseException;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+import java.util.ArrayList;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * JUnit Test class. Test generated Parser with broken dependency string
+ * @author jkrueger
+ */
+public class DependencyParserTest2 {
+
+ private DependencyParser dp;
+ private ParameterWrapper pw;
+ private List> pl;
+
+ public DependencyParserTest2() throws DependencyException, FileNotFoundException {
+ dp = new DependencyParser();
+ dp.setTooldescription(new FileInputStream("src/test/xml/broken.xml"));
+ pw = new ParameterWrapper();
+ dp.setParameterWrapper(pw);
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ // fct1 has three parameters (A,B,C) and dependency (A & B & C)
+ @Test
+ public void test_fct_1() throws ParseException, DependencyException {
+ dp.setFunctionId("fct_1");
+ pl = new ArrayList>();
+ pw.setParameter(pl);
+ // generate tree
+ Node node = dp.generate();
+ assertFalse(node.evaluate());
+ }
+}
diff --git a/libs/dependencyparser/src/test/xml/broken.xml b/libs/dependencyparser/src/test/xml/broken.xml
new file mode 100644
index 0000000..580d189
--- /dev/null
+++ b/libs/dependencyparser/src/test/xml/broken.xml
@@ -0,0 +1,93 @@
+
+
+ Example 1
+ Example 1 describing some parameters and its dependencies between them
+ This is one of the example description describing some parameters and its dependencies between them
+
+
+
+ Jan
+ Krueger
+ CeBiTeC
+ jkrueger@cebitec.uni-bielefeld.de
+ +49 521 106 2494
+
+
+ Jan
+ Krueger
+ CeBiTeC
+ jkrueger@cebitec.uni-bielefeld.de
+ +49 521 106 2494
+
+
+
+
+
+ binary
+ /bin/echo
+
+
+
+
+ A
+ A :: int
+ parameter A :: int
+ int
+
+
+
+ B
+ B :: float
+ parameter B :: float
+ float
+
+
+
+
+
+ DepFun1
+ dependency for function 1
+ Dependency description for function 1.
+ and(def(@A),and(def(@B),def(@C)))
+
+
+
+
+
+
+ function1
+ function 1 with dependency 1 (A and B and C)
+
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libs/dependencyparser/src/test/xml/sample.xml b/libs/dependencyparser/src/test/xml/sample.xml
new file mode 100644
index 0000000..a983c7b
--- /dev/null
+++ b/libs/dependencyparser/src/test/xml/sample.xml
@@ -0,0 +1,550 @@
+
+
+ Example 1
+ Example 1 describing some parameters and its dependencies between them
+ This is one of the example description describing some parameters and its dependencies between them
+
+
+
+ Jan
+ Krueger
+ CeBiTeC
+ jkrueger@cebitec.uni-bielefeld.de
+ +49 521 106 2494
+
+
+ Jan
+ Krueger
+ CeBiTeC
+ jkrueger@cebitec.uni-bielefeld.de
+ +49 521 106 2494
+
+
+
+
+
+ binary
+ /bin/echo
+
+
+
+
+ A
+ A :: int
+ parameter A :: int
+ int
+
+
+
+ B
+ B :: float
+ parameter B :: float
+ float
+
+
+
+ C
+ C :: boolean
+ parameter C :: boolean
+ boolean
+
+
+
+ D
+ D :: string
+ parameter D :: string
+ string
+
+
+
+ E
+ E :: int
+ parameter e :: int
+ int
+
+
+
+
+ DepFun1
+ dependency for function 1
+ Dependency description for function 1.
+ and(def(@A),and(def(@B),def(@C)))
+
+
+ DepFun2
+ dependency for function 2
+ Dependency description for function 2.
+ or(def(@A),or(def(@B),def(@C)))
+
+
+ DepFun3
+ dependency for function 3
+ Dependency description for function 3.
+ or(and(def(@A),def(@B)),def(@C))
+
+
+ DepFun4
+ dependency for function 4
+ Dependency description for function 4.
+ or(and(def(@A),def(@B)),or(def(@E),and(def(@C),def(@D))))
+
+
+ DepFun5
+ dependency for function 5
+ Dependency description for function 5.
+ and(def(@A),not(def(@B)))
+
+
+ DepFun6
+ dependency for function 6
+ Dependency description for function 6.
+ impl(def(@A),def(@B))
+
+
+ DepFun7
+ dependency for function 7
+ Dependency description for function 7.
+ impl(ge(@A,10),def(@B))
+
+
+ DepFun8
+ dependency for function 8
+ Dependency description for function 8.
+ logeq(def(@A),def(@B))
+
+
+ DepFun9
+ dependency for function 9
+ Dependency description for function 9.
+ and(gt(@A,10),gt(@B,10.0))
+
+
+ DepFun10
+ dependency for function 10
+ Dependency description for function 10.
+ and(eq(@A,10),eq(@B,10.0))
+
+
+ DepFun11
+ dependency for function 11
+ Dependency description for function 11.
+ and(lt(@A,10),lt(@B,10.0))
+
+
+ DepFun12
+ dependency for function 9
+ Dependency description for function 9.
+ and(ge(@A,10),ge(@B,10.0))
+
+
+ DepFun13
+ dependency for function 10
+ Dependency description for function 10.
+ and(ne(@A,10),ne(@B,10.0))
+
+
+ DepFun14
+ dependency for function 11
+ Dependency description for function 11.
+ and(le(@A,10),le(@B,10.0))
+
+
+ DepFun15
+ dependency for function 15
+ Dependency description for function 15.
+ gt(@A,@B)
+
+
+ DepFun16
+ dependency for function 16
+ Dependency description for function 16.
+ and(def(@A),not(gt(@B,10)))
+
+
+
+ DepFun17a
+ 1st dependency for function 17
+ 1st Dependency description for function 17.
+ and(def(@A),def(@B))
+
+
+
+ DepFun17b
+ 2nd dependency for function 17
+ 2nd Dependency description for function 17.
+ and(def(@C),def(@D))
+
+
+
+
+ CwithA
+ wenn C dann muss A definiert sein
+ wenn C dann muss A definiert sein
+ or(not(def(@C)),and(def(@C),def(@A)))
+
+
+
+ DNOTA
+ wenn D dann darf A nicht definiert sein
+ wenn D dann darf A nicht definiert sein
+ or(not(def(@D)),and(def(@D),not(def(@A))))
+
+
+
+ AwithB_BwithA_AleB
+ wenn A dann muss B definiert sein (und umgekehrt) und A muss kleiner gleich B sein
+ wenn A dann muss B definiert sein (und umgekehrt) und A muss kleiner gleich B sein
+ or(not(or(def(@A),def(@B))),le(@A,@B))
+
+
+
+
+ boolean test
+ wenn C wahr ist muss A definiert sein
+ wenn C wahr ist muss A definiert sein
+ or(eq(@C,'false'),and(eq(@C,'true'),def(@A)))
+
+
+
+
+ function1
+ function 1 with dependency 1 (A and B and C)
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+
+
+
+
+ function2
+ function 2 with dependency 2 (A or B or C)
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+
+
+
+
+ function3
+ function 3 with dependency 3 ((A and B) or C)
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+
+
+
+
+ function3
+ function 4 with dependency 4 ((A and B) or (C and D) or E)
+
+
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+ D
+ E
+
+
+
+
+ function5
+ function 5 with dependency 5 (A and (not B))
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function6
+ function 6 with dependency 6 (A -> B)
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function7
+ function 7 with dependency 7 ((A==10) -> B)
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function8
+ function 8 with dependency 8 (A <-> B)
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function9
+ function 9 with dependency 9 ((@A > 10) and (@B > 10.0))
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function10
+ function 10 with dependency 10 ((@A == 10) and (@B == 10.0))
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function11
+ function 11 with dependency 11 ((@A < 10) and (@B < 10.0))
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function12
+ function 12 with dependency 12 ((@A => 10) and (@B => 10.0))
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function13
+ function 13 with dependency 13 ((@A != 10) and (@B != 10.0))
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function14
+ function 14 with dependency 14 ((@A <= 10) and (@B <= 10.0))
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function15
+ function 15 with dependency 15 (@A >@B)
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+ function16
+ function 16 with dependency 16 (A and ( not (@A > 10)))
+
+
+
+
+
+
+
+
+ A
+ B
+
+
+
+
+ function17
+ function 17 with dependency 17a and 17b
+
+
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+ D
+
+
+
+
+
+ function 18
+ entspricht im wesentlichen RNAhybrid
+
+
+
+
+
+
+
+
+
+
+
+
+ A
+ B
+ C
+ D
+
+
+
+
+
+ function 19
+ tested den Typen boolean
+
+
+
+
+
+
+
+ C
+
+
+
+
+
+
+
+
+
+
diff --git a/libs/ontoaccess/pom.xml b/libs/ontoaccess/pom.xml
index 525c373..daf16a1 100644
--- a/libs/ontoaccess/pom.xml
+++ b/libs/ontoaccess/pom.xml
@@ -34,13 +34,13 @@
org.apache.jenajena-core
- 2.10.1
+ 2.7.1com.github.ansell.pelletpellet-jena
- 2.3.6-ansell
+ 2.3.2
diff --git a/libs/pom.xml b/libs/pom.xml
index 7f5aa0e..687b56f 100644
--- a/libs/pom.xml
+++ b/libs/pom.xml
@@ -16,6 +16,7 @@
validatorviewerbibiservsearch
+ dependencyparserLibs
diff --git a/pom.xml b/pom.xml
index 343b86e..1ce23a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,7 @@
-
+4.0.0de.unibi.cebitec.bibiservbibiserv
@@ -19,9 +21,10 @@
- schemas
- libsbibimainapp
+ libs
+ tools
+ schemasUTF-8
diff --git a/schemas/bibiservabstraction/src/main/xsd/BiBiServAbstraction.xsd b/schemas/bibiservabstraction/src/main/xsd/BiBiServAbstraction.xsd
index 272cefb..ea5d33f 100644
--- a/schemas/bibiservabstraction/src/main/xsd/BiBiServAbstraction.xsd
+++ b/schemas/bibiservabstraction/src/main/xsd/BiBiServAbstraction.xsd
@@ -139,15 +139,15 @@
-
+
- Order all elements lexographical, wether they are
+ Order all elements lexicographical, wether they are
category or itemRef elements
-
+
- Order all elements lexographical, first all categories second all itemRefs
+ Order all elements lexicographical, first all categories second all itemRefs
@@ -481,15 +481,23 @@
to be sufficient to call the executable resource.
-
+
- Optional DEPRECATED tag: The 'executableType' element specified which
- kind of supported executable type was described here.
+ Optional tag: The 'executableType' element specified which
+ kind of supported executable type was described here. Could be used by implemting call class
+
-
+
+
+ Optional tag: The 'image' element specifies [docker] image container used
+ for execution.
+
+
+
+
- The 'path' element contains the
+ Optional tag: The 'path' element contains the
filesystem path of an executable file. This has to be given in order for the
server to be able to call the external executable program.
diff --git a/tools/DeployTools/build.xml b/tools/DeployTools/build.xml
new file mode 100644
index 0000000..d9c2263
--- /dev/null
+++ b/tools/DeployTools/build.xml
@@ -0,0 +1,209 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Loading Ivy Settings from BiBiServ ...
+
+
+
+ BiBiserv not available, load Ivy settings from ${user.home}/ivy-rep/ivy-settings.xml or if this file does not exist load default settings file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/DeployTools/ivy.xml b/tools/DeployTools/ivy.xml
new file mode 100644
index 0000000..eab4060
--- /dev/null
+++ b/tools/DeployTools/ivy.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/DeployTools/pom.xml b/tools/DeployTools/pom.xml
new file mode 100644
index 0000000..627603f
--- /dev/null
+++ b/tools/DeployTools/pom.xml
@@ -0,0 +1,68 @@
+
+
+ 4.0.0
+ de.unibi.cebitec.bibiserv
+ deploytools
+ stable.release
+ jar
+ DeployTools
+
+
+
+ snapshot-repository.java.net
+ Java.net Snapshot Repository for Maven
+ https://maven.java.net/content/repositories/snapshots/
+ default
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+ org.apache.ant
+ ant
+ 1.9.0
+ compile
+
+
+
+ ${project.groupId}
+ bibiservabstraction
+ 1.0
+
+
+
+ ${project.groupId}
+ ontoaccess
+ 0.9
+
+
+
+ ${project.groupId}
+ bibitools
+ 2.0
+
+
+
+
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
diff --git a/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/AbstractVerifyTask.java b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/AbstractVerifyTask.java
new file mode 100644
index 0000000..f84df8d
--- /dev/null
+++ b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/AbstractVerifyTask.java
@@ -0,0 +1,117 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+import de.unibi.techfak.bibiserv.cms.TrunnableItem;
+import java.io.File;
+import java.io.IOException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.w3c.dom.Document;
+
+/**
+ * AbstractVerfifyTask is an abstraced class used as base for all implementing
+ * classes.
+ *
+ * This class extends the ant Task class.
+ *
+ *
+ * @author Jan Krueger - jkrueger(at)techfak.uni-bielefeld.de
+ */
+public abstract class AbstractVerifyTask extends Task {
+
+ private File runnableitemfile;
+ private TrunnableItem runnableitem;
+ private JAXBElement jaxbe;
+
+ @Override
+ public void execute() throws BuildException {
+ if (getRunnableitemfile() == null) {
+ throw new BuildException("Attribute runnableitemfile is mandatory!");
+ }
+ }
+
+ /**
+ * Set Tooldescription (=runnableitem) file. Function load file and create a
+ * corresponding JAXB object.
+ *
+ *
+ * @param file
+ * @throws JAXBException, if file can't be marshalled to a JAXB object
+ * @throws IOException if file doesn't ecists or can't be read
+ */
+ public void setRunnableitemfile(File file) throws JAXBException, IOException {
+ runnableitemfile = file;
+ if (!runnableitemfile.isFile() || !runnableitemfile.canRead()) {
+ throw new IOException("File " + runnableitemfile.toString() + " can't read!");
+ }
+ JAXBContext ctx = JAXBContext.newInstance(de.unibi.techfak.bibiserv.cms.TrunnableItem.class);
+ Unmarshaller um = ctx.createUnmarshaller();
+ jaxbe = (JAXBElement) um.unmarshal(file);
+ runnableitem = jaxbe.getValue();
+ }
+
+ /**
+ * Get tooldescription (=runnableitem) file.
+ *
+ * @return Return tooldesription file
+ */
+ public File getRunnableitemfile() {
+ return runnableitemfile;
+ }
+
+ /**
+ * Get tooldescription (JAXB) object
+ *
+ * @return Return tooldescription object.
+ */
+ public TrunnableItem getRunnableitem() {
+ return runnableitem;
+ }
+
+ /**
+ * Return W3C DOM document representatiopn from tooldescription.
+ *
+ * @return Return W3C DOM document representation from tooldescription.
+ * @throws JAXBException, if JAXB object can't be marshalled to DOM document
+ * @throws ParserConfigurationException, if
+ */
+ public Document getRunnableitemAsDocument() throws JAXBException, ParserConfigurationException {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ Document document = dbf.newDocumentBuilder().newDocument();
+
+ JAXBContext ctx = JAXBContext.newInstance(de.unibi.techfak.bibiserv.cms.TrunnableItem.class);
+ Marshaller m = ctx.createMarshaller();
+ m.marshal(jaxbe, document);
+
+ return document;
+ }
+}
diff --git a/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyDownload.java b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyDownload.java
new file mode 100644
index 0000000..5fd892f
--- /dev/null
+++ b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyDownload.java
@@ -0,0 +1,266 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+
+import de.unibi.techfak.bibiserv.cms.Tfile;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.bind.JAXBException;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * VerifyDownload is small tool class that compares file within a directory
+ * and described by the download within the tool description.
+ *
+ * This class extends the ant Task class and overwrites its execute class.
+ *
+ *
+ * @author Jan Krueger - jkrueger(at)techfak.uni-bielefeld.de
+ */
+public class VerifyDownload extends AbstractVerifyTask {
+
+
+ List download_xml_list = new ArrayList();
+ List download_dir_list = new ArrayList();
+ private File downloaddir;
+
+
+
+ /**
+ * Default Constructor
+ */
+ public VerifyDownload() {
+ }
+
+ /**
+ * Constructor of class.
+ *
+ * @param runnableitemfile
+ * @param downloaddir
+ * @throws IOException in the case the runnableitem file or download dir doesn't exist or can't be read
+ *
+ */
+ public VerifyDownload(File runnableitemfile, File downloaddir) throws IOException, JAXBException {
+ setRunnableitemfile(runnableitemfile);
+ setDownloaddir(downloaddir);
+ }
+
+ @Override
+ public void execute() throws BuildException {
+ super.execute();
+
+ if (downloaddir == null) {
+ throw new BuildException("Attribute downloaddir is mandatory!");
+ }
+
+
+ // if (downloaddir.exists() && !downloaddir.isDirectory() && !downloaddir.canRead()) {
+
+ try {
+ initialize();
+ } catch (JAXBException e){
+ throw new BuildException(e);
+ }
+
+ List resultlist = new ArrayList();
+ if (compareEntries(download_xml_list, download_dir_list, resultlist)){
+ System.out.println("Found "+printList(resultlist)+" download elements!");
+ } else {
+ if (download_xml_list.size() > 0) {
+ throw new BuildException("The tooldescription contains downloadable "
+ + "items ("+printList(download_xml_list)+") which are NOT "
+ + "available in the resource directory '"+downloaddir+"' !");
+ } else if (download_dir_list.size() > 0) {
+ throw new BuildException("The resource directory '"+downloaddir+"' "
+ + "contains items ("+printList(download_dir_list)+") which "
+ + "are NOT described in the tool description!");
+ } else {
+ throw new BuildException("Should never occure ....");
+ }
+ }
+
+
+ }
+
+ /**
+ * Initize object using init() method. Method fill the both FileNameList with
+ * content.
+ *
+ * @throws JAXBException in the case RunnableItemFile can't be parsed into an JAXB class.
+ */
+ public void initialize() throws JAXBException {
+ getDownloadableEntries(download_xml_list);
+
+ if (downloaddir.exists() && downloaddir.isDirectory() && downloaddir.canRead()) {
+ getDirEntries(downloaddir, download_dir_list);
+ }
+ }
+
+ public File getDownloaddir() {
+ return downloaddir;
+ }
+
+ public void setDownloaddir(File downloaddir) throws IOException{
+ /* get all entries within download dir */
+ this.downloaddir = downloaddir;
+
+
+ }
+
+
+
+ /**
+ * Function compareEntries compares two lists (list1 and list2) and return
+ * true if both lists are equal, false otherwise. Attention! Elements that
+ * occurrs in both list are removed from it and append to the result list.
+ *
+ * @param list1 - list containing strings
+ * @param list2 - list containing strings
+ * @param list3 - an empty, but initalized list
+ *
+ * @return
+ */
+ public static boolean compareEntries(List list1, List list2, List list3) {
+ int counter = 0;
+ while (counter < list1.size()) {
+ String elem = list1.get(counter);
+ if (list2.contains(elem)) {
+ // remove from both lists ...
+ list1.remove(elem);
+ list2.remove(elem);
+ // ... and add to result list
+ list3.add(elem);
+ } else {
+ counter++;
+ }
+ }
+ if (list1.isEmpty() && list2.isEmpty()) {
+ return true;
+ }
+ return false;
+ }
+
+
+
+ /**
+ * Static Function getDownloadableEntries determins all downloadable (filename)
+ * and pack them into a list.
+ *
+
+ * @param list - append all found Downloadable filenames to list
+ */
+ public void getDownloadableEntries(List list) throws BuildException {
+ List lod = getRunnableitem().getDownloadable();
+ for (Tfile d : lod) {
+ if (d.isSetFilename()) { //local resource
+ list.add(d.getFilename());
+ } else { // must be an external resource
+
+ // check url
+ try {
+ URL url = new URL(d.getUrl());
+ URLConnection connection = url.openConnection();
+ connection.connect();
+ InputStream in = connection.getInputStream();
+ } catch (MalformedURLException e) {
+ throw new BuildException("Malformed URL : '"+d.getUrl()+"'");
+
+ } catch (IOException e){
+ throw new BuildException("IOException while open connection to '"+d.getUrl()+ "': "+e.getMessage());
+ }
+
+
+ }
+ }
+ }
+
+ /**
+ * Function getDirEntries determins a list of files within a given
+ * directory. Subdirectories are also considered.
+ *
+ *
+ * @param file - Directory to be searched
+ * @param list - List all found files
+ */
+ public static void getDirEntries(File file, List list) {
+ getDirEntries(file, file.toString().length() > 0 ? file.toString() + "/" : "", list);
+ }
+
+ /**
+ * Private Helper function used by fct getDirEntries for recursion steps ...
+ *
+ * @param file
+ * @param prefix
+ * @param list
+ */
+ private static void getDirEntries(File file, String prefix, List list) {
+ if (file.isFile()) {
+ String fn = file.toString().substring(prefix.length());
+ list.add(fn);
+ } else if (file.isDirectory()) {
+ File[] file_list = file.listFiles();
+ for (File f : file_list) {
+ getDirEntries(f, prefix, list);
+ }
+ }
+ }
+
+
+
+ /**
+ * Helper function, returns all elements of list as String
+ *
+ * @param l
+ * @return
+ */
+ public static String printList(List l) {
+ return printList(l,false);
+ }
+
+
+ public static String printList(List l, boolean br) {
+ String s = null;
+ StringBuilder sb = new StringBuilder();
+ Iterator i = l.iterator();
+ while (i.hasNext()) {
+ s = i.next();
+ sb.append(s);
+ if (i.hasNext()) {
+ if (br) {
+ sb.append("\n");
+ } else {
+ sb.append(",");
+ }
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyFunction.java b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyFunction.java
new file mode 100644
index 0000000..8141dc9
--- /dev/null
+++ b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyFunction.java
@@ -0,0 +1,226 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted 2010 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de"
+ *
+ * Contributor(s):
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+import de.unibi.techfak.bibiserv.cms.TenumParam;
+import de.unibi.techfak.bibiserv.cms.Texample;
+import de.unibi.techfak.bibiserv.cms.Texample.Prop;
+import de.unibi.techfak.bibiserv.cms.Tfunction;
+import de.unibi.techfak.bibiserv.cms.Tfunction.Inputref;
+import de.unibi.techfak.bibiserv.cms.TinputOutput;
+import de.unibi.techfak.bibiserv.cms.Tparam;
+import de.unibi.techfak.bibiserv.cms.TparamGroup;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * VerifyFucntion is small tool class that check if every param, input and ouput
+ * is referenced by the inputAndOutputOrder.
+ *
+ * This class extends the ant Task class and overwrites its execute class.
+ *
+ *
+ * @author Jan Krueger - jkrueger(at)techfak.uni-bielefeld.de
+ */
+public class VerifyFunction extends AbstractVerifyTask {
+
+ @Override
+ public void execute() throws BuildException {
+ super.execute();
+ if (getRunnableitem().isSetExecutable()) {
+
+ // for all functions ...
+ for (Tfunction tf : getRunnableitem().getExecutable().getFunction()) {
+ System.out.println("Found function :" + tf.getId());
+ List> paramAndInputOutputOrderList = tf.getParamAndInputOutputOrder().getReferenceOrAdditionalString();
+ List paramAndInputOutputOrderidList = new ArrayList();
+ for (JAXBElement> jaxbe : paramAndInputOutputOrderList) {
+ if (jaxbe.getValue() instanceof TinputOutput) {
+ paramAndInputOutputOrderidList.add(((TinputOutput) jaxbe.getValue()).getId());
+ } else if (jaxbe.getValue() instanceof Tparam) {
+ paramAndInputOutputOrderidList.add(((Tparam) jaxbe.getValue()).getId());
+ } else if (jaxbe.getValue() instanceof TenumParam) {
+ paramAndInputOutputOrderidList.add(((TenumParam) jaxbe.getValue()).getId());
+ } else {
+ System.out.println("ignore unsupported type :" + jaxbe.getValue().getClass().getName());
+ }
+ }
+ List paramAndInputOutputReferenceIdList = getInputOutputIdList(tf.getId());
+ try {
+ paramAndInputOutputReferenceIdList.addAll(getParamIdList(tf.getId()));
+ } catch (Exception e) {
+ throw new BuildException(e);
+ }
+
+ // check if example(s) exists and all refid are valid and all values are valid
+ for (Texample te : tf.getExample()) {
+ for (Prop p : te.getProp()) {
+ if (!paramAndInputOutputOrderidList.contains(p.getIdref())) {
+ throw new BuildException("The example tag named '"+te.getName()+"' of function '"+tf.getId()+"' has an unknown reference '"+p.getIdref()+"'!");
+ }
+ }
+ }
+
+ if(!VerifyDownload.compareEntries(paramAndInputOutputOrderidList, paramAndInputOutputReferenceIdList, new ArrayList())){
+ if (!paramAndInputOutputOrderidList.isEmpty()) {
+ throw new BuildException("The ParamAndInputOutputOrder tag of function '"+tf.getId()+" contains refId(s) ["+VerifyDownload.printList(paramAndInputOutputOrderidList)+"] which are not part of this function!");
+ } else {
+ throw new BuildException("The ParamAndInputOutputOrder tag of function '"+tf.getId()+" misses refId(s) ["+VerifyDownload.printList(paramAndInputOutputReferenceIdList)+"] !");
+ }
+ }
+ System.out.println(" -> References seems to be ok!");
+
+
+ }
+ } else {
+ System.out.println("No Executable found ...");
+ }
+ }
+
+ public List getInputIdList(String function_id) {
+ List list = new ArrayList();
+ for (TinputOutput input : getInputList(function_id)) {
+ list.add(input.getId());
+ }
+ return list;
+ }
+
+ /**
+ * Return a list of input(s) used/referenced by given function id.
+ *
+ * @param function_id
+ * @return Return a list of inputs
+ */
+ public List getInputList(String function_id) {
+ List list = new ArrayList();
+ for (Inputref ref : getFunction(function_id).getInputref()) {
+ list.add((TinputOutput) ref.getRef());
+ }
+ return list;
+ }
+
+ public String getOutputId(String function_id) {
+ return getOutput(function_id).getId();
+ }
+
+ /** Return an output used/referenced by given function id/
+ *
+ * @param function_id
+ * @return return output
+ */
+ public TinputOutput getOutput(String function_id) {
+ return (TinputOutput) (getFunction(function_id).getOutputref().getRef());
+ }
+
+ public List getInputOutputIdList(String function_id) {
+ List list = getInputIdList(function_id);
+ list.add(getOutputId(function_id));
+ return list;
+ }
+
+ /**
+ * Return a list of input(s) and ouput used/referenced by given function id.
+ *
+ * @param function_id
+ * @return
+ */
+ public List getInputOutputList(String function_id) {
+ List list = getInputList(function_id);
+ list.add(getOutput(function_id));
+ return list;
+ }
+
+ /**
+ * Return a list of parameterIds used/referenced by given function id.
+ *
+ * @param function_id
+ * @return Return a list of parameterIds.
+ */
+ public List getParamList(String function_id) throws Exception {
+ List list = new ArrayList();
+ if (getFunction(function_id).isSetParamGroup()) {
+ buildParamList(getFunction(function_id).getParamGroup(), list);
+ }
+
+ return list;
+ }
+
+ /**
+ * Return a list of parameterIds used/referenced by given function id.
+ *
+ * @param function_id
+ * @return Return a list of parameterIds.
+ */
+ public List getParamIdList(String function_id) throws Exception {
+ List list = new ArrayList();
+ for (Object o : getParamList(function_id)) {
+ if (o instanceof Tparam) {
+ list.add(((Tparam)o).getId());
+ } else {
+ list.add(((TenumParam)o).getId());
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Private helper method, search recursvily for parameter
+ *
+ * @param c an object of type Tparam or TparamGroup
+ * @param l
+ * @throws Exception if an unknown object
+ */
+ private void buildParamList(Object c, List l) throws Exception {
+ if (c instanceof Tparam || c instanceof TenumParam ) {
+ l.add( c);
+ } else if (c instanceof TparamGroup) {
+ TparamGroup tpg = (TparamGroup) c;
+ for (Object o : tpg.getParamrefOrParamGroupref()) {
+ if (o instanceof TparamGroup.Paramref) {
+ buildParamList(((TparamGroup.Paramref) o).getRef(), l);
+ } else {
+ buildParamList(((TparamGroup.ParamGroupref) o).getRef(), l);
+ }
+ }
+ } else {
+ throw new Exception("Unkown object of type '" + c.getClass().getName() + "'. Aborting!");
+ }
+ }
+
+ /**
+ * Return the function with given id (if exists)
+ *
+ * @param function_id
+ * @return
+ */
+ public Tfunction getFunction(String function_id) {
+ for (Tfunction tf : getRunnableitem().getExecutable().getFunction()) {
+ if (tf.isSetId() && tf.getId().equals(function_id)) {
+ return tf;
+ }
+ }
+ return null;
+ }
+}
diff --git a/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyImage.java b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyImage.java
new file mode 100644
index 0000000..c691e4f
--- /dev/null
+++ b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyImage.java
@@ -0,0 +1,62 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010-2012 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted 2010-2012 BiBiServ Curator Team"
+ *
+ * Contributor(s): Jan Krueger
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+import java.io.File;
+
+/**
+ *
+ * Deprecated class. Only for compatibility reason for generated tools before than 03/07/2012.
+ *
+ * Class is replaced by VerifyLinks.
+ *
+ * @author Jan Krueger - jkrueger(at)cebitec.uni-bielefeld.de
+ */
+@Deprecated
+public class VerifyImage extends VerifyLinks {
+
+ @Deprecated
+ public void setImagedir(String imagedir) {
+ super.setResourcedir(imagedir);
+ }
+
+ @Deprecated
+ public void setImageDir(String imagedir) {
+ super.setResourcedir(imagedir);
+ }
+
+ @Deprecated
+ public void setImagedir(File imagedir) {
+ super.setResourcedir(imagedir);
+ }
+
+ @Deprecated
+ public void setImageDir(File imagedir) {
+ super.setResourcedir(imagedir);
+ }
+
+ @Deprecated
+ public void setIgnorePattern(String pattern) {
+ ignore_list.add(new Ignore(pattern));
+ }
+}
diff --git a/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyLinks.java b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyLinks.java
new file mode 100644
index 0000000..9a2b2f4
--- /dev/null
+++ b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyLinks.java
@@ -0,0 +1,395 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010-2012 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted 2010-2012 BiBiServ Curator Team"
+ *
+ * Contributor(s): Jan Krueger
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+import de.unibi.techfak.bibiserv.xml.NamespaceContext;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * VerifyImage is small tool class that compares all href/src links from the
+ * tool description with
+ *
+ *
+ * This class extends the ant Task class and overwrites its execute class.
+ *
+ *
+ * @author Jan Krueger - jkrueger(at)techfak.uni-bielefeld.de
+ */
+public class VerifyLinks extends AbstractVerifyTask {
+
+ List node_list = new ArrayList();
+ List resource_dir_list = new ArrayList();
+ List ignore_list = new ArrayList();
+ private File resourcedir;
+ private File out;
+
+ /**
+ * Default Constructor
+ */
+ public VerifyLinks() {
+ }
+
+ public VerifyLinks(File runnableitemfile, File resourcedir) throws Exception {
+ setRunnableitemfile(runnableitemfile);
+ setResourcedir(resourcedir);
+
+ }
+
+ @Override
+ public void execute() throws BuildException {
+
+ super.execute();
+
+
+ // add ignore elements from nested ignore elements
+ if (ignore_list != null && !ignore_list.isEmpty()) {
+ System.out.println("Ignore list : ");
+ for (Ignore i : ignore_list){
+ System.out.print( i + " ");
+ }
+ System.out.println("");
+ }
+
+ // check if image dir is set , a directory and readable
+ if (resourcedir == null || !resourcedir.isDirectory() || !resourcedir.canRead()) {
+ throw new BuildException("ImageDir '" + resourcedir + "' must be set, a directory and readable!");
+ }
+ // get all file entries
+ VerifyDownload.getDirEntries(resourcedir, resource_dir_list);
+
+ Document runnableitem;
+ try {
+ runnableitem = getRunnableitemAsDocument();
+ } catch (Exception e) {
+ throw new BuildException("An Exception occurred while converting a JAXB representation to W3C DOM document." + e.getMessage());
+ }
+
+
+
+ // get all image entries
+ try {
+ node_list = VerifyLinks.getImagesEntries(runnableitem, ignore_list);
+ System.out.println("Found images (XML): " + list2list(node_list));
+ } catch (XPathExpressionException e) {
+ throw new BuildException(e);
+ }
+
+ List result_list = new ArrayList();
+ List image_xml_list = list2list(node_list);
+ if (!compareEntries(image_xml_list, resource_dir_list, result_list)) {
+ image_xml_list.removeAll(result_list);
+ throw new BuildException("Entr(y|ies) (" + VerifyDownload.printList(image_xml_list) + ") missed in resource dir (" + resourcedir + ")!");
+ }
+
+ if (out == null) {
+ System.out.println("Attribute 'out' not set, don't modify " + getRunnableitemfile() + " !");
+ } else {
+ addPrefix(node_list, "applications/" + ((Attr) (runnableitem.getDocumentElement().getAttributes().getNamedItem("id"))).getValue() + "/resources/");
+ try {
+ NodetoStream(runnableitem, new FileOutputStream(out));
+ } catch (FileNotFoundException e) {
+ throw new BuildException(e);
+ }
+ System.out.println("Update runnableitem entries ...");
+ }
+ }
+
+
+
+ public final void setResourcedir(String resourcedir){
+ this.resourcedir = new File(resourcedir);
+ }
+
+
+ public final void setResourcedir(File resourcedir) {
+ this.resourcedir =resourcedir;
+ }
+
+ public void setIgnorepattern(String pattern) {
+ ignore_list.add(new Ignore(pattern));
+ }
+
+
+
+
+
+ public void setOut(File out) {
+ this.out = out;
+ }
+
+ public void setOut(String out) {
+ this.out = new File(out);
+ }
+
+ public List getImagesDirList() {
+ return resource_dir_list;
+ }
+
+ /**
+ * Return a list of nodes (DOM) describing an image source (AttributeNode).
+ *
+ * @param runnableitem - Tooldescriptiion to be searched.
+ * @return Return a list of nodes (DOM)
+ * @throws XPathExpressionException
+ */
+ public static List getImagesEntries(Document runnableitem) throws XPathExpressionException {
+ return getImagesEntries(runnableitem, null);
+ }
+
+ /**
+ * Return a list of nodes (DOM) describing an image source (AttributeNodes)
+ * and not matching a pattern from the ingnorelist.
+ *
+ * @param runnableitem - Tooldescriptiion to be searched.
+ * @param ignorelist - List of regexp pattern
+ * @return Return a list of nodes (DOM)
+ * @throws XPathExpressionException
+ */
+ public static List getImagesEntries(Document runnableitem, List ignorelist) throws XPathExpressionException {
+
+
+ XPathFactory xpathfactory = XPathFactory.newInstance();
+ XPath xpath = xpathfactory.newXPath();
+ NamespaceContext nsc = new NamespaceContext();
+
+ /**
+ * Set Namespaces
+ */
+ nsc.addNamespace("http://www.w3.org/XML/1998/namespace", "xml");
+ nsc.addNamespace("bibiserv:de.unibi.techfak.bibiserv.cms.microhtml", "microhtml");
+ nsc.addNamespace("bibiserv:de.unibi.techfak.bibiserv.cms.minihtml", "minihtml");
+ nsc.addNamespace("bibiserv:de.unibi.techfak.bibiserv.cms", "cms");
+
+
+ xpath.setNamespaceContext(nsc);
+ XPathExpression expr_src = xpath.compile("//*/@src"); //images
+ XPathExpression expr_href = xpath.compile("//*/@href"); // all other href
+
+
+ //minihtml
+ List nodelist = nodelist2list((NodeList) expr_src.evaluate(runnableitem, XPathConstants.NODESET));
+ //microhtml
+ nodelist.addAll(nodelist2list((NodeList) expr_href.evaluate(runnableitem, XPathConstants.NODESET)));
+
+ // if ignorelist is empty then we are finished and return the nodelist
+ if ((ignorelist == null) || ignorelist.isEmpty()) {
+ return nodelist;
+ }
+
+ // otherwise if have to check each node against the pattern from the ignorelist
+
+ List resultlist = new ArrayList();
+
+ for (Node n : nodelist) {
+ boolean t = true;
+ for (Ignore ignore : ignorelist) {
+
+ if (n.getTextContent().matches(ignore.getRegexp())) {
+ t = false;
+ break;
+ }
+
+
+ }
+ if (t) {
+ resultlist.add(n);
+ }
+ }
+
+ return resultlist;
+ }
+
+ /**
+ * Take care that all list elements (Strings) from entries_from_xml are
+ * contained in entries_from_dir, but not vice versa. All found elements in
+ * stored in the resultlist.
+ *
+ *
+ * @param entries_from_xml
+ * @param entries_from_dir
+ * @param resultlist - EMPTY! list
+ * @return
+ */
+ public static boolean compareEntries(List entries_from_xml, List entries_from_dir, List resultlist) {
+ for (String entry_xml : entries_from_xml) {
+ if (inList(entries_from_dir, entry_xml)) {
+ resultlist.add(entry_xml);
+ }
+ }
+ return entries_from_xml.containsAll(resultlist) && entries_from_xml.size() == resultlist.size();
+ }
+
+ private static boolean inList(List l, String s) {
+ for (String e : l) {
+ if (s.equals(e)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Add a prefix for each node of the nodelist.
+ *
+ * @param nl
+ * @param prefix
+ */
+ public static void addPrefix(List nl, String prefix) {
+ for (Node n : nl) {
+ n.setTextContent(prefix + n.getTextContent());
+ }
+ }
+
+ public static void NodetoStream(Node node, OutputStream out) {
+ try {
+ Source source = new DOMSource(node);
+
+ Result result = new StreamResult(out);
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer();
+ transformer.transform(source, result);
+
+ } catch (TransformerConfigurationException e) {
+ e.printStackTrace();
+ } catch (TransformerException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static String NodeToString(Node node) {
+ try {
+ Source source = new DOMSource(node);
+ StringWriter stringWriter = new StringWriter();
+ Result result = new StreamResult(stringWriter);
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer();
+ transformer.transform(source, result);
+ return stringWriter.getBuffer().toString();
+ } catch (TransformerConfigurationException e) {
+ e.printStackTrace();
+ } catch (TransformerException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * private helper method, convert a unmodifyable nodelist (DOM) to a List of
+ * Nodes. \
+ *
+ * @param nl - nodelist (DOM)
+ * @return Return a list of nodes
+ */
+ private static List nodelist2list(NodeList nl) {
+ List tmp = new ArrayList();
+ for (int i = 0; i < nl.getLength(); ++i) {
+ tmp.add(nl.item(i));
+ }
+ return tmp;
+ }
+
+ /**
+ * private Helper method . Converts a list of Nodes to a list of Strings
+ * (Node textcontent)
+ *
+ * @param nl
+ * @return
+ */
+ public static List list2list(List nl) {
+ List r = new ArrayList();
+ for (Node n : nl) {
+ r.add(n.getTextContent());
+ }
+ return r;
+ }
+
+
+ /**
+ * Own static inner class for nested ignore elements
+ */
+ public static class Ignore {
+
+ private String regexp;
+
+ public Ignore(){
+
+ }
+
+ public Ignore(String regexp){
+ this.regexp = regexp;
+ }
+
+ public void setRegexp(String rexexp) {
+ this.regexp = rexexp;
+ }
+
+ public String getRegexp() {
+ return regexp;
+ }
+
+ @Override
+ public String toString() {
+ return regexp;
+ }
+
+
+
+ }
+
+
+
+ public Ignore createIgnore(){
+ Ignore ignore = new Ignore();
+ ignore_list.add(ignore);
+ return ignore;
+
+ }
+}
diff --git a/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyReferences.java b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyReferences.java
new file mode 100644
index 0000000..b9f921a
--- /dev/null
+++ b/tools/DeployTools/src/main/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyReferences.java
@@ -0,0 +1,82 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+import de.unibi.cebitec.bibiserv.util.bibtexparser.BibtexParser;
+import de.unibi.cebitec.bibiserv.util.bibtexparser.ParseException;
+import de.unibi.techfak.bibiserv.util.ontoaccess.bibiontotypes.BiBiPublication;
+import java.io.File;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ *
+ * @author jkrueger
+ */
+public class VerifyReferences extends AbstractVerifyTask {
+
+ public VerifyReferences() {
+ }
+
+ public VerifyReferences(File file) {
+ try {
+ setRunnableitemfile(file);
+ } catch (Exception ex) {
+ throw new BuildException(ex);
+ }
+ }
+
+
+
+ @Override
+ public void execute() throws BuildException {
+ super.execute();
+
+
+ //extract all references from runnableitem
+
+ if (getRunnableitem().isSetReferences() && getRunnableitem().getReferences().isSetReference()) {
+
+
+
+ List retlist = new ArrayList<>();
+ StringBuilder refbuf = new StringBuilder();
+ for (String string : getRunnableitem().getReferences().getReference()) {
+ refbuf.append(string);
+ refbuf.append("\n");
+ }
+ BibtexParser parser = new BibtexParser(new StringReader(refbuf.toString()));
+ try {
+ parser.parse();
+ retlist = parser.getPublicationObjects();
+ } catch (ParseException ex) {
+ System.err.println("Given String could not be parsed as bibreference. Error was:\n" + ex.getLocalizedMessage());
+ throw new BuildException(ex);
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyDownloadTest.java b/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyDownloadTest.java
new file mode 100644
index 0000000..918cd11
--- /dev/null
+++ b/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyDownloadTest.java
@@ -0,0 +1,155 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010-2016 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted 2016 BiBiServ"
+ *
+ * Contributor(s): Jan Krüger
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
+import java.io.File;
+import java.io.IOException;
+import javax.xml.bind.JAXBException;
+import org.apache.tools.ant.BuildException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Class providing test methods for VerifyDownload Class.
+ *
+ *
+ * @author Jan Krueger - jkrueger(at)cebitec.uni-bielefeld.de
+ */
+public class VerifyDownloadTest {
+
+ VerifyDownload vd;
+ File runnableitem = new File("src/test/resources/paramtesttool.bs2");
+ File downloaddir = new File("src/test/resources/resources/downloads");
+
+// File runnableitem = new File("/vol/bibi/share/bibiserv2_central/jkrueger/apps/guugle_20120207135611/config/runnableitem.xml");
+// File downloaddir = new File("/vol/bibi/share/bibiserv2_central/jkrueger/apps/guugle_20120207135611/resources/downloads");
+
+ public VerifyDownloadTest() {
+ try {
+ vd = new VerifyDownload(runnableitem, downloaddir);
+ vd.initialize();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ } catch (JAXBException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Test
+ public void testDirEntries() {
+ List resultlist = new ArrayList();
+ VerifyDownload.getDirEntries(downloaddir, resultlist);
+ // list should contain three entries
+
+ List expected_resultlist = new ArrayList();
+ expected_resultlist.add("file1.txt");
+ expected_resultlist.add("file2.txt");
+ expected_resultlist.add("subdir/file3.txt");
+
+
+ if (!resultlist.containsAll(expected_resultlist)) {
+ fail("resultlist (" + VerifyDownload.printList(resultlist) + ") isn't equal to expected result list (" + VerifyDownload.printList(expected_resultlist));
+ }
+
+ }
+
+ @Test
+ public void testDownloadEntries() {
+ List resultlist = new ArrayList();
+ vd.getDownloadableEntries(resultlist);
+
+ List expected_resultlist = new ArrayList();
+ expected_resultlist.add("file1.txt");
+
+ if (!resultlist.containsAll(expected_resultlist)) {
+ fail("resultlist (" + VerifyDownload.printList(resultlist) + ") isn't equal to expected result list (" + VerifyDownload.printList(expected_resultlist));
+ }
+
+ }
+
+ @Test
+ public void testCompareEntries() {
+ List list1 = new ArrayList();
+ List list2 = new ArrayList();
+ List resultlist = new ArrayList();
+
+ VerifyDownload.getDirEntries(downloaddir, list1);
+ vd.getDownloadableEntries(list2);
+
+ System.out.println("list 1 ::"+VerifyDownload.printList(list1));
+ System.out.println("list 2 ::"+VerifyDownload.printList(list2));
+
+ // compareEntries should return false
+ if (VerifyDownload.compareEntries(list1, list2, resultlist)) {
+ fail("Since list1 and list2 aren't equal, compareEntries should return false!");
+ }
+
+ // list1 should contain two elements
+ if (list1.size() != 2) {
+ fail("List1 should contain two list elements, but contains (" + VerifyDownload.printList(list1) + ")");
+ }
+
+ // list2 should be empty
+ if (!list2.isEmpty()) {
+ fail("List2 should be empty, but contains (" + VerifyDownload.printList(list2) + ")");
+ }
+
+ // resultlist shoudl could contain one elment ("file1.txt")
+ if (resultlist.size() != 1 && !resultlist.get(0).equals("file1.txt")) {
+ fail("Expected one element named \"file1.txt\" in resultlist, got " + resultlist.size() + " element(s) containing " + VerifyDownload.printList(resultlist));
+ }
+
+
+
+
+ }
+
+ @Test
+ public void testExecute() {
+ vd = new VerifyDownload();
+ try {
+ vd.setDownloaddir(downloaddir);
+ vd.setRunnableitemfile(runnableitem);
+ vd.execute();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ } catch (JAXBException e) {
+ fail(e.getMessage());
+ } catch (BuildException e) {
+ System.out.println(e.getMessage());
+ }
+ }
+}
diff --git a/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyLinksTest.java b/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyLinksTest.java
new file mode 100644
index 0000000..3d02f01
--- /dev/null
+++ b/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyLinksTest.java
@@ -0,0 +1,191 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010-2016 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted 2016 BiBiServ"
+ *
+ * Contributor(s): Jan Krüger
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+import de.unibi.techfak.bibiserv.deploy.tools.VerifyLinks.Ignore;
+import org.w3c.dom.Document;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.NamedNodeMap;
+import static org.junit.Assert.*;
+
+/**
+ * Class providing tests for validating links.
+ *
+ *
+ * @author @author Jan Krueger - jkrueger(at)cebitec.uni-bielefeld.de
+ */
+public class VerifyLinksTest {
+
+ VerifyLinks vi;
+ final static File runnableitem = new File("src/test/resources/paramtesttool.bs2");
+ final static File resourcedir = new File("src/test/resources/resources");
+ final static List ignorelist = Arrays.asList(new Ignore("http.*"),new Ignore("/.*"), new Ignore("#.*$") );
+
+ public VerifyLinksTest() {
+ try {
+ vi = new VerifyLinks(runnableitem, resourcedir);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Test
+ public void testGetImagesEntries_without_ignorelist() {
+ try {
+ System.out.println("test getImagesEntries(doc)");
+
+ List result_1 = VerifyLinks.list2list(VerifyLinks.getImagesEntries(vi.getRunnableitemAsDocument()));
+ List expected_result_1 = Arrays.asList(
+ "images/parameter_block.png",
+ "images/parameter_block.png",
+ "images/The_Earth_seen_from_Apollo_17.jpg",
+ "http://en.wikipedia.org/wiki/ICEfaces",
+ "http://de.wikipedia.org/wiki/ICEfaces",
+ "/cg-cat?viewType=manual",
+ "/cg-cat?viewType=references",
+ "http://java.sun.com/products/javawebstart/download.jsp",
+ "http://java.sun.com/javase/6/webnotes/6u11.html#rootcertificates-1.6.0_11",
+ "http://mailhide.recaptcha.net/d?k=01SmXl276guo9S44_bhjUwPA==&c=K12sZO1-T7B5Py34tWDH9eiSTcMzz6gz6z5BdAF9MCMK6wRoGjVn801PpJHHfeT6",
+ "http://www.gnu.org/licenses/gpl-3.0-standalone.html",
+ "http://mailhide.recaptcha.net/d?k=01SmXl276guo9S44_bhjUwPA==&c=K12sZO1-T7B5Py34tWDH9eiSTcMzz6gz6z5BdAF9MCMK6wRoGjVn801PpJHHfeT6",
+ "/cgi-bin/treecat_start",
+ "webstart/treecat_splash64px.gif",
+ "webstart/treecat_splash64px.gif",
+ "http://java.sun.com/products/autodl/j2se",
+ "webstart/cg-cat.jar",
+ "http://bibiserv.cebitec.uni-bielefeld.de",
+ "#test",
+ "/rnamovies?viewType=references",
+ "example/test.fas");
+
+ if (!expected_result_1.containsAll(result_1)) {
+ fail("resultlist \n(" + VerifyDownload.printList(result_1) + ")\n isn't equal to expected result list \n(" + VerifyDownload.printList(expected_result_1) + ")");
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail(ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetImagesEntries_with_ignorelist() throws Exception {
+ System.out.println("test getImagesEntries(dox,ignorelist)");
+
+
+
+
+ List result_2 = VerifyLinks.list2list(VerifyLinks.getImagesEntries(vi.getRunnableitemAsDocument(), ignorelist));
+ List expected_result_2 = Arrays.asList(
+ "images/parameter_block.png",
+ "images/parameter_block.png",
+ "images/The_Earth_seen_from_Apollo_17.jpg",
+ "webstart/treecat_splash64px.gif",
+ "webstart/treecat_splash64px.gif",
+ "webstart/cg-cat.jar",
+ "example/test.fas");
+
+
+
+ if (!expected_result_2.containsAll(result_2)) {
+ fail("resultlist (" + VerifyDownload.printList(result_2) + ") isn't equal to expected result list (" + VerifyDownload.printList(expected_result_2) + ")");
+ }
+
+
+ }
+
+ @Test
+ public void testCompareEntries() throws Exception {
+ System.out.println("test compareEntries() [with ignorelist]");
+ List result_3a = VerifyLinks.list2list(VerifyLinks.getImagesEntries(vi.getRunnableitemAsDocument(), ignorelist));
+ List result_3b = new ArrayList<>();
+ VerifyDownload.getDirEntries(resourcedir, result_3b);
+ List result_3c = new ArrayList<>();
+
+ if (!VerifyLinks.compareEntries(result_3a, result_3b, result_3c)) {
+
+
+
+ System.out.println("a:" + VerifyDownload.printList(result_3a));
+ System.out.println("b:" + VerifyDownload.printList(result_3b));
+ System.out.println("c:" + VerifyDownload.printList(result_3c));
+
+ result_3a.removeAll(result_3c);
+ fail("Entr(y|ies) " + VerifyDownload.printList(result_3a) + " missed in download dir!");
+ }
+
+
+
+
+
+
+ }
+
+ @Test
+ public void testReplace() throws Exception {
+ System.out.println("testReplace()");
+
+ Document doc = vi.getRunnableitemAsDocument();
+
+ NamedNodeMap nnm = doc.getDocumentElement().getAttributes();
+ Node n = nnm.getNamedItem("id");
+ String id = ((Attr) n).getValue();
+
+
+ List result_4 = VerifyLinks.getImagesEntries(doc,ignorelist);
+ VerifyLinks.addPrefix(result_4, "applications/" + id + "/");
+
+ System.out.println(VerifyLinks.NodeToString(doc));
+
+ }
+
+
+ @Test
+ public void testRegExp(){
+ String pattern = "http.*";
+
+ String text1 = "http://bibiserv";
+ String text2 = "/http/bibiserv";
+
+ assertTrue(text1.matches(pattern));
+
+ assertFalse(text2.matches(pattern));
+
+ }
+}
diff --git a/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyReferencesTest.java b/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyReferencesTest.java
new file mode 100644
index 0000000..5ac06c0
--- /dev/null
+++ b/tools/DeployTools/src/test/java/de/unibi/techfak/bibiserv/deploy/tools/VerifyReferencesTest.java
@@ -0,0 +1,100 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010-2016 BiBiServ Curator Team, http://bibiserv.cebitec.uni-bielefeld.de,
+ * All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common
+ * Development and Distribution License("CDDL") (the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at http://www.sun.com/cddl/cddl.html
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License. When distributing the software, include
+ * this License Header Notice in each file. If applicable, add the following
+ * below the License Header, with the fields enclosed by brackets [] replaced
+ * by your own identifying information:
+ *
+ * "Portions Copyrighted 2016 BiBiServ"
+ *
+ * Contributor(s): Jan Krüger
+ *
+ */
+package de.unibi.techfak.bibiserv.deploy.tools;
+
+import java.io.File;
+import org.apache.tools.ant.BuildException;
+import org.junit.*;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Jan Krueger - jkrueger(at)cebitec.uni-bielefeld.de
+ */
+public class VerifyReferencesTest {
+
+ VerifyReferences vr;
+ final static File runnableitemOk = new File("src/test/resources/rnamovies.bs2");
+ final static File runnableitemFail = new File("src/test/resources/ceged.bs2");
+
+ public VerifyReferencesTest() {
+
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of execute method, of class VerifyReferences.
+ */
+ @Test
+ public void testExecute() {
+
+ // should be ok
+ try {
+ vr = new VerifyReferences(runnableitemOk);
+
+ } catch (BuildException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ try {
+ vr.execute();
+ } catch (BuildException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ // should be failed
+ try {
+ vr = new VerifyReferences(runnableitemFail);
+
+ } catch (BuildException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ try {
+ vr.execute();
+ fail("Broken reference are ok ???");
+ } catch (BuildException e) {
+ e.printStackTrace();
+
+ }
+
+ }
+}
diff --git a/tools/DeployTools/src/test/resources/ceged.bs2 b/tools/DeployTools/src/test/resources/ceged.bs2
new file mode 100644
index 0000000..089f346
--- /dev/null
+++ b/tools/DeployTools/src/test/resources/ceged.bs2
@@ -0,0 +1,175 @@
+
+
+ CEGeD
+ Calculate Evolutionary Genome Distances
+
+ CEGeD (Calculate Evolutionary Genome Distances) computes the Inversion distance,
+ the Translocation distance and the Double-Cut-and-Join distance of genomes. The genome
+ data can be read from files or typed in manually in the program. The comparisons are
+ shown as text and as graphic, and can be saved to files. CEGeD is an extension of the
+ DCJ tool.
+ The Double-Cut-and-Join operation was first introduced by Yancopoulos et al.
+ [YAN:ATT:FRI:2005].
+ A simpler treatment and a more concise model, presented in [BEG:MIX:STO:2006], is
+ implemented in our CEGeD tool.
+
+ Calculate Evolutionary Genome Distances
+ Evolutionary Genome Distances
+
+ Rafael
+ Friesen
+ Bielefeld university, CeBiTec, IFB, GI
+ rfriesen@cebitec.uni-bielefeld.de
+
+
+ Julia
+ Mixtacki
+ unknown
+
+
+ Jens
+ Stoye
+ Bielefeld university, CeBiTeC, IFB, GI
+ stoye@techfak.uni-bielefeld.de
+
+
+ BiBiServ
+ administrators
+ Bielefeld university, CeBiTeC, IFB, BiBiServ
+ bibiadm@cebitec.uni-bielefeld.de
+
+
+
+ @article{BEG:MIX:STO:2006, author={A. Bergeron and J. Mixtacki and J. Stoye},
+ title={A unifying view of genome rearrangements.}, year=2006, journal={Proceedings of
+ WABI 2006}, doi={10.1007/11851561} }
+
+ @article{YAN:ATT:FRI:2005, author={S. Yancopoulos and O. Attie and R. Friedberg},
+ title={Efficient sorting of genomic permutations by translocation, inversion and block
+ interchange}, year=2005, journal={Bioinformatics}, doi={10.1093/bioinformatics/bti535}
+
+
+
+
+
+
+
+
+ Webstart
+ CEGeD uses Java WebStart facilities to allow full-featured applications
+ to be launched with just a single-click of a mouse. At least Java 1.5 or newer is needed
+ to run CEGeD.
+
+
+ CEGeD online version is based on Java
+ WebStart version 1.0.1 or higher.
+ If you do not have a Java Runtime Environment version 1.5.0 or higher
+ installed, or if you are working on Solaris/Linux and never previously used Java
+ WebStart, please follow these installation
+ instructions.
+ The file size of the CEGeD program is about 48 KBytes.
+
+
+
+
+ CEGeD
+ Rafael Friesen
+ CEGeD - Calculate Evolutionary Genome Distances
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Genome Representation
+
+ Every file can contain several genomes.
+ Every genome starts with a name line: > followed by the genome
+ name.
+ In the following line(s) come the genes separated by
+ whitespaces.
+ Each chromosome is concluded by ) or |. A ) concludes a circular
+ chromosome, a | concludes a linear chromosome.
+ The gene names can contain all signs except whitespaces. A minus (-)
+ before a gene name means that the gene direction is backwards.
+ Every line that starts with // has no function and is a comment-line.
+ Everything before the first genome is a comment, too.
+ Example for a Genome:
+
+
+ Genome1 a c -d | b e ) f g |
+
+
+
+
+
+
+
+ A simple example file can be found here. A more complex example file that shows more possibilities
+ (comments and more) can be found here.
+ DCJ Sorting The program computes DCJ - distance and an optimal
+ sorting scenario. DCJ Sorting example:
+
+
+ a c -d | b e ) f g | a g | b e ) d -c -f |
+ a g ) b e ) d -c -f | a b e g ) d -c -f | d -b -a
+ -g -e -c -f | c f ) d -b -a -g -e | a e g ) b -d |
+ c f )
+
+
+
+
+ DCJ-operations in the example: Translocation
+ Closure Fusion of two circular chromosomes Fusion of
+ linear and circular chromosome Fission with closure
+ Fission with closure
+
+ For more explanation how the DCJ operations are defined look at . Program Usage - Step By
+ Step
+
+ To load genomes from file click on Load Genomes and choose one or more
+ files that contains at least one genome.
+ If you want to compare example genomes click on Example
+ Genomes.
+ If you want to open a genome editor to type in genomes manually click on
+ Editor, then
+ Type in the genomes in the editor window
+ Click on Add to add the typed genomes to the genome list of
+ CEGeD
+ To remove genomes from that list you can also use the editor
+ window: choose a genome and click on Remove.
+
+
+ Choose the genomes to compare in the lists in the main window
+ By pressing the Button Run the genomes will be compared
+ The results are shown in the tabs. The top tab row is for choosing the
+ comparison method. The second tab row is for switching between graphic result
+ and text result.
+ After running a comparison you can save the results by first opening the
+ Save Results window and then choosing which results should be saved by clicking
+ on the corresponding Buttons. Graphic results will be saved as PNG
+ graphics.
+ All values can be cleared with the Clear button.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/DeployTools/src/test/resources/paramtesttool.bs2 b/tools/DeployTools/src/test/resources/paramtesttool.bs2
new file mode 100644
index 0000000..8ea571d
--- /dev/null
+++ b/tools/DeployTools/src/test/resources/paramtesttool.bs2
@@ -0,0 +1,617 @@
+
+
+ ParameterTestTool
+ ParameterTestWerkzeug
+ This is a tool for testing all parameter possibilities
+ Dieses Werkzeug dient ausschließlich dem Test aller Parameter Möglichkeiten, die
+ derzeit von dem BiBiServ2 Framework unterstützt werden.
+ This a testing tool. It's only purpose is to test all parameter combinations with different types and views, which are
+ supported by the BiBiServ2 framework.
+ Dieses Werkzeug ist ein Testtool. Es dient ausschliesslich dem Test aller Parameter Kombinationen und deren Darstellung im Browser.
+ Aus bioinformatischer Sicht macht das Werkzeug dementsprechend keine Sinn.
+
+
+
+ Jan
+ Krüger
+ BiBiServ - CeBiTec - Bielefeld University
+ jkrueger@cebitec.uni-bielefeld.de
+
+
+ Joe
+ User
+ Faculty of Dummy Users - Bielefeld University
+
+
+
+
+ BiBiServ
+ Mitarbeiter
+ bibi-help@cebitec.uni-bielefeld.de
+
+ This is sample text inside a custom conten field. The text make absolutly no sense, beside filling the field with content.
+
+ ICEfaces is an open source Ajax framework that enables Java EE application developers to create and deploy server-based rich Internet application
+ (RIA) using the Java language. ICEfaces leverages the entire standards-based Java EE ecosystem of tools and execution environments. Rich enterprise
+ application features are developed in pure Java, and in a pure thin-client model. There are no Applets or proprietary browser plug-ins required.
+ ICEfaces applications are JavaServer Faces (JSF) applications, so Java EE application development skills apply directly and Java developers are
+ isolated from doing any JavaScript related development. (text copied from wikipedia).
+
+
+
+
+ ICEfaces ist ein auf JavaServer Faces (JSF) basierendes Ajax-Framework für Java, welches durch ICEsoft entwickelt wird. Seit November 2006 steht
+ das Projekt neben einer kommerziellen Lizenz auch unter der Mozilla Public License (MPL) zur Verfügung.
+ ICEfaces verfügt über eine umfangreiche Bibliothek an Komponenten für die Benutzerschnittstelle mit eingebauter Ajax-Funktionalität. Dazu gehören
+ beispielsweise Bäume, Tabs und Menüs. Diese Komponenten können in einer standardkonformen JSF-Seite verwendet werden. Im Gegensatz zu den üblichen
+ Komponenten einer Webseite können diese jedoch über Ajax mit dem Webcontainer kommunizieren und bei Bedarf Daten nachladen ohne dass die gesamte
+ Webseite neu geladen wird. Der Entwickler muss sich dabei nicht um die Details dieser Kommunikation kümmern, da diese im Hintergrund transparent
+ abläuft. Mit ICEfaces lassen sich so Rich Internet Application (RIA) entwickeln, ohne JavaScript programmieren zu müssen. Der schlussendlich im
+ Browser ausgeführte JavaScript-Code wird durch das Framework zur Laufzeit generiert. (Text von WikiPedia
+ kopiert).
+
+
+
+ 1.0
+
+ binary
+
+ echo
+
+
+ echo
+ Returns an echo of parameter inputs
+ Gibt die übergebenen Parameter als "echo" zurück.
+ The output is tool specific. All input parameter values are returned like
+ an echo.
+ Die Rückgabe ist Werkzeug spezifisch. Alle an das Werkzeug übergebenen Parameter werden als Liste zurückgeben.
+ ToolDependentRepresentation
+ STDOUT
+
+
+
+ boolean
+ boolean test parameter
+ This a boolean test parameter using the SELECTBOOLEANCHECKBOX.
+ boolean
+ -boolean
+ SELECTBOOLEANCHECKBOX
+
+
+ boolean(2)
+ boolean test parameter (2)
+ This a boolean test parameter using the INPUTTEXT.
+ boolean
+ -boolean2
+ INPUTTEXT
+
+
+ int
+ int test parameter
+ int test parameter with gui element inputtext.
+ int
+ -int
+ INPUTTEXT
+
+
+ int_min_max_default
+ int min max test parameter
+ int min max test parameter with gui element inputtext.
+ int
+ -int_max_min_default
+ 50
+ 0
+ 100
+ INPUTTEXT
+
+
+ float
+ float test parameter
+ Float test parameter with gui element inputext.
+ float
+ -float
+
+ INPUTTEXT
+
+
+ float_max_min_default
+ float test parameter with default value and min / max constraints
+ float test parameter with default value and min / max constraints and GUI
+element INPUTTEXT.
+ float
+ -float_min_max
+ 99.9
+ 90.5
+ 99.99
+ INPUTTEXT
+
+
+ string
+ string test parameter
+ string test parameter with gui element inputtext.
+ string
+ -string
+ INPUTTEXT
+
+
+ string_regexp
+ string test parameter with regexp constraint
+ string test parameter with regexp constraint and gui element inputtext.
+ string
+ -string_regexp
+ \d{0,5}\s.+
+ INPUTTEXT
+
+
+ string_min_max
+ string test parameter with min / max length restrictions
+ string test parameter with min / max length restrictions and gui element inputext.
+ string
+ 10
+ 100
+ INPUTTEXT
+
+
+ string_regexp_default
+ string test parameter with regexp restriction and default value
+ string test parameter with regexp restriction and default value and gui
+element textarea.
+ string
+ -string_regexp_default
+ ACGU
+ [ACGU]*
+ INPUTTEXTAREA
+
+
+ Enum SelectOneRadio
+ Enumaration test parameter. Choose one country selecting a radio button.
+ Enumeration test parameter using GUI element SELECTONERADIO. Choose one country selecting a radio button.
+ string
+ -lang_sor
+
+ DE
+ DE
+ German
+ Deutsch
+
+
+ US
+ US
+ United States of America
+ Vereinigte Staaten von Amerika
+
+
+ SE
+ SE
+ Sweden
+ Schweden
+
+
+ NL
+ NL
+ Netherland
+ Holland
+
+ SELECTONERADIO
+
+
+ Enum SelectOneListBox
+ Enumaration test parameter. Choose one country from the list box.
+ Enumeration test parameter using GUI element SELECTONELISTBOX. Choose one country from the list box.
+ string
+ -lang_sol
+
+ DE
+ DE
+ German
+ Deutsch
+
+
+ US
+ US
+ United States of America
+ Vereinigte Staaten von Amerika
+
+
+ SE
+ SE
+ Sweden
+ Schweden
+
+
+ NL
+ NL
+ Netherland
+ Holland
+
+ SELECTONELISTBOX
+
+
+ Enum SelectOneMenu
+ Enumaration test parameter. Choose one country from the menu.
+ Enumeration test parameter using GUI element SELECTONEMENU. Choose one country from the menu.
+ string
+ -lang_som
+
+ DE
+ DE
+ German
+ Deutsch
+
+
+ US
+ US
+ United States of America
+ Vereinigte Staaten von Amerika
+
+
+ SE
+ SE
+ Sweden
+ Schweden
+
+
+ NL
+ NL
+ Netherland
+ Holland
+
+ SELECTONEMENU
+
+
+ Enum SelectManyListBox
+ Enumaration test parameter. Choose one or more countries from the list box.
+ Enumeration test parameter using GUI element SELECTMANYLISTBOX. Choose one or more countries from the list box.
+ string
+ -lang_sml
+
+ DE
+ DE
+ German
+ Deutsch
+
+
+ US
+ US
+ United States of America
+ Vereinigte Staaten von Amerika
+
+
+ SE
+ SE
+ Sweden
+ Schweden
+
+
+ NL
+ NL
+ Netherland
+ Holland
+
+ SELECTMANYLISTBOX
+
+
+ Enum SelectManyMenu
+ Enumaration test parameter. Choose one or more countries from the menu.
+ Enumeration test parameter using GUI element SELECTMANYMENU. Choose one or more countries from the menu.
+ string
+ -lang_smm
+
+ DE
+ DE
+ German
+ Deutsch
+
+
+ US
+ US
+ United States of America
+ Vereinigte Staaten von Amerika
+
+
+ SE
+ SE
+ Sweden
+ Schweden
+
+
+ NL
+ NL
+ Netherland
+ Holland
+
+ SELECTMANYMENU
+
+
+ Enum SelectManyCheckBox
+ Enumeration test parameter. Select one or more countries from the checkboxes.
+ Enumeration test parameter using GUI element SELECTMANYCHECKBOX. Select one or more countries from the checkboxes.
+ string
+ -lang_smc
+
+ DE
+ DE
+ German
+ Deutsch
+
+
+ US
+ US
+ United States of America
+ Vereinigte Staaten von Amerika
+
+
+ SE
+ SE
+ Sweden
+ Schweden
+
+
+ NL
+ NL
+ Netherland
+ Holland
+
+ SELECTMANYCHECKBOX
+
+
+ all normal
+ Parameter group containing all "normal" parameters.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all enum
+ Parameter group containing all "enumeration" parameters.
+
+
+
+
+
+
+
+
+
+
+
+ Param Test Function
+ Function using a combination of all 'normal' parameter. All parameter values are returned as result.
+
+ The ParameterTestTool function Param Test Function is a simple echo function to test and explain all supported parameters. For simplicity this function hasn't
+ any input value. The BiBiServ2 CodeGen package currently support the following parameter:
+
+ boolean - checkbox/inputbox
+ int - inputbox with a default value and a restriction to a minimum/maximum value.
+ float - inputbox with a default value and a restriction to a minimum/maximum value.
+ string - inputbox with a restriction to a regular expression or to a minimum/maximum string length.
+
+ Currently only two(three) different views are supported. CheckBox for boolean based parameter and Inputbox
+ for all parameters independent of their type.
+ InputBoxes can be a single line textfield or textarea (latter makes only sense for string based parameters).
+ Each parameter is described by a so called parameter block element.
+
+ A parameter block consists of a parameter name (1), a parameter help action (2), which shows/hides the parameter help (3)
+ containing the parameter short description and all constraints/restrictions to this parameters, the parameter view itsself (4)
+ and an message block (5), which appears when validate the entered content.
+
+
+ Die ParameterTestWerkzeug Funktion Param Test Funktion ist eine Echo Funktion, um alle unterstützten parameter
+ darzustellen und zu testen. Um das Ganze möglichst einfach zu gestalten hat diese Funktion keine Eingabe Argumente. Das BiBiServ2 CodeGen
+ Paket unterstützt derzeit die folgenden Parameter :
+
+
+ boolean - checkbox/inputbox
+ int - inputbox with a default value and a restriction to a minimum/maximum value.
+ float - inputbox with a default value and a restriction to a minimum/maximum value.
+ string - inputbox with a restriction to a regular expression or to a minimum/maximum string length.
+
+
+ Derzeit werden nur zwei (bzw. drei) verschiedenen Ansichten unterstützt. CheckBoxen für Wahrheitswerte und Eingabefelder für
+ alle Parameter unabhängig von Ihrem Typ. Eingabefelder können ein- oder mehrzeilig sein. Jeder Parameter wird in der
+ xhtml (faces) Datei durch einen Parameterblock beschrieben :
+
+
+ Ein Parameterblock besteht aus einem Namen (1), einer Hilfe Schaltfläche (2), der Hilfe zu dem Parameter (3), der Parameter
+ Darstellung (4) und einem Nachrichten Block(5).
+
+
+
+ dummy
+
+
+
+
+
+ parametertesttool_output_echo
+ parametertesttool_param_boolean
+ parametertesttool_param_boolean2
+ parametertesttool_param_int
+ parametertesttool_param_int_min_max_default
+ parametertesttool_param_float
+ parametertesttool_param_float_max_min_default
+ parametertesttool_param_string
+ parametertesttool_param_string_regexp
+ parametertesttool_param_string_min_max
+ parametertesttool_param_string_regexp_default
+
+
+
+ Enumeration parameter test function
+ Function using a combination of all supported 'enum' parameter. All selected values are returned as result.
+
+ The ParameterTestTool function1 is an simple "echo" function to test and explain all supported enum parameters. For simplicity this function hasn't
+ any input value. The BiBiServ2 CodeGen package should currently support the following enumeration based parameter.
+
+ Select One Radiobutton
+ Select One ListBox
+ Select One Menu
+ Select Many Checkbox
+ Select Many ListBox
+ Select Many Menu
+
+ The only difference between all the Select One ... parameter is the view on the submission page. The function is the same. The user
+ select one key and the corresponding value is returned (optional leading with the content of the <option> tag. While the
+ Select One ... parameter return only one value (well, that's the reason why they are called Select One ...), all
+ Select Many ... parameter could return a list of values (as comma separated values in one string).
+
+
+
+ dummy2
+
+
+
+
+
+ parametertesttool_enum_selectoneradio
+ parametertesttool_enum_selectonelistbox
+ parametertesttool_enum_selectonemenu
+ parametertesttool_enum_selectmanycheckbox
+ parametertesttool_enum_selectmanylistbox
+ parametertesttool_enum_selectmanymenu
+ parametertesttool_output_echo
+
+
+
+
+ Sample Text File
+ file1.txt
+ This is sample short description for a simple text file.
+
+
+
+
+ Submission Page
+ Submission Seite
+
+ This Submission page is similar to the tool itself written for
+test purpose only.
+ This tool makes - from the view of bioinformatican - absolutely no
+sense. This text also is absolute nonsense and is only
+an bullshit sample for free content.
+
+
+ Diese Submission Seite ist ähnlich wie das Tool selbst nur für reine Testzwecke erstellt worden. Das
+ Werkzeug macht auch bioinformatischer Sicht absolut keinen Sinn und auch dieser Text
+ ist nur eine sinnfreie Buchstabenmenge, die (zufälligerweise) Wörter bilden.
+
+
+
+
+
+ Download Page
+ Download Seite
+
+
+
+
+ WebService Page
+ WebService Seite
+ No Custom Content
+
+
+
+
+ On this page you can start treecat to run locally on your computer. Just
+ click on the graphic or the link below:
+
+ On the manual page it is
+ described how to use this program.
+ If the program was useful for you, please cite it in your work.
+ Webstart
+ This program can be executed to run locally on your computer using the Java
+ WebStart technology. The download size to start the program is approximately 1
+ MByte.
+
+ If an error is issued during WebStart it is quite likely that your Java
+ version is too old. The program uses features of Java 1.6 (SE 6).
+ If you do not have a Java Runtime Environment version 1.6 or higher
+ installed, or if you are working on Solaris/Linux and never previously used Java
+ WebStart, please follow these installation
+ instructions.
+ Java WebStart might complain that it cannot verify the digital signature.
+ Our certificate is signed by Deutsche Telekom Root CA 2 which has been added to
+ the trusted certificates since Java Version 6 Update 11.
+
+ About
+ treecat was developed by Peter Husemann, Bielefeld University. The source code is available
+ under
+ GPL3. Please contact the author.
+ Acknowledgements
+ Thanks to Pina Krell and Roland Wittler for the Newick
+ parser.
+
+
+ treecat
+ Peter Husemann, Bielefeld University
+ treecat - Phylogenetic Tree based Contig Arrangement Tool
+ This is the tool treecat, which estimates a layout for a
+ set of contigs based on several related reference genomes and a phylogenetic
+ tree of the involved species.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is an introduction text for the tools manual. At this place normally
+all parameter, enumerations, inputs and functions are listed with their description and constraints. If this is not the
+case it isn't implemented, yet.
+ Die ist ein beispielhafter Einführungstext für die Anleitung des Tools. An dieser
+ Stelle sollten normalerweise alle Parameter, Aufzählungen und Ein-/Ausgabetypen und Funktionen erläutert werden. Falls
+ dies nicht der Fall, das ist diese Funktionalität leider noch nicht implementiert.
+ Every Manual page also supports a custom content area at the end of page. The author every
+ or any other authorized person can place additional explanation/description there. This a good place for e.g. a (short) description
+ of the algorithm of the tool.
+ Jede Beschreibungsseite enthält am Ende einen Bereich der vom Autor individuell mit Inhalt
+ versehen werden kann. Das ist u.a. eine gute Stelle um z.B. kurz den Algorithmus zu erklären der hinter dem Tool steckt. Die
+ Betonung liegt aber auf kurz, weitreichende wissenschaftliche Ergüsse sollte lieber in einem separaten Dokument im Downloadbereich
+ hinterlegt werden.Eine Liste von absoluten und relativen Links :
+
+ BiBiServ
+ GoTo start (relativer Link on same page to named anchor)
+ GoTo rnamovies references (absolute Link on same page)
+ Get test sequence data (relativer link)
+
+
+
+
diff --git a/tools/DeployTools/src/test/resources/resources/downloads/file1.txt b/tools/DeployTools/src/test/resources/resources/downloads/file1.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tools/DeployTools/src/test/resources/resources/downloads/file2.txt b/tools/DeployTools/src/test/resources/resources/downloads/file2.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tools/DeployTools/src/test/resources/resources/downloads/subdir/file3.txt b/tools/DeployTools/src/test/resources/resources/downloads/subdir/file3.txt
new file mode 100644
index 0000000..0cd29f4
--- /dev/null
+++ b/tools/DeployTools/src/test/resources/resources/downloads/subdir/file3.txt
@@ -0,0 +1 @@
+file3.txt ...
diff --git a/tools/DeployTools/src/test/resources/resources/downloads2/file1.txt b/tools/DeployTools/src/test/resources/resources/downloads2/file1.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tools/DeployTools/src/test/resources/resources/example/test.fas b/tools/DeployTools/src/test/resources/resources/example/test.fas
new file mode 100644
index 0000000..8c57564
--- /dev/null
+++ b/tools/DeployTools/src/test/resources/resources/example/test.fas
@@ -0,0 +1,2 @@
+>id descr
+ACGAUGCUCGAUCGUACGAUCGUACAUCAU
diff --git a/tools/DeployTools/src/test/resources/resources/images/The_Earth_seen_from_Apollo_17.jpg b/tools/DeployTools/src/test/resources/resources/images/The_Earth_seen_from_Apollo_17.jpg
new file mode 100644
index 0000000..e69de29
diff --git a/tools/DeployTools/src/test/resources/resources/images/parameter_block.png b/tools/DeployTools/src/test/resources/resources/images/parameter_block.png
new file mode 100644
index 0000000..e69de29
diff --git a/tools/DeployTools/src/test/resources/resources/webstart/cg-cat.jar b/tools/DeployTools/src/test/resources/resources/webstart/cg-cat.jar
new file mode 100644
index 0000000..378ab68
Binary files /dev/null and b/tools/DeployTools/src/test/resources/resources/webstart/cg-cat.jar differ
diff --git a/tools/DeployTools/src/test/resources/resources/webstart/treecat_splash64px.gif b/tools/DeployTools/src/test/resources/resources/webstart/treecat_splash64px.gif
new file mode 100644
index 0000000..9a0a75d
Binary files /dev/null and b/tools/DeployTools/src/test/resources/resources/webstart/treecat_splash64px.gif differ
diff --git a/tools/DeployTools/src/test/resources/rnamovies.bs2 b/tools/DeployTools/src/test/resources/rnamovies.bs2
new file mode 100644
index 0000000..fa0d41d
--- /dev/null
+++ b/tools/DeployTools/src/test/resources/rnamovies.bs2
@@ -0,0 +1,296 @@
+
+
+ RNA Movies
+ RNA Movies is a system for the visualization of RNA secondary structure landscapes.
+ Its input is a script consisting of structures from which animated graphical structure representations
+ are generated. In this way, it creates the impression of an RNA-molecule moving through its own 2D
+ structure space.
+
+
+ Sequential Animation of RNA secondary structure
+ including pseudoknots and entangled helices
+
+
+ RNAMovies is a system for the visualization of RNA secondary structure spaces, i.e. multiple sets of
+ secondary structure data. The program creates an interpolated animation of the data using the well-known
+ NAVIEW-routines. The highlighting of pseudo-knotted regions is also supported.
+
+
+ This page relates to the Java version of RNA Movies that replaces the former online-version as well
+ as the standalone-versions.
+
+ The new version features SVG-export for high quality graphics as well as several image formats
+ (JPEG,PNG and GIF). Single or multiple image export is supported. Additionally to its own formats RNAMovies supports DSCE and RNAStructML as input format
+
+
+ RNA Movies is a system for the visualization of RNA secondary structure landscapes.
+ RNA secondary structure visualisation
+
+ Alexander
+ Kaiser
+ Bielefeld university, technical faculty
+ akaiser@techfak.uni-bielefeld.de
+
+
+ Dirk
+ Evers
+ dirk.evers@cebitec.uni-bielefeld.de
+
+
+ Jan
+ Krueger
+ Bielefeld university, CeBiTec, BiBiServ
+ jkrueger@cebitec.uni-bielefeld.de
+
+
+ BiBiServ
+ Administrators
+ Bielefeld university, CeBiTec, BiBiServ
+ bibi-help@cebitec.uni-bielefeld.de
+
+
+ @article{KAI:KRUE:EVE:2007,
+ author={Kaiser, Alexander and Krueger, Jan and Evers, Dirk},
+ title={RNA Movies 2 : sequential animation of RNA secondary structures},
+ year=2007,
+ journal={Nucleic Acids Research},
+ doi={10.1093/nar/gkm309}
+ }
+
+ @article{EVE:GIE:1999,
+ author={Evers, Dirk and Giegerich, Robert},
+ title={RNA movies: visualizing RNA secondary structure spaces},
+ year=1999,
+ journal={BioInformatics},
+ doi={10.1093/bioinformatics/15.1.32}
+ }
+
+
+
+
+
+ RNAMovies
+ 2.04
+ rnamovies_src.tar.gz
+ Java Source package
+ Source/Java
+
+
+
+ RNAMovies
+ rnamovies.jar
+ Java 5 Binary package
+ Java 5
+
+
+ Download
+
+ Comment: Most of downloaded tools are compressed with gzip and
+ merged in a TAR - archive. They can be unpacked using gzip and tar on an unix like system or a
+ tool like winzip on a windows system.
+
+
+ Example using gzip/tar: gzip -cd "TOOL".tar.gz | tar xvf -
+
+
+ The BiBiServ team does not provide any support for compiling or using a tool from the download section.
+ Please contact the author directly in case of any problem.
+
+
+
+
+ Webstart
+
+ RNAMovies uses Java WebStart facilities to allow full-featured applications to be launched with just a single-click of a mouse.
+ At least Java 1.5 or newer is needed to run RNAMovies.
+
+
+
+ RNAMovies online version is based on Java WebStart
+ version 1.0.1 or higher.
+ If you do not have a Java Runtime Environment version 1.5.0 or higher installed, or
+ if you are working on Solaris/Linux and never previously used Java WebStart, please follow
+ these installation instructions.
+ The file size of the RNAMovies program is about 410 KBytes.
+
+
+
+
+ RNAMovies2
+ Alexander Kaiser
+ RNAMovies:Sequential Animation of RNA secondary structure
+ including pseudoknots and entangled helices
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The original RNA Movies, which is
+ available for download, is available for Unix-like systems only.
+ The new Java version is available for the Microsoft Windows platform as well.
+ The online version of RNA Movies is
+ available as applet (embedded into a website that features a
+ submission form) and WebStart application.
+
+ Menu and Toolbar
+
+ Most functions are self explainatory. The tool bar at the
+ bottom of the applet provides the following functionality (from
+ left to right):
+
+
+ Open movie
+
+ Play movie
+
+ Stop movie
+
+ Skip one frame
+ back
+
+ Skip one frame
+
+
+ File:
+
+
+ Open ...Open a movie in DSCE/RNM format
+
+
+ Import ...Import a movie in RNAStructML format
+
+
+ Export ...Export current movie as PNG/JPEG/SVG/(animated)GIF
+
+
+ Configure...Show the configuration panel
+
+
+
+
+ Movie:
+
+
+ PlayStart the animation
+
+
+ StopStop/Pause the animation
+
+
+ PreviousStep one frame back
+
+
+ NextSkip one frame
+
+
+ Goto Frame ...Goto a specific frame
+
+
+ View:
+
+
+
+
+ Zoom In
+ Zoom in by 25%
+
+
+ Zoom Out
+ Zoom out by 25%
+
+
+ Reset view
+ Reset zoom, rotation and moving
+
+
+
+
+ Help:
+
+
+ About...
+ Show references/credits
+
+
+
+ Mouse actions:
+
+
+ Left button
+ Move
+
+
+ Right button
+ Rotate
+
+
+ Mouse wheel
+ Zoom
+
+
+
+
+
+
+
+ Security
+
+ As mentioned before the 'online' RNA
+ Movies client is written in Java language and runs as an
+ applet in your browser's restricted enviroment called
+ sandbox. The access control policies
+ of such an enviroment are typically restricted in many ways. In
+ general applets cannot write files. Therefore we have digitally
+ signed the applet to enable users to use its import and export
+ functionality. This means that a warning dialog asks the user to
+ accept the applet's signature. For now we use a selfmade security
+ certificate which is not trusted.
+
+ Input data format
+
+ Since release 1.2 RNA Movies
+ supports two input formats. The RNAfold / Vienna format and DCSE
+ format. Both formats have been extended to include pseudoknots,
+ entangled helices, and structure description. The RNM format is
+ simpler and more intuitive while the DCSE format has more
+ possibilities. The current version (2.x) supports additionally to
+ its own format the DCSE format and RNAStructML
+ as input format.
+
+
+ Some Examples
+
+
+ BeetSoil-BorneVirus
+
+
+ LeptomonasCollosoma5'-Ende
+
+
+ HIV1-leader.3
+
+
+ Odontoglossum
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/ManagerClient/ivy.xml b/tools/ManagerClient/ivy.xml
new file mode 100644
index 0000000..a1090f9
--- /dev/null
+++ b/tools/ManagerClient/ivy.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/ManagerClient/pom.xml b/tools/ManagerClient/pom.xml
new file mode 100644
index 0000000..19b2eb0
--- /dev/null
+++ b/tools/ManagerClient/pom.xml
@@ -0,0 +1,48 @@
+
+
+ 4.0.0
+ de.unibi.cebitec.bibiserv
+ managerclient
+ stable.release
+ jar
+ ManagerClient
+
+
+
+ snapshot-repository.java.net
+ Java.net Snapshot Repository for Maven
+ https://maven.java.net/content/repositories/snapshots/
+ default
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+
+
+
+
+ com.sun.jersey
+ jersey-client
+ 1.19.2
+
+
+
+
+ org.apache.ant
+ ant
+ 1.9.0
+ compile
+
+
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
diff --git a/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/AntTaskDefClassLoader.java b/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/AntTaskDefClassLoader.java
new file mode 100644
index 0000000..d5e4852
--- /dev/null
+++ b/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/AntTaskDefClassLoader.java
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package de.unibi.cebitec.bibiserv.client.manager;
+
+/**
+ *
+ * @author jkrueger
+ */
+public class AntTaskDefClassLoader extends ClassLoader{
+
+ @Override
+ protected Class> findClass(String name) throws ClassNotFoundException {
+ System.err.println(System.getProperty("java.class.path"));
+
+ return super.findClass(name);
+ }
+
+
+
+}
diff --git a/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/ManagerClient.java b/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/ManagerClient.java
new file mode 100644
index 0000000..222667a
--- /dev/null
+++ b/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/ManagerClient.java
@@ -0,0 +1,267 @@
+package de.unibi.cebitec.bibiserv.client.manager;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.client.urlconnection.HTTPSProperties;
+import java.io.BufferedReader;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.Properties;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import javax.ws.rs.core.MediaType;
+
+/**
+ *
+ * @author jkrueger
+ */
+public class ManagerClient {
+
+ private Properties bibiserv2_manager;
+ private static File pwdfile = new File(System.getProperty("user.home") + "/.bibiserv2_manager");
+ private WebResource res = null;
+
+ public ManagerClient() throws Exception {
+ this(null, null, null);
+ }
+
+ /**
+ * Initialize the ManagerClient
+ *
+ *
+ * @param server - server to be used, overwrites ~/.bibiserv2_manager
+ * settings
+ * @param port - server to be used, overwrites ~/.bibiserv2_manager settings
+ * @param ssl - server to be used, overwrites ~/.bibiserv2_manager settings
+ * @throws Exception
+ */
+ public ManagerClient(String server, String port, Boolean ssl) throws Exception {
+ bibiserv2_manager = readBiBiServ2PropertiesFile();
+ if (server == null || port == null || ssl == null) {
+ server = bibiserv2_manager.getProperty("server");
+ port = bibiserv2_manager.getProperty("port");
+ ssl = new Boolean(bibiserv2_manager.getProperty("ssl"));
+ if (server == null || port == null || ssl == null) {
+ System.err.println("Properties 'server', 'port' and 'ssl' must be set within the '" + pwdfile + "'!");
+ System.exit(1);
+
+ }
+ }
+
+ // create url
+ String url = (ssl ? "https" : "http") + "://" + server + ":" + port + "/rest";
+
+ Client client = Client.create(createClientConfig());
+
+ res = client.resource(url);
+
+ }
+
+ /**
+ * Deploy an application to server
+ *
+ * @param zipfile
+ * @throws Exception
+ */
+ public void deploy(File zipfile) throws Exception {
+ /* read zipfile into bytestream */
+ InputStream in = new FileInputStream(zipfile);
+ byte[] bytes = new byte[(int) zipfile.length()];
+
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length
+ && (numRead = in.read(bytes, offset, bytes.length - offset)) >= 0) {
+ offset += numRead;
+ }
+ in.close();
+
+ try {
+ res.path("manager").
+ type(MediaType.APPLICATION_OCTET_STREAM).
+ header("authorization", "basic "+bibiserv2_manager.get("role") + ":" + bibiserv2_manager.get("password")).
+ put(bytes);
+ System.out.println("successful!");
+ } catch (UniformInterfaceException e) {
+ String answer = is2string(e.getResponse().getEntityInputStream());
+ if (answer == null || answer.isEmpty()) {
+ System.err.println(e.getMessage());
+ } else {
+ System.err.println(answer);
+ }
+ }
+
+ }
+
+ /**
+ * Undeploy an application from server
+ *
+ * @param name
+ * @throws ManagerException_Exception
+ */
+ public void undeploy(String name) {
+ try {
+ res.path("manager").
+ type(MediaType.TEXT_PLAIN).
+ header("authorization", "basic "+bibiserv2_manager.get("role") + ":" + bibiserv2_manager.get("password")).
+ put(name);
+ System.out.println("successful!");
+ } catch (UniformInterfaceException e) {
+ String answer = is2string(e.getResponse().getEntityInputStream());
+ if (answer == null || answer.isEmpty()) {
+ System.err.println(e.getMessage());
+ } else {
+ System.err.println(answer);
+ }
+ }
+ }
+
+ /**
+ * Static method that look for an Java Properties file
+ * (System.getProperty("user.home") + "/.bibiserv2_manager") containing two
+ * Java properties 'role' and 'password'. Throws an exception with enhanced
+ * error message, if properties file doesn't exists, can't be read as
+ * property file or doesn;t contain not all the both necessary properties.
+ * Return a Properties object with at least two properties ('role' and
+ * 'password').
+ *
+ *
+ *
+ * @return Return a Properties object with at least two properties ('role'
+ * and 'password').
+ * @throws Throws an Exception if properties file can't be read (see above).
+ */
+ public static Properties readBiBiServ2PropertiesFile() throws Exception {
+
+ // check if ~/.bibiserv2_manager file exists and contains a user, passwort pair
+
+
+ String message = "Create a password(property)file '" + pwdfile.toString() + "' containing two Java properties;\n"
+ + "role and password\n\n"
+ + "Example:\n"
+ + "# bibimainapp manager admin role [required] \n"
+ + "role=dummy\n"
+ + "# bibimainapp manager admin role password [required] \n"
+ + "password=my_password\n"
+ + "# server host name \n"
+ + "server=bibiserv2.cebitec.uni-bielefeld.de\n"
+ + "# server port\n"
+ + "port=443\n"
+ + "# use ssl\n"
+ + "ssl=true\n\n";
+
+
+ if (!pwdfile.exists() || !pwdfile.isFile()) {
+ throw new Exception("Passwordfile '" + pwdfile.toString() + "' not found ...\n" + message);
+ }
+ Properties pwdprop = new Properties();
+ pwdprop.load(new FileReader(pwdfile));
+
+ if (!(pwdprop.containsKey("role") && pwdprop.containsKey("password"))) {
+ throw new Exception("Passwordfile '" + pwdfile.toString() + "' found, but contains wrong or no properties ...\n" + message);
+ }
+ if (pwdprop.containsKey("server")) {
+ if (!pwdprop.containsKey("port")) {
+ pwdprop.setProperty("port", "80");
+ }
+
+ }
+
+ return pwdprop;
+ }
+
+ public static void main(String args[]) {
+ try {
+ // get home dir
+
+
+ if (!(args.length == 2 || args.length == 5)) {
+ System.err.println("usage: java " + ManagerClient.class.getName() + "\n"
+ + "\t deploy ()\n"
+ + "\t undeploy name/id ()\n\n"
+ + "(If server, port and ssl are not given the values from ~/.bibiserv2_manager are used instead!");
+ System.exit(1);
+ }
+
+ ManagerClient app;
+ if (args.length == 2) {
+ app = new ManagerClient();
+ } else {
+ app = new ManagerClient(args[2], args[3], new Boolean(args[4]));
+ }
+ switch (args[0]) {
+ case "deploy":
+ app.deploy(new File(args[1]));
+ break;
+ case "undeploy":
+ app.undeploy(args[1]);
+ break;
+ default:
+ System.err.println("Unsupported command '" + args[0] + "'!");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private ClientConfig createClientConfig() throws Exception {
+ // Create a trust manager that does not validate certificate chains
+ TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ }
+ }};
+
+// Install the all-trusting trust manager
+
+ SSLContext sc = SSLContext.getInstance("TLS");
+ sc.init(null, trustAllCerts, new SecureRandom());
+ HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+
+
+ ClientConfig config = new DefaultClientConfig();
+ config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(
+ new HostnameVerifier() {
+ @Override
+ public boolean verify(String s, SSLSession sslSession) {
+ return true;
+ }
+ }, sc));
+ return config;
+ }
+
+ private static String is2string(InputStream is) {
+
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ String line;
+ StringBuilder sb = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ sb.append(line);
+ }
+ return sb.toString();
+ } catch (IOException e) {
+ return e.getMessage();
+ }
+ }
+}
diff --git a/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/ManagerClientTask.java b/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/ManagerClientTask.java
new file mode 100644
index 0000000..9514cf0
--- /dev/null
+++ b/tools/ManagerClient/src/main/java/de/unibi/cebitec/bibiserv/client/manager/ManagerClientTask.java
@@ -0,0 +1,84 @@
+package de.unibi.cebitec.bibiserv.client.manager;
+
+import java.io.File;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ *
+ * @author Jan Krueger - jkrueger(at)cebitec.uni-bielefeld.de
+ */
+public class ManagerClientTask extends Task {
+
+ private String action;
+ private String server;
+ private String port;
+ private String file;
+ private String name;
+ private Boolean ssl;
+ private String usage = "";
+ private ManagerClient managerclient;
+
+ @Override
+ public void execute() throws BuildException {
+
+ try {
+ // initialize ManagerApplication
+ if (server != null) {
+ managerclient = new ManagerClient("server", (port == null) ? "80" : port, false);
+ } else {
+ managerclient = new ManagerClient();
+ }
+
+
+ if (action != null) {
+ if (action.equals("deploy")) {
+ if (file != null && (new File(file).exists())) {
+ managerclient.deploy(new File(file));
+ } else {
+ new BuildException(usage);
+ }
+ } else if (action.equals("undeploy")) {
+ if (name != null) {
+ managerclient.undeploy(name);
+ } else {
+ new BuildException(usage);
+ }
+ } else {
+ new BuildException("no Action given :" +usage);
+ }
+ } else {
+ new BuildException(usage);
+ }
+ } catch (Exception e) {
+ throw new BuildException(e);
+ }
+
+
+
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public void setServer(String server) {
+ this.server = server;
+ }
+
+ public void setSsl(Boolean ssl){
+ this.ssl = ssl;
+ }
+}
diff --git a/tools/ManagerClient/src/main/rescources/config/log4j.properties b/tools/ManagerClient/src/main/rescources/config/log4j.properties
new file mode 100644
index 0000000..e9bc17a
--- /dev/null
+++ b/tools/ManagerClient/src/main/rescources/config/log4j.properties
@@ -0,0 +1,12 @@
+log4j.rootLogger=error, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%-5p (%d) %m [%F:%L]%n
+
+log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.file.File=/vol/bibiwssv/spool/dialign/dialign.log
+log4j.appender.file.DatePattern=.yyyy-MM-dd
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%-5p (%d) %m [%F:%L]%n
+
diff --git a/tools/pom.xml b/tools/pom.xml
new file mode 100644
index 0000000..8b23a5a
--- /dev/null
+++ b/tools/pom.xml
@@ -0,0 +1,34 @@
+
+
+ 4.0.0
+ de.unibi.cebitec.bibiserv
+ tools
+ stable.release
+ pom
+ Tools
+
+
+
+ snapshot-repository.java.net
+ Java.net Snapshot Repository for Maven
+ https://maven.java.net/content/repositories/snapshots/
+ default
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+
+ DeployTools
+ ManagerClient
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+