Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
XWikiDBVersion | 33 | 8 | 0% | 8 | 2 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package com.xpn.xwiki.store.migration; | |
21 | ||
22 | /** | |
23 | * Stores XWiki's data version in the database. Used to find out which migrations to execute based on the current data | |
24 | * version in the Database (each migration says which minimal version it requires to execute). | |
25 | * <p> | |
26 | * The version scheme in the past was to use the SVN revision number of the commit of the migrator but since we've now | |
27 | * moved to Git we're now using an integer matching the current XWiki version and allowing for a range of 1000 | |
28 | * migrations. So if you're writing the first migrator for version 5.2 of XWiki then the version will be 52000. If | |
29 | * you're writing the 2nd migration for XWiki 5.2 then its version would be 52001, etc. | |
30 | * | |
31 | * @version $Id: f7d837eee58ca94c8e3f0888aa71fddda058689c $ | |
32 | */ | |
33 | public class XWikiDBVersion implements Comparable<XWikiDBVersion> | |
34 | { | |
35 | /** svn revision number. */ | |
36 | private int version; | |
37 | ||
38 | /** Default constructor. It is need for Hibernate. */ | |
39 | 26 | public XWikiDBVersion() |
40 | { | |
41 | } | |
42 | ||
43 | /** @param version - data version */ | |
44 | 3703 | public XWikiDBVersion(int version) |
45 | { | |
46 | 3703 | this.version = version; |
47 | } | |
48 | ||
49 | /** @return data version */ | |
50 | 93044 | public int getVersion() |
51 | { | |
52 | 93055 | return this.version; |
53 | } | |
54 | ||
55 | /** @param version - data version */ | |
56 | 64 | protected void setVersion(int version) |
57 | { | |
58 | 64 | this.version = version; |
59 | } | |
60 | ||
61 | 46503 | @Override |
62 | public int compareTo(XWikiDBVersion o) | |
63 | { | |
64 | 46506 | if (o == null) { |
65 | 8 | return -1; |
66 | } | |
67 | 46491 | return Integer.valueOf(getVersion()).compareTo(o.getVersion()); |
68 | } | |
69 | ||
70 | 1586 | @Override |
71 | public String toString() | |
72 | { | |
73 | 1586 | return String.valueOf(this.version); |
74 | } | |
75 | ||
76 | /** @return next version */ | |
77 | 0 | public XWikiDBVersion increment() |
78 | { | |
79 | 0 | return new XWikiDBVersion(getVersion() + 1); |
80 | } | |
81 | } |