applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / utils / ProvenanceStuff.java
1 /*\r
2  * This file is part of the Vamsas Client version 0.1. \r
3  * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, \r
4  *  Andrew Waterhouse and Dominik Lindner.\r
5  * \r
6  * Earlier versions have also been incorporated into Jalview version 2.4 \r
7  * since 2008, and TOPALi version 2 since 2007.\r
8  * \r
9  * The Vamsas Client is free software: you can redistribute it and/or modify\r
10  * it under the terms of the GNU Lesser General Public License as published by\r
11  * the Free Software Foundation, either version 3 of the License, or\r
12  * (at your option) any later version.\r
13  *  \r
14  * The Vamsas Client is distributed in the hope that it will be useful,\r
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  * GNU Lesser General Public License for more details.\r
18  * \r
19  * You should have received a copy of the GNU Lesser General Public License\r
20  * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.\r
21  */\r
22 package uk.ac.vamsas.objects.utils;\r
23 \r
24 import java.util.Date;\r
25 \r
26 import org.apache.commons.logging.Log;\r
27 import org.apache.commons.logging.LogFactory;\r
28 \r
29 import uk.ac.vamsas.objects.core.Entry;\r
30 import uk.ac.vamsas.objects.core.Provenance;\r
31 \r
32 public class ProvenanceStuff {\r
33 \r
34   /**\r
35    * stuff for making and doing things with provenance objects.\r
36    */\r
37   static Log log = LogFactory.getLog(ProvenanceStuff.class);\r
38 \r
39   /**\r
40    * @param app\r
41    *          TODO\r
42    * @param action\r
43    *          text for action entry\r
44    * @return new Provenance entry for ArchiveWriter created docs. TODO: Verify\r
45    *         and move to SimpleClient class for provenance handling\r
46    */\r
47   public static Entry newProvenanceEntry(String app, String user, String action) {\r
48     log.debug("Adding ProvenanceEntry(" + user + "," + action + ")");\r
49     Entry e = new Entry();\r
50     e.setApp(app);\r
51     e.setAction(action);\r
52     e.setUser(user);\r
53     e.setDate(new Date());\r
54     return e;\r
55   }\r
56 \r
57   public static Provenance newProvenance(Entry entry) {\r
58     Provenance list = new Provenance();\r
59     list.addEntry(entry);\r
60     return list;\r
61   }\r
62 \r
63   public static Provenance newProvenance(String user, String action) {\r
64     return newProvenance(ProvenanceStuff.newProvenanceEntry(\r
65         "vamsasApp:ExampleVamsasClient/alpha", user, action));\r
66   }\r
67 \r
68   public static Provenance newProvenance(String app, String user, String action) {\r
69     return newProvenance(ProvenanceStuff.newProvenanceEntry(app, user, action));\r
70   }\r
71 \r
72 }\r