Revision 2695 org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.lib/org.gvsig.vcsgis.lib.impl/src/main/java/org/gvsig/vcsgis/repository/localdb/tables/RevisionsRepoTable.java
RevisionsRepoTable.java | ||
---|---|---|
9 | 9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
10 | 10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 | 11 |
import org.gvsig.tools.dataTypes.DataTypes; |
12 |
import org.gvsig.tools.dispose.DisposableIterable; |
|
12 | 13 |
import org.gvsig.tools.dispose.DisposeUtils; |
14 |
import org.gvsig.vcsgis.client.tables.LocalRevisionsTable; |
|
15 |
import org.gvsig.vcsgis.lib.client.VCSGisClientManager; |
|
16 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
|
17 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository.RepositoryRevision; |
|
13 | 18 |
import org.gvsig.vcsgis.repository.localdb.VCSGisRepositoryLocaldb; |
19 |
import static org.gvsig.vcsgis.repository.localdb.tables.DataRepoTable.TABLE_NAME; |
|
14 | 20 |
|
15 | 21 |
/** |
16 | 22 |
* |
... | ... | |
22 | 28 |
|
23 | 29 |
private static final String COD_REVISION = "COD_REVISION"; |
24 | 30 |
private static final String COD_USER = "COD_USER"; |
31 |
private static final String COD_ENTITY = "COD_ENTITY"; |
|
25 | 32 |
private static final String REVISION_NUMBER = "REV_NUMBER"; |
26 | 33 |
private static final String REVISION_COMMENT = "REV_COMMENT"; |
27 | 34 |
private static final String REVISION_EFECTIVEDATE = "REV_EFECTIVEDATE"; |
28 | 35 |
private static final String REVISION_OPERATIONDATE = "REV_OPERATIONDATE"; |
29 | 36 |
private static final String REVISION_TAGS = "REV_TAGS"; |
30 | 37 |
|
31 |
public static class RevisionRepoRow extends AbstractRow { |
|
38 |
public static class RevisionRepoRow extends AbstractRow implements RepositoryRevision{
|
|
32 | 39 |
|
33 | 40 |
public RevisionRepoRow(VCSGisRepositoryLocaldb repository) { |
34 | 41 |
super(repository, TABLE_NAME, COD_REVISION, null); |
... | ... | |
41 | 48 |
public String getUserCode() { |
42 | 49 |
return this.feature.getString(COD_USER); |
43 | 50 |
} |
51 |
|
|
52 |
@Override |
|
53 |
public String getRevisionCode() { |
|
54 |
return this.getCode(); |
|
55 |
} |
|
44 | 56 |
|
45 |
public Timestamp getOperationDate() {
|
|
57 |
public Timestamp getRevisionDate() {
|
|
46 | 58 |
return (Timestamp) this.feature.getTimestamp(REVISION_OPERATIONDATE); |
47 | 59 |
} |
48 | 60 |
|
... | ... | |
73 | 85 |
this.feature.set(REVISION_EFECTIVEDATE, date); |
74 | 86 |
} |
75 | 87 |
|
76 |
public void setOperationDate(java.util.Date date) {
|
|
88 |
public void setRevisionDate(java.util.Date date) {
|
|
77 | 89 |
Timestamp tm = new Timestamp(date.getTime()); |
78 | 90 |
this.feature.set(REVISION_OPERATIONDATE, tm); |
79 | 91 |
} |
... | ... | |
119 | 131 |
this.calculateRevisionNumber(); |
120 | 132 |
super.insert(); |
121 | 133 |
} |
134 |
|
|
135 |
public void setEntityCode(String code) { |
|
136 |
this.feature.set(COD_ENTITY, code); |
|
137 |
|
|
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
public String getLabel() { |
|
142 |
return "r"+this.getNumber(); |
|
143 |
} |
|
144 |
|
|
145 |
@Override |
|
146 |
public RevisionRepoRow getValue() { |
|
147 |
return this; |
|
148 |
} |
|
149 |
|
|
150 |
@Override |
|
151 |
public String toString() { |
|
152 |
return "r"+this.getNumber(); |
|
153 |
} |
|
154 |
|
|
122 | 155 |
|
156 |
|
|
123 | 157 |
|
124 | 158 |
} |
125 | 159 |
|
... | ... | |
158 | 192 |
.setAllowIndexDuplicateds(true) |
159 | 193 |
.setSize(40) |
160 | 194 |
.setLabel("Cod. user"); |
195 |
ft.add(COD_ENTITY, DataTypes.STRING) |
|
196 |
.setIsIndexed(true) |
|
197 |
.setAllowIndexDuplicateds(true) |
|
198 |
.setSize(40) |
|
199 |
.setLabel("Cod. entity"); |
|
161 | 200 |
ft.add(REVISION_OPERATIONDATE, DataTypes.TIMESTAMP) |
162 | 201 |
.setIsIndexed(true) |
163 | 202 |
.setAllowIndexDuplicateds(true) |
... | ... | |
183 | 222 |
public RevisionsRepoTable(String tableName, FeatureType featureType) { |
184 | 223 |
super(tableName, featureType); |
185 | 224 |
} |
225 |
|
|
226 |
public DisposableIterable<Feature> getAllRevisions(VCSGisRepositoryLocaldb repository, String entityCode) { |
|
227 |
FeatureStore store = null; |
|
228 |
DisposableIterable<Feature> features = null; |
|
229 |
try { |
|
230 |
|
|
231 |
store = repository.openFeatureStore(TABLE_NAME, null); |
|
232 |
FeatureSet fset = store.getFeatureSet("\""+COD_ENTITY+"\"='"+entityCode+"'"); |
|
233 |
features = fset.iterable(); |
|
234 |
return features; |
|
235 |
} catch (Exception ex) { |
|
236 |
DisposeUtils.disposeQuietly(features); |
|
237 |
throw new RuntimeException("Can't retrieve revisions of 'ENTITY["+entityCode+"].", ex); |
|
238 |
} finally { |
|
239 |
if( store!=null ) { |
|
240 |
DisposeUtils.dispose(store); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
186 | 245 |
|
187 | 246 |
} |
Also available in: Unified diff