Skip to content

Commit 0c88311

Browse files
committed
fix #270 - expose bitemporal system time
1 parent 258db2d commit 0c88311

File tree

7 files changed

+221
-72
lines changed

7 files changed

+221
-72
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2012-2015 MarkLogic Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.marklogic.client.bitemporal;
17+
18+
import java.util.Calendar;
19+
import com.marklogic.client.document.DocumentDescriptor;
20+
21+
public interface TemporalDescriptor extends DocumentDescriptor {
22+
/**
23+
* Returns the URI identifier for the database document.
24+
* @return the document URI
25+
*/
26+
public String getUri();
27+
28+
/**
29+
* Returns the temporal system time when the document was written or deleted.
30+
* @return the temporal system time
31+
*/
32+
public Calendar getTemporalSystemTime();
33+
}

src/main/java/com/marklogic/client/bitemporal/TemporalDocumentManager.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.marklogic.client.ForbiddenUserException;
2020
import com.marklogic.client.ResourceNotFoundException;
2121
import com.marklogic.client.Transaction;
22+
import com.marklogic.client.bitemporal.TemporalDescriptor;
2223
import com.marklogic.client.document.DocumentDescriptor;
2324
import com.marklogic.client.document.DocumentManager;
2425
import com.marklogic.client.document.DocumentUriTemplate;
@@ -42,9 +43,10 @@ public interface TemporalDocumentManager<R extends AbstractReadHandle, W extends
4243
* @param transaction an open transaction under which the document may have been created or deleted
4344
* @param temporalCollection the name of the temporal collection existing in the database into
4445
* which this document should be written
45-
* @return the database uri that identifies the created document
46+
* @return the TemporalDescriptor including the database uri that identifies the created document,
47+
* as well as the temporal system time when the document was created
4648
*/
47-
public DocumentDescriptor create(DocumentUriTemplate template,
49+
public TemporalDescriptor create(DocumentUriTemplate template,
4850
DocumentMetadataWriteHandle metadataHandle,
4951
W contentHandle,
5052
ServerTransform transform,
@@ -65,8 +67,9 @@ public DocumentDescriptor create(DocumentUriTemplate template,
6567
* @param transaction an open transaction under which the document may have been created or deleted
6668
* @param temporalCollection the name of the temporal collection existing in the database into
6769
* which this document should be written
70+
* @return the TemporalDescriptor with the temporal system time when the document was written
6871
*/
69-
public void write(DocumentDescriptor desc,
72+
public TemporalDescriptor write(DocumentDescriptor desc,
7073
DocumentMetadataWriteHandle metadataHandle,
7174
W contentHandle,
7275
ServerTransform transform,
@@ -87,8 +90,9 @@ public void write(DocumentDescriptor desc,
8790
* @param transaction an open transaction under which the document may have been created or deleted
8891
* @param temporalCollection the name of the temporal collection existing in the database into
8992
* which this document should be written
93+
* @return the TemporalDescriptor with the temporal system time when the document was written
9094
*/
91-
public void write(String docId,
95+
public TemporalDescriptor write(String docId,
9296
DocumentMetadataWriteHandle metadataHandle,
9397
W contentHandle,
9498
ServerTransform transform,
@@ -105,8 +109,9 @@ public void write(String docId,
105109
* @param transaction an open transaction under which the document may have been created or deleted
106110
* @param temporalCollection the name of the temporal collection existing in the database in
107111
* which this document should be marked as deleted
112+
* @return the TemporalDescriptor with the temporal system time when the document was deleted
108113
*/
109-
public void delete(DocumentDescriptor desc,
114+
public TemporalDescriptor delete(DocumentDescriptor desc,
110115
Transaction transaction,
111116
String temporalCollection)
112117
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException;
@@ -120,8 +125,9 @@ public void delete(DocumentDescriptor desc,
120125
* @param transaction an open transaction under which the document may have been created or deleted
121126
* @param temporalCollection the name of the temporal collection existing in the database in
122127
* which this document should be marked as deleted
128+
* @return the TemporalDescriptor with the temporal system time when the document was deleted
123129
*/
124-
public void delete(String docId,
130+
public TemporalDescriptor delete(String docId,
125131
Transaction transaction,
126132
String temporalCollection)
127133
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException;
@@ -139,9 +145,10 @@ public void delete(String docId,
139145
* @param temporalCollection the name of the temporal collection existing in the database into
140146
* which this document should be written
141147
* @param systemTime the application-specified system time with which this document will be marked
142-
* @return the database uri that identifies the created document
148+
* @return the database uri that identifies the created document,
149+
* as well as the temporal system time when the document was created
143150
*/
144-
public DocumentDescriptor create(DocumentUriTemplate template,
151+
public TemporalDescriptor create(DocumentUriTemplate template,
145152
DocumentMetadataWriteHandle metadataHandle,
146153
W contentHandle,
147154
ServerTransform transform,
@@ -162,8 +169,9 @@ public DocumentDescriptor create(DocumentUriTemplate template,
162169
* @param temporalCollection the name of the temporal collection existing in the database into
163170
* which this document should be written
164171
* @param systemTime the application-specified system time with which this document will be marked
172+
* @return the TemporalDescriptor with the temporal system time when the document was written
165173
*/
166-
public void write(DocumentDescriptor desc,
174+
public TemporalDescriptor write(DocumentDescriptor desc,
167175
DocumentMetadataWriteHandle metadataHandle,
168176
W contentHandle,
169177
ServerTransform transform,
@@ -184,8 +192,9 @@ public void write(DocumentDescriptor desc,
184192
* @param temporalCollection the name of the temporal collection existing in the database into
185193
* which this document should be written
186194
* @param systemTime the application-specified system time with which this document will be marked
195+
* @return the TemporalDescriptor with the temporal system time when the document was written
187196
*/
188-
public void write(String docId,
197+
public TemporalDescriptor write(String docId,
189198
DocumentMetadataWriteHandle metadataHandle,
190199
W contentHandle,
191200
ServerTransform transform,
@@ -202,8 +211,9 @@ public void write(String docId,
202211
* @param temporalCollection the name of the temporal collection existing in the database in
203212
* which this document should be marked as deleted
204213
* @param systemTime the application-specified system time with which this document will be marked
214+
* @return the TemporalDescriptor with the temporal system time when the document was deleted
205215
*/
206-
public void delete(DocumentDescriptor desc,
216+
public TemporalDescriptor delete(DocumentDescriptor desc,
207217
Transaction transaction,
208218
String temporalCollection,
209219
java.util.Calendar systemTime)
@@ -217,8 +227,9 @@ public void delete(DocumentDescriptor desc,
217227
* @param temporalCollection the name of the temporal collection existing in the database in
218228
* which this document should be marked as deleted
219229
* @param systemTime the application-specified system time with which this document will be marked
230+
* @return the TemporalDescriptor with the temporal system time when the document was deleted
220231
*/
221-
public void delete(String docId,
232+
public TemporalDescriptor delete(String docId,
222233
Transaction transaction,
223234
String temporalCollection,
224235
java.util.Calendar systemTime)

src/main/java/com/marklogic/client/impl/DocumentDescriptorImpl.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@
1515
*/
1616
package com.marklogic.client.impl;
1717

18+
import java.util.Calendar;
19+
20+
import com.marklogic.client.bitemporal.TemporalDescriptor;
1821
import com.marklogic.client.document.DocumentDescriptor;
1922
import com.marklogic.client.io.Format;
2023

21-
public class DocumentDescriptorImpl implements DocumentDescriptor {
24+
public class DocumentDescriptorImpl implements DocumentDescriptor, TemporalDescriptor {
2225
private String uri;
2326
private Format format;
2427
private String mimetype;
2528
private long byteLength = UNKNOWN_LENGTH;
2629
private long version = UNKNOWN_VERSION;
2730
private boolean isInternal = false;
31+
private Calendar temporalSystemTime;
2832

2933
public DocumentDescriptorImpl(boolean isInternal) {
3034
super();
@@ -93,4 +97,13 @@ protected void setInternal(boolean isInternal) {
9397
protected boolean isInternal() {
9498
return isInternal;
9599
}
100+
101+
@Override
102+
public Calendar getTemporalSystemTime() {
103+
return temporalSystemTime;
104+
}
105+
106+
protected void setTemporalSystemTime(Calendar dateTime) {
107+
this.temporalSystemTime = dateTime;
108+
}
96109
}

0 commit comments

Comments
 (0)